| | |
| | | use app\common\enum\user\balanceLog\BalanceLogSceneEnum; |
| | | use app\common\model\user\BalanceLog as BalanceLogModel; |
| | | use app\common\service\BaseService; |
| | | use app\common\model\plus\business\Business as BusinessModel; |
| | | use app\common\model\plus\business\Setting as SettingModel; |
| | | use app\api\model\user\PointsLog as PointsLogModel; |
| | | |
| | | /** |
| | | * 名片订单支付成功后的回调 |
| | |
| | | return false; |
| | | } |
| | | } |
| | | // 验证余额支付时用户余额是否满足 |
| | | if ($payType == OrderPayTypeEnum::POINTS) { |
| | | if ($this->user['points'] < $this->model['pay_price']) { |
| | | $this->error = '用户联盟币不足,无法使用联盟币支付'; |
| | | return false; |
| | | } |
| | | } |
| | | // 事务处理 |
| | | $this->model->transaction(function () use ($payType, $payData) { |
| | | // 更新订单状态 |
| | | $this->updateOrderInfo($payType, $payData); |
| | | // 累积用户总消费金额 |
| | | $this->user->setIncPayMoney($this->model['pay_price']); |
| | | if ($payType != OrderPayTypeEnum::POINTS) { |
| | | // 累积用户总消费金额 |
| | | $this->user->setIncPayMoney($this->model['pay_price']); |
| | | } |
| | | |
| | | // 记录订单支付信息 |
| | | $this->updatePayInfo($payType); |
| | | // 如果是置顶订单,更新名片置顶状态 |
| | | if ($this->model['order_source'] == 20) { |
| | | $this->updateBusinessCardTopStatus(); |
| | | } |
| | | }); |
| | | return true; |
| | | } |
| | |
| | | 'user_id' => $this->user['user_id'], |
| | | 'money' => -$this->model['pay_price'], |
| | | ], ['order_no' => $this->model['order_no']]); |
| | | }elseif ($payType == OrderPayTypeEnum::POINTS && $this->model['pay_price'] > 0) { |
| | | // 更新用户联盟币 |
| | | $this->user->where('user_id', '=', $this->user['user_id']) |
| | | ->dec('points', $this->model['pay_price']) |
| | | ->update(); |
| | | $describe=$this->model['order_source'] == 20?'用户购买名片置顶服务':'用户购买名片服务'; |
| | | PointsLogModel::add([ |
| | | 'user_id' => $this->user['user_id'], |
| | | 'value' => $this->model['pay_price'], |
| | | 'describe' =>$describe." 订单号:{$this->model['order_no']}", |
| | | 'remark' => '', |
| | | ]); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新名片置顶状态 |
| | | */ |
| | | private function updateBusinessCardTopStatus() |
| | | { |
| | | // 获取置顶设置 |
| | | $setting = SettingModel::getItem('basic'); |
| | | $topDays = isset($setting['top_days']) ? $setting['top_days'] : 7; // 默认7天 |
| | | |
| | | // 计算置顶到期时间 |
| | | $topTime = time() + ($topDays * 86400); |
| | | |
| | | // 更新名片置顶状态 |
| | | $businessCard = BusinessModel::detail($this->model['business_card_id']); |
| | | if ($businessCard) { |
| | | $businessCard->save([ |
| | | 'is_top' => 1, |
| | | 'top_time' => $topTime |
| | | ]); |
| | | } |
| | | } |
| | | /** |
| | | * 返回shop_supplier_id |
| | | * $pay_status 兼容支付宝支付 |
| | | */ |
| | | public function isExistSupplier() |
| | | { |
| | | return 0; |
| | | } |
| | | } |