|
|
@@ -583,6 +583,30 @@ class Checkout
|
|
|
if (!$this->validateOrderForm($order, $this->param['linkman'], $this->param['phone'])) {
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+ // 检查是否购买的低级别升级套餐
|
|
|
+ if($this->model['is_upgrade']==1){
|
|
|
+ // 是否存在未确认的升级产品
|
|
|
+ if(Order::where(['user_id'=> $this->model['user_id'],'order_status'=>10,'is_upgrade'=>1])->value('order_id')){
|
|
|
+ $this->error = '您有未处理完成的升级商品订单,请先处理';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $grade = User::alias('a')
|
|
|
+ ->where(['a.user_id'=> $this->model['user_id'],'a.wxapp_id'=>$this->model['wxapp_id']])
|
|
|
+ ->join('user_grade ug','ug.grade_id=a.grade_id','left')
|
|
|
+ ->field('a.user_id,ug.upgrade')
|
|
|
+ ->find();
|
|
|
+
|
|
|
+ $grade = $grade?$grade->toArray() : [];
|
|
|
+ $upgrade = isset($grade['upgrade']) && !is_array($grade['upgrade'])? json_decode($grade['upgrade'], true) : [];
|
|
|
+ $upgradeMoney = isset($upgrade['expend_money'])?$upgrade['expend_money'] : 0;
|
|
|
+ if($upgradeMoney>=$this->model['total_price']){
|
|
|
+ $this->error = '当前级别不能购买低级别套餐';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 创建新的订单
|
|
|
$status = $this->model->transaction(function () use ($order) {
|
|
|
// 创建订单事件
|
|
|
@@ -590,49 +614,26 @@ class Checkout
|
|
|
});
|
|
|
// 余额支付标记订单已支付
|
|
|
if ($status && $order['pay_type'] == PayTypeEnum::BALANCE) {
|
|
|
+
|
|
|
// 验证密码
|
|
|
- $payPassword = input('pay_password','');
|
|
|
- if(empty($payPassword)){
|
|
|
+ $payPassword = input('pay_password', '');
|
|
|
+ if (empty($payPassword)) {
|
|
|
$this->error = '请填写支付密码';
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- $userPayPassword = User::where(['user_id'=> $this->model['user_id'],'wxapp_id'=>$this->model['wxapp_id']])
|
|
|
+ $userPayPassword = User::where(['user_id' => $this->model['user_id'], 'wxapp_id' => $this->model['wxapp_id']])
|
|
|
->value('pay_password');
|
|
|
- if(empty($userPayPassword)){
|
|
|
+ if (empty($userPayPassword)) {
|
|
|
$this->error = '请先设置支付密码';
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if(makePassword($payPassword) != $userPayPassword){
|
|
|
+ if (makePassword($payPassword) != $userPayPassword) {
|
|
|
$this->error = '支付密码错误';
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // 是否存在未确认的升级产品
|
|
|
- if(Order::where(['user_id'=> $this->model['user_id'],'order_status'=>10,'is_upgrade'=>1])->value('order_id')){
|
|
|
- $this->error = '您有未处理完成的升级商品订单,请先处理';
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- // 检查是否购买的低级别升级套餐
|
|
|
- if($this->model['is_upgrade']==1){
|
|
|
- $grade = User::alias('a')
|
|
|
- ->where(['a.user_id'=> $this->model['user_id'],'a.wxapp_id'=>$this->model['wxapp_id']])
|
|
|
- ->join('user_grade ug','ug.grade_id=a.grade_id','left')
|
|
|
- ->field('a.user_id,ug.upgrade')
|
|
|
- ->find();
|
|
|
-
|
|
|
- $grade = $grade?$grade->toArray() : [];
|
|
|
- $upgrade = isset($grade['upgrade']) && !is_array($grade['upgrade'])? json_decode($grade['upgrade'], true) : [];
|
|
|
- $upgradeMoney = isset($upgrade['expend_money'])?$upgrade['expend_money'] : 0;
|
|
|
- if($upgradeMoney>=$this->model['total_price']){
|
|
|
- $this->error = '当前级别不能购买低级别套餐';
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
return $this->model->onPaymentByBalance($this->model['order_no']);
|
|
|
}
|
|
|
return $status;
|