From 8a11ac7b3b1b8791e7165e27a856676632595d5c Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Sun, 21 Apr 2024 14:43:02 +0800 Subject: [PATCH] 1 --- app/api/service/identity/PaySuccess.php | 42 +++++++++---------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/app/api/service/identity/PaySuccess.php b/app/api/service/identity/PaySuccess.php index 1dcd1d36..c6b058f6 100644 --- a/app/api/service/identity/PaySuccess.php +++ b/app/api/service/identity/PaySuccess.php @@ -28,7 +28,6 @@ use app\common\library\Log; use app\common\service\BaseService; use app\store\model\dealer\User; use cores\exception\BaseException; -use think\facade\Db; /** * 余额充值订单支付成功服务类 @@ -186,24 +185,16 @@ class PaySuccess extends BaseService // 当前订单信息 $orderInfo = $this->getOrderInfo(); // 事务处理 -// $this->orderModel()->transaction(function () use ($orderInfo) { -// // 更新订单状态 -// $this->updateOrderStatus(); -// // 累积用户总消费金额 -// UserModel::setIncPayMoney($orderInfo['user_id'], (float)$orderInfo['pay_price']); -// // 记录订单支付信息 -// $this->updatePayInfo(); -// //更改会员角色 -// $this->activate(); -// }); - // 更新订单状态 - $this->updateOrderStatus(); - // 累积用户总消费金额 - UserModel::setIncPayMoney($orderInfo['user_id'], (float)$orderInfo['pay_price']); - // 记录订单支付信息 - $this->updatePayInfo(); - //更改会员角色 - $this->activate(); + $this->orderModel()->transaction(function () use ($orderInfo) { + // 更新订单状态 + $this->updateOrderStatus(); + // 累积用户总消费金额 + UserModel::setIncPayMoney($orderInfo['user_id'], (float)$orderInfo['pay_price']); + // 记录订单支付信息 + $this->updatePayInfo(); + //更改会员角色 + $this->activate(); + }); } @@ -360,28 +351,26 @@ class PaySuccess extends BaseService Lock::unLock("OrderPaySuccess_{$orderInfo['order_id']}"); } + /** + * @notes:修改会员身份信息 + * @throws BaseException + * @author: wanghousheng + */ private function activate(): void { - Db::table('yoshop_wx_server')->insertGetId(['content' => '修改会员信息开始', 'created_at' => date('Y-m-d H:i:s')]); $orderInfo = $this->getOrderInfo(); - Db::table('yoshop_wx_server')->insertGetId(['content' => '订单信息', 'created_at' => date('Y-m-d H:i:s')]); - Db::table('yoshop_wx_server')->insertGetId(['content' => json_encode($orderInfo), 'created_at' => date('Y-m-d H:i:s')]); $userInfo = $this->getUserInfo(); - Db::table('yoshop_wx_server')->insertGetId(['content' => '会员信息', 'created_at' => date('Y-m-d H:i:s')]); - Db::table('yoshop_wx_server')->insertGetId(['content' => json_encode($userInfo), 'created_at' => date('Y-m-d H:i:s')]); //判断当前用户角色 $orderType = $orderInfo['order_type']; $userType = $userInfo['user_type']; if ($userType == UserTypeEnum::STORE) { return; } - Db::table('yoshop_wx_server')->insertGetId(['content' => '修改会员信息开始222222', 'created_at' => date('Y-m-d H:i:s')]); $userModel = new UserModel(); $up = []; $time = date('Y-m-d'); //已经是会员或者未开通会员 if ($orderType == IdentityEnum::MEMBER && $userType != UserTypeEnum::DEALER) { - $up['user_type'] = UserTypeEnum::MEMBER; //已经是会员 if ($userType == UserTypeEnum::MEMBER) { @@ -414,7 +403,6 @@ class PaySuccess extends BaseService } $up['fx_effective_time'] = date("Y-m-d", strtotime("+{$orderInfo['month']} months", strtotime($time))); } - Db::table('yoshop_wx_server')->insertGetId(['content' => json_encode($up), 'created_at' => date('Y-m-d H:i:s')]); $userModel->where(['user_id' => $userInfo['user_id']])->save($up); } } \ No newline at end of file