From 23290082d00bc7987bcaed100eec523d42c848e9 Mon Sep 17 00:00:00 2001 From: xmzhao71 Date: Mon, 4 Sep 2023 18:43:36 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=81=9C?= =?UTF-8?q?=E8=BD=A6=E5=85=A5=E5=9C=BA=E5=9B=9E=E8=B0=83=E5=B9=82=E7=AD=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../car/WxParkCallBackBaseController.java | 17 +++++++---------- .../com/iformall/utils/RedisCacheUtils.java | 4 ++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/mallinkCallback/src/main/java/com/iformall/controller/callback/car/WxParkCallBackBaseController.java b/mallinkCallback/src/main/java/com/iformall/controller/callback/car/WxParkCallBackBaseController.java index 3747d80ea..790b6b45e 100644 --- a/mallinkCallback/src/main/java/com/iformall/controller/callback/car/WxParkCallBackBaseController.java +++ b/mallinkCallback/src/main/java/com/iformall/controller/callback/car/WxParkCallBackBaseController.java @@ -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); diff --git a/mallinkService/src/main/java/com/iformall/utils/RedisCacheUtils.java b/mallinkService/src/main/java/com/iformall/utils/RedisCacheUtils.java index d4a3f31e7..351c502fa 100644 --- a/mallinkService/src/main/java/com/iformall/utils/RedisCacheUtils.java +++ b/mallinkService/src/main/java/com/iformall/utils/RedisCacheUtils.java @@ -169,4 +169,8 @@ public class RedisCacheUtils { Set keys = template.keys(prefix+"*"); template.delete(keys); } + + public static Boolean hasKey(RedisTemplate template,String key) { + return template.hasKey(key); + } }