Explorar el Código

3秒内不允许重复开单

shish hace 4 años
padre
commit
6d6af1d6e3
Se han modificado 1 ficheros con 10 adiciones y 0 borrados
  1. 10 0
      app-ghs/controllers/OrderController.php

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

@@ -699,6 +699,16 @@ class OrderController extends BaseController
         if (empty($customId)) {
             util::fail('请选择客户');
         }
+
+        //3秒内不允许重复开单
+        $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, 3, 'has']);
+
         $custom = CustomClass::getCustom($customId);
         if (empty($custom)) {
             util::fail('请选客户哦');