diff --git a/cereshop-app/src/main/resources/mybatis/mapper/storehouse/CereShopStorehouseDAO.xml b/cereshop-app/src/main/resources/mybatis/mapper/storehouse/CereShopStorehouseDAO.xml index a272616..479a608 100644 --- a/cereshop-app/src/main/resources/mybatis/mapper/storehouse/CereShopStorehouseDAO.xml +++ b/cereshop-app/src/main/resources/mybatis/mapper/storehouse/CereShopStorehouseDAO.xml @@ -20,4 +20,8 @@ storehouse_id, shop_id, storehouse_name, type, kind, if_cashier, one_product_order_price_limit, more_product_order_price_limit,one_product_num_limit,more_product_num_limit, order_number_limit,create_time,update_time + + diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/dao/shop/CereShopGroupDAO.java b/cereshop-business/src/main/java/com/shop/cereshop/business/dao/shop/CereShopGroupDAO.java index 605ec8c..d05758d 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/dao/shop/CereShopGroupDAO.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/dao/shop/CereShopGroupDAO.java @@ -5,6 +5,7 @@ */ package com.shop.cereshop.business.dao.shop; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.shop.cereshop.business.page.group.Group; import com.shop.cereshop.business.page.group.GroupDetail; import com.shop.cereshop.business.page.group.GroupProduct; @@ -13,7 +14,6 @@ import com.shop.cereshop.business.param.group.GroupCondition; import com.shop.cereshop.business.param.group.GroupGetAllParam; import com.shop.cereshop.business.param.group.GroupProductParam; import com.shop.cereshop.commons.domain.shop.CereShopGroup; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -50,4 +50,6 @@ public interface CereShopGroupDAO extends BaseMapper { List findProducts(@Param("shopGroupId") Long shopGroupId); List findProductByIds(@Param("ids") List ids); + + List selectAll(); } diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/dao/storehouse/CereShopStorehouseDAO.java b/cereshop-business/src/main/java/com/shop/cereshop/business/dao/storehouse/CereShopStorehouseDAO.java index 4fd23cf..4bfe18a 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/dao/storehouse/CereShopStorehouseDAO.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/dao/storehouse/CereShopStorehouseDAO.java @@ -6,11 +6,16 @@ package com.shop.cereshop.business.dao.storehouse; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.shop.cereshop.commons.domain.shop.CereShopGroup; import com.shop.cereshop.commons.domain.storehouse.CereShopStorehouse; import com.shop.cereshop.commons.domain.user.CerePrivacyVerifySetting; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + @Mapper public interface CereShopStorehouseDAO extends BaseMapper { + List selectAll(); + } diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductImport.java b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductImport.java index bc72be6..28befc5 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductImport.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductImport.java @@ -46,7 +46,7 @@ public class ProductImport { * 商品分组名称 */ @IsNeeded - private Long shopGroupName; + private String shopGroupName; /** * 商品名称 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 80ba54a..bf7a70b 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 @@ -5,19 +5,25 @@ */ package com.shop.cereshop.business.service.checkImport.impl; +import com.google.gson.Gson; import com.shop.cereshop.business.param.product.*; import com.shop.cereshop.business.service.checkImport.ImportCheckService; import com.shop.cereshop.business.service.product.CereProductClassifyService; import com.shop.cereshop.business.service.product.CereProductSkuService; import com.shop.cereshop.business.service.product.CereShopProductService; import com.shop.cereshop.business.service.shop.CerePlatformShopService; +import com.shop.cereshop.business.service.shop.CereShopGroupService; +import com.shop.cereshop.business.service.storehouse.CereShopStorehouseService; 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; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -27,6 +33,7 @@ import java.util.List; import java.util.Map; @Service +@Slf4j public class importCheckServiceImpl implements ImportCheckService { @Autowired @@ -41,6 +48,12 @@ public class importCheckServiceImpl implements ImportCheckService { @Autowired private CereProductClassifyService cereProductClassifyService; + @Autowired + private CereShopGroupService cereShopGroupService; + + @Autowired + private CereShopStorehouseService cereShopStorehouseService; + @Override public List checkProduct(List list) throws CoBusinessException { String message=""; @@ -61,20 +74,37 @@ public class importCheckServiceImpl implements ImportCheckService { } //定义分类map Map classifyMap=new HashMap<>(); + //定义分组map + Map groupMap=new HashMap<>(); //定义商品map Map productMap=new HashMap<>(); //定义商家map Map shopMap=new HashMap<>(); + //定义仓库map + Map storehouseMap=new HashMap<>(); //查询所有分类数据 List classifies=cereProductClassifyService.selectAll(); if(!EmptyUtils.isEmpty(classifies)){ classifies.forEach((item)->classifyMap.put(item.getClassifyHierarchy(),item)); } + + //分组数据 + List groups=cereShopGroupService.selectAll(); + if(!EmptyUtils.isEmpty(groups)){ + groups.forEach((item)->groupMap.put(item.getShopId()+"-"+item.getGroupName(), item)); + } //查询所有商品数据 List productList=cereShopProductService.selectAll(); if(!EmptyUtils.isEmpty(productList)){ productList.forEach((item)->productMap.put(item.getShopId()+"-"+item.getClassifyId()+"-"+item.getProductName(),item)); } + + //查询所有仓库 + List storehouseList= cereShopStorehouseService.selectAll(); + if(!EmptyUtils.isEmpty(storehouseList)){ + storehouseList.forEach((item)->storehouseMap.put(item.getShopId()+"-"+item.getStorehouseName(),item)); + } + //查询所有商家 List shops=cerePlatformShopService.selectAll(); if(!EmptyUtils.isEmpty(shops)){ @@ -93,7 +123,9 @@ public class importCheckServiceImpl implements ImportCheckService { //根据商家名称查询商家是否存在 if(EmptyUtils.isEmpty(shopMap.get(productImport.getShopName()))){ message+="第"+(i+3)+"行商家未注册;"; + continue; } + String classifyName=""; if(!EmptyUtils.isEmpty(productImport.getOneClassifyName())){ classifyName+="-"+productImport.getOneClassifyName(); @@ -104,13 +136,27 @@ public class importCheckServiceImpl implements ImportCheckService { if(!EmptyUtils.isEmpty(productImport.getThreeClassifyName())){ classifyName+="-"+productImport.getThreeClassifyName(); } - //查询分类是否存在 - if(EmptyUtils.isEmpty(classifyMap.get(classifyName))){ - message+="第"+(i+3)+"行分类不存在;"; - } CerePlatformShop shop = shopMap.get(productImport.getShopName()); + log.info("商品分类:"+classifyName); CereProductClassify classify = classifyMap.get(classifyName); + if(EmptyUtils.isEmpty(classify)){ + message+="第"+(i+3)+"行分类出错;"; + continue; + } + + String key=shop.getShopId()+"-"+classify.getClassifyId()+"-"+productImport.getProductName(); + CereShopGroup cereShopGroup = groupMap.get(shop.getShopId()+"-"+productImport.getShopGroupName()); + + if(EmptyUtils.isEmpty(cereShopGroup)){ + message+="第"+(i+3)+"行分类数据出错;"; + continue; + } + if(EmptyUtils.isEmpty(storehouseMap.get(shop.getShopId()+"-"+productImport.getStorehouseName()))){ + message+="第"+(i+3)+"行仓库出错;"; + continue; + } + //校验商品是否已存在 if(!EmptyUtils.isEmpty(productMap.get(key))){ message+="第"+(i+3)+"行商品已存在;"; @@ -120,6 +166,9 @@ public class importCheckServiceImpl implements ImportCheckService { param.setClassifyId(classify.getClassifyId()); param.setProductName(productImport.getProductName()); param.setSupplierName(productImport.getSupplierName()); + + param.setShopGroupId(cereShopGroup.getShopGroupId()); + if(!EmptyUtils.isEmpty(productImport.getIfLogistics())){ if(productImport.getIfLogistics().equals(StringEnum.YES.getCode())){ param.setIfLogistics(String.valueOf(IntegerEnum.YES.getCode())); @@ -156,9 +205,21 @@ public class importCheckServiceImpl implements ImportCheckService { 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); + }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); param.setSkus(skus); products.add(param); 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 56154fe..e6bb126 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 @@ -8,6 +8,7 @@ package com.shop.cereshop.business.service.product.impl; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.google.gson.Gson; import com.shop.cereshop.business.dao.brand.BrandDAO; import com.shop.cereshop.business.dao.product.CereProductClassifyDAO; import com.shop.cereshop.business.dao.product.CereShopProductDAO; @@ -442,6 +443,7 @@ public class CereShopProductServiceImpl implements CereShopProductService { //已下架 cereShopProduct.setShelveState(Integer.parseInt(param.getShelveState())); } + cereShopProduct.setShopGroupId(param.getShopGroupId()); cereShopProduct.setCreateTime(time); cereShopProduct.setShopId(param.getShopId()); cereShopProductDAO.insert(cereShopProduct); @@ -696,6 +698,11 @@ public class CereShopProductServiceImpl implements CereShopProductService { cereProductSku.setWeight(sku.getWeight()); cereProductSku.setProductId(productId); cereProductSku.setCreateTime(time); + cereProductSku.setRate(sku.getRate()); + cereProductSku.setIsCross(sku.getIsCross()); + cereProductSku.setStorehouseId(sku.getStorehouseId()); + + log.info(new Gson().toJson(cereProductSku)); //新增规格 cereProductSkuService.insert(cereProductSku); //将商品库存数量放到redis中 diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/CereShopGroupService.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/CereShopGroupService.java index eb9347b..16598df 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/CereShopGroupService.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/CereShopGroupService.java @@ -11,6 +11,7 @@ import com.shop.cereshop.business.param.group.*; import com.shop.cereshop.business.param.product.ProductGetGroupParam; import com.shop.cereshop.commons.domain.business.CerePlatformBusiness; import com.shop.cereshop.commons.domain.common.Page; +import com.shop.cereshop.commons.domain.product.CereProductClassify; import com.shop.cereshop.commons.domain.shop.CereShopGroup; import com.shop.cereshop.commons.exception.CoBusinessException; @@ -32,4 +33,6 @@ public interface CereShopGroupService { Page getProducts(GroupProductParam param) throws CoBusinessException; List getProductIds(ShopGroupSaveParam group) throws CoBusinessException; + + List selectAll(); } diff --git a/cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/impl/CereShopGroupServiceImpl.java b/cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/impl/CereShopGroupServiceImpl.java index 19c0f4d..757169b 100644 --- a/cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/impl/CereShopGroupServiceImpl.java +++ b/cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/impl/CereShopGroupServiceImpl.java @@ -225,4 +225,9 @@ public class CereShopGroupServiceImpl implements CereShopGroupService { return page; } + + @Override + public List selectAll() { + return cereShopGroupDAO.selectAll(); + } } 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 6729928..e1a3f52 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 @@ -11,8 +11,12 @@ import com.shop.cereshop.business.param.storehouse.ShopStorehouseSaveParam; import com.shop.cereshop.business.param.storehouse.ShopStorehouseUpdateParam; import com.shop.cereshop.commons.domain.business.CerePlatformBusiness; import com.shop.cereshop.commons.domain.common.Page; +import com.shop.cereshop.commons.domain.shop.CereShopGroup; +import com.shop.cereshop.commons.domain.storehouse.CereShopStorehouse; import com.shop.cereshop.commons.exception.CoBusinessException; +import java.util.List; + public interface CereShopStorehouseService { /** @@ -54,4 +58,6 @@ public interface CereShopStorehouseService { * @throws CoBusinessException */ int deleteById(Long storehouseId, CerePlatformBusiness user) throws CoBusinessException; + + List selectAll(); } 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 acf01ce..4ad59b6 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 @@ -96,4 +96,11 @@ public class CereShopStorehouseServiceImpl implements CereShopStorehouseService cerePlatformLogService.addLog(user,"仓库管理","商户端操作","删除仓库",cereShopStorehouse.getStorehouseId()); return result; } + + @Override + public List selectAll() { + + return cereShopStorehouseDAO.selectAll(); + } + } diff --git a/cereshop-business/src/main/resources/mybatis/mapper/shop/CereShopGroupDAO.xml b/cereshop-business/src/main/resources/mybatis/mapper/shop/CereShopGroupDAO.xml index 1e6ecc0..2b658b1 100644 --- a/cereshop-business/src/main/resources/mybatis/mapper/shop/CereShopGroupDAO.xml +++ b/cereshop-business/src/main/resources/mybatis/mapper/shop/CereShopGroupDAO.xml @@ -105,6 +105,10 @@ SELECT shop_group_id,group_name FROM cere_shop_group where shop_id=#{shopId} + + UPDATE cere_shop_product set shop_group_id=NULL where shop_group_id=#{shopGroupId} diff --git a/cereshop-business/src/main/resources/mybatis/mapper/storehouse/CereShopStorehouseDAO.xml b/cereshop-business/src/main/resources/mybatis/mapper/storehouse/CereShopStorehouseDAO.xml index a272616..479a608 100644 --- a/cereshop-business/src/main/resources/mybatis/mapper/storehouse/CereShopStorehouseDAO.xml +++ b/cereshop-business/src/main/resources/mybatis/mapper/storehouse/CereShopStorehouseDAO.xml @@ -20,4 +20,8 @@ storehouse_id, shop_id, storehouse_name, type, kind, if_cashier, one_product_order_price_limit, more_product_order_price_limit,one_product_num_limit,more_product_num_limit, order_number_limit,create_time,update_time + +