Selaa lähdekoodia

不允许重复开单

shish 3 vuotta sitten
vanhempi
commit
5d150690d6
1 muutettua tiedostoa jossa 11 lisäystä ja 9 poistoa
  1. 11 9
      app-ghs/controllers/OrderController.php

+ 11 - 9
app-ghs/controllers/OrderController.php

@@ -703,15 +703,6 @@ class OrderController extends BaseController
             util::fail('请选择客户');
         }
 
-        //4秒内不允许重复开单
-        $staffId = $this->shopAdminId ?? 0;
-        $cacheKey = 'ghs_create_order_' . $staffId . '_' . $customId;
-        $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
-        if (!empty($has)) {
-            util::fail('请稍等');
-        }
-        Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 4, 'has']);
-
         $custom = CustomClass::getCustom($customId);
         if (empty($custom)) {
             util::fail('请选客户哦');
@@ -821,6 +812,17 @@ class OrderController extends BaseController
             }
         }
 
+
+        //4秒内不允许重复开单
+        $staffId = $this->shopAdminId ?? 0;
+        $cacheKey = 'ghs_create_order_' . $staffId . '_' . $customId;
+        $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+        if (!empty($has)) {
+            util::fail('请稍等');
+        }
+        Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 4, 'has']);
+
+
         $connection = Yii::$app->db;//事务处理
         $transaction = $connection->beginTransaction();
         try {