Browse Source

Merge remote-tracking branch 'origin/zx_saas_goods' into zx_saas_goods

zouxuan 1 năm trước cách đây
mục cha
commit
38c0f39691

+ 1 - 13
mec-application/src/main/java/com/ym/mec/web/controller/GoodsController.java

@@ -14,7 +14,6 @@ import com.ym.mec.biz.service.GoodsService;
 import com.ym.mec.biz.service.SysUserService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.dto.BrandDto;
-import com.ym.mec.common.dto.ProductAttributeCategoryDto;
 import com.ym.mec.common.dto.ProductCategoryDto;
 import com.ym.mec.common.page.PageInfo;
 import io.swagger.annotations.Api;
@@ -124,18 +123,7 @@ public class GoodsController extends BaseController {
         }else if(StringUtils.isEmpty(employee.getOrganIdList())){
             return failed("用户所在分部异常");
         }
-        PageInfo<Goods> page = goodsService.queryPage(queryInfo);
-        List<Goods> rows = page.getRows();
-        if (!rows.isEmpty()) {
-            Map<String, String> brandIdNameMap = goodsService.queryGoodsBrandList().stream().collect(Collectors.toMap(next -> next.getId().toString(), BrandDto::getName));
-            Map<Integer, String> categoryIdNameMap = goodsService.queryGoodsCategoryList().stream().collect(Collectors.toMap(next -> next.getId().intValue(), ProductCategoryDto::getName));
-
-            for (Goods row : rows) {
-                row.setBrandName(brandIdNameMap.getOrDefault(row.getBrand(), row.getBrand()));
-                row.setGoodsCategoryName(categoryIdNameMap.getOrDefault(row.getGoodsCategoryId(), ""));
-            }
-        }
-        return succeed(page);
+        return succeed(goodsService.queryPage(queryInfo));
     }
 
     @ApiOperation(value = "通过科目编号、商品分类 查询商品(教材、辅件)列表")

+ 82 - 43
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GoodsServiceImpl.java

@@ -13,7 +13,6 @@ import com.ym.mec.biz.dal.dao.SellOrderDao;
 import com.ym.mec.biz.dal.dao.TeacherDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.GoodsSellDto;
-import com.ym.mec.biz.dal.dto.SubjectGoodsDto;
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.GoodsProcurement;
 import com.ym.mec.biz.dal.entity.GoodsSub;
@@ -48,6 +47,7 @@ import com.ym.mec.common.entity.GoodsSubStockModel;
 import com.ym.mec.common.entity.UploadReturnBean;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.common.tenant.TenantContextHolder;
@@ -73,18 +73,9 @@ import org.springframework.util.CollectionUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
-import java.io.BufferedWriter;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
+import java.io.*;
 import java.math.BigDecimal;
 import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -302,7 +293,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 					throw new BizException("{}等商品还在销售中", goodsNames);
 				}
 			}
