shish hace 1 año
padre
commit
4582264ef3

+ 31 - 9
app-hd/controllers/PurchaseController.php

@@ -36,6 +36,28 @@ class PurchaseController extends BaseController
 
     public $guestAccess = ['detail', 'ali-pay', 'get-ali-pay-code', 'wx-pay'];
 
+    //取消采购单 ssh 20250710
+    public function actionCancel()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $info = PurchaseClass::getById($id, true);
+        if (empty($info)) {
+            util::fail('没有找到采购单');
+        }
+        if (!isset($info->mainId) || $info->mainId != $this->mainId) {
+            util::fail('访问错误');
+        }
+        if ($info->status == 5) {
+            util::fail('已取消');
+        }
+        if ($info->status != 1) {
+            util::fail('不能取消');
+        }
+        PurchaseService::expire($info);
+        util::complete('已取消');
+    }
+
     //获取支付宝付款码 ssh 20240713
     public function actionGetAliPayCode()
     {
@@ -593,20 +615,20 @@ class PurchaseController extends BaseController
                     }
                 }
 
-                if(isset($ghsInfo['home'])){
-                    if($ghsInfo['home'] == 0){
+                if (isset($ghsInfo['home'])) {
+                    if ($ghsInfo['home'] == 0) {
                         util::fail('暂不支持送货上门,请选其它配送方式');
                     }
-                    if(!empty($ghsInfo['homeAmount'])){
-                        $homeType = $ghsInfo['homeType']??0;
+                    if (!empty($ghsInfo['homeAmount'])) {
+                        $homeType = $ghsInfo['homeType'] ?? 0;
                         $homeAmount = floatval($ghsInfo['homeAmount']);
-                        if($homeType == 0){
-                            if($homeAmount>$respond->actPrice){
+                        if ($homeType == 0) {
+                            if ($homeAmount > $respond->actPrice) {
                                 util::fail("满{$homeAmount}元 可送货上门");
                             }
                         }
-                        if($homeType == 1){
-                            if ($homeAmount>$respond->bigNum) {
+                        if ($homeType == 1) {
+                            if ($homeAmount > $respond->bigNum) {
                                 util::fail("满{$homeAmount}扎 可送货上门");
                             }
                         }
@@ -720,7 +742,7 @@ class PurchaseController extends BaseController
                 if (isset($cg->book) && $cg->book == 0) {
                     $ghsShopId = $ghs['shopId'] ?? 0;
                     if (getenv('YII_ENV') == 'production') {
-                        $specialList = [10649, 8042, 16454, 21319, 33668,42345];
+                        $specialList = [10649, 8042, 16454, 21319, 33668, 42345];
                     } else {
                         $specialList = [36523];
                     }

+ 1 - 1
biz-hd/purchase/services/PurchaseService.php

@@ -182,7 +182,7 @@ class PurchaseService extends BaseService
     public static function expire($purchase)
     {
         if ($purchase->status != PurchaseClass::STATUS_UN_PAY) {
-            util::fail('不是待付款订单哦');
+            util::fail('不能取消');
         }
         //采购单失效
         $id = $purchase->id;