Browse Source

//解决重复充值问题

shish 2 years ago
parent
commit
bfa078d193
1 changed files with 10 additions and 0 deletions
  1. 10 0
      app-ghs/controllers/CustomController.php

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

@@ -93,6 +93,16 @@ class CustomController extends BaseController
         if ($amount <= 0) {
             //util::fail('充值金额需要大于0');
         }
+
+        //解决重复充值问题
+        $cacheKey = 'help_custom_recharge_' . $customId;
+        $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+        if (!empty($has)) {
+            util::fail('刚有提交充值,请60秒之后');
+            return false;
+        }
+        Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 60, 'has']);
+
         $custom = CustomClass::getLockById($customId);
         if (empty($custom)) {
             util::fail('没有找到客户');