Sfoglia il codice sorgente

推单参数修改

lhm 3 anni fa
parent
commit
c48ea49f2a

+ 29 - 2
kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java

@@ -110,6 +110,7 @@ import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 
@@ -2221,9 +2222,13 @@ public class OrderServiceImpl implements OrderService {
             });
             // 将在循环中查询数据库改为一次性查询
             List<GoodsEntity> goodsEntityList = goodsService.queryGoodsStockByQueryGoodsVoList(queryGoodsVOList);
+            Map<String, GoodsEntity> goodsEntityMap = goodsEntityList.stream().collect(Collectors.toMap(GoodsEntity::getSku, Function.identity(), (k1, k2) -> k2));
             // 复制集合数据
             ListUtils listUtils = BeanUtils.instantiate(ListUtils.class);
             listUtils.copyList(goodsEntityList, queryGoodsVOList);
+
+            // 商品总重量
+            BigDecimal weight = new BigDecimal(0);
             // 检查库存和更新库存
             for (QueryGoodsVO goodsDto : queryGoodsVOList) {
                 // 要购买的数量
@@ -2317,6 +2322,16 @@ public class OrderServiceImpl implements OrderService {
                     goodsEntity.setActivity(goodsDto.getActivity());
                     goodsEntity.setStoreId(storeId);
                     goodsEntity.setListPicUrl(goodsDto.getListPicUrl());
+                    GoodsEntity goodsEntity1 = goodsEntityMap.get(sku);
+                    if (Objects.nonNull(goodsEntity1)) {
+                        goodsEntity.setNetWeight(goodsEntity1.getNetWeight());
+                        goodsEntity.setWarehouseSn(goodsEntity1.getWarehouseSn());
+                        goodsEntity.setConsignorSn(goodsEntity1.getConsignorSn());
+                        goodsEntity.setWarehousSysGoodId(goodsEntity1.getWarehousSysGoodId());
+                        goodsEntity.setInventoryType(goodsEntity1.getInventoryType());
+                        goodsEntity.setDefectiveProductsGrade(goodsEntity1.getDefectiveProductsGrade());
+                        weight = weight.add(goodsEntity1.getNetWeight().multiply(new BigDecimal(goodsEntity.getSellVolume())));
+                    }
                     goodsEntities.add(goodsEntity);
                 } else {
                     // sku不存在
@@ -2391,6 +2406,7 @@ public class OrderServiceImpl implements OrderService {
             order.setMerchOrderSn(merchOrderSn);
             order.setCoupon_name(couponSn); // 借用这个字段来记录是否使用优惠券
             order.setIdCard(userEntity.getIdNo());
+            order.setWeight(weight);
             //插入订单信息和订单商品
             orderDao.saveOrderVo(order);
 
@@ -2759,7 +2775,7 @@ public class OrderServiceImpl implements OrderService {
         OrderInfoItemDTO orderInfoItemDTO = new OrderInfoItemDTO();
         orderInfoItemDTO.setOrderId(orderGoodsVo.getOrderSn());
         orderInfoItemDTO.setImageUrl(orderGoodsVo.getList_pic_url());
-        orderInfoItemDTO.setBn("11111111");
+        orderInfoItemDTO.setBn(orderGoodsVo.getSku());
         orderInfoItemDTO.setBarcode(orderGoodsVo.getBarcode());
         orderInfoItemDTO.setName(orderGoodsVo.getGoods_name());
         orderInfoItemDTO.setCost(orderGoodsVo.getMarket_price());
@@ -2786,7 +2802,12 @@ public class OrderServiceImpl implements OrderService {
         orderInfoDTO.setConsigneeTel("0756-8800000");
         orderInfoDTO.setConsigneeEmail("hk@greedc.com");
         orderInfoDTO.setConsigneeMobile(order.getMobile());
-        orderInfoDTO.setWeight("?");
+        BigDecimal weight = order.getWeight();
+        if (Objects.nonNull(weight)) {
+            orderInfoDTO.setWeight(weight.toString());
+        } else {
+            orderInfoDTO.setWeight("0");
+        }
         orderInfoDTO.setQuantity(order.getNumber());
         orderInfoDTO.setOrderTotal(order.getActual_price());
         orderInfoDTO.setPlatform("store");
@@ -4845,6 +4866,12 @@ public class OrderServiceImpl implements OrderService {
         orderGoodsVo.setGoodsRate(goodsDto.getGoodsRate());
         orderGoodsVo.setSku(goodsDto.getSku());
 
+        orderGoodsVo.setNetWeight(goodsDto.getNetWeight());
+        orderGoodsVo.setWarehouseSn(goodsDto.getWarehouseSn());
+        orderGoodsVo.setConsignorSn(goodsDto.getConsignorSn());
+        orderGoodsVo.setWarehouseSysGoodId(goodsDto.getWarehousSysGoodId());
+        orderGoodsVo.setInventoryType(goodsDto.getInventoryType());
+        orderGoodsVo.setDefectiveProductsGrade(goodsDto.getDefectiveProductsGrade());
 
         BigDecimal number = new BigDecimal(Long.valueOf(goodsDto.getSellVolume()));
         BigDecimal goodsTotal = goodsDto.getRetailPrice().multiply(number);//单商品总价

+ 76 - 0
kmall-api/src/main/java/com/kmall/api/entity/OrderGoodsVo.java

@@ -89,7 +89,35 @@ public class OrderGoodsVo implements Serializable {
      */
     private String barcode;
 
+    /**
+     * 商品重量
+     */
+    private BigDecimal netWeight;
+
+    /**
+     * 仓库编码
+     */
+    private String warehouseSn;
+
+    /**
+     * 货主编码
+     */
+    private String consignorSn;
+
+    /**
+     * 仓储系统商品ID
+     */
+    private String warehouseSysGoodId;
 
+    /**
+     * 库存类型,默认:ZP(正品)
+     */
+    private String inventoryType;
+
+    /**
+     * 残品等级(非残次品可不填)
+     */
+    private String defectiveProductsGrade;
 
     public BigDecimal getDiscountedPrice() {
         return discountedPrice;
@@ -355,4 +383,52 @@ public class OrderGoodsVo implements Serializable {
     public void setBarcode(String barcode) {
         this.barcode = barcode;
     }
+
+    public BigDecimal getNetWeight() {
+        return netWeight;
+    }
+
+    public void setNetWeight(BigDecimal netWeight) {
+        this.netWeight = netWeight;
+    }
+
+    public String getWarehouseSn() {
+        return warehouseSn;
+    }
+
+    public void setWarehouseSn(String warehouseSn) {
+        this.warehouseSn = warehouseSn;
+    }
+
+    public String getConsignorSn() {
+        return consignorSn;
+    }
+
+    public void setConsignorSn(String consignorSn) {
+        this.consignorSn = consignorSn;
+    }
+
+    public String getWarehouseSysGoodId() {
+        return warehouseSysGoodId;
+    }
+
+    public void setWarehouseSysGoodId(String warehouseSysGoodId) {
+        this.warehouseSysGoodId = warehouseSysGoodId;
+    }
+
+    public String getInventoryType() {
+        return inventoryType;
+    }
+
+    public void setInventoryType(String inventoryType) {
+        this.inventoryType = inventoryType;
+    }
+
+    public String getDefectiveProductsGrade() {
+        return defectiveProductsGrade;
+    }
+
+    public void setDefectiveProductsGrade(String defectiveProductsGrade) {
+        this.defectiveProductsGrade = defectiveProductsGrade;
+    }
 }

+ 13 - 0
kmall-api/src/main/java/com/kmall/api/entity/OrderVo.java

@@ -236,6 +236,11 @@ public class OrderVo implements Serializable {
      */
     private String payApp;
 
+    /**
+     * 商品总重量
+     */
+    private BigDecimal weight;
+
     public String getDiscountApplyType() {
         return discountApplyType;
     }
@@ -1069,4 +1074,12 @@ public class OrderVo implements Serializable {
     public void setPayApp(String payApp) {
         this.payApp = payApp;
     }
+
+    public BigDecimal getWeight() {
+        return weight;
+    }
+
+    public void setWeight(BigDecimal weight) {
+        this.weight = weight;
+    }
 }