Browse Source

Merge remote-tracking branch 'origin/developerC' into developerC

# Conflicts:
#	src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java
#	src/main/resources/mapper/ShipMapper.xml
#	src/main/resources/mapper/SubmitMapper.xml
zhijiezhao 1 năm trước cách đây
mục cha
commit
a9b79b5d09
27 tập tin đã thay đổi với 644 bổ sung204 xóa
  1. 74 18
      src/main/java/com/caimei365/order/components/OrderCommonService.java
  2. 116 7
      src/main/java/com/caimei365/order/components/ProductService.java
  3. 4 4
      src/main/java/com/caimei365/order/controller/HeliPayApi.java
  4. 15 0
      src/main/java/com/caimei365/order/controller/OrderClubApi.java
  5. 28 8
      src/main/java/com/caimei365/order/controller/ShipApi.java
  6. 14 0
      src/main/java/com/caimei365/order/mapper/OrderClubMapper.java
  7. 15 5
      src/main/java/com/caimei365/order/mapper/ShipMapper.java
  8. 4 0
      src/main/java/com/caimei365/order/model/po/OrderReceiptRelationPo.java
  9. 4 0
      src/main/java/com/caimei365/order/model/po/OrderShopPo.java
  10. 33 0
      src/main/java/com/caimei365/order/model/po/ShopPo.java
  11. 13 0
      src/main/java/com/caimei365/order/model/vo/ShopOrderVo.java
  12. 8 0
      src/main/java/com/caimei365/order/service/OrderClubService.java
  13. 2 2
      src/main/java/com/caimei365/order/service/PayOrderService.java
  14. 32 3
      src/main/java/com/caimei365/order/service/ShipService.java
  15. 9 7
      src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java
  16. 7 0
      src/main/java/com/caimei365/order/service/impl/HeliPayServiceImpl.java
  17. 18 7
      src/main/java/com/caimei365/order/service/impl/OrderClubServiceImpl.java
  18. 29 22
      src/main/java/com/caimei365/order/service/impl/PayOrderServiceImpl.java
  19. 91 10
      src/main/java/com/caimei365/order/service/impl/ShipServiceImpl.java
  20. 13 19
      src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java
  21. 2 2
      src/main/resources/mapper/CartClubMapper.xml
  22. 23 6
      src/main/resources/mapper/OrderClubMapper.xml
  23. 11 9
      src/main/resources/mapper/OrderCommonMapper.xml
  24. 6 6
      src/main/resources/mapper/OrderSellerMapper.xml
  25. 6 3
      src/main/resources/mapper/ReceiptMapper.xml
  26. 57 8
      src/main/resources/mapper/ShipMapper.xml
  27. 10 58
      src/main/resources/mapper/SubmitMapper.xml

+ 74 - 18
src/main/java/com/caimei365/order/components/OrderCommonService.java

@@ -241,23 +241,23 @@ public class OrderCommonService {
     public void setShopOrderStatus(ShopOrderVo shopOrderVo) {
     public void setShopOrderStatus(ShopOrderVo shopOrderVo) {
         // 11, 待付待收待发
         // 11, 待付待收待发
         if (1 == shopOrderVo.getStatus() ) {
         if (1 == shopOrderVo.getStatus() ) {
-            if ( 1 == shopOrderVo.getSendOutStatus() && 1 == shopOrderVo.getReceiptStatus()){
+            if ( 1 == shopOrderVo.getReceiptStatus() && 1 == shopOrderVo.getSendOutStatus()){
                 shopOrderVo.setStatus(11);
                 shopOrderVo.setStatus(11);
-            } else if (1 == shopOrderVo.getSendOutStatus() && 2 == shopOrderVo.getReceiptStatus()) {
+            } else if ( 1 == shopOrderVo.getReceiptStatus() && 2 == shopOrderVo.getSendOutStatus()) {
                 shopOrderVo.setStatus(12);
                 shopOrderVo.setStatus(12);
-            } else if (1 == shopOrderVo.getSendOutStatus() && 3 == shopOrderVo.getReceiptStatus()) {
+            } else if ( 1 == shopOrderVo.getReceiptStatus() && 3 == shopOrderVo.getSendOutStatus()) {
                 shopOrderVo.setStatus(13);
                 shopOrderVo.setStatus(13);
-            } else if (2 == shopOrderVo.getSendOutStatus() && 1 == shopOrderVo.getReceiptStatus()) {
+            } else if ( 2 == shopOrderVo.getReceiptStatus() && 1 == shopOrderVo.getSendOutStatus()) {
                 shopOrderVo.setStatus(21);
                 shopOrderVo.setStatus(21);
-            } else if (2 == shopOrderVo.getSendOutStatus() && 2 == shopOrderVo.getReceiptStatus()) {
+            } else if ( 2 == shopOrderVo.getReceiptStatus() && 2 == shopOrderVo.getSendOutStatus()) {
                 shopOrderVo.setStatus(22);
                 shopOrderVo.setStatus(22);
-            } else if (2 == shopOrderVo.getSendOutStatus() && 3 == shopOrderVo.getReceiptStatus()) {
+            } else if ( 2 == shopOrderVo.getReceiptStatus() && 3 == shopOrderVo.getSendOutStatus()) {
                 shopOrderVo.setStatus(23);
                 shopOrderVo.setStatus(23);
-            } else if (3 == shopOrderVo.getSendOutStatus() && 1 == shopOrderVo.getReceiptStatus()) {
+            } else if ( 3 == shopOrderVo.getReceiptStatus() && 1 == shopOrderVo.getSendOutStatus()) {
                 shopOrderVo.setStatus(31);
                 shopOrderVo.setStatus(31);
-            } else if (3 == shopOrderVo.getSendOutStatus() && 2 == shopOrderVo.getReceiptStatus()) {
+            } else if ( 3 == shopOrderVo.getReceiptStatus() && 2 == shopOrderVo.getSendOutStatus()) {
                 shopOrderVo.setStatus(32);
                 shopOrderVo.setStatus(32);
-            } else if (3 == shopOrderVo.getSendOutStatus() && 3 == shopOrderVo.getReceiptStatus()) {
+            } else if ( 3 == shopOrderVo.getReceiptStatus() && 3 == shopOrderVo.getSendOutStatus()) {
                 shopOrderVo.setStatus(33);
                 shopOrderVo.setStatus(33);
             }
             }
         }
         }
@@ -382,6 +382,13 @@ public class OrderCommonService {
      * @return
      * @return
      */
      */
     public List<DiscernReceiptVo> getDiscernReceiptAndSetShoporder(ShopOrderVo shopOrderVo) {
     public List<DiscernReceiptVo> getDiscernReceiptAndSetShoporder(ShopOrderVo shopOrderVo) {
+        // 判断是否可以走线上支付
+        Integer orderVoucher = orderCommonMapper.getOrderVoucher(shopOrderVo.getShopOrderId());
+        if (null != orderVoucher && orderVoucher > 0) {
+            shopOrderVo.setOnlinePay(2);
+        } else {
+            shopOrderVo.setOnlinePay(1);
+        }
         // 支付记录
         // 支付记录
         List<DiscernReceiptVo> discernReceiptList = orderCommonMapper.getDiscernReceipt(shopOrderVo.getOrderId(), shopOrderVo.getShopOrderId().toString());
         List<DiscernReceiptVo> discernReceiptList = orderCommonMapper.getDiscernReceipt(shopOrderVo.getOrderId(), shopOrderVo.getShopOrderId().toString());
         Double receiptAmount = 0d;
         Double receiptAmount = 0d;
@@ -393,31 +400,80 @@ public class OrderCommonService {
                 if (null != discernReceipt.getPayType()) {
                 if (null != discernReceipt.getPayType()) {
                     discernReceipt.setPayTypeStr(ReceivablesType.getReceivablesType(discernReceipt.getPayType()));
                     discernReceipt.setPayTypeStr(ReceivablesType.getReceivablesType(discernReceipt.getPayType()));
                 }
                 }
+                if (2 == discernReceipt.getPayWay()) {
+                    shopOrderVo.setOnlinePay(2);
+                }
             });
             });
             receiptAmount = finalReceiptAmount.get();
             receiptAmount = finalReceiptAmount.get();
         } else {
         } else {
             //返佣款
             //返佣款
             Double tempAmount = orderCommonMapper.getRebateAmountByShopOrder(shopOrderVo.getShopOrderId());
             Double tempAmount = orderCommonMapper.getRebateAmountByShopOrder(shopOrderVo.getShopOrderId());
             if (null != tempAmount) {
             if (null != tempAmount) {
-                shopOrderVo.setOnlinePay(1);
+                shopOrderVo.setOnlinePay(2);
             }
             }
         }
         }
-        // 判断是否可以走线上支付
-        Integer orderVoucher = orderCommonMapper.getOrderVoucher(shopOrderVo.getShopOrderId());
-        if (null != orderVoucher && orderVoucher > 0) {
-            shopOrderVo.setOnlinePay(1);
-        } else {
-            shopOrderVo.setOnlinePay(2);
-        }
         //待付总金额
         //待付总金额
         if (null == shopOrderVo.getRealPay()) {
         if (null == shopOrderVo.getRealPay()) {
             shopOrderVo.setRealPay(shopOrderVo.getNeedPayAmount());
             shopOrderVo.setRealPay(shopOrderVo.getNeedPayAmount());
         }
         }
         shopOrderVo.setObligation(MathUtil.sub(shopOrderVo.getRealPay(), receiptAmount).doubleValue());
         shopOrderVo.setObligation(MathUtil.sub(shopOrderVo.getRealPay(), receiptAmount).doubleValue());
         //支付总金额
         //支付总金额
-        shopOrderVo.setReceiptAmount(receiptAmount);
+        if(!discernReceiptList.isEmpty()) {
+            shopOrderVo.setReceiptAmount(receiptAmount);
+        }
         return discernReceiptList;
         return discernReceiptList;
     }
     }
+
+    public void setPostageInfo(ShopOrderVo shopOrder) {
+        // 冷链商品类型
+        List<Integer> arrList = new ArrayList<>();
+        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 == 7536)) {
+            arrList.add(1);
+        } else if (!collect.contains(7536)) {
+            arrList.add(2);
+        } else {
+            arrList.add(3);
+        }
+        // 冷链运输费 -- 联合丽格
+        if (null != shopOrder.getIsColdChina() && 1 == shopOrder.getIsColdChina()) {
+            shopOrder.setColdChina(700.00d);
+        } else {
+            shopOrder.setColdChina(0.00d);
+        }
+        // 拼接运费信息--联合丽格
+        if (null != shopOrder.getColdChina()) {
+            String open = "";
+            String close = "";
+            if (shopOrder.getIsColdChina()==1) {
+                open = "(";
+                close = ")";
+            } else if (!arrList.stream().allMatch(c -> c == 1)) {
+                open = "(";
+                close = ")";
+            } else {
+                open = "";
+                close = "";
+            }
+            if (-1 == shopOrder.getShopPostFlag()) {
+                // 到付
+                shopOrder.setPostageInfo("¥" + MathUtil.add(shopOrder.getShopPostFee(), shopOrder.getColdChina()).doubleValue() + open +(shopOrder.getIsColdChina()==1?"冷链费: ¥" + shopOrder.getColdChina().doubleValue():"") + (arrList.stream().allMatch(c -> c == 1)?"":" 其他: 到付")+close);
+            } else if (0 == shopOrder.getShopPostFlag()) {
+                // 包邮
+                shopOrder.setPostageInfo("¥" + MathUtil.add(shopOrder.getShopPostFee(), shopOrder.getColdChina()).doubleValue() + open +(shopOrder.getIsColdChina()==1?"冷链费: ¥" + shopOrder.getColdChina().doubleValue():"") + (arrList.stream().allMatch(c -> c == 1)?"":" 其他: 包邮")+close);
+            } else {
+                // 有运费
+                shopOrder.setPostageInfo("¥" + MathUtil.add(shopOrder.getShopPostFee(), shopOrder.getColdChina()).doubleValue() + open +(shopOrder.getIsColdChina()==1?"冷链费: ¥" + shopOrder.getColdChina().doubleValue():"") + (!arrList.stream().allMatch(c -> c == 1)?" 其他: ¥" + shopOrder.getShopPostFee():"") + close);
+            }
+        } else {
+            shopOrder.setPostageInfo(shopOrder.getShopPostFlag() == -1?"到付":shopOrder.getShopPostFlag() == 0?"包邮":"¥" + shopOrder.getShopPostFee().doubleValue());
+        }
+    }
+
     /**
     /**
      * 设置搜索关键词历史记录
      * 设置搜索关键词历史记录
      *
      *

+ 116 - 7
src/main/java/com/caimei365/order/components/ProductService.java

@@ -1,6 +1,7 @@
 package com.caimei365.order.components;
 package com.caimei365.order.components;
 
 
 import com.caimei365.order.mapper.BaseMapper;
 import com.caimei365.order.mapper.BaseMapper;
+import com.caimei365.order.mapper.PayOrderMapper;
 import com.caimei365.order.model.dto.VipSkuPriceDto;
 import com.caimei365.order.model.dto.VipSkuPriceDto;
 import com.caimei365.order.model.po.*;
 import com.caimei365.order.model.po.*;
 import com.caimei365.order.model.vo.*;
 import com.caimei365.order.model.vo.*;
@@ -8,6 +9,7 @@ import com.caimei365.order.utils.MathUtil;
 import com.caimei365.order.utils.ImageUtil;
 import com.caimei365.order.utils.ImageUtil;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.ArrayUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.CollectionUtils;
@@ -16,6 +18,7 @@ import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 import java.util.stream.IntStream;
 
 
@@ -32,6 +35,8 @@ public class ProductService {
     private String domain;
     private String domain;
     @Resource
     @Resource
     private BaseMapper baseMapper;
     private BaseMapper baseMapper;
+    @Resource
+    private PayOrderMapper payOrderMapper;
 
 
     /**
     /**
      * 设置商品图片及税费
      * 设置商品图片及税费
@@ -357,19 +362,102 @@ public class ProductService {
      * 保存余额抵扣到收款记录
      * 保存余额抵扣到收款记录
      *
      *
      * @param balancePayFee 余额抵扣
      * @param balancePayFee 余额抵扣
-     * @param orderId       主订单Id
+     * @param shopOrderList 主订单Id
      * @param note          日志备注
      * @param note          日志备注
      */
      */
