Pārlūkot izejas kodu

一分钟内双重验证码限制查看人数

zoujiajian 2 gadi atpakaļ
vecāks
revīzija
e1a23934e3

+ 2 - 2
netflix-service/src/main/java/com/cyksj/redis/RedisService.java

@@ -665,8 +665,8 @@ public class RedisService {
         //获客链接 到企业微信内将平台标识与unionId 对应
         CORP_CUSTOMER_ACQUISTION_UNIONID_CLICKID("corp:customer:unionId:%s","unionid 对应的clickId",60*60*24),
 
-        WEEKEND_DUTY_UNDERSTAFFED_NOTIFY("weekend_duty_understaffed_notify","周末值班人员不足短信通知key",60*60)
-
+        WEEKEND_DUTY_UNDERSTAFFED_NOTIFY("weekend_duty_understaffed_notify","周末值班人员不足短信通知key",60*60),
+        DOUBLE_VERIFY_CODE_VIEW_MINUTES_KEY("double_verify_code_view_minutes_key","双重验证码查看同时间段人数限制",60)
         ;
 
         private String name;

+ 5 - 0
netflix-web/src/main/java/com/cyksj/web/controller/group/GroupRelationController.java

@@ -264,6 +264,11 @@ public class GroupRelationController {
         //获取双重验证码
         Integer num = groupRelationFrontService.getUserCodeNumBySkuId(userId, groupsRelationView.getSkuId());
         if (count >= num) throw BusinessRuntimeException.getInstance("获取双重验证码次数上限");
+        //一分钟内 只能一人获取
+        boolean b = redisService.setNx(RedisService.key.DOUBLE_VERIFY_CODE_VIEW_MINUTES_KEY.getEnvName() + groupsRelationView.getTripsAccount(), relationId, RedisService.key.DOUBLE_VERIFY_CODE_VIEW_MINUTES_KEY.getTimeout());
+        if (!b) {
+            throw BusinessRuntimeException.getInstance("一分钟内已有人获取该账号验证码,请稍后获取..");
+        }
         int second = now.second();
         if (second < 30 && 30 - second < 3) {
             ThreadUtil.sleep(30 - second + 1, TimeUnit.SECONDS);