From 66b0783408f42263250fe9d9086d299a8497c480 Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Sun, 24 Mar 2024 17:19:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A7=AF=E5=88=86=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E6=96=B9=E5=BC=8F=E5=92=8C=E7=A7=AF=E5=88=86=E5=85=85?= =?UTF-8?q?=E5=80=BC=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/shopro/controller/Pay.php | 19 ++++++++++++++++++- addons/shopro/job/trade/OrderPaid.php | 7 +++++++ addons/shopro/service/CommissionScoreLog.php | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/addons/shopro/controller/Pay.php b/addons/shopro/controller/Pay.php index a4304d4..b74f19a 100755 --- a/addons/shopro/controller/Pay.php +++ b/addons/shopro/controller/Pay.php @@ -54,7 +54,7 @@ class Pay extends Common $this->error('已下单成功'); } - if (!$payment || !in_array($payment, ['wechat', 'alipay', 'money', 'offline'])) { + if (!$payment || !in_array($payment, ['wechat', 'alipay', 'money', 'offline','score'])) { $this->error('支付类型不能为空'); } @@ -115,6 +115,23 @@ class Pay extends Common $this->success('订单支付成功', $order); } + //商城订单积分支付 + if ($payment == 'score' && $order_type == 'order') { + // 积分支付 + $order = Db::transaction(function () use ($payOper, $order, $order_type) { + // 加锁读订单 + $order = $order->lock(true)->find($order->id); + + $order = $payOper->score($order, $order->remain_pay_fee, $order_type); + + return $order; + }); + if ($order->status != $order::STATUS_PAID) { + $this->error('订单支付失败'); + } + $this->success('订单支付成功', $order); + } + // 微信支付宝(第三方)付款 $payModel = $payOper->{$payment}($order, $order->remain_pay_fee, $order_type); diff --git a/addons/shopro/job/trade/OrderPaid.php b/addons/shopro/job/trade/OrderPaid.php index 8a84dcf..5b57bed 100755 --- a/addons/shopro/job/trade/OrderPaid.php +++ b/addons/shopro/job/trade/OrderPaid.php @@ -47,6 +47,13 @@ class OrderPaid extends BaseJob 'order_sn' => $order->order_sn, 'order_type' => 'trade_order', ]); + + // 增加积分 + WalletService::change($user, 'score', $money, 'order_recharge', [ + 'order_id' => $order->id, + 'order_sn' => $order->order_sn, + 'order_type' => 'trade_order', + ]); } if ($gift > 0) { diff --git a/addons/shopro/service/CommissionScoreLog.php b/addons/shopro/service/CommissionScoreLog.php index ba3d460..3a3db9d 100644 --- a/addons/shopro/service/CommissionScoreLog.php +++ b/addons/shopro/service/CommissionScoreLog.php @@ -29,6 +29,6 @@ class CommissionScoreLog * 获取用户等级 */ public function getUserLevel() { - + echo 11; } } \ No newline at end of file