浏览代码

联合丽格

huangzhiguo 2 年之前
父节点
当前提交
5ce5c4d7ae

+ 38 - 4
src/main/java/com/caimei365/order/components/OrderCommonService.java

@@ -14,10 +14,9 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
 
 /**
  * Description
@@ -68,6 +67,8 @@ public class OrderCommonService {
         String[] shopOrderIdArr = order.getShopOrderIds().split(",");
         List<String> shopOrderIds = Arrays.asList(shopOrderIdArr);
         List<ShopOrderVo> shopOrderList = orderCommonMapper.getShopOrderList(shopOrderIds);
+        // 冷链商品类型
+        List<Integer> arrList = new ArrayList<>();
         shopOrderList.forEach(shopOrder -> {
             // 店铺促销活动
             PromotionsVo shopPromotion = null;
@@ -77,6 +78,16 @@ public class OrderCommonService {
             }
             List<OrderProductVo> orderProductList = orderCommonMapper.getShopOrderProduct(shopOrder.getShopOrderId());
             orderProductList.removeIf(Objects::isNull);
+            // 冷链商品判定
+            List<Integer> collect = orderProductList.stream().map(OrderProductVo::getProductId).collect(Collectors.toList());
+            collect.removeIf(c -> c == 999);
+            if (collect.stream().allMatch(c -> c == 7881)) {
+                arrList.add(1);
+            } else if (!collect.contains(7881)) {
+                arrList.add(2);
+            } else {
+                arrList.add(3);
+            }
             orderProductList.forEach(orderProduct -> {
                 // 不含税可开票商品,单价/折后单价在原基础上加上税费
                 boolean taxFlag = (Integer.valueOf(0).equals(orderProduct.getIncludedTax()) && (Integer.valueOf(1).equals(orderProduct.getInvoiceType()) || Integer.valueOf(2).equals(orderProduct.getInvoiceType())));
@@ -115,7 +126,30 @@ public class OrderCommonService {
             if (0 == order.getOnlinePayFlag()) {
                 shopOrder.setObligation(MathUtil.sub(shopOrder.getRealPay(), shopOrder.getReceiptAmount()).doubleValue());
             }
+            // 冷链运输费 -- 联合丽格
+            if (null != shopOrder.getIsColdChina() && 1 == shopOrder.getIsColdChina()) {
+                order.setColdChina(700.00d);
+                order.setIsColdChina(shopOrder.getIsColdChina());
+            } else {
+                order.setColdChina(0.00d);
+                order.setIsColdChina(0);
+            }
         });
+        // 拼接运费信息--联合丽格
+        if (null != order.getColdChina()) {
+            if (-1 == order.getPostageFlag()) {
+                // 到付
+                order.setPostageInfo("¥" + order.getPostage().doubleValue() + "("+(order.getIsColdChina()==1?"冷链费: ¥" + order.getColdChina().doubleValue():"") + (arrList.stream().allMatch(c -> c == 1)?")":" 其他: 到付)"));
+            } else if (0 == order.getPostageFlag()) {
+                // 包邮
+                order.setPostageInfo("¥" + order.getPostage().doubleValue() + "("+(order.getIsColdChina()==1?"冷链费: ¥" + order.getColdChina().doubleValue():"") + (arrList.stream().allMatch(c -> c == 1)?")":" 其他: 包邮)"));
+            } else {
+                // 有运费
+                order.setPostageInfo("¥" + order.getPostage().doubleValue() + "("+(order.getIsColdChina()==1?"冷链费: ¥" + order.getColdChina().doubleValue():"") + (!arrList.stream().allMatch(c -> c == 1)?" 其他: ¥" + MathUtil.sub(order.getPostage(), order.getColdChina()).doubleValue():")") + ")");
+            }
+        } else {
+            order.setPostageInfo(order.getPostage().doubleValue() == -1?"到付":order.getPostageFlag() == 0?"包邮":"¥" + order.getPostage().doubleValue());
+        }
         // 过滤运费商品
         shopOrderList.removeIf(shopOrder -> shopOrder.getShopId() == 998);
         order.setShopOrderList(shopOrderList);

+ 11 - 9
src/main/java/com/caimei365/order/components/ProductService.java

@@ -210,6 +210,17 @@ public class ProductService {
         } else {
             postageFlagList = baseMapper.getPostageFlagOrganizeList(skuIdList);
         }
+        // 是否包含需要冷链运输商品
+        if (0 != organizeId) {
+            List<Integer> collect = postageFlagList.stream().map(ProductPostageVo::getProductId).collect(Collectors.toList());
+            if (collect.stream().allMatch(c -> c == 7881)) {
+                postageMap.put("designatedFlag", 1);
+            } else if (!collect.contains(7881)) {
+                postageMap.put("designatedFlag", 2);
+            } else {
+                postageMap.put("designatedFlag", 3);
+            }
+        }
         if (null != postageFlagList && postageFlagList.size() > 0) {
             for (ProductPostageVo postageVo : postageFlagList) {
                 if (null != postageVo) {
@@ -233,15 +244,6 @@ public class ProductService {
             // 采美
             count = baseMapper.countUserOrder(userId);
         } else {
-            // 是否包含需要冷链运输商品
-            List<Integer> collect = postageFlagList.stream().map(ProductPostageVo::getProductId).collect(Collectors.toList());
-            if (collect.stream().allMatch(c -> c == 7502)) {
-                postageMap.put("designatedFlag",1);
-            } else if (!collect.contains(7502)) {
-                postageMap.put("designatedFlag",2);
-            } else {
-                postageMap.put("designatedFlag",3);
-            }
             // 组织 -- 联合丽格无首单优惠
             count = -1;
         }

+ 2 - 2
src/main/java/com/caimei365/order/controller/OrderClubApi.java

@@ -291,7 +291,7 @@ public class OrderClubApi {
             @ApiImplicitParam(required = false, name = "iv", value = "微信加密算法的初始向量")
     })
     @GetMapping("/share/code/check")
-    public ResponseJson<String> checkOrderShareCode( Integer orderId, String shareCode, String code, String encryptedData, String iv, @RequestHeader HttpHeaders headers) {
+    public ResponseJson<String> checkOrderShareCode(Integer userId, Integer orderId, String shareCode, String code, String encryptedData, String iv, @RequestHeader HttpHeaders headers) {
         if (null == orderId) {
             return ResponseJson.error("订单Id不能为空!", null);
         }
@@ -301,7 +301,7 @@ public class OrderClubApi {
         if (StringUtils.isEmpty(code)) {
             return ResponseJson.error("微信code不能为空!", null);
         }
-        return orderClubService.checkOrderShareCode(orderId, shareCode, code, encryptedData, iv, headers);
+        return orderClubService.checkOrderShareCode(userId, orderId, shareCode, code, encryptedData, iv, headers);
     }
 
 

+ 5 - 0
src/main/java/com/caimei365/order/mapper/SubmitMapper.java

@@ -81,6 +81,11 @@ public interface SubmitMapper {
      */
     void insertShopOrder(OrderShopPo shopOrder);
 
