|
|
|
@ -28,6 +28,7 @@ use app\common\library\Log; |
|
|
|
|
use app\common\service\BaseService; |
|
|
|
|
use app\store\model\dealer\User; |
|
|
|
|
use cores\exception\BaseException; |
|
|
|
|
use think\facade\Db; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 余额充值订单支付成功服务类 |
|
|
|
@ -126,12 +127,16 @@ class PaySuccess extends BaseService |
|
|
|
|
*/ |
|
|
|
|
public function handle(): bool |
|
|
|
|
{ |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => '开始处理业务', 'created_at' => date('Y-m-d H:i:s')]); |
|
|
|
|
// 验证当前参数是否合法 |
|
|
|
|
$this->verifyParameters(); |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => '数据合法', 'created_at' => date('Y-m-d H:i:s')]); |
|
|
|
|
// 当前订单开启并发锁 |
|
|
|
|
$this->lockUp(); |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => '准备修改订单', 'created_at' => date('Y-m-d H:i:s')]); |
|
|
|
|
// 验证当前订单是否允许支付 |
|
|
|
|
if ($this->checkOrderStatusOnPay()) { |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => '修改订单开始', 'created_at' => date('Y-m-d H:i:s')]); |
|
|
|
|
// 更新订单状态为已付款 |
|
|
|
|
$this->updatePayStatus(); |
|
|
|
|
} |
|
|
|
@ -184,10 +189,12 @@ class PaySuccess extends BaseService |
|
|
|
|
Log::append('PaySuccess --updatePayStatus', ['title' => '订单已付款事件']); |
|
|
|
|
// 当前订单信息 |
|
|
|
|
$orderInfo = $this->getOrderInfo(); |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => json_encode($orderInfo), 'created_at' => date('Y-m-d H:i:s')]); |
|
|
|
|
// 事务处理 |
|
|
|
|
$this->orderModel()->transaction(function () use ($orderInfo) { |
|
|
|
|
// 更新订单状态 |
|
|
|
|
$this->updateOrderStatus(); |
|
|
|
|
Db::table('yoshop_wx_server')->insertGetId(['content' => '修改订单开始11111', 'created_at' => date('Y-m-d H:i:s')]); |
|
|
|
|
// 累积用户总消费金额 |
|
|
|
|
UserModel::setIncPayMoney($orderInfo['user_id'], (float)$orderInfo['pay_price']); |
|
|
|
|
// 记录订单支付信息 |
|
|
|
|