Browse Source

修改商品导入功能

master
xh-pan1 2 years ago
parent
commit
4550303f11
  1. 2
      cereshop-business/src/main/java/com/shop/cereshop/business/controller/ProductController.java
  2. 2
      cereshop-business/src/main/java/com/shop/cereshop/business/dao/product/CereShopProductDAO.java
  3. 5
      cereshop-business/src/main/java/com/shop/cereshop/business/param/product/ProductSaveParam.java
  4. 2
      cereshop-business/src/main/java/com/shop/cereshop/business/service/checkImport/ImportCheckService.java
  5. 156
      cereshop-business/src/main/java/com/shop/cereshop/business/service/checkImport/impl/importCheckServiceImpl.java
  6. 4
      cereshop-business/src/main/java/com/shop/cereshop/business/service/product/CereShopProductService.java
  7. 129
      cereshop-business/src/main/java/com/shop/cereshop/business/service/product/impl/CereShopProductServiceImpl.java
  8. 2
      cereshop-business/src/main/java/com/shop/cereshop/business/service/storehouse/CereShopStorehouseService.java
  9. 15
      cereshop-business/src/main/java/com/shop/cereshop/business/service/storehouse/impl/CereShopStorehouseServiceImpl.java
  10. 5
      cereshop-business/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml
  11. 2
      cereshop-business/src/main/resources/mybatis/mapper/shop/CereShopGroupDAO.xml

2
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();
}

2
cereshop-business/src/main/java/com/shop/cereshop/business/dao/product/CereShopProductDAO.java

@ -54,6 +54,8 @@ public interface CereShopProductDAO extends BaseMapper<CereShopProduct> {
List<CereShopProduct> selectAll();
List<CereShopProduct> selectAllByShopId(@Param("shopId") Long shopId);
List<ProductMember> getProductMembers(@Param("productId") Long productId);
int deleteShopCartByProductId(@Param("productId")Long productId);

5
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
*/

2
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<ProductSaveParam> checkProduct(List<ProductImport> list) throws CoBusinessException;
List<ProductSaveParam> checkProduct(Long shopId, List<ProductImport> list) throws CoBusinessException;
}