-    public void saveDiscernReceipt(Double balancePayFee, Integer orderId, String note) {
+    public void saveDiscernReceipt(Double balancePayFee, List<OrderShopPo> shopOrderList, String note) {
         Date date = new Date();
         Date date = new Date();
         String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
         String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
+        ShopOrderVo shopOrderVo = new ShopOrderVo();
+        AtomicReference<Double> ba = new AtomicReference<>(balancePayFee);
+        shopOrderList.forEach(shopOrder -> {
+            double shopOrderPay = 0d;
+            if (MathUtil.compare(balancePayFee, shopOrder.getNeedPayAmount()) >= 0) {
+                shopOrder.setReceiptStatus(3);
+                shopOrderPay = shopOrder.getNeedPayAmount();
+            } else {
+                shopOrder.setReceiptStatus(2);
+                shopOrderPay = ba.get();
+            }
+            ba.updateAndGet(v -> ba.get() - shopOrder.getNeedPayAmount());
+            // 识别款项表
+            DiscernReceiptPo discernReceipt = new DiscernReceiptPo();
+            discernReceipt.setPayWay(3);
+            discernReceipt.setPayType(16);
+            discernReceipt.setReceiptType(1);
+            discernReceipt.setReceiptStatus(3);
+            discernReceipt.setReceiptAmount(shopOrderPay);
+            discernReceipt.setConfirmType(4);
+            discernReceipt.setReceiptDate(curDateStr);
+            discernReceipt.setConfirmDate(curDateStr);
+            discernReceipt.setReviewDate(curDateStr);
+            discernReceipt.setUpdateDate(curDateStr);
+            discernReceipt.setDelFlag(0);
+            // 保存 收款记录
+            baseMapper.insertDiscernReceipt(discernReceipt);
+            log.info(note + ">>>>>>>>>>>保存识别款项(insert[cm_discern_receipt])id:" + discernReceipt.getId() + ",shopOrderId:" + shopOrder.getShopOrderId());
+            // 收款项和订单关系表
+            OrderReceiptRelationPo relation = new OrderReceiptRelationPo();
+            relation.setReceiptId(discernReceipt.getId());
+            relation.setOrderId(shopOrder.getOrderId());
+            relation.setShopOrderId(shopOrder.getShopOrderId());
+            relation.setAssociateAmount(shopOrderPay);
+            relation.setRelationType(2);
+            relation.setDelFlag(0);
+            // 保存 收款项和订单关系
+            baseMapper.insertOrderReceiptRelation(relation);
+            //保存余额到余额收支记录
+            BalanceRecordPo balanceRecord = new BalanceRecordPo();
+            balanceRecord.setUserId(shopOrder.getUserId());
+            balanceRecord.setType(2);
+            balanceRecord.setBalanceType(1);
+            balanceRecord.setAddDate(new Date());
+            balanceRecord.setAmount(shopOrderPay);
+            balanceRecord.setOrderId(shopOrder.getOrderId());
+            balanceRecord.setShopOrderId(shopOrder.getShopOrderId());
+            balanceRecord.setRemark("机构自主订单");
+            balanceRecord.setDelFlag(0);
+            // 保存 余额收支记录
+            baseMapper.insertBalanceRecord(balanceRecord);
+            log.info("【提交订单】>>>>>>>>>>>>>>>>>>>>>>>>>>新增用户余额收支记录(insert[cm_user_balance_record])shopOrderId:" + shopOrder.getShopOrderId());
+            log.info(note + ">>>>>>>>>>>收款项和订单关系(insert[cm_receipt_order_relation])id:" + relation.getId() + ",shopOrderId:" + shopOrder.getShopOrderId());
+            // 修改子订单状态
+            shopOrderVo.setShopOrderId(shopOrder.getShopOrderId());
+            shopOrderVo.setReceiptStatus(shopOrder.getReceiptStatus());
+            shopOrderVo.setAccountAmount(shopOrderPay);
+            shopOrderVo.setReceiptAmount(shopOrderPay);
+            payOrderMapper.updateShopOrderBalancePay(shopOrderVo);
+
+        });
+
+    }
+
+    /**
+     *
+     * @param balancePayFee
+     * @param shopOrder
+     * @param note
+     */
+    public void saveShopOrderDiscernReceipt(Double balancePayFee, ShopOrderVo shopOrder, String note) {
+        Date date = new Date();
+        String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
+        AtomicReference<Double> ba = new AtomicReference<>(balancePayFee);
+        double shopOrderPay = 0d;
+        if (MathUtil.compare(balancePayFee, shopOrder.getNeedPayAmount()) >= 0) {
+            shopOrder.setReceiptStatus(3);
+            shopOrderPay = shopOrder.getNeedPayAmount();
+        } else {
+            shopOrder.setReceiptStatus(2);
+            shopOrderPay = ba.get();
+        }
+        ba.updateAndGet(v -> ba.get() - shopOrder.getNeedPayAmount());
         // 识别款项表
         // 识别款项表
         DiscernReceiptPo discernReceipt = new DiscernReceiptPo();
         DiscernReceiptPo discernReceipt = new DiscernReceiptPo();
         discernReceipt.setPayWay(3);
         discernReceipt.setPayWay(3);
         discernReceipt.setPayType(16);
         discernReceipt.setPayType(16);
         discernReceipt.setReceiptType(1);
         discernReceipt.setReceiptType(1);
         discernReceipt.setReceiptStatus(3);
         discernReceipt.setReceiptStatus(3);
-        discernReceipt.setReceiptAmount(balancePayFee);
+        discernReceipt.setReceiptAmount(shopOrderPay);
         discernReceipt.setConfirmType(4);
         discernReceipt.setConfirmType(4);
         discernReceipt.setReceiptDate(curDateStr);
         discernReceipt.setReceiptDate(curDateStr);
         discernReceipt.setConfirmDate(curDateStr);
         discernReceipt.setConfirmDate(curDateStr);
@@ -378,17 +466,38 @@ public class ProductService {
         discernReceipt.setDelFlag(0);
         discernReceipt.setDelFlag(0);
         // 保存 收款记录
         // 保存 收款记录
         baseMapper.insertDiscernReceipt(discernReceipt);
         baseMapper.insertDiscernReceipt(discernReceipt);
-        log.info(note + ">>>>>>>>>>>保存识别款项(insert[cm_discern_receipt])id:" + discernReceipt.getId() + ",orderId:" + orderId);
+        log.info(note + ">>>>>>>>>>>保存识别款项(insert[cm_discern_receipt])id:" + discernReceipt.getId() + ",shopOrderId:" + shopOrder.getShopOrderId());
         // 收款项和订单关系表
         // 收款项和订单关系表
         OrderReceiptRelationPo relation = new OrderReceiptRelationPo();
         OrderReceiptRelationPo relation = new OrderReceiptRelationPo();
         relation.setReceiptId(discernReceipt.getId());
         relation.setReceiptId(discernReceipt.getId());
-        relation.setOrderId(orderId);
-        relation.setAssociateAmount(balancePayFee);
+        relation.setOrderId(shopOrder.getOrderId());
+        relation.setShopOrderId(shopOrder.getShopOrderId());
+        relation.setAssociateAmount(shopOrderPay);
         relation.setRelationType(2);
         relation.setRelationType(2);
         relation.setDelFlag(0);
         relation.setDelFlag(0);
         // 保存 收款项和订单关系
         // 保存 收款项和订单关系
         baseMapper.insertOrderReceiptRelation(relation);
         baseMapper.insertOrderReceiptRelation(relation);
-        log.info(note + ">>>>>>>>>>>收款项和订单关系(insert[cm_receipt_order_relation])id:" + relation.getId() + ",orderId:" + orderId);
+        //保存余额到余额收支记录
+        BalanceRecordPo balanceRecord = new BalanceRecordPo();
+        balanceRecord.setUserId(shopOrder.getUserId());
+        balanceRecord.setType(2);
+        balanceRecord.setBalanceType(1);
+        balanceRecord.setAddDate(new Date());
+        balanceRecord.setAmount(shopOrderPay);
+        balanceRecord.setOrderId(shopOrder.getOrderId());
+        balanceRecord.setShopOrderId(shopOrder.getShopOrderId());
+        balanceRecord.setRemark("机构自主订单");
+        balanceRecord.setDelFlag(0);
+        // 保存 余额收支记录
+        baseMapper.insertBalanceRecord(balanceRecord);
+        log.info("【提交订单】>>>>>>>>>>>>>>>>>>>>>>>>>>新增用户余额收支记录(insert[cm_user_balance_record])shopOrderId:" + shopOrder.getShopOrderId());
+        log.info(note + ">>>>>>>>>>>收款项和订单关系(insert[cm_receipt_order_relation])id:" + relation.getId() + ",shopOrderId:" + shopOrder.getShopOrderId());
+
+        // 修改子订单状态
+        shopOrder.setAccountAmount(shopOrderPay);
+        shopOrder.setReceiptAmount(shopOrderPay);
+        payOrderMapper.updateShopOrderBalancePay(shopOrder);
+
     }
     }
 
 
     /**
     /**

+ 4 - 4
src/main/java/com/caimei365/order/controller/HeliPayApi.java

@@ -184,13 +184,13 @@ public class HeliPayApi {
      * 收银台数据显示
      * 收银台数据显示
      */
      */
     @ApiOperation("收银台数据(旧:/PayOrder/checkoutCounter)")
     @ApiOperation("收银台数据(旧:/PayOrder/checkoutCounter)")
-    @ApiImplicitParam(required = true, name = "orderId", value = "订单Id")
+    @ApiImplicitParam(required = true, name = "shopOrderId", value = "订单Id")
     @GetMapping("/checkout/counter")
     @GetMapping("/checkout/counter")
-    public ResponseJson<Map<String, Object>> getCheckoutCounter(Integer orderId) {
-        if (null == orderId) {
+    public ResponseJson<Map<String, Object>> getCheckoutCounter(Integer shopOrderId) {
+        if (null == shopOrderId) {
             return ResponseJson.error("订单Id不能为空!", null);
             return ResponseJson.error("订单Id不能为空!", null);
         }
         }
-        return payOrderService.getCheckoutCounter(orderId);
+        return payOrderService.getCheckoutCounter(shopOrderId);
     }
     }
 
 
     /**
     /**

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

@@ -3,6 +3,7 @@ package com.caimei365.order.controller;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.OrderDto;
 import com.caimei365.order.model.dto.OrderDto;
 import com.caimei365.order.model.dto.VoucherDto;
 import com.caimei365.order.model.dto.VoucherDto;
+import com.caimei365.order.model.po.ShopPo;
 import com.caimei365.order.model.vo.*;
 import com.caimei365.order.model.vo.*;
 import com.caimei365.order.service.OrderClubService;
 import com.caimei365.order.service.OrderClubService;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
@@ -350,4 +351,18 @@ public class OrderClubApi {
         }
         }
         return orderClubService.getClauseById(clauseId);
         return orderClubService.getClauseById(clauseId);
     }
     }
+
+    /**
+     * 查询供应商银行账户信息
+     * @param shopId
+     * @return
+     */
+    @ApiOperation("查询供应商银行账户信息")
+    @GetMapping("/getShopBank")
+    public ResponseJson<ShopPo> getShopBankAccount(Integer shopId) {
+        if (null == shopId) {
+            return ResponseJson.error(-1, "供应商Id不能为空",null);
+        }
+        return orderClubService.getShopBankAccount(shopId);
+    }
 }
 }

+ 28 - 8
src/main/java/com/caimei365/order/controller/ShipApi.java

@@ -1,10 +1,12 @@
 package com.caimei365.order.controller;
 package com.caimei365.order.controller;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.JsonParamsDto;
 import com.caimei365.order.model.dto.JsonParamsDto;
 import com.caimei365.order.model.dto.LogisticsBatchDto;
 import com.caimei365.order.model.dto.LogisticsBatchDto;
 import com.caimei365.order.model.dto.LogisticsDto;
 import com.caimei365.order.model.dto.LogisticsDto;
 import com.caimei365.order.model.dto.OrderRemarkDto;
 import com.caimei365.order.model.dto.OrderRemarkDto;
+import com.caimei365.order.model.po.ShopPo;
 import com.caimei365.order.model.vo.*;
 import com.caimei365.order.model.vo.*;
 import com.caimei365.order.service.ShipService;
 import com.caimei365.order.service.ShipService;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
@@ -45,17 +47,18 @@ public class ShipApi {
             @ApiImplicitParam(required = false, name = "payStatus", value = "结算状态"),
             @ApiImplicitParam(required = false, name = "payStatus", value = "结算状态"),
             @ApiImplicitParam(required = false, name = "shopOrderNo", value = "订单编号"),
             @ApiImplicitParam(required = false, name = "shopOrderNo", value = "订单编号"),
             @ApiImplicitParam(required = false, name = "receiver", value = "买家名称(收货人)"),
             @ApiImplicitParam(required = false, name = "receiver", value = "买家名称(收货人)"),
+            @ApiImplicitParam(required = false, name = "organizeId", value = "订单来源"),
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
             @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
             @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
             @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
     })
     })
     @GetMapping("/list")
     @GetMapping("/list")
-    public ResponseJson<PageInfo<ShopOrderVo>> getShopOrderList(Integer shopId, Integer sendOutStatus, Integer payStatus, String shopOrderNo, String receiver,
+    public ResponseJson<PageInfo<ShopOrderVo>> getShopOrderList(Integer shopId, Integer sendOutStatus, Integer payStatus, String shopOrderNo, String receiver, Integer organizeId,
                                                         @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                         @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                         @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
                                                         @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
         if (null == shopId) {
         if (null == shopId) {
             return ResponseJson.error("供应商Id不能为空!", null);
             return ResponseJson.error("供应商Id不能为空!", null);
         }
         }
-        return shipService.getShopOrderList(shopId, sendOutStatus, payStatus, shopOrderNo, receiver, pageNum, pageSize);
+        return shipService.getShopOrderList(shopId, sendOutStatus, payStatus, shopOrderNo, receiver, organizeId, pageNum, pageSize);
     }
     }
 
 
     /**
     /**
@@ -357,15 +360,29 @@ public class ShipApi {
         return shipService.saveProductQualification(jsonParamsDto);
         return shipService.saveProductQualification(jsonParamsDto);
     }
     }
 
 
+    /**
+     * 更改收款状态
+     * @param amount
+     * @param shopOrderId
+     * @return
+     */
+    @GetMapping("/check/receipt")
+    public ResponseJson checkReceipt(Double amount, Integer shopOrderId) {
+        if (null == amount || null == shopOrderId) {
+            return ResponseJson.error("参数不能为空!");
+        }
+        return shipService.checkReceipt(amount, shopOrderId);
+    }
+
     /**
     /**
      * 订单备注详情
      * 订单备注详情
-     * @param orderId
+     * @param shopOrderId
      * @return
      * @return
      */
      */
     @ApiOperation("订单备注详情")
     @ApiOperation("订单备注详情")
