提交 40b7b899 作者: xiaowang

修复:商品编辑

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