|
@@ -11,10 +11,12 @@ import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
|
|
|
import com.cyksj.common.util.GoogleGenerator;
|
|
import com.cyksj.common.util.GoogleGenerator;
|
|
|
|
|
+import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.common.util.StringUtil;
|
|
import com.cyksj.common.util.StringUtil;
|
|
|
import com.cyksj.dto.Result;
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.*;
|
|
import com.cyksj.mapper.*;
|
|
|
|
|
+import com.cyksj.model.dto.DoubleVerifyDto;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
|
import com.cyksj.model.request.OrderPayRequest;
|
|
import com.cyksj.model.request.OrderPayRequest;
|
|
@@ -68,6 +70,8 @@ public class GroupRelationController {
|
|
|
|
|
|
|
|
private final SysConfigMapper sysConfigMapper;
|
|
private final SysConfigMapper sysConfigMapper;
|
|
|
|
|
|
|
|
|
|
+ private final DoubleVerifyClickRefreshRecordMapper refreshRecordMapper;
|
|
|
|
|
+
|
|
|
private final GlobalThreadPoolTaskExecutor THREAD_POOL;
|
|
private final GlobalThreadPoolTaskExecutor THREAD_POOL;
|
|
|
|
|
|
|
|
@RequestMapping("/get/renewal")
|
|
@RequestMapping("/get/renewal")
|
|
@@ -214,8 +218,11 @@ public class GroupRelationController {
|
|
|
doubleVerifyClickRecord.setSkuId(groupsRelationView.getSkuId());
|
|
doubleVerifyClickRecord.setSkuId(groupsRelationView.getSkuId());
|
|
|
doubleVerifyRecordMapper.insert(doubleVerifyClickRecord);
|
|
doubleVerifyRecordMapper.insert(doubleVerifyClickRecord);
|
|
|
|
|
|
|
|
- redisService.set(String.format("%s-%s", userId, sb.toString()), 0, 60 * 60l);
|
|
|
|
|
- redisService.set(String.format("%s/%s", userId, sb.toString()), groupsRelationView.getApiSecret(), 60 * 60l);
|
|
|
|
|
|
|
+ DoubleVerifyDto doubleVerifyDto = new DoubleVerifyDto();
|
|
|
|
|
+ doubleVerifyDto.setClickId(doubleVerifyClickRecord.getId());
|
|
|
|
|
+ doubleVerifyDto.setApiSecret(groupsRelationView.getApiSecret());
|
|
|
|
|
+ redisService.set(String.format("%s-%s", userId, sb.toString()), 0, 60 * 10l);
|
|
|
|
|
+ redisService.set(String.format("%s/%s", userId, sb.toString()), Jsons.toJson(doubleVerifyDto), 60 * 10l);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
throw BusinessRuntimeException.getInstance("获取双重验证码错误,请联系客服");
|
|
throw BusinessRuntimeException.getInstance("获取双重验证码错误,请联系客服");
|
|
|
}
|
|
}
|
|
@@ -238,19 +245,32 @@ public class GroupRelationController {
|
|
|
@GetMapping("/refresh/code")
|
|
@GetMapping("/refresh/code")
|
|
|
public Result<String> refreshCode(String code) {
|
|
public Result<String> refreshCode(String code) {
|
|
|
long userId = StpUserUtil.getLoginIdAsLong();
|
|
long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
- String key = String.format("%s-%s", userId, code);
|
|
|
|
|
- String apiSecretKey = String.format("%s/%s", userId, code);
|
|
|
|
|
- Object value = redisService.get(key);
|
|
|
|
|
- if (value == null) {
|
|
|
|
|
|
|
+ String numKey = String.format("%s-%s", userId, code);
|
|
|
|
|
+ Object num = redisService.get(numKey);
|
|
|
|
|
+
|
|
|
|
|
+ String objKey = String.format("%s/%s", userId, code);
|
|
|
|
|
+ Object objValue = redisService.get(objKey);
|
|
|
|
|
+ if (objValue == null || num == null) {
|
|
|
throw BusinessRuntimeException.getInstance("请重新获取双重验证码");
|
|
throw BusinessRuntimeException.getInstance("请重新获取双重验证码");
|
|
|
}
|
|
}
|
|
|
- Integer refreshNum = Integer.parseInt(value.toString());
|
|
|
|
|
|
|
+ Integer refreshNum = Integer.parseInt(num.toString());
|
|
|
|
|
+ String apiSecret = null;
|
|
|
|
|
+ Long clickId = 0l;
|
|
|
|
|
+ try {
|
|
|
|
|
+ DoubleVerifyDto dto = Jsons.parseObject(objValue.toString(), DoubleVerifyDto.class);
|
|
|
|
|
+ apiSecret = dto.getApiSecret();
|
|
|
|
|
+ clickId = dto.getClickId();
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ apiSecret = objValue.toString();
|
|
|
|
|
+ }
|
|
|
if (refreshNum >= 3) {
|
|
if (refreshNum >= 3) {
|
|
|
- redisService.del(key);
|
|
|
|
|
- redisService.del(apiSecretKey);
|
|
|
|
|
|
|
+ redisService.del(numKey);
|
|
|
|
|
+ redisService.del(objKey);
|
|
|
throw BusinessRuntimeException.getInstance("刷新次数已达到3次,请重新获取验证码");
|
|
throw BusinessRuntimeException.getInstance("刷新次数已达到3次,请重新获取验证码");
|
|
|
}
|
|
}
|
|
|
- String apiSecret = redisService.getStr(apiSecretKey);
|
|
|
|
|
|
|
+ if (apiSecret == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("请重新获取双重验证码");
|
|
|
|
|
+ }
|
|
|
StringBuilder sb = new StringBuilder();
|
|
StringBuilder sb = new StringBuilder();
|
|
|
try {
|
|
try {
|
|
|
long c = GoogleGenerator.getCode(apiSecret, DateTime.now().getTime());
|
|
long c = GoogleGenerator.getCode(apiSecret, DateTime.now().getTime());
|
|
@@ -258,11 +278,18 @@ public class GroupRelationController {
|
|
|
while (sb.length() < 6) {
|
|
while (sb.length() < 6) {
|
|
|
sb.insert(0, 0);
|
|
sb.insert(0, 0);
|
|
|
}
|
|
}
|
|
|
- redisService.incr(key, 1l);
|
|
|
|
|
|
|
+ redisService.incr(numKey, 1l);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
throw BusinessRuntimeException.getInstance("刷新双重验证码错误,请联系客服");
|
|
throw BusinessRuntimeException.getInstance("刷新双重验证码错误,请联系客服");
|
|
|
}
|
|
}
|
|
|
|
|
+ if (clickId != 0) {
|
|
|
|
|
+ //刷新双重验证码记录
|
|
|
|
|
+ DoubleVerifyClickRefreshRecord refreshRecord = new DoubleVerifyClickRefreshRecord();
|
|
|
|
|
+ refreshRecord.setClickId(clickId);
|
|
|
|
|
+ refreshRecord.setUserId(userId);
|
|
|
|
|
+ refreshRecordMapper.insert(refreshRecord);
|
|
|
|
|
+ }
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(sb.toString());
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(sb.toString());
|
|
|
}
|
|
}
|
|
|
|
|
|