-    @GetMapping(value = "/remarksView/{orderId}")
-    public ResponseJson<List<OrderRemarkDto>> remarksView(@PathVariable("orderId") Integer orderId) {
-        List<OrderRemarkDto> remarksList = shipService.findList(orderId);
+    @GetMapping(value = "/remarksView")
+    public ResponseJson<List<OrderRemarkDto>> remarksView( Integer shopOrderId) {
+        List<OrderRemarkDto> remarksList = shipService.findList(shopOrderId);
         return ResponseJson.success(remarksList);
         return ResponseJson.success(remarksList);
     }
     }
 
 
@@ -402,7 +419,10 @@ public class ShipApi {
      */
      */
     @ApiOperation("下载备注文件")
     @ApiOperation("下载备注文件")
     @GetMapping("/download/remark")
     @GetMapping("/download/remark")
-    public void downFile(Integer fileId, HttpServletRequest request, HttpServletResponse response) throws IOException {
-        shipService.downFile(fileId, request, response);
+    public ResponseJson<Map<String, Object>> downFile(Integer fileId, HttpServletRequest request, HttpServletResponse response) throws IOException {
+        if (null == fileId) {
+            return ResponseJson.error(-1,"id不能为空", null);
+        }
+        return shipService.downFile(fileId, request, response);
     }
     }
 }
 }

+ 14 - 0
src/main/java/com/caimei365/order/mapper/OrderClubMapper.java

@@ -441,6 +441,13 @@ public interface OrderClubMapper {
 
 
     List<Sku> getOrganizeSku(@Param("productId") Integer productId);
     List<Sku> getOrganizeSku(@Param("productId") Integer productId);
 
 
+    /**
+     * 发票信息
+     * @param orderId
+     * @return
+     */
+    InvoicePo getOrderInvoice(@Param("orderId") Integer orderId);
+
     List<VoucherPo> getVoucher(@Param("shopOrderId") Integer shopOrderId);
     List<VoucherPo> getVoucher(@Param("shopOrderId") Integer shopOrderId);
 
 
     List<VoucherImageDto> getVoucherImage(@Param("voucherIds") List<Integer> voucherIds);
     List<VoucherImageDto> getVoucherImage(@Param("voucherIds") List<Integer> voucherIds);
@@ -452,4 +459,11 @@ public interface OrderClubMapper {
     void updateVoucherImage(VoucherImageDto voucherImageDto);
     void updateVoucherImage(VoucherImageDto voucherImageDto);
 
 
     void insertVoucherImage(VoucherImageDto voucherImageDto);
     void insertVoucherImage(VoucherImageDto voucherImageDto);
+
+    /**
+     * 查询供应商银行卡信息
+     * @param shopId
+     * @return
+     */
+    ShopPo getShopBankAccount(@Param("shopId") Integer shopId);
 }
 }

+ 15 - 5
src/main/java/com/caimei365/order/mapper/ShipMapper.java

@@ -21,7 +21,7 @@ public interface ShipMapper {
     /**
     /**
      * 机构订单列表
      * 机构订单列表
      */
      */
-    List<ShopOrderVo> getShopOrderList(Integer shopId, Integer sendOutStatus, Integer payStatus, String shopOrderNo, String receiver);
+    List<ShopOrderVo> getShopOrderList(Integer shopId, Integer sendOutStatus, Integer payStatus, String shopOrderNo, String receiver, Integer organizeId);
     /**
     /**
      * 供应商结算列表
      * 供应商结算列表
      */
      */
@@ -56,9 +56,10 @@ public interface ShipMapper {
 
 
     /**
     /**
      * (收款买家)收款状态:1待收款、2部分收款、3已收款
      * (收款买家)收款状态:1待收款、2部分收款、3已收款
-     * @param orderId 订单Id
+     * @param shopOrderId 子订单Id
+     * @return
      */
      */
-    Integer getOrderReceiptStatus(Integer orderId);
+    Integer getShopOrderReceiptStatus(Integer shopOrderId);
     /**
     /**
      * 物流公司
      * 物流公司
      * @param value 快递公司代码
      * @param value 快递公司代码
@@ -227,12 +228,21 @@ public interface ShipMapper {
 
 
     Integer getUserIdByShopId(Integer shopId);
     Integer getUserIdByShopId(Integer shopId);
 
 
+    Double findWaitPay(Integer shopOrderId);
+
+    void insertOrderReceipt(ReceiptVo receiptVo);
+
+    void insertOrderRelation(OrderReceiptRelationPo record);
+
+    String findOrderStatus(Integer orderId);
+
+    void updateReceiptStatus(Integer status, Integer shopOrderId);
     /**
     /**
      * 订单备注
      * 订单备注
-     * @param orderId
+     * @param shopOrderId
      * @return
      * @return
      */
      */
-    List<OrderRemarkDto> findList(Integer orderId);
+    List<OrderRemarkDto> findList(Integer shopOrderId);
 
 
     /**
     /**
      * 插入订单备注
      * 插入订单备注

+ 4 - 0
src/main/java/com/caimei365/order/model/po/OrderReceiptRelationPo.java

@@ -53,6 +53,10 @@ public class OrderReceiptRelationPo implements Serializable {
      *  认证通会员购买记录Id
      *  认证通会员购买记录Id
      */
      */
     private Integer authVipRecordId;
     private Integer authVipRecordId;
+    /**
+     * 收款金额
+     */
+    private Double receiptAmount;
     /**
     /**
      * 删除标记 0 否,其余是
      * 删除标记 0 否,其余是
      */
      */

+ 4 - 0
src/main/java/com/caimei365/order/model/po/OrderShopPo.java

@@ -161,6 +161,10 @@ public class OrderShopPo implements Serializable {
      * 订单状态 1:待确认 2:已确认 3:交易完成 4:订单完成 5:已关闭 6:交易全退
      * 订单状态 1:待确认 2:已确认 3:交易完成 4:订单完成 5:已关闭 6:交易全退
      */
      */
     private Integer shopStatus;
     private Integer shopStatus;
+    /**
+     *
+     */
+    private Integer receiptStatus;
     /**
     /**
      * 已付款金额
      * 已付款金额
      */
      */

+ 33 - 0
src/main/java/com/caimei365/order/model/po/ShopPo.java

@@ -0,0 +1,33 @@
+package com.caimei365.order.model.po;
+
+import lombok.Data;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/6/18
+ */
+@Data
+public class ShopPo {
+    /**
+     * 供应商Id
+     */
+    private Integer shopId;
+    /**
+     * 供应商名称
+     */
+    private String name;
+    /**
+     * 银行账号
+     */
+    private String bankAccount;
+    /**
+     * 付款账号的户名
+     */
+    private String bankAccountName;
+    /**
+     * 付款账号的开户行
+     */
+    private String bankName;
+}

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

@@ -1,5 +1,6 @@
 package com.caimei365.order.model.vo;
 package com.caimei365.order.model.vo;
 
 
+import com.caimei365.order.model.po.InvoicePo;
 import com.caimei365.order.model.po.VoucherPo;
 import com.caimei365.order.model.po.VoucherPo;
 import lombok.Data;
 import lombok.Data;
 
 
@@ -277,6 +278,10 @@ public class ShopOrderVo implements Serializable {
      * (收款买家)收款状态:1待收款、2部分收款、3已收款
      * (收款买家)收款状态:1待收款、2部分收款、3已收款
      */
      */
     private Integer receiptStatus;
     private Integer receiptStatus;
+    /**
+     * 退款状态:1无退款、3有退款
+     */
+    private Integer refundStatus;
     /**
     /**
      * 供应商已退金额
      * 供应商已退金额
      */
      */
@@ -329,6 +334,10 @@ public class ShopOrderVo implements Serializable {
      * 是否使用余额 0否 1是
      * 是否使用余额 0否 1是
      */
      */
    private Integer useBalanceFlag;
    private Integer useBalanceFlag;
+    /**
+     * 发票信息
+     */
+   private InvoicePo invoice;
     /**
     /**
      * 支付凭证
      * 支付凭证
      */
      */
@@ -349,6 +358,10 @@ public class ShopOrderVo implements Serializable {
      * 是否开发票 没开发票 0 开个人发票 1 开企业发票2
      * 是否开发票 没开发票 0 开个人发票 1 开企业发票2
      */
      */
     private Integer invoiceFlag;
     private Integer invoiceFlag;
+    /**
+     * 是否有商品发票属性的限制,为true时只能线下支付
+     */
+    private boolean invoiceStatus = false;
     /**
     /**
      * 退款总金额
      * 退款总金额
      */
      */

+ 8 - 0
src/main/java/com/caimei365/order/service/OrderClubService.java

@@ -2,6 +2,7 @@ package com.caimei365.order.service;
 
 
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.VoucherDto;
 import com.caimei365.order.model.dto.VoucherDto;
+import com.caimei365.order.model.po.ShopPo;
 import com.caimei365.order.model.vo.*;
 import com.caimei365.order.model.vo.*;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpHeaders;
@@ -140,4 +141,11 @@ public interface OrderClubService {
      */
      */
     ResponseJson<ClauseVo> getClauseById(Integer clauseId);
     ResponseJson<ClauseVo> getClauseById(Integer clauseId);
 
 
+    /**
+     * 查询供应商银行卡信息
+     * @param shopId
+     * @return
+     */
+    ResponseJson<ShopPo> getShopBankAccount(Integer shopId);
+
 }
 }

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

@@ -37,9 +37,9 @@ public interface PayOrderService {
     ResponseJson<Integer> getPayOnLineSwitch();
     ResponseJson<Integer> getPayOnLineSwitch();
     /**
     /**
      * 收银台数据显示
      * 收银台数据显示
-     * @param orderId 订单Id
+     * @param shopOrderId 订单Id
      */
      */
-    ResponseJson<Map<String, Object>> getCheckoutCounter(Integer orderId);
+    ResponseJson<Map<String, Object>> getCheckoutCounter(Integer shopOrderId);
     /**
     /**
      *  生成网银支付链接
      *  生成网银支付链接
      * @param payLinkDto {
      * @param payLinkDto {

+ 32 - 3
src/main/java/com/caimei365/order/service/ShipService.java

@@ -33,7 +33,7 @@ public interface ShipService {
      * @param pageNum        页码
      * @param pageNum        页码
      * @param pageSize       每页数量
      * @param pageSize       每页数量
      */
      */
-    ResponseJson<PageInfo<ShopOrderVo>> getShopOrderList(Integer shopId, Integer sendOutStatus, Integer payStatus, String shopOrderNo, String receiver, int pageNum, int pageSize);
+    ResponseJson<PageInfo<ShopOrderVo>> getShopOrderList(Integer shopId, Integer sendOutStatus, Integer payStatus, String shopOrderNo, String receiver, Integer organizeId, int pageNum, int pageSize);
     /**
     /**
      * 供应商结算列表
      * 供应商结算列表
      * @param shopId         供应商Id
      * @param shopId         供应商Id
@@ -161,11 +161,40 @@ public interface ShipService {
      */
      */
     ResponseJson<Void> saveProductQualification(JsonParamsDto jsonParamsDto);
     ResponseJson<Void> saveProductQualification(JsonParamsDto jsonParamsDto);
 
 
-    List<OrderRemarkDto> findList(Integer orderId);
+    /**
+     * 更改收款状态
+     * @param amount
+     * @param shopOrderId
+     * @return
+     */
+    ResponseJson checkReceipt(Double amount, Integer shopOrderId);
+    /**
+     * 订单备注列表
+     * @param shopOrderId
+     * @return
+     */
+    List<OrderRemarkDto> findList(Integer shopOrderId);
 
 
+    /**
+     * 插入订单备注
+     * @param remark
+     */
     void insertRemark(OrderRemarkDto remark);
     void insertRemark(OrderRemarkDto remark);
 
 
+    /**
+     * 上传备注文件
+     * @param file
+     * @param orderId
+     * @return
+     */
     ResponseJson<Map<String, Object>> upload(MultipartFile file, Integer orderId);
     ResponseJson<Map<String, Object>> upload(MultipartFile file, Integer orderId);
 
 
-    void downFile(Integer fileId, HttpServletRequest request, HttpServletResponse response) throws IOException;
+    /**
+     * 下载
+     * @param fileId
+     * @param request
+     * @param response
+     * @throws IOException
+     */
+    ResponseJson<Map<String, Object>> downFile(Integer fileId, HttpServletRequest request, HttpServletResponse response) throws IOException;
 }
 }

+ 9 - 7
src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java

@@ -319,7 +319,7 @@ public class CartClubServiceImpl implements CartClubService {
                             productIterator.remove();
                             productIterator.remove();
                         }
                         }
                     } else {
                     } else {
-                        if (cartItemVo.getValidFlag() == 1) {
+                        if (cartItemVo.getValidFlag() == 2) {
                             // 设置商品有效
                             // 设置商品有效
                             cartItemVo.setStatus(0);
                             cartItemVo.setStatus(0);
                             // 该供应商下价格累加
                             // 该供应商下价格累加
@@ -1053,7 +1053,6 @@ public class CartClubServiceImpl implements CartClubService {
                                     shop.setPostageFlag(1);
                                     shop.setPostageFlag(1);
                                 }
                                 }
                             }
                             }
-                            shopPrice.set(MathUtil.add(shopPrice.get(), coldChain).doubleValue());
                             // 设置商品图片及税费
                             // 设置商品图片及税费
                             boolean taxFlag = false;
                             boolean taxFlag = false;
                             if (0 == organizeId) {
                             if (0 == organizeId) {
@@ -1168,10 +1167,12 @@ public class CartClubServiceImpl implements CartClubService {
                         } else {
                         } else {
                             shop.setIsColdChina(false);
                             shop.setIsColdChina(false);
                         }
                         }
+                        // 总费用 + 冷链费
+                        // shopPrice.set(MathUtil.add(shopPrice.get(), coldChain).doubleValue());
                         // 总运费
                         // 总运费
                         shop.setAllPostage(MathUtil.add(shop.getPostage(),coldChain).doubleValue());
                         shop.setAllPostage(MathUtil.add(shop.getPostage(),coldChain).doubleValue());
                         // 供应商总金额
                         // 供应商总金额
-                        shopPrice.set(MathUtil.add(shopPrice.get(), shop.getPostage()).doubleValue());
+                        shopPrice.set(MathUtil.add(shopPrice.get(), shop.getAllPostage()).doubleValue());
                         if (shopKindCount.get() > 0) {
                         if (shopKindCount.get() > 0) {
                             // 店铺促销
                             // 店铺促销
                             if (null != shopPromotion) {
                             if (null != shopPromotion) {
@@ -1507,7 +1508,6 @@ public class CartClubServiceImpl implements CartClubService {
                                     }
                                     }
                                 }
                                 }
                             }
                             }
-                            shopPrice.set(MathUtil.add(shopPrice.get(), coldChain).doubleValue());
                             // 设置商品图片及税费
                             // 设置商品图片及税费
                             boolean taxFlag = productService.setCartItemImgAndTax(cartItemVo);
                             boolean taxFlag = productService.setCartItemImgAndTax(cartItemVo);
                             // 是否充值商品
                             // 是否充值商品
@@ -1607,10 +1607,12 @@ public class CartClubServiceImpl implements CartClubService {
                         } else {
                         } else {
                             shop.setIsColdChina(false);
                             shop.setIsColdChina(false);
                         }
                         }
+                        // 总费用 + 冷链费
+                        // shopPrice.set(MathUtil.add(shopPrice.get(), coldChain).doubleValue());
                         // 总运费
                         // 总运费
                         shop.setAllPostage(MathUtil.add(shop.getPostage(),coldChain).doubleValue());
                         shop.setAllPostage(MathUtil.add(shop.getPostage(),coldChain).doubleValue());
                         // 供应商总金额
                         // 供应商总金额
-                        shopPrice.set(MathUtil.add(shopPrice.get(), shop.getPostage()).doubleValue());
+                        shopPrice.set(MathUtil.add(shopPrice.get(), shop.getAllPostage()).doubleValue());
                         if (shopKindCount.get() > 0) {
                         if (shopKindCount.get() > 0) {
                             // 店铺促销
                             // 店铺促销
                             if (null != shopPromotion) {
                             if (null != shopPromotion) {
@@ -1984,7 +1986,7 @@ public class CartClubServiceImpl implements CartClubService {
                 } else {
                 } else {
                     coldChain = 700d;
                     coldChain = 700d;
                     shop.setPostageFlag(1);
                     shop.setPostageFlag(1);
-                    totalPrice.set(MathUtil.add(totalPrice.get(), coldChain).doubleValue());
+                    // totalPrice.set(MathUtil.add(totalPrice.get(), coldChain).doubleValue());
                     shop.setIsColdChina(true);
                     shop.setIsColdChina(true);
                 }
                 }
             } else {
             } else {
@@ -1995,7 +1997,7 @@ public class CartClubServiceImpl implements CartClubService {
         // 总运费
         // 总运费
         shop.setAllPostage(MathUtil.add(shop.getPostage(),coldChain).doubleValue());
         shop.setAllPostage(MathUtil.add(shop.getPostage(),coldChain).doubleValue());
         // 供应商总金额
         // 供应商总金额
-        totalPrice.set(MathUtil.add(totalPrice.get(), shop.getPostage()).doubleValue());
+        totalPrice.set(MathUtil.add(totalPrice.get(), shop.getAllPostage()).doubleValue());
         // 商品总金额累加
         // 商品总金额累加
         originalPrice.set(MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getOriginalPrice()).doubleValue());
         originalPrice.set(MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getOriginalPrice()).doubleValue());
         totalPrice.set(MathUtil.add(totalPrice.get(), MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());
         totalPrice.set(MathUtil.add(totalPrice.get(), MathUtil.mul(cartItemVo.getNumber(), cartItemVo.getPrice())).doubleValue());

+ 7 - 0
src/main/java/com/caimei365/order/service/impl/HeliPayServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei365.order.components.HeliPayUtil;
 import com.caimei365.order.components.HeliPayUtil;
 import com.caimei365.order.components.OnlinePostFormUtil;
 import com.caimei365.order.components.OnlinePostFormUtil;
+import com.caimei365.order.components.OrderCommonService;
 import com.caimei365.order.components.WeChatService;
 import com.caimei365.order.components.WeChatService;
 import com.caimei365.order.constant.Constant;
 import com.caimei365.order.constant.Constant;
 import com.caimei365.order.mapper.BaseMapper;
 import com.caimei365.order.mapper.BaseMapper;
@@ -78,6 +79,8 @@ public class HeliPayServiceImpl implements HeliPayService {
     @Resource
     @Resource
     private RemoteCallService remoteCallService;
     private RemoteCallService remoteCallService;
     @Resource
     @Resource
+    private OrderCommonService orderCommonService;
+    @Resource
     private WeChatService weChatService;
     private WeChatService weChatService;
     @Resource
     @Resource
     private OrderRefundMapper refundMapper;
     private OrderRefundMapper refundMapper;
@@ -1238,6 +1241,9 @@ public class HeliPayServiceImpl implements HeliPayService {
                     orderProduct.setTotalAmount(orderProduct.getTotalFee());
                     orderProduct.setTotalAmount(orderProduct.getTotalFee());
                 }
                 }
             });
             });
+            if (null == shopOrder.getRealPay()) {
+                shopOrder.setRealPay(shopOrder.getNeedPayAmount());
+            }
             shopOrder.setObligation(MathUtil.sub(shopOrder.getRealPay(), shopOrder.getReceiptAmount()).doubleValue());
             shopOrder.setObligation(MathUtil.sub(shopOrder.getRealPay(), shopOrder.getReceiptAmount()).doubleValue());
             if (998 == shopOrder.getShopId()) {
             if (998 == shopOrder.getShopId()) {
                 shopOrder.setObligation(shopOrder.getTotalAmount());
                 shopOrder.setObligation(shopOrder.getTotalAmount());
@@ -1278,6 +1284,7 @@ public class HeliPayServiceImpl implements HeliPayService {
                 onlinePay = 2;
                 onlinePay = 2;
             }
             }
             shopOrder.setOnlinePay(onlinePay);
             shopOrder.setOnlinePay(onlinePay);
+            orderCommonService.setPostageInfo(shopOrder);
         });
         });
         return ResponseJson.success(shopOrderList);
         return ResponseJson.success(shopOrderList);
     }
     }

+ 18 - 7
src/main/java/com/caimei365/order/service/impl/OrderClubServiceImpl.java

@@ -149,10 +149,10 @@ public class OrderClubServiceImpl implements OrderClubService {
             // 设置子订单付款金额
             // 设置子订单付款金额
             orderCommonService.getDiscernReceiptAndSetShoporder(shopOrder);
             orderCommonService.getDiscernReceiptAndSetShoporder(shopOrder);
             // 联合丽格 [待付款]或者线下支付[部分付款] 的子订单 状态
             // 联合丽格 [待付款]或者线下支付[部分付款] 的子订单 状态
-            if ((4 != shopOrder.getStatus() && 5 != shopOrder.getStatus()) && (1 == shopOrder.getReceiptStatus() || (2 == shopOrder.getReceiptStatus() && 1 == shopOrder.getOnlinePay()))) {
-                shopOrder.setCheckFlag(1);
+            if ((4 != shopOrder.getStatus() && 5 != shopOrder.getStatus()) && (1 == shopOrder.getReceiptStatus() || (2 == shopOrder.getReceiptStatus() && 2 == shopOrder.getOnlinePay()))) {
+                shopOrder.setCheckFlag(2);
             } else {
             } else {
-                shopOrder.setCheckFlag(0);
+                shopOrder.setCheckFlag(1);
             }
             }
         });
         });
         /*List<OrderVo> orderList = orderClubMapper.getOrderList(userId, orderState, orderNo, beginTime, endTime);
         /*List<OrderVo> orderList = orderClubMapper.getOrderList(userId, orderState, orderNo, beginTime, endTime);
@@ -317,10 +317,10 @@ public class OrderClubServiceImpl implements OrderClubService {
             //退款总金额
             //退款总金额
             shopOrder.setReturnedPurchaseFee(returnedPurchaseFee.get());
             shopOrder.setReturnedPurchaseFee(returnedPurchaseFee.get());
         }
         }
-        if ((4 != shopOrder.getStatus() && 5 != shopOrder.getStatus()) && (1 == shopOrder.getReceiptStatus() || (2 == shopOrder.getReceiptStatus() && 1 == shopOrder.getOnlinePay()))) {
-            shopOrder.setCheckFlag(1);
+        if ((4 != shopOrder.getStatus() && 5 != shopOrder.getStatus()) && (1 == shopOrder.getReceiptStatus() || (2 == shopOrder.getReceiptStatus() && 2 == shopOrder.getOnlinePay()))) {
+            shopOrder.setCheckFlag(2);
         } else {
         } else {
-            shopOrder.setCheckFlag(0);
+            shopOrder.setCheckFlag(1);
         }
         }
         //售后条款
         //售后条款
         ClauseVo clause = null;
         ClauseVo clause = null;
@@ -478,7 +478,7 @@ public class OrderClubServiceImpl implements OrderClubService {
             orderClubMapper.updateUserMoneyByUserId(updateMoney, shopOrder.getUserId());
             orderClubMapper.updateUserMoneyByUserId(updateMoney, shopOrder.getUserId());
             log.info(note + ">>>>>>>>>>>更新用户余额(update[user(userMoney)])userId:" + shopOrder.getUserId() + ",shopOrderId:" + shopOrderId);
             log.info(note + ">>>>>>>>>>>更新用户余额(update[user(userMoney)])userId:" + shopOrder.getUserId() + ",shopOrderId:" + shopOrderId);
             // 保存余额到收款记录
             // 保存余额到收款记录
-            productService.saveDiscernReceipt(shopOrder.getAccountAmount(), shopOrderId, note);
+            productService.saveShopOrderDiscernReceipt(shopOrder.getAccountAmount(), shopOrder, note);
         }
         }
         if (null == shopOrder.getAccountAmount() || shopOrder.getAccountAmount() == 0d) {
         if (null == shopOrder.getAccountAmount() || shopOrder.getAccountAmount() == 0d) {
             shopOrder.setReceiptStatus(1);
             shopOrder.setReceiptStatus(1);
@@ -1140,4 +1140,15 @@ public class OrderClubServiceImpl implements OrderClubService {
         return ResponseJson.success(clause);
         return ResponseJson.success(clause);
     }
     }
 
 
+    /**
+     * 查询供应商银行卡信息
+     *
+     * @param shopId
+     * @return
+     */
+    @Override
+    public ResponseJson<ShopPo> getShopBankAccount(Integer shopId) {
+        return ResponseJson.success(orderClubMapper.getShopBankAccount(shopId));
+    }
+
 }
 }

+ 29 - 22
src/main/java/com/caimei365/order/service/impl/PayOrderServiceImpl.java

