diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index 1d2a48bc..4a4f0316 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -196,7 +196,7 @@ class MerchantIntention extends BaseController $postUrl = env('TASK_WORKER_HOST_URL') . '/adminapi/company/createShopMerchant'; $res = $this->sendMerIntentionApply($sendData, $postUrl); if (!$res['ok']) { - Db::name('merchant_integntion')->where('mer_intention_id', $intentionId)->delete(); + Db::name('merchant_intention')->where('mer_intention_id', $intentionId)->delete(); throw new ValidateException('商户交易申请失败,' . $res['msg']); } Db::name('merchant')->where('uid', $this->userInfo->uid)->where('status', 1)->update(['business_status'=>1]); diff --git a/app/listener/paySuccessMargin.php b/app/listener/paySuccessMargin.php index 2068a639..bc4c208f 100644 --- a/app/listener/paySuccessMargin.php +++ b/app/listener/paySuccessMargin.php @@ -21,10 +21,16 @@ class paySuccessMargin 'paid' => 1, 'pay_time' => date('Y-m-d H:i:s') ]); - Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->inc('margin',$marginInfo['total_price']); - Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->dec('recharge_margin',$marginInfo['total_price']); $merchantInfo = Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->find(); - if ($merchantInfo['recharge_margin'] <= 0) { + $marginAmount = (float)$merchantInfo['margin'] + (float)$marginInfo['total_price']; + Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->update([ + 'margin' => $marginAmount + ]); + $rechargeAmount = (float)$marginInfo['recharge_margin'] - (float)$merchantInfo['total_price']; + Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->update([ + 'recharge_margin' => $rechargeAmount + ]); + if ($rechargeAmount <= 0) { Db::name('merchant')->where('mer_id', $marginInfo['mer_id'] ?? 0)->where('uid', $marginInfo['uid'] ?? 0)->update([ 'is_margin' => 10 ]);