Explorar el Código

xhShop 的rechargeWeal=3时,有使用红包的订单做限制

shizhongqi hace 3 meses
padre
commit
9091db7dfa
Se han modificado 2 ficheros con 26 adiciones y 0 borrados
  1. 10 0
      app-hd/controllers/OrderController.php
  2. 16 0
      app-mall/controllers/OrderController.php

+ 10 - 0
app-hd/controllers/OrderController.php

@@ -826,6 +826,16 @@ class OrderController extends BaseController
                     if ($hb->beginTime > time()) {
                         util::fail('红包可使用期未到');
                     }
+                    if ($this->shop->rechargeWeal == 3) {
+                        // 判断支付方式是否是余额支付
+                        if ($hasPay != dict::getDict('hasPay', 'balance')) {
+                            util::fail('此红包非余额支付不可用');
+                        } else {
+                            if($custom->balance < $post['modifyPrice']) {
+                                util::fail('此红包非余额支付不可用(您的余额不足)');
+                            }
+                        }
+                    }
                 } else {
                     Yii::error('没有找到红包,hbId: ', $hbId . ' ' . __METHOD__);
                     util::fail('红包无效');

+ 16 - 0
app-mall/controllers/OrderController.php

@@ -441,6 +441,16 @@ class OrderController extends BaseController
                     if ($modifyPrice < $hb->minConsume) {
                         util::fail("不满足最低消费金额{$hb->minConsume}元");
                     }
+                    if ($this->shop->rechargeWeal == 3) {
+                        // 判断支付方式是否是余额支付
+                        if($hasPay != dict::getDict('hasPay', 'balance')) {
+                            util::fail('此红包非余额支付不可用');
+                        } else {
+                            if($custom->balance < $post['modifyPrice']) {
+                                util::fail('此红包非余额支付不可用(您的余额不足)');
+                            }
+                        }
+                    }
                     $modifyPrice = bcsub($modifyPrice, $hb->amount, 2);//扣减红包
                 } else {
                     Yii::error('没有找到红包,hbId', $hbId . ' ' . __METHOD__);
@@ -763,6 +773,11 @@ class OrderController extends BaseController
                     if ($modifyPrice < $hb->minConsume) {
                         util::fail("不满足最低消费金额{$hb->minConsume}元");
                     }
+                    if ($this->shop->rechargeWeal == 3) {
+                        if($custom->balance < $modifyPrice) {
+                            util::fail('此红包非余额支付不可用(您的余额不足)');
+                        }
+                    }
                     $modifyPrice = bcsub($modifyPrice, $hb->amount, 2);//扣减红包
                 } else {
                     Yii::error('没有找到红包,hbId', $hbId . ' ' . __METHOD__);
@@ -1237,6 +1252,7 @@ class OrderController extends BaseController
         $showYePay = $balance >= $actPrice && $actPrice > 0 ? 1 : 0;
         $detail['showYePay'] = $showYePay;
 
+        $detail['rechargeWeal'] = $this->shop->rechargeWeal; //是否开启余额支付
         util::success($detail);
     }