添加积分支付方式和积分充值功能

main
ztt 8 months ago
parent 5818086533
commit 66b0783408
  1. 19
      addons/shopro/controller/Pay.php
  2. 7
      addons/shopro/job/trade/OrderPaid.php
  3. 2
      addons/shopro/service/CommissionScoreLog.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);

@ -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) {

@ -29,6 +29,6 @@ class CommissionScoreLog
* 获取用户等级
*/
public function getUserLevel() {
echo 11;
}
}
Loading…
Cancel
Save