👍 增加NPE防御

This commit is contained in:
2022-12-07 10:38:29 +08:00
parent d84528ee14
commit baedf074be
2 changed files with 16 additions and 15 deletions
@@ -2773,6 +2773,12 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
StringBuilder pBrand=new StringBuilder();
StringBuilder pCate=new StringBuilder();
yxStoreOrder.getCartInfoList().forEach(c->{
if (ObjectUtil.isEmpty(c.getCartInfoMap())){
return;
}
if (!c.getCartInfoMap().containsKey("productInfo")){
return;
}
Object info = c.getCartInfoMap().get("productInfo");
YxStoreProductQueryVo vo = JSONUtil.toBean(info.toString(), YxStoreProductQueryVo.class);
if (ObjectUtil.isNotEmpty(vo)) {
@@ -2783,14 +2789,19 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
.append(" ,\r\n");
}
if (!c.getCartInfoMap().containsKey("productId")){
return;
}
Integer productId=Integer.valueOf(c.getCartInfoMap().get("productId").toString());
YxStoreProduct yxStoreProduct=yxStoreProductService.getById(productId);
if (ObjectUtil.isNotNull(yxStoreBrandService.getById(yxStoreProduct.getBrandId()))){
pBrand.append(yxStoreBrandService.getById(yxStoreProduct.getBrandId()).getBrandName());
}
if (ObjectUtil.isNotNull(yxStoreCategoryService.getById(yxStoreProduct.getCateId()))){
if (ObjectUtil.isNotEmpty(yxStoreProduct)){
if (ObjectUtil.isNotNull(yxStoreBrandService.getById(yxStoreProduct.getBrandId()))) {
pBrand.append(yxStoreBrandService.getById(yxStoreProduct.getBrandId()).getBrandName());
}
if (ObjectUtil.isNotNull(yxStoreCategoryService.getById(yxStoreProduct.getCateId()))) {
// YxStoreCategory yxStoreCategory=yxStoreCategoryService.getById(yxStoreProduct.getCateId());
pCate.append(yxStoreCategoryService.getById(yxStoreProduct.getCateId()).getCateName());
pCate.append(yxStoreCategoryService.getById(yxStoreProduct.getCateId()).getCateName());
}
}
});
map.put("商品名称",pname);