-			List<GoodsWrapper.GoodsSub> goodsSubs = queryGoodsSub(goodsId);
+			List<GoodsWrapper.GoodsSub> goodsSubs = queryGoodsSubByGoodId(goodsId);
 			if (!CollectionUtils.isEmpty(goodsSubs) && status == 1) {
 				long falseSize = goodsSubs.stream().map(GoodsWrapper.GoodsSub::getGoodsStatus).filter(Boolean.FALSE::equals).count();
 				if (falseSize > 0) {
@@ -323,7 +314,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		goodsDao.update(goods);
 	}
 
-	private List<GoodsWrapper.GoodsSub> queryGoodsSub(Integer goodsId) {
+	private List<GoodsWrapper.GoodsSub> queryGoodsSubByGoodId(Integer goodsId) {
 		// 从管乐迷商城组合的商品
 		QueryWrapper<GoodsSub> queryWrapper = new QueryWrapper<>();
 		queryWrapper.eq("goods_id_", goodsId);
@@ -331,7 +322,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		if (goodsSubs.isEmpty()) {
 			return new ArrayList<>();
 		}
-		List<String> skuList = goodsSubs.stream().map(next -> next.getSku().toString()).distinct().collect(Collectors.toList());
+//		List<String> skuList = goodsSubs.stream().map(next -> next.getSku().toString()).distinct().collect(Collectors.toList());
 		List<GoodsWrapper.GoodsSub> goodsSubList = goodsSubs.stream().map(next -> {
 			GoodsWrapper.GoodsSub goodsSub = new GoodsWrapper.GoodsSub();
 			goodsSub.setId(next.getId());
@@ -342,13 +333,15 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 			goodsSub.setGoodsPrice(next.getGoodsPrice());
 			return goodsSub;
 		}).collect(Collectors.toList());
+		List<String> goodIdList = goodsSubs.stream().map(next -> next.getMallGoodsId().toString()).distinct().collect(Collectors.toList());
 		PmsProductQueryParamDto build = PmsProductQueryParamDto.builder()
-				.skuStockIds(String.join(",", skuList))
+				.productIds(String.join(",", goodIdList))
 				.pageSize(9999)
 				.pageNum(1).build();
 		build.setJson(JSON.toJSONString(build));
-		Map<Integer, PmsProductDto> map = mallFeignService.getProductList(build)
-				.getRows().stream().collect(Collectors.toMap(PmsProductDto::getSkuStockId, Function.identity()));
+		List<PmsProductDto> rows = mallFeignService.getProductList(build).getRows();
+		Map<Integer, PmsProductDto> map = rows.stream().collect(Collectors.toMap(PmsProductDto::getSkuStockId, Function.identity()));
+		Map<Long, List<PmsProductDto>> groupByGoodId = rows.stream().collect(Collectors.groupingBy(PmsProductDto::getGoodsId));
 		goodsSubList.forEach(next -> {
 			PmsProductDto dto = map.get(next.getSku());
 			if (dto != null) {
@@ -358,8 +351,11 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 				} else {
 					next.setGoodsStatus(dto.getPublishStatus() == 1);
 				}
-				next.setMallGoodsName(dto.getName());
-				next.setProductSn(dto.getProductSn());
+			}
+			if(groupByGoodId.containsKey(Long.valueOf(next.getMallGoodsId()))){
+				PmsProductDto dto1 =  groupByGoodId.get(Long.valueOf(next.getMallGoodsId())).get(0);
+				next.setMallGoodsName(dto1.getName());
+				next.setProductSn(dto1.getProductSn());
 			}
 		});
 		return goodsSubList;
@@ -385,6 +381,24 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 	}
 
 	@Override
+	public PageInfo<Goods> queryPage(QueryInfo queryInfo) {
+		PageInfo<Goods> page = super.queryPage(queryInfo);
+
+		List<Goods> rows = page.getRows();
+		if (!rows.isEmpty()) {
+			Map<String, String> brandIdNameMap = this.queryGoodsBrandList().stream().collect(Collectors.toMap(next -> next.getId().toString(), BrandDto::getName));
+			List<ProductCategoryDto> productCategoryDtos = treeToList(this.queryGoodsCategoryList());
+			Map<Integer, String> categoryIdNameMap = productCategoryDtos.stream().collect(Collectors.toMap(next -> next.getId().intValue(), ProductCategoryDto::getName));
+
+			for (Goods row : rows) {
+				row.setBrandName(brandIdNameMap.getOrDefault(row.getBrand(), row.getBrand()));
+				row.setGoodsCategoryName(categoryIdNameMap.getOrDefault(row.getGoodsCategoryId(), ""));
+			}
+		}
+		return page;
+	}
+
+	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public List<Goods> importGoods(MultipartFile file, Integer operatorId) throws Exception {
 		Map<String, List<Map<String, Object>>> sheetsListMap = POIUtil.importExcel(new ByteArrayInputStream(file.getBytes()), 2, file.getOriginalFilename());
@@ -600,8 +614,11 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		goodsCategoryQueryInfo.setDelFlag(YesOrNoEnum.NO);
 		goodsCategoryQueryInfo.setPage(1);
 		goodsCategoryQueryInfo.setRows(9999);
-		Map<String, Integer> categoryIdNameMap = goodsCategoryService.querySubjectGoods(goodsCategoryQueryInfo).getRows()
-				.stream().collect(Collectors.toMap(SubjectGoodsDto::getGoodsCategoryName, SubjectGoodsDto::getGoodsCategoryId));
+
+		List<ProductCategoryDto> categoryList = mallFeignService.listWithChildren();
+		List<ProductCategoryDto> allCategoryList = treeToList(categoryList);
+		Map<String, Long> categoryIdNameMap = allCategoryList
+				.stream().collect(Collectors.toMap(ProductCategoryDto::getName, ProductCategoryDto::getId));
 		Set<String> categoryNames = categoryIdNameMap.keySet();
 
 		// 查询员工机构
@@ -612,14 +629,14 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		InputStream inputStream = new ClassPathResource("columnMapper.ini").getInputStream();
 		Map<String, String> columns = IniFileUtil.readIniFile(inputStream, TemplateTypeEnum.GOODS_GROUP.getMsg());
 
-		List<Map<String, Object>> firstSheet = sheetsListMap.get(0);
+		List<Map<String, Object>> firstSheet = sheetsListMap.entrySet().iterator().next().getValue();
 		List<String> skuList = firstSheet.stream().map(next -> next.get("SKU").toString()).distinct().collect(Collectors.toList());
 
 		List<PmsProductDto> subGoods;
 		try {
 			// 查询SKU对应商品
 			PmsProductQueryParamDto dto = PmsProductQueryParamDto.builder()
-					.skuStockIds(String.join(",", skuList))
+					.skuStockCodes(String.join(",", skuList))
 					.pageNum(1)
 					.pageSize(9999)
 					.build();
@@ -629,11 +646,15 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 			errList.add("商城服务调用失败");
 			return getExportErrLogFile(errList);
 		}
-		Map<String, PmsProductDto>skuMap = subGoods.stream().collect(Collectors.toMap(next -> (next.getName() + "_" + next.getSkuCode()), Function.identity()));
+		Map<String, PmsProductDto> skuMap = new HashMap<>();
+		subGoods.forEach(next -> {
+			String key = next.getName() + "_" + next.getSkuCode();
+			if (!skuMap.containsKey(key)) { // 处理出现重复key问题
+				skuMap.put(key, next);
+			}
+		});
 
-//		List<GoodsWrapper.Goods> goodsList = new ArrayList<>();
 		List<JSONObject> jsonObjectList = new ArrayList<>();
-		Set<String> snSet = new HashSet<>();
 		for (Map.Entry<String, List<Map<String, Object>>> sheetData : sheetsListMap.entrySet()) {
 			List<Map<String, Object>> rows = sheetData.getValue();
 			if (rows.isEmpty()) {
@@ -642,26 +663,24 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 			Map<String, Object> firstRow = rows.get(0);
 			// 缺省字段
 			Set<String> templateFields = columns.keySet();
-			List<String> defaultField = templateFields.stream().filter(firstRow::containsKey).collect(Collectors.toList());
+			List<String> defaultField = templateFields.stream().filter(next->!firstRow.containsKey(next)).collect(Collectors.toList());
 			if (!defaultField.isEmpty()) {
 				errList.add("导入字段缺省:" + String.join(",", defaultField));
 				return getExportErrLogFile(errList);
 			}
 
-			String lineErrMsg = "第%s行存在错误:%s";
+			String lineErrMsg = "错误行号:第%s行,%s";
 			Map<String, String> beforeGoods = new HashMap<>();
 
-			JSONObject objectMap = new JSONObject();
-			String subGoodsName = null;
-			String subGoodsSku = null;
 			for (int i = 0; i < rows.size(); i++) {
+				JSONObject objectMap = new JSONObject();
 				int rowNum = i + 2;
-//				GoodsWrapper.Goods goods = new GoodsWrapper.Goods();
-//				GoodsWrapper.GoodsSub goodsSub = new GoodsWrapper.GoodsSub();
 				Map<String, Object> row = rows.get(i);
 				if (row.size() == 0) {
 					continue;
 				}
+				String subGoodsName = null;
+				String subGoodsSku = null;
 				List<String> lineErrList = new ArrayList<>();
 				for (Map.Entry<String, Object> entry : row.entrySet()) {
 					String fieldName = entry.getKey();
@@ -710,17 +729,17 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 						}
 					} else if ("type".equals(fieldCode)) {
 						String tempValue = value;
-						boolean match = Arrays.stream(GoodsType.values()).allMatch(next -> next.getDesc().equals(tempValue));
-						if (match) {
-							objectMap.put(fieldCode, value);
+						Optional<GoodsType> first = Arrays.stream(GoodsType.values()).filter(next -> next.getDesc().equals(tempValue)).findFirst();
+						if (first.isPresent()) {
+							objectMap.put(fieldCode, first.get().getCode());
 						} else {
 							lineErrList.add("字段‘" + fieldName + "’类型不支持");
 						}
 					} else if ("goodsCategoryName".equals(fieldCode)) {
 						if(categoryNames.contains(value)){
-							objectMap.put("goodsCategoryId", categoryIdNameMap.get(value));
+							objectMap.put("goodsCategoryId", categoryIdNameMap.get(value).intValue());
 						}else {
-							lineErrList.add("字段‘" + fieldName + "’类型不支持");
+							lineErrList.add("字段‘" + fieldName + "’不支持");
 						}
 					} else if ("educationShowOrganName".equals(fieldCode)
 							|| "courseFeeShowOrganName".equals(fieldCode)
@@ -750,7 +769,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 								objectMap.put("stock", dto.getStock());
 								objectMap.put("goodsStatus", dto.getPublishStatus()==1);
 							} else {
-								lineErrList.add("子商品‘" + value + "[" + subGoodsSku + "]’不存在");
+								lineErrList.add("子商品‘" + subGoodsName + "[" + subGoodsSku + "]’不存在");
 							}
 						}
 					} else if ("sku".equals(fieldCode)) {
@@ -764,7 +783,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 								objectMap.put("stock", dto.getStock());
 								objectMap.put("goodsStatus", dto.getPublishStatus()==1);
 							} else {
-								lineErrList.add("子商品‘" + value + "[" + subGoodsSku + "]’不存在");
+								lineErrList.add("子商品‘" + subGoodsName + "[" + subGoodsSku + "]’不存在");
 							}
 						}
 					} else if ("subGoodsPrice".equals(fieldCode)) {
@@ -802,7 +821,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 			return goods;
 		}).collect(Collectors.toList());
 
