优化代码,修改一个可能出现的获取商品分类的错误
This commit is contained in:
parent
478ba2048a
commit
5e6a56e193
@ -56,7 +56,7 @@ public class StoreGoodsLabelServiceImpl extends ServiceImpl<StoreGoodsLabelMappe
|
||||
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);
|
||||
|
@ -11,7 +11,6 @@ import cn.lili.modules.store.entity.dto.FreightTemplateChildDTO;
|
||||
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;
|
||||
|
||||
@ -51,16 +50,16 @@ public class SkuFreightRender implements CartRenderStep {
|
||||
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()) {
|
||||
@ -99,7 +98,7 @@ public class SkuFreightRender implements CartRenderStep {
|
||||
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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user