yzc 2 лет назад
Родитель
Сommit
afa635b887

+ 2 - 2
sckw-modules/sckw-order/src/main/java/com/sckw/order/serivce/KwoTradeOrderService.java

@@ -282,7 +282,7 @@ public class KwoTradeOrderService {
         if (goods.getAmount().compareTo(amount) < 0) {
             throw new BusinessException("商品库存不足,请联系供应方!");
         }
-        BigDecimal advancePrice = goods.getAdvancePrice().multiply(new BigDecimal(10000));
+        BigDecimal advancePrice = goods.getAdvancePrice().multiply(new BigDecimal("10000"));
         //受理订单不校验预付款限额
         if (!isAcceptanceOrder && trading.startsWith("0") && price.compareTo(advancePrice) < 0) {
             throw new BusinessException("您的订单总额未达到预付限额,请确认");
@@ -297,7 +297,7 @@ public class KwoTradeOrderService {
                 throw new BusinessException("检测尚未创建对应预付款清单,请先创建!");
             }
             long money = data.get(0).getMoney();
-            if (money < advancePrice.multiply(new BigDecimal(100)).longValueExact()) {
+            if (money < advancePrice.multiply(new BigDecimal("10000")).longValueExact()) {
                 throw new BusinessException("您的预付清单可用余额不足,请先充值!");
             }
         }

+ 4 - 4
sckw-modules/sckw-product/src/main/java/com/sckw/product/controller/KwpGoodsController.java

@@ -31,12 +31,12 @@ public class KwpGoodsController {
      * @desc: 添加商品草稿
      * @author: yzc
      * @date: 2023-07-05 10:54
-     * @Param addGoodsParam:
+     * @Param param:
      * @return: com.sckw.core.web.response.HttpResult
      */
     @PostMapping(value = "/addDraft", produces = MediaType.APPLICATION_JSON_VALUE)
-    public HttpResult addDraft(@RequestBody AddGoodsParam addGoodsParam) {
-        kwpGoodsService.addDraft(addGoodsParam);
+    public HttpResult addDraft(@RequestBody @Validated AddGoodsDraftParam param) {
+        kwpGoodsService.addDraft(param);
         return HttpResult.ok("添加草稿商品成功");
     }
 
@@ -75,7 +75,7 @@ public class KwpGoodsController {
     @PostMapping(value = "/update", produces = MediaType.APPLICATION_JSON_VALUE)
     public HttpResult update(@RequestBody @Validated UpdateGoodsParam updateGoodsParam) {
         kwpGoodsService.update(updateGoodsParam);
-        return HttpResult.ok("修改成功");
+        return HttpResult.ok("修改商品成功");
     }
 
 

+ 112 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/req/AddGoodsDraftParam.java

@@ -0,0 +1,112 @@
+package com.sckw.product.model.vo.req;
+
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.DecimalMin;
+import jakarta.validation.constraints.Size;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.hibernate.validator.constraints.Length;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @desc: 添加草稿商品请求参数
+ * @author: yzc
+ * @date: 2023-07-03 8:35
+ */
+@Getter
+@Setter
+@ToString
+public class AddGoodsDraftParam {
+    /**
+     * 商品名称
+     */
+    @Length(max = 50, message = "商品名称最多支持50字")
+    private String name;
+
+    /**
+     * 商品类型
+     */
+    private String goodsType;
+
+    /**
+     * 单位(吨、方、件、箱、其他)
+     */
+    private String unit;
+
+    /**
+     * 规格尺寸
+     */
+    @Length(max = 20, message = "规格尺寸最多支持20字")
+    private String spec;
+
+    /**
+     * 库存数量
+     */
+    @DecimalMin(value = "0.00", message = "库存数量最小为零")
+    private BigDecimal amount;
+
+    /**
+     * 参数目录
+     */
+    @Size(max = 10, message = "参数目录最多支持10个")
+    @Valid
+    private List<GoodsAttributes> attributes;
+
+    /**
+     * 发票税率(%)
+     */
+    private String taxRate;
+
+    /**
+     * 交易方式(合同采购、直接采购、预付款、货到付款、到款发货)
+     */
+    private String trading;
+
+    /**
+     * 预付款最低限额(万元)
+     */
+    @DecimalMin(value = "0.00", message = "预付款最低限额最小为零")
+    private BigDecimal advancePrice;
+
+    /**
+     * 价格梯度
+     */
+    @Size(max = 4, message = "价格梯度最多4个")
+    private List<GoodsPriceRanges> priceRanges;
+
+    /**
+     * 供应企业
+     */
+    private Long supplyEntId;
+
+    /**
+     * 地址信息
+     */
+    private AddressInfo addressInfo;
+
+    /**
+     * 专属客户经理(用户ID)
+     */
+    private Long manager;
+
+    /**
+     * 备注
+     */
+    @Length(max = 200, message = "备注最多支持200字")
+    private String remark;
+
+    /**
+     * 商品缩略图
+     */
+    private String thumb;
+
+    /**
+     * 商品详情图片
+     */
+    @Size(max = 5, message = "商品详情图片最多支持5张")
+    private List<GoodsImages> images;
+
+}

+ 4 - 0
sckw-modules/sckw-product/src/main/java/com/sckw/product/model/vo/req/UpdateGoodsParam.java

@@ -1,5 +1,6 @@
 package com.sckw.product.model.vo.req;
 
+import jakarta.validation.Valid;
 import jakarta.validation.constraints.DecimalMin;
 import jakarta.validation.constraints.NotNull;
 import jakarta.validation.constraints.Size;
@@ -46,6 +47,7 @@ public class UpdateGoodsParam {
     /**
      * 规格尺寸
      */
+    @Length(max = 20, message = "规格尺寸最多支持20字")
     private String spec;
 
     /**
@@ -58,6 +60,7 @@ public class UpdateGoodsParam {
      * 参数目录
      */
     @Size(max = 10, message = "参数目录最多支持10个")
+    @Valid
     private List<GoodsAttributes> attributes;
 
     /**
@@ -73,6 +76,7 @@ public class UpdateGoodsParam {
     /**
      * 预付款最低限额(万元)
      */
+    @DecimalMin(value = "0.00", message = "预付款最低限额最小为零")
     private BigDecimal advancePrice;
 
     /**

+ 14 - 20
sckw-modules/sckw-product/src/main/java/com/sckw/product/service/KwpGoodsService.java

@@ -29,7 +29,6 @@ import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
-import org.jetbrains.annotations.NotNull;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -61,20 +60,21 @@ public class KwpGoodsService {
      * @desc: 添加草稿商品
      * @author: yzc
      * @date: 2023-07-03 9:30
-     * @Param addGoodsParam:
+     * @Param param:
      * @return: void
      */
     @Transactional(rollbackFor = Exception.class)
-    public void addDraft(AddGoodsParam addGoodsParam) {
+    public void addDraft(AddGoodsDraftParam param) {
         Long entId = LoginUserHolder.getEntId();
         //添加商品信息
-        KwpGoods goods = BeanUtils.copyProperties(addGoodsParam, KwpGoods.class);
-        if (Objects.nonNull(addGoodsParam.getAddressInfo())) {
-            Integer cityCode = addGoodsParam.getAddressInfo().getCityCode();
+        KwpGoods goods = BeanUtils.copyProperties(param, KwpGoods.class);
+        if (Objects.nonNull(param.getAddressInfo())) {
+            Integer cityCode = param.getAddressInfo().getCityCode();
             goods.setAreaCode(cityCode);
         }
         goods.setEntId(entId).setStatus(GoodsStatusEnum.SAVED.getCode());
         kwpGoodsMapper.insert(goods);
+        AddGoodsParam addGoodsParam = BeanUtils.copyProperties(param, AddGoodsParam.class);
         addGoodsOtherInfo(goods.getId(), addGoodsParam);
     }
 
@@ -289,9 +289,9 @@ public class KwpGoodsService {
      * @Param param:
      * @return: void
      */
-    private void judgeParameters(@NotNull UpdateGoodsParam param) {
-        if (StringUtils.isBlank(param.getName()) || param.getName().length() > 50) {
-            throw new BusinessException("商品名称不能为空且最长50字符!");
+    private void judgeParameters(UpdateGoodsParam param) {
+        if (StringUtils.isBlank(param.getName())) {
+            throw new BusinessException("商品名称不能为空且!");
         }
         if (StringUtils.isBlank(param.getGoodsType())) {
             throw new BusinessException("商品类型不能为空!");
@@ -299,11 +299,11 @@ public class KwpGoodsService {
         if (StringUtils.isBlank(param.getUnit())) {
             throw new BusinessException("计量单位不能为空!");
         }
-        if (StringUtils.isBlank(param.getSpec()) || param.getSpec().length() > 20) {
+        if (StringUtils.isBlank(param.getSpec())) {
             throw new BusinessException("规格尺寸不能为空!");
         }
-        if (Objects.isNull(param.getAmount()) || param.getAmount().compareTo(BigDecimal.ZERO) < 0) {
-            throw new BusinessException("库存数量不能为空且最小为零!");
+        if (Objects.isNull(param.getAmount())) {
+            throw new BusinessException("库存数量不能为空!");
         }
         if (StringUtils.isBlank(param.getTaxRate())) {
             throw new BusinessException("发票税率不能为空!");
@@ -318,11 +318,8 @@ public class KwpGoodsService {
         List<GoodsAttributes> attributes = param.getAttributes();
         if (CollectionUtils.isNotEmpty(attributes)) {
             attributes.forEach(e -> {
-                if (StringUtils.isBlank(e.getName()) || e.getName().length() > 10) {
-                    throw new BusinessException("参数名称不能为空且最长10字符!");
-                }
-                if (StringUtils.isBlank(e.getVal()) || e.getVal().length() > 20) {
-                    throw new BusinessException("参数值不能为空且最长20字符!");
+                if (StringUtils.isBlank(e.getName()) || StringUtils.isBlank(e.getVal())) {
+                    throw new BusinessException("参数名称或参数值不能为空且!");
                 }
             });
         }
@@ -389,9 +386,6 @@ public class KwpGoodsService {
         if (Objects.isNull(param.getManager())) {
             throw new BusinessException("客户经理不能为空!");
         }
-        if (StringUtils.isNotBlank(param.getRemark()) && param.getRemark().length() > 200) {
-            throw new BusinessException("备注最多支持200字!");
-        }
     }
 
     /**