@@ -97,6 +97,7 @@ public class PayOrderServiceImpl implements PayOrderService {
         // 返回数据
         // 返回数据
         Map<String, Object> map = new HashMap<>();
         Map<String, Object> map = new HashMap<>();
         map.put("shopOrderId", shopOrderId);
         map.put("shopOrderId", shopOrderId);
+        map.put("orderId", shopOrder.getOrderId());
         // 查询审核中的退款退货数量
         // 查询审核中的退款退货数量
         int refundCount = payOrderMapper.getShopRefundCount(shopOrderId);
         int refundCount = payOrderMapper.getShopRefundCount(shopOrderId);
         if (refundCount > 0) {
         if (refundCount > 0) {
@@ -151,7 +152,7 @@ public class PayOrderServiceImpl implements PayOrderService {
     /**
     /**
      * 订单支付,余额抵扣
      * 订单支付,余额抵扣
      *
      *
-     * @param orderId 订单Id
+     * @param shopOrderId 订单Id
      */
      */
     @Override
     @Override
     public ResponseJson<Map<String, Object>> balanceDeduction(Integer shopOrderId) {
     public ResponseJson<Map<String, Object>> balanceDeduction(Integer shopOrderId) {
@@ -249,19 +250,20 @@ public class PayOrderServiceImpl implements PayOrderService {
     /**
     /**
      * 收银台数据显示
      * 收银台数据显示
      *
      *
-     * @param orderId 订单Id
+     * @param shopOrderId 订单Id
      */
      */
     @Override
     @Override
-    public ResponseJson<Map<String, Object>> getCheckoutCounter(Integer orderId) {
+    public ResponseJson<Map<String, Object>> getCheckoutCounter(Integer shopOrderId) {
         // 订单信息
         // 订单信息
-        OrderVo order = orderCommonMapper.getOrderByOrderId(orderId);
-        if (null == order) {
+        // OrderVo order = orderCommonMapper.getOrderByOrderId(orderId);
+        ShopOrderVo shopOrder = orderCommonMapper.getShopOrderById(shopOrderId);
+        if (null == shopOrder) {
             return ResponseJson.error("订单不存在", null);
             return ResponseJson.error("订单不存在", null);
         }
         }
         // 机构信息
         // 机构信息
-        String userName = baseMapper.getUserNameByUserId(order.getUserId());
+        String userName = baseMapper.getUserNameByUserId(shopOrder.getUserId());
         // 支付记录
         // 支付记录
-        List<DiscernReceiptVo> discernReceiptList = orderCommonMapper.getDiscernReceipt(order.getOrderId(), order.getShopOrderIds());
+        List<DiscernReceiptVo> discernReceiptList = orderCommonMapper.getDiscernReceipt(shopOrder.getOrderId(), shopOrder.getShopOrderId().toString());
         if (!discernReceiptList.isEmpty()) {
         if (!discernReceiptList.isEmpty()) {
             AtomicDouble receiptAmount = new AtomicDouble(0d);
             AtomicDouble receiptAmount = new AtomicDouble(0d);
             AtomicBoolean offlineFlag = new AtomicBoolean(false);
             AtomicBoolean offlineFlag = new AtomicBoolean(false);
@@ -277,23 +279,23 @@ public class PayOrderServiceImpl implements PayOrderService {
                 }
                 }
             });
             });
             if (offlineFlag.get()) {
             if (offlineFlag.get()) {
-                order.setOnlinePayFlag(1);
+                shopOrder.setOnlinePay(1);
             }
             }
-            order.setReceiptAmount(receiptAmount.get());
+            shopOrder.setReceiptAmount(receiptAmount.get());
         }
         }
         // 总成本
         // 总成本
         AtomicDouble totalCostPrice = new AtomicDouble(0d);
         AtomicDouble totalCostPrice = new AtomicDouble(0d);
         // 商品数据
         // 商品数据
-        List<OrderProductVo> orderProductList = orderCommonMapper.getOrderProductByOrderId(orderId);
+        List<OrderProductVo> orderProductList = orderCommonMapper.getshopOrderProductByOrderId(shopOrderId);
         //过滤运费商品
         //过滤运费商品
         orderProductList.removeIf(product -> product.getShopId() == 998);
         orderProductList.removeIf(product -> product.getShopId() == 998);
         // 是否有商品发票属性的限制
         // 是否有商品发票属性的限制
         orderProductList.forEach(orderProduct -> {
         orderProductList.forEach(orderProduct -> {
             // 商品含税未知 or 订单选择开企业发票,商品不含税不能开票
             // 商品含税未知 or 订单选择开企业发票,商品不含税不能开票
             boolean productTaxFlag = (null == orderProduct.getIncludedTax()) || (null == orderProduct.getInvoiceType()) || (Integer.valueOf(2).equals(orderProduct.getIncludedTax()))
             boolean productTaxFlag = (null == orderProduct.getIncludedTax()) || (null == orderProduct.getInvoiceType()) || (Integer.valueOf(2).equals(orderProduct.getIncludedTax()))
-                    || (Integer.valueOf(2).equals(order.getInvoiceFlag()) && (Integer.valueOf(0).equals(orderProduct.getIncludedTax()) && Integer.valueOf(3).equals(orderProduct.getInvoiceType())));
+                    || (Integer.valueOf(2).equals(shopOrder.getInvoiceFlag()) && (Integer.valueOf(0).equals(orderProduct.getIncludedTax()) && Integer.valueOf(3).equals(orderProduct.getInvoiceType())));
             if (productTaxFlag) {
             if (productTaxFlag) {
-                order.setInvoiceStatus(true);
+                shopOrder.setInvoiceStatus(true);
             }
             }
             //当应付金额小于订单总成本时,不能走线上支付,总成本=商品成本 + 供应商运费 + 供应商税费
             //当应付金额小于订单总成本时,不能走线上支付,总成本=商品成本 + 供应商运费 + 供应商税费
             double costPrice = MathUtil.mul(orderProduct.getCostPrice(), orderProduct.getNum()).doubleValue();
             double costPrice = MathUtil.mul(orderProduct.getCostPrice(), orderProduct.getNum()).doubleValue();
@@ -303,26 +305,31 @@ public class PayOrderServiceImpl implements PayOrderService {
                 //成本+税费
                 //成本+税费
                 costPrice = MathUtil.add(costPrice, payableTax).doubleValue();
                 costPrice = MathUtil.add(costPrice, payableTax).doubleValue();
             }
             }
-            List<ShopOrderVo> shopOrderList = orderCommonMapper.getShopOrderListByOrderId(order.getOrderId());
-            for (ShopOrderVo shopOrder : shopOrderList) {
+//            List<ShopOrderVo> shopOrderList = orderCommonMapper.getShopOrderListByOrderId(order.getOrderId());
+//            for (ShopOrderVo shopOrder : shopOrderList) {
                 // 付供应商运费
                 // 付供应商运费
                 Double shopPostFee = shopOrder.getShopPostFee();
                 Double shopPostFee = shopOrder.getShopPostFee();
                 costPrice = MathUtil.add(costPrice, shopPostFee).doubleValue();
                 costPrice = MathUtil.add(costPrice, shopPostFee).doubleValue();
-            }
+//            }
             totalCostPrice.set(MathUtil.add(costPrice, totalCostPrice.get()).doubleValue());
             totalCostPrice.set(MathUtil.add(costPrice, totalCostPrice.get()).doubleValue());
         });
         });
-        Integer onlinePay = order.getOnlinePayFlag();
+        // 待付金额
+        if (null == shopOrder.getRealPay()) {
+            shopOrder.setRealPay(shopOrder.getNeedPayAmount());
+        }
+        shopOrder.setObligation(MathUtil.sub(shopOrder.getRealPay(), shopOrder.getReceiptAmount()).doubleValue());
+        Integer onlinePay = shopOrder.getOnlinePay();
         // 返回数据
         // 返回数据
         Map<String, Object> map = new HashMap<>();
         Map<String, Object> map = new HashMap<>();
         map.put("userName", userName);
         map.put("userName", userName);
-        map.put("order", order);
+        map.put("shopOrder", shopOrder);
         map.put("discernReceipt", discernReceiptList);
         map.put("discernReceipt", discernReceiptList);
         map.put("orderProductList", orderProductList);
         map.put("orderProductList", orderProductList);
         //能否线上判断付供应商是否大于订单金额
         //能否线上判断付供应商是否大于订单金额
-        if (order.getBalancePayFee() > 0 || totalCostPrice.get() > order.getPayTotalFee()) {
+        if (shopOrder.getAccountAmount() > 0 || totalCostPrice.get() > shopOrder.getTotalAmount()) {
             onlinePay = 1;
             onlinePay = 1;
         }
         }
-        Integer num = orderCommonMapper.findSplitCode(orderId);
+        Integer num = orderCommonMapper.findSplitCode(shopOrder.getOrderId());
         if (num > 0) {
         if (num > 0) {
             onlinePay = 1;
             onlinePay = 1;
         }
         }
@@ -709,12 +716,12 @@ public class PayOrderServiceImpl implements PayOrderService {
                 //成本+税费
                 //成本+税费
                 costPrice = MathUtil.add(costPrice, payableTax).doubleValue();
                 costPrice = MathUtil.add(costPrice, payableTax).doubleValue();
             }
             }
-            List<ShopOrderVo> shopOrderList = orderCommonMapper.getShopOrderListByOrderId(order.getOrderId());
-            for (ShopOrderVo shopOrder : shopOrderList) {
+             List<ShopOrderVo> shopOrderList = orderCommonMapper.getShopOrderListByOrderId(order.getOrderId());
+             for (ShopOrderVo shopOrder : shopOrderList) {
                 // 付供应商运费
                 // 付供应商运费
                 Double shopPostFee = shopOrder.getShopPostFee();
                 Double shopPostFee = shopOrder.getShopPostFee();
                 costPrice = MathUtil.add(costPrice, shopPostFee).doubleValue();
                 costPrice = MathUtil.add(costPrice, shopPostFee).doubleValue();
-            }
+             }
             totalCostPrice.set(MathUtil.add(costPrice, totalCostPrice.get()).doubleValue());
             totalCostPrice.set(MathUtil.add(costPrice, totalCostPrice.get()).doubleValue());
         });
         });
         //. 后台线上支付开关2.商品是否有分账账号 3. 订单是否进行过线下支付 4.是否使用了余额抵扣
         //. 后台线上支付开关2.商品是否有分账账号 3. 订单是否进行过线下支付 4.是否使用了余额抵扣

+ 91 - 10
src/main/java/com/caimei365/order/service/impl/ShipServiceImpl.java

@@ -2,6 +2,7 @@ package com.caimei365.order.service.impl;
 
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
+import com.caimei365.order.components.OrderCommonService;
 import com.caimei365.order.components.OssService;
 import com.caimei365.order.components.OssService;
 import com.caimei365.order.components.WeChatService;
 import com.caimei365.order.components.WeChatService;
 import com.caimei365.order.mapper.*;
 import com.caimei365.order.mapper.*;
@@ -36,6 +37,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
+import java.util.stream.Collectors;
 
 
 import static com.alibaba.fastjson.JSON.parseArray;
 import static com.alibaba.fastjson.JSON.parseArray;
 
 
@@ -57,6 +59,8 @@ public class ShipServiceImpl implements ShipService {
     @Resource
     @Resource
     private AddressMapper addressMapper;
     private AddressMapper addressMapper;
     @Resource
     @Resource
+    private OrderCommonService orderCommonService;
+    @Resource
     private OrderCommonMapper orderCommonMapper;
     private OrderCommonMapper orderCommonMapper;
     @Resource
     @Resource
     private OrderClubMapper orderClubMapper;
     private OrderClubMapper orderClubMapper;
@@ -82,14 +86,20 @@ public class ShipServiceImpl implements ShipService {
      * @param pageSize      每页数量
      * @param pageSize      每页数量
      */
      */
     @Override
     @Override
-    public ResponseJson<PageInfo<ShopOrderVo>> getShopOrderList(Integer shopId, Integer sendOutStatus, Integer payStatus, String shopOrderNo, String receiver, int pageNum, int pageSize) {
+    public ResponseJson<PageInfo<ShopOrderVo>> getShopOrderList(Integer shopId, Integer sendOutStatus, Integer payStatus, String shopOrderNo, String receiver, Integer organizeId, int pageNum, int pageSize) {
         // 分页请求数据
         // 分页请求数据
         PageHelper.startPage(pageNum, pageSize);
         PageHelper.startPage(pageNum, pageSize);
-        List<ShopOrderVo> shopOrderList = shipMapper.getShopOrderList(shopId, sendOutStatus, payStatus, shopOrderNo, receiver);
+        List<ShopOrderVo> shopOrderList = shipMapper.getShopOrderList(shopId, sendOutStatus, payStatus, shopOrderNo, receiver, organizeId);
         shopOrderList.forEach(shopOrder -> {
         shopOrderList.forEach(shopOrder -> {
             if (null != shopOrder) {
             if (null != shopOrder) {
                 setShopOrderInfo(shopOrder);
                 setShopOrderInfo(shopOrder);
             }
             }
+            // 联合丽格 [待付款]或者线下支付[部分付款] 的子订单 状态
+            if ((4 != shopOrder.getStatus() && 5 != shopOrder.getStatus()) && (1 == shopOrder.getReceiptStatus() || (2 == shopOrder.getReceiptStatus() && 2 == shopOrder.getOnlinePay()))) {
+                shopOrder.setCheckFlag(2);
+            } else {
+                shopOrder.setCheckFlag(1);
+            }
         });
         });
         PageInfo<ShopOrderVo> pageInfo = new PageInfo(shopOrderList);
         PageInfo<ShopOrderVo> pageInfo = new PageInfo(shopOrderList);
         return ResponseJson.success(pageInfo);
         return ResponseJson.success(pageInfo);
@@ -182,6 +192,12 @@ public class ShipServiceImpl implements ShipService {
             return ResponseJson.error("子订单异常,shopOrderId:" + shopOrderId, null);
             return ResponseJson.error("子订单异常,shopOrderId:" + shopOrderId, null);
         }
         }
         setShopOrderInfo(shopOrder);
         setShopOrderInfo(shopOrder);
+        // 联合丽格 [待付款]或者线下支付[部分付款] 的子订单 状态
+        if ((4 != shopOrder.getStatus() && 5 != shopOrder.getStatus()) && (1 == shopOrder.getReceiptStatus() || (2 == shopOrder.getReceiptStatus() && 2 == shopOrder.getOnlinePay()))) {
+            shopOrder.setCheckFlag(2);
+        } else {
+            shopOrder.setCheckFlag(1);
+        }
         Map<String, Object> map = new HashMap<>(2);
         Map<String, Object> map = new HashMap<>(2);
         map.put("shopOrder", shopOrder);
         map.put("shopOrder", shopOrder);
         // 结算记录
         // 结算记录
@@ -233,11 +249,13 @@ public class ShipServiceImpl implements ShipService {
 
 
 
 
     private void setShopOrderInfo(ShopOrderVo shopOrder) {
     private void setShopOrderInfo(ShopOrderVo shopOrder) {
+        // 设置订单状态
+        orderCommonService.setShopOrderStatus(shopOrder);
         // 收货地址
         // 收货地址
         OrderUserinfoVo userInfo = addressMapper.getOrderUserinfo(shopOrder.getOrderId());
         OrderUserinfoVo userInfo = addressMapper.getOrderUserinfo(shopOrder.getOrderId());
         shopOrder.setUserInfo(userInfo);
         shopOrder.setUserInfo(userInfo);
         // (收款买家)收款状态:1待收款、2部分收款、3已收款
         // (收款买家)收款状态:1待收款、2部分收款、3已收款
-        Integer receiptStatus = shipMapper.getOrderReceiptStatus(shopOrder.getOrderId());
+        Integer receiptStatus = shipMapper.getShopOrderReceiptStatus(shopOrder.getShopOrderId());
         //(收款买家)收款状态:1待收款、2部分收款、3已收款
         //(收款买家)收款状态:1待收款、2部分收款、3已收款
         shopOrder.setReceiptStatus(receiptStatus);
         shopOrder.setReceiptStatus(receiptStatus);
         // 供应商名称
         // 供应商名称
@@ -264,6 +282,25 @@ public class ShipServiceImpl implements ShipService {
                 orderProduct.setActualCancelNum(actualCancelNum);
                 orderProduct.setActualCancelNum(actualCancelNum);
             }
             }
         });
         });
+        // 发票信息
+        InvoicePo orderInvoice = orderClubMapper.getOrderInvoice(shopOrder.getOrderId());
+        shopOrder.setInvoice(orderInvoice);
+        // 线下支付凭证
+        List<VoucherPo> voucher = orderClubMapper.getVoucher(shopOrder.getShopOrderId());
+        // 支付凭证图片
+        if (null != voucher) {
+            List<Integer> ids = voucher.stream().map(VoucherPo::getId).collect(Collectors.toList());
+            List<VoucherImageDto> voucherImage = orderClubMapper.getVoucherImage(ids);
+            voucher.forEach(v -> {
+                List<VoucherImageDto> imageList = voucherImage.stream().filter(m -> m.getVoucherId().equals(v.getId())).collect(Collectors.toList());
+                v.setImgs(imageList);
+            });
+        }
+        // 子订单信息
+        orderCommonService.setShopOrderInfo(shopOrder);
+        // 设置子订单付款金额
+        orderCommonService.getDiscernReceiptAndSetShoporder(shopOrder);
+        shopOrder.setVoucher(voucher);
         shopOrder.setOrderProductList(orderProductList);
         shopOrder.setOrderProductList(orderProductList);
         shopOrder.setShopLogo(ImageUtil.getImageUrl("shopLogo", shopOrder.getShopLogo(), domain));
         shopOrder.setShopLogo(ImageUtil.getImageUrl("shopLogo", shopOrder.getShopLogo(), domain));
         shopOrder.setOrderProductList(orderProductList);
         shopOrder.setOrderProductList(orderProductList);
@@ -1036,6 +1073,43 @@ public class ShipServiceImpl implements ShipService {
         }
         }
     }
     }
 
 
