|
|
@@ -7,7 +7,6 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.extra.servlet.ServletUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
|
import com.cyksj.common.util.GoogleGenerator;
|
|
|
@@ -71,7 +70,7 @@ public class GroupRelationController {
|
|
|
|
|
|
private final RedisService redisService;
|
|
|
|
|
|
- private final SysConfigMapper sysConfigMapper;
|
|
|
+ private final UserFuncPropertyMapper userFuncPropertyMapper;
|
|
|
|
|
|
private final DoubleVerifyClickRefreshRecordMapper refreshRecordMapper;
|
|
|
|
|
|
@@ -192,7 +191,7 @@ public class GroupRelationController {
|
|
|
public Result<String> getAuthCode(Long relationId) {
|
|
|
long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
List<Long> userIds = userService.getRelationUserIdList(userId, null);
|
|
|
- //每个人 每月只能获取两次
|
|
|
+ //每个人 每月只能获取3次
|
|
|
if (relationId == null) throw BusinessRuntimeException.getInstance("车票不存在");
|
|
|
GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder()
|
|
|
.field(GroupsRelationView::getId, relationId)
|
|
|
@@ -205,11 +204,11 @@ public class GroupRelationController {
|
|
|
.eq(DoubleVerifyClickRecord::getRelationId, relationId)
|
|
|
.eq(DoubleVerifyClickRecord::getAccountId, groupsRelationView.getAccountId())
|
|
|
.between(DoubleVerifyClickRecord::getCreatedTime, DateUtil.beginOfMonth(now), DateUtil.endOfMonth(now)));
|
|
|
- SysConfig double_verify_num = sysConfigMapper.selectOne(Wrappers.lambdaQuery(SysConfig.class).eq(SysConfig::getSysKey, Constant.ACCOUNT_DOUBLE_VERIFY_KEY));
|
|
|
- int num = 2;
|
|
|
- if (double_verify_num != null) {
|
|
|
- num = Integer.parseInt(double_verify_num.getSysValue());
|
|
|
- }
|
|
|
+ UserFuncProperty userFuncProperty = userFuncPropertyMapper.selectOne(Wrappers.lambdaQuery(UserFuncProperty.class)
|
|
|
+ .eq(UserFuncProperty::getUserId, userId).last("limit 1"));
|
|
|
+ //默认3次
|
|
|
+ int num = 3;
|
|
|
+ if (userFuncProperty != null) num = userFuncProperty.getVerifyCheckNum();
|
|
|
if (count >= num) throw BusinessRuntimeException.getInstance("获取双重验证码次数上限");
|
|
|
int second = now.second();
|
|
|
if (second < 30 && 30 - second < 3) {
|
|
|
@@ -218,12 +217,22 @@ public class GroupRelationController {
|
|
|
ThreadUtil.sleep(60 - second + 1, TimeUnit.SECONDS);
|
|
|
}
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
+ JSONObject re = new JSONObject();
|
|
|
try {
|
|
|
long code = GoogleGenerator.getCode(groupsRelationView.getApiSecret(), now.getTime());
|
|
|
sb.append(code);
|
|
|
while (sb.length() < 6) {
|
|
|
sb.insert(0, 0);
|
|
|
}
|
|
|
+ re.putOpt("code", sb.toString());
|
|
|
+ int nowSecond = DateTime.now().second();
|
|
|
+ int time = 0;
|
|
|
+ if (nowSecond < 30) {
|
|
|
+ time = 30 - nowSecond;
|
|
|
+ } else {
|
|
|
+ time = 60 - nowSecond;
|
|
|
+ }
|
|
|
+ re.putOpt("time", time);
|
|
|
DoubleVerifyClickRecord doubleVerifyClickRecord = new DoubleVerifyClickRecord();
|
|
|
doubleVerifyClickRecord.setRelationId(relationId);
|
|
|
doubleVerifyClickRecord.setUserId(userId);
|
|
|
@@ -231,6 +240,8 @@ public class GroupRelationController {
|
|
|
doubleVerifyClickRecord.setAccountId(groupsRelationView.getAccountId());
|
|
|
doubleVerifyClickRecord.setAccount(groupsRelationView.getTripsAccount());
|
|
|
doubleVerifyClickRecord.setSkuId(groupsRelationView.getSkuId());
|
|
|
+ doubleVerifyClickRecord.setCode(sb.toString());
|
|
|
+ doubleVerifyClickRecord.setRemainTime(time);
|
|
|
doubleVerifyRecordMapper.insert(doubleVerifyClickRecord);
|
|
|
|
|
|
DoubleVerifyDto doubleVerifyDto = new DoubleVerifyDto();
|
|
|
@@ -241,16 +252,6 @@ public class GroupRelationController {
|
|
|
} catch (Exception e) {
|
|
|
throw BusinessRuntimeException.getInstance("获取双重验证码错误,请联系客服");
|
|
|
}
|
|
|
- JSONObject re = new JSONObject();
|
|
|
- re.putOpt("code", sb.toString());
|
|
|
- int nowSecond = DateTime.now().second();
|
|
|
- int time = 0;
|
|
|
- if (nowSecond < 30) {
|
|
|
- time = 30 - nowSecond;
|
|
|
- } else {
|
|
|
- time = 60 - nowSecond;
|
|
|
- }
|
|
|
- re.putOpt("time", time);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(re.toString());
|
|
|
}
|
|
|
|
|
|
@@ -299,10 +300,19 @@ public class GroupRelationController {
|
|
|
throw BusinessRuntimeException.getInstance("刷新双重验证码错误,请联系客服");
|
|
|
}
|
|
|
if (clickId != 0) {
|
|
|
+ int nowSecond = DateTime.now().second();
|
|
|
+ int time = 0;
|
|
|
+ if (nowSecond < 30) {
|
|
|
+ time = 30 - nowSecond;
|
|
|
+ } else {
|
|
|
+ time = 60 - nowSecond;
|
|
|
+ }
|
|
|
//刷新双重验证码记录
|
|
|
DoubleVerifyClickRefreshRecord refreshRecord = new DoubleVerifyClickRefreshRecord();
|
|
|
refreshRecord.setClickId(clickId);
|
|
|
refreshRecord.setUserId(userId);
|
|
|
+ refreshRecord.setCode(sb.toString());
|
|
|
+ refreshRecord.setRemainTime(time);
|
|
|
refreshRecordMapper.insert(refreshRecord);
|
|
|
}
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(sb.toString());
|