Browse Source

fix:修复停车入场回调幂等问题

release_toaliyun_real
xmzhao71 2 years ago
parent
commit
23290082d0
2 changed files with 11 additions and 10 deletions
  1. +7
    -10
      mallinkCallback/src/main/java/com/iformall/controller/callback/car/WxParkCallBackBaseController.java
  2. +4
    -0
      mallinkService/src/main/java/com/iformall/utils/RedisCacheUtils.java

+ 7
- 10
mallinkCallback/src/main/java/com/iformall/controller/callback/car/WxParkCallBackBaseController.java View File

@@ -16,9 +16,6 @@ import com.iformall.exception.MallinkException;
import com.iformall.service.*;
import com.iformall.service.park.ParkFactory;
import com.iformall.service.park.entity.ParkNotifyParam;
import com.iformall.service.park.impl.cyf.CYFUtil;
import com.iformall.service.park.impl.etcp.ETCPUtil;
import com.iformall.service.park.impl.tjd.TJDUtil;
import com.iformall.service.park.utils.ParkCacheUtils;
import com.iformall.utils.DateUtils;
import com.iformall.utils.RedisCacheUtils;
@@ -30,17 +27,11 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class WxParkCallBackBaseController extends BaseController {
@@ -184,9 +175,15 @@ public class WxParkCallBackBaseController extends BaseController {
if (null == param) {
return new Result();
}
// 回调去重
String key = "callback:" + param.getCarNumber();
if (RedisCacheUtils.hasKey(redisTemplate, key)) {
logger.info("回调数据重复=========>{}", JSON.toJSONString(sourceParam));
return new Result();
}
RedisCacheUtils.cache(redisTemplate, key, "", 60 * 2);
String carNumber = param.getCarNumber();
ParkCacheUtils.removeCache(redisTemplate, vendor.getMessage(), carNumber);
ParkCacheUtils.setCarCouponUnUseCacheLock(redisTemplate, vendor.getMessage(), carNumber);


+ 4
- 0
mallinkService/src/main/java/com/iformall/utils/RedisCacheUtils.java View File

@@ -169,4 +169,8 @@ public class RedisCacheUtils {
Set keys = template.keys(prefix+"*");
template.delete(keys);
}

public static Boolean hasKey(RedisTemplate<String, Object> template,String key) {
return template.hasKey(key);
}
}

Loading…
Cancel
Save