+    /**
+     * 更改收款状态
+     *
+     * @param amount
+     * @param shopOrderId
+     * @return
+     */
+    @Override
+    public ResponseJson checkReceipt(Double amount, Integer shopOrderId) {
+        Double wait = shipMapper.findWaitPay(shopOrderId);
+        if (amount > wait) {
+            return ResponseJson.error("支付金额大于待付!");
+        }
+        ReceiptVo receiptVo = new ReceiptVo();
+        // 31 线下凭证
+        receiptVo.setPayType(31);
+        receiptVo.setPayWay(2);
+        receiptVo.setNewReceiptType(2);
+        receiptVo.setReceiptType(1);
+        receiptVo.setReceiptStatus(3);
+        receiptVo.setReceiptAmount(amount);
+        shipMapper.insertOrderReceipt(receiptVo);
+        OrderReceiptRelationPo record = new OrderReceiptRelationPo();
+        record.setReceiptAmount(amount);
+        record.setRelationType(2);
+        record.setReceiptId(receiptVo.getId());
+        record.setShopOrderId(shopOrderId);
+        shipMapper.insertOrderRelation(record);
+        // 根据金额修改cm_order状态
+        Integer status = 2;
+        if (0 == wait - amount) {
+            status = 3;
+        }
+        shipMapper.updateReceiptStatus(status, shopOrderId);
+        return ResponseJson.success();
+    }
+
     @Override
     @Override
     public List<OrderRemarkDto> findList(Integer orderId) {
     public List<OrderRemarkDto> findList(Integer orderId) {
         List<OrderRemarkDto> list = shipMapper.findList(orderId);
         List<OrderRemarkDto> list = shipMapper.findList(orderId);
@@ -1048,9 +1122,9 @@ public class ShipServiceImpl implements ShipService {
 
 
     @Override
     @Override
     public void insertRemark(OrderRemarkDto remark) {
     public void insertRemark(OrderRemarkDto remark) {
-        /*CmMallAdminUser user = (CmMallAdminUser) SecurityUtils.getSubject().getPrincipal();
-        remark.setCreateBy(user.getId());
-        shipMapper.insert(remark);*/
+        // CmMallAdminUser user = (CmMallAdminUser) SecurityUtils.getSubject().getPrincipal();
+        // remark.setCreateBy(user.getId());
+        shipMapper.insert(remark);
         List<String> images = remark.getImages();
         List<String> images = remark.getImages();
         List<OssFileDto> ossFiles = remark.getOssFiles();
         List<OssFileDto> ossFiles = remark.getOssFiles();
         if (null != images && images.size() > 0) {
         if (null != images && images.size() > 0) {
@@ -1112,10 +1186,17 @@ public class ShipServiceImpl implements ShipService {
     }
     }
 
 
     @Override
     @Override
-    public void downFile(Integer fileId, HttpServletRequest request, HttpServletResponse response) throws IOException {
+    public ResponseJson<Map<String, Object>> downFile(Integer fileId, HttpServletRequest request, HttpServletResponse response) throws IOException {
         OssFileDto remarkFile = shipMapper.findRemarkById(fileId);
         OssFileDto remarkFile = shipMapper.findRemarkById(fileId);
-        String fileName = remarkFile.getName();
-        ossUtils.downFile(remarkFile.getOssName(), fileName);
-        ossService.download(request, response, fileName);
+        Map<String, Object> map = new HashMap<>();
+        if (null != remarkFile) {
+            String fileName = remarkFile.getName();
+            ossUtils.downFile(remarkFile.getOssName(), fileName);
+            ossService.download(request, response, fileName);
+            map.put("code", 0);
+        } else {
+            map.put("code", -1);
+        }
+        return ResponseJson.success(map);
     }
     }
 }
 }

+ 13 - 19
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -936,10 +936,12 @@ public class SubmitServiceImpl implements SubmitService {
                 shopOrder.setShopPostFee(postage);
                 shopOrder.setShopPostFee(postage);
             }
             }
             // 需要支付金额 shouldPayFee +运费
             // 需要支付金额 shouldPayFee +运费
-            // needPayAmount.set(MathUtil.add(needPayAmount.get(), postage).doubleValue());
-            log.info("postage=-***====" + postage);
+            needPayAmount.set(MathUtil.add(needPayAmount.get(), postage).doubleValue());
+            log.info("postage=-***===="+postage);
             isColdChina.set(MathUtil.add(isColdChina.get(), shopIsColdChina.get()).doubleValue());
             isColdChina.set(MathUtil.add(isColdChina.get(), shopIsColdChina.get()).doubleValue());
-            log.info("isColdChina.get()=------=-=-====" + isColdChina.get());
+            log.info("isColdChina.get()=------=-=-===="+isColdChina.get());
+            // 需要支付金额 shouldPayFee + 冷链费
+            needPayAmount.set(MathUtil.add(needPayAmount.get(), isColdChina.get()).doubleValue());
             // 统计总运费
             // 统计总运费
             postageFee.set(MathUtil.add(postageFee.get(), postage).doubleValue());
             postageFee.set(MathUtil.add(postageFee.get(), postage).doubleValue());
             log.info("统计总运费+--+-+-" + postageFee.get());
             log.info("统计总运费+--+-+-" + postageFee.get());
@@ -1135,8 +1137,12 @@ public class SubmitServiceImpl implements SubmitService {
         // 设置运费
         // 设置运费
         // mainOrder.setPostage(orderParamBo.getPostage());
         // mainOrder.setPostage(orderParamBo.getPostage());
         // 订单总额 = 商品费 + 运费
         // 订单总额 = 商品费 + 运费
-        log.info("总运费" + postageFee.get());
+        log.info("总运费"+postageFee.get());
         payTotalFee.set(MathUtil.add(productTotalFee.get(), postageFee.get()).doubleValue());
         payTotalFee.set(MathUtil.add(productTotalFee.get(), postageFee.get()).doubleValue());
+        // 总金额 + 冷链运输费
+        log.info("isColdChina.get()=------=-=-===="+isColdChina.get());
+        payTotalFee.set(MathUtil.add(payTotalFee.get(), isColdChina.get()).doubleValue());
+        log.info("payTotalFee.get()=------=-=-===="+payTotalFee.get());
         // 运费标志:0包邮 -1到付 1遵循运费规则
         // 运费标志:0包邮 -1到付 1遵循运费规则
         // mainOrder.setPostageFlag(orderParamBo.getPostageFlag());
         // mainOrder.setPostageFlag(orderParamBo.getPostageFlag());
         /*if (1 == orderParamBo.getPostageFlag() && orderParamBo.getOffsetBeans() > 0) {
         /*if (1 == orderParamBo.getPostageFlag() && orderParamBo.getOffsetBeans() > 0) {
@@ -1152,7 +1158,7 @@ public class SubmitServiceImpl implements SubmitService {
         mainOrder.setProductTotalFee(productTotalFee.get());
         mainOrder.setProductTotalFee(productTotalFee.get());
         mainOrder.setOrderTotalFee(productTotalFee.get());
         mainOrder.setOrderTotalFee(productTotalFee.get());
         // 订单总额(商品金额+运费)-- 冷链运输费
         // 订单总额(商品金额+运费)-- 冷链运输费
-        mainOrder.setPayTotalFee(MathUtil.add(payTotalFee.get(), isColdChina.get()).doubleValue());
+        mainOrder.setPayTotalFee(payTotalFee.get());
         // 订单状态
         // 订单状态
         if (0 == organizeId) {
         if (0 == organizeId) {
             if (3 == orderParamBo.getCartType()) {
             if (3 == orderParamBo.getCartType()) {
@@ -1208,6 +1214,7 @@ public class SubmitServiceImpl implements SubmitService {
             // 支付时间
             // 支付时间
             mainOrder.setPayTime(curDateStr);
             mainOrder.setPayTime(curDateStr);
         } else {
         } else {
+            log.info("payTotalFee.get()=------=-=-===="+payTotalFee.get());
             //不用余额的情况下真是支付金额赋值为订单总额
             //不用余额的情况下真是支付金额赋值为订单总额
             payableAmount.set(payTotalFee.get());
             payableAmount.set(payTotalFee.get());
         }
         }
@@ -1696,23 +1703,10 @@ public class SubmitServiceImpl implements SubmitService {
          */
          */
         // 余额支付标识,0不使用,1使用
         // 余额支付标识,0不使用,1使用
         if (1 == orderParamBo.getBalancePayFlag() && MathUtil.compare(balancePayFee.get(), 0) > 0) {
         if (1 == orderParamBo.getBalancePayFlag() && MathUtil.compare(balancePayFee.get(), 0) > 0) {
-            //保存余额到余额收支记录
-            BalanceRecordPo balanceRecord = new BalanceRecordPo();
-            balanceRecord.setUserId(mainOrder.getUserId());
-            balanceRecord.setType(2);
-            balanceRecord.setBalanceType(1);
-            balanceRecord.setAddDate(new Date());
-            balanceRecord.setAmount(balancePayFee.get());
-            balanceRecord.setOrderId(mainOrder.getOrderId());
-            balanceRecord.setRemark("机构自主订单");
-            balanceRecord.setDelFlag(0);
-            // 保存 余额收支记录
-            baseMapper.insertBalanceRecord(balanceRecord);
-            log.info("【提交订单】>>>>>>>>>>>>>>>>>>>>>>>>>>新增用户余额收支记录(insert[cm_user_balance_record])orderId:" + mainOrder.getOrderId());
             // 保存余额抵扣到收款记录(自主订单)
             // 保存余额抵扣到收款记录(自主订单)
             if (3 != orderParamBo.getCartType()) {
             if (3 != orderParamBo.getCartType()) {
                 Integer orderId = mainOrder.getOrderId();
                 Integer orderId = mainOrder.getOrderId();
-                productService.saveDiscernReceipt(balancePayFee.get(), orderId, "【提交订单】");
+                productService.saveDiscernReceipt(balancePayFee.get(), shopOrderList, "【提交订单】");
             }
             }
         }
         }
 
 

+ 2 - 2
src/main/resources/mapper/CartClubMapper.xml

@@ -127,7 +127,7 @@
                p.productType
                p.productType
         FROM cm_cart c
         FROM cm_cart c
                  LEFT JOIN product P ON c.productID = p.productID
                  LEFT JOIN product P ON c.productID = p.productID
-                 LEFT JOIN cm_sku cs ON cs.productID = p.productID
+                 LEFT JOIN cm_sku cs ON cs.skuId = c.skuId
         WHERE c.userID = #{userId}
         WHERE c.userID = #{userId}
           and p.shopID = #{shopId}
           and p.shopID = #{shopId}
           and cs.organizeID = #{organizeId}
           and cs.organizeID = #{organizeId}
@@ -360,7 +360,7 @@
             useGeneratedKeys="true">
             useGeneratedKeys="true">
         INSERT INTO cm_cart (skuId, shopID, productID, userID, productCount, addTime, reBuyFlag)
         INSERT INTO cm_cart (skuId, shopID, productID, userID, productCount, addTime, reBuyFlag)
         VALUES (#{skuId},
         VALUES (#{skuId},
-                (select shopId from product p left join cm_sku cs on p.productId = cs.productId where cs.skuId = #{skuId} and cs.organizeId = 0),
+                (select shopId from product p left join cm_sku cs on p.productId = cs.productId where cs.skuId = #{skuId}),
                 (select productId from cm_sku where skuId = #{skuId}), #{userId},
                 (select productId from cm_sku where skuId = #{skuId}), #{userId},
                 #{productCount},
                 #{productCount},
                 #{addTime}, #{reBuyFlag})
                 #{addTime}, #{reBuyFlag})

+ 23 - 6
src/main/resources/mapper/OrderClubMapper.xml

@@ -259,6 +259,7 @@
             cso.brokerage,
             cso.brokerage,
             cso.canRefundAmount,
             cso.canRefundAmount,
             cso.itemCount,
             cso.itemCount,
+            ifnull(cso.accountAmount, 0) as accountAmount,
             cso.totalAmount,
             cso.totalAmount,
             cso.productAmount,
             cso.productAmount,
             cso.needPayAmount,
             cso.needPayAmount,
@@ -272,7 +273,7 @@
             cso.payStatus,
             cso.payStatus,
             cso.orderSubmitType,
             cso.orderSubmitType,
             cso.splitFlag,
             cso.splitFlag,
-            cso.sendOutStatus,
+            ifnull(cso.sendOutStatus, 1) as sendOutStatus,
             co.secondHandOrderFlag as secondHandOrderFlag,
             co.secondHandOrderFlag as secondHandOrderFlag,
             IFNULL(cso.receiptAmount,0) AS receiptAmount,
             IFNULL(cso.receiptAmount,0) AS receiptAmount,
             cso.eachDiscount,
             cso.eachDiscount,
@@ -283,7 +284,7 @@
             s.shopType AS shopType,
             s.shopType AS shopType,
             co.clauseID AS clauseId,
             co.clauseID AS clauseId,
             co.invoiceFlag,
             co.invoiceFlag,
-            cso.receiptStatus,
+            ifnull(cso.receiptStatus, 1) as receiptStatus,
             cso.shopStatus as status
             cso.shopStatus as status
         FROM cm_shop_order cso
         FROM cm_shop_order cso
                  LEFT JOIN shop s ON cso.shopID = s.shopID
                  LEFT JOIN shop s ON cso.shopID = s.shopID
@@ -569,7 +570,7 @@
             cso.payStatus,
             cso.payStatus,
             cso.orderSubmitType,
             cso.orderSubmitType,
             cso.splitFlag,
             cso.splitFlag,
-            cso.sendOutStatus,
+            ifnull(cso.sendOutStatus, 1) as sendOutStatus,
             (select onlinePayFlag from cm_order where orderId = cso.orderId ) as onlinePay,
             (select onlinePayFlag from cm_order where orderId = cso.orderId ) as onlinePay,
             (select secondHandOrderFlag from cm_order where orderId = cso.orderId ) as secondHandOrderFlag,
             (select secondHandOrderFlag from cm_order where orderId = cso.orderId ) as secondHandOrderFlag,
             s.name AS shopName,
             s.name AS shopName,
@@ -579,7 +580,7 @@
             IFNULL(cso.receiptAmount,0) AS receiptAmount,
             IFNULL(cso.receiptAmount,0) AS receiptAmount,
             cso.eachDiscount,
             cso.eachDiscount,
             IFNULL(cso.realPay, cso.needPayAmount)AS readPay,
             IFNULL(cso.realPay, cso.needPayAmount)AS readPay,
-            cso.receiptStatus,
+            ifnull(cso.receiptStatus, 1) as receiptStatus,
             cso.shopStatus as status
             cso.shopStatus as status
         FROM cm_shop_order cso
         FROM cm_shop_order cso
                  LEFT JOIN shop s ON cso.shopID = s.shopID
                  LEFT JOIN shop s ON cso.shopID = s.shopID
@@ -700,12 +701,12 @@
                         cso.payStatus,
                         cso.payStatus,
                         cso.orderSubmitType,
                         cso.orderSubmitType,
                         cso.splitFlag,
                         cso.splitFlag,
-                        cso.sendOutStatus,
+                        ifnull(cso.sendOutStatus, 1) as sendOutStatus,
                         (SELECT secondHandOrderFlag FROM cm_order WHERE orderId = cso.orderId ) AS secondHandOrderFlag,
                         (SELECT secondHandOrderFlag FROM cm_order WHERE orderId = cso.orderId ) AS secondHandOrderFlag,
                         IFNULL(cso.receiptAmount,0) AS receiptAmount,
                         IFNULL(cso.receiptAmount,0) AS receiptAmount,
                         cso.eachDiscount,
                         cso.eachDiscount,
                         IFNULL(cso.realPay, cso.needPayAmount)AS readPay,
                         IFNULL(cso.realPay, cso.needPayAmount)AS readPay,
-                        cso.receiptStatus,
+                        ifnull(cso.receiptStatus, 1) as receiptStatus,
                         cso.shopStatus AS STATUS
                         cso.shopStatus AS STATUS
         FROM cm_shop_order cso
         FROM cm_shop_order cso
                  LEFT JOIN cm_order_product cop ON cso.shopOrderId = cop.shopOrderId
                  LEFT JOIN cm_order_product cop ON cso.shopOrderId = cop.shopOrderId
@@ -1053,6 +1054,18 @@
         WHERE productId = #{productId} and organizeId = 4
         WHERE productId = #{productId} and organizeId = 4
         ORDER BY price ASC
         ORDER BY price ASC
     </select>
     </select>
+    <select id="getOrderInvoice" resultType="com.caimei365.order.model.po.InvoicePo">
+        SELECT id,
+               orderId,
+               invoiceTitle,
+               corporationTaxNum,
+               registeredAddress,
+               registeredPhone,
+               bankAccountNo,
+               openBank
+        FROM bp_order_invoice
+        WHERE orderId = #{orderId}
+    </select>
     <select id="getVoucher" resultType="com.caimei365.order.model.po.VoucherPo">
     <select id="getVoucher" resultType="com.caimei365.order.model.po.VoucherPo">
         SELECT id, shopOrderId, remarks, addtime FROM cm_order_payment_voucher WHERE shopOrderId = #{shopOrderId}
         SELECT id, shopOrderId, remarks, addtime FROM cm_order_payment_voucher WHERE shopOrderId = #{shopOrderId}
     </select>
     </select>
@@ -1085,4 +1098,8 @@
         insert into cm_voucher_image (voucherId, image)
         insert into cm_voucher_image (voucherId, image)
         values (#{voucherId},#{img})
         values (#{voucherId},#{img})
     </insert>
     </insert>
+
+    <select id="getShopBankAccount" resultType="com.caimei365.order.model.po.ShopPo">
+        SELECT shopId, name, bankAccount, bankAccountName, bankName FROM shop WHERE shopId = #{shopId}
+    </select>
 </mapper>
 </mapper>

+ 11 - 9
src/main/resources/mapper/OrderCommonMapper.xml

@@ -51,15 +51,15 @@
         cso.orderTime,
         cso.orderTime,
         cso.orderSubmitType,
         cso.orderSubmitType,
         cso.splitFlag,
         cso.splitFlag,
-        cso.sendOutStatus,
+        ifnull(cso.sendOutStatus, 1) as sendOutStatus,
         s.name AS shopName,
         s.name AS shopName,
         s.payway as payway,
         s.payway as payway,
         s.logo AS shopLogo,
         s.logo AS shopLogo,
         s.shopType as shopType,
         s.shopType as shopType,
         ifnull(cso.receiptAmount,0) as receiptAmount,
         ifnull(cso.receiptAmount,0) as receiptAmount,
         cso.eachDiscount,
         cso.eachDiscount,
-        ifnull(cso.realPay, cso.needPayAmount)as readPay,
-        cso.receiptStatus
+        ifnull(cso.realPay, cso.needPayAmount) as readPay,
+        ifnull(cso.receiptStatus, 1) as receiptStatus
         FROM cm_shop_order cso
         FROM cm_shop_order cso
         LEFT JOIN shop s ON cso.shopID = s.shopID
         LEFT JOIN shop s ON cso.shopID = s.shopID
         WHERE cso.delFlag = 0
         WHERE cso.delFlag = 0
@@ -170,7 +170,7 @@
         FROM cm_receipt_order_relation cror
         FROM cm_receipt_order_relation cror
                  LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
                  LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
         WHERE ((cror.orderID = #{orderId} AND cror.relationType = '2') OR
         WHERE ((cror.orderID = #{orderId} AND cror.relationType = '2') OR
-               (cror.orderID = #{shopOrderId} AND cror.relationType = '1'))
+               (cror.shopOrderId = #{shopOrderId} AND cror.relationType = '2'))
           AND cror.delFlag = '0'
           AND cror.delFlag = '0'
           AND cdr.delFlag = '0'
           AND cdr.delFlag = '0'
           AND cdr.receiptStatus = '3'
           AND cdr.receiptStatus = '3'
@@ -483,6 +483,7 @@
         cso.totalAmount,
         cso.totalAmount,
         cso.productAmount,
         cso.productAmount,
         cso.needPayAmount,
         cso.needPayAmount,
+        ifnull(cso.accountAmount,0) as accountAmount,
         cso.shopProductAmount,
         cso.shopProductAmount,
         cso.shopPostFee,
         cso.shopPostFee,
         IFNULL(cso.shopPostFlag, 0) AS shopPostFlag,
         IFNULL(cso.shopPostFlag, 0) AS shopPostFlag,
@@ -493,7 +494,7 @@
         cso.payStatus,
         cso.payStatus,
         cso.orderSubmitType,
         cso.orderSubmitType,
         cso.splitFlag,
         cso.splitFlag,
-        cso.sendOutStatus,
+        ifnull(cso.sendOutStatus, 1) as sendOutStatus,
         (select secondHandOrderFlag from cm_order where orderId = cso.orderId ) as secondHandOrderFlag,
         (select secondHandOrderFlag from cm_order where orderId = cso.orderId ) as secondHandOrderFlag,
         s.name AS shopName,
         s.name AS shopName,
         s.payway AS payway,
         s.payway AS payway,
@@ -502,7 +503,7 @@
         IFNULL(cso.receiptAmount,0) AS receiptAmount,
         IFNULL(cso.receiptAmount,0) AS receiptAmount,
         cso.eachDiscount,
         cso.eachDiscount,
         IFNULL(cso.realPay, cso.needPayAmount)AS readPay,
         IFNULL(cso.realPay, cso.needPayAmount)AS readPay,
-        cso.receiptStatus,
+        ifnull(cso.receiptStatus, 1) as receiptStatus,
         cso.shopStatus as status
         cso.shopStatus as status
         FROM cm_shop_order cso
         FROM cm_shop_order cso
         LEFT JOIN shop s ON cso.shopID = s.shopID
         LEFT JOIN shop s ON cso.shopID = s.shopID
@@ -584,7 +585,8 @@
                orderTime,
                orderTime,
                orderSubmitType,
                orderSubmitType,
                payStatus,
                payStatus,
-               sendOutStatus,
+               ifnull(sendOutStatus, 1) as sendOutStatus,
+               ifnull(receiptStatus, 1) as receiptStatus,
                splitFlag
                splitFlag
         FROM cm_shop_order
         FROM cm_shop_order
         WHERE delFlag = 0
         WHERE delFlag = 0
@@ -807,11 +809,11 @@
                cop.orderTime,
                cop.orderTime,
                cop.orderSubmitType,
                cop.orderSubmitType,
                cop.payStatus,
                cop.payStatus,
-               cop.sendOutStatus,
                cop.splitFlag,
                cop.splitFlag,
                cop.realPay,
                cop.realPay,
                cop.receiptAmount,
                cop.receiptAmount,
-               cop.receiptStatus,
+               ifnull(cop.sendOutStatus, 1) as sendOutStatus,
+               ifnull(cop.receiptStatus, 1) as receiptStatus,
                cop.splitCode,
                cop.splitCode,
                ifnull(cop.paySuccessCounter, 0) as paySuccessCounter,
                ifnull(cop.paySuccessCounter, 0) as paySuccessCounter,
                p.name                           as shopName,
                p.name                           as shopName,

+ 6 - 6
src/main/resources/mapper/OrderSellerMapper.xml

@@ -130,7 +130,7 @@
         cso.payStatus,
         cso.payStatus,
         cso.orderSubmitType,
         cso.orderSubmitType,
         cso.splitFlag,
         cso.splitFlag,
-        cso.sendOutStatus,
+        ifnull(cso.sendOutStatus, 1) as sendOutStatus,
         (select onlinePayFlag from cm_order where orderId = cso.orderId ) as onlinePay,
         (select onlinePayFlag from cm_order where orderId = cso.orderId ) as onlinePay,
         (select secondHandOrderFlag from cm_order where orderId = cso.orderId ) as secondHandOrderFlag,
         (select secondHandOrderFlag from cm_order where orderId = cso.orderId ) as secondHandOrderFlag,
         IFNULL(cso.receiptAmount,0) AS receiptAmount,
         IFNULL(cso.receiptAmount,0) AS receiptAmount,
@@ -140,7 +140,7 @@
         s.logo AS shopLogo,
         s.logo AS shopLogo,
         s.shopType AS shopType,
         s.shopType AS shopType,
         IFNULL(cso.realPay, cso.needPayAmount)AS readPay,
         IFNULL(cso.realPay, cso.needPayAmount)AS readPay,
-        cso.receiptStatus,
+        ifnull(cso.receiptStatus, 1) as receiptStatus,
         cso.shopStatus as status
         cso.shopStatus as status
         <if test="orderSubmitType == 3">
         <if test="orderSubmitType == 3">
             ,s.linkMan as serviceName
             ,s.linkMan as serviceName
@@ -293,7 +293,7 @@
         cso.payStatus,
         cso.payStatus,
         cso.orderSubmitType,
         cso.orderSubmitType,
         cso.splitFlag,
         cso.splitFlag,
-        cso.sendOutStatus,
+        ifnull(cso.sendOutStatus, 1) as sendOutStatus,
         (select onlinePayFlag from cm_order where orderId = cso.orderId ) as onlinePay,
         (select onlinePayFlag from cm_order where orderId = cso.orderId ) as onlinePay,
         (select secondHandOrderFlag from cm_order where orderId = cso.orderId ) as secondHandOrderFlag,
         (select secondHandOrderFlag from cm_order where orderId = cso.orderId ) as secondHandOrderFlag,
         IFNULL(cso.receiptAmount,0) AS receiptAmount,
         IFNULL(cso.receiptAmount,0) AS receiptAmount,
@@ -303,7 +303,7 @@
         s.logo AS shopLogo,
         s.logo AS shopLogo,
         s.shopType AS shopType,
         s.shopType AS shopType,
         IFNULL(cso.realPay, cso.needPayAmount)AS readPay,
         IFNULL(cso.realPay, cso.needPayAmount)AS readPay,
-        cso.receiptStatus,
+        ifnull(cso.receiptStatus, 1) as receiptStatus,
         cso.shopStatus as status
         cso.shopStatus as status
         FROM cm_shop_order cso
         FROM cm_shop_order cso
         LEFT JOIN shop s ON cso.shopID = s.shopID
         LEFT JOIN shop s ON cso.shopID = s.shopID
@@ -426,7 +426,7 @@
         cso.payStatus,
         cso.payStatus,
         cso.orderSubmitType,
         cso.orderSubmitType,
         cso.splitFlag,
         cso.splitFlag,
-        cso.sendOutStatus,
+        ifnull(cso.sendOutStatus, 1) as sendOutStatus,
         (select onlinePayFlag from cm_order where orderId = cso.orderId ) as onlinePay,
         (select onlinePayFlag from cm_order where orderId = cso.orderId ) as onlinePay,
         (select secondHandOrderFlag from cm_order where orderId = cso.orderId ) as secondHandOrderFlag,
         (select secondHandOrderFlag from cm_order where orderId = cso.orderId ) as secondHandOrderFlag,
         IFNULL(cso.receiptAmount,0) AS receiptAmount,
         IFNULL(cso.receiptAmount,0) AS receiptAmount,
@@ -436,7 +436,7 @@
         s.logo AS shopLogo,
         s.logo AS shopLogo,
         s.shopType AS shopType,
         s.shopType AS shopType,
         IFNULL(cso.realPay, cso.needPayAmount)AS readPay,
         IFNULL(cso.realPay, cso.needPayAmount)AS readPay,
-        cso.receiptStatus,
+        ifnull(cso.receiptStatus, 1) as receiptStatus,
         cso.shopStatus as status
         cso.shopStatus as status
         FROM cm_shop_order cso
         FROM cm_shop_order cso
         LEFT JOIN cm_order_product cop ON cso.shopOrderId = cop.shopOrderId
         LEFT JOIN cm_order_product cop ON cso.shopOrderId = cop.shopOrderId

+ 6 - 3
src/main/resources/mapper/ReceiptMapper.xml

@@ -816,7 +816,8 @@
         cso.orderTime,
         cso.orderTime,
         cso.orderSubmitType,
         cso.orderSubmitType,
         cso.payStatus,
         cso.payStatus,
-        cso.sendOutStatus,
+        ifnull(cso.sendOutStatus, 1) as sendOutStatus,
+        ifnull(cso.receiptStatus, 1) as receiptStatus,
         cso.splitFlag,
         cso.splitFlag,
         cso.shopOtherFee,
         cso.shopOtherFee,
         s.name AS shopName,
         s.name AS shopName,
@@ -876,7 +877,8 @@
         cso.orderTime,
         cso.orderTime,
         cso.orderSubmitType,
         cso.orderSubmitType,
         cso.payStatus,
         cso.payStatus,
-        cso.sendOutStatus,
+        ifnull(cso.sendOutStatus, 1) as sendOutStatus,
+        ifnull(cso.receiptStatus, 1) as receiptStatus,
         cso.splitFlag,
         cso.splitFlag,
         cso.shopOtherFee,
         cso.shopOtherFee,
         s.name AS shopName,
         s.name AS shopName,
@@ -938,7 +940,8 @@
                orderTime,
                orderTime,
                orderSubmitType,
                orderSubmitType,
                payStatus,
                payStatus,
-               sendOutStatus,
+               ifnull(sendOutStatus, 1) as sendOutStatus,
+               ifnull(receiptStatus, 1) as receiptStatus,
                splitFlag
                splitFlag
         FROM cm_shop_order
         FROM cm_shop_order
         WHERE shopOrderID = #{shopOrderId}
         WHERE shopOrderID = #{shopOrderId}

+ 57 - 8
src/main/resources/mapper/ShipMapper.xml

@@ -101,6 +101,8 @@
             a.orderID AS orderId,
             a.orderID AS orderId,
             a.orderNo,
             a.orderNo,
             a.shopID AS shopId,
             a.shopID AS shopId,
+            a.organizeID as organizeId,
+            IFNULL(a.isColdChina, 0) AS isColdChina,
             a.note,
             a.note,
             a.userID AS userId,
             a.userID AS userId,
             a.clubID AS clubId,
             a.clubID AS clubId,
@@ -116,12 +118,17 @@
             a.shopProductAmount,
             a.shopProductAmount,
             a.shopPostFee,
             a.shopPostFee,
             a.shopTaxFee,
             a.shopTaxFee,
+            IFNULL(a.shopPostFlag, 0) AS shopPostFlag,
             a.shouldPayShopAmount,
             a.shouldPayShopAmount,
             a.payedShopAmount,
             a.payedShopAmount,
+            ifnull(a.accountAmount,0) as accountAmount,
             a.orderTime,
             a.orderTime,
             a.orderSubmitType,
             a.orderSubmitType,
             a.payStatus,
             a.payStatus,
-            a.sendOutStatus,
+            ifnull(a.sendOutStatus, 1) as sendOutStatus,
+            ifnull(a.receiptStatus, 1) as receiptStatus,
+            a.refundStatus,
+            a.shopStatus as status,
             a.splitFlag
             a.splitFlag
         FROM cm_shop_order a
         FROM cm_shop_order a
         LEFT JOIN bp_order_userinfo ou ON  ou.orderId=a.orderId
         LEFT JOIN bp_order_userinfo ou ON  ou.orderId=a.orderId
@@ -146,6 +153,9 @@
                     AND a.payStatus = #{payStatus}
                     AND a.payStatus = #{payStatus}
                 </if>
                 </if>
             </if>
             </if>
+            <if test="organizeId != null">
+                a.organizeID = #{organizeId}
+            </if>
             <if test="receiver != null and receiver != ''">
             <if test="receiver != null and receiver != ''">
                 AND ou.shouHuoRen like concat('%',#{receiver},'%')
                 AND ou.shouHuoRen like concat('%',#{receiver},'%')
             </if>
             </if>
@@ -200,7 +210,7 @@
         </where>
         </where>
     </select>
     </select>
     <select id="getShopOrderRelation" resultType="com.caimei365.order.model.vo.DiscernReceiptVo">
     <select id="getShopOrderRelation" resultType="com.caimei365.order.model.vo.DiscernReceiptVo">
-        SELECT cdr.payWay, cror.orderId, cror.shopOrderId, cror.associateAmount
+        SELECT cdr.payWay, cdr.payType, cror.orderId, cror.shopOrderId, cror.associateAmount
             FROM cm_discern_receipt cdr
             FROM cm_discern_receipt cdr
         LEFT JOIN cm_receipt_order_relation cror ON (cror.receiptID = cdr.id AND cror.delFlag = '0')
         LEFT JOIN cm_receipt_order_relation cror ON (cror.receiptID = cdr.id AND cror.delFlag = '0')
         where cror.shopOrderId = #{shopOrderId}
         where cror.shopOrderId = #{shopOrderId}
@@ -218,6 +228,8 @@
             orderID AS orderId,
             orderID AS orderId,
             orderNo,
             orderNo,
             shopID AS shopId,
             shopID AS shopId,
+            organizeID as organizeId,
+            IFNULL(isColdChina, 0) AS isColdChina,
             note,
             note,
             userID AS userId,
             userID AS userId,
             clubID AS clubId,
             clubID AS clubId,
@@ -232,16 +244,20 @@
             needPayAmount,
             needPayAmount,
             shopProductAmount,
             shopProductAmount,
             shopPostFee,
             shopPostFee,
+            IFNULL(shopPostFlag, 0) AS shopPostFlag,
             shopTaxFee,
             shopTaxFee,
             shouldPayShopAmount,
             shouldPayShopAmount,
             payedShopAmount,
             payedShopAmount,
+            ifnull(accountAmount,0) as accountAmount,
             outStoreNum,
             outStoreNum,
             IFNULL(presentNum,0) AS presentNum,
             IFNULL(presentNum,0) AS presentNum,
             orderTime,
             orderTime,
             orderSubmitType,
             orderSubmitType,
             payStatus,
             payStatus,
+            ifnull(sendOutStatus, 1) as sendOutStatus,
+            ifnull(receiptStatus, 1) as receiptStatus,
+            refundStatus,
             shopStatus as status,
             shopStatus as status,
-            sendOutStatus,
             splitFlag
             splitFlag
         FROM cm_shop_order
         FROM cm_shop_order
         WHERE shopOrderID = #{shopOrderId} AND delFlag = '0'
         WHERE shopOrderID = #{shopOrderId} AND delFlag = '0'
@@ -259,10 +275,9 @@
         WHERE cmo.shopOrderID=#{shopOrderId}
         WHERE cmo.shopOrderID=#{shopOrderId}
     </select>
     </select>
 
 
-
-    <select id="getOrderReceiptStatus" resultType="java.lang.Integer">
-        SELECT receiptStatus FROM cm_order
-        WHERE orderID = #{orderId} AND delFlag = '0'
+    <select id="getShopOrderReceiptStatus" resultType="java.lang.Integer">
+        SELECT receiptStatus FROM cm_shop_order
+        WHERE shopOrderId = #{shopOrderId} AND delFlag = '0'
     </select>
     </select>
     <select id="getLogisticsCompany" resultType="com.caimei365.order.model.vo.CompanyVo">
     <select id="getLogisticsCompany" resultType="com.caimei365.order.model.vo.CompanyVo">
         SELECT id, value, label
         SELECT id, value, label
@@ -428,6 +443,38 @@
         SELECT userID FROM shop WHERE shopID=#{shopId}
         SELECT userID FROM shop WHERE shopID=#{shopId}
     </select>
     </select>
 
 
+    <select id="findWaitPay" resultType="java.lang.Double">
+        SELECT ifnull((SELECT IFNULL(realPay, needPayAmount) - receiptAmount  FROM cm_shop_order WHERE shopOrderId = #{shopOrderId}) - ifnull(SUM(receiptAmount),0),0)
+        FROM cm_discern_receipt cdr
+                 LEFT JOIN cm_receipt_order_relation cror ON cdr.id = cror.receiptID
+        WHERE cror.shopOrderId = #{shopOrderId}
+    </select>
+    <insert id="insertOrderReceipt" keyColumn="id" keyProperty="id"
+            parameterType="com.caimei365.order.model.vo.ReceiptVo" useGeneratedKeys="true">
+        insert into cm_discern_receipt(payWay, payType, receiptType, receiptStatus, receiptAmount, confirmType,
+                                       receiptDate, confirmDate, reviewDate, delFlag, receStatct)
+        values (#{payWay}, #{payType}, #{receiptType}, #{receiptStatus}, #{receiptAmount}, 4, now(), now(), now(), 0, 0)
+    </insert>
+    <insert id="insertOrderRelation">
+        INSERT INTO cm_receipt_order_relation(relationType,
+                                              receiptID,
+                                              associateAmount,
+                                              shopOrderId,
+                                              delFlag)
+        VALUES (#{relationType},
+                #{receiptId},
+                #{receiptAmount},
+                #{shopOrderId},
+                0)
+    </insert>
+    <select id="findOrderStatus" resultType="java.lang.String">
+        select status from cm_order where orderId = #{orderId}
+    </select>
+    <update id="updateReceiptStatus">
+        update cm_shop_order
+        set receiptStatus = #{status}
+        where shopOrderId = #{shopOrderId}
+    </update>
     <select id="findList" resultType="com.caimei365.order.model.dto.OrderRemarkDto">
     <select id="findList" resultType="com.caimei365.order.model.dto.OrderRemarkDto">
         SELECT a.id           AS "id",
         SELECT a.id           AS "id",
                a.orderId      AS "orderId",
                a.orderId      AS "orderId",
@@ -437,7 +484,7 @@
                cu.accountName AS "createName"
                cu.accountName AS "createName"
         FROM cm_order_remark a
         FROM cm_order_remark a
                  LEFT JOIN cm_mall_admin_user cu ON cu.id = a.createBy
                  LEFT JOIN cm_mall_admin_user cu ON cu.id = a.createBy
-        where a.orderId = #{orderId}
+        where a.shopOrderId = #{shopOrderId}
         ORDER BY a.createDate
         ORDER BY a.createDate
     </select>
     </select>
 
 
@@ -469,10 +516,12 @@
     <insert id="insert" parameterType="com.caimei365.order.model.dto.OrderRemarkDto" keyProperty="id"
     <insert id="insert" parameterType="com.caimei365.order.model.dto.OrderRemarkDto" keyProperty="id"
             useGeneratedKeys="true">
             useGeneratedKeys="true">
         INSERT INTO cm_order_remark(orderID,
         INSERT INTO cm_order_remark(orderID,
+                                    shopOrderId,
                                     remarks,
                                     remarks,
                                     createBy,
                                     createBy,
                                     createDate)
                                     createDate)
         VALUES (#{orderId},
         VALUES (#{orderId},
+                #{shopOrderId},
                 #{remarks},
                 #{remarks},
                 #{createBy},
                 #{createBy},
                 now())
                 now())

+ 10 - 58
src/main/resources/mapper/SubmitMapper.xml

@@ -168,58 +168,6 @@
         SET onlinePayWays = #{onlinePayWays}
         SET onlinePayWays = #{onlinePayWays}
         WHERE orderID = #{orderId}
         WHERE orderID = #{orderId}
     </update>
     </update>
-    <update id="updateOrderProduct">
-        update cm_order_product
-        set price                   = #{price},
-            costPrice               = #{costPrice},
-            totalAmount             = #{totalAmount},
-            totalFee                = #{totalFee},
-            shouldPayFee            = #{shouldPayFee},
-            ladderPriceFlag         = #{ladderPriceFlag},
-            taxRate                 = #{taxRate},
-            addedValueTax           = #{addedValueTax},
-            totalAddedValueTax      = #{totalAddedValueTax},
-            shouldPayTotalTax       = #{shouldPayTotalTax},
-            singleShouldPayTotalTax = #{singleShouldPayTotalTax},
-            shopProductAmount       = #{shopProductAmount},
-            singleShopFee           = #{singleShopFee}
-        where orderProductId = #{orderProductId}
-    </update>
-    <update id="updateShopOrder">
-        update cm_shop_order
-        set
-        <if test="status != null">
-            shopStatus = #{status},
-        </if>
-        <if test="realPay != null">
-            realPay = #{realPay},
-        </if>
-        <if test="receiptAmount != null">
-            receiptAmount = #{receiptAmount},
-        </if>
-        <if test="accountAmount != null">
-            accountAmount = #{accountAmount},
-        </if>
-        <if test="productAmount != null">
-            productAmount = #{productAmount},
-        </if>
-        <if test="totalAmount != null">
-            totalAmount = #{totalAmount},
-        </if>
-        <if test="needPayAmount != null">
-            needPayAmount = #{needPayAmount},
-        </if>
-        <if test="promotionFullReduction != null">
-            promotionFullReduction = #{promotionFullReduction},
-        </if>
-        <if test="receiptStatus != null">
-            receiptStatus = #{receiptStatus},
-        </if>
-        <if test="shopProductAmount != null">
-            shopProductAmount = #{shopProductAmount}
-        </if>
-        where shopOrderId = #{shopOrderId}
-    </update>
     <select id="getOrganizeSkuInfo" resultType="com.caimei365.order.model.po.CmOrganizeSkuPo">
     <select id="getOrganizeSkuInfo" resultType="com.caimei365.order.model.po.CmOrganizeSkuPo">
         SELECT skuId,
         SELECT skuId,
                productId,
                productId,
@@ -300,17 +248,21 @@
                p.`name`           AS `name`,
                p.`name`           AS `name`,
                p.mainImage        AS image,
                p.mainImage        AS image,
                cs.price,
                cs.price,
+               cs.costPrice,
+               IFNULL(cs.costCheckFlag, 1) AS costCheckFlag,
+               cs.shopPercent as costProportional,
                p.productCategory,
                p.productCategory,
                cs.ladderPriceFlag,
                cs.ladderPriceFlag,
                p.includedTax,
                p.includedTax,
                p.invoiceType,
                p.invoiceType,
-               p.taxPoint         AS taxRate,
-               cs.unit            AS productUnit,
-               p.supplierTaxPoint AS shopTaxRate,
-               p.splitCode        as splitCode
+               p.taxPoint                 AS taxRate,
+               cs.unit                     AS productUnit,
+               cs.normalPrice,
+               p.supplierTaxPoint         AS shopTaxRate,
+               p.splitCode as splitCode
         FROM product p
         FROM product p
-                 LEFT JOIN cm_sku cs ON cs.productId = p.productId
-        WHERE cs.skuId = #{skuId}
+                 LEFT JOIN cm_sku cs on p.productID = cs.productId
+        WHERE cs.skuId = #{skuId} and cs.organizeId = 4
     </select>
     </select>
     <select id="getClauseNameById" resultType="java.lang.String">
     <select id="getClauseNameById" resultType="java.lang.String">
         SELECT `name`
         SELECT `name`