【缺陷修复】商城: spu 更新会重置实际销量和浏览量的问题
This commit is contained in:
parent
33dc329485
commit
7fb3f9857b
|
@ -78,7 +78,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateSpu(ProductSpuSaveReqVO updateReqVO) {
|
public void updateSpu(ProductSpuSaveReqVO updateReqVO) {
|
||||||
// 校验 SPU 是否存在
|
// 校验 SPU 是否存在
|
||||||
validateSpuExists(updateReqVO.getId());
|
ProductSpuDO spu = validateSpuExists(updateReqVO.getId());
|
||||||
// 校验分类、品牌
|
// 校验分类、品牌
|
||||||
validateCategory(updateReqVO.getCategoryId());
|
validateCategory(updateReqVO.getCategoryId());
|
||||||
brandService.validateProductBrand(updateReqVO.getBrandId());
|
brandService.validateProductBrand(updateReqVO.getBrandId());
|
||||||
|
@ -87,7 +87,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||||
productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType());
|
productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType());
|
||||||
|
|
||||||
// 更新 SPU
|
// 更新 SPU
|
||||||
ProductSpuDO updateObj = BeanUtils.toBean(updateReqVO, ProductSpuDO.class);
|
ProductSpuDO updateObj = BeanUtils.toBean(updateReqVO, ProductSpuDO.class).setStatus(spu.getStatus());
|
||||||
initSpuFromSkus(updateObj, skuSaveReqList);
|
initSpuFromSkus(updateObj, skuSaveReqList);
|
||||||
productSpuMapper.updateById(updateObj);
|
productSpuMapper.updateById(updateObj);
|
||||||
// 批量更新 SKU
|
// 批量更新 SKU
|
||||||
|
@ -176,10 +176,12 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||||
productSkuService.deleteSkuBySpuId(id);
|
productSkuService.deleteSkuBySpuId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateSpuExists(Long id) {
|
private ProductSpuDO validateSpuExists(Long id) {
|
||||||
if (productSpuMapper.selectById(id) == null) {
|
ProductSpuDO spuDO = productSpuMapper.selectById(id);
|
||||||
|
if (spuDO == null) {
|
||||||
throw exception(SPU_NOT_EXISTS);
|
throw exception(SPU_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
return spuDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue