diff --git a/app/api/service/order/PaySuccess.php b/app/api/service/order/PaySuccess.php index 22e0da2e..4f65e11c 100644 --- a/app/api/service/order/PaySuccess.php +++ b/app/api/service/order/PaySuccess.php @@ -356,14 +356,15 @@ class PaySuccess extends BaseService //增加商户支付详情 $model = \app\store\model\Merchant::detail($orderInfo['merchant_id']); $precent = 1; + if ($model['commission_ratio']) { $precent = (1 - $model['commission_ratio'] / 1000); } - $orderInfo['pay_price'] = (float)($precent * $orderInfo['pay_price']); - (new merchantPayModel())->addDetail($orderInfo); + $precentPrice = $precent * $orderInfo['pay_price']; + (new merchantPayModel())->addDetail($orderInfo, (float)$precentPrice); //累计商户余额支付金额 - merchantModel::setIncTotal($orderInfo['merchant_id'], (float)$orderInfo['pay_price']); + merchantModel::setIncTotal($orderInfo['merchant_id'], (float)$precentPrice); } // 将第三方交易记录更新为已支付状态 if (in_array($this->method, [PaymentMethodEnum::WECHAT, PaymentMethodEnum::ALIPAY])) { diff --git a/app/common/model/MerchantPay.php b/app/common/model/MerchantPay.php index 3e04a8d0..0725e0ee 100644 --- a/app/common/model/MerchantPay.php +++ b/app/common/model/MerchantPay.php @@ -34,14 +34,14 @@ class MerchantPay extends BaseModel * @param float $money * @return mixed */ - public function addDetail($orderInfo) + public function addDetail($orderInfo, $precentPrice) { if (!empty($orderInfo['merchant_id'])) { $data = [ 'order_id' => $orderInfo['order_id'], //'store_id' => $orderInfo['store_id'], 'merchant_id' => $orderInfo['merchant_id'], - 'total_amount' => (float)$orderInfo['pay_price'], + 'total_amount' => $precentPrice, ]; return $this->save($this->createData($data)); }