Authored by qinchao

fix 更低价redis key

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