+    /**
+     * 修改订单运费状态
+     */
+    void updateOrder(@Param("freight") Double freight, @Param("orderId") Integer orderId );
+
     /**
      * 保存 订单商品
      */

+ 16 - 0
src/main/java/com/caimei365/order/model/vo/OrderVo.java

@@ -163,6 +163,22 @@ public class OrderVo implements Serializable {
      * -1到付,0包邮,大于0具体金额,-2仪器到付其它包邮(且运费已使用商品形式存储)
      */
     private Double postage;
+    /**
+     * 冷链费
+     */
+    private Double coldChina;
+    /**
+     * 是否包含冷链费
+     */
+    private Integer isColdChina;
+    /**
+     * 运费--联合丽格
+     */
+    private String postageInfo;
+    /**
+     * 上传支付凭证状态
+     */
+    private Integer checkFlag;
     /**
      * 商品总金额 (商品单价乘以数量,再加上税费)
      */

+ 4 - 0
src/main/java/com/caimei365/order/model/vo/ShopOrderVo.java

@@ -47,6 +47,10 @@ public class ShopOrderVo implements Serializable {
      * 组织Id
      */
     private Integer organizeId;
+    /**
+     * 冷链费用标记
+     */
+    private Integer isColdChina;
     /**
      * 订单编号
      */

+ 2 - 1
src/main/java/com/caimei365/order/service/OrderClubService.java

@@ -114,6 +114,7 @@ public interface OrderClubService {
     ResponseJson<String> identityOrderShareCode(Integer orderId, Integer userId, Integer serviceProviderId, String code, String encryptedData, String iv, HttpHeaders headers);
     /**
      * 分享订单,校验分享码
+     * @param userId 用户Id
      * @param orderId 订单Id
      * @param shareCode 分享码
      * @param code 微信code
@@ -121,7 +122,7 @@ public interface OrderClubService {
      * @param iv 微信加密算法的初始向量
      * @param headers HttpHeaders
      */
-    ResponseJson<String> checkOrderShareCode(Integer orderId, String shareCode, String code, String encryptedData, String iv, HttpHeaders headers);
+    ResponseJson<String> checkOrderShareCode(Integer userId, Integer orderId, String shareCode, String code, String encryptedData, String iv, HttpHeaders headers);
     /**
      * 分享订单,初始商品数据
      * @param orderId 订单Id

+ 2 - 5
src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java

@@ -1208,15 +1208,12 @@ public class CartClubServiceImpl implements CartClubService {
                 }
             });
             // 删除空数据
-            log.info("shopList===="+shopList);
             shopList.removeIf(shop -> (null == shop || shop.getCount() == 0));
-            log.info("shopList----"+shopList);
 
         }
         // 总促销计算
         // 满减满赠叠加计算
         List<CartShopVo> finalShopList = shopList;
-        log.info("shopList*****"+shopList);
         totalPromotions.forEach(promotions -> {
             // 该促销内商品总价
             double touchPrice = promotions.getProductList().stream().mapToDouble(product -> product.getNumber() * product.getPrice()).sum();
@@ -1298,7 +1295,7 @@ public class CartClubServiceImpl implements CartClubService {
             double coldChain = 0.00d;
             if (null != totalProductList) {
                 for (CartItemVo cart :totalProductList) {
-                    if (7502 == cart.getProductId()) {
+                    if (7881 == cart.getProductId()) {
                         if (cart.getNumber() >= 100) {
                             coldChain = 0.00d;
                         } else {
@@ -1987,7 +1984,7 @@ public class CartClubServiceImpl implements CartClubService {
         // 联合丽格冷链费
         if (0 != organizeId) {
             double coldChain = 0.00d;
-            if (7502 == cartDto.getProductId()) {
+            if (7881 == cartDto.getProductId()) {
                 if (cartDto.getProductCount() >= 100) {
                     coldChain = 0.00d;
                 } else {

+ 17 - 6
src/main/java/com/caimei365/order/service/impl/OrderClubServiceImpl.java

@@ -150,8 +150,10 @@ public class OrderClubServiceImpl implements OrderClubService {
             orderCommonService.getDiscernReceiptAndSetOrder(order);
             // 联合丽格 [待付款]或者线下支付[部分付款] 的主订单 状态
             if (0 != order.getOrganizeId()) {
-                if (1 == order.getPayStatus() || (2 == order.getPayStatus() && 1 == order.getOnlinePayFlag())) {
-                    order.setStatus(333);
+                if ((6 != order.getStatus() && 7 != order.getStatus()) && (1 == order.getReceiptStatus() || (2 == order.getReceiptStatus() && 1 == order.getOnlinePayFlag()))) {
+                    order.setCheckFlag(1);
+                } else {
+                    order.setCheckFlag(0);
                 }
             }
         });
@@ -210,8 +212,10 @@ public class OrderClubServiceImpl implements OrderClubService {
         // OrderPo -> OrderVo
         BeanUtils.copyProperties(orderPo, order);
         if (0 != order.getOrganizeId()) {
-            if (1 == order.getPayStatus() || (2 == order.getPayStatus() && 1 == order.getOnlinePayFlag())) {
-                order.setStatus(333);
+            if ((6 != order.getStatus() && 7 != order.getStatus()) && (1 == order.getReceiptStatus() || (2 == order.getReceiptStatus() && 1 == order.getOnlinePayFlag()))) {
+                order.setCheckFlag(1);
+            } else {
+                order.setCheckFlag(0);
             }
         }
         order.setOrderMark("#" + order.getOrderId() + "#");
@@ -985,13 +989,20 @@ public class OrderClubServiceImpl implements OrderClubService {
      * @param headers       HttpHeaders
      */
     @Override
-    public ResponseJson<String> checkOrderShareCode(Integer orderId, String shareCode, String code, String encryptedData, String iv, HttpHeaders headers) {
+    public ResponseJson<String> checkOrderShareCode(Integer userId, Integer orderId, String shareCode, String code, String encryptedData, String iv, HttpHeaders headers) {
+        // 用户组织Id
+        Integer organizeId = baseMapper.getOrganizeId(userId);
         int orderCount = orderClubMapper.countMainOrderByOrderId(orderId);
         if (0 == orderCount) {
             return ResponseJson.error("订单不存在!", null);
         }
         // 微信小程序授权登录(调用user服务,发送服务间调用POST请求)
-        String loginData = remoteCallService.appletsAuthorization(code, encryptedData, iv, headers);
+        String loginData = null;
+        if (0 == organizeId) {
+            loginData = remoteCallService.appletsAuthorization(code, encryptedData, iv, headers);
+        } else {
+            loginData = remoteCallService.appletsOrganizeAuthorization(code, encryptedData, iv, headers, userId);
+        }
         if (StringUtils.isEmpty(loginData)) {
             return ResponseJson.error("微信授权登录异常!", null);
         }

+ 97 - 73
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -562,13 +562,18 @@ public class SubmitServiceImpl implements SubmitService {
                     return ResponseJson.error("订单商品不存在!", null);
                 }
                 // 联合丽格冷链费商品
-                if (7502 == product.getProductId()) {
-                    if (productNum >= 100) {
-                        isColdChina.set(0.00d);
-                    } else {
-                        isColdChina.set(700.00d);
-                        orderParamBo.setOrderShouldPayFee(MathUtil.sub(orderParamBo.getOrderShouldPayFee(), isColdChina.get()).doubleValue());
+                if (1 == orderParamBo.getIsColdChain()) {
+                    if (7881 == product.getProductId()) {
+                        if (productNum >= 100) {
+                            isColdChina.set(0.00d);
+                        } else {
+                            isColdChina.set(700.00d);
+    //                        payableAmount.set(MathUtil.add(payableAmount.get(), isColdChina).doubleValue());
+//                            orderParamBo.setOrderShouldPayFee(MathUtil.sub(orderParamBo.getOrderShouldPayFee(), isColdChina.get()).doubleValue());
+                        }
                     }
+                } else {
+                    isColdChina.set(0.00d);
                 }
                 // 是否二手商品
                 if (null != product.getProductCategory() && 2 == product.getProductCategory()) {
@@ -628,69 +633,71 @@ public class SubmitServiceImpl implements SubmitService {
                     }
                     // 计算单价
                     // 超级会员单价折扣计算
-                    if (null != svipProductPo && 1 == svipProductPo.getSvipProductFlag()) {
-                        // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
-                        if (orderParamBo.getSvipUserFlag()) {
-                            if (1 == svipProductPo.getSvipPriceType()) {
-                                // 折扣价
-                                discountPrice = MathUtil.div(MathUtil.mul(productPrice, svipProductPo.getSvipDiscount()), 100, 2).doubleValue();
-                            } else if (2 == svipProductPo.getSvipPriceType()) {
-                                // 直接优惠价
-                                discountPrice = svipProductPo.getSvipDiscountPrice();
-                            }
-                            // 商品超级会员优惠
-                            BigDecimal svipReduction = MathUtil.sub(productPrice, discountPrice);
-                            if (taxFlag) {
-                                // 商品税费超级会员优惠
-                                BigDecimal svipTaxReduction = MathUtil.div(MathUtil.mul(svipReduction, product.getTaxRate()), 100, 2);
-                                svipReduction = MathUtil.add(svipReduction, svipTaxReduction);
+                    if (0 == organizeId) {
+                        if (null != svipProductPo && 1 == svipProductPo.getSvipProductFlag()) {
+                            // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
+                            if (orderParamBo.getSvipUserFlag()) {
+                                if (1 == svipProductPo.getSvipPriceType()) {
+                                    // 折扣价
+                                    discountPrice = MathUtil.div(MathUtil.mul(productPrice, svipProductPo.getSvipDiscount()), 100, 2).doubleValue();
+                                } else if (2 == svipProductPo.getSvipPriceType()) {
+                                    // 直接优惠价
+                                    discountPrice = svipProductPo.getSvipDiscountPrice();
+                                }
+                                // 商品超级会员优惠
+                                BigDecimal svipReduction = MathUtil.sub(productPrice, discountPrice);
+                                if (taxFlag) {
+                                    // 商品税费超级会员优惠
+                                    BigDecimal svipTaxReduction = MathUtil.div(MathUtil.mul(svipReduction, product.getTaxRate()), 100, 2);
+                                    svipReduction = MathUtil.add(svipReduction, svipTaxReduction);
+                                }
+                                // 统计超级会员优惠
+                                product.setSvipReduction(svipReduction.doubleValue());
+                                svipShopReduction.set(MathUtil.add(svipShopReduction, MathUtil.mul(svipReduction, productNum)).doubleValue());
+                                svipFullReduction.set(MathUtil.add(svipFullReduction, MathUtil.mul(svipReduction, productNum)).doubleValue());
+                                // 保存订单商品svip数据
+                                product.setSvipPriceFlag(1);
+                                product.setSvipPriceType(svipProductPo.getSvipPriceType());
+                                product.setSvipDiscount(1 == svipProductPo.getSvipPriceType() ? svipProductPo.getSvipDiscount() : 0.00d);
                             }
-                            // 统计超级会员优惠
-                            product.setSvipReduction(svipReduction.doubleValue());
-                            svipShopReduction.set(MathUtil.add(svipShopReduction, MathUtil.mul(svipReduction, productNum)).doubleValue());
-                            svipFullReduction.set(MathUtil.add(svipFullReduction, MathUtil.mul(svipReduction, productNum)).doubleValue());
-                            // 保存订单商品svip数据
-                            product.setSvipPriceFlag(1);
-                            product.setSvipPriceType(svipProductPo.getSvipPriceType());
-                            product.setSvipDiscount(1 == svipProductPo.getSvipPriceType() ? svipProductPo.getSvipDiscount() : 0.00d);
                         }
-                    }
-                    // 有单品优惠价促销活动
-                    else if (null != promotions || null != shopPromotions) {
-                        // 是否包含活动商品(受订单未支付自动关闭时间影响)  0 否 1 是
-                        hasActProductFlag = true;
-                        // 关闭阶梯价格,活动优先
-                        product.setLadderPriceFlag(0);
-                        product.setActProduct(1);
-                        if (null != promotions && promotions.getType() == 1 && promotions.getMode() == 1) {
-                            discountPrice = promotions.getTouchPrice();
+                        // 有单品优惠价促销活动
+                        else if (null != promotions || null != shopPromotions) {
+                            // 是否包含活动商品(受订单未支付自动关闭时间影响)  0 否 1 是
+                            hasActProductFlag = true;
+                            // 关闭阶梯价格,活动优先
+                            product.setLadderPriceFlag(0);
+                            product.setActProduct(1);
+                            if (null != promotions && promotions.getType() == 1 && promotions.getMode() == 1) {
+                                discountPrice = promotions.getTouchPrice();
+                            }
                         }
-                    }
 
-                    //有阶梯价
-                    else if (1 == product.getLadderPriceFlag()) {
-                        // 启用了阶梯价格
-                        List<LadderPriceVo> ladderPrices = baseMapper.getLadderPriceList(skuId);
-                        // 判断阶梯价格的购买数量校验
-                        int minBuyNumber = null != ladderPrices.get(0) ? ladderPrices.get(0).getBuyNum() : 0;
-                        if (productNum < minBuyNumber) {
-                            return ResponseJson.error("商品购买量低于最小起订量!", null);
-                        }
-                        //根据商品购买数量获取商品对应阶梯价格
-                        for (LadderPriceVo ladderPrice : ladderPrices) {
-                            if (productNum >= ladderPrice.getBuyNum()) {
-                                discountPrice = ladderPrice.getBuyPrice();
+                        //有阶梯价
+                        else if (1 == product.getLadderPriceFlag()) {
+                            // 启用了阶梯价格
+                            List<LadderPriceVo> ladderPrices = baseMapper.getLadderPriceList(skuId);
+                            // 判断阶梯价格的购买数量校验
+                            int minBuyNumber = null != ladderPrices.get(0) ? ladderPrices.get(0).getBuyNum() : 0;
+                            if (productNum < minBuyNumber) {
+                                return ResponseJson.error("商品购买量低于最小起订量!", null);
                             }
+                            //根据商品购买数量获取商品对应阶梯价格
+                            for (LadderPriceVo ladderPrice : ladderPrices) {
+                                if (productNum >= ladderPrice.getBuyNum()) {
+                                    discountPrice = ladderPrice.getBuyPrice();
+                                }
+                            }
+                            product.setLadderPrices(ladderPrices);
+                            product.setActProduct(2);
+                        } else {
+                            // 复购价
+                            Double repurchase = baseMapper.getRepurchasePrice(skuId, orderParamBo.getUserId());
+                            if (null != repurchase && repurchase > 0) {
+                                discountPrice = repurchase;
+                            }
+                            product.setActProduct(0);
                         }
-                        product.setLadderPrices(ladderPrices);
-                        product.setActProduct(2);
-                    } else {
-                        // 复购价
-                        Double repurchase = baseMapper.getRepurchasePrice(skuId, orderParamBo.getUserId());
-                        if (null != repurchase && repurchase > 0) {
-                            discountPrice = repurchase;
-                        }
-                        product.setActProduct(0);
                     }
                     if (MathUtil.compare(discountPrice, BigDecimal.ZERO) == 0) {
                         return ResponseJson.error("商品购买价格不能为0!", null);
@@ -837,6 +844,7 @@ public class SubmitServiceImpl implements SubmitService {
                 // 付供应商 商品费=成本价*(购买数量  + 赠品数量)
                 Double costAmount = MathUtil.mul(costPrice, MathUtil.add(productNum, presentNum)).doubleValue();
                 product.setShopProductAmount(costAmount);
+                log.info("product.getShopProductAmount()***"+product.getShopProductAmount());
                 //应付供应商(单)=成本价+供应商税费(单)
                 Double singleShopFee = MathUtil.add(product.getCostPrice(), shopTax).doubleValue();
                 product.setSingleShopFee(singleShopFee);
@@ -879,6 +887,8 @@ public class SubmitServiceImpl implements SubmitService {
                 // 商品总金额
                 shopAmount.set(MathUtil.add(shopAmount.get(), product.getTotalAmount()).doubleValue());
                 // 付供应商 商品费
+                log.info("shopProductAmount.get()"+shopProductAmount.get());
+                log.info("product.getShopProductAmount()"+product.getShopProductAmount());
                 shopProductAmount.set(MathUtil.add(shopProductAmount.get(), product.getShopProductAmount()).doubleValue());
                 // 付供应商税费
                 shopTaxFee.set(MathUtil.add(shopTaxFee.get(), product.getShouldPayTotalTax()).doubleValue());
@@ -1103,8 +1113,8 @@ public class SubmitServiceImpl implements SubmitService {
         // 商品总额
         mainOrder.setProductTotalFee(productTotalFee.get());
         mainOrder.setOrderTotalFee(productTotalFee.get());
-        // 订单总额(商品金额+运费)
-        mainOrder.setPayTotalFee(payTotalFee.get());
+        // 订单总额(商品金额+运费)-- 冷链运输费
+        mainOrder.setPayTotalFee(MathUtil.add(payTotalFee.get(), isColdChina.get()).doubleValue());
         // 订单状态
         if (0 == organizeId) {
             if (3 == orderParamBo.getCartType()) {
@@ -1165,8 +1175,8 @@ public class SubmitServiceImpl implements SubmitService {
         }
         // 余额支付金额
         mainOrder.setBalancePayFee(balancePayFee.get());
-        // 实际支付金额(商品金额+运费-余额抵扣)
-        mainOrder.setPayableAmount(payableAmount.get());
+        // 实际支付金额(商品金额+运费-余额抵扣) + 冷链费用
+        mainOrder.setPayableAmount(MathUtil.add(payableAmount.get(), isColdChina.get()).doubleValue());
 
         // 是否返佣订单
         Integer rebateFlag = (null == orderParamBo.getRebateFlag() ? 0 : orderParamBo.getRebateFlag());
@@ -1176,6 +1186,7 @@ public class SubmitServiceImpl implements SubmitService {
         }
 
         // 判断前端传入orderShouldPayFee订单应付金额,和后台计算应付金额对比
+        orderParamBo.setOrderShouldPayFee(MathUtil.sub(orderParamBo.getOrderShouldPayFee(), isColdChina.get()).doubleValue());
         log.info("【提交订单】>>>>>后台计算payableAmount:" + payableAmount.get() + " ,前端传入orderShouldPayFee:" + orderParamBo.getOrderShouldPayFee());
         // compare return[-1:v1<v2, 0:v1=v2, 1:v1>v2]
         int compare = MathUtil.compare(orderParamBo.getOrderShouldPayFee(), payableAmount.get());
@@ -1184,7 +1195,8 @@ public class SubmitServiceImpl implements SubmitService {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             return ResponseJson.error("订单付款金额不正确!", null);
         }
-
+        // 加冷链费
+        orderParamBo.setOrderShouldPayFee(MathUtil.add(orderParamBo.getOrderShouldPayFee(), isColdChina.get()).doubleValue());
         // 售后条款
         Integer clauseId = orderParamBo.getClauseId();
         String clauseName = null;
@@ -1445,7 +1457,7 @@ public class SubmitServiceImpl implements SubmitService {
          * 采美豆抵扣不生成
          */
         log.info("PostageFlag===="+mainOrder.getPostageFlag()+"====UserBeans=====***"+mainOrder.getUserBeans());
-        if (( 1 == mainOrder.getPostageFlag() && 0 == mainOrder.getUserBeans() ) || ( 0 == mainOrder.getPostageFlag() && 0 != organizeId )) {
+        if (( 1 == mainOrder.getPostageFlag() && 0 == mainOrder.getUserBeans() ) || ( 0 == mainOrder.getPostageFlag() && isColdChina.get() > 0.00d && 0 != organizeId ) || ( -1 == mainOrder.getPostageFlag() && isColdChina.get() > 0.00d && 0 != organizeId )) {
             // 获取 邮费商品    productId 999 skuId 1
             OrderProductPo postageProduct = submitMapper.getProductDetails(1);
             // 生成子订单编号
@@ -1466,9 +1478,12 @@ public class SubmitServiceImpl implements SubmitService {
             postageOrder.setUserId(mainOrder.getUserId());
             postageOrder.setOrderSubmitType(mainOrder.getOrderSubmitType());
             postageOrder.setItemCount(1);
-            postageOrder.setSplitCode(Constant.CUSTOMERNUM);
-            postageOrder.setRealPay(mainOrder.getPostage());
-            postageOrder.setEachDiscount(0d);
+            if (0 == organizeId) {
+                postageOrder.setSplitCode(Constant.CUSTOMERNUM);
+            } else {
+                // 联合丽格
+                postageOrder.setSplitCode("E1807782723");
+            }
             // 冷链运输费
             if (1 == orderParamBo.getIsColdChain()) {
                 postageOrder.setIsColdChina(1);
@@ -1476,6 +1491,9 @@ public class SubmitServiceImpl implements SubmitService {
             } else {
                 postageOrder.setIsColdChina(0);
             }
+            postageOrder.setRealPay(mainOrder.getPostage());
+            postageOrder.setEachDiscount(0d);
+
             //运费商品供应商Id默认998
             postageOrder.setShopId(postageProduct.getShopId());
             postageOrder.setProductAmount(mainOrder.getPostage());
@@ -1498,6 +1516,8 @@ public class SubmitServiceImpl implements SubmitService {
             }
             // 订单默认可拆分
             postageOrder.setSplitFlag(1);
+            // 设置组织Id
+            postageOrder.setOrganizeId(organizeId);
             /*
              * 保存运费子订单
              */
@@ -1509,6 +1529,10 @@ public class SubmitServiceImpl implements SubmitService {
             } else {
                 shopOrderIds.set(shopOrderIds.get() + "," + postageOrder.getShopOrderId());
             }
+            // 有冷链运输费 且大于 0 修改主订单运费状态
+            if (MathUtil.add(mainOrder.getPostage(), isColdChina.get()).doubleValue() > 0) {
+                submitMapper.updateOrder(mainOrder.getPostage().doubleValue(), mainOrder.getOrderId());
+            }
             /*
              * 设置运费商品
              */
@@ -1791,7 +1815,7 @@ public class SubmitServiceImpl implements SubmitService {
         }
         log.info("**********************微信模板消息推送*****************************");
         List<Integer> productIds = orderClubMapper.getProductOrder(mainOrder.getOrderId());
-        if (0 == mainOrder.getSecondHandOrderFlag() && 0 == mainOrder.getRebateFlag() && (null != productIds && !productIds.contains(6060)) && mainOrder.getOrderType() != 0) {
+        if (0 == organizeId && 0 == mainOrder.getSecondHandOrderFlag() && 0 == mainOrder.getRebateFlag() && (null != productIds && !productIds.contains(6060)) && mainOrder.getOrderType() != 0) {
             log.info("*******获取公众名" + orderClubMapper.getOrderIds(mainOrder.getOrderId()).toString());
             String name = "0";
             try {

+ 2 - 0
src/main/resources/mapper/OrderCommonMapper.xml

@@ -11,6 +11,8 @@
         cso.shopOrderID AS shopOrderId,
         cso.shopOrderNo,
         cso.orderID AS orderId,
+        cso.organizeID AS organizeId,
+        cso.isColdChina AS isColdChina,
         cso.orderNo,
         cso.shopID AS shopId,
         cso.note,

+ 5 - 0
src/main/resources/mapper/SubmitMapper.xml

@@ -43,6 +43,11 @@
                 #{shouldPayShopAmount}, #{orderTime}, #{orderSubmitType}, #{splitFlag}, #{payStatus},
                 #{payedShopAmount}, #{splitCode}, #{realPay}, #{eachDiscount}, 1)
     </insert>
+    <update id="updateOrder">
+        update cm_order
+        set freight = #{freight}
+        where orderId = #{orderId}
+    </update>
     <insert id="insertOrderProduct" keyColumn="orderProductID" keyProperty="orderProductId"
             parameterType="com.caimei365.order.model.po.OrderProductPo" useGeneratedKeys="true">
         INSERT INTO cm_order_product (orderID, orderNo, shopOrderID, shopOrderNo, organizeProductID,organizeID, orderPromotionsId, productId, shopId,