156
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<ProductSaveParam> checkProduct(List<ProductImport> list) throws CoBusinessException {
public List<ProductSaveParam> checkProduct(Long shopId, List<ProductImport> list) throws CoBusinessException {
String message="";
List<ProductSaveParam> products=new ArrayList<>();
Map<String,ProductSaveParam> productMaps=new HashMap<>();
if(!EmptyUtils.isEmpty(list)){
Map<String,ProductImport> 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<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<String,CereShopProduct> dbProductMap=new HashMap<>();
//定义仓库map
Map<String,CereShopStorehouse> storehouseMap=new HashMap<>();
Map<String,Storehouse> storehouseMap=new HashMap<>();
//查询所有分类数据
List<CereProductClassify> classifies=cereProductClassifyService.selectAll();
if(!EmptyUtils.isEmpty(classifies)){
@ -89,42 +107,29 @@ public class importCheckServiceImpl implements ImportCheckService {
}
//分组数据
List<CereShopGroup> groups=cereShopGroupService.selectAll();
ProductGetGroupParam shopGroupParam = new ProductGetGroupParam();
shopGroupParam.setShopId(shopId);
List<CereShopGroup> groups = cereShopGroupService.getGroupSelect(shopGroupParam);
if(!EmptyUtils.isEmpty(groups)){
groups.forEach((item)->groupMap.put(item.getShopId()+"-"+item.getGroupName(), item));
}
//查询所有商品数据
List<CereShopProduct> productList=cereShopProductService.selectAll();
List<CereShopProduct> 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<CereShopStorehouse> storehouseList= cereShopStorehouseService.selectAll();
ShopStorehouseGetAllParam storehouseParams = new ShopStorehouseGetAllParam();
storehouseParams.setShopId(shopId);
List<Storehouse> storehouseList= cereShopStorehouseService.selectAllByParam(storehouseParams);
if(!EmptyUtils.isEmpty(storehouseList)){
storehouseList.forEach((item)->storehouseMap.put(item.getShopId()+"-"+item.getStorehouseName(),item));
}
//查询所有商家
List<CerePlatformShop> 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<SkuParam> skus=new ArrayList<>();
SkuParam cereProductSku=new SkuParam();
List<SkuNameValueParam> 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<SkuParam> skus= param.getSkus();
if(skus == null){
skus = new ArrayList<>();
param.setSkus(skus);
products.add(param);
}
SkuParam cereProductSku=new SkuParam();
List<SkuNameValueParam> 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());
}
}

4
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<CereShopProduct> selectAll();
List<CereShopProduct> selectAllByShopId(Long shopId);
List<ProductMember> getProductMembers(Long productId) throws CoBusinessException;
void setProductMember(ProductMemberParam param) throws CoBusinessException;

129
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<Sku> 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<ProductImport> list = ImportExeclUtil.readDateListT(wb, new ProductImport());
String time= TimeUtils.yyMMddHHmmss();
//校验有效数据
List<ProductSaveParam> products=importCheckService.checkProduct(list);
List<ProductSaveParam> products=importCheckService.checkProduct(shopId, list);
List<CereShopCoupon> coupons=cereShopCouponService.findAllByShopId(shopId);
List<CereShopCouponDetail> details = new ArrayList<>();
if(!EmptyUtils.isEmpty(products)){
List<CereSkuName> 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<CereShopCoupon> coupons=cereShopCouponService.findAllByShopId(cereShopProduct.getShopId());
if(!EmptyUtils.isEmpty(coupons)){
//如果有,将新增的商品插入到优惠券商品明细表中
List<CereShopCouponDetail> 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<CereShopProduct> selectAllByShopId(Long shopId) {
return cereShopProductDAO.selectAllByShopId(shopId);
}
@Override
public List<ProductMember> getProductMembers(Long productId) throws CoBusinessException {
//查询所有规格数据
List<ProductMember> members=cereShopProductDAO.getProductMembers(productId);
@ -685,11 +742,11 @@ public class CereShopProductServiceImpl implements CereShopProductService {
return result;
}
private void saveExcelSkus(List<SkuParam> skus, Long productId, List<CereSkuName> skuNames, String time) throws CoBusinessException{
private void saveExcelSkus(List<SkuParam> skus, Long productId, Integer style, List<CereSkuName> 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());

2
cereshop-business/src/main/java/com/shop/cereshop/business/service/storehouse/CereShopStorehouseService.java

@ -32,6 +32,8 @@ public interface CereShopStorehouseService {
*/
Page<Storehouse> getAll(ShopStorehouseGetAllParam param);
List<Storehouse> selectAllByParam(ShopStorehouseGetAllParam param);
/**
* 更新仓库
* @param shopStorehouseUpdateParam

15
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<Storehouse> selectAllByParam(ShopStorehouseGetAllParam param) {
LambdaQueryWrapper<CereShopStorehouse> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CereShopStorehouse::getShopId, param.getShopId());
wrapper.like(StringUtils.isNotBlank(param.getStorehouseName()), CereShopStorehouse::getStorehouseName, param.getStorehouseName());
List<CereShopStorehouse> list= cereShopStorehouseDAO.selectList(wrapper);
List<Storehouse> 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<CereShopStorehouse> selectAll() {
return cereShopStorehouseDAO.selectAll();
}

5
cereshop-business/src/main/resources/mybatis/mapper/product/CereShopProductDAO.xml

@ -345,6 +345,11 @@
FROM cere_shop_product
</select>
<select id="selectAllByShopId" resultType="com.shop.cereshop.commons.domain.product.CereShopProduct">
SELECT product_id, classify_id, shop_id, product_name
FROM cere_shop_product where shop_id = #{shopId}
</select>
<select id="getProductMembers" parameterType="java.lang.Object"
resultType="com.shop.cereshop.business.page.member.ProductMember">
SELECT a.product_id, a.sku_id, a.price, b.`value`,c.`mode`

2
cereshop-business/src/main/resources/mybatis/mapper/shop/CereShopGroupDAO.xml

@ -102,7 +102,7 @@
</update>
<select id="getGroupSelect" parameterType="java.lang.Object" resultType="com.shop.cereshop.commons.domain.shop.CereShopGroup">
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}
</select>
<select id="selectAll" resultType="com.shop.cereshop.commons.domain.shop.CereShopGroup">

Loading…
Cancel
Save