Переглянути джерело

修改重复消息去重逻辑

wujiefeng 9 місяців тому
батько
коміт
d365c2da9a

+ 1 - 1
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/VipUserRecordDao.java

@@ -17,5 +17,5 @@ public interface VipUserRecordDao extends MongoDao<VipUserRecord>, VipUserRecord
 
     VipUserRecord findTop1ByCpIdOrderByOperateTime(String cpId);
 
-    VipUserRecord findTop1ByCpIdAndSucAndPlanningIdOrderByCreateTimeDesc(String cpId, Integer suc, String planningId);
+    VipUserRecord findTop1ByCpIdOrderByCreateTimeDesc(String cpId);
 }

+ 4 - 2
RewardServer/src/main/java/com/zhongshu/reward/server/core/stream/VipUserStream.java

@@ -13,6 +13,8 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.Objects;
+
 @Log4j2
 @Component("vipUserStreamConsumer")
 public class VipUserStream extends StreamConsumer<VipUserParam> {
@@ -30,8 +32,8 @@ public class VipUserStream extends StreamConsumer<VipUserParam> {
     public void accept(VipUserParam vipUserParam) {
         log.info("收到会员套餐消息:{}",vipUserParam);
 
-        VipUserRecord existsRecord = vipUserRecordDao.findTop1ByCpIdAndSucAndPlanningIdOrderByCreateTimeDesc(vipUserParam.getCpId(), vipUserParam.getSuc(), vipUserParam.getPlanningId());
-        if (ObjectUtils.isNotEmpty(existsRecord)){
+        VipUserRecord existsRecord = vipUserRecordDao.findTop1ByCpIdOrderByOperateTime(vipUserParam.getCpId());
+        if (ObjectUtils.isNotEmpty(existsRecord) && vipUserParam.getPlanningId().equals(existsRecord.getPlanningId()) && Objects.equals(vipUserParam.getSuc(), existsRecord.getSuc())){
             log.info("重复订阅消息");
             return;
         }