Jelajahi Sumber

重复提交问题

shish 2 tahun lalu
induk
melakukan
b7d0ca41ad
1 mengubah file dengan 8 tambahan dan 0 penghapusan
  1. 8 0
      app-ghs/controllers/OrderController.php

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

@@ -844,6 +844,14 @@ class OrderController extends BaseController
             util::fail('请选客户哦');
         }
 
+        //4秒内不允许重复提交
+        $cacheKey = 'ghs_custom_create_order_' . $customId;
+        $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+        if (!empty($has)) {
+            util::fail('请勿重复提交');
+        }
+        Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 4, 'has']);
+
         CustomClass::valid($custom, $this->shopId);
         if (isset($custom['mainId']) && !empty($custom['mainId']) && $custom['mainId'] == $custom['ownMainId']) {
             util::fail('不能自己给自己开单');