|
|
|
@ -14,7 +14,6 @@ namespace app\api\service\identity; |
|
|
|
|
|
|
|
|
|
use app\api\model\PaymentTrade as PaymentTradeModel; |
|
|
|
|
use app\api\model\recharge\Order as OrderModel; |
|
|
|
|
use app\api\model\Server\ServerOrder; |
|
|
|
|
use app\api\model\User as UserModel; |
|
|
|
|
use app\api\model\user\BalanceLog as BalanceLogModel; |
|
|
|
|
use app\api\model\user\IdentityOrder; |
|
|
|
@ -22,9 +21,12 @@ use app\common\enum\order\PayStatus; |
|
|
|
|
use app\common\enum\payment\Method as PaymentMethodEnum; |
|
|
|
|
use app\common\enum\recharge\order\PayStatus as PayStatusEnum; |
|
|
|
|
use app\common\enum\user\balanceLog\Scene as SceneEnum; |
|
|
|
|
use app\common\enum\user\IdentityEnum; |
|
|
|
|
use app\common\enum\user\UserTypeEnum; |
|
|
|
|
use app\common\library\Lock; |
|
|
|
|
use app\common\library\Log; |
|
|
|
|
use app\common\service\BaseService; |
|
|
|
|
use app\store\model\dealer\User; |
|
|
|
|
use cores\exception\BaseException; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -35,7 +37,7 @@ use cores\exception\BaseException; |
|
|
|
|
class PaySuccess extends BaseService |
|
|
|
|
{ |
|
|
|
|
// 当前订单信息 |
|
|
|
|
public ServerOrder $orderInfo; |
|
|
|
|
public IdentityOrder $orderInfo; |
|
|
|
|
|
|
|
|
|
// 当前用户信息 |
|
|
|
|
private UserModel $userInfo; |
|
|
|
@ -44,7 +46,7 @@ class PaySuccess extends BaseService |
|
|
|
|
private string $orderNo; |
|
|
|
|
|
|
|
|
|
// 当前订单ID |
|
|
|
|
private string $orderId; |
|
|
|
|
private int $orderId; |
|
|
|
|
|
|
|
|
|
// 订单支付方式 |
|
|
|
|
private string $method; |
|
|
|
@ -59,7 +61,7 @@ class PaySuccess extends BaseService |
|
|
|
|
* 设置支付的订单ID |
|
|
|
|
* @param int $orderId 订单ID |
|
|
|
|
*/ |
|
|
|
|
public function setOrderId(int $orderId): \app\api\service\Server\PaySuccess |
|
|
|
|
public function setOrderId(int $orderId): PaySuccess |
|
|
|
|
{ |
|
|
|
|
$this->orderId = $orderId; |
|
|
|
|
return $this; |
|
|
|
@ -182,9 +184,12 @@ class PaySuccess extends BaseService |
|
|
|
|
UserModel::setIncPayMoney($orderInfo['user_id'], (float)$orderInfo['pay_price']); |
|
|
|
|
// 记录订单支付信息 |
|
|
|
|
$this->updatePayInfo(); |
|
|
|
|
//更改会员角色 |
|
|
|
|
$this->activate(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 记录订单支付的信息 |
|
|
|
|
* @throws BaseException |
|
|
|
@ -333,4 +338,38 @@ class PaySuccess extends BaseService |
|
|
|
|
$orderInfo = $this->getOrderInfo(); |
|
|
|
|
Lock::unLock("OrderPaySuccess_{$orderInfo['order_id']}"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function activate(): void |
|
|
|
|
{ |
|
|
|
|
$orderInfo = $this->orderInfo; |
|
|
|
|
$userInfo = $this->userInfo; |
|
|
|
|
//判断当前用户角色 |
|
|
|
|
$orderType = $orderInfo['type']; |
|
|
|
|
$userType = $userInfo['user_type']; |
|
|
|
|
if ($userType == UserTypeEnum::STORE) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
$userModel = new UserModel(); |
|
|
|
|
$up = []; |
|
|
|
|
$time = date('Y-m-d'); |
|
|
|
|
if (!empty($userInfo['effective_time']) && strtotime($userInfo['effective_time']) > strtotime(date('Y-m-d'))) { |
|
|
|
|
$time = $userInfo['effective_time']; |
|
|
|
|
} |
|
|
|
|
//已经是会员或者未开通会员 |
|
|
|
|
if ($orderType == IdentityEnum::MEMBER && $userType != UserTypeEnum::DEALER) { |
|
|
|
|
$up['user_type'] = UserTypeEnum::MEMBER; |
|
|
|
|
} else { |
|
|
|
|
//分销商 |
|
|
|
|
$up['user_type'] = UserTypeEnum::DEALER; |
|
|
|
|
if (!User::isDealerUser($userInfo['user_id'])) { |
|
|
|
|
// 新增分销商用户 |
|
|
|
|
User::add($userInfo['user_id'], [ |
|
|
|
|
'real_name' => $userInfo['mobile'], |
|
|
|
|
'mobile' => $userInfo['mobile'], |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$up['effective_time'] = date("Y-m-d", strtotime("+{$orderInfo['month']} months", strtotime($time))); |
|
|
|
|
$userModel->where(['user_id' => $userInfo['user_id']])->save($up); |
|
|
|
|
} |
|
|
|
|
} |