Authored by qinchao

fix 更低价redis key

@@ -67,16 +67,20 @@ public class SellerOrderPriceChangeHandler implements IEventHandler<SellerOrderP @@ -67,16 +67,20 @@ public class SellerOrderPriceChangeHandler implements IEventHandler<SellerOrderP
67 } 67 }
68 int changedSellerUid = sog.getUid(); 68 int changedSellerUid = sog.getUid();
69 BigDecimal changedPrice = sog.getGoodsPrice(); 69 BigDecimal changedPrice = sog.getGoodsPrice();
  70 + Integer storageId = sog.getStorageId();
70 //根据storageId获取所有在售的卖家的订单 71 //根据storageId获取所有在售的卖家的订单
71 - List<SellerOrderGoods> list= sellerOrderGoodsViewMapper.selectCanSellByStorageId(sog.getStorageId()); 72 + List<SellerOrderGoods> list= sellerOrderGoodsViewMapper.selectCanSellByStorageId(storageId);
72 //把自己过滤掉,只保留价格高于当前价格 73 //把自己过滤掉,只保留价格高于当前价格
73 list = list.stream().filter(r->r.getGoodsPrice().compareTo(changedPrice)>0&&changedSellerUid!=r.getUid().intValue()).collect(Collectors.toList()); 74 list = list.stream().filter(r->r.getGoodsPrice().compareTo(changedPrice)>0&&changedSellerUid!=r.getUid().intValue()).collect(Collectors.toList());
  75 + if(CollectionUtils.isEmpty(list)){
  76 + return ;
  77 + }
74 //从redis过滤uid+storgeid+date 78 //从redis过滤uid+storgeid+date
75 Date currentTime = new Date(); 79 Date currentTime = new Date();
76 String dateString = formatter.format(currentTime);//2019-03-20 80 String dateString = formatter.format(currentTime);//2019-03-20
77 81
78 //发送,并记录到redis 82 //发送,并记录到redis
79 - RedisKeyBuilder redisKey = getRedisKeyBuilder(dateString); 83 + RedisKeyBuilder redisKey = getRedisKeyBuilder(dateString, storageId);
80 Set<String> members = yhSetOperations.members(redisKey); 84 Set<String> members = yhSetOperations.members(redisKey);
81 if(CollectionUtils.isNotEmpty(members)){ 85 if(CollectionUtils.isNotEmpty(members)){
82 list = list.stream().filter(r->!members.contains(getValueForSet(r))).collect(Collectors.toList()); 86 list = list.stream().filter(r->!members.contains(getValueForSet(r))).collect(Collectors.toList());
@@ -98,10 +102,10 @@ public class SellerOrderPriceChangeHandler implements IEventHandler<SellerOrderP @@ -98,10 +102,10 @@ public class SellerOrderPriceChangeHandler implements IEventHandler<SellerOrderP
98 } 102 }
99 103
100 public String getValueForSet(SellerOrderGoods r){ 104 public String getValueForSet(SellerOrderGoods r){
101 - return r.getUid()+"-"+r.getStorageId(); 105 + return String.valueOf(r.getUid());
102 } 106 }
103 107
104 - public static RedisKeyBuilder getRedisKeyBuilder(String dateString){  
105 - return RedisKeyBuilder.newInstance().appendFixed("ufo:order:price:change:").appendVar(dateString); 108 + public static RedisKeyBuilder getRedisKeyBuilder(String dateString,Integer storageId){
  109 + return RedisKeyBuilder.newInstance().appendFixed("ufo:order:price:change:").appendVar(dateString+"-"+storageId);
106 } 110 }
107 } 111 }