-		Map<String, List<GoodsWrapper.Goods>> goodsGroup = goodsList.stream().collect(Collectors.groupingBy(next -> next.getClass() + "_" + next.getSn()));
+		Map<String, List<GoodsWrapper.Goods>> goodsGroup = goodsList.stream().collect(Collectors.groupingBy(next -> next.getName() + "_" + next.getSn()));
 //
 //
 //		// 数据合并
@@ -1104,7 +1123,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 			goods.setFreeFeeShowOrganName(StringUtils.join(organizationDao.findByOrganIds(goods.getFreeFeeShowOrganId()),","));
 		}
 		GoodsWrapper.Goods detail = JSON.parseObject(JSON.toJSONString(goods), GoodsWrapper.Goods.class);
-		detail.setGoodsSubList(queryGoodsSub(goodsId));
+		detail.setGoodsSubList(queryGoodsSubByGoodId(goodsId));
 		return detail;
 	}
 
@@ -1299,7 +1318,10 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 			throw new RuntimeException(e);
 		}
 		try {
-			BufferedWriter csvFileOutputStream = new BufferedWriter(new OutputStreamWriter(Files.newOutputStream(file.toPath()), StandardCharsets.UTF_8), 1024);
+			FileOutputStream out = new FileOutputStream(file);
+			byte[] uft8bom = {(byte) 0xef, (byte) 0xbb, (byte) 0xbf}; // 处理乱码
+			out.write(uft8bom);
+			BufferedWriter csvFileOutputStream = new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8));
 
 			for (String errMsg : errList) {
 				csvFileOutputStream.write(errMsg);
@@ -1314,4 +1336,21 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods>  implement
 		}
 		return "";
 	}
