|
|
@@ -3,6 +3,8 @@ package org.springblade.salesPart.duoduo.controller;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springblade.common.enums.NumberEnum;
|
|
|
+import org.springblade.common.utils.RedisUtils;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
@@ -35,7 +37,7 @@ public class DuoDuoOpenApiController {
|
|
|
|
|
|
private final IAppTenantService appTenantService;
|
|
|
|
|
|
-
|
|
|
+ private final RedisUtils redisUtils;
|
|
|
|
|
|
|
|
|
@PostMapping("customerRechargeMsg")
|
|
|
@@ -43,6 +45,15 @@ public class DuoDuoOpenApiController {
|
|
|
@RequestHeader("timestamp") Long timestamp,
|
|
|
@RequestHeader("appid") String appId,
|
|
|
@RequestBody @Valid CnAutoMall cnAutoMallVo) {
|
|
|
+ long currentTime = System.currentTimeMillis();
|
|
|
+ if (Math.abs(currentTime - timestamp) > NumberEnum.SIXTY_THOUSAND.number) {
|
|
|
+ return R.fail("请求已过期");
|
|
|
+ }
|
|
|
+ // 时间戳防重校验
|
|
|
+ String timestampKey = "idempotent:timestamp:" + appId + ":" + timestamp;
|
|
|
+ if (redisUtils.hasKey(timestampKey)) {
|
|
|
+ return R.fail("请求重复,请勿重复提交");
|
|
|
+ }
|
|
|
boolean verify = MallSignUtil.verify(sign, timestamp, appId);
|
|
|
if (!verify) {
|
|
|
return R.fail("签名验证失败");
|
|
|
@@ -50,7 +61,7 @@ public class DuoDuoOpenApiController {
|
|
|
if (!Objects.equals(cnAutoMallVo.getAppId(), appId)) {
|
|
|
return R.fail("签名appId与参数appId不一致");
|
|
|
}
|
|
|
- return appTenantService.customerRechargeMsg(cnAutoMallVo);
|
|
|
+ return appTenantService.customerRechargeMsg(cnAutoMallVo, timestampKey);
|
|
|
}
|
|
|
|
|
|
|