Authored by chenchao

fix bug 5067

... ... @@ -101,7 +101,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
sogList.stream().forEach(item -> {
item.setImageUrl(ImageUrlAssist.getAllProductPicUrl(item.getImageUrl(), "goodsimg", "center", "d2hpdGU="));
});
Map<Integer,String> overPriceTipsMap = buildOverPriceTipsMap(sogList);
Map<String, String> overPriceTipsMap = buildOverPriceTipsMap(sogList);
Map<Integer, SellerOrderGoods> skupSellerOrderGoodsMap = sogList.parallelStream()
.collect(Collectors.toMap(SellerOrderGoods::getId, (SellerOrderGoods sog) -> sog));
List<Integer> skupList = sogList.parallelStream().map(SellerOrderGoods::getId).collect(Collectors.toList());
... ... @@ -160,19 +160,25 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
@Autowired
private SellerOrderPrepareProcessor sellerOrderPrepareProcessor;
private String overFlowPriceKey(Integer storageId, BigDecimal salePrice){
return new StringBuilder(storageId).append(salePrice).toString();
}
/**
* todo 需要商品提供批量接口,减少db net IO, 目前的工期太短,后期再优化
* @param sogList
* @return
*/
private Map<Integer,String> buildOverPriceTipsMap(List<SellerOrderGoods> sogList){
Map<Integer,String> map = new HashMap<>(sogList.size());
private Map<String,String> buildOverPriceTipsMap(List<SellerOrderGoods> sogList){
Map<String,String> map = new HashMap<>(sogList.size());
for(SellerOrderGoods sog : sogList) {
int storageId = sog.getStorageId();
if (map.containsKey(storageId)){
BigDecimal prdPrice = sog.getGoodsPrice();
String key = overFlowPriceKey(storageId, prdPrice);
if (map.containsKey(key)){
continue;
}
BigDecimal prdPrice = sog.getGoodsPrice();
final String defaultResult = "";
String value;
try {
... ... @@ -184,7 +190,8 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
log.warn("in buildOverPriceTipsMap storageId {},prdPrice {}", storageId, prdPrice, ex);
value = defaultResult;
}
map.put(storageId, value);
map.put(key, value);
}
return map;
}
... ... @@ -194,7 +201,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
OrderListInfo buildOrderListInfo(SellerOrderGoods sellerOrderGoods,
SellerOrder sellerOrder, SellerType st, Map<Integer,String> overPriceTipsMap) {
SellerOrder sellerOrder, SellerType st, Map<String,String> overPriceTipsMap) {
OrderListInfo orderListInfo = new OrderListInfo();
Long orderCode;
... ... @@ -244,7 +251,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
orderListInfo.setSecendLevelCreateTime(sellerOrder.getCreateTime());
orderListInfo.setCreateTime(DateUtil.formatDate(sellerOrder.getCreateTime(), DateUtil.yyyy_MM_dd_HH_mm_SS));
if (SHOW_OVER_FLOW_PRICE_STATUS.contains(skupStatus.getCode())){
orderListInfo.setTips(overPriceTipsMap.get(sellerOrderGoods.getStorageId()));
orderListInfo.setTips(overPriceTipsMap.get(overFlowPriceKey(sellerOrderGoods.getStorageId(), sellerOrderGoods.getGoodsPrice())));
}
return orderListInfo;
}
... ...