diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/controller/ProductController.java b/cereshop-business/src/main/java/com/shop/cereshop/business/controller/ProductController.java index 715d4c5..831c47f 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/controller/ProductController.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/controller/ProductController.java @@ -279,7 +279,7 @@ public class ProductController { return new Result(CoReturnFormat.NOT_FILE); } Workbook wb= WorkbookFactory.create(file.getInputStream()); - cereShopProductService.importProduct(wb); + cereShopProductService.importProduct(ContextUtil.getShopId(), wb); return new Result(); } diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/dao/product/CereShopProductDAO.java b/cereshop-business/src/main/java/com/shop/cereshop/business/dao/product/CereShopProductDAO.java index 77f9e00..646b4ed 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/dao/product/CereShopProductDAO.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/dao/product/CereShopProductDAO.java @@ -54,6 +54,8 @@ public interface CereShopProductDAO extends BaseMapper { List selectAll(); + List selectAllByShopId(@Param("shopId") Long shopId); + List getProductMembers(@Param("productId") Long productId); int deleteShopCartByProductId(@Param("productId")Long productId); diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductSaveParam.java b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductSaveParam.java index 1c2fe36..44ff93a 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductSaveParam.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductSaveParam.java @@ -24,6 +24,11 @@ import java.util.List; @ApiModel(value = "ProductSaveParam", description = "添加商品请求") public class ProductSaveParam { + @ApiModelProperty(value = "商品Id", hidden = true) + private Long productId; + + @ApiModelProperty(value = "是否是新商品", hidden = true) + private Boolean isNew; /** * 店铺id */ diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/checkImport/ImportCheckService.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/checkImport/ImportCheckService.java index 10d517d..45cde5b 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/checkImport/ImportCheckService.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/service/checkImport/ImportCheckService.java @@ -12,5 +12,5 @@ import com.shop.cereshop.commons.exception.CoBusinessException; import java.util.List; public interface ImportCheckService { - List checkProduct(List list) throws CoBusinessException; + List checkProduct(Long shopId, List list) throws CoBusinessException; } diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/checkImport/impl/importCheckServiceImpl.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/checkImport/impl/importCheckServiceImpl.java index bf7a70b..3f6f5e6 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/checkImport/impl/importCheckServiceImpl.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/service/checkImport/impl/importCheckServiceImpl.java @@ -6,7 +6,9 @@ package com.shop.cereshop.business.service.checkImport.impl; import com.google.gson.Gson; +import com.shop.cereshop.business.page.storehouse.Storehouse; import com.shop.cereshop.business.param.product.*; +import com.shop.cereshop.business.param.storehouse.ShopStorehouseGetAllParam; import com.shop.cereshop.business.service.checkImport.ImportCheckService; import com.shop.cereshop.business.service.product.CereProductClassifyService; import com.shop.cereshop.business.service.product.CereProductSkuService; @@ -18,9 +20,7 @@ import com.shop.cereshop.commons.constant.IntegerEnum; import com.shop.cereshop.commons.constant.StringEnum; import com.shop.cereshop.commons.domain.product.CereProductClassify; import com.shop.cereshop.commons.domain.product.CereShopProduct; -import com.shop.cereshop.commons.domain.shop.CerePlatformShop; import com.shop.cereshop.commons.domain.shop.CereShopGroup; -import com.shop.cereshop.commons.domain.storehouse.CereShopStorehouse; import com.shop.cereshop.commons.exception.CoBusinessException; import com.shop.cereshop.commons.utils.EmptyUtils; import lombok.extern.slf4j.Slf4j; @@ -55,33 +55,51 @@ public class importCheckServiceImpl implements ImportCheckService { private CereShopStorehouseService cereShopStorehouseService; @Override - public List checkProduct(List list) throws CoBusinessException { + public List checkProduct(Long shopId, List list) throws CoBusinessException { String message=""; - List products=new ArrayList<>(); + + Map productMaps=new HashMap<>(); + if(!EmptyUtils.isEmpty(list)){ Map map=new HashMap<>(); //校验是否存在重复商品名称数据 for (ProductImport item : list) { - if(!EmptyUtils.isEmpty(map.get(item.getProductName()))){ + if(!EmptyUtils.isEmpty(map.get(item.getProductName() + "--" + item.getSkuValue()))){ //如果存在 message+=item.getProductName()+";"; }else { - map.put(item.getProductName(),item); + map.put(item.getProductName() + "--" + item.getSkuValue(),item); } } if(map.size()!=list.size()){ message+="以上数据在表格中有重复,请修改后重试!"; } + if(!EmptyUtils.isEmpty(message)){ + throw new CoBusinessException(message); + } + + //校验必填项 + for (ProductImport productImport : list) { + if (EmptyUtils.isEmpty(productImport.getOneClassifyName()) + || EmptyUtils.isEmpty(productImport.getProductName()) + || EmptyUtils.isEmpty(productImport.getSkuValue()) || EmptyUtils.isEmpty(productImport.getPrice()) + || EmptyUtils.isEmpty(productImport.getOriginalPrice())) { + message += "存在必填项为空的数据,请检查后重试"; + } + } + if(!EmptyUtils.isEmpty(message)){ + throw new CoBusinessException(message); + } + //定义分类map Map classifyMap=new HashMap<>(); //定义分组map Map groupMap=new HashMap<>(); //定义商品map - Map productMap=new HashMap<>(); - //定义商家map - Map shopMap=new HashMap<>(); + Map dbProductMap=new HashMap<>(); //定义仓库map - Map storehouseMap=new HashMap<>(); + Map storehouseMap=new HashMap<>(); + //查询所有分类数据 List classifies=cereProductClassifyService.selectAll(); if(!EmptyUtils.isEmpty(classifies)){ @@ -89,42 +107,29 @@ public class importCheckServiceImpl implements ImportCheckService { } //分组数据 - List groups=cereShopGroupService.selectAll(); + ProductGetGroupParam shopGroupParam = new ProductGetGroupParam(); + shopGroupParam.setShopId(shopId); + List groups = cereShopGroupService.getGroupSelect(shopGroupParam); if(!EmptyUtils.isEmpty(groups)){ groups.forEach((item)->groupMap.put(item.getShopId()+"-"+item.getGroupName(), item)); } + //查询所有商品数据 - List productList=cereShopProductService.selectAll(); + List productList=cereShopProductService.selectAllByShopId(shopId); if(!EmptyUtils.isEmpty(productList)){ - productList.forEach((item)->productMap.put(item.getShopId()+"-"+item.getClassifyId()+"-"+item.getProductName(),item)); + productList.forEach((item)->dbProductMap.put(item.getShopId()+"-"+item.getClassifyId()+"-"+item.getProductName(),item)); } //查询所有仓库 - List storehouseList= cereShopStorehouseService.selectAll(); + ShopStorehouseGetAllParam storehouseParams = new ShopStorehouseGetAllParam(); + storehouseParams.setShopId(shopId); + List storehouseList= cereShopStorehouseService.selectAllByParam(storehouseParams); if(!EmptyUtils.isEmpty(storehouseList)){ storehouseList.forEach((item)->storehouseMap.put(item.getShopId()+"-"+item.getStorehouseName(),item)); } - //查询所有商家 - List shops=cerePlatformShopService.selectAll(); - if(!EmptyUtils.isEmpty(shops)){ - shops.forEach((item)->shopMap.put(item.getShopName(),item)); - } for (int i = 0; i < list.size(); i++) { - ProductSaveParam param=new ProductSaveParam(); ProductImport productImport = list.get(i); - //校验必填项 - if(EmptyUtils.isEmpty(productImport.getShopName())||EmptyUtils.isEmpty(productImport.getOneClassifyName()) - ||EmptyUtils.isEmpty(productImport.getProductName()) - ||EmptyUtils.isEmpty(productImport.getSkuValue())||EmptyUtils.isEmpty(productImport.getPrice()) - ||EmptyUtils.isEmpty(productImport.getOriginalPrice())){ - message+="存在必填项为空的数据,请检查后重试"; - } - //根据商家名称查询商家是否存在 - if(EmptyUtils.isEmpty(shopMap.get(productImport.getShopName()))){ - message+="第"+(i+3)+"行商家未注册;"; - continue; - } String classifyName=""; if(!EmptyUtils.isEmpty(productImport.getOneClassifyName())){ @@ -136,7 +141,7 @@ public class importCheckServiceImpl implements ImportCheckService { if(!EmptyUtils.isEmpty(productImport.getThreeClassifyName())){ classifyName+="-"+productImport.getThreeClassifyName(); } - CerePlatformShop shop = shopMap.get(productImport.getShopName()); + log.info("商品分类:"+classifyName); CereProductClassify classify = classifyMap.get(classifyName); if(EmptyUtils.isEmpty(classify)){ @@ -144,29 +149,32 @@ public class importCheckServiceImpl implements ImportCheckService { continue; } - - String key=shop.getShopId()+"-"+classify.getClassifyId()+"-"+productImport.getProductName(); - CereShopGroup cereShopGroup = groupMap.get(shop.getShopId()+"-"+productImport.getShopGroupName()); + CereShopGroup cereShopGroup = groupMap.get(shopId+"-"+productImport.getShopGroupName()); if(EmptyUtils.isEmpty(cereShopGroup)){ - message+="第"+(i+3)+"行分类数据出错;"; + message+="第"+(i+3)+"行分组数据出错;"; continue; } - if(EmptyUtils.isEmpty(storehouseMap.get(shop.getShopId()+"-"+productImport.getStorehouseName()))){ + if(EmptyUtils.isEmpty(storehouseMap.get(shopId+"-"+productImport.getStorehouseName()))){ message+="第"+(i+3)+"行仓库出错;"; continue; } - //校验商品是否已存在 - if(!EmptyUtils.isEmpty(productMap.get(key))){ - message+="第"+(i+3)+"行商品已存在;"; + + String productKey = productImport.getProductName(); + + ProductSaveParam param = new ProductSaveParam(); + if(productMaps.containsKey(productKey)){ + //重复商品进行累加 + param = productMaps.get(productKey); }else { + productMaps.put(productKey, param); + //正常商品数据封装 - param.setShopId(shop.getShopId()); + param.setShopId(shopId); param.setClassifyId(classify.getClassifyId()); param.setProductName(productImport.getProductName()); param.setSupplierName(productImport.getSupplierName()); - param.setShopGroupId(cereShopGroup.getShopGroupId()); if(!EmptyUtils.isEmpty(productImport.getIfLogistics())){ @@ -196,39 +204,51 @@ public class importCheckServiceImpl implements ImportCheckService { }else { param.setShelveState(String.valueOf(IntegerEnum.YES.getCode())); } - //封装规格数据 - List skus=new ArrayList<>(); - SkuParam cereProductSku=new SkuParam(); - List cereSkuNames=new ArrayList<>(); - NameValue nameValue=new NameValue(); - nameValue.setSkuValue(productImport.getSkuValue()); - cereProductSku.setNameValue(nameValue); - cereProductSku.setSkuAttrCodeDTOList(cereSkuNames); - cereProductSku.setPrice(productImport.getPrice()); - cereProductSku.setRate(productImport.getRate()); - - CereShopStorehouse cereShopStorehouse = storehouseMap.get(shop.getShopId()+"-"+productImport.getStorehouseName()); - cereProductSku.setStorehouseId(cereShopStorehouse.getStorehouseId().intValue()); - - if(!EmptyUtils.isEmpty(productImport.getIsCross())){ - cereProductSku.setIsCross(0); + + //校验商品是否已存在 + String dbProductKey=shopId+"-"+classify.getClassifyId()+"-"+productImport.getProductName(); + if(dbProductMap.containsKey(dbProductKey)){ + param.setProductId(dbProductMap.get(dbProductKey).getProductId()); }else { - cereProductSku.setIsCross(new Integer(productImport.getIsCross())); + param.setProductId(null); } - cereProductSku.setSku(productImport.getSku()); - cereProductSku.setOriginalPrice(productImport.getOriginalPrice()); - cereProductSku.setStockNumber(productImport.getStockNumber()); - cereProductSku.setWeight(productImport.getWeight()); - log.info(new Gson().toJson(cereProductSku)); - skus.add(cereProductSku); + } + + //封装规格数据 + List skus= param.getSkus(); + if(skus == null){ + skus = new ArrayList<>(); param.setSkus(skus); - products.add(param); } + + SkuParam cereProductSku=new SkuParam(); + List cereSkuNames=new ArrayList<>(); + NameValue nameValue=new NameValue(); + nameValue.setSkuValue(productImport.getSkuValue()); + cereProductSku.setNameValue(nameValue); + cereProductSku.setSkuAttrCodeDTOList(cereSkuNames); + cereProductSku.setPrice(productImport.getPrice()); + cereProductSku.setRate(productImport.getRate()); + + Storehouse cereShopStorehouse = storehouseMap.get(shopId+"-"+productImport.getStorehouseName()); + cereProductSku.setStorehouseId(cereShopStorehouse.getStorehouseId().intValue()); + + if(!EmptyUtils.isEmpty(productImport.getIsCross())){ + cereProductSku.setIsCross(0); + }else { + cereProductSku.setIsCross(new Integer(productImport.getIsCross())); + } + cereProductSku.setSku(productImport.getSku()); + cereProductSku.setOriginalPrice(productImport.getOriginalPrice()); + cereProductSku.setStockNumber(productImport.getStockNumber()); + cereProductSku.setWeight(productImport.getWeight()); + log.info(new Gson().toJson(cereProductSku)); + skus.add(cereProductSku); } if(!EmptyUtils.isEmpty(message)){ throw new CoBusinessException(message); } } - return products; + return new ArrayList<>(productMaps.values()); } } diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/CereShopProductService.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/CereShopProductService.java index baa569c..379cc36 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/CereShopProductService.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/CereShopProductService.java @@ -32,7 +32,7 @@ public interface CereShopProductService { Page getAll(ProductGetAllParam param) throws CoBusinessException; - void importProduct(Workbook wb) throws CoBusinessException,Exception; + void importProduct(Long shopId, Workbook wb) throws CoBusinessException,Exception; CereShopProduct checkName(Long shopId, Long classifyId, String productName); @@ -46,6 +46,8 @@ public interface CereShopProductService { List selectAll(); + List selectAllByShopId(Long shopId); + List getProductMembers(Long productId) throws CoBusinessException; void setProductMember(ProductMemberParam param) throws CoBusinessException; diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java index e6bb126..8d3dbc2 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java @@ -47,6 +47,7 @@ import com.shop.cereshop.commons.exception.CoBusinessException; import com.shop.cereshop.commons.poi.ImportExeclUtil; import com.shop.cereshop.commons.utils.EmptyUtils; import com.shop.cereshop.commons.utils.ProjectInvokeUtil; +import com.shop.cereshop.commons.utils.StringUtils; import com.shop.cereshop.commons.utils.TimeUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; @@ -196,6 +197,11 @@ public class CereShopProductServiceImpl implements CereShopProductService { @Override @Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = {CoBusinessException.class, Exception.class}) public void update(ProductUpdateParam param, CerePlatformBusiness user) throws CoBusinessException { + + CereShopProduct dbCereShopProduct = cereShopProductDAO.selectByPrimaryKey(param.getProductId()); + if(dbCereShopProduct == null){ + throw new CoBusinessException(CoReturnFormat.SYS_METHOD_UNKNOWN, "查找不到对应的商品", ""); + } String time= TimeUtils.yyMMddHHmmss(); //更新商品数据 CereShopProduct cereShopProduct=new CereShopProduct(); @@ -213,19 +219,52 @@ public class CereShopProductServiceImpl implements CereShopProductService { cereShopProduct.setIfCredit(param.getIfCredit()); cereShopProduct.setCreditLimit(param.getCreditLimit()); cereShopProduct.setBrandId(param.getBrandId()); - if (IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(param.getShelveState())) { + + + boolean isNeedReExam = false; + if(!StringUtils.equals(cereShopProduct.getProductName(), dbCereShopProduct.getProductName())){ + isNeedReExam = true; + } + if(!isNeedReExam && !StringUtils.equals(cereShopProduct.getProductBrief(), dbCereShopProduct.getProductBrief())){ + isNeedReExam = true; + } + if(!isNeedReExam && !StringUtils.equals(cereShopProduct.getProductText(), dbCereShopProduct.getProductText())){ + isNeedReExam = true; + } + if(!isNeedReExam && !Objects.equals(cereShopProduct.getClassifyId(), dbCereShopProduct.getClassifyId())){ + isNeedReExam = true; + } + if(!isNeedReExam && !Objects.equals(cereShopProduct.getShopGroupId(), dbCereShopProduct.getShopGroupId())){ + isNeedReExam = true; + } + if(!isNeedReExam && !Objects.equals(cereShopProduct.getBrandId(), dbCereShopProduct.getBrandId())){ + isNeedReExam = true; + } + + if(!isNeedReExam){ + List skuList = cereProductSkuService.findByProductId(cereShopProduct.getProductId()); + if(param.getSkus() != null && !param.getSkus().isEmpty() && skuList != null && !skuList.isEmpty()){ + if(!Objects.equals(param.getSkus().get(0).getStyle(), skuList.get(0).getStyle())){ + isNeedReExam = true; + } + } + } + + if (isNeedReExam && IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(param.getShelveState())) { //如果是已上架,修改状态为审核中 cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); } else { //已下架 cereShopProduct.setShelveState(param.getShelveState()); } + //不管是审核中,还是已下架,sku实时信息都要改成下架 projectInvokeUtil.postRefreshSkuRealInfo(param.getProductId(), null, RefreshSkuRealInfoSourceEnum.PUT_OFF_SHELVE, null); cereShopProduct.setUpdateTime(time); cereShopProduct.setShopId(param.getShopId()); cereShopProductDAO.updateByPrimaryKeySelective(cereShopProduct); + if(!EmptyUtils.isEmpty(param.getImages())){ //清空商品图片 cereProductImageService.deleteByProductId(param.getProductId()); @@ -421,48 +460,61 @@ public class CereShopProductServiceImpl implements CereShopProductService { } @Override - public void importProduct(Workbook wb) throws CoBusinessException,Exception { + public void importProduct(Long shopId, Workbook wb) throws CoBusinessException,Exception { List list = ImportExeclUtil.readDateListT(wb, new ProductImport()); String time= TimeUtils.yyMMddHHmmss(); //校验有效数据 - List products=importCheckService.checkProduct(list); + List products=importCheckService.checkProduct(shopId, list); + List coupons=cereShopCouponService.findAllByShopId(shopId); + List details = new ArrayList<>(); + if(!EmptyUtils.isEmpty(products)){ List skuNames = new ArrayList<>(); - for (ProductSaveParam param:products) { + for (ProductSaveParam param : products) { //新增商品数据 - CereShopProduct cereShopProduct=new CereShopProduct(); - cereShopProduct.setProductName(param.getProductName()); - cereShopProduct.setClassifyId(param.getClassifyId()); - cereShopProduct.setSupplierName(param.getSupplierName()); - cereShopProduct.setIfLogistics(Integer.parseInt(param.getIfLogistics())); - cereShopProduct.setIfOversold(Integer.parseInt(param.getIfOversold())); - if(IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(Integer.parseInt(param.getShelveState()))){ - //如果是已上架,修改状态为审核中 - cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); + if(param.getProductId() == null) { + CereShopProduct cereShopProduct = new CereShopProduct(); + cereShopProduct.setProductName(param.getProductName()); + cereShopProduct.setClassifyId(param.getClassifyId()); + cereShopProduct.setSupplierName(param.getSupplierName()); + cereShopProduct.setIfLogistics(Integer.parseInt(param.getIfLogistics())); + cereShopProduct.setIfOversold(Integer.parseInt(param.getIfOversold())); + if (IntegerEnum.PRODUCT_EXAMINE_YES.getCode().equals(Integer.parseInt(param.getShelveState()))) { + //如果是已上架,修改状态为审核中 + cereShopProduct.setShelveState(IntegerEnum.PRODUCT_EXAMINE_STAY.getCode()); + } else { + //已下架 + cereShopProduct.setShelveState(Integer.parseInt(param.getShelveState())); + } + cereShopProduct.setShopGroupId(param.getShopGroupId()); + cereShopProduct.setCreateTime(time); + cereShopProduct.setShopId(param.getShopId()); + cereShopProductDAO.insert(cereShopProduct); + + if(!EmptyUtils.isEmpty(coupons)){ + //如果有,将新增的商品插入到优惠券商品明细表中 + details.addAll(coupons.stream().map(coupon -> { + CereShopCouponDetail detail = new CereShopCouponDetail(); + detail.setProductId(cereShopProduct.getProductId()); + detail.setShopCouponId(coupon.getShopCouponId()); + return detail; + }).collect(Collectors.toList())); + } + //新增规格数据 + saveExcelSkus(param.getSkus(),cereShopProduct.getProductId(), + param.getSkus().size() > 1 ? IntegerEnum.SKU_STYLE_MORE.getCode() : IntegerEnum.SKU_STYLE_ONE.getCode(), + skuNames,time); }else { - //已下架 - cereShopProduct.setShelveState(Integer.parseInt(param.getShelveState())); + //新增规格数据 + saveExcelSkus(param.getSkus(),param.getProductId(), IntegerEnum.SKU_STYLE_MORE.getCode(), skuNames,time); } - cereShopProduct.setShopGroupId(param.getShopGroupId()); - cereShopProduct.setCreateTime(time); - cereShopProduct.setShopId(param.getShopId()); - cereShopProductDAO.insert(cereShopProduct); - //查询当前是否有全部商品且进行中状态的优惠券 - List coupons=cereShopCouponService.findAllByShopId(cereShopProduct.getShopId()); - if(!EmptyUtils.isEmpty(coupons)){ - //如果有,将新增的商品插入到优惠券商品明细表中 - List details = coupons.stream().map(coupon -> { - CereShopCouponDetail detail = new CereShopCouponDetail(); - detail.setProductId(cereShopProduct.getProductId()); - detail.setShopCouponId(coupon.getShopCouponId()); - return detail; - }).collect(Collectors.toList()); - //批量插入数据 - cereShopCouponDetailService.insertBatch(details); - } - //新增规格数据 - saveExcelSkus(param.getSkus(),cereShopProduct.getProductId(),skuNames,time); } + + if(!EmptyUtils.isEmpty(details)){ + //批量插入数据 + cereShopCouponDetailService.insertBatch(details); + } + cereSkuNameService.insertBatch(skuNames); } } @@ -510,6 +562,11 @@ public class CereShopProductServiceImpl implements CereShopProductService { } @Override + public List selectAllByShopId(Long shopId) { + return cereShopProductDAO.selectAllByShopId(shopId); + } + + @Override public List getProductMembers(Long productId) throws CoBusinessException { //查询所有规格数据 List members=cereShopProductDAO.getProductMembers(productId); @@ -685,11 +742,11 @@ public class CereShopProductServiceImpl implements CereShopProductService { return result; } - private void saveExcelSkus(List skus, Long productId, List skuNames, String time) throws CoBusinessException{ + private void saveExcelSkus(List skus, Long productId, Integer style, List skuNames, String time) throws CoBusinessException{ if(!EmptyUtils.isEmpty(skus)) { for (SkuParam sku : skus) { CereProductSku cereProductSku = new CereProductSku(); - cereProductSku.setStyle(IntegerEnum.SKU_STYLE_ONE.getCode()); + cereProductSku.setStyle(style); cereProductSku.setOriginalPrice(sku.getOriginalPrice()); cereProductSku.setPrice(sku.getPrice()); cereProductSku.setSkuImage(sku.getSkuImage()); diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/storehouse/CereShopStorehouseService.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/storehouse/CereShopStorehouseService.java index e1a3f52..207b288 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/storehouse/CereShopStorehouseService.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/service/storehouse/CereShopStorehouseService.java @@ -32,6 +32,8 @@ public interface CereShopStorehouseService { */ Page getAll(ShopStorehouseGetAllParam param); + List selectAllByParam(ShopStorehouseGetAllParam param); + /** * 更新仓库 * @param shopStorehouseUpdateParam diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/storehouse/impl/CereShopStorehouseServiceImpl.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/storehouse/impl/CereShopStorehouseServiceImpl.java index 4ad59b6..d363544 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/storehouse/impl/CereShopStorehouseServiceImpl.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/service/storehouse/impl/CereShopStorehouseServiceImpl.java @@ -65,6 +65,20 @@ public class CereShopStorehouseServiceImpl implements CereShopStorehouseService } @Override + public List selectAllByParam(ShopStorehouseGetAllParam param) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(CereShopStorehouse::getShopId, param.getShopId()); + wrapper.like(StringUtils.isNotBlank(param.getStorehouseName()), CereShopStorehouse::getStorehouseName, param.getStorehouseName()); + List list= cereShopStorehouseDAO.selectList(wrapper); + List storehouseList= list.stream().map(item -> { + Storehouse storehouse = new Storehouse(); + BeanUtils.copyProperties(item, storehouse); + return storehouse; + }).collect(Collectors.toList()); + return storehouseList; + } + + @Override @Transactional(isolation= Isolation.DEFAULT,propagation= Propagation.REQUIRED,rollbackFor = {CoBusinessException.class, Exception.class}) public int update(ShopStorehouseUpdateParam shopStorehouseUpdateParam, CerePlatformBusiness user) throws CoBusinessException { CereShopStorehouse cereShopStorehouse = new CereShopStorehouse(); @@ -99,7 +113,6 @@ public class CereShopStorehouseServiceImpl implements CereShopStorehouseService @Override public List selectAll() { - return cereShopStorehouseDAO.selectAll(); } diff --git a/cereshop-business/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml b/cereshop-business/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml index 3d9c722..be2a633 100644 --- a/cereshop-business/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml +++ b/cereshop-business/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml @@ -345,6 +345,11 @@ FROM cere_shop_product + + - SELECT shop_group_id,group_name FROM cere_shop_group where shop_id=#{shopId} + SELECT shop_group_id, shop_id, group_name FROM cere_shop_group where shop_id=#{shopId}