+
+	public List<ProductCategoryDto> treeToList(List<ProductCategoryDto> categoryList) {
+		if (categoryList.isEmpty()) {
+			return new ArrayList<>();
+		}
+		List<ProductCategoryDto> result = new ArrayList<>();
+		categoryList.forEach(next -> {
+			result.add(next);
+			String name = next.getName();
+			List<ProductCategoryDto> children = next.getChildren();
+			if (!CollectionUtils.isEmpty(children)) {
+				children.forEach(c -> c.setName(name + "/" + c.getName()));
+				result.addAll(children);
+			}
+		});
+		return result;
+	}
 }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -1837,7 +1837,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             model.setSuccess(true);
         } catch (Exception e) {
             model.setSuccess(false);
-            e.printStackTrace();
+            logger.error("订单[{}]取消失败", order.getTransNo(), e);
         }
         return model;
     }

+ 2 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/dto/PmsProductQueryParamDto.java

@@ -16,6 +16,8 @@ import javax.validation.constraints.NotNull;
 public class PmsProductQueryParamDto {
     //skuId多个逗号隔开
     private String skuStockIds;
+    //skuCode多个逗号隔开
+    private String skuStockCodes;
     //上架状态
     private Integer publishStatus;
     //商品名称模糊关键字

+ 4 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/dto/ProductCategoryDto.java

@@ -3,6 +3,8 @@ package com.ym.mec.common.dto;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
 
 @Data
 public class ProductCategoryDto {
@@ -12,4 +14,6 @@ public class ProductCategoryDto {
     private Long parentId;
 
     private String name;
+
+    private List<ProductCategoryDto> children = new ArrayList<>();
 }

+ 12 - 0
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/PmsProductServiceImpl.java

@@ -286,6 +286,17 @@ public class PmsProductServiceImpl implements PmsProductService {
         List<PmsSkuStock> removeSkuList = oriStuList.stream().filter(item-> !updateSkuIds.contains(item.getId())).collect(Collectors.toList());
         handleSkuStockCode(insertSkuList,id);
         handleSkuStockCode(updateSkuList,id);
+
+        List<PmsSkuStock> adds= new ArrayList<>();
+        adds.addAll(insertSkuList);
+        adds.addAll(updateSkuList);
+
+        // 判断sku编码是否重复
+        List<String> skuCodes = adds.stream().map(PmsSkuStock::getSkuCode).collect(Collectors.toList());
+        long distinctCount = skuCodes.stream().distinct().count();
+        if (distinctCount != skuCodes.size()) {
+            throw new BizException("SKU编码重复");
+        }
         //新增sku
         if(CollUtil.isNotEmpty(insertSkuList)){
             relateAndInsertList(skuStockDao, insertSkuList, id);
@@ -301,6 +312,7 @@ public class PmsProductServiceImpl implements PmsProductService {
         }
         //修改sku
         if(CollUtil.isNotEmpty(updateSkuList)){
+
             for (PmsSkuStock pmsSkuStock : updateSkuList) {
                 pmsSkuStock.setLockStock(null);
                 skuStockMapper.updateByPrimaryKeySelective(pmsSkuStock);

+ 10 - 0
mec-mall/mall-admin/src/main/java/com/yonge/cooleshow/admin/service/impl/PmsSkuStockServiceImpl.java

@@ -2,6 +2,7 @@ package com.yonge.cooleshow.admin.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.google.common.collect.Lists;
+import com.ym.mec.common.exception.BizException;
 import com.yonge.cooleshow.admin.dao.PmsSkuStockDao;
 import com.yonge.cooleshow.admin.wrapper.PmsSkuStockWrapper;
 import com.yonge.cooleshow.mbg.dto.PmsSkuStockDto;
@@ -69,6 +70,15 @@ public class PmsSkuStockServiceImpl implements PmsSkuStockService {
 
     @Override
     public int update(Long pid, List<PmsSkuStock> skuStockList) {
+
+        // 判断sku code是否重复
+        // 判断sku编码是否重复
+        List<String> skuCodes = skuStockList.stream().map(PmsSkuStock::getSkuCode).collect(Collectors.toList());
+        long distinctCount = skuCodes.stream().distinct().count();
+        if (distinctCount != skuCodes.size()) {
+            throw new BizException("SKU编码重复");
+        }
+
         return skuStockDao.replaceList(skuStockList);
     }
 

+ 3 - 0
mec-mall/mall-admin/src/main/resources/config/mybatis/PmsProductDao.xml

@@ -136,6 +136,9 @@
             <if test="param.skuStockIds != null and param.skuStockIds != ''">
                 and find_in_set(t1.id,#{param.skuStockIds})
             </if>
+            <if test="param.skuStockCodes != null and param.skuStockCodes != ''">
+                and find_in_set(t1.sku_code,#{param.skuStockCodes})
+            </if>
             <if test="param.keyword != null and param.keyword != ''">
                 and (t.name like concat('%',#{param.keyword},'%') )
             </if>

+ 10 - 5
mec-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/impl/OmsCartItemServiceImpl.java

@@ -10,10 +10,7 @@ import com.yonge.cooleshow.mbg.model.*;
 import com.yonge.cooleshow.portal.dao.PortalProductDao;
 import com.yonge.cooleshow.portal.domain.CartProduct;
 import com.yonge.cooleshow.portal.domain.CartPromotionItem;
-import com.yonge.cooleshow.portal.service.OmsCartItemService;
-import com.yonge.cooleshow.portal.service.OmsPromotionService;
-import com.yonge.cooleshow.portal.service.PmsPortalProductService;
-import com.yonge.cooleshow.portal.service.UmsMemberService;
+import com.yonge.cooleshow.portal.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
@@ -49,6 +46,9 @@ public class OmsCartItemServiceImpl implements OmsCartItemService {
     @Autowired
     private PmsPortalProductService portalProductService;
 
+    @Autowired
+    private PortalBrandService portalBrandService;
+
     @Override
     public OmsCartItem add(OmsCartItem cartItem) {
         UmsMember currentMember;
@@ -85,7 +85,12 @@ public class OmsCartItemServiceImpl implements OmsCartItemService {
             cartItem.setProductName(pmsProduct.getName());
             cartItem.setProductSubTitle(pmsProduct.getSubTitle());
             cartItem.setProductCategoryId(pmsProduct.getProductCategoryId());
-            cartItem.setProductBrand(pmsProduct.getName());
+            if (pmsProduct.getBrandId() != null) {
+                PmsBrand detail = portalBrandService.detail(pmsProduct.getBrandId());
+                if ( detail != null) {
+                    cartItem.setProductBrand(detail.getName());
+                }
+            }
             cartItem.setProductSn(pmsProduct.getProductSn());
             if (cartItem.getProductSkuId() != null) {
                 cartItem.setProductSkuCode(pmsSkuStock.getSkuCode());

+ 1 - 1
mec-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/impl/OmsPortalOrderServiceImpl.java

@@ -602,7 +602,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
                 if (!data.getSuccess()) {
                     throw new BizException("远程取消失败");
                 }
-                if (data.getStatus()) {
+                if (data.getStatus() !=null && data.getStatus()) {
                     LOG.info("订单支付成功,修改订单状态");
                     orderSuccess(cancelOrder, cancelOrder.getPayAmount(), data.getPayChannel());
                     return;