Browse Source

fixed 商品成本价功能开发迭代

fushengqian 1 month ago
parent
commit
6dff759bfa

+ 3 - 0
fuint-application/src/main/java/com/fuint/common/dto/GoodsDto.java

@@ -63,6 +63,9 @@ public class GoodsDto implements Serializable {
     @ApiModelProperty("划线价格")
     private BigDecimal linePrice;
 
+    @ApiModelProperty("成本价格")
+    private BigDecimal costPrice;
+
     @ApiModelProperty("库存")
     private Double stock;
 

+ 3 - 0
fuint-application/src/main/java/com/fuint/common/dto/GoodsSkuDto.java

@@ -46,6 +46,9 @@ public class GoodsSkuDto implements Serializable {
     @ApiModelProperty("划线价格")
     private BigDecimal linePrice;
 
+    @ApiModelProperty("成本价格")
+    private BigDecimal costPrice;
+
     @ApiModelProperty("重量")
     private BigDecimal weight;
 

+ 6 - 0
fuint-application/src/main/java/com/fuint/common/service/impl/GoodsServiceImpl.java

@@ -307,6 +307,12 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
         if (reqDto.getLinePrice() == null && reqDto.getId() <= 0) {
             mtGoods.setLinePrice(new BigDecimal("0.00"));
         }
+        if (reqDto.getCostPrice() != null) {
+            mtGoods.setCostPrice(reqDto.getCostPrice());
+        }
+        if (reqDto.getCostPrice() == null && reqDto.getId() <= 0) {
+            mtGoods.setCostPrice(new BigDecimal("0.00"));
+        }
         if (StringUtil.isNotEmpty(reqDto.getCouponIds())) {
             mtGoods.setCouponIds(reqDto.getCouponIds());
         }

+ 13 - 2
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendGoodsController.java

@@ -299,6 +299,7 @@ public class BackendGoodsController extends BaseController {
         String goodsNo = param.get("goodsNo") == null ? "" : param.get("goodsNo").toString();
         String price = param.get("price") == null ? "" : param.get("price").toString();
         String linePrice = param.get("linePrice") == null ? "" : param.get("linePrice").toString();
+        String costPrice = param.get("costPrice") == null ? "" : param.get("costPrice").toString();
         String weight = param.get("weight") == null ? "" : param.get("weight").toString();
         Double initSale = param.get("initSale") == null ? 0 : Double.parseDouble(param.get("initSale").toString());
         String salePoint = param.get("salePoint") == null ? "" : param.get("salePoint").toString();
@@ -395,6 +396,12 @@ public class BackendGoodsController extends BaseController {
             }
             sku.setLinePrice(skuLinePrice);
 
+            BigDecimal skuCostPrice = new BigDecimal("0");
+            if (skuDto.get("costPrice") != null && StringUtil.isNotEmpty(skuDto.get("costPrice").toString())) {
+                skuCostPrice = new BigDecimal(skuDto.get("costPrice").toString());
+            }
+            sku.setCostPrice(skuCostPrice);
+
             BigDecimal skuWeight = new BigDecimal("0");
             if (skuDto.get("weight") != null && StringUtil.isNotEmpty(skuDto.get("weight").toString())) {
                 skuWeight = new BigDecimal(skuDto.get("weight").toString());
@@ -412,12 +419,13 @@ public class BackendGoodsController extends BaseController {
         if (skuList.size() > 0 && isSingleSpec.equals(YesOrNoEnum.NO.getKey())) {
             price = skuList.get(0).get("price").toString();
             linePrice = skuList.get(0).get("linePrice").toString();
+            costPrice = skuList.get(0).get("costPrice").toString();
             weight = skuList.get(0).get("weight").toString();
             // 库存等于所有sku库存相加
-            Integer allStock = 0;
+            Double allStock = 0.0;
             for (LinkedHashMap item : skuList) {
                  if (StringUtil.isNotEmpty(item.get("stock").toString())) {
-                     allStock = allStock + Integer.parseInt(item.get("stock").toString());
+                     allStock = allStock + Double.parseDouble(item.get("stock").toString());
                  }
             }
             stock = allStock.toString();
@@ -465,6 +473,9 @@ public class BackendGoodsController extends BaseController {
         if (StringUtil.isNotEmpty(linePrice)) {
             mtGoods.setLinePrice(new BigDecimal(linePrice));
         }
+        if (StringUtil.isNotEmpty(costPrice)) {
+            mtGoods.setCostPrice(new BigDecimal(costPrice));
+        }
         if (StringUtil.isNotEmpty(weight)) {
             mtGoods.setWeight(new BigDecimal(weight));
         }

+ 4 - 2
fuint-repository/src/main/java/com/fuint/repository/model/MtGoods.java

@@ -56,12 +56,15 @@ public class MtGoods implements Serializable {
     @ApiModelProperty("图片地址")
     private String images;
 
-    @ApiModelProperty("价格")
+    @ApiModelProperty("销售价格")
     private BigDecimal price;
 
     @ApiModelProperty("划线价格")
     private BigDecimal linePrice;
 
+    @ApiModelProperty("成本价格")
+    private BigDecimal costPrice;
+
     @ApiModelProperty("库存")
     private Double stock;
 
@@ -104,5 +107,4 @@ public class MtGoods implements Serializable {
     @ApiModelProperty("A:正常;D:删除")
     private String status;
 
-
 }

+ 3 - 0
fuint-repository/src/main/java/com/fuint/repository/model/MtGoodsSku.java

@@ -49,6 +49,9 @@ public class MtGoodsSku implements Serializable {
     @ApiModelProperty("划线价格")
     private BigDecimal linePrice;
 
+    @ApiModelProperty("成本价格")
+    private BigDecimal costPrice;
+
     @ApiModelProperty("重量")
     private BigDecimal weight;