|
@@ -14,6 +14,7 @@ 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.entity.Goods;
|
|
|
+import com.ym.mec.biz.dal.entity.GoodsCategory;
|
|
|
import com.ym.mec.biz.dal.entity.GoodsProcurement;
|
|
|
import com.ym.mec.biz.dal.entity.GoodsSub;
|
|
|
import com.ym.mec.biz.dal.entity.Organization;
|
|
@@ -47,6 +48,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;
|
|
@@ -128,13 +130,9 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
if (CollectionUtils.isEmpty(rows)) {
|
|
|
throw new BizException("没有查询到商品信息");
|
|
|
}
|
|
|
- List<ProductCategoryDto> productCategoryDtos = treeToList(queryGoodsCategoryList());
|
|
|
- Map<Long, String> IdNamemap = productCategoryDtos.stream().collect(Collectors.toMap(ProductCategoryDto::getId, ProductCategoryDto::getName));
|
|
|
-
|
|
|
List<Organization> all = organizationDao.findAll(params);
|
|
|
Map<Integer, String> organizationMap = all.stream().collect(Collectors.toMap(Organization::getId, Organization::getName));
|
|
|
for (Goods goods : rows) {
|
|
|
- goods.setGoodsCategoryName(IdNamemap.getOrDefault(Long.valueOf(goods.getGoodsCategoryId()),""));
|
|
|
if(StringUtils.isNotEmpty(goods.getStudentShowOrganId())){
|
|
|
String[] split = goods.getStudentShowOrganId().split(",");
|
|
|
StringBuffer sb = new StringBuffer();
|
|
@@ -349,6 +347,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
PmsProductDto dto = map.get(next.getSku());
|
|
|
if (dto != null) {
|
|
|
next.setPrice(dto.getPrice());
|
|
|
+ next.setSkuCode(dto.getSkuCode());
|
|
|
if (1 == dto.getDeleteStatus()) {
|
|
|
next.setGoodsStatus(false);
|
|
|
} else {
|
|
@@ -384,29 +383,14 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageInfo<Goods> queryPage(GoodsQueryInfo queryInfo) {
|
|
|
- Integer goodsCategoryId = queryInfo.getGoodsCategoryId();
|
|
|
- if (goodsCategoryId != null) {
|
|
|
- Map<Long, ProductCategoryDto> idCategoryMap = mallFeignService.listWithChildren().stream().collect(Collectors.toMap(ProductCategoryDto::getId, Function.identity()));
|
|
|
- if (idCategoryMap.containsKey(Long.valueOf(goodsCategoryId))) {
|
|
|
- ProductCategoryDto productCategoryDto = idCategoryMap.get(Long.valueOf(goodsCategoryId));
|
|
|
- List<String> categoryIdList = productCategoryDto.getChildren().stream().map(ProductCategoryDto::getId).map(String::valueOf).distinct().collect(Collectors.toList());
|
|
|
- categoryIdList.add(goodsCategoryId.toString());
|
|
|
- queryInfo.setGoodsCategoryIds(String.join(",", categoryIdList));
|
|
|
- queryInfo.setGoodsCategoryId(null);
|
|
|
- }
|
|
|
- }
|
|
|
+ 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;
|
|
@@ -629,10 +613,10 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
goodsCategoryQueryInfo.setPage(1);
|
|
|
goodsCategoryQueryInfo.setRows(9999);
|
|
|
|
|
|
- List<ProductCategoryDto> categoryList = mallFeignService.listWithChildren();
|
|
|
- List<ProductCategoryDto> allCategoryList = categoryList.stream().map(ProductCategoryDto::getChildren).filter(next->!next.isEmpty()).flatMap(Collection::stream).collect(Collectors.toList());
|
|
|
- Map<String, Long> categoryIdNameMap = allCategoryList
|
|
|
- .stream().collect(Collectors.toMap(ProductCategoryDto::getName, ProductCategoryDto::getId));
|
|
|
+
|
|
|
+ List<GoodsCategory> categoryList = goodsCategoryService.findAll(new HashMap<>()).stream().filter(next -> YesOrNoEnum.NO.equals(next.getDelFlag())).collect(Collectors.toList());
|
|
|
+ Map<String, Integer> categoryIdNameMap = categoryList
|
|
|
+ .stream().collect(Collectors.toMap(GoodsCategory::getName, GoodsCategory::getId));
|
|
|
Set<String> categoryNames = categoryIdNameMap.keySet();
|
|
|
|
|
|
// 查询员工机构
|
|
@@ -668,8 +652,13 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- List<String> snSet = firstSheet.stream().map(next -> next.get("组合商品货号").toString()).filter(StringUtils::isNotEmpty).distinct().collect(Collectors.toList());
|
|
|
- List<String> existSnList = goodsDao.findBySns(snSet).stream().map(Goods::getSn).distinct().collect(Collectors.toList());
|
|
|
+ // excel中所有的sn
|
|
|
+ List<String> snSet = firstSheet.stream().map(next -> next.get("组合商品货号").toString()).filter(StringUtils::isNotEmpty).collect(Collectors.toList());
|
|
|
+ // 获取重复的货号
|
|
|
+ List<String> repeatSnList = snSet.stream().collect(Collectors.groupingBy(e -> e, Collectors.counting()))
|
|
|
+ .entrySet().stream().filter(e -> e.getValue() > 1)
|
|
|
+ .map(Map.Entry::getKey).collect(Collectors.toList());
|
|
|
+ List<String> existSnList = goodsDao.findBySns(snSet.stream().distinct().collect(Collectors.toList())).stream().map(Goods::getSn).distinct().collect(Collectors.toList());
|
|
|
|
|
|
Map<String, Long> brandNameIdMap = mallFeignService.getList().stream().collect(Collectors.toMap(BrandDto::getName, BrandDto::getId));
|
|
|
|
|
@@ -690,8 +679,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
|
|
|
String lineErrMsg = "错误行号:第%s行,%s";
|
|
|
Map<String, String> beforeGoods = new HashMap<>();
|
|
|
-
|
|
|
- Map<String, String> snNameMap = new HashMap<>();
|
|
|
+ Map<String, Set<String>> snSubGoodsMap = new HashMap<>();
|
|
|
for (int i = 0; i < rows.size(); i++) {
|
|
|
JSONObject objectMap = new JSONObject();
|
|
|
int rowNum = i + 2;
|
|
@@ -699,6 +687,11 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
if (row.size() == 0) {
|
|
|
continue;
|
|
|
}
|
|
|
+ // 新商品标志
|
|
|
+ String sn = row.get("组合商品货号").toString();
|
|
|
+ if (StringUtils.isNotEmpty(sn)) {
|
|
|
+ beforeGoods.clear();
|
|
|
+ }
|
|
|
String subGoodsName = null;
|
|
|
String subGoodsSku = null;
|
|
|
List<String> lineErrList = new ArrayList<>();
|
|
@@ -731,21 +724,16 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
} else {
|
|
|
beforeGoods.put(fieldCode, value);
|
|
|
}
|
|
|
- if("sn".equals(fieldCode)){
|
|
|
+ if ("sn".equals(fieldCode)) {
|
|
|
if (existSnList.contains(value)) {
|
|
|
lineErrList.add("货号[" + value + "]已存在");
|
|
|
} else {
|
|
|
- String goodsName = row.get("组合商品名称").toString();
|
|
|
- if (snNameMap.containsKey(value) && !snNameMap.get(value).equals(goodsName)) {
|
|
|
+ if (repeatSnList.contains(value)) {
|
|
|
lineErrList.add("货号[" + value + "]重复");
|
|
|
- } else {
|
|
|
- snNameMap.put(value, goodsName);
|
|
|
}
|
|
|
- objectMap.put(fieldCode, value);
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- if ("marketPrice".equals(fieldCode)
|
|
|
+ objectMap.put(fieldCode, value);
|
|
|
+ } else if ("marketPrice".equals(fieldCode)
|
|
|
|| "discountPrice".equals(fieldCode)
|
|
|
|| "groupPurchasePrice".equals(fieldCode)) {
|
|
|
if (NumberUtils.isNumber(value)) {
|
|
@@ -842,8 +830,21 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
!objectMap.containsKey("memberFeeShowOrganId") &&
|
|
|
!objectMap.containsKey("freeFeeShowOrganId") &&
|
|
|
!objectMap.containsKey("replacementShowOrganId")) {
|
|
|
- lineErrList.add("可售分部至少需要选择一个");
|
|
|
+ lineErrList.add("可售分部至少需要填写一个");
|
|
|
}
|
|
|
+ // 校验子商品sku是否重复
|
|
|
+ String tempSn = objectMap.get("sn").toString();
|
|
|
+ String tempSku = objectMap.get("sku").toString();
|
|
|
+ if (StringUtils.isNotEmpty(tempSn) && StringUtils.isNotEmpty(tempSku)) {
|
|
|
+ Set<String> set = snSubGoodsMap.getOrDefault(tempSn, new HashSet<>());
|
|
|
+ if (set.contains(tempSku)) {
|
|
|
+ lineErrList.add("子商品SKU重复");
|
|
|
+ } else {
|
|
|
+ set.add(tempSku);
|
|
|
+ snSubGoodsMap.put(tempSn, set);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (!lineErrList.isEmpty()) {
|
|
|
errList.add(String.format(lineErrMsg, rowNum, String.join(",", lineErrList)));
|
|
|
}
|
|
@@ -863,6 +864,7 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
List<GoodsWrapper.Goods> goodsList = jsonObjectList.stream().map(next -> {
|
|
|
String jsonString = next.toJSONString();
|
|
|
GoodsWrapper.Goods goods = JSON.parseObject(jsonString, GoodsWrapper.Goods.class);
|
|
|
+ goods.setSellCount(0);
|
|
|
GoodsWrapper.GoodsSub goodsSub = JSON.parseObject(jsonString, GoodsWrapper.GoodsSub.class);
|
|
|
ArrayList<GoodsWrapper.GoodsSub> arrayList = new ArrayList<>();
|
|
|
arrayList.add(goodsSub);
|
|
@@ -1173,10 +1175,6 @@ public class GoodsServiceImpl extends BaseServiceImpl<Integer, Goods> implement
|
|
|
}
|
|
|
GoodsWrapper.Goods detail = JSON.parseObject(JSON.toJSONString(goods), GoodsWrapper.Goods.class);
|
|
|
detail.setGoodsSubList(queryGoodsSubByGoodId(goodsId));
|
|
|
-
|
|
|
- List<ProductCategoryDto> productCategoryDtos = treeToList(queryGoodsCategoryList());
|
|
|
- Map<Long, String> IdNamemap = productCategoryDtos.stream().collect(Collectors.toMap(ProductCategoryDto::getId, ProductCategoryDto::getName));
|
|
|
- detail.setGoodsCategoryName(IdNamemap.getOrDefault(Long.valueOf(detail.getGoodsCategoryId()), ""));
|
|
|
return detail;
|
|
|
}
|
|
|
|
|
@@ -1404,21 +1402,4 @@ 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;
|
|
|
- }
|
|
|
}
|