|
|
@@ -1,8 +1,11 @@
|
|
|
package com.cyksj.web.controller.manage.goods;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
|
|
+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;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
@@ -25,6 +28,7 @@ import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
import java.util.Set;
|
|
|
|
|
|
@@ -104,7 +108,7 @@ public class CmsGoodsDonSkuController {
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
@PutMapping(value = "/update")
|
|
|
@Log(module = "平台管理/编辑规格", businessType = BusinessType.PUT, isSaveRequestData = true)
|
|
|
- public Result<String> skuUpdate(@RequestBody GoodsDonSku sku){
|
|
|
+ public Result<String> skuUpdate(@RequestBody GoodsDonSku sku) throws Exception {
|
|
|
Long goodsId = sku.getGoodsId();
|
|
|
GoodsDon goods = goodsDonService.getById(goodsId);
|
|
|
if (goods.getType() == 1) {
|
|
|
@@ -119,6 +123,23 @@ public class CmsGoodsDonSkuController {
|
|
|
if (sku.getDays() == null) {
|
|
|
sku.setDays(null);
|
|
|
}
|
|
|
+ String specificGoodsIds = sku.getSpecificGoodsIds();
|
|
|
+ if (StrUtil.isEmpty(specificGoodsIds)) {
|
|
|
+ sku.setSpecificPrice(BigDecimal.ZERO);
|
|
|
+ } else {
|
|
|
+ Set<Long> specificGids = Jsons.parseSet(specificGoodsIds, Long.class);
|
|
|
+ Integer count = goodsDonService.count(Wrappers.lambdaQuery(GoodsDon.class)
|
|
|
+ .in(GoodsDon::getId, specificGids)
|
|
|
+ .eq(GoodsDon::getStatus, true)
|
|
|
+ .eq(GoodsDon::getDeleted, true));
|
|
|
+ if (count != specificGids.size()) {
|
|
|
+ throw BusinessRuntimeException.getInstance("存在被删除或已下架的平台");
|
|
|
+ }
|
|
|
+ BigDecimal specificPrice = sku.getSpecificPrice();
|
|
|
+ if (specificPrice == null || specificPrice.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("请输入正确的特定价格");
|
|
|
+ }
|
|
|
+ }
|
|
|
//优惠加购
|
|
|
goodsDonSkuService.handleDiscountPurchaseGoods(sku, sku.getDpSku());
|
|
|
goodsDonSkuService.saveOrUpdate(sku);
|