Browse Source

修改商品导入功能

master
xh-pan1 2 years ago
parent
commit
733d351c6c
  1. 4
      cereshop-app/src/main/resources/mybatis/mapper/storehouse/CereShopStorehouseDAO.xml
  2. 4
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/shop/CereShopGroupDAO.java
  3. 5
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/storehouse/CereShopStorehouseDAO.java
  4. 2
      cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductImport.java
  5. 69
      cereshop-business/src/main/java/com/shop/cereshop/business/service/checkImport/impl/importCheckServiceImpl.java
  6. 7
      cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java
  7. 3
      cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/CereShopGroupService.java
  8. 5
      cereshop-business/src/main/java/com/shop/cereshop/business/service/shop/impl/CereShopGroupServiceImpl.java
  9. 6
      cereshop-business/src/main/java/com/shop/cereshop/business/service/storehouse/CereShopStorehouseService.java
  10. 7
      cereshop-business/src/main/java/com/shop/cereshop/business/service/storehouse/impl/CereShopStorehouseServiceImpl.java
  11. 4
      cereshop-business/src/main/resources/mybatis/mapper/shop/CereShopGroupDAO.xml
  12. 4
      cereshop-business/src/main/resources/mybatis/mapper/storehouse/CereShopStorehouseDAO.xml

4
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
</sql>
<select id="selectAll" resultType="com.shop.cereshop.commons.domain.storehouse.CereShopStorehouse">
SELECT storehouse_id,shop_id, storehouse_name FROM cere_shop_storehouse
</select>
</mapper>

4
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<CereShopGroup> {
List<GroupProduct> findProducts(@Param("shopGroupId") Long shopGroupId);
List<Product> findProductByIds(@Param("ids") List<Long> ids);
List<CereShopGroup> selectAll();
}

5
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<CereShopStorehouse> {
List<CereShopStorehouse> selectAll();
}

2
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;
/**
* 商品名称

69
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<ProductSaveParam> checkProduct(List<ProductImport> list) throws CoBusinessException {
String message="";
@ -61,20 +74,37 @@ public class importCheckServiceImpl implements ImportCheckService {
}
//定义分类map
Map<String,CereProductClassify> classifyMap=new HashMap<>();
//定义分组map
Map<String,CereShopGroup> groupMap=new HashMap<>();
//定义商品map
Map<String,CereShopProduct> productMap=new HashMap<>();
//定义商家map
Map<String,CerePlatformShop> shopMap=new HashMap<>();
//定义仓库map
Map<String,CereShopStorehouse> storehouseMap=new HashMap<>();
//查询所有分类数据
List<CereProductClassify> classifies=cereProductClassifyService.selectAll();
if(!EmptyUtils.isEmpty(classifies)){
classifies.forEach((item)->classifyMap.put(item.getClassifyHierarchy(),item));
}
//分组数据
List<CereShopGroup> groups=cereShopGroupService.selectAll();
if(!EmptyUtils.isEmpty(groups)){
groups.forEach((item)->groupMap.put(item.getShopId()+"-"+item.getGroupName(), item));
}
//查询所有商品数据
List<CereShopProduct> productList=cereShopProductService.selectAll();
if(!EmptyUtils.isEmpty(productList)){
productList.forEach((item)->productMap.put(item.getShopId()+"-"+item.getClassifyId()+"-"+item.getProductName(),item));
}
//查询所有仓库
List<CereShopStorehouse> storehouseList= cereShopStorehouseService.selectAll();
if(!EmptyUtils.isEmpty(storehouseList)){
storehouseList.forEach((item)->storehouseMap.put(item.getShopId()+"-"+item.getStorehouseName(),item));
}
//查询所有商家
List<CerePlatformShop> 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);

7
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中

3
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<Product> getProductIds(ShopGroupSaveParam group) throws CoBusinessException;
List<CereShopGroup> selectAll();
}

5
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<CereShopGroup> selectAll() {
return cereShopGroupDAO.selectAll();
}
}

6
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<CereShopStorehouse> selectAll();
}

7
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<CereShopStorehouse> selectAll() {
return cereShopStorehouseDAO.selectAll();
}
}

4
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}
</select>
<select id="selectAll" resultType="com.shop.cereshop.commons.domain.shop.CereShopGroup">
SELECT shop_group_id,group_name, shop_id FROM cere_shop_group
</select>
<update id="updateGroup" parameterType="java.lang.Object">
UPDATE cere_shop_product set shop_group_id=NULL where shop_group_id=#{shopGroupId}
</update>

4
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
</sql>
<select id="selectAll" resultType="com.shop.cereshop.commons.domain.storehouse.CereShopStorehouse">
SELECT storehouse_id,shop_id, storehouse_name FROM cere_shop_storehouse
</select>
</mapper>
Loading…
Cancel
Save