|
|
@@ -3,6 +3,7 @@ package com.cyksj.web.controller.manage.goods;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.annotation.Log;
|
|
|
+import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
import com.cyksj.common.util.Jsons;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.BusinessType;
|
|
|
@@ -216,7 +217,12 @@ public class CmsGoodsDonSkuController {
|
|
|
goodsDonSku.setSpecIds(specIds);
|
|
|
goodsDonSku.setSpecVal(specVal);
|
|
|
goodsDonSku.setSpecJson(specJson);
|
|
|
-
|
|
|
+ if (goods.getType() == 1) {
|
|
|
+ if (sku.getMonths() != null && sku.getDays() != null)
|
|
|
+ throw BusinessRuntimeException.getInstance("续费天数和续费月数不能同时存在");
|
|
|
+ if (sku.getMonths() == null && sku.getDays() == null)
|
|
|
+ throw BusinessRuntimeException.getInstance("请输入对应续费时间");
|
|
|
+ }
|
|
|
goodsDonSkuService.save(goodsDonSku);
|
|
|
|
|
|
}
|
|
|
@@ -234,6 +240,20 @@ public class CmsGoodsDonSkuController {
|
|
|
@PutMapping(value = "/update")
|
|
|
@Log(module = "平台管理/编辑规格", businessType = BusinessType.PUT, isSaveRequestData = true)
|
|
|
public Result<String> skuUpdate(@RequestBody GoodsDonSku sku){
|
|
|
+ Long goodsId = sku.getGoodsId();
|
|
|
+ GoodsDon goods = goodsDonService.getById(goodsId);
|
|
|
+ if (goods.getType() == 1) {
|
|
|
+ if (sku.getMonths() != null && sku.getDays() != null)
|
|
|
+ throw BusinessRuntimeException.getInstance("续费天数和续费月数不能同时存在");
|
|
|
+ if (sku.getMonths() == null && sku.getDays() == null)
|
|
|
+ throw BusinessRuntimeException.getInstance("请输入对应续费时间");
|
|
|
+ }
|
|
|
+ if (sku.getMonths() == null) {
|
|
|
+ sku.setMonths(null);
|
|
|
+ }
|
|
|
+ if (sku.getDays() == null) {
|
|
|
+ sku.setDays(null);
|
|
|
+ }
|
|
|
goodsDonSkuService.saveOrUpdate(sku);
|
|
|
//给平台更新额外属性
|
|
|
goodsDonService.updateGoodsSkuPrice(sku.getGoodsId(), null);
|
|
|
@@ -250,9 +270,9 @@ public class CmsGoodsDonSkuController {
|
|
|
@DeleteMapping("/delete/{skuId}")
|
|
|
@Log(module = "平台管理/删除规格", businessType = BusinessType.DELETE)
|
|
|
public Result<String> skuDelete(@PathVariable Long skuId) {
|
|
|
- goodsDonSkuService.removeById(skuId);
|
|
|
//给平台更新额外属性
|
|
|
GoodsDonSku sku = goodsDonSkuService.getById(skuId);
|
|
|
+ goodsDonSkuService.removeById(skuId);
|
|
|
goodsDonService.updateGoodsSkuPrice(sku.getGoodsId(), null);
|
|
|
Set<String> keys = redisService.keys(RedisService.key.YH_HOME_PAGHE_CACHE.getName() + "*");
|
|
|
redisService.del(keys.toArray(String[]::new));
|