Skip to content

Commit

Permalink
优化代码,修改一个可能出现的获取商品分类的错误
Browse files Browse the repository at this point in the history
  • Loading branch information
LeiGaoRobot committed Jun 9, 2022
1 parent 478ba20 commit 5e6a56e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public List<StoreGoodsLabelVO> listByStoreId(String storeId) {
StoreGoodsLabelVO storeGoodsLabelVO = new StoreGoodsLabelVO(storeGoodsLabel.getId(), storeGoodsLabel.getLabelName(), storeGoodsLabel.getLevel(), storeGoodsLabel.getSortOrder());
List<StoreGoodsLabelVO> storeGoodsLabelVOChildList = new ArrayList<>();
list.stream()
.filter(label -> label.getParentId().equals(storeGoodsLabel.getId()))
.filter(label -> label.getParentId() != null && label.getParentId().equals(storeGoodsLabel.getId()))
.forEach(storeGoodsLabelChild -> storeGoodsLabelVOChildList.add(new StoreGoodsLabelVO(storeGoodsLabelChild.getId(), storeGoodsLabelChild.getLabelName(), storeGoodsLabelChild.getLevel(), storeGoodsLabelChild.getSortOrder())));
storeGoodsLabelVO.setChildren(storeGoodsLabelVOChildList);
storeGoodsLabelVOList.add(storeGoodsLabelVO);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import cn.lili.modules.store.entity.enums.FreightTemplateEnum;
import cn.lili.modules.store.entity.vos.FreightTemplateVO;
import cn.lili.modules.store.service.FreightTemplateService;
import org.apache.xmlbeans.impl.store.Cur;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

Expand Down Expand Up @@ -51,16 +50,16 @@ public void render(TradeDTO tradeDTO) {
Map<String, List<String>> freightGroups = freightTemplateGrouping(cartSkuVOS);

//循环运费模版
for (String freightTemplateId : freightGroups.keySet()) {
for (Map.Entry<String, List<String>> freightTemplateGroup : freightGroups.entrySet()) {

//商品id列表
List<String> skuIds = freightGroups.get(freightTemplateId);
List<String> skuIds = freightTemplateGroup.getValue();

//当前购物车商品列表
List<CartSkuVO> currentCartSkus = cartSkuVOS.stream().filter(item -> skuIds.contains(item.getGoodsSku().getId())).collect(Collectors.toList());

//寻找对应对商品运费计算模版
FreightTemplateVO freightTemplate = freightTemplateService.getFreightTemplate(freightTemplateId);
FreightTemplateVO freightTemplate = freightTemplateService.getFreightTemplate(freightTemplateGroup.getKey());
if (freightTemplate != null
&& freightTemplate.getFreightTemplateChildList() != null
&& !freightTemplate.getFreightTemplateChildList().isEmpty()) {
Expand Down Expand Up @@ -99,7 +98,7 @@ public void render(TradeDTO tradeDTO) {
Double count = currentCartSkus.stream().mapToDouble(item ->
// 根据计费规则 累加计费基数
freightTemplateChildDTO.getPricingMethod().equals(FreightTemplateEnum.NUM.name()) ?
item.getNum() :
item.getNum().doubleValue() :
CurrencyUtil.mul(item.getNum(), item.getGoodsSku().getWeight())
).sum();

Expand Down

0 comments on commit 5e6a56e

Please sign in to comment.