dev798
wxy 2024-05-14 17:09:21 +08:00
parent 963dacbfe2
commit 6823f81809
1 changed files with 36 additions and 9 deletions

View File

@ -89,10 +89,40 @@ public class MallProductInfoServiceImpl implements MallProductInfoService
packageDataSeveOrUpdate(mallProductInfo,num,userId); packageDataSeveOrUpdate(mallProductInfo,num,userId);
return num; return num;
} }
/**
* step
*/
public enum Step{
STEP_ONE,
STEP_TWO,
STEP_THREE
}
// 获取步骤
private Step getStep(MallProductInfo mallProductInfo){
String step = mallProductInfo.getStep();
if(step == null){
return null;
}
return Step.valueOf(step);
}
// 处理步骤一
private void handleStepOne(MallProductInfoForm mallProductInfo){
//获取商品信息ID
Long productInfoId = mallProductInfo.getId();
//清空商品的sku信息列表
mallProductInfo.setSkuInfoList(null);
// 根据商品信息ID,删除商品信息对应的sku信息
mallProductSkuInfoService.deleteMallProductSkuInfoId(productInfoId);
}
// 处理步骤二
private void handleStepTwo(MallProductInfoForm mallProductInfo){
// 清空商品的描述信息
mallProductInfo.setProductDesc("");
}
/** /**
* step
* *
*
* @param mallProductInfo * @param mallProductInfo
* @return * @return
*/ */
@ -103,19 +133,16 @@ public class MallProductInfoServiceImpl implements MallProductInfoService
String step = mallProductInfo.getStep(); String step = mallProductInfo.getStep();
if (step == null) { if (step == null) {
// 在这里处理 step 为 null 的情况,可以抛出异常或者采取其他措施 // 在这里处理 step 为 null 的情况,可以抛出异常或者采取其他措施
log.error("Step 参数为空"); throw new IllegalArgumentException("Step参数为空");
return 0; // 或者抛出异常
} }
switch (step) { switch (step) {
case ProductConstant.STEP_ONE: case ProductConstant.STEP_ONE:
Long productInfoId = mallProductInfo.getId(); // 处理步骤一
// 处理步骤一清除当前产品的SKU信息 handleStepOne(mallProductInfo);
mallProductInfo.setSkuInfoList(null);
mallProductSkuInfoService.deleteMallProductSkuInfoId(productInfoId);
break; break;
case ProductConstant.STEP_TWO: case ProductConstant.STEP_TWO:
// 处理步骤二:清空产品描述 // 处理步骤二
mallProductInfo.setProductDesc(""); handleStepTwo(mallProductInfo);
break; break;
default: default:
// 对于未知步骤,不做任何处理 // 对于未知步骤,不做任何处理