提交 40b7b899 作者: xiaowang

修复:商品编辑

上级 60fff22e
...@@ -55,12 +55,10 @@ public class MallIndustrySkuInfoDO implements Serializable { ...@@ -55,12 +55,10 @@ public class MallIndustrySkuInfoDO implements Serializable {
return GoodsSpecDTO.builder() return GoodsSpecDTO.builder()
.id(this.id) .id(this.id)
.goodsSpecName(this.industrySkuSpecName) .goodsSpecName(this.industrySkuSpecName)
.categoryId(this.categoriesId)
.chooseType(this.chooseType) .chooseType(this.chooseType)
.skuUnitId(skuUnitId) .skuUnitId(skuUnitId)
.unitName(this.unitName) .unitName(this.unitName)
.skuId(this.industrySkuId) .skuId(this.industrySkuId)
.typeName(this.typeName)
.skuName(this.industrySkuName) .skuName(this.industrySkuName)
.must(must) .must(must)
.build(); .build();
......
...@@ -53,12 +53,9 @@ public class MallProdInfoDO implements Serializable { ...@@ -53,12 +53,9 @@ public class MallProdInfoDO implements Serializable {
return GoodsSpecDTO.builder() return GoodsSpecDTO.builder()
.id(this.id) .id(this.id)
.goodsSpecName(this.prodSkuSpecName) .goodsSpecName(this.prodSkuSpecName)
.categoryId(this.categoriesId)
.chooseType(this.chooseType) .chooseType(this.chooseType)
.skuUnitId(skuUnitId) .skuUnitId(skuUnitId)
.unitName(this.unitName) .unitName(this.unitName)
.skuId(this.productId)
.typeName(this.typeName)
.must(must) .must(must)
.skuName(this.productSkuName) .skuName(this.productSkuName)
.brandInfoId(brandInfoId) .brandInfoId(brandInfoId)
......
...@@ -27,12 +27,6 @@ public class GoodsSpecDTO implements Serializable { ...@@ -27,12 +27,6 @@ public class GoodsSpecDTO implements Serializable {
@ApiModelProperty(value = "规格名称") @ApiModelProperty(value = "规格名称")
private String goodsSpecName; private String goodsSpecName;
@ApiModelProperty(value = "产品或行业类型")
private Integer categoryId;
@ApiModelProperty(value = "产品或行业类型名称")
private String typeName;
@ApiModelProperty(value = "产品或行业skuId") @ApiModelProperty(value = "产品或行业skuId")
private Integer skuId; private Integer skuId;
......
...@@ -28,9 +28,9 @@ public class GoodsProdSpecVO implements Serializable { ...@@ -28,9 +28,9 @@ public class GoodsProdSpecVO implements Serializable {
@ApiModelProperty(value = "产品类型id") @ApiModelProperty(value = "产品类型id")
private Integer categoryId; private Integer categoryId;
@ApiModelProperty(value = "产品:新增自定义时此字段可不用填写")
@ApiModelProperty(value = "产品:自定义时此字段可不用填写")
private Integer skuId; private Integer skuId;
@ApiModelProperty(value = "规格来源 0:获取 1:自定义") @ApiModelProperty(value = "规格来源 0:获取 1:自定义")
private Integer flag; private Integer flag;
......
...@@ -485,85 +485,74 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -485,85 +485,74 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateCustomize(GoodsInfo goodsInfo, List<GoodsProdSpecVO> zdySpecInfo, Integer id) { public void updateCustomize(GoodsInfo goodsInfo, List<GoodsProdSpecVO> zdySpecInfo, Integer id) {
// 获取自定义产品及规格信息(获取带id的)
// 先获取自定义的sku及规格(原来有的)
List<GoodsProdSpecVO> zdySpec = List<GoodsProdSpecVO> zdySpec =
zdySpecInfo.stream().filter(d -> d.getId() != null).collect(Collectors.toList()); zdySpecInfo.stream().filter(d -> d.getId() != null).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(zdySpec)) { if (CollectionUtils.isNotEmpty(zdySpec)) {
// 根据获取到的自定义sku及规格进行操作 for (GoodsProdSpecVO d : zdySpec) {
List<MallProdInfoDO> zdySpecList = // 修改产品的规格基本信息
zdySpec.stream() MallProdInfoDO mallProdInfoDO = new MallProdInfoDO(d).setId(d.getId()).setProductId(d.getSkuId());
.map(
d -> {
// 构建商品对应的sku信息
ProductDO productSkuDO =
new ProductDO().setId(d.getSkuId()).setProductName(d.getProductName());
productDao.updateProductSku(productSkuDO);
return new MallProdInfoDO(d).setId(d.getId()).setProductId(d.getSkuId());
})
.collect(Collectors.toList());
// 批量修改sku的信息
for (MallProdInfoDO mallProdInfoDO : zdySpecList) {
goodsInfoDao.updateMallProdSkuInfo(mallProdInfoDO); goodsInfoDao.updateMallProdSkuInfo(mallProdInfoDO);
} // 构建商品对应的产品信息
// goodsInfoDao.batchUpdateMallProdSkuInfo(zdySpecList); ProductDO productSkuDO =
} new ProductDO().setId(d.getSkuId()).setProductName(d.getProductName());
for (GoodsProdSpecVO goodsSpecVO : zdySpec) { productDao.updateProductSku(productSkuDO);
// 【1】获取输入的自定义规格信息// id不为空则修改 List<ProductSpecVO> customizeInfoList =
List<ProductSpecVO> customizeInfoList = d.getCustomizeInfo().stream()
goodsSpecVO.getCustomizeInfo().stream() .filter(e -> e.getId() != null)
.filter(d -> d.getId() != null) .collect(Collectors.toList());
.collect(Collectors.toList()); // 【2】删除多余的自定义规格
for (ProductSpecVO d : customizeInfoList) { if (!CollectionUtils.isEmpty(d.getDelProductSpecId())) {
// ①修改价格配置 // 批量查出spec的数据
ProductSpecCPQVO productSpecCPQVO = d.getProductSpecCPQVO(); List<MallProdSkuInfoSpecDO> prodSkuInfoSpecList =
// 删除所有的随后在新增 productDao.getProductSpecByIds(d.getDelProductSpecId());
productDao.removeProductSpecCPQ(productSpecCPQVO); for (MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO : prodSkuInfoSpecList) {
productSkuService.insertSpecPrice(productSpecCPQVO); productDao.removeProductSpec(mallProdSkuInfoSpecDO.getProductSpecId());
ProductSpecDO productSpecDO = new ProductSpecDO(d); }
productSpecDO.setId(productSpecCPQVO.getProductSpecId()); goodsInfoDao.batchUpdateMallProdSpec(d.getDelProductSpecId());
// ②在修改自定义的数据 }
productDao.updateProductSpec(productSpecDO); for (ProductSpecVO e : customizeInfoList) {
} // ①修改价格配置
// 【2】删除多余的自定义规格 ProductSpecCPQVO productSpecCPQVO = e.getProductSpecCPQVO();
if (!CollectionUtils.isEmpty(goodsSpecVO.getDelProductSpecId())) { // 删除所有的随后在新增
// 批量查出spec的数据 productDao.removeProductSpecCPQ(productSpecCPQVO);
List<MallProdSkuInfoSpecDO> prodSkuInfoSpecList = productSkuService.insertSpecPrice(productSpecCPQVO);
productDao.getProductSpecByIds(goodsSpecVO.getDelProductSpecId()); ProductSpecDO productSpecDO = new ProductSpecDO(e);
for (MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO : prodSkuInfoSpecList) { productSpecDO.setId(productSpecCPQVO.getProductSpecId());
productDao.removeProductSpec(mallProdSkuInfoSpecDO.getProductSpecId()); // ②在修改自定义的数据
productDao.updateProductSpec(productSpecDO);
}
// 【3】新增最新的自定义规格
List<ProductSpecVO> collect =
d.getCustomizeInfo().stream()
.filter(e -> e.getId() == null)
.collect(Collectors.toList());
for (ProductSpecVO param : collect) {
ProductSpecDO productSpecDO = new ProductSpecDO(param);
// 新增产品sku
productDao.insertProductSpec(productSpecDO);
// 批量配置价格信息
ProductSpecCPQVO productSpecCPQVO = param.getProductSpecCPQVO();
productSpecCPQVO.setProductSpecId(productSpecDO.getId());
productSkuService.insertSpecPrice(productSpecCPQVO);
// 构建商品对应的规格信息
MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO =
new MallProdSkuInfoSpecDO()
.setProductSpecId(productSpecDO.getId())
.setMallProdSkuInfoId(d.getId())
.setGoodsInfoId(id);
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallProdSkuInfoSpec(mallProdSkuInfoSpecDO);
} }
goodsInfoDao.batchUpdateMallProdSpec(goodsSpecVO.getDelProductSpecId());
} }
// 【3】新增最新的自定义规格 // 2.2 新增新的自定义规格信息
List<ProductSpecVO> collect = List<GoodsProdSpecVO> newZdySpec =
goodsSpecVO.getCustomizeInfo().stream() zdySpecInfo.stream().filter(d -> d.getId() == null).collect(Collectors.toList());
.filter(d -> d.getId() == null) if (CollectionUtils.isNotEmpty(newZdySpec)) {
.collect(Collectors.toList()); productSkuSpecOperation(goodsInfo, newZdySpec);
for (ProductSpecVO param : collect) {
ProductSpecDO productSpecDO = new ProductSpecDO(param);
// 新增产品sku
productDao.insertProductSpec(productSpecDO);
// 批量配置价格信息
ProductSpecCPQVO productSpecCPQVO = param.getProductSpecCPQVO();
productSpecCPQVO.setProductSpecId(productSpecDO.getId());
productSkuService.insertSpecPrice(productSpecCPQVO);
// 构建商品对应的规格信息
MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO =
new MallProdSkuInfoSpecDO()
.setProductSpecId(productSpecDO.getId())
.setMallProdSkuInfoId(goodsSpecVO.getId())
.setGoodsInfoId(id);
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallProdSkuInfoSpec(mallProdSkuInfoSpecDO);
} }
} }
// 2.2 新增新的自定义规格信息
List<GoodsProdSpecVO> newZdySpec =
zdySpecInfo.stream().filter(d -> d.getId() == null).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(newZdySpec)) {
productSkuSpecOperation(goodsInfo, newZdySpec);
}
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
......
...@@ -104,8 +104,6 @@ public class MiniProgramProductMallServiceImpl implements MiniProgramProductMall ...@@ -104,8 +104,6 @@ public class MiniProgramProductMallServiceImpl implements MiniProgramProductMall
.setGoodsSpecName(d.getProdSkuSpecName()) .setGoodsSpecName(d.getProdSkuSpecName())
.setSkuName(d.getProductSkuName()) .setSkuName(d.getProductSkuName())
.setBrandInfoId(d.getBrandInfoId()) .setBrandInfoId(d.getBrandInfoId())
.setCategoryId(d.getCategoriesId())
.setTypeName(d.getTypeName())
.setChooseType(d.getChooseType()) .setChooseType(d.getChooseType())
.setSkuUnitId(d.getSkuUnitId()) .setSkuUnitId(d.getSkuUnitId())
.setUnitName(d.getUnitName()) .setUnitName(d.getUnitName())
......
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
update goods_info update goods_info
set goods_name = #{goodsName}, set goods_name = #{goodsName},
eco_label = #{ecoLabel}, eco_label = #{ecoLabel},
directory_id = #{directoryId},
category_by_one = #{categoryByOne}, category_by_one = #{categoryByOne},
category_by_two = #{categoryByTwo}, category_by_two = #{categoryByTwo},
shelf_status = #{shelfStatus} shelf_status = #{shelfStatus}
...@@ -596,21 +597,18 @@ ...@@ -596,21 +597,18 @@
mi.goods_info_id, mi.goods_info_id,
mi.product_id productId, mi.product_id productId,
mi.prod_spec_name prodSkuSpecName, mi.prod_spec_name prodSkuSpecName,
mi.categories_id categoriesId,
mi.choose_type chooseType, mi.choose_type chooseType,
mi.sku_unit_id skuUnitId, mi.sku_unit_id skuUnitId,
mi.is_must must, mi.is_must must,
mi.flag flag, mi.flag flag,
mi.create_time createTime, mi.create_time createTime,
c.name typeName,
su.id skuUnitId, su.id skuUnitId,
su.unit_name unitName, su.unit_name unitName,
ps.product_name productSkuName ps.product_name productSkuName
FROM mall_prod_info mi FROM mall_prod_info mi
INNER JOIN categories c ON c.id = mi.categories_id
INNER JOIN sku_unit su ON mi.sku_unit_id = su.id INNER JOIN sku_unit su ON mi.sku_unit_id = su.id
INNER JOIN product ps ON ps.id = mi.product_id INNER JOIN product ps ON ps.id = mi.product_id
WHERE mi.goods_info_id = #{id} WHERE mi.goods_info_id = #{goodsInfoId}
AND mi.is_deleted = 0 AND mi.is_deleted = 0
ORDER BY mi.create_time asc ORDER BY mi.create_time asc
</select> </select>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论