wang hou sheng 7 months ago
parent 6724ee3fc1
commit 8a11ac7b3b
  1. 42
      app/api/service/identity/PaySuccess.php

@ -28,7 +28,6 @@ use app\common\library\Log;
use app\common\service\BaseService; use app\common\service\BaseService;
use app\store\model\dealer\User; use app\store\model\dealer\User;
use cores\exception\BaseException; use cores\exception\BaseException;
use think\facade\Db;
/** /**
* 余额充值订单支付成功服务类 * 余额充值订单支付成功服务类
@ -186,24 +185,16 @@ class PaySuccess extends BaseService
// 当前订单信息 // 当前订单信息
$orderInfo = $this->getOrderInfo(); $orderInfo = $this->getOrderInfo();
// 事务处理 // 事务处理
// $this->orderModel()->transaction(function () use ($orderInfo) { $this->orderModel()->transaction(function () use ($orderInfo) {
// // 更新订单状态 // 更新订单状态
// $this->updateOrderStatus(); $this->updateOrderStatus();
// // 累积用户总消费金额 // 累积用户总消费金额
// UserModel::setIncPayMoney($orderInfo['user_id'], (float)$orderInfo['pay_price']); UserModel::setIncPayMoney($orderInfo['user_id'], (float)$orderInfo['pay_price']);
// // 记录订单支付信息 // 记录订单支付信息
// $this->updatePayInfo(); $this->updatePayInfo();
// //更改会员角色 //更改会员角色
// $this->activate(); $this->activate();
// }); });
// 更新订单状态
$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']}"); Lock::unLock("OrderPaySuccess_{$orderInfo['order_id']}");
} }
/**
* @notes:修改会员身份信息
* @throws BaseException
* @author: wanghousheng
*/
private function activate(): void private function activate(): void
{ {
Db::table('yoshop_wx_server')->insertGetId(['content' => '修改会员信息开始', 'created_at' => date('Y-m-d H:i:s')]);
$orderInfo = $this->getOrderInfo(); $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(); $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']; $orderType = $orderInfo['order_type'];
$userType = $userInfo['user_type']; $userType = $userInfo['user_type'];
if ($userType == UserTypeEnum::STORE) { if ($userType == UserTypeEnum::STORE) {
return; return;
} }
Db::table('yoshop_wx_server')->insertGetId(['content' => '修改会员信息开始222222', 'created_at' => date('Y-m-d H:i:s')]);
$userModel = new UserModel(); $userModel = new UserModel();
$up = []; $up = [];
$time = date('Y-m-d'); $time = date('Y-m-d');
//已经是会员或者未开通会员 //已经是会员或者未开通会员
if ($orderType == IdentityEnum::MEMBER && $userType != UserTypeEnum::DEALER) { if ($orderType == IdentityEnum::MEMBER && $userType != UserTypeEnum::DEALER) {
$up['user_type'] = UserTypeEnum::MEMBER; $up['user_type'] = UserTypeEnum::MEMBER;
//已经是会员 //已经是会员
if ($userType == 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))); $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); $userModel->where(['user_id' => $userInfo['user_id']])->save($up);
} }
} }
Loading…
Cancel
Save