|
|
|
@ -344,27 +344,36 @@ class PaySuccess extends BaseService |
|
|
|
|
// 当前订单信息 |
|
|
|
|
$orderInfo = $this->getOrderInfo(); |
|
|
|
|
// 余额支付 |
|
|
|
|
if ($this->method == PaymentMethodEnum::BALANCE) { |
|
|
|
|
// 更新用户余额 |
|
|
|
|
UserModel::setDecBalance((int)$orderInfo['user_id'], (float)$orderInfo['pay_price']); |
|
|
|
|
// 新增余额变动记录 |
|
|
|
|
BalanceLogModel::add(SceneEnum::CONSUME, [ |
|
|
|
|
'user_id' => (int)$orderInfo['user_id'], |
|
|
|
|
'money' => -$orderInfo['pay_price'], |
|
|
|
|
], ['order_no' => $orderInfo['order_no']]); |
|
|
|
|
if ($this->method == PaymentMethodEnum::BALANCE || $this->method == PaymentMethodEnum::HUIFU) { |
|
|
|
|
if ($this->method == PaymentMethodEnum::BALANCE) { |
|
|
|
|
// 更新用户余额 |
|
|
|
|
UserModel::setDecBalance((int)$orderInfo['user_id'], (float)$orderInfo['pay_price']); |
|
|
|
|
// 新增余额变动记录 |
|
|
|
|
BalanceLogModel::add(SceneEnum::CONSUME, [ |
|
|
|
|
'user_id' => (int)$orderInfo['user_id'], |
|
|
|
|
'money' => -$orderInfo['pay_price'], |
|
|
|
|
], ['order_no' => $orderInfo['order_no']]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //增加商户支付详情 |
|
|
|
|
// $model = \app\store\model\Merchant::detail($orderInfo['merchant_id']); |
|
|
|
|
// $precent = 1; |
|
|
|
|
if ($orderInfo['merchant_id']) { |
|
|
|
|
//增加商户支付详情 |
|
|
|
|
$model = \app\store\model\Merchant::detail($orderInfo['merchant_id']); |
|
|
|
|
if ($model) { |
|
|
|
|
$precent = 1; |
|
|
|
|
|
|
|
|
|
// if ($model['commission_ratio']) { |
|
|
|
|
// $precent = (1 - $model['commission_ratio'] / 1000); |
|
|
|
|
// } |
|
|
|
|
// $precentPrice = round($precent * $orderInfo['pay_price'], 2); |
|
|
|
|
// (new merchantPayModel())->addDetail($orderInfo, $precentPrice); |
|
|
|
|
if ($model['commission_ratio']) { |
|
|
|
|
$precent = (1 - $model['commission_ratio'] / 1000); |
|
|
|
|
} |
|
|
|
|
$precentPrice = round($precent * $orderInfo['pay_price'], 2); |
|
|
|
|
(new merchantPayModel())->addDetail($orderInfo, $precentPrice, $this->method == PaymentMethodEnum::HUIFU ? 1 : 0); |
|
|
|
|
|
|
|
|
|
// //累计商户余额支付金额 |
|
|
|
|
// merchantModel::setIncTotal($orderInfo['merchant_id'], $precentPrice); |
|
|
|
|
//累计商户余额支付金额 |
|
|
|
|
merchantModel::setIncTotal($orderInfo['merchant_id'], $precentPrice); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
// 将第三方交易记录更新为已支付状态 |
|
|
|
|
if (in_array($this->method, [PaymentMethodEnum::WECHAT, PaymentMethodEnum::ALIPAY, PaymentMethodEnum::HUIFU])) { |
|
|
|
|