Bladeren bron

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

# Conflicts:
#	src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java
Duan_xu 3 jaren geleden
bovenliggende
commit
d2c1e606d5
34 gewijzigde bestanden met toevoegingen van 2174 en 1439 verwijderingen
  1. 52 11
      src/main/java/com/caimei365/order/components/HeliPayUtil.java
  2. 70 0
      src/main/java/com/caimei365/order/components/OnlinePostFormUtil.java
  3. 31 28
      src/main/java/com/caimei365/order/components/OrderCommonService.java
  4. 76 23
      src/main/java/com/caimei365/order/controller/HeliPayApi.java
  5. 181 36
      src/main/java/com/caimei365/order/controller/HeliPayNonOrderApi.java
  6. 4 0
      src/main/java/com/caimei365/order/mapper/BaseMapper.java
  7. 5 5
      src/main/java/com/caimei365/order/mapper/OrderClubMapper.java
  8. 4 0
      src/main/java/com/caimei365/order/mapper/OrderCommonMapper.java
  9. 14 7
      src/main/java/com/caimei365/order/mapper/PayOrderMapper.java
  10. 5 0
      src/main/java/com/caimei365/order/mapper/SubmitMapper.java
  11. 5 0
      src/main/java/com/caimei365/order/model/dto/PayLinkDto.java
  12. 4 0
      src/main/java/com/caimei365/order/model/po/OrderPo.java
  13. 4 0
      src/main/java/com/caimei365/order/model/po/OrderProductPo.java
  14. 4 1
      src/main/java/com/caimei365/order/model/po/OrderShopPo.java
  15. 40 0
      src/main/java/com/caimei365/order/model/vo/OnlineCheckVo.java
  16. 4 0
      src/main/java/com/caimei365/order/model/vo/OrderPayLinkVo.java
  17. 4 0
      src/main/java/com/caimei365/order/model/vo/OrderProductVo.java
  18. 16 2
      src/main/java/com/caimei365/order/model/vo/ShopOrderVo.java
  19. 41 9
      src/main/java/com/caimei365/order/service/HeliPayNonOrderService.java
  20. 10 8
      src/main/java/com/caimei365/order/service/HeliPayService.java
  21. 4 0
      src/main/java/com/caimei365/order/service/PayOrderService.java
  22. 487 532
      src/main/java/com/caimei365/order/service/impl/HeliPayNonOrderServiceImpl.java
  23. 312 241
      src/main/java/com/caimei365/order/service/impl/HeliPayServiceImpl.java
  24. 156 57
      src/main/java/com/caimei365/order/service/impl/PayOrderServiceImpl.java
  25. 8 1
      src/main/java/com/caimei365/order/service/impl/ReceiptServiceImpl.java
  26. 5 1
      src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java
  27. 2 2
      src/main/java/com/caimei365/order/utils/ImageUtil.java
  28. 9 2
      src/main/resources/mapper/BaseMapper.xml
  29. 1 3
      src/main/resources/mapper/CartSellerMapper.xml
  30. 5 5
      src/main/resources/mapper/OrderClubMapper.xml
  31. 533 445
      src/main/resources/mapper/OrderCommonMapper.xml
  32. 39 7
      src/main/resources/mapper/PayOrderMapper.xml
  33. 33 13
      src/main/resources/mapper/SubmitMapper.xml
  34. 6 0
      src/test/java/com/caimei365/order/OrderApplicationTests.java

+ 52 - 11
src/main/java/com/caimei365/order/components/HeliPayUtil.java

@@ -33,6 +33,8 @@ public class HeliPayUtil {
     private String secondHandUrl;
     @Value("${pay.vip-notify-url}")
     private String superVipUrl;
+    @Value("${pay.auth-vip-notify-url}")
+    private String authVipUrl;
     @Value("${wx.mini-app-id}")
     private String miniAppId;
     @Value("${pay.notify-url}")
@@ -41,6 +43,8 @@ public class HeliPayUtil {
     private String unionPay;
     @Value("${pay.vip-union-url}")
     private String vipUnionPay;
+    @Value("${pay.auth-vip-union-url}")
+    private String authVipUnionPay;
     @Value("${pay.second-union-url}")
     private String secondUnionPay;
     @Value("${pay.coupon-notify-url}")
@@ -98,6 +102,19 @@ public class HeliPayUtil {
             pay.setP18_desc(attach);
             //收款账号
             pay.setP3_customerNumber(Constant.CUSTOMERNUM);
+        } else if ("authVip".equals(payFlag)) {
+            VipRecordBo record = payOrderMapper.getAuthVipRecord(heliDto.getVipRecordId());
+            Double price = payOrderMapper.getAuthVipPackagePrice(record.getPackageId());
+            //会员
+            orderId = record.getUserId() + "A" + heliDto.getVipRecordId() + "V" + record.getPackageId() + "T" + time + environment;
+            pay.setP9_orderAmount(price.toString());
+            pay.setP12_notifyUrl(authVipUrl);
+            String product = "采美订单" + orderId;
+            pay.setP15_goodsName(product);
+            String attach = record.getPackageId() + "," + record.getUserId() + "," + heliDto.getVipRecordId() + "," + BizType.getNumByType(heliDto.getPayType());
+            pay.setP18_desc(attach);
+            //收款账号
+            pay.setP3_customerNumber(Constant.CUSTOMERNUM);
         }else if("coupon".equals(payFlag)){
             Double couponPrice = payOrderMapper.getCouponPrice(heliDto.getCouponRecordId());
             orderId = heliDto.getUserId() + "C" + heliDto.getCouponId() + "R" + heliDto.getCouponRecordId() + "T" + time + environment;
@@ -111,9 +128,9 @@ public class HeliPayUtil {
             pay.setP3_customerNumber(Constant.CUSTOMERNUM);
         } else if ("order".equals(payFlag)) {
             //普通订单
-            OrderVo order = orderCommonMapper.getOrderByOrderId(heliDto.getOrderId());
+            OrderVo order = orderCommonMapper.getOrderByShopOrderId(heliDto.getShopOrderId());
             orderId = order.getOrderNo() + "T" + time + environment;
-            pay.setP9_orderAmount(heliDto.getPayAmount().toString());
+            pay.setP9_orderAmount(heliDto.getPayAmount());
             pay.setP12_notifyUrl(notifyUrl);
             String product = "采美订单" + order.getOrderNo();
             pay.setP15_goodsName(product);
@@ -170,6 +187,18 @@ public class HeliPayUtil {
             pay.setP14_desc(attach);
             //收款账号
             pay.setP3_customerNumber(Constant.CUSTOMERNUM);
+        }else if ("authVip".equals(payFlag)) {
+            VipRecordBo record = payOrderMapper.getAuthVipRecord(heliDto.getVipRecordId());
+            Double price = payOrderMapper.getAuthVipPackagePrice(record.getPackageId());
+            pay.setP5_orderAmount(price.toString());
+            pay.setP9_notifyUrl(superVipUrl);
+            orderId = record.getUserId() + "A" + heliDto.getVipRecordId() + "V" + record.getPackageId() + "T" + time + environment;
+            String product = "采美订单" + orderId;
+            pay.setP12_goodsName(product);
+            String attach = record.getPackageId() + "," + record.getUserId() + "," + heliDto.getVipRecordId() + "," + BizType.getNumByType(heliDto.getPayType());
+            pay.setP14_desc(attach);
+            //收款账号
+            pay.setP3_customerNumber(Constant.CUSTOMERNUM);
         }else if("coupon".equals(payFlag)){
             Double couponPrice = payOrderMapper.getCouponPrice(heliDto.getCouponRecordId());
             orderId = heliDto.getUserId() + "C" + heliDto.getCouponId() + "R" + heliDto.getCouponRecordId() + "T" + time + environment;
@@ -184,9 +213,9 @@ public class HeliPayUtil {
         }
         else if ("order".equals(payFlag)) {
             //以子订单为单位付款,商户号为商品的分帐号
-            OrderVo order = orderCommonMapper.getOrderByOrderId(heliDto.getOrderId());
+            OrderVo order = orderCommonMapper.getOrderByShopOrderId(heliDto.getShopOrderId());
             orderId = order.getOrderNo() + "T" + time + environment;
-            pay.setP5_orderAmount(heliDto.getPayAmount().toString());
+            pay.setP5_orderAmount(heliDto.getPayAmount());
             pay.setP9_notifyUrl(notifyUrl);
             String product = "采美订单" + order.getOrderNo();
             pay.setP12_goodsName(product);
@@ -253,17 +282,29 @@ public class HeliPayUtil {
                 String attach = heliDto.getCouponId() + "," + heliDto.getUserId() + "," + heliDto.getCouponRecordId() + "," + BizType.getNumByType(heliDto.getPayType())+","+heliDto.getSource();
                 URLEncoder.encode(attach,"UTF-8");
                 pay.setP15_desc(attach);
-            }
-            else if ("order".equals(payFlag)) {
-                OrderVo order = orderCommonMapper.getOrderByOrderId(heliDto.getOrderId());
+            } else if ("authVip".equals(payFlag)) {
+                pay.setP3_customerNumber(Constant.CUSTOMERNUM);
+                VipRecordBo record = payOrderMapper.getAuthVipRecord(heliDto.getVipRecordId());
+                Double price = payOrderMapper.getAuthVipPackagePrice(record.getPackageId());
+                pay.setP4_orderAmount(price.toString());
+                pay.setP12_serverCallback(authVipUnionPay);
+                orderId = record.getUserId() + "A" + heliDto.getVipRecordId() + "V" + record.getPackageId() + "T" + time + environment;
+                String product = "采美订单" + orderId;
+                URLEncoder.encode(product,"UTF-8");
+                pay.setP8_goodsName(product);
+                String attach = record.getPackageId() + "," + record.getUserId() + "," + heliDto.getVipRecordId() + "," + BizType.getNumByType(heliDto.getUserType());
+                URLEncoder.encode(attach,"UTF-8");
+                pay.setP15_desc(attach);
+            } else if ("order".equals(payFlag)) {
+                OrderVo order = orderCommonMapper.getOrderByShopOrderId(heliDto.getShopOrderId());
                 orderId = order.getOrderNo() + "T" + time + environment;
-                pay.setP4_orderAmount(heliDto.getPayAmount().toString());
+                pay.setP4_orderAmount(heliDto.getPayAmount());
                 pay.setP12_serverCallback(unionPay);
                 String product = "采美订单" + order.getOrderNo();
-                URLEncoder.encode(product,"UTF-8");
+                URLEncoder.encode(product, "UTF-8");
                 pay.setP8_goodsName(product);
-                String attach = order.getOrderId() + "," + BizType.getNumByType(heliDto.getUserType())+","+heliDto.getShopOrderId();;
-                URLEncoder.encode(attach,"UTF-8");
+                String attach = order.getOrderId() + "," + BizType.getNumByType(heliDto.getUserType()) + "," + heliDto.getShopOrderId();
+                URLEncoder.encode(attach, "UTF-8");
                 pay.setP15_desc(attach);
             }
             pay.setP1_bizType("OnlinePay");

+ 70 - 0
src/main/java/com/caimei365/order/components/OnlinePostFormUtil.java

@@ -0,0 +1,70 @@
+package com.caimei365.order.components;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.FormBody;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author zzj
+ */
+
+@Slf4j
+public class OnlinePostFormUtil {
+
+    public static OkHttpClient client = new OkHttpClient.Builder()
+            .connectTimeout(3, TimeUnit.SECONDS)
+            .readTimeout(20, TimeUnit.SECONDS)
+            .build();
+
+    public static <T> T postForm(Map<String, String> params, String url, String sign, Class<T> clazz) {
+        FormBody.Builder builder = new FormBody.Builder();
+        for (Map.Entry<String, String> entry : params.entrySet()) {
+            builder.add(entry.getKey(), entry.getValue());
+        }
+        builder.add("sign", sign);
+
+        Request request = new Request.Builder() // okHttp post
+                .url(url)
+                .post(builder.build())
+                .build();
+
+        Response response = null;
+        try {
+            response = client.newCall(request).execute();
+        } catch (IOException e) {
+            throw new IllegalStateException("请求出错", e);
+        }
+        if (!response.isSuccessful()) {
+            try {
+                log.info(response.body().string());
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            throw new RuntimeException("请求失败了: http response code: " + response.code());
+        }
+
+        okhttp3.ResponseBody body = response.body();
+        String content = null;
+        try {
+            content = body.string();
+        } catch (IOException e) {
+            throw new IllegalStateException("IO异常", e);
+        }
+        JSONObject res = JSON.parseObject(content);
+        //网银查询回调
+        if (!"SUCCESS".equals(res.getString("rt10_orderStatus"))) {
+            log.info("网银查询成功结果------->"+res.toString());
+        }
+        /** rt4_success 为 true,需验签  **/
+        return res.toJavaObject(clazz);
+    }
+
+}

+ 31 - 28
src/main/java/com/caimei365/order/components/OrderCommonService.java

@@ -31,6 +31,7 @@ public class OrderCommonService {
     private String domain;
     @Resource
     private OrderCommonMapper orderCommonMapper;
+
     /**
      * 设置订单状态
      */
@@ -58,7 +59,7 @@ public class OrderCommonService {
      */
     public void getShopOrderData(OrderVo order) {
         // 子订单
-        if (StringUtils.isEmpty(order.getShopOrderIds())){
+        if (StringUtils.isEmpty(order.getShopOrderIds())) {
             return;
         }
         String[] shopOrderIdArr = order.getShopOrderIds().split(",");
@@ -96,13 +97,16 @@ public class OrderCommonService {
                 if (null != orderProduct.getSvipPriceFlag() && 1 == orderProduct.getSvipPriceFlag()) {
                     if (1 == orderProduct.getSvipPriceType()) {
                         orderProduct.setSvipPriceTag(MathUtil.div(orderProduct.getSvipDiscount(), 10, 1) + "折");
-                    } else if (2 == orderProduct.getSvipPriceType()){
+                    } else if (2 == orderProduct.getSvipPriceType()) {
                         orderProduct.setSvipPriceTag("¥" + orderProduct.getDiscountPrice());
                     }
                 }
             });
             shopOrder.setOrderProductList(orderProductList);
             shopOrder.setShopLogo(ImageUtil.getImageUrl("shopLogo", shopOrder.getShopLogo(), domain));
+            if (0 == order.getOnlinePayFlag()) {
+                shopOrder.setObligation(MathUtil.sub(shopOrder.getRealPay(), shopOrder.getReceiptAmount()).doubleValue());
+            }
         });
         // 过滤运费商品
         shopOrderList.removeIf(shopOrder -> shopOrder.getShopId() == 998);
@@ -112,6 +116,7 @@ public class OrderCommonService {
 
     /**
      * 设置付款金额
+     *
      * @param order OrderVo
      */
     public List<DiscernReceiptVo> getDiscernReceiptAndSetOrder(OrderVo order) {
@@ -132,9 +137,7 @@ public class OrderCommonService {
             //返佣款
             if (!order.getShopOrderIds().contains(",")) {
                 Double tempAmount = orderCommonMapper.getRebateAmountByShopOrder(Integer.parseInt(order.getShopOrderIds()));
-                if (null == tempAmount) {
-                    order.setOnlinePayFlag(0);
-                } else {
+                if (null != tempAmount) {
                     order.setOnlinePayFlag(1);
                 }
             }
@@ -143,28 +146,27 @@ public class OrderCommonService {
         int offlineCount = orderCommonMapper.countOfflinePayment(order.getOrderId());
         if (offlineCount > 0) {
             order.setOnlinePayFlag(1);
-        } else {
-            order.setOnlinePayFlag(0);
-        }
-        //付供应商总金额 + 默认手续费 > 订单总金额
-        Double payTotalFee = order.getPayTotalFee();
-        Double handlingFee = MathUtil.mul(payTotalFee, 0.0038, 2).doubleValue();
-        if (MathUtil.compare(handlingFee, 8) < 0) {
-            handlingFee = 8d;
-        }
-        List<Double> shouldPayShopAmount = orderCommonMapper.getShouldPayShopAmountList(order.getOrderId());
-        if (!shouldPayShopAmount.isEmpty()) {
-            AtomicDouble finalHandlingFee = new AtomicDouble(handlingFee);
-            shouldPayShopAmount.forEach(amount -> {
-                finalHandlingFee.set(MathUtil.add(finalHandlingFee.get(), amount).doubleValue());
-            });
-            handlingFee = finalHandlingFee.get();
-        }
-        if (MathUtil.compare(payTotalFee, handlingFee) < 0) {
-            order.setPayButton(true);
-        } else {
-            order.setPayButton(false);
         }
+
+//        //付供应商总金额 + 默认手续费 > 订单总金额
+//        Double payTotalFee = order.getPayTotalFee();
+//        Double handlingFee = MathUtil.mul(payTotalFee, 0.0038, 2).doubleValue();
+//        if (MathUtil.compare(handlingFee, 8) < 0) {
+//            handlingFee = 8d;
+//        }
+//        List<Double> shouldPayShopAmount = orderCommonMapper.getShouldPayShopAmountList(order.getOrderId());
+//        if (!shouldPayShopAmount.isEmpty()) {
+//            AtomicDouble finalHandlingFee = new AtomicDouble(handlingFee);
+//            shouldPayShopAmount.forEach(amount -> {
+//                finalHandlingFee.set(MathUtil.add(finalHandlingFee.get(), amount).doubleValue());
+//            });
+//            handlingFee = finalHandlingFee.get();
+//        }
+//        if (MathUtil.compare(payTotalFee, handlingFee) < 0) {
+//            order.setPayButton(true);
+//        } else {
+//            order.setPayButton(false);
+//        }
         //待付总金额
         order.setPendingPayments(MathUtil.sub(order.getPayableAmount(), receiptAmount).doubleValue());
         //支付总金额
@@ -174,7 +176,8 @@ public class OrderCommonService {
 
     /**
      * 设置搜索关键词历史记录
-     * @param userId 用户Id
+     *
+     * @param userId     用户Id
      * @param searchWord 搜索关键词
      */
     public void setHistoryRecord(Integer userId, String searchWord) {
@@ -187,7 +190,7 @@ public class OrderCommonService {
         // 查询搜索关键词历史记录是否存在
         Integer recordId = orderCommonMapper.getSearchHistoryIdByWord(searchWord);
         // 保存搜索关键词历史记录
-        if (null != recordId && recordId >0) {
+        if (null != recordId && recordId > 0) {
             historyRecord.setId(recordId);
             orderCommonMapper.updateSearchHistory(historyRecord);
         } else {

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

@@ -7,6 +7,7 @@ import com.caimei365.order.model.dto.PayDto;
 import com.caimei365.order.model.dto.PayLinkDto;
 import com.caimei365.order.model.vo.AccountResVo;
 import com.caimei365.order.model.vo.NotifyResponseVo;
+import com.caimei365.order.model.vo.ShopOrderVo;
 import com.caimei365.order.model.vo.UnionResVo;
 import com.caimei365.order.service.HeliPayService;
 import com.caimei365.order.service.PayOrderService;
@@ -24,6 +25,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.beans.IntrospectionException;
 import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
+import java.util.List;
 import java.util.Map;
 
 
@@ -42,6 +44,16 @@ public class HeliPayApi {
     private final HeliPayService heliPayService;
     private final PayOrderService payOrderService;
 
+    @ApiOperation("获取子订单信息")
+    @ApiImplicitParam(required = true, name = "orderId", value = "订单Id")
+    @GetMapping("/shoporders")
+    public ResponseJson<List<ShopOrderVo>> getShopOrders(Integer orderId) {
+        if (null == orderId) {
+            return ResponseJson.error("订单Id不能为空!", null);
+        }
+        return heliPayService.getShopOrders(orderId);
+    }
+
     /**
      * 订单支付前效验付款规则
      */
@@ -84,7 +96,7 @@ public class HeliPayApi {
      * 收银台数据显示
      */
     @ApiOperation("收银台数据(旧:/PayOrder/checkoutCounter)")
-    @ApiImplicitParam(required = false, name = "orderId", value = "订单Id")
+    @ApiImplicitParam(required = true, name = "orderId", value = "订单Id")
     @GetMapping("/checkout/counter")
     public ResponseJson<Map<String, Object>> getCheckoutCounter(Integer orderId) {
         if (null == orderId) {
@@ -93,6 +105,19 @@ public class HeliPayApi {
         return payOrderService.getCheckoutCounter(orderId);
     }
 
+    /**
+     * 收银台数据显示
+     */
+    @ApiOperation("收银台数据(旧:/PayOrder/checkoutCounter)")
+    @ApiImplicitParam(required = true, name = "orderId", value = "订单Id")
+    @GetMapping("/checkout/shoporders")
+    public ResponseJson<Map<String, Object>> getCheckoutShopOrders(Integer shopOrderId) {
+        if (null == shopOrderId) {
+            return ResponseJson.error("子订单Id不能为空!", null);
+        }
+        return payOrderService.getCheckoutShopOrders(shopOrderId);
+    }
+
 
     /**
      * 生成网银支付链接
@@ -105,12 +130,6 @@ public class HeliPayApi {
     @ApiOperation("生成网银支付链接(旧:/PayOrder/payLink)")
     @PostMapping("/link")
     public ResponseJson<String> getPayLink(PayLinkDto payLinkDto) {
-        if (null == payLinkDto.getOrderId() && null == payLinkDto.getVipRecordId()) {
-            return ResponseJson.error("订单Id和会员购买记录Id不能同时为空!", null);
-        }
-        if (null != payLinkDto.getOrderId() && null != payLinkDto.getVipRecordId()) {
-            return ResponseJson.error("订单Id和会员购买记录Id不能同时出现!", null);
-        }
         return payOrderService.getPayLink(payLinkDto);
     }
 
@@ -141,23 +160,23 @@ public class HeliPayApi {
     /**
      * 判断此次支付是否完成
      *
-     * @param orderId           订单id
+     * @param shopOrderId           订单id
      * @param paySuccessCounter 付款次数
      */
     @ApiOperation("判断此次支付是否完成(旧:/PayOrder/payWhetherSuccess)")
     @ApiImplicitParams({
-            @ApiImplicitParam(required = false, name = "orderId", value = "订单id"),
+            @ApiImplicitParam(required = false, name = "shopOrderId", value = "订单id"),
             @ApiImplicitParam(required = false, name = "paySuccessCounter", value = "付款次数")
     })
     @GetMapping("/result/check")
-    public ResponseJson<String> payWhetherSuccess(Integer orderId, Integer paySuccessCounter) {
-        if (null == orderId) {
-            return ResponseJson.error("订单Id不能为空!", null);
+    public ResponseJson<String> payWhetherSuccess(Integer shopOrderId, Integer paySuccessCounter) {
+        if (null == shopOrderId) {
+            return ResponseJson.error("订单Id不能为空!", null);
         }
         if (null == paySuccessCounter) {
             return ResponseJson.error("付款次数不能为空!", null);
         }
-        return payOrderService.payWhetherSuccess(orderId, paySuccessCounter);
+        return payOrderService.payWhetherSuccess(shopOrderId, paySuccessCounter);
     }
 
     /**
@@ -166,21 +185,52 @@ public class HeliPayApi {
      * @param mbOrderId 平台唯一流水号
      */
     @ApiOperation("查询本次支付订单结果(旧:/PayOrder/findOrderStatus)")
-    @ApiImplicitParam(required = false, name = "mbOrderId", value = "平台唯一流水号")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "mbOrderId", value = "平台唯一流水号"),
+            @ApiImplicitParam(required = true, name = "orderFlag", value = "订单标识:0非订单,1订单"),
+            @ApiImplicitParam(required = false, name = "shopOrderId", value = "子订单Id")
+    })
     @GetMapping("/result/json")
-    public ResponseJson<JSONObject> getPayOrderResult(String mbOrderId) {
+    public ResponseJson<JSONObject> getPayOrderResult(String mbOrderId,Integer orderFlag,Integer shopOrderId) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
         if (null == mbOrderId) {
             return ResponseJson.error("平台唯一流水号不能为空!", null);
         }
-        return heliPayService.getPayOrderResult(mbOrderId);
+        if (null == orderFlag) {
+            return ResponseJson.error("订单标识不能为空!", null);
+        }
+        return heliPayService.getPayOrderResult(mbOrderId, orderFlag,shopOrderId);
     }
 
     /**
-     * 合利宝pc微信支付宝二维码
+     * 查询网银本次支付订单结果
+     *
+     * @param mbOrderId 平台唯一流水号
+     */
+    @ApiOperation("查询网银本次支付订单结果(旧:/PayOrder/findOrderStatus)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "mbOrderId", value = "平台唯一流水号"),
+            @ApiImplicitParam(required = true, name = "orderFlag", value = "订单标识:0非订单,1订单"),
+            @ApiImplicitParam(required = false, name = "shopOrderId", value = "子订单Id")
+    })
+    @GetMapping("/result/union")
+    public ResponseJson<JSONObject> getUnionResult(String mbOrderId,Integer orderFlag,Integer shopOrderId) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (null == mbOrderId) {
+            return ResponseJson.error("平台唯一流水号不能为空!", null);
+        }
+        if (null == orderFlag) {
+            return ResponseJson.error("订单标识不能为空!", null);
+        }
+        return heliPayService.getUnionResult(mbOrderId, orderFlag,shopOrderId);
+    }
+    /**
+     * 合利宝pc支付宝二维码
      */
-    @ApiOperation("合利宝pc微信/支付宝扫码支付")
+    @ApiOperation("合利宝支付宝扫码支付")
     @PostMapping("/scan/pay")
-    public ResponseJson<JSONObject> payByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
+    public ResponseJson<JSONObject> payByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (StringUtils.isBlank(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空!", null);
+        }
         if (null == heliDto.getShopOrderId()) {
             return ResponseJson.error("子订单Id不能为空!", null);
         }
@@ -192,7 +242,10 @@ public class HeliPayApi {
      */
     @ApiOperation("合利宝微信小程序/公众号支付")
     @PostMapping("/online")
-    public ResponseJson<JSONObject> payOnline(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
+    public ResponseJson<JSONObject> payOnline(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (StringUtils.isBlank(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空!", null);
+        }
         if (null == heliDto.getShopOrderId()) {
             return ResponseJson.error("子订单Id不能为空!", null);
         }
@@ -205,8 +258,8 @@ public class HeliPayApi {
     @ApiOperation("合利宝网银支付")
     @PostMapping("/union")
     public ResponseJson<String> link(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
-        if (null == heliDto.getOrderId()) {
-            return ResponseJson.error("订单Id不能为空!", null);
+        if (StringUtils.isBlank(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空!", null);
         }
         if (null == heliDto.getShopOrderId()) {
             return ResponseJson.error("子订单Id不能为空!", null);
@@ -261,7 +314,7 @@ public class HeliPayApi {
 
     @ApiOperation("银行通道码获取")
     @GetMapping("/bankcode")
-    public ResponseJson<JSONObject> bankcode() {
+    public ResponseJson<Map<String, Object>> bankcode() {
         return heliPayService.bankCode();
     }
 

+ 181 - 36
src/main/java/com/caimei365/order/controller/HeliPayNonOrderApi.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.HeliDto;
 import com.caimei365.order.model.dto.PayCouponDto;
+import com.caimei365.order.model.dto.PayVipDto;
 import com.caimei365.order.model.vo.NotifyResponseVo;
 import com.caimei365.order.model.vo.UnionResVo;
 import com.caimei365.order.service.HeliPayNonOrderService;
@@ -43,7 +44,10 @@ public class HeliPayNonOrderApi {
      */
     @ApiOperation("二手发布-微信线上支付(旧:/PayOrder/appletsSecondHandPay)(/PayOrder/secondHandPay[WEIXIN])")
     @PostMapping("/second/wechat")
-    public ResponseJson<JSONObject> paySecondByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
+    public ResponseJson<JSONObject> paySecondByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (StringUtils.isBlank(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空!", null);
+        }
         if (null == heliDto.getProductId()) {
             return ResponseJson.error("二手商品Id不能为空!", null);
         }
@@ -54,7 +58,7 @@ public class HeliPayNonOrderApi {
     }
 
     /**
-     * 二手发布-微信/支付宝二维码
+     * 二手发布-支付宝二维码
      *
      * @param heliDto {
      *                productId      二手发布商品id
@@ -63,7 +67,10 @@ public class HeliPayNonOrderApi {
      */
     @ApiOperation("二手发布-支付宝线上支付(旧:/PayOrder/secondHandPay[ALIPAY])")
     @PostMapping("/second/scan")
-    public ResponseJson<JSONObject> paySecondByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
+    public ResponseJson<JSONObject> paySecondByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (StringUtils.isBlank(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空!", null);
+        }
         if (null == heliDto.getProductId()) {
             return ResponseJson.error("二手商品Id不能为空!", null);
         }
@@ -108,21 +115,25 @@ public class HeliPayNonOrderApi {
         }
         return payNonOrderService.couponCheck(couponRecordId);
     }
-     /**
+
+    /**
      * 购买优惠券-微信线上支付
      *
      * @param heliDto {
-     *                     couponId      购买优惠券Id
-     *                     userId        userId
-     *                     couponRecordId  购买记录id
-     *                     returnUrl     页面回调地址
-     *                     code          微信小程序code
-     *                     state         微信公众号state参数
-     *                     }
+     *                couponId      购买优惠券Id
+     *                userId        userId
+     *                couponRecordId  购买记录id
+     *                returnUrl     页面回调地址
+     *                code          微信小程序code
+     *                state         微信公众号state参数
+     *                }
      */
     @ApiOperation("购买价值优惠券-微信支付")
     @PostMapping("/coupon/wechat")
-    public ResponseJson<JSONObject> payCouponByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
+    public ResponseJson<JSONObject> payCouponByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (StringUtils.isBlank(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空!", null);
+        }
         if (null == heliDto.getCouponRecordId()) {
             return ResponseJson.error("购买记录id不能为空!", null);
         }
@@ -143,12 +154,12 @@ public class HeliPayNonOrderApi {
 
     @ApiOperation("购买价值优惠券-网银线上支付")
     @PostMapping("/coupon/union")
-    public ResponseJson<String> payCouponByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
-        if (null == heliDto.getVipRecordId()) {
-            return ResponseJson.error("购买记录id不能为空!", null);
+    public ResponseJson<String> payCouponByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (StringUtils.isBlank(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空!", null);
         }
-        if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
-            return ResponseJson.error("回调地址不能为空!", null);
+        if (null == heliDto.getCouponRecordId()) {
+            return ResponseJson.error("购买记录id不能为空!", null);
         }
         if (StringUtils.isEmpty(heliDto.getBankCode())) {
             return ResponseJson.error("银行编码不能为空!", null);
@@ -156,8 +167,14 @@ public class HeliPayNonOrderApi {
         if (StringUtils.isEmpty(heliDto.getUserType())) {
             return ResponseJson.error("银行用户类型不能为空!", null);
         }
-        if(null==heliDto.getSource()){
-            return ResponseJson.error("领取渠道不能为空!",null);
+        if (null == heliDto.getSource()) {
+            return ResponseJson.error("领取渠道不能为空!", null);
+        }
+        if (null == heliDto.getCouponId()) {
+            return ResponseJson.error("优惠券Id不能为空!", null);
+        }
+        if (null == heliDto.getUserId()) {
+            return ResponseJson.error("userId不能为空!", null);
         }
         return payNonOrderService.couponUnionPay(heliDto, headers);
     }
@@ -166,16 +183,19 @@ public class HeliPayNonOrderApi {
      * 购买价值优惠券-微信/支付宝二维码
      *
      * @param heliDto {
-     *                     couponId      购买优惠券Id
-     *                     userId        userId
-     *                     couponRecordId  购买记录id
-     *                     returnUrl     页面回调地址
-     *                     state         微信公众号state参数
+     *                couponId      购买优惠券Id
+     *                userId        userId
+     *                couponRecordId  购买记录id
+     *                returnUrl     页面回调地址
+     *                state         微信公众号state参数
      *                }
      */
     @ApiOperation("购买价值优惠券-支付宝线上支付")
-    @PostMapping("/second/scan")
-    public ResponseJson<JSONObject> payCouponByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
+    @PostMapping("/coupon/scan")
+    public ResponseJson<JSONObject> payCouponByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (StringUtils.isBlank(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空!", null);
+        }
         if (null == heliDto.getCouponRecordId()) {
             return ResponseJson.error("购买记录id不能为空!", null);
         }
@@ -195,13 +215,14 @@ public class HeliPayNonOrderApi {
      * 购买优惠券-支付回调
      */
     @ApiOperation("购买优惠券-支付回调")
-    @GetMapping("/coupon/callback")
+    @PostMapping("/coupon/callback")
     public String couponCallback(NotifyResponseVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
         if (null == res) {
             return "回调参数失败";
         }
         return payNonOrderService.couponCallback(res);
     }
+
     /**
      * 二手发布-网银支付回调
      */
@@ -216,13 +237,13 @@ public class HeliPayNonOrderApi {
 
     @ApiOperation("升级超级会员-网银线上支付")
     @PostMapping("/vip/union")
-    public ResponseJson<String> paySuperVipByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
+    public ResponseJson<String> paySuperVipByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (StringUtils.isBlank(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空!", null);
+        }
         if (null == heliDto.getVipRecordId()) {
             return ResponseJson.error("会员购买记录Id不能为空!", null);
         }
-        if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
-            return ResponseJson.error("回调地址不能为空!", null);
-        }
         if (StringUtils.isEmpty(heliDto.getBankCode())) {
             return ResponseJson.error("银行编码不能为空!", null);
         }
@@ -234,7 +255,10 @@ public class HeliPayNonOrderApi {
 
     @ApiOperation("二手发布-网银线上支付(旧:/PayOrder/secondHandPay[UNIONPAY])")
     @PostMapping("/second/union")
-    public ResponseJson<String> paySecondByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
+    public ResponseJson<String> paySecondByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (StringUtils.isBlank(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空!", null);
+        }
         if (null == heliDto.getProductId()) {
             return ResponseJson.error("二手商品Id不能为空!", null);
         }
@@ -262,7 +286,10 @@ public class HeliPayNonOrderApi {
      */
     @ApiOperation("升级超级会员-微信线上支付")
     @PostMapping("/vip/wechat")
-    public ResponseJson<JSONObject> paySuperVipByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
+    public ResponseJson<JSONObject> paySuperVipByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (StringUtils.isBlank(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空!", null);
+        }
         if (null == heliDto.getVipRecordId()) {
             return ResponseJson.error("会员购买记录Id不能为空!", null);
         }
@@ -282,7 +309,10 @@ public class HeliPayNonOrderApi {
      */
     @ApiOperation("升级超级会员-支付宝线上支付")
     @PostMapping("/vip/scan")
-    public ResponseJson<JSONObject> paySuperVipByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
+    public ResponseJson<JSONObject> paySuperVipByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (StringUtils.isBlank(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空!", null);
+        }
         if (null == heliDto.getVipRecordId()) {
             return ResponseJson.error("会员购买记录Id不能为空!", null);
         }
@@ -317,9 +347,9 @@ public class HeliPayNonOrderApi {
     }
 
     /**
-     * 升级超级会员-网银支付回调
+     * 购买优惠券-网银支付回调
      */
-    @ApiOperation("升级超级会员-网银支付回调")
+    @ApiOperation("购买优惠券-网银支付回调")
     @PostMapping("/coupon/callback/union")
     public String couponUnionCallback(UnionResVo data) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
         if (null == data) {
@@ -327,4 +357,119 @@ public class HeliPayNonOrderApi {
         }
         return payNonOrderService.unionCouponCallback(data);
     }
+
+    @ApiOperation("开通认证通会员-网银线上支付")
+    @PostMapping("/auth/vip/union")
+    public ResponseJson<String> payAuthVipByUnionPay(HeliDto heliDto, @RequestHeader HttpHeaders headers){
+        if (StringUtils.isEmpty(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空", null);
+        }
+        if (null == heliDto.getVipRecordId()) {
+            return ResponseJson.error("会员购买记录Id不能为空!", null);
+        }
+        if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
+            return ResponseJson.error("回调地址不能为空!", null);
+        }
+        if (StringUtils.isEmpty(heliDto.getBankCode())) {
+            return ResponseJson.error("银行编码不能为空!", null);
+        }
+        if (StringUtils.isEmpty(heliDto.getUserType())) {
+            return ResponseJson.error("银行用户类型不能为空!", null);
+        }
+        return payNonOrderService.authVipUnionPay(heliDto, headers);
+    }
+
+    /**
+     * 开通认证通会员-微信线上支付
+     *
+     * @param heliDto {
+     *                vipRecordId   会员购买记录Id
+     *                returnUrl     页面回调地址
+     *                code          微信小程序code
+     *                state         微信公众号state参数
+     *                }
+     */
+    @ApiOperation("升级认证通会员-微信线上支付")
+    @PostMapping("/auth/vip/wechat")
+    public ResponseJson<JSONObject> payAuthVipByWeChat(HeliDto heliDto, @RequestHeader HttpHeaders headers) throws IllegalAccessException, IntrospectionException, InvocationTargetException {
+        if (StringUtils.isEmpty(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空", null);
+        }
+        if (null == heliDto.getVipRecordId()) {
+            return ResponseJson.error("会员购买记录Id不能为空!", null);
+        }
+        if (StringUtils.isEmpty(heliDto.getCode())) {
+            return ResponseJson.error("微信code不能为空!", null);
+        }
+        return payNonOrderService.payAuthVipByWeChat(heliDto, headers);
+    }
+
+    /**
+     * 开通认证通会员-微信/支付宝二维码
+     *
+     * @param heliDto {
+     *                vipRecordId   会员购买记录Id
+     *                returnUrl     页面回调地址
+     *                }
+     */
+    @ApiOperation("升级认证通会员-支付宝线上支付")
+    @PostMapping("/auth/vip/scan")
+    public ResponseJson<JSONObject> payAuthVipByAlipay(HeliDto heliDto, @RequestHeader HttpHeaders headers) {
+        if (StringUtils.isEmpty(heliDto.getPayType())) {
+            return ResponseJson.error("支付类型不能为空", null);
+        }
+        if (null == heliDto.getVipRecordId()) {
+            return ResponseJson.error("会员购买记录Id不能为空!", null);
+        }
+        if (StringUtils.isEmpty(heliDto.getReturnUrl())) {
+            return ResponseJson.error("回调地址不能为空!", null);
+        }
+        return payNonOrderService.payAuthVipByAlipay(heliDto, headers);
+    }
+
+    /**
+     * 开通认证通会员-网银支付回调
+     */
+    @ApiOperation("开通认证通会员-网银支付回调")
+    @PostMapping("/auth/vip/callback/union")
+    public String paymentAuthVipCallback(UnionResVo data) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (null == data) {
+            return "回调参数失败";
+        }
+        return payNonOrderService.unionAuthVipCallback(data);
+    }
+
+    /**
+     * 开通认证通会员-支付回调
+     */
+    @ApiOperation("开通认证通会员-支付回调")
+    @PostMapping("/auth/vip/callback")
+    public String paymentAuthVipCallback(NotifyResponseVo data) throws NoSuchAlgorithmException, InvalidKeySpecException, IntrospectionException, InvocationTargetException, IllegalAccessException {
+        if (null == data) {
+            return "回调参数失败";
+        }
+        return payNonOrderService.paymentAuthVipCallback(data);
+    }
+
+    @ApiOperation("购买认证通会员-查询是否购买成功")
+    @GetMapping("/auth/vip/check")
+    public ResponseJson authVipCheck(Integer vipRecordId) {
+        if (null == vipRecordId) {
+            return ResponseJson.error("购买记录id不能为空!", null);
+        }
+        return payNonOrderService.authVipCheck(vipRecordId);
+    }
+
+    /**
+     * 购买超级会员-查询是否购买成功
+     */
+    @ApiOperation("购买超级会员-查询是否购买成功")
+    @GetMapping("/vip/check")
+    public ResponseJson vipCheck(Integer recordId) {
+        if (null == recordId) {
+            return ResponseJson.error("购买记录id不能为空!", null);
+        }
+        return payNonOrderService.vipCheck(recordId);
+    }
+
 }

+ 4 - 0
src/main/java/com/caimei365/order/mapper/BaseMapper.java

@@ -233,4 +233,8 @@ public interface BaseMapper {
     AuthUserVo getAuthUser(Integer userId);
 
     String findType(String mbOrderId);
+
+    String findShopOrderIds(Integer orderId);
+
+    void updateOrderOnlineFlag(Integer orderId);
 }

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

@@ -240,13 +240,13 @@ public interface OrderClubMapper {
     /**
      * 根据用户id获取用户openid列表(微信公众号openid,下单)
      */
-    List<String> getOpenidListByPermission(String unionid);
+    List<String> getOpenidListByPermission(String unionId);
 
-    Integer getUserId(Integer orderid);
+    Integer getUserId(Integer orderId);
 
-    String getOpenidunionId(Integer userid);
-     //查询是否是订金订单6060是订金订单其他不是
-    List<Integer> getProductOrder(Integer orderid);
+    String getOpenidunionId(Integer userId);
+
+    List<Integer> getProductOrder(Integer orderId);
     /*
      *根据orderId查询商品名称
      */

+ 4 - 0
src/main/java/com/caimei365/order/mapper/OrderCommonMapper.java

@@ -163,4 +163,8 @@ public interface OrderCommonMapper {
     List<DiscernReceiptVo> getShopOrderDiscernReceipt(Integer shopOrderId);
 
     ShopOrderVo getShopOrderByOrderId(Integer shopOrderId);
+
+    List<OrderProductVo> getOrderProductByShopOrderId(Integer shopOrderId);
+
+    Double findShopFee(Integer shopOrderId);
 }

+ 14 - 7
src/main/java/com/caimei365/order/mapper/PayOrderMapper.java

@@ -2,10 +2,7 @@ package com.caimei365.order.mapper;
 
 import com.caimei365.order.model.bo.VipRecordBo;
 import com.caimei365.order.model.po.*;
-import com.caimei365.order.model.vo.BankCodeVo;
-import com.caimei365.order.model.vo.CouponCheckVo;
-import com.caimei365.order.model.vo.OrderPayLinkVo;
-import com.caimei365.order.model.vo.OrderVo;
+import com.caimei365.order.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -78,9 +75,9 @@ public interface PayOrderMapper {
     Integer getOrderPromotionsId(Integer orderId);
     /**
      * 付款次数
-     * @param orderId 订单Id
+     * @param shopOrderId 订单Id
      */
-    Integer getDbPaySuccessCounter(Integer orderId);
+    Integer getDbPaySuccessCounter(Integer shopOrderId);
 
     /**
      * 根据用户id获取用户openid列表(微信公众号openid,下单)
@@ -227,7 +224,7 @@ public interface PayOrderMapper {
      */
     OrderPayLinkVo getAuthVipPayLink(@Param("recordId") int recordId, @Param("amount") Double amount);
 
-    Double getCouponPrice(Integer couponId);
+    Double getCouponPrice(Integer recordId);
 
     void insertCouponRecord(CouponRecordPo cr);
 
@@ -246,4 +243,14 @@ public interface PayOrderMapper {
     void updateSplitAccount(String mbOrderId, String orderRequestNo);
 
     String findShopOrderSplitCode(Integer shopOrderId);
+
+    void updateShopOrder(ShopOrderVo shopOrder);
+
+    Integer getOrderId(Integer shopOrderId);
+
+    List<BankCodeVo> findB2BBankCode();
+
+    List<BankCodeVo> findB2CBankCode();
+
+    String getSplitCodeByShopOrderId(Integer shopOrderId);
 }

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

@@ -5,6 +5,7 @@ import com.caimei365.order.model.po.*;
 import com.caimei365.order.model.vo.AddressVo;
 import com.caimei365.order.model.vo.LadderPriceVo;
 import com.caimei365.order.model.vo.PromotionsVo;
+import com.caimei365.order.model.vo.ShopOrderVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -145,4 +146,8 @@ public interface SubmitMapper {
     List<Integer> findLowOrder(@Param("userId") Integer userId, @Param("orderTime") Date orderTime);
 
     void updateOnlinePayFlag(Integer onlinePayFlag, Integer orderId);
+
+    List<OrderShopPo> findShops(List<String> productIdList);
+
+    Integer findSplitResult(List<String> productIdList);
 }

+ 5 - 0
src/main/java/com/caimei365/order/model/dto/PayLinkDto.java

@@ -39,4 +39,9 @@ public class PayLinkDto implements Serializable {
      */
     @ApiModelProperty("本次待付款金额")
     private Double unpaidAmount;
+    /**
+     * 子订单Id
+     */
+    @ApiModelProperty("子订单Id")
+    private Integer shopOrderId;
 }

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

@@ -17,6 +17,10 @@ public class OrderPo implements Serializable {
      * orderSeen:订单对机构可见度,1可见,2不可见
      */
     private Integer orderSeen;
+    /**
+     * 经理折扣
+     */
+    private Integer discountFee;
     /**
      * 订单号
      */

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

@@ -16,6 +16,10 @@ import java.util.List;
 @Data
 public class OrderProductPo implements Serializable {
     private static final long serialVersionUID = 1L;
+    /**
+     * 不包含单品满减的商品金额
+     */
+    private Double realProductFee;
     /**
      * 商品Id
      */

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

@@ -13,7 +13,10 @@ import java.io.Serializable;
 @Data
 public class OrderShopPo implements Serializable {
     private static final long serialVersionUID = 1L;
-
+    /**
+     * 虚拟字段,不包含店铺满减的子订单应付
+     */
+    private Double realNeedPay;
     /**
      * 均摊优惠
      */

+ 40 - 0
src/main/java/com/caimei365/order/model/vo/OnlineCheckVo.java

@@ -0,0 +1,40 @@
+package com.caimei365.order.model.vo;
+
+import com.google.common.collect.ImmutableSet;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.util.Set;
+
+@Setter
+@Getter
+@ToString
+public class OnlineCheckVo implements Serializable {
+    private String rt1_bizType;
+    private String rt2_retCode;
+    private String rt3_customerNumber;
+    private String rt4_orderId;
+    private String rt5_orderAmount;
+    private String rt6_bankId;
+    private String rt7_business;
+    private String rt8_createDate;
+    private String rt9_completeDate;
+    private String rt10_orderStatus;
+    private String rt11_desc;
+    //DEBIT:借记卡
+    //CREDIT:贷记卡
+    //UNKNOWN:未知ZCREDIT:准贷记卡
+    //DEBIT_CREDIT:借贷合一
+    private String onlineCardType;
+    private String sign;
+
+
+    /**
+     * 需要加签的属性参数
+     * 看接口文档
+     */
+    public static final Set<String> NEED_SIGN_PARAMS = ImmutableSet.of("rt1_bizType", "rt2_retCode", "rt3_customerNumber",
+            "rt4_orderId", "rt5_orderAmount", "rt6_bankId", "rt7_business", "rt8_createDate","rt9_completeDate","rt10_orderStatus");
+}

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

@@ -17,6 +17,10 @@ public class OrderPayLinkVo implements Serializable {
     private static final long serialVersionUID = 1L;
 
     private Integer id;
+    /**
+     * 子订单id
+     */
+    private Integer shopOrderId;
     /**
      * 订单id
      */

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

@@ -14,6 +14,10 @@ import java.math.BigDecimal;
 @Data
 public class OrderProductVo implements Serializable {
     private static final long serialVersionUID = 1L;
+    /**
+     * 商品货号
+     */
+    private String productCode;
     /**
      * 商品分账商户号
      */

+ 16 - 2
src/main/java/com/caimei365/order/model/vo/ShopOrderVo.java

@@ -15,7 +15,13 @@ import java.util.List;
 @Data
 public class ShopOrderVo implements Serializable {
     private static final long serialVersionUID = 1L;
-
+    /**
+     * 子订单已支付成功次数统计
+     */
+    private Integer paySuccessCounter;
+    /**
+     * 特殊供应商标识
+     */
     private Integer shopType;
     /**
      * 子订单ID
@@ -77,6 +83,14 @@ public class ShopOrderVo implements Serializable {
      * (付款供应商)付款状态:1待付款、2部分付款、3已付款
      */
     private Integer payStatus;
+    /**
+     *  用户待付(realPay-receiptAmount)
+     */
+    private Double  obligation;
+    /**
+     * 均摊优惠的金额
+     */
+    private Double eachDiscount;
     /**
      * 已付款金额
      */
@@ -114,7 +128,7 @@ public class ShopOrderVo implements Serializable {
      */
     private Double receiptAmount;
     /**
-     * 优惠均摊后真实付金额needpay
+     * 优惠均摊后真实付金额needpay
      */
     private Double realPay;
     /**

+ 41 - 9
src/main/java/com/caimei365/order/service/HeliPayNonOrderService.java

@@ -18,7 +18,7 @@ import java.security.spec.InvalidKeySpecException;
 public interface HeliPayNonOrderService {
     ResponseJson<PayCouponDto> getCouponRecord(PayCouponDto payCouponDto, HttpHeaders headers);
 
-    ResponseJson<JSONObject> payCouponByWeChat(HeliDto heliDto, HttpHeaders headers);
+    ResponseJson<JSONObject> payCouponByWeChat(HeliDto heliDto, HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
 
     String couponCallback(NotifyResponseVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
     /**
@@ -30,7 +30,7 @@ public interface HeliPayNonOrderService {
      *               state         微信公众号state参数
      * }
      */
-    ResponseJson<JSONObject> paySecondByWeChat(HeliDto heliDto, HttpHeaders headers);
+    ResponseJson<JSONObject> paySecondByWeChat(HeliDto heliDto, HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
     /**
      * 二手发布支付宝线上支付
      * @param heliDto {
@@ -38,7 +38,7 @@ public interface HeliPayNonOrderService {
      *               returnUrl     页面回调地址
      * }
      */
-    ResponseJson<JSONObject> paySecondByAlipay(HeliDto heliDto, HttpHeaders headers);
+    ResponseJson<JSONObject> paySecondByAlipay(HeliDto heliDto, HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
 
     /**
      * 二手发布支付回调
@@ -54,7 +54,7 @@ public interface HeliPayNonOrderService {
      *               state         微信公众号state参数
      * }
      */
-    ResponseJson<JSONObject> paySuperVipByWeChat(HeliDto heliDto, HttpHeaders headers);
+    ResponseJson<JSONObject> paySuperVipByWeChat(HeliDto heliDto, HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
     /**
      * 升级超级会员-支付宝线上支付
      * @param heliDto {
@@ -62,16 +62,16 @@ public interface HeliPayNonOrderService {
      *               returnUrl     页面回调地址
      * }
      */
-    ResponseJson<JSONObject> paySuperVipByAlipay(HeliDto heliDto, HttpHeaders headers);
+    ResponseJson<JSONObject> paySuperVipByAlipay(HeliDto heliDto, HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
 
     /**
      * 升级超级会员-支付回调
      */
     String paymentSuperVipCallback(NotifyResponseVo data) throws NoSuchAlgorithmException, InvalidKeySpecException, IntrospectionException, InvocationTargetException, IllegalAccessException;
 
-    ResponseJson<String> unionPay(HeliDto heliDto, HttpHeaders headers);
+    ResponseJson<String> unionPay(HeliDto heliDto, HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
 
-    ResponseJson<String> unionPaySecond(HeliDto heliDto, HttpHeaders headers);
+    ResponseJson<String> unionPaySecond(HeliDto heliDto, HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
 
     /**
      * 升级超级会员-网银支付回调
@@ -82,11 +82,43 @@ public interface HeliPayNonOrderService {
      */
     String unionSecondCallback(UnionResVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
 
-    ResponseJson<JSONObject> payCouponByAlipay(HeliDto heliDto, HttpHeaders headers);
+    ResponseJson<JSONObject> payCouponByAlipay(HeliDto heliDto, HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
 
-    ResponseJson<String> couponUnionPay(HeliDto heliDto, HttpHeaders headers);
+    ResponseJson<String> couponUnionPay(HeliDto heliDto, HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
 
     String unionCouponCallback(UnionResVo data) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
 
     ResponseJson couponCheck(Integer couponRecordId);
+
+    /**
+     * 认证通会员网银支付
+     */
+    ResponseJson<String> authVipUnionPay(HeliDto heliDto, HttpHeaders headers);
+
+    /**
+     * 认证通会员微信支付
+     */
+    ResponseJson<JSONObject> payAuthVipByWeChat(HeliDto heliDto, HttpHeaders headers) throws IllegalAccessException, IntrospectionException, InvocationTargetException;
+
+    /**
+     * 认证通会员支付宝支付
+     */
+    ResponseJson<JSONObject> payAuthVipByAlipay(HeliDto heliDto, HttpHeaders headers);
+
+    /**
+     * 认证通会员支付回调
+     */
+    String paymentAuthVipCallback(NotifyResponseVo data) throws IllegalAccessException, IntrospectionException, InvocationTargetException;
+
+    /**
+     * 认证通会员网银支付回调
+     */
+    String unionAuthVipCallback(UnionResVo data) throws IllegalAccessException, IntrospectionException, InvocationTargetException;
+
+    /**
+     * 认证通会员购买确认
+     */
+    ResponseJson authVipCheck(Integer vipRecordId);
+
+    ResponseJson vipCheck(Integer recordId);
 }

+ 10 - 8
src/main/java/com/caimei365/order/service/HeliPayService.java

@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.HeliDto;
 import com.caimei365.order.model.dto.PayDto;
-import com.caimei365.order.model.vo.AccountResVo;
-import com.caimei365.order.model.vo.AppCreateOrderVo;
-import com.caimei365.order.model.vo.NotifyResponseVo;
-import com.caimei365.order.model.vo.UnionResVo;
+import com.caimei365.order.model.vo.*;
 import org.springframework.http.HttpHeaders;
 
 import javax.servlet.http.HttpServletRequest;
@@ -15,6 +12,8 @@ import java.beans.IntrospectionException;
 import java.lang.reflect.InvocationTargetException;
 import java.security.NoSuchAlgorithmException;
 import java.security.spec.InvalidKeySpecException;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Description
@@ -23,9 +22,9 @@ import java.security.spec.InvalidKeySpecException;
  * @date : 2021/11/11
  */
 public interface HeliPayService {
-    ResponseJson<JSONObject> payByWeChat(HeliDto heliDto, HttpHeaders headers);
+    ResponseJson<JSONObject> payByWeChat(HeliDto heliDto, HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
 
-    ResponseJson<JSONObject> payOnline(HeliDto heliDto, HttpHeaders headers);
+    ResponseJson<JSONObject> payOnline(HeliDto heliDto, HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
     /**
      * 回调
      */
@@ -42,12 +41,15 @@ public interface HeliPayService {
      */
     String delayedSplittingCallback(AccountResVo data);
 
-    ResponseJson<JSONObject> bankCode();
+    ResponseJson<Map<String, Object>> bankCode();
 
-    ResponseJson<JSONObject> getPayOrderResult(String mbOrderId);
+    ResponseJson<JSONObject> getPayOrderResult(String mbOrderId, Integer orderFlag,Integer shopOrderId) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
     /**
      * 银联回调
      */
     String unionCallback(UnionResVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
 
+    ResponseJson<List<ShopOrderVo>> getShopOrders(Integer orderId);
+
+    ResponseJson<JSONObject> getUnionResult(String mbOrderId, Integer orderFlag, Integer shopOrderId);
 }

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

@@ -4,12 +4,14 @@ import com.alibaba.fastjson.JSONObject;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.PayDto;
 import com.caimei365.order.model.dto.PayLinkDto;
+import com.caimei365.order.model.vo.ShopOrderVo;
 import org.springframework.http.HttpHeaders;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.security.NoSuchAlgorithmException;
 import java.security.spec.InvalidKeySpecException;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -118,6 +120,8 @@ public interface PayOrderService {
 
     ResponseJson<JSONObject> payByUnion(PayDto payDto, HttpHeaders headers);
 
+    ResponseJson<Map<String, Object>> getCheckoutShopOrders(Integer shopOrderId);
+
 //    /**
 //     * 手动临时分账
 //     */

File diff suppressed because it is too large
+ 487 - 532
src/main/java/com/caimei365/order/service/impl/HeliPayNonOrderServiceImpl.java


+ 312 - 241
src/main/java/com/caimei365/order/service/impl/HeliPayServiceImpl.java

@@ -3,6 +3,7 @@ package com.caimei365.order.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei365.order.components.HeliPayUtil;
+import com.caimei365.order.components.OnlinePostFormUtil;
 import com.caimei365.order.components.WeChatService;
 import com.caimei365.order.constant.Constant;
 import com.caimei365.order.mapper.BaseMapper;
@@ -19,6 +20,7 @@ import com.caimei365.order.model.po.*;
 import com.caimei365.order.model.vo.*;
 import com.caimei365.order.service.HeliPayService;
 import com.caimei365.order.service.RemoteCallService;
+import com.caimei365.order.utils.ImageUtil;
 import com.caimei365.order.utils.MathUtil;
 import com.caimei365.order.utils.PayUtil;
 import com.caimei365.order.utils.helipay.Disguiser;
@@ -30,6 +32,7 @@ import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.HttpStatus;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpHeaders;
 import org.springframework.stereotype.Service;
 import org.springframework.web.servlet.ModelAndView;
@@ -78,6 +81,8 @@ public class HeliPayServiceImpl implements HeliPayService {
     private RemoteCallService remoteCallService;
     @Resource
     private WeChatService weChatService;
+    @Value("${caimei.wwwDomain}")
+    private String domain;
 
     /**
      * 微信/支付宝扫码接口
@@ -100,108 +105,98 @@ public class HeliPayServiceImpl implements HeliPayService {
      * 签名	sign	是	String(40)	d3382b9a9b08cefc1a79d276ec03d83a	MD5 签名结果,详见“第 5 章 数字签名”
      */
     @Override
-    public ResponseJson<JSONObject> payByWeChat(HeliDto heliDto, HttpHeaders headers) {
+    public ResponseJson<JSONObject> payByWeChat(HeliDto heliDto, HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
         log.info("--------进入支付二维码创建接口----------");
-        try {
-            AppCreateOrderVo pay = new AppCreateOrderVo();
-            String splitCode = payOrderMapper.findShopOrderSplitCode(heliDto.getShopOrderId());
-            if (StringUtils.isBlank(splitCode)) {
-                return ResponseJson.error("子订单无商户号!", null);
-            }
-            pay.setP3_customerNumber(splitCode);
-            //合利宝主扫接口参数赋值
-            heliPayUtil.setValue(pay, heliDto, "order", headers);
-            if (!(StringUtils.equals(AppPayType.ALIPAY.name(), pay.getP8_appType())
-                    && StringUtils.equals(PayType.SWIPE.name(), pay.getP4_payType()))) {
-                pay.setOpenId(null);
-                pay.setAuthConfirmMode(null);
-            }
-            Map<String, String> map = MyBeanUtils.convertBean(pay, new LinkedHashMap());
-            String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, AppCreateOrderVo.NEED_SIGN_PARAMS);
-            //密钥拼接
-            oriMessage += SPLIT + Constant.SAOMA;
-            log.info("签名原文串:" + oriMessage);
-            String sign = Disguiser.disguiseMD5(oriMessage.trim());
-            log.info("签名串:" + sign);
-            map.put("sign", sign);
-            log.info("发送参数:" + map);
-            Map<String, Object> resultMap = HttpClientService.getHttpResp(map, Constant.REQUEST_URL);
-            log.info("响应结果:" + resultMap);
-            if ((Integer) resultMap.get("statusCode") == HttpStatus.SC_OK) {
-                String resultMsg = (String) resultMap.get("response");
-                AppCreateOrderResponseVo orderResponseVo = JSONObject.parseObject(resultMsg, AppCreateOrderResponseVo.class);
-                String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(orderResponseVo, AppCreateOrderResponseVo.NEED_SIGN_PARAMS);
-                assemblyRespOriSign += Constant.SPLIT + Constant.SAOMA;
-                log.info("组装返回结果签名串:" + assemblyRespOriSign);
-                String responseSign = orderResponseVo.getSign();
-                log.info("响应签名:" + responseSign);
-                String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
-                JSONObject jsonObject = JSONObject.parseObject(resultMsg);
-                if (checkSign.equals(responseSign) && "0000".equals(orderResponseVo.getRt2_retCode())) {
-                    return ResponseJson.success("二维码创建成功", jsonObject);
-                } else {
-                    return ResponseJson.error("二维码创建失败", jsonObject);
-                }
+        AppCreateOrderVo pay = new AppCreateOrderVo();
+        String splitCode = payOrderMapper.findShopOrderSplitCode(heliDto.getShopOrderId());
+        if (StringUtils.isBlank(splitCode)) {
+            return ResponseJson.error("子订单无商户号!", null);
+        }
+        pay.setP3_customerNumber(splitCode);
+        //合利宝主扫接口参数赋值
+        heliPayUtil.setValue(pay, heliDto, "order", headers);
+        if (!(StringUtils.equals(AppPayType.ALIPAY.name(), pay.getP8_appType())
+                && StringUtils.equals(PayType.SWIPE.name(), pay.getP4_payType()))) {
+            pay.setOpenId(null);
+            pay.setAuthConfirmMode(null);
+        }
+        Map<String, String> map = MyBeanUtils.convertBean(pay, new LinkedHashMap());
+        String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, AppCreateOrderVo.NEED_SIGN_PARAMS);
+        //密钥拼接
+        oriMessage += SPLIT + Constant.SAOMA;
+        log.info("签名原文串:" + oriMessage);
+        String sign = Disguiser.disguiseMD5(oriMessage.trim());
+        log.info("签名串:" + sign);
+        map.put("sign", sign);
+        log.info("发送参数:" + map);
+        Map<String, Object> resultMap = HttpClientService.getHttpResp(map, Constant.REQUEST_URL);
+        log.info("响应结果:" + resultMap);
+        if ((Integer) resultMap.get("statusCode") == HttpStatus.SC_OK) {
+            String resultMsg = (String) resultMap.get("response");
+            AppCreateOrderResponseVo orderResponseVo = JSONObject.parseObject(resultMsg, AppCreateOrderResponseVo.class);
+            String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(orderResponseVo, AppCreateOrderResponseVo.NEED_SIGN_PARAMS);
+            assemblyRespOriSign += Constant.SPLIT + Constant.SAOMA;
+            log.info("组装返回结果签名串:" + assemblyRespOriSign);
+            String responseSign = orderResponseVo.getSign();
+            log.info("响应签名:" + responseSign);
+            String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
+            JSONObject jsonObject = JSONObject.parseObject(resultMsg);
+            if (checkSign.equals(responseSign) && "0000".equals(orderResponseVo.getRt2_retCode())) {
+                return ResponseJson.success("二维码创建成功", jsonObject);
             } else {
-                return ResponseJson.error("二维码创建失败", null);
+                return ResponseJson.error("二维码创建失败", jsonObject);
             }
-        } catch (Exception e) {
-            log.error("二维码创建失败" + e);
+        } else {
             return ResponseJson.error("二维码创建失败", null);
         }
     }
 
     @Override
-    public ResponseJson<JSONObject> payOnline(HeliDto heliDto, HttpHeaders headers) {
+    public ResponseJson<JSONObject> payOnline(HeliDto heliDto, HttpHeaders headers) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
         log.info("--------进入公众号/小程序预创建订单接口----------");
-        try {
-            AppPayPublicCreateOrderVo pay = new AppPayPublicCreateOrderVo();
-            String splitCode = payOrderMapper.findShopOrderSplitCode(heliDto.getShopOrderId());
-            if (StringUtils.isBlank(splitCode)) {
-                return ResponseJson.error("子订单无商户号!", null);
-            }
-            pay.setP3_customerNumber(splitCode);
-            //合利宝主扫接口参数赋值
-            heliPayUtil.setOnlineValue(pay, heliDto, "order", headers);
-            if ("GZH".equals(heliDto.getPayType()) || "XCX".equals(heliDto.getPayType())) {
-                //公众号/小程序
-                String openId = getOpenId(heliDto, headers);
-                if (StringUtils.isEmpty(openId)) {
-                    return ResponseJson.error("微信openId获取失败", null);
-                }
-                pay.setP8_openid(openId);
+        AppPayPublicCreateOrderVo pay = new AppPayPublicCreateOrderVo();
+        String splitCode = payOrderMapper.findShopOrderSplitCode(heliDto.getShopOrderId());
+        if (StringUtils.isBlank(splitCode)) {
+            return ResponseJson.error("子订单无商户号!", null);
+        }
+        pay.setP3_customerNumber(splitCode);
+        //合利宝主扫接口参数赋值
+        heliPayUtil.setOnlineValue(pay, heliDto, "order", headers);
+        if ("GZH".equals(heliDto.getPayType()) || "XCX".equals(heliDto.getPayType())) {
+            //公众号/小程序
+            String openId = getOpenId(heliDto, headers);
+            if (StringUtils.isEmpty(openId)) {
+                return ResponseJson.error("微信openId获取失败", null);
             }
-            Map<String, String> map = MyBeanUtils.convertBean(pay, new LinkedHashMap());
-            String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, AppPayPublicCreateOrderVo.NEED_SIGN_PARAMS);
-            oriMessage += SPLIT + Constant.SAOMA;
-            log.info("签名原文串:" + oriMessage);
-            String sign = Disguiser.disguiseMD5(oriMessage.trim());
-            log.info("签名串:" + sign);
-            map.put("sign", sign);
-            log.info("发送参数:" + map);
-            Map<String, Object> resultMap = HttpClientService.getHttpResp(map, Constant.REQUEST_URL);
-            log.info("响应结果:" + resultMap);
-            if ((Integer) resultMap.get("statusCode") == HttpStatus.SC_OK) {
-                String resultMsg = (String) resultMap.get("response");
-                AppPayPublicOrderResponseVo orderResponseVo = JSONObject.parseObject(resultMsg, AppPayPublicOrderResponseVo.class);
-                String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(orderResponseVo, AppPayPublicOrderResponseVo.NEED_SIGN_PARAMS);
-                assemblyRespOriSign += Constant.SPLIT + Constant.SAOMA;
-                log.info("组装返回结果签名串:" + assemblyRespOriSign);
-                String responseSign = orderResponseVo.getSign();
-                log.info("响应签名:" + responseSign);
-                String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
-                if (checkSign.equals(responseSign) && "0000".equals(orderResponseVo.getRt2_retCode())) {
-                    JSONObject jsonObject = JSONObject.parseObject(resultMsg);
-                    return ResponseJson.success("请求成功", jsonObject);
-                } else {
-                    return ResponseJson.error("请求参数有误", JSONObject.parseObject(resultMsg));
-                }
+            pay.setP8_openid(openId);
+        }
+        Map<String, String> map = MyBeanUtils.convertBean(pay, new LinkedHashMap());
+        String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, AppPayPublicCreateOrderVo.NEED_SIGN_PARAMS);
+        oriMessage += SPLIT + Constant.SAOMA;
+        log.info("签名原文串:" + oriMessage);
+        String sign = Disguiser.disguiseMD5(oriMessage.trim());
+        log.info("签名串:" + sign);
+        map.put("sign", sign);
+        log.info("发送参数:" + map);
+        Map<String, Object> resultMap = HttpClientService.getHttpResp(map, Constant.REQUEST_URL);
+        log.info("响应结果:" + resultMap);
+        if ((Integer) resultMap.get("statusCode") == HttpStatus.SC_OK) {
+            String resultMsg = (String) resultMap.get("response");
+            AppPayPublicOrderResponseVo orderResponseVo = JSONObject.parseObject(resultMsg, AppPayPublicOrderResponseVo.class);
+            String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(orderResponseVo, AppPayPublicOrderResponseVo.NEED_SIGN_PARAMS);
+            assemblyRespOriSign += Constant.SPLIT + Constant.SAOMA;
+            log.info("组装返回结果签名串:" + assemblyRespOriSign);
+            String responseSign = orderResponseVo.getSign();
+            log.info("响应签名:" + responseSign);
+            String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
+            if (checkSign.equals(responseSign) && "0000".equals(orderResponseVo.getRt2_retCode())) {
+                JSONObject jsonObject = JSONObject.parseObject(resultMsg);
+                return ResponseJson.success("请求成功", jsonObject);
             } else {
-                return ResponseJson.error("请求失败", null);
+                return ResponseJson.error("请求参数有误", JSONObject.parseObject(resultMsg));
             }
-        } catch (Exception e) {
-            log.error("交易失败" + e);
-            return ResponseJson.error("交易失败", null);
+        } else {
+            return ResponseJson.error("请求失败", null);
         }
     }
 
@@ -213,14 +208,8 @@ public class HeliPayServiceImpl implements HeliPayService {
         log.info("回调签名" + sign);
         String oriMessage = MyBeanUtils.getSigned(res, null);
         String oriMessage1 = oriMessage + SPLIT + Constant.SAOMA;
-        String oriMessage2 = oriMessage + SPLIT + Constant.FENZHANG;
-        String oriMessage3 = oriMessage + SPLIT + Constant.XUNI;
-        String oriMessage4 = oriMessage + SPLIT + Constant.WANGYIN;
         String checkSign1 = Disguiser.disguiseMD5(oriMessage1.trim());
-        String checkSign2 = Disguiser.disguiseMD5(oriMessage2.trim());
-        String checkSign3 = Disguiser.disguiseMD5(oriMessage3.trim());
-        String checkSign4 = Disguiser.disguiseMD5(oriMessage4.trim());
-        boolean b = sign.equals(checkSign1) || sign.equals(checkSign2) || sign.equals(checkSign3) || sign.equals(checkSign4);
+        boolean b = sign.equals(checkSign1);
         if (!b) {
             return "验签名失败!";
         }
@@ -297,12 +286,14 @@ public class HeliPayServiceImpl implements HeliPayService {
         }
         // 更新付款次数
         Integer paySuccessCounter = (null == order.getPaySuccessCounter()) ? 1 : order.getPaySuccessCounter() + 1;
+        Integer paySuccess = (null == shopOrder.getPaySuccessCounter()) ? 1 : shopOrder.getPaySuccessCounter() + 1;
+        shopOrder.setPaySuccessCounter(paySuccess);
         order.setPaySuccessCounter(paySuccessCounter);
         order.setUpdateDate(curDateStr);
         // 更新订单支付状态
         payOrderMapper.updateOrderStatus(order);
         // 支付记录
-        // todo子订单返佣????
+        //todo sql的or条件子订单返佣????
         List<DiscernReceiptVo> shopOrderDiscernReceiptList = orderCommonMapper.getShopOrderDiscernReceipt(shopOrderId);
         double shopOrderReceiptAmount = 0d;
         if (null != shopOrderDiscernReceiptList && shopOrderDiscernReceiptList.size() > 0) {
@@ -317,13 +308,7 @@ public class HeliPayServiceImpl implements HeliPayService {
         } else {
             shopOrder.setReceiptStatus(2);
         }
-
-        //todo 修改子订单支付链接状态
-        OrderPayLinkVo orderPayLink = payOrderMapper.getOrderPayLink(orderId, amount);
-        if (null != orderPayLink && ("12".equals(payType) || "17".equals(payType))) {
-            orderPayLink.setPayStatus(1);
-            payOrderMapper.updateOrderPayLinkStatus(orderPayLink);
-        }
+        payOrderMapper.updateShopOrder(shopOrder);
         // 保存收款记录
         DiscernReceiptPo discernReceipt = new DiscernReceiptPo();
         discernReceipt.setPayWay(1);
@@ -357,52 +342,52 @@ public class HeliPayServiceImpl implements HeliPayService {
         baseMapper.insertOrderReceiptRelation(relation);
         log.info("【支付异步回调】>>>>>>>>>>>收款项和订单关系(insert[cm_receipt_order_relation])id:" + relation.getId() + ",orderId:" + orderId);
 
+        //当前版本无法线上走充值/订金订单
         // 商品数据
-        List<OrderProductVo> orderProductList = orderCommonMapper.getOrderProductByOrderId(orderId);
-        // todo 当前版本无法线上走订金订单
+//        List<OrderProductVo> orderProductList = orderCommonMapper.getOrderProductByOrderId(orderId);
         // 判断是否是充值商品
-        int rechargeFlag = 0;
-        // 缴纳订金订单
-        int[] productId1 = {6060, 6061, 6062, 6063, 6064};
-        // 充值余额订单
-        int[] productId2 = {6065, 6066, 6067, 6068, 6069};
-        for (OrderProductVo product : orderProductList) {
-            if (ArrayUtils.contains(productId1, product.getProductId())) {
-                rechargeFlag = 1;
-                break;
-            }
-            if (ArrayUtils.contains(productId2, product.getProductId())) {
-                rechargeFlag = 2;
-                break;
-            }
-        }
-        if (rechargeFlag > 0) {
-            // 账户余额
-            double oldUserMoney = baseMapper.getUserMoney(order.getUserId());
-            double userMoney = MathUtil.add(oldUserMoney, amount).doubleValue();
-            // 可用余额
-            Double oldAvailableMoney = baseMapper.getAbleUserMoney(order.getUserId());
-            double availableMoney = MathUtil.add(oldAvailableMoney, amount).doubleValue();
-            payOrderMapper.updateMoneyByUserId(userMoney, availableMoney, order.getUserId());
-            log.info("【支付异步回调】>>>>>>>>>>>更新用户余额(update[user])userId:" + order.getUserId() + ",orderId:" + orderId);
-            //保存余额到余额收支记录
-            BalanceRecordPo balanceRecord = new BalanceRecordPo();
-            balanceRecord.setUserId(order.getUserId());
-            balanceRecord.setType(1);
-            if (rechargeFlag == 1) {
-                balanceRecord.setBalanceType(6);
-            } else {
-                balanceRecord.setBalanceType(7);
-            }
-            balanceRecord.setAddDate(new Date());
-            balanceRecord.setAmount(amount);
-            balanceRecord.setOrderId(orderId);
-            balanceRecord.setRemark("订单商品充值余额");
-            balanceRecord.setDelFlag(0);
-            // 保存 余额收支记录
-            baseMapper.insertBalanceRecord(balanceRecord);
-            log.info("【支付异步回调】>>>>>>>>>>>>>>>>>>>>>>>>>>订单商品充值余额(insert[cm_user_balance_record])orderId:" + orderId);
-        }
+//        int rechargeFlag = 0;
+//        // 缴纳订金订单
+//        int[] productId1 = {6060, 6061, 6062, 6063, 6064};
+//        // 充值余额订单
+//        int[] productId2 = {6065, 6066, 6067, 6068, 6069};
+//        for (OrderProductVo product : orderProductList) {
+//            if (ArrayUtils.contains(productId1, product.getProductId())) {
+//                rechargeFlag = 1;
+//                break;
+//            }
+//            if (ArrayUtils.contains(productId2, product.getProductId())) {
+//                rechargeFlag = 2;
+//                break;
+//            }
+//        }
+//        if (rechargeFlag > 0) {
+//            // 账户余额
+//            double oldUserMoney = baseMapper.getUserMoney(order.getUserId());
+//            double userMoney = MathUtil.add(oldUserMoney, amount).doubleValue();
+//            // 可用余额
+//            Double oldAvailableMoney = baseMapper.getAbleUserMoney(order.getUserId());
+//            double availableMoney = MathUtil.add(oldAvailableMoney, amount).doubleValue();
+//            payOrderMapper.updateMoneyByUserId(userMoney, availableMoney, order.getUserId());
+//            log.info("【支付异步回调】>>>>>>>>>>>更新用户余额(update[user])userId:" + order.getUserId() + ",orderId:" + orderId);
+//            //保存余额到余额收支记录
+//            BalanceRecordPo balanceRecord = new BalanceRecordPo();
+//            balanceRecord.setUserId(order.getUserId());
+//            balanceRecord.setType(1);
+//            if (rechargeFlag == 1) {
+//                balanceRecord.setBalanceType(6);
+//            } else {
+//                balanceRecord.setBalanceType(7);
+//            }
+//            balanceRecord.setAddDate(new Date());
+//            balanceRecord.setAmount(amount);
+//            balanceRecord.setOrderId(orderId);
+//            balanceRecord.setRemark("订单商品充值余额");
+//            balanceRecord.setDelFlag(0);
+//            // 保存 余额收支记录
+//            baseMapper.insertBalanceRecord(balanceRecord);
+//            log.info("【支付异步回调】>>>>>>>>>>>>>>>>>>>>>>>>>>订单商品充值余额(insert[cm_user_balance_record])orderId:" + orderId);
+//        }
 
         // 线上支付与自主下单送豆(已全部收款),最后一笔线上支付成功后,赠送200采美豆
         if (3 == order.getReceiptStatus() && 0 == order.getSecondHandOrderFlag()) {
@@ -482,7 +467,7 @@ public class HeliPayServiceImpl implements HeliPayService {
     public ResponseJson<String> link(HeliDto heliDto, HttpHeaders headers) {
         log.info("--------进入线上支付接口----------");
         // 订单信息
-        OrderVo order = orderCommonMapper.getOrderByOrderId(heliDto.getOrderId());
+        OrderVo order = orderCommonMapper.getOrderByShopOrderId(heliDto.getShopOrderId());
         if (null == order) {
             log.error("订单不存在");
             return ResponseJson.error("订单不存在");
@@ -521,6 +506,7 @@ public class HeliPayServiceImpl implements HeliPayService {
             if (StringUtils.isBlank(splitCode)) {
                 return ResponseJson.error("子订单无商户号!", null);
             }
+            heliOnlineVo.setP3_customerNumber(splitCode);
             heliPayUtil.setLinkValue(heliOnlineVo, heliDto, "order", headers);
             Map<String, String> map = MyBeanUtils.convertBean(heliOnlineVo, new LinkedHashMap());
             String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, HeliOnlineVo.NEED_SIGN_PARAMS);
@@ -851,69 +837,71 @@ public class HeliPayServiceImpl implements HeliPayService {
 
     //银行通道码获取
     @Override
-    public ResponseJson<JSONObject> bankCode() {
-        List<BankCodeVo> banks = payOrderMapper.findBankCode();
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("list", banks);
-        return ResponseJson.success("获取成功", jsonObject);
+    public ResponseJson<Map<String, Object>> bankCode() {
+        List<BankCodeVo> B2B = payOrderMapper.findB2BBankCode();
+        List<BankCodeVo> B2C = payOrderMapper.findB2CBankCode();
+        Map<String, Object> banks = new HashMap<>(2);
+        banks.put("B2B", B2B);
+        banks.put("B2C", B2C);
+        return ResponseJson.success("获取成功", banks);
     }
 
     @Override
-    public ResponseJson<JSONObject> getPayOrderResult(String mbOrderId) {
+    public ResponseJson<JSONObject> getPayOrderResult(String mbOrderId, Integer orderFlag, Integer shopOrderId) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
         log.info("--------进入交易订单查询接口----------");
+        //区分网银和其他产品
         QueryOrderVo queryOrderVo = new QueryOrderVo();
         queryOrderVo.setP1_bizType("AppPayQuery");
         queryOrderVo.setP2_orderId(mbOrderId);
-        //todo 换收款账户
-        queryOrderVo.setP3_customerNumber(Constant.CUSTOMERNUM2);
-        try {
-            Map<String, String> map = MyBeanUtils.convertBean(queryOrderVo, new LinkedHashMap());
-            String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, QueryOrderVo.NEED_SIGN_PARAMS);
-            //区分网银和其他产品
-            String payType = baseMapper.findType(mbOrderId);
-            if ("12".equals(payType) || "17".equals(payType)) {
-                oriMessage += Constant.SPLIT + Constant.WANGYIN;
-            } else {
-                oriMessage += Constant.SPLIT + Constant.SAOMA;
+        if (0 == orderFlag) {
+            queryOrderVo.setP3_customerNumber(Constant.CUSTOMERNUM);
+        } else {
+            if (null == shopOrderId) {
+                return ResponseJson.error("子订单Id不能为空!", null);
             }
-            log.info("签名原文串:" + oriMessage);
-            String sign = Disguiser.disguiseMD5(oriMessage.trim());
-            log.info("签名串:" + sign);
-            map.put("sign", sign);
-            log.info("发送参数:" + map);
-            Map<String, Object> resultMap = HttpClientService.getHttpResp(map, Constant.REQUEST_URL);
-            log.info("响应结果:" + resultMap);
-            if ((Integer) resultMap.get("statusCode") == HttpStatus.SC_OK) {
-                String resultMsg = (String) resultMap.get("response");
-                QueryOrderResponseVo queryOrderResponseVo = JSONObject.parseObject(resultMsg, QueryOrderResponseVo.class);
-                String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(queryOrderResponseVo, QueryOrderResponseVo.NEED_SIGN_PARAMS);
-                log.info("组装返回结果签名串:" + assemblyRespOriSign);
-                if ("12".equals(payType) || "17".equals(payType)) {
-                    assemblyRespOriSign += Constant.SPLIT + Constant.WANGYIN;
-                } else {
-                    assemblyRespOriSign += Constant.SPLIT + Constant.SAOMA;
-                }
-                String responseSign = queryOrderResponseVo.getSign();
-                log.info("响应签名:" + responseSign);
-                String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
-                if (checkSign.equals(responseSign)) {
-                    if ("0000".equals(queryOrderResponseVo.getRt2_retCode())) {
-                        JSONObject jsonObject = JSONObject.parseObject(resultMsg, JSONObject.class);
-                        return ResponseJson.success("查询成功", jsonObject);
-                    } else {
-                        return ResponseJson.error("验签失败", null);
-                    }
+            String splitCode = payOrderMapper.getSplitCodeByShopOrderId(shopOrderId);
+            if (null == splitCode) {
+                return ResponseJson.error("订单信息不正确!", null);
+            }
+            queryOrderVo.setP3_customerNumber(splitCode);
+        }
+
+        Map<String, String> map = MyBeanUtils.convertBean(queryOrderVo, new LinkedHashMap());
+        String oriMessage = MyBeanUtils.getSignedByPresetParameter(map, QueryOrderVo.NEED_SIGN_PARAMS);
+        oriMessage += Constant.SPLIT + Constant.SAOMA;
+        log.info("签名原文串:" + oriMessage);
+        String sign = Disguiser.disguiseMD5(oriMessage.trim());
+        log.info("md5加密签名串:" + sign);
+        map.put("sign", sign);
+        log.info("发送参数:" + map);
+        Map<String, Object> resultMap = HttpClientService.getHttpResp(map, Constant.REQUEST_URL);
+        log.info("响应结果:" + resultMap);
+        if ((Integer) resultMap.get("statusCode") == HttpStatus.SC_OK) {
+            String resultMsg = (String) resultMap.get("response");
+            QueryOrderResponseVo queryOrderResponseVo = JSONObject.parseObject(resultMsg, QueryOrderResponseVo.class);
+            String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(queryOrderResponseVo, QueryOrderResponseVo.NEED_SIGN_PARAMS);
+            log.info("组装返回结果签名串:" + assemblyRespOriSign);
+            assemblyRespOriSign += Constant.SPLIT + Constant.SAOMA;
+            String responseSign = queryOrderResponseVo.getSign();
+            log.info("响应签名:" + responseSign);
+            String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
+            if (checkSign.equals(responseSign)) {
+                if ("0000".equals(queryOrderResponseVo.getRt2_retCode())) {
+                    JSONObject jsonObject = JSONObject.parseObject(resultMsg, JSONObject.class);
+                    return ResponseJson.success("查询成功", jsonObject);
                 } else {
                     return ResponseJson.error("验签失败", null);
                 }
             } else {
-                return ResponseJson.error("查询失败", null);
+                return ResponseJson.error("验签失败", null);
             }
-        } catch (Exception e) {
+        } else {
             return ResponseJson.error("查询失败", null);
         }
+
     }
 
+
     @Override
     public String unionCallback(UnionResVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
         log.info("******************** 网银支付异步回调 start *******************");
@@ -946,11 +934,17 @@ public class HeliPayServiceImpl implements HeliPayService {
         Integer orderId = Integer.valueOf(split[0]);
         //1位置支付类型
         String payType = split[1];
+        //2位置子订单id
+        Integer shopOrderId = Integer.valueOf(split[2]);
         // 订单信息
         OrderVo order = orderCommonMapper.getOrderByOrderId(orderId);
+        ShopOrderVo shopOrder = orderCommonMapper.getShopOrderByOrderId(shopOrderId);
         if (null == order) {
             return "订单不存在";
         }
+        if (null == shopOrder) {
+            return "子订单不存在";
+        }
         // 支付记录
         List<DiscernReceiptVo> discernReceiptList = orderCommonMapper.getDiscernReceipt(order.getOrderId(), order.getShopOrderIds());
         double receiptAmount = 0d;
@@ -1007,6 +1001,23 @@ public class HeliPayServiceImpl implements HeliPayService {
             orderPayLink.setPayStatus(1);
             payOrderMapper.updateOrderPayLinkStatus(orderPayLink);
         }
+        // 支付记录
+        //todo 子订单返佣????
+        List<DiscernReceiptVo> shopOrderDiscernReceiptList = orderCommonMapper.getShopOrderDiscernReceipt(shopOrderId);
+        double shopOrderReceiptAmount = 0d;
+        if (null != shopOrderDiscernReceiptList && shopOrderDiscernReceiptList.size() > 0) {
+            for (DiscernReceiptVo discernReceipt : shopOrderDiscernReceiptList) {
+                shopOrderReceiptAmount = MathUtil.add(shopOrderReceiptAmount, discernReceipt.getAssociateAmount()).doubleValue();
+            }
+        }
+        shopOrder.setReceiptAmount(MathUtil.add(shopOrderReceiptAmount, amount).doubleValue());
+        //均摊后needpay:已支付
+        if (MathUtil.compare(shopOrder.getRealPay(), shopOrder.getReceiptAmount()) == 0) {
+            shopOrder.setReceiptStatus(3);
+        } else {
+            shopOrder.setReceiptStatus(2);
+        }
+        payOrderMapper.updateShopOrder(shopOrder);
         // 保存收款记录
         DiscernReceiptPo discernReceipt = new DiscernReceiptPo();
         discernReceipt.setPayWay(1);
@@ -1035,55 +1046,11 @@ public class HeliPayServiceImpl implements HeliPayService {
         relation.setSplitStatus(0);
         relation.setRelationType(2);
         relation.setDelFlag(0);
+        relation.setShopOrderId(shopOrderId);
         // 保存 收款项和订单关系
         baseMapper.insertOrderReceiptRelation(relation);
         log.info("【支付异步回调】>>>>>>>>>>>收款项和订单关系(insert[cm_receipt_order_relation])id:" + relation.getId() + ",orderId:" + orderId);
 
-        // 商品数据
-        List<OrderProductVo> orderProductList = orderCommonMapper.getOrderProductByOrderId(orderId);
-        // 判断是否是充值商品
-        int rechargeFlag = 0;
-        // 缴纳订金订单
-        int[] productId1 = {6060, 6061, 6062, 6063, 6064};
-        // 充值余额订单
-        int[] productId2 = {6065, 6066, 6067, 6068, 6069};
-        for (OrderProductVo product : orderProductList) {
-            if (ArrayUtils.contains(productId1, product.getProductId())) {
-                rechargeFlag = 1;
-                break;
-            }
-            if (ArrayUtils.contains(productId2, product.getProductId())) {
-                rechargeFlag = 2;
-                break;
-            }
-        }
-        if (rechargeFlag > 0) {
-            // 账户余额
-            double oldUserMoney = baseMapper.getUserMoney(order.getUserId());
-            double userMoney = MathUtil.add(oldUserMoney, amount).doubleValue();
-            // 可用余额
-            Double oldAvailableMoney = baseMapper.getAbleUserMoney(order.getUserId());
-            double availableMoney = MathUtil.add(oldAvailableMoney, amount).doubleValue();
-            payOrderMapper.updateMoneyByUserId(userMoney, availableMoney, order.getUserId());
-            log.info("【支付异步回调】>>>>>>>>>>>更新用户余额(update[user])userId:" + order.getUserId() + ",orderId:" + orderId);
-            //保存余额到余额收支记录
-            BalanceRecordPo balanceRecord = new BalanceRecordPo();
-            balanceRecord.setUserId(order.getUserId());
-            balanceRecord.setType(1);
-            if (rechargeFlag == 1) {
-                balanceRecord.setBalanceType(6);
-            } else {
-                balanceRecord.setBalanceType(7);
-            }
-            balanceRecord.setAddDate(new Date());
-            balanceRecord.setAmount(amount);
-            balanceRecord.setOrderId(orderId);
-            balanceRecord.setRemark("订单商品充值余额");
-            balanceRecord.setDelFlag(0);
-            // 保存 余额收支记录
-            baseMapper.insertBalanceRecord(balanceRecord);
-            log.info("【支付异步回调】>>>>>>>>>>>>>>>>>>>>>>>>>>订单商品充值余额(insert[cm_user_balance_record])orderId:" + orderId);
-        }
         // 线上支付与自主下单送豆(已全部收款),最后一笔线上支付成功后,赠送200采美豆
         if (3 == order.getReceiptStatus() && 0 == order.getSecondHandOrderFlag()) {
             UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
@@ -1158,6 +1125,110 @@ public class HeliPayServiceImpl implements HeliPayService {
         return "SUCCESS";
     }
 
+    @Override
+    public ResponseJson<List<ShopOrderVo>> getShopOrders(Integer orderId) {
+        String shopOrderId = baseMapper.findShopOrderIds(orderId);
+        // 子订单
+        if (StringUtils.isBlank(shopOrderId)) {
+            return ResponseJson.error("子订单为空!", null);
+        }
+        String[] shopOrderIdArr = shopOrderId.split(",");
+        List<String> shopOrderIds = Arrays.asList(shopOrderIdArr);
+        List<ShopOrderVo> shopOrderList = orderCommonMapper.getShopOrderList(shopOrderIds);
+        shopOrderList.forEach(shopOrder -> {
+            // 店铺促销活动
+            PromotionsVo shopPromotion = null;
+            if (null != shopOrder.getOrderPromotionsId() && shopOrder.getOrderPromotionsId() > 0) {
+                shopPromotion = orderCommonMapper.getOrderPromotionsById(shopOrder.getOrderPromotionsId());
+                shopOrder.setShopPromotion(shopPromotion);
+            }
+            List<OrderProductVo> orderProductList = orderCommonMapper.getShopOrderProduct(shopOrder.getShopOrderId());
+            orderProductList.removeIf(Objects::isNull);
+            orderProductList.forEach(orderProduct -> {
+                // 不含税可开票商品,单价/折后单价在原基础上加上税费
+                boolean taxFlag = (Integer.valueOf(0).equals(orderProduct.getIncludedTax()) && (Integer.valueOf(1).equals(orderProduct.getInvoiceType()) || Integer.valueOf(2).equals(orderProduct.getInvoiceType())));
+                if (taxFlag) {
+                    Double valueTax = MathUtil.div(MathUtil.mul(orderProduct.getPrice(), orderProduct.getTaxRate()), 100).doubleValue();
+                    orderProduct.setPrice(MathUtil.add(orderProduct.getPrice(), valueTax).doubleValue());
+                    orderProduct.setDiscountPrice(MathUtil.add(orderProduct.getDiscountPrice(), orderProduct.getAddedValueTax()).doubleValue());
+                }
+                orderProduct.setImage(ImageUtil.getImageUrl("product", orderProduct.getImage(), domain));
+                // 查询订单下商品的促销活动
+                if (null != orderProduct.getOrderPromotionsId() && orderProduct.getOrderPromotionsId() > 0) {
+                    PromotionsVo promotions = orderCommonMapper.getOrderPromotionsById(orderProduct.getOrderPromotionsId());
+                    if (null != promotions) {
+                        if (taxFlag && Integer.valueOf(1).equals(promotions.getType()) && Integer.valueOf(1).equals(promotions.getMode())) {
+                            promotions.setTouchPrice(MathUtil.add(promotions.getTouchPrice(), MathUtil.div(MathUtil.mul(promotions.getTouchPrice(), orderProduct.getTaxRate()), 100)).doubleValue());
+                        }
+                        orderProduct.setProductPromotion(promotions);
+                    }
+                }
+                // 超级会员优惠商品设置优惠标签
+                if (null != orderProduct.getSvipPriceFlag() && 1 == orderProduct.getSvipPriceFlag()) {
+                    if (1 == orderProduct.getSvipPriceType()) {
+                        orderProduct.setSvipPriceTag(MathUtil.div(orderProduct.getSvipDiscount(), 10, 1) + "折");
+                    } else if (2 == orderProduct.getSvipPriceType()) {
+                        orderProduct.setSvipPriceTag("¥" + orderProduct.getDiscountPrice());
+                    }
+                }
+            });
+            shopOrder.setObligation(MathUtil.sub(shopOrder.getRealPay(), shopOrder.getReceiptAmount()).doubleValue());
+            if(998==shopOrder.getShopId()){
+                shopOrder.setObligation(shopOrder.getTotalAmount());
+            }
+            shopOrder.setOrderProductList(orderProductList);
+            shopOrder.setShopLogo(ImageUtil.getImageUrl("shopLogo", shopOrder.getShopLogo(), domain));
+        });
+        return ResponseJson.success(shopOrderList);
+    }
+
+    @Override
+    public ResponseJson<JSONObject> getUnionResult(String mbOrderId, Integer orderFlag, Integer shopOrderId) {
+        String customerNumber = "";
+        if (0 == orderFlag) {
+            customerNumber = Constant.CUSTOMERNUM;
+        } else {
+            if (null == shopOrderId) {
+                return ResponseJson.error("子订单Id不能为空!", null);
+            }
+            String splitCode = payOrderMapper.getSplitCodeByShopOrderId(shopOrderId);
+            if (null == splitCode) {
+                return ResponseJson.error("订单信息不正确!", null);
+            }
+            customerNumber = splitCode;
+        }
+        Map<String, String> sPara = new HashMap<String, String>();
+        sPara.put("P1_bizType", "OnlineQuery");
+        sPara.put("P2_orderId", mbOrderId);
+        sPara.put("P3_customerNumber", customerNumber);
+        StringBuffer sb = new StringBuffer();
+        sb.append("&").append("OnlineQuery").append("&").append(mbOrderId).append("&")
+                .append(customerNumber).append("&").append(WANGYIN);
+        String sign = Disguiser.disguiseMD5(sb.toString());
+        sPara.put("sign", sign);
+        try {
+            OnlineCheckVo on = OnlinePostFormUtil.postForm(sPara, YL, sign, OnlineCheckVo.class);
+            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(on), JSONObject.class);
+            if (!"0000".equals(on.getRt2_retCode())) {
+                log.info("查询失败:" + on.toString());
+                return ResponseJson.error("查询失败", jsonObject);
+            } else {
+                String assemblyRespOriSign = MyBeanUtils.getSignedByPresetParameter(on, OnlineCheckVo.NEED_SIGN_PARAMS);
+                log.info("组装返回结果签名串:" + assemblyRespOriSign);
+                assemblyRespOriSign += Constant.SPLIT + WANGYIN;
+                String checkSign = Disguiser.disguiseMD5(assemblyRespOriSign.trim());
+                if (!checkSign.equals(on.getSign())) {
+                    return ResponseJson.error("验签失败", jsonObject);
+                } else {
+                    return ResponseJson.success("查询成功", jsonObject);
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
     public static <T> T postForm(Map<String, String> params, String url, String sign, Class<T> clazz) {
         FormBody.Builder builder = new FormBody.Builder();
         for (Map.Entry<String, String> entry : params.entrySet()) {

+ 156 - 57
src/main/java/com/caimei365/order/service/impl/PayOrderServiceImpl.java

@@ -102,7 +102,20 @@ public class PayOrderServiceImpl implements PayOrderService {
             return ResponseJson.success(map);
         }
         // 付款金额
-        orderCommonService.getDiscernReceiptAndSetOrder(order);
+        List<DiscernReceiptVo> discernReceiptAndSetOrder = orderCommonService.getDiscernReceiptAndSetOrder(order);
+        if (null == discernReceiptAndSetOrder || discernReceiptAndSetOrder.size() == 0) {
+            //无支付记录可余额抵扣
+            map.put("balanceFlag", 0);
+        } else {
+            long count = discernReceiptAndSetOrder.stream().filter(d -> d.getPayWay().equals(2) || d.getPayWay().equals(3)).count();
+            if (count > 0) {
+                map.put("balanceFlag", 0);
+            }
+            long onlineCount = discernReceiptAndSetOrder.stream().filter(d -> d.getPayWay().equals(1)).count();
+            if (onlineCount > 0 && 0 == count) {
+                map.put("balanceFlag", 1);
+            }
+        }
         map.put("pendingPayments", order.getPendingPayments());
         map.put("onlinePayFlag", order.getOnlinePayFlag());
         // 商品数据
@@ -214,13 +227,12 @@ public class PayOrderServiceImpl implements PayOrderService {
             log.info("【订单支付,线上/线下余额抵扣】>>>>>>>>>>>>>>>>>>>>>>>>>>新增用户余额收支记录(insert[cm_user_balance_record])orderId:" + orderId);
             log.info("************************订单支付完成消息推送*********************");
             //判断是否是二手订单和返佣订单
-            if (0 == orderClubMapper.getsecondHandOrderFlag(orderId) && 0 == orderClubMapper.getrebateFlag(orderId) && !"6060".equals(orderClubMapper.getProductOrder(orderId))){
-
+            if (0 == orderClubMapper.getsecondHandOrderFlag(orderId) && 0 == orderClubMapper.getrebateFlag(orderId) && !"6060".equals(orderClubMapper.getProductOrder(orderId))) {
                 try {
                     String accessToken = weChatService.getAccessToken();
                     List<String> openidList = payOrderMapper.getOpenidListByPermission(orderClubMapper.getOpenidunionId(order.getUserId()));
                     openidList.removeIf(Objects::isNull);
-                    String name = StringUtils.strip(orderClubMapper.getOrderIds(orderId).toString().substring(0,11), "[]");
+                    String name = StringUtils.strip(orderClubMapper.getOrderIds(orderId).toString().substring(0, 11), "[]");
                     String associateTitle = "订单支付成功!";
                     Double money = orderClubMapper.getpayTotalFee(orderId);
                     String orderno = order.getOrderNo();
@@ -236,8 +248,10 @@ public class PayOrderServiceImpl implements PayOrderService {
                     log.error("【订单发货通知】获取微信公众号access_token异常!", e);
                 }
             }
-            log.info("支付成功"+order.getUserId());
+            log.info("支付成功" + order.getUserId());
         }
+        order.setOnlinePayFlag(1);
+        baseMapper.updateOrderOnlineFlag(order.getOrderId());
         Map<String, Object> map = new HashMap<>(2);
         map.put("order", order);
         map.put("balancePayFee", balancePayFee);
@@ -318,7 +332,7 @@ public class PayOrderServiceImpl implements PayOrderService {
             }
             totalCostPrice.set(MathUtil.add(costPrice, totalCostPrice.get()).doubleValue());
         });
-
+        Integer onlinePay = order.getOnlinePayFlag();
         // 返回数据
         Map<String, Object> map = new HashMap<>();
         map.put("userName", userName);
@@ -326,17 +340,14 @@ public class PayOrderServiceImpl implements PayOrderService {
         map.put("discernReceipt", discernReceiptList);
         map.put("orderProductList", orderProductList);
         //能否线上判断付供应商是否大于订单金额
-//        orderCommonService.getDiscernReceiptAndSetOrder(order);
-//        boolean payButton = order.isPayButton();
-
-        //todo 线上支付优化,订单商品中有没设置分帐帐号的无法线上
+        if (order.getBalancePayFee() > 0 || totalCostPrice.get() > order.getPayTotalFee()) {
+            onlinePay = 1;
+        }
         Integer num = orderCommonMapper.findSplitCode(orderId);
         if (num > 0) {
-            map.put("onlinePay", 2);
-        }
-        if (0 == num) {
-            map.put("onlinePay", 1);
+            onlinePay = 1;
         }
+        map.put("onlinePay", onlinePay);
         return ResponseJson.success(map);
     }
 
@@ -347,18 +358,19 @@ public class PayOrderServiceImpl implements PayOrderService {
      * @param payLinkDto {
      *                   orderId       订单ID
      *                   vipRecordId   会员购买记录Id
+     *                   couponRecordId 优惠券购买记录id
      *                   }
      */
     @Override
     public ResponseJson<String> getPayLink(PayLinkDto payLinkDto) {
         OrderPayLinkVo orderPayLink = null;
-        if (null != payLinkDto.getOrderId()) {
+        if (null != payLinkDto.getShopOrderId()) {
             // 订单信息
-            OrderVo order = orderCommonMapper.getOrderByOrderId(payLinkDto.getOrderId());
+            OrderVo order = orderCommonMapper.getOrderByShopOrderId(payLinkDto.getShopOrderId());
             if (null == order) {
                 return ResponseJson.error("订单不存在", null);
             }
-            orderPayLink = payOrderMapper.getOrderPayLink(payLinkDto.getOrderId(), null);
+            orderPayLink = payOrderMapper.getOrderPayLink(payLinkDto.getShopOrderId(), null);
         } else if (null != payLinkDto.getVipRecordId()) {
             orderPayLink = payOrderMapper.getVipPayLink(payLinkDto.getVipRecordId(), null);
         } else {
@@ -402,7 +414,7 @@ public class PayOrderServiceImpl implements PayOrderService {
         } else {
             orderPayLink.setUnpaidAmount(payLinkDto.getUnpaidAmount());
         }
-        orderPayLink.setOrderId(payLinkDto.getOrderId());
+        orderPayLink.setShopOrderId(payLinkDto.getShopOrderId());
         orderPayLink.setVipRecordId(payLinkDto.getVipRecordId());
         orderPayLink.setAuthVipRecordId(payLinkDto.getAuthVipRecordId());
         orderPayLink.setPayType(payLinkDto.getPayType());
@@ -439,7 +451,7 @@ public class PayOrderServiceImpl implements PayOrderService {
     @Override
     public ResponseJson<Map<String, Object>> linkPayData(String linkLogo) {
         OrderPayLinkVo orderPayLink = payOrderMapper.getPayLinkByLinkLogo(linkLogo);
-        if (null == orderPayLink || (null == orderPayLink.getOrderId() && null == orderPayLink.getVipRecordId() && null == orderPayLink.getAuthVipRecordId())) {
+        if (null == orderPayLink || (null == orderPayLink.getShopOrderId() && null == orderPayLink.getVipRecordId() && null == orderPayLink.getAuthVipRecordId())) {
             // 已重新生成链接
             return ResponseJson.error("链接已更新,请重新获取", null);
         }
@@ -450,14 +462,17 @@ public class PayOrderServiceImpl implements PayOrderService {
         AuthUserVo authUser = null;
         // 链接类型:1订单,2超级会员,3认证通会员
         int type = 0;
+        // 订单标识,0非订单,1订单
+        int orderFlag = 0;
         // 订单支付记录
         List<DiscernReceiptVo> discernReceiptList = null;
-        if (null != orderPayLink.getOrderId()) {
+        if (null != orderPayLink.getShopOrderId()) {
+            orderFlag = 1;
             type = 1;
             // 订单信息
-            OrderVo order = orderCommonMapper.getOrderByOrderId(orderPayLink.getOrderId());
+            OrderVo order = orderCommonMapper.getOrderByShopOrderId(orderPayLink.getShopOrderId());
             // 支付记录
-            discernReceiptList = orderCommonMapper.getDiscernReceipt(order.getOrderId(), order.getShopOrderIds());
+            discernReceiptList = orderCommonMapper.getShopOrderDiscernReceipt(orderPayLink.getShopOrderId());
             // 机构信息
             userName = baseMapper.getUserNameByUserId(order.getUserId());
         } else if (null != orderPayLink.getVipRecordId()) {
@@ -503,6 +518,7 @@ public class PayOrderServiceImpl implements PayOrderService {
             time = dateFormat.format(orderPayLink.getEffectiveTime());
         }
         Map<String, Object> map = new HashMap<>(5);
+        map.put("orderFlag", orderFlag);
         map.put("type", type);
         map.put("orderPayLink", orderPayLink);
         map.put("userName", userName);
@@ -638,6 +654,93 @@ public class PayOrderServiceImpl implements PayOrderService {
         return toPayOrder(payParam, headers);
     }
 
+    @Override
+    public ResponseJson<Map<String, Object>> getCheckoutShopOrders(Integer shopOrderId) {
+        // 订单信息
+        ShopOrderVo shop = orderCommonMapper.getShopOrderByOrderId(shopOrderId);
+        OrderVo order = orderCommonMapper.getOrderByOrderId(shop.getOrderId());
+        Integer onlinePay = order.getOnlinePayFlag();
+        if (null == shop || null == order) {
+            return ResponseJson.error("订单不存在", null);
+        }
+        // 机构信息
+        String userName = baseMapper.getUserNameByUserId(order.getUserId());
+        // 支付记录
+        List<DiscernReceiptVo> discernReceiptList = orderCommonMapper.getShopOrderDiscernReceipt(shopOrderId);
+        AtomicDouble receiptAmount = new AtomicDouble(0d);
+        AtomicBoolean offlineFlag = new AtomicBoolean(false);
+        if (!discernReceiptList.isEmpty()) {
+            discernReceiptList.forEach(discernReceipt -> {
+                if (2 == discernReceipt.getPayWay()) {
+                    offlineFlag.set(true);
+                }
+                if (3 == discernReceipt.getReceiptStatus()) {
+                    receiptAmount.set(MathUtil.add(receiptAmount.get(), discernReceipt.getAssociateAmount()).doubleValue());
+                }
+                if (null != discernReceipt.getPayType()) {
+                    discernReceipt.setPayTypeStr(ReceivablesType.getReceivablesType(discernReceipt.getPayType()));
+                }
+            });
+            if (offlineFlag.get()) {
+                return ResponseJson.error("已经线下支付过,只能线下支付!", null);
+            }
+        }
+        shop.setReceiptAmount(receiptAmount.get());
+        shop.setObligation(MathUtil.sub(shop.getRealPay(), receiptAmount.get()).doubleValue());
+        if(998==shop.getShopId()){
+            shop.setObligation(orderCommonMapper.findShopFee(shopOrderId));
+        }
+        // 总成本
+        AtomicDouble totalCostPrice = new AtomicDouble(0d);
+        // 商品数据
+        List<OrderProductVo> orderProductList = orderCommonMapper.getOrderProductByOrderId(shop.getOrderId());
+        // 子订单商品数据
+        List<OrderProductVo> orderProductByShopOrderId = orderCommonMapper.getOrderProductByShopOrderId(shopOrderId);
+        //过滤运费商品
+        orderProductList.removeIf(product -> product.getShopId() == 998);
+        // 是否有商品发票属性的限制
+        orderProductList.forEach(orderProduct -> {
+            // 商品含税未知 or 订单选择开企业发票,商品不含税不能开票
+            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())));
+            if (productTaxFlag) {
+                order.setInvoiceStatus(true);
+            }
+            //当应付金额小于订单总成本时,不能走线上支付,总成本=商品成本 + 供应商运费 + 供应商税费
+            double costPrice = MathUtil.mul(orderProduct.getCostPrice(), orderProduct.getNum()).doubleValue();
+            if (Integer.valueOf(0).equals(orderProduct.getIncludedTax()) && !Integer.valueOf(3).equals(orderProduct.getInvoiceType())) {
+                //应付总税费
+                Double payableTax = MathUtil.mul(orderProduct.getSingleShouldPayTotalTax(), orderProduct.getNum()).doubleValue();
+                //成本+税费
+                costPrice = MathUtil.add(costPrice, payableTax).doubleValue();
+            }
+            List<ShopOrderVo> shopOrderList = orderCommonMapper.getShopOrderListByOrderId(order.getOrderId());
+            for (ShopOrderVo shopOrder : shopOrderList) {
+                // 付供应商运费
+                Double shopPostFee = shopOrder.getShopPostFee();
+                costPrice = MathUtil.add(costPrice, shopPostFee).doubleValue();
+            }
+            totalCostPrice.set(MathUtil.add(costPrice, totalCostPrice.get()).doubleValue());
+        });
+        //. 后台线上支付开关2.商品是否有分账账号 3. 订单是否进行过线下支付 4.是否使用了余额抵扣
+        // 5. 子订单支付金额减去手续费后是否不小于子订单成本 。 6. 各个子订单分摊后的最终子订单金额之和是否等于主订单应付金额。这6个要求的判断优先级同以上顺序。
+        Integer num = orderCommonMapper.findSplitCode(shop.getOrderId());
+        if (num > 0) {
+            onlinePay = 1;
+        }
+        if (order.getBalancePayFee() > 0 || totalCostPrice.get() > order.getPayTotalFee()) {
+            onlinePay = 1;
+        }
+        // 返回数据
+        Map<String, Object> map = new HashMap<>();
+        map.put("userName", userName);
+        map.put("shopOrder", shop);
+        map.put("discernReceipt", discernReceiptList);
+        map.put("orderProductList", orderProductByShopOrderId);
+        map.put("onlinePay", onlinePay);
+        return ResponseJson.success(map);
+    }
+
     /**
      * 订单线上支付
      */
@@ -806,28 +909,28 @@ public class PayOrderServiceImpl implements PayOrderService {
             log.info("【支付异步回调】>>>>>>>>>>>>>>订单(全部支付),修改订单状态:" + order.getStatus() + ",orderId:" + orderId);
             log.info("************************订单支付完成消息推送*********************");
             //判断是否是二手订单和返佣订单
-                if (0 == orderClubMapper.getsecondHandOrderFlag(orderId) && 0 == orderClubMapper.getrebateFlag(orderId) && !"6060".equals(orderClubMapper.getProductOrder(orderId))) {
-                    try {
-                        String accessToken = weChatService.getAccessToken();
-                        log.info(">>>>>>>>>>>>>>>>>"+order.getUserId()+">>>>>>>>>>>>>>"+orderClubMapper.getOpenidunionId(order.getUserId()));
-                        List<String> openidList = payOrderMapper.getOpenidListByPermission(orderClubMapper.getOpenidunionId(order.getUserId()));
-                        openidList.removeIf(Objects::isNull);
-                        String name = StringUtils.strip(orderClubMapper.getOrderIds(orderId).toString().substring(0,11), "[]");
-                        String associateTitle = "订单支付成功!";
-                        Double money = orderClubMapper.getpayTotalFee(orderId);
-                        String orderno = orderClubMapper.getOrderNo(orderId);
-                        String paytime = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
-                        String remarkText = "采美将尽快为您安排发货~";
-                        // 跳转到【小程序付款-选择支付方式页面】
-                        String pagePath = "pages/user/order/order-details?orderId=" + orderId;
-                        for (String openid : openidList) {
-                            // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接)
-                            weChatService.sendTemplateMsgz(accessToken, openid, associateTitle, paytime, name, orderno, money, remarkText, pagePath);
-                        }
-                    } catch (Exception e) {
-                        log.error("【订单发货通知】获取微信公众号access_token异常!", e);
+            if (0 == orderClubMapper.getsecondHandOrderFlag(orderId) && 0 == orderClubMapper.getrebateFlag(orderId) && !orderClubMapper.getProductOrder(orderId).contains(6060)) {
+                try {
+                    String accessToken = weChatService.getAccessToken();
+                    log.info(">>>>>>>>>>>>>>>>>" + order.getUserId() + ">>>>>>>>>>>>>>" + orderClubMapper.getOpenidunionId(order.getUserId()));
+                    List<String> openidList = payOrderMapper.getOpenidListByPermission(orderClubMapper.getOpenidunionId(order.getUserId()));
+                    openidList.removeIf(Objects::isNull);
+                    String name = StringUtils.strip(orderClubMapper.getOrderIds(orderId).toString().substring(0, 11), "[]");
+                    String associateTitle = "订单支付成功!";
+                    Double money = orderClubMapper.getpayTotalFee(orderId);
+                    String orderno = orderClubMapper.getOrderNo(orderId);
+                    String paytime = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
+                    String remarkText = "采美将尽快为您安排发货~";
+                    // 跳转到【小程序付款-选择支付方式页面】
+                    String pagePath = "pages/user/order/order-details?orderId=" + orderId;
+                    for (String openid : openidList) {
+                        // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接)
+                        weChatService.sendTemplateMsgz(accessToken, openid, associateTitle, paytime, name, orderno, money, remarkText, pagePath);
                     }
+                } catch (Exception e) {
+                    log.error("【订单发货通知】获取微信公众号access_token异常!", e);
                 }
+            }
             log.info("支付成功2");
         } else {
             // 部分支付
@@ -1010,26 +1113,24 @@ public class PayOrderServiceImpl implements PayOrderService {
     /**
      * 判断此次支付是否完成
      *
-     * @param orderId           订单id
+     * @param shopOrderId       子订单id
      * @param paySuccessCounter 付款次数
      */
     @Override
-    public ResponseJson<String> payWhetherSuccess(Integer orderId, Integer paySuccessCounter) {
-        Integer dbPayCounter = payOrderMapper.getDbPaySuccessCounter(orderId);
-
+    public ResponseJson<String> payWhetherSuccess(Integer shopOrderId, Integer paySuccessCounter) {
+        Integer dbPayCounter = payOrderMapper.getDbPaySuccessCounter(shopOrderId);
+        Integer orderId = payOrderMapper.getOrderId(shopOrderId);
         if (paySuccessCounter.equals(dbPayCounter)) {
-
             return ResponseJson.error(-2, "支付失败", "付款次数异常");
         } else if (dbPayCounter > paySuccessCounter) {
-
-            if ( 1 == orderClubMapper.getReceiptStatus(orderId)) {
+            if (1 == orderClubMapper.getReceiptStatus(orderId)) {
                 if (0 == orderClubMapper.getsecondHandOrderFlag(orderId) && 0 == orderClubMapper.getrebateFlag(orderId)) {
                     try {
                         String accessToken = weChatService.getAccessToken();
-                        String unionid=orderClubMapper.getOpenidunionId(orderClubMapper.getUserId(orderId));
+                        String unionid = orderClubMapper.getOpenidunionId(orderClubMapper.getUserId(orderId));
                         List<String> openidList = payOrderMapper.getOpenidListByPermission(unionid);
                         openidList.removeIf(Objects::isNull);
-                        String name = StringUtils.strip(orderClubMapper.getOrderIds(orderId).toString().substring(0,11), "[]");
+                        String name = StringUtils.strip(orderClubMapper.getOrderIds(orderId).toString().substring(0, 11), "[]");
                         String associateTitle = "订单支付成功!";
                         Double money = orderClubMapper.getpayTotalFee(orderId);
                         String orderno = orderClubMapper.getOrderNo(orderId);
@@ -1046,8 +1147,6 @@ public class PayOrderServiceImpl implements PayOrderService {
                     }
                 }
             }
-
-
             return ResponseJson.success("支付成功");
         } else {
             return ResponseJson.error("支付异常", null);
@@ -1143,12 +1242,13 @@ public class PayOrderServiceImpl implements PayOrderService {
                         totalAmount4 = MathUtil.add(totalAmount4, account.getSplitAccount()).doubleValue();
                     }
                 }
-                addMaps(maps, totalAmount1, PayUtil.publicAccountNo);
+                //分账方不能重复,1,5都是信息,加一起分
+                double v = MathUtil.add(totalAmount1, totalAmount4).doubleValue();
+                addMaps(maps, v, PayUtil.publicAccountNo);
                 addMaps(maps, totalAmount2, PayUtil.privateAccountNo);
                 addMaps(maps, totalAmount3, PayUtil.commonInvoiceNo);
                 // 网络切信息
-                // addMaps(maps, totalAmount4, PayUtil.brokerage);
-                addMaps(maps, totalAmount4, PayUtil.publicAccountNo);
+//                addMaps(maps, totalAmount4, PayUtil.publicAccountNo);
                 String parameters = JSON.toJSONString(maps);
                 log.info("【延时分账】>>>>>>>>>>分账参数: " + parameters);
 
@@ -1208,7 +1308,6 @@ public class PayOrderServiceImpl implements PayOrderService {
     }
 
     /**
-     *
      * 分账详情
      */
     private List<SplitAccountPo> setSplitAccountDetail(OrderVo order, PayParamBo payParam) {

+ 8 - 1
src/main/java/com/caimei365/order/service/impl/ReceiptServiceImpl.java

@@ -639,6 +639,12 @@ public class ReceiptServiceImpl implements ReceiptService {
             return ResponseJson.error("无权限操作!", null);
         }
         ReceiptVo receipt = receiptMapper.getReceiptDetail(id);
+        //超级管理员可以看,其他人不能看已确认的单
+        if (null != receipt.getConfirmUserPermissionId()) {
+            if(1 == receiptUser.getUserType() && !receiptUser.getId().equals(receipt.getConfirmUserPermissionId())){
+                return ResponseJson.error("无权限操作!", null);
+            }
+        }
         if (null != receipt) {
             setReceiptDetail(receipt);
             List<OrderVo> orderList = new ArrayList<>();
@@ -1604,6 +1610,7 @@ public class ReceiptServiceImpl implements ReceiptService {
                         }
                     }
                     // 更新订单收款状态
+                    order.setOnlinePayFlag(1);
                     payOrderMapper.updateOrderStatus(order);
                     log.info("【线下收款】----------审核通过订单状态改变---orderId:" + order.getOrderId() + "--status:" + order.getStatus());
                     //判断是否有充值商品,充值到余额
@@ -2075,7 +2082,7 @@ public class ReceiptServiceImpl implements ReceiptService {
                 contentTime.add(group);
             }
             // 建设银行
-            if (Arrays.asList(1, 18, 19).contains(typeId)) {
+            if (Arrays.asList(1, 18, 19, 20).contains(typeId)) {
                 for (int i = 1; i < 5; i++) {
                     if (contentTime.get(i).length() < 2) {
                         String s = contentTime.get(i);

+ 5 - 1
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -34,6 +34,7 @@ import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
 
 import static com.alibaba.fastjson.JSON.parseArray;
 import static com.alibaba.fastjson.JSON.parseObject;
@@ -68,6 +69,8 @@ public class SubmitServiceImpl implements SubmitService {
     @Resource
     private PayOrderMapper payOrderMapper;
 
+    public static String unionId;
+    public static Integer oderid;
 
     /**
      * 生成订单
@@ -128,6 +131,7 @@ public class SubmitServiceImpl implements SubmitService {
         // 获取机构用户Id
         Integer clubUserId = baseMapper.getUserIdByClubId(submitDto.getClubId());
         submitDto.getUnionId();
+        unionId=submitDto.getUnionId();
         if (null == clubUserId || clubUserId == 0) {
             return ResponseJson.error("机构用户信息异常!", null);
         }
@@ -1545,7 +1549,7 @@ public class SubmitServiceImpl implements SubmitService {
             String name="0";
             try {
                 String accessToken = weChatService.getAccessToken();
-                List<String> openidList = orderClubMapper.getOpenidListByPermission(orderClubMapper.getOpenidunionId(mainOrder.getUserId()));
+                List<String> openidList = orderClubMapper.getOpenidListByPermission(unionId);
                 openidList.removeIf(Objects::isNull);
                 String i=orderClubMapper.getOrderIds(mainOrder.getOrderId()).toString();
                 if(i.length()<10){

+ 2 - 2
src/main/java/com/caimei365/order/utils/ImageUtil.java

@@ -53,12 +53,12 @@ public class ImageUtil {
             } else if (StringUtils.equals(dirName, "club")) {
                 image = "/img/default/default_club.jpg";
             } else if (StringUtils.equals(dirName, "shopLogo")) {
-                image = "/img/default/suppliver.jpg";
+                image = "/img/default/suppliver.png";
             }else if (StringUtils.equals(dirName, "caiMeiImage")) {
                 image = "/img/default/caiMeiImage.jpg";
             }
         }
-        return dirName.trim() + image;
+        return domain + image;
     }
 
 

+ 9 - 2
src/main/resources/mapper/BaseMapper.xml

@@ -267,9 +267,9 @@
     <insert id="insertOrderReceiptRelation" keyColumn="id" keyProperty="id"
             parameterType="com.caimei365.order.model.po.OrderReceiptRelationPo" useGeneratedKeys="true">
         INSERT INTO cm_receipt_order_relation (relationType, receiptId, associationType, associateAmount, orderId, couponRecordId, vipRecordId, authVipRecordId, delFlag,
-                                               mbOrderId, orderRequestNo, splitStatus, productId)
+                                               mbOrderId, orderRequestNo, splitStatus, productId,shopOrderId)
         VALUES (#{relationType}, #{receiptId}, #{associationType}, #{associateAmount}, #{orderId}, #{couponRecordId}, #{vipRecordId}, #{authVipRecordId}, #{delFlag},
-                #{mbOrderId}, #{orderRequestNo}, #{splitStatus}, #{productId})
+                #{mbOrderId}, #{orderRequestNo}, #{splitStatus}, #{productId},#{shopOrderId})
     </insert>
     <insert id="insertBeansHistory" parameterType="com.caimei365.order.model.po.UserBeansHistoryPo">
         INSERT INTO user_beans_history (userId, type, beansType, orderId, num, pushStatus, addTime, delFlag)
@@ -296,6 +296,10 @@
             ableUserMoney = #{ableUserMoney}
         WHERE userID = #{userId}
     </update>
+    <update id="updateOrderOnlineFlag">
+        update cm_order set onlinePayFlag = 1
+        where orderID = #{orderId}
+    </update>
     <insert id="insertBalanceRecord" parameterType="com.caimei365.order.model.po.BalanceRecordPo">
         INSERT INTO cm_user_balance_record (userId, type, balanceType, addDate, amount, orderId, receiptId, remark, delFlag)
         VALUES (#{userId}, #{type}, #{balanceType}, #{addDate}, #{amount}, #{orderId}, #{receiptId}, #{remark}, #{delFlag})
@@ -349,4 +353,7 @@
         LEFT JOIN cm_receipt_order_relation cror ON cdr.id=cror.receiptID
         WHERE cror.mbOrderId=#{mbOrderId}
     </select>
+    <select id="findShopOrderIds" resultType="java.lang.String">
+        select shopOrderIDs from cm_order where orderID = #{orderId}
+    </select>
 </mapper>

+ 1 - 3
src/main/resources/mapper/CartSellerMapper.xml

@@ -128,11 +128,9 @@
             if(csp.id is not null,1,0) as svipProductFlag,
             csp.priceType as svipPriceType,
             csp.discount as svipDiscount,
-            csp.discountPrice as svipDiscountPrice,
-            cop.productType as giftType
+            csp.discountPrice as svipDiscountPrice
         FROM bp_order_product_cart c
         LEFT JOIN product p ON c.productId = p.productID
-        left join cm_order_product cop on c.productId = cop.productID
         LEFT JOIN cm_svip_product csp ON p.productID = csp.productId
         WHERE c.serviceProviderId = #{serviceProviderId} AND c.clubId = #{clubId} AND c.shopID = #{shopId}
         AND p.productID in

+ 5 - 5
src/main/resources/mapper/OrderClubMapper.xml

@@ -497,17 +497,17 @@
         AND scr.delFlag = '0' AND osc.expiredTime > NOW()
     </select>
     <select id="getOpenidListByPermission" resultType="java.lang.String">
-        SELECT openid FROM `wechat_user` WHERE unionId= #{unionid}
+        SELECT openid FROM `wechat_user` WHERE unionId= #{unionId}
     </select>
 
     <select id="getOpenidunionId" resultType="java.lang.String">
         SELECT DISTINCT cm.unionId FROM  `cm_mall_operation_user` cm
         LEFT JOIN `user` u ON u.userID = cm.userID
-        WHERE u.userID=#{userid}
+        WHERE u.userID=#{userId}
     </select>
 
     <select id="getProductOrder" resultType="java.lang.Integer">
-        SELECT productID FROM `cm_order_product` WHERE orderId=#{orderid}
+        SELECT productID FROM `cm_order_product` WHERE orderId=#{orderId}
     </select>
 
     <select id="getOrderIds" resultType="java.lang.String">
@@ -561,7 +561,7 @@
         LEFT JOIN cm_coupon cc ON a.couponId = cc.id
         WHERE if(cc.moneyCouponFlag=2,cc.delFlag = 0,cc.id>0)
         AND a.delFlag = 0
-        AND a.couponId = #{clubCouponId}
+        AND a.id = #{clubCouponId}
         AND a.status = 1
         AND NOW() <![CDATA[ > ]]> startDate
         AND NOW() <![CDATA[ < ]]> if(receiveFlag = 1,endDate,date_add(if((SELECT registerTime FROM user WHERE userID = #{userId}) <![CDATA[ > ]]> startDate and (SELECT registerTime FROM user WHERE userID = #{userId}) <![CDATA[ < ]]> endDate,(SELECT registerTime FROM user WHERE userID = #{userId}),startDate),
@@ -587,6 +587,6 @@
         select userId from cm_order where orderID = #{orderId}
     </select>
     <select id="getUserId" resultType="java.lang.Integer">
-        SELECT userID FROM `cm_order` WHERE orderID=#{orderid}
+        SELECT userID FROM `cm_order` WHERE orderID=#{orderId}
     </select>
 </mapper>

+ 533 - 445
src/main/resources/mapper/OrderCommonMapper.xml

@@ -2,7 +2,9 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.order.mapper.OrderCommonMapper">
     <select id="countLogisticsBatch" resultType="java.lang.Integer">
-        SELECT COUNT(*) FROM cm_logistics_batch WHERE orderID= #{orderId}
+        SELECT COUNT(*)
+        FROM cm_logistics_batch
+        WHERE orderID = #{orderId}
     </select>
     <select id="getShopOrderList" resultType="com.caimei365.order.model.vo.ShopOrderVo">
         SELECT
@@ -34,7 +36,11 @@
         cso.sendOutStatus,
         s.name AS shopName,
         s.logo AS shopLogo,
-        s.shopType as shopType
+        s.shopType as shopType,
+        ifnull(cso.receiptAmount,0) as receiptAmount,
+        cso.eachDiscount,
+        cso.realPay,
+        cso.receiptStatus
         FROM cm_shop_order cso
         LEFT JOIN shop s ON cso.shopID = s.shopID
         WHERE cso.delFlag = 0
@@ -44,149 +50,162 @@
         </foreach>
     </select>
     <select id="getOrderPromotionsById" resultType="com.caimei365.order.model.vo.PromotionsVo">
-        SELECT
-        id,
-        name,
-        description,
-        orderId,
-        type,
-        mode,
-        touchPrice,
-        reducedPrice,
-        beginTime,
-        endTime,
-        status
+        SELECT id,
+               name,
+               description,
+               orderId,
+               type,
+               mode,
+               touchPrice,
+               reducedPrice,
+               beginTime,
+               endTime,
+               status
         FROM cm_promotions_order
         WHERE id = #{orderPromotionsId}
     </select>
     <select id="getShopOrderProduct" resultType="com.caimei365.order.model.vo.OrderProductVo">
-        SELECT
-        cop.orderProductID AS orderProductId,
-        cop.orderID AS orderId,
-        cop.orderNo,
-        cop.shopOrderID AS shopOrderId,
-        cop.shopOrderNo,
-        cop.orderPromotionsId,
-        cop.productId,
-        cop.shopId,
-        cop.name,
-        cop.productImage AS image,
-        cop.price,
-        cop.shopName,
-        cop.costPrice,
-        cop.normalPrice,
-        cop.ladderPriceFlag,
-        cop.discountPrice,
-        cop.discount,
-        cop.totalAmount,
-        cop.totalFee,
-        cop.shouldPayFee,
-        cop.productUnit,
-        cop.num,
-        cop.presentNum,
-        cop.discountFee,
-        cop.includedTax,
-        cop.invoiceType,
-        cop.taxRate,
-        cop.addedValueTax,
-        cop.totalAddedValueTax,
-        cop.singleShouldPayTotalTax,
-        cop.shouldPayTotalTax,
-        cop.shopProductAmount,
-        cop.singleShopFee,
-        cop.shopFee,
-        cop.singleOtherFee,
-        cop.otherFee,
-        cop.singleCmFee,
-        cop.cmFee,
-        cop.payStatus,
-        cop.buyAgainFlag,
-        cop.notOutStore,
-        cop.isActProduct AS actProduct,
-        cop.productType AS giftType,
-        cop.svipPriceFlag,
-        cop.svipPriceType,
-        cop.svipDiscount,
-        p.productCategory as productCategory,
-        p.productType
+        SELECT cop.orderProductID AS orderProductId,
+               cop.orderID        AS orderId,
+               cop.orderNo,
+               cop.shopOrderID    AS shopOrderId,
+               cop.shopOrderNo,
+               cop.orderPromotionsId,
+               cop.productId,
+               cop.shopId,
+               cop.name,
+               cop.productImage   AS image,
+               cop.price,
+               cop.shopName,
+               cop.costPrice,
+               cop.normalPrice,
+               cop.ladderPriceFlag,
+               cop.discountPrice,
+               cop.discount,
+               cop.totalAmount,
+               cop.totalFee,
+               cop.shouldPayFee,
+               cop.productUnit,
+               cop.num,
+               cop.presentNum,
+               cop.discountFee,
+               cop.includedTax,
+               cop.invoiceType,
+               cop.taxRate,
+               cop.addedValueTax,
+               cop.totalAddedValueTax,
+               cop.singleShouldPayTotalTax,
+               cop.shouldPayTotalTax,
+               cop.shopProductAmount,
+               cop.singleShopFee,
+               cop.shopFee,
+               cop.singleOtherFee,
+               cop.otherFee,
+               cop.singleCmFee,
+               cop.cmFee,
+               cop.payStatus,
+               cop.buyAgainFlag,
+               cop.notOutStore,
+               cop.isActProduct   AS actProduct,
+               cop.productType    AS giftType,
+               cop.svipPriceFlag,
+               cop.svipPriceType,
+               cop.svipDiscount,
+               p.productCategory  as productCategory,
+               p.productType,
+               p.productCode
         FROM cm_order_product cop
-        LEFT JOIN product p ON cop.productID = p.productID
+                 LEFT JOIN product p ON cop.productID = p.productID
         WHERE cop.shopOrderID = #{shopOrderId}
     </select>
     <select id="getDiscernReceipt" resultType="com.caimei365.order.model.vo.DiscernReceiptVo">
-        SELECT
-        cdr.id,
-        cdr.payWay,
-        cdr.payType,
-        cdr.receiptType,
-        cdr.receiptStatus,
-        cdr.receiptAmount,
-        cdr.confirmType,
-        cdr.receiptDate,
-        cdr.confirmDate,
-        cdr.reviewDate,
-        cdr.updateDate,
-        cdr.delFlag,
-        cror.associateAmount
+        SELECT cdr.id,
+               cdr.payWay,
+               cdr.payType,
+               cdr.receiptType,
+               cdr.receiptStatus,
+               cdr.receiptAmount,
+               cdr.confirmType,
+               cdr.receiptDate,
+               cdr.confirmDate,
+               cdr.reviewDate,
+               cdr.updateDate,
+               cdr.delFlag,
+               cror.associateAmount
         FROM cm_receipt_order_relation cror
-        LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
-        WHERE ((cror.orderID = #{orderId} AND cror.relationType = '2') OR (cror.orderID = #{shopOrderId} AND cror.relationType = '1'))
-        AND cror.delFlag = '0' AND cdr.delFlag = '0' AND cdr.receiptStatus = '3' AND cdr.payType != '16' AND cdr.receiptStatus IN(2,3)
+                 LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
+        WHERE ((cror.orderID = #{orderId} AND cror.relationType = '2') OR
+               (cror.orderID = #{shopOrderId} AND cror.relationType = '1'))
+          AND cror.delFlag = '0'
+          AND cdr.delFlag = '0'
+          AND cdr.receiptStatus = '3'
+          AND cdr.payType != '16'
+          AND cdr.receiptStatus IN (2, 3)
         ORDER BY cdr.receiptDate DESC
     </select>
     <select id="getVipDiscernReceipt" resultType="com.caimei365.order.model.vo.DiscernReceiptVo">
-        SELECT
-            cdr.id,
-            cdr.payWay,
-            cdr.payType,
-            cdr.receiptType,
-            cdr.receiptStatus,
-            cdr.receiptAmount,
-            cdr.confirmType,
-            cdr.receiptDate,
-            cdr.confirmDate,
-            cdr.reviewDate,
-            cdr.updateDate,
-            cdr.delFlag,
-            cror.mbOrderId,
-            cror.associateAmount
-        FROM cm_receipt_order_relation cror LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
-        WHERE vipRecordId = #{vipRecordId} AND cror.relationType = '3' AND cror.delFlag = '0' AND cdr.delFlag = '0'
+        SELECT cdr.id,
+               cdr.payWay,
+               cdr.payType,
+               cdr.receiptType,
+               cdr.receiptStatus,
+               cdr.receiptAmount,
+               cdr.confirmType,
+               cdr.receiptDate,
+               cdr.confirmDate,
+               cdr.reviewDate,
+               cdr.updateDate,
+               cdr.delFlag,
+               cror.mbOrderId,
+               cror.associateAmount
+        FROM cm_receipt_order_relation cror
+                 LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
+        WHERE vipRecordId = #{vipRecordId}
+          AND cror.relationType = '3'
+          AND cror.delFlag = '0'
+          AND cdr.delFlag = '0'
     </select>
     <select id="getRebateAmountByShopOrder" resultType="java.lang.Double">
-        SELECT
-        receiptAmount
+        SELECT receiptAmount
         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.delFlag = '0'
-        AND cror.orderID = #{shopOrderId}
-        AND cror.relationType = 1
-        AND cdr.receiptStatus= '2'
+          AND cror.orderID = #{shopOrderId}
+          AND cror.relationType = 1
+          AND cdr.receiptStatus = '2'
     </select>
     <select id="countOfflinePayment" resultType="java.lang.Integer">
         SELECT count(*)
         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' AND cror.delFlag = '0'
-        AND cdr.delFlag = '0' AND cdr.receiptStatus IN(2,3) AND cdr.payWay = '2'
+          AND cror.relationType = '2'
+          AND cror.delFlag = '0'
+          AND cdr.delFlag = '0'
+          AND cdr.receiptStatus IN (2, 3)
+          AND cdr.payWay = '2'
     </select>
     <select id="getShouldPayShopAmountList" resultType="java.lang.Double">
-        SELECT shouldPayShopAmount FROM cm_shop_order WHERE orderID = #{orderId} AND delFlag = '0'
+        SELECT shouldPayShopAmount
+        FROM cm_shop_order
+        WHERE orderID = #{orderId}
+          AND delFlag = '0'
     </select>
     <update id="updateSearchHistory">
-        UPDATE user_order_history SET
-        userId = #{userId},
-        searchWord = #{searchWord},
-        searchDate = #{searchDate},
-        delFlag = #{delFlag}
+        UPDATE user_order_history
+        SET userId     = #{userId},
+            searchWord = #{searchWord},
+            searchDate = #{searchDate},
+            delFlag    = #{delFlag}
         WHERE id = #{id}
     </update>
     <delete id="deleteSearchHistoryLimit">
-        DELETE FROM user_order_history
-        WHERE userId=#{userId}
-        AND id NOT IN (
-        SELECT temp.id FROM (SELECT id FROM user_order_history WHERE userId=#{userId} ORDER BY id DESC LIMIT 10) AS temp
+        DELETE
+        FROM user_order_history
+        WHERE userId = #{userId}
+          AND id NOT IN (
+            SELECT temp.id
+            FROM (SELECT id FROM user_order_history WHERE userId = #{userId} ORDER BY id DESC LIMIT 10) AS temp
         )
     </delete>
     <insert id="insertSearchHistory">
@@ -194,293 +213,294 @@
         VALUES (#{userId}, #{searchWord}, #{searchDate}, #{delFlag})
     </insert>
     <select id="getSearchHistoryIdByWord" resultType="java.lang.Integer">
-        SELECT id FROM user_order_history
+        SELECT id
+        FROM user_order_history
         WHERE searchWord = #{searchWord}
         ORDER BY id DESC
         LIMIT 1
     </select>
     <select id="countSearchHistory" resultType="java.lang.Integer">
-        SELECT COUNT(*) FROM user_order_history WHERE userId = #{userId}
+        SELECT COUNT(*)
+        FROM user_order_history
+        WHERE userId = #{userId}
     </select>
     <select id="getOrderProductByOrderId" resultType="com.caimei365.order.model.vo.OrderProductVo">
-        SELECT
-        cop.orderProductID AS orderProductId,
-        cop.orderID AS orderId,
-        cop.orderNo,
-        cop.shopOrderID AS shopOrderId,
-        cop.shopOrderNo,
-        cop.orderPromotionsId,
-        cop.productId,
-        cop.shopId,
-        cop.name,
-        cop.productImage AS image,
-        cop.price,
-        cop.shopName,
-        IF(cop.shopid=998 AND co.freight> 0,co.freight,cop.costPrice)AS costPrice,
-        cop.normalPrice,
-        cop.ladderPriceFlag,
-        cop.discountPrice,
-        cop.discount,
-        cop.totalAmount,
-        cop.totalFee,
-        cop.shouldPayFee,
-        cop.productUnit,
-        cop.num,
-        cop.presentNum,
-        cop.discountFee,
-        cop.includedTax,
-        cop.invoiceType,
-        cop.taxRate,
-        cop.addedValueTax,
-        cop.totalAddedValueTax,
-        cop.singleShouldPayTotalTax,
-        cop.shouldPayTotalTax,
-        cop.shopProductAmount,
-        cop.singleShopFee,
-        cop.shopFee,
-        cop.singleOtherFee,
-        cop.otherFee,
-        cop.singleCmFee,
-        cop.cmFee,
-        cop.payStatus,
-        cop.buyAgainFlag,
-        cop.notOutStore,
-        cop.isActProduct AS actProduct,
-        cop.productType,
-        p.productCategory as productCategory,
-        p.splitCode,
-        p.productType
+        SELECT cop.orderProductID                                                 AS orderProductId,
+               cop.orderID                                                        AS orderId,
+               cop.orderNo,
+               cop.shopOrderID                                                    AS shopOrderId,
+               cop.shopOrderNo,
+               cop.orderPromotionsId,
+               cop.productId,
+               cop.shopId,
+               cop.name,
+               cop.productImage                                                   AS image,
+               cop.price,
+               cop.shopName,
+               IF(cop.shopid = 998 AND co.freight > 0, co.freight, cop.costPrice) AS costPrice,
+               cop.normalPrice,
+               cop.ladderPriceFlag,
+               cop.discountPrice,
+               cop.discount,
+               cop.totalAmount,
+               cop.totalFee,
+               cop.shouldPayFee,
+               cop.productUnit,
+               cop.num,
+               cop.presentNum,
+               cop.discountFee,
+               cop.includedTax,
+               cop.invoiceType,
+               cop.taxRate,
+               cop.addedValueTax,
+               cop.totalAddedValueTax,
+               cop.singleShouldPayTotalTax,
+               cop.shouldPayTotalTax,
+               cop.shopProductAmount,
+               cop.singleShopFee,
+               cop.shopFee,
+               cop.singleOtherFee,
+               cop.otherFee,
+               cop.singleCmFee,
+               cop.cmFee,
+               cop.payStatus,
+               cop.buyAgainFlag,
+               cop.notOutStore,
+               cop.isActProduct                                                   AS actProduct,
+               cop.productType,
+               p.productCategory                                                  as productCategory,
+               p.splitCode,
+               p.productType
         FROM cm_order_product cop
-        LEFT JOIN product p ON cop.productID = p.productID
-        LEFT JOIN cm_order co ON cop.orderId=co.orderId
+                 LEFT JOIN product p ON cop.productID = p.productID
+                 LEFT JOIN cm_order co ON cop.orderId = co.orderId
         WHERE co.orderID = #{orderId}
-        AND IF(co.userBeans=0,1=1,cop.shopid!=998)
+          AND IF(co.userBeans = 0, 1 = 1, cop.shopid != 998)
         ORDER BY cop.discountPrice DESC
     </select>
     <select id="countReturnedNum" resultType="java.lang.Integer">
         SELECT SUM(crpp.actualReturnedNum)
         FROM cm_returned_purchase_product crpp
-        LEFT JOIN cm_returned_purchase rp ON rp.id = crpp.returnedID
+                 LEFT JOIN cm_returned_purchase rp ON rp.id = crpp.returnedID
         WHERE crpp.productID = #{productId}
-        AND crpp.shopOrderID = #{shopOrderId}
-        AND rp.status = '2' AND rp.delFlag = '0'
+          AND crpp.shopOrderID = #{shopOrderId}
+          AND rp.status = '2'
+          AND rp.delFlag = '0'
     </select>
     <select id="countActualCancelNum" resultType="java.lang.Integer">
         SELECT SUM(crpp.actualCancelNum)
         FROM cm_returned_purchase_product crpp
-        LEFT JOIN cm_returned_purchase rp ON rp.id = crpp.returnedID
+                 LEFT JOIN cm_returned_purchase rp ON rp.id = crpp.returnedID
         WHERE crpp.productID = #{productId}
-        AND crpp.shopOrderID = #{shopOrderId}
-        AND rp.status = '2' AND rp.delFlag = '0'
+          AND crpp.shopOrderID = #{shopOrderId}
+          AND rp.status = '2'
+          AND rp.delFlag = '0'
     </select>
     <select id="getOrderByOrderId" resultType="com.caimei365.order.model.vo.OrderVo">
-        SELECT
-        orderID AS orderId,
-        shopOrderIds,
-        orderSource,
-        orderNo,
-        organizeID AS organizeId,
-        userID AS userId,
-        clubID AS clubId,
-        buyUserID AS buyUserId,
-        orderTime AS orderTime,
-        updateDate AS updateDate,
-        delFlag,
-        userBeans,
-        orderType,
-        orderSubmitType,
-        confirmFlag,
-        onlinePayFlag,
-        splitFlag,
-        payFlag,
-        receiptStatus,
-        payStatus,
-        zeroCostFlag,
-        sendOutStatus,
-        refundType,
-        affirmPaymentFlag,
-        productCount,
-        presentCount,
-        promotionalGiftsCount,
-        hasActProduct,
-        promotionFullReduction,
-        secondHandOrderFlag,
-        invoiceFlag,
-        freePostFlag AS postageFlag,
-        freight AS postage,
-        productTotalFee,
-        orderTotalFee,
-        payTotalFee,
-        payableAmount,
-        balancePayFee,
-        discountFee,
-        status,
-        paySuccessCounter,
-        confirmTime,
-        payTime,
-        rebateFlag,
-        clauseID AS clauseId,
-        clauseName,
-        payTime,
-        orderNo
+        SELECT orderID      AS orderId,
+               shopOrderIds,
+               orderSource,
+               orderNo,
+               organizeID   AS organizeId,
+               userID       AS userId,
+               clubID       AS clubId,
+               buyUserID    AS buyUserId,
+               orderTime    AS orderTime,
+               updateDate   AS updateDate,
+               delFlag,
+               userBeans,
+               orderType,
+               orderSubmitType,
+               confirmFlag,
+               onlinePayFlag,
+               splitFlag,
+               payFlag,
+               receiptStatus,
+               payStatus,
+               zeroCostFlag,
+               sendOutStatus,
+               refundType,
+               affirmPaymentFlag,
+               productCount,
+               presentCount,
+               promotionalGiftsCount,
+               hasActProduct,
+               promotionFullReduction,
+               secondHandOrderFlag,
+               invoiceFlag,
+               freePostFlag AS postageFlag,
+               freight      AS postage,
+               productTotalFee,
+               orderTotalFee,
+               payTotalFee,
+               payableAmount,
+               balancePayFee,
+               discountFee,
+               status,
+               paySuccessCounter,
+               confirmTime,
+               payTime,
+               rebateFlag,
+               clauseID     AS clauseId,
+               clauseName,
+               payTime,
+               orderNo
         FROM cm_order
         WHERE orderID = #{orderId}
     </select>
     <select id="getOrderByShopOrderId" resultType="com.caimei365.order.model.vo.OrderVo">
-        SELECT
-           co.orderID AS orderId,
-           co.shopOrderIds,
-           co.orderSource,
-           co.orderNo,
-           co.organizeID AS organizeId,
-           co.userID AS userId,
-           co.clubID AS clubId,
-           co.buyUserID AS buyUserId,
-           co.orderTime AS orderTime,
-           co.updateDate AS updateDate,
-           co.delFlag,
-           co.userBeans,
-           co.orderType,
-           co.orderSubmitType,
-           co.confirmFlag,
-           co.onlinePayFlag,
-           co.splitFlag,
-           co.payFlag,
-           co.receiptStatus,
-           co.payStatus,
-           co.zeroCostFlag,
-           co.sendOutStatus,
-           co.refundType,
-           co.affirmPaymentFlag,
-           co.productCount,
-           co.presentCount,
-           co.promotionalGiftsCount,
-           co.hasActProduct,
-           co.promotionFullReduction,
-           co.secondHandOrderFlag,
-           co.invoiceFlag,
-           co.freePostFlag AS postageFlag,
-           co.freight AS postage,
-           co.productTotalFee,
-           co.orderTotalFee,
-           co.payTotalFee,
-           co.payableAmount,
-           co.balancePayFee,
-           co.discountFee,
-           co.status,
-           co.paySuccessCounter,
-           co.confirmTime,
-           co.payTime,
-           co.rebateFlag,
-           co.clauseID AS clauseId,
-           co.clauseName
+        SELECT co.orderID      AS orderId,
+               co.shopOrderIds,
+               co.orderSource,
+               co.orderNo,
+               co.organizeID   AS organizeId,
+               co.userID       AS userId,
+               co.clubID       AS clubId,
+               co.buyUserID    AS buyUserId,
+               co.orderTime    AS orderTime,
+               co.updateDate   AS updateDate,
+               co.delFlag,
+               co.userBeans,
+               co.orderType,
+               co.orderSubmitType,
+               co.confirmFlag,
+               co.onlinePayFlag,
+               co.splitFlag,
+               co.payFlag,
+               co.receiptStatus,
+               co.payStatus,
+               co.zeroCostFlag,
+               co.sendOutStatus,
+               co.refundType,
+               co.affirmPaymentFlag,
+               co.productCount,
+               co.presentCount,
+               co.promotionalGiftsCount,
+               co.hasActProduct,
+               co.promotionFullReduction,
+               co.secondHandOrderFlag,
+               co.invoiceFlag,
+               co.freePostFlag AS postageFlag,
+               co.freight      AS postage,
+               co.productTotalFee,
+               co.orderTotalFee,
+               co.payTotalFee,
+               co.payableAmount,
+               co.balancePayFee,
+               co.discountFee,
+               co.status,
+               co.paySuccessCounter,
+               co.confirmTime,
+               co.payTime,
+               co.rebateFlag,
+               co.clauseID     AS clauseId,
+               co.clauseName
         FROM cm_shop_order cso
-        LEFT JOIN cm_order co ON cso.orderID = co.orderID
+                 LEFT JOIN cm_order co ON cso.orderID = co.orderID
         WHERE cso.shopOrderID = #{shopOrderId}
     </select>
     <select id="getShopOrderListByOrderId" resultType="com.caimei365.order.model.vo.ShopOrderVo">
-        SELECT
-        shopOrderID AS shopOrderId,
-        shopOrderNo,
-        orderID AS orderId,
-        orderNo,
-        shopID AS shopId,
-        note,
-        userID AS userId,
-        clubID AS clubId,
-        spID AS spId,
-        orderPromotionsId,
-        promotionFullReduction,
-        brokerage,
-        canRefundAmount,
-        itemCount,
-        totalAmount,
-        productAmount,
-        needPayAmount,
-        shopProductAmount,
-        shopPostFee,
-        shopTaxFee,
-        shouldPayShopAmount,
-        orderTime,
-        orderSubmitType,
-        payStatus,
-        sendOutStatus,
-        splitFlag
+        SELECT shopOrderID AS shopOrderId,
+               shopOrderNo,
+               orderID     AS orderId,
+               orderNo,
+               shopID      AS shopId,
+               note,
+               userID      AS userId,
+               clubID      AS clubId,
+               spID        AS spId,
+               orderPromotionsId,
+               promotionFullReduction,
+               brokerage,
+               canRefundAmount,
+               itemCount,
+               totalAmount,
+               productAmount,
+               needPayAmount,
+               shopProductAmount,
+               shopPostFee,
+               shopTaxFee,
+               shouldPayShopAmount,
+               orderTime,
+               orderSubmitType,
+               payStatus,
+               sendOutStatus,
+               splitFlag
         FROM cm_shop_order
         WHERE delFlag = 0
-        AND orderID = #{orderId}
+          AND orderID = #{orderId}
     </select>
     <select id="getLogisticsBatchList" resultType="com.caimei365.order.model.vo.LogisticsBatchVo">
-        SELECT
-        id,
-        shopOrderID AS shopOrderId,
-        orderID AS orderId,
-        outStoreTimes,
-        status,
-        mailer,
-        shopID AS shopId,
-        updateDate,
-        deliveryTime,
-        receiptTime,
-        remarkImage,
-        remark
-        FROM cm_logistics_batch WHERE orderID= #{orderId}
+        SELECT id,
+               shopOrderID AS shopOrderId,
+               orderID     AS orderId,
+               outStoreTimes,
+               status,
+               mailer,
+               shopID      AS shopId,
+               updateDate,
+               deliveryTime,
+               receiptTime,
+               remarkImage,
+               remark
+        FROM cm_logistics_batch
+        WHERE orderID = #{orderId}
     </select>
     <select id="getLogisticsRecord" resultType="com.caimei365.order.model.vo.LogisticsRecordVo">
-        SELECT
-        clr.id,
-        clr.logisticsBatchID AS logisticsBatchId,
-        clr.shopOrderID AS shopOrderId,
-        clr.orderID AS orderId,
-        clr.orderProductID AS orderProductId,
-        clr.buyNum,
-        clr.num,
-        clr.productID AS productId,
-        clr.productName,
-        clr.image
+        SELECT clr.id,
+               clr.logisticsBatchID AS logisticsBatchId,
+               clr.shopOrderID      AS shopOrderId,
+               clr.orderID          AS orderId,
+               clr.orderProductID   AS orderProductId,
+               clr.buyNum,
+               clr.num,
+               clr.productID        AS productId,
+               clr.productName,
+               clr.image
         FROM cm_logistics_record clr
-        WHERE clr.shopOrderID = #{shopOrderId} AND clr.logisticsBatchID = #{logisticsBatchId}
+        WHERE clr.shopOrderID = #{shopOrderId}
+          AND clr.logisticsBatchID = #{logisticsBatchId}
     </select>
     <select id="getLogisticsInfoList" resultType="com.caimei365.order.model.vo.LogisticsInformationVo">
-        SELECT DISTINCT
-        li.id,
-        li.logisticsBatchID AS logisticsBatchId,
-        li.type,
-        li.shopOrderID AS shopOrderId,
-        li.orderProductID AS orderProductId,
-        li.orderID AS orderId,
-        li.nu,
-        li.state,
-        li.info,
-        li.logisticsCompanyName,
-        li.logisticsCompanyCode,
-        li.shopID AS shopId,
-        li.updateDate,
-        li.remarks
+        SELECT DISTINCT li.id,
+                        li.logisticsBatchID AS logisticsBatchId,
+                        li.type,
+                        li.shopOrderID      AS shopOrderId,
+                        li.orderProductID   AS orderProductId,
+                        li.orderID          AS orderId,
+                        li.nu,
+                        li.state,
+                        li.info,
+                        li.logisticsCompanyName,
+                        li.logisticsCompanyCode,
+                        li.shopID           AS shopId,
+                        li.updateDate,
+                        li.remarks
         FROM logistics_information li
         WHERE li.logisticsBatchID = #{logisticsBatchId}
     </select>
     <select id="getPrevCouponList" resultType="com.caimei365.order.model.vo.CouponVo">
         SELECT
-            id AS couponId,
-            couponAmount,
-            touchPrice,
-            moneyCouponPrice,
-            moneyCouponFlag,
-            moneyCouponType,
-            <if test="userId == null || userId == 0">
-                startDate,
-                endDate,
-            </if>
-            <if test="userId >0">
-                if(#{registerTime} <![CDATA[ > ]]> startDate,#{registerTime},startDate) as startDate,
-                if(receiveFlag=1,endDate,date_add(if(#{registerTime} <![CDATA[ > ]]> startDate and #{registerTime} <![CDATA[ < ]]> endDate,#{registerTime},startDate),interval receivePeriod day)) as endDate,
-            </if>
-            couponType,
-            userId,
-            shopId,
-            productType,
-            categoryType
+        id AS couponId,
+        couponAmount,
+        touchPrice,
+        moneyCouponPrice,
+        moneyCouponFlag,
+        moneyCouponType,
+        <if test="userId == null || userId == 0">
+            startDate,
+            endDate,
+        </if>
+        <if test="userId >0">
+            if(#{registerTime} <![CDATA[ > ]]> startDate,#{registerTime},startDate) as startDate,
+            if(receiveFlag=1,endDate,date_add(if(#{registerTime} <![CDATA[ > ]]> startDate and #{registerTime}
+            <![CDATA[ < ]]> endDate,#{registerTime},startDate),interval receivePeriod day)) as endDate,
+        </if>
+        couponType,
+        userId,
+        shopId,
+        productType,
+        categoryType
         FROM cm_coupon
         WHERE delFlag = 0 AND couponsMode = 0 AND status != 2
         <if test="userId == null or userId == 0">
@@ -496,37 +516,37 @@
             AND couponType = 4))
             and NOW() <![CDATA[ > ]]> startDate
             and NOW() <![CDATA[ < ]]> if(receiveFlag = 1,endDate,
-            date_add(if(#{registerTime} <![CDATA[ > ]]> startDate and #{registerTime} <![CDATA[ < ]]> endDate,#{registerTime},startDate),
+            date_add(if(#{registerTime} <![CDATA[ > ]]> startDate and #{registerTime} <![CDATA[ < ]]>
+            endDate,#{registerTime},startDate),
             interval receivePeriod day))
         </if>
         ORDER BY createDate DESC
     </select>
     <select id="getClubCouponList" resultType="com.caimei365.order.model.vo.CouponVo">
-        SELECT
-            a.id AS clubCouponId,
-            cc.id AS couponId,
-            cc.couponAmount,
-            cc.touchPrice,
-            cc.moneyCouponFlag,
-            cc.moneyCouponPrice,
-            cc.moneyCouponType,
-            if(cc.vipFlag = 1,cc.startDate,a.createDate) as startDate,
-            if(cc.vipFlag = 1,cc.endDate,date_add(a.createDate,interval cc.usePeriod day)) as endDate,
-            cc.couponType,
-            cc.userId,
-            cc.shopId,
-            cc.productType,
-            cc.categoryType
+        SELECT a.id                                                                              AS clubCouponId,
+               cc.id                                                                             AS couponId,
+               cc.couponAmount,
+               cc.touchPrice,
+               cc.moneyCouponFlag,
+               cc.moneyCouponPrice,
+               cc.moneyCouponType,
+               if(cc.vipFlag = 1, cc.startDate, a.createDate)                                    as startDate,
+               if(cc.vipFlag = 1, cc.endDate, date_add(a.createDate, interval cc.usePeriod day)) as endDate,
+               cc.couponType,
+               cc.userId,
+               cc.shopId,
+               cc.productType,
+               cc.categoryType
         FROM cm_coupon_club a
-        LEFT JOIN cm_coupon cc ON a.couponId = cc.id
+                 LEFT JOIN cm_coupon cc ON a.couponId = cc.id
         WHERE cc.delFlag = 0
-        AND a.delFlag = 0
-        AND a.userId = #{userId}
-        AND a.status = 1
-        AND if(cc.vipFlag = 1,
-               NOW() BETWEEN cc.startDate AND cc.endDate,
-            NOW() BETWEEN a.createDate AND date_add(a.createDate,interval cc.usePeriod day))
-        AND cc.status != 2
+          AND a.delFlag = 0
+          AND a.userId = #{userId}
+          AND a.status = 1
+          AND if(cc.vipFlag = 1,
+                 NOW() BETWEEN cc.startDate AND cc.endDate,
+                 NOW() BETWEEN a.createDate AND date_add(a.createDate, interval cc.usePeriod day))
+          AND cc.status != 2
         ORDER BY a.createDate DESC
     </select>
     <select id="getCouponProductIds" resultType="java.lang.Integer">
@@ -540,87 +560,155 @@
         </if>
     </select>
     <select id="getOrderInvoice" resultType="com.caimei365.order.model.vo.InvoiceVo">
-        SELECT
-            id,
-            type,
-            orderId,
-            invoiceTitle,
-            corporationTaxNum,
-            registeredAddress,
-            registeredPhone,
-            bankAccountNo,
-            openBank
+        SELECT id,
+               type,
+               orderId,
+               invoiceTitle,
+               corporationTaxNum,
+               registeredAddress,
+               registeredPhone,
+               bankAccountNo,
+               openBank
         FROM bp_order_invoice
         WHERE orderId = #{orderId}
         LIMIT 1
     </select>
     <select id="getUserRegisterTime" resultType="java.util.Date">
-        select registerTime from user where userID = #{userId}
+        select registerTime
+        from user
+        where userID = #{userId}
     </select>
     <select id="finduserBean" resultType="java.lang.Integer">
-        select userBeans from cm_order where orderID = #{orderId}
+        select userBeans
+        from cm_order
+        where orderID = #{orderId}
     </select>
     <select id="findSplitCode" resultType="java.lang.Integer">
         SELECT COUNT(*)
         FROM product p
-        LEFT JOIN cm_order_product cop  ON cop.productid=p.productid
+                 LEFT JOIN cm_order_product cop ON cop.productid = p.productid
         WHERE cop.orderId = #{orderId}
           AND (p.splitCode IS NULL OR p.splitCode = '')
     </select>
     <select id="getShopOrderDiscernReceipt" resultType="com.caimei365.order.model.vo.DiscernReceiptVo">
-        SELECT
-            cdr.id,
-            cdr.payWay,
-            cdr.payType,
-            cdr.receiptType,
-            cdr.receiptStatus,
-            cdr.receiptAmount,
-            cdr.confirmType,
-            cdr.receiptDate,
-            cdr.confirmDate,
-            cdr.reviewDate,
-            cdr.updateDate,
-            cdr.delFlag,
-            cror.associateAmount
+        SELECT cdr.id,
+               cdr.payWay,
+               cdr.payType,
+               cdr.receiptType,
+               cdr.receiptStatus,
+               cdr.receiptAmount,
+               cdr.confirmType,
+               cdr.receiptDate,
+               cdr.confirmDate,
+               cdr.reviewDate,
+               cdr.updateDate,
+               cdr.delFlag,
+               cror.associateAmount
         FROM cm_receipt_order_relation cror
-        LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
-        WHERE cror.orderID = #{orderId} AND cror.relationType = '2'
-          AND cror.delFlag = '0' AND cdr.delFlag = '0' AND cdr.receiptStatus = '3' AND cdr.payType != '16' AND cdr.receiptStatus IN(2,3)
+                 LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
+        WHERE ((cror.shopOrderId = #{shopOrderId} AND cror.relationType = '2') OR
+               (cror.orderID = #{shopOrderId} AND cror.relationType = '1'))
+          AND cror.delFlag = '0'
+          AND cdr.delFlag = '0'
+          AND cdr.receiptStatus = '3'
+          AND cdr.payType != '16'
+          AND cdr.receiptStatus IN (2, 3)
         ORDER BY cdr.receiptDate DESC
     </select>
     <select id="getShopOrderByOrderId" resultType="com.caimei365.order.model.vo.ShopOrderVo">
-        SELECT
-            shopOrderID AS shopOrderId,
-            shopOrderNo,
-            orderID AS orderId,
-            orderNo,
-            shopID AS shopId,
-            note,
-            userID AS userId,
-            clubID AS clubId,
-            spID AS spId,
-            orderPromotionsId,
-            promotionFullReduction,
-            brokerage,
-            canRefundAmount,
-            itemCount,
-            totalAmount,
-            productAmount,
-            needPayAmount,
-            shopProductAmount,
-            shopPostFee,
-            shopTaxFee,
-            shouldPayShopAmount,
-            orderTime,
-            orderSubmitType,
-            payStatus,
-            sendOutStatus,
-            splitFlag,
-            realPay,
-            receiptAmount,
-            receiptStatus
-        FROM cm_shop_order
+        SELECT cop.shopOrderID AS shopOrderId,
+               cop.shopOrderNo,
+               cop.orderID     AS orderId,
+               cop.orderNo,
+               cop.shopID      AS shopId,
+               cop.note,
+               cop.userID      AS userId,
+               cop.clubID      AS clubId,
+               cop.spID        AS spId,
+               cop.orderPromotionsId,
+               cop.promotionFullReduction,
+               cop.brokerage,
+               cop.canRefundAmount,
+               cop.itemCount,
+               cop.totalAmount,
+               cop.productAmount,
+               cop.needPayAmount,
+               cop.shopProductAmount,
+               cop.shopPostFee,
+               cop.shopTaxFee,
+               cop.shouldPayShopAmount,
+               cop.orderTime,
+               cop.orderSubmitType,
+               cop.payStatus,
+               cop.sendOutStatus,
+               cop.splitFlag,
+               cop.realPay,
+               cop.receiptAmount,
+               cop.receiptStatus,
+               ifnull(cop.paySuccessCounter,0) as paySuccessCounter,
+               p.name          as shopName
+        FROM cm_shop_order cop
+                 left join shop p on cop.shopID = p.shopID
         WHERE delFlag = 0
           AND shopOrderID = #{shopOrderId}
     </select>
+    <select id="getOrderProductByShopOrderId" resultType="com.caimei365.order.model.vo.OrderProductVo">
+        SELECT cop.orderProductID                                                 AS orderProductId,
+               cop.orderID                                                        AS orderId,
+               cop.orderNo,
+               cop.shopOrderID                                                    AS shopOrderId,
+               cop.shopOrderNo,
+               cop.orderPromotionsId,
+               cop.productId,
+               cop.shopId,
+               cop.name,
+               cop.productImage                                                   AS image,
+               cop.price,
+               cop.shopName,
+               IF(cop.shopid = 998 AND co.freight > 0, co.freight, cop.costPrice) AS costPrice,
+               cop.normalPrice,
+               cop.ladderPriceFlag,
+               cop.discountPrice,
+               cop.discount,
+               cop.totalAmount,
+               cop.totalFee,
+               cop.shouldPayFee,
+               cop.productUnit,
+               cop.num,
+               cop.presentNum,
+               cop.discountFee,
+               cop.includedTax,
+               cop.invoiceType,
+               cop.taxRate,
+               cop.addedValueTax,
+               cop.totalAddedValueTax,
+               cop.singleShouldPayTotalTax,
+               cop.shouldPayTotalTax,
+               cop.shopProductAmount,
+               cop.singleShopFee,
+               cop.shopFee,
+               cop.singleOtherFee,
+               cop.otherFee,
+               cop.singleCmFee,
+               cop.cmFee,
+               cop.payStatus,
+               cop.buyAgainFlag,
+               cop.notOutStore,
+               cop.isActProduct                                                   AS actProduct,
+               cop.productType,
+               p.productCategory                                                  as productCategory,
+               p.splitCode,
+               p.productType
+        FROM cm_order_product cop
+                 LEFT JOIN product p ON cop.productID = p.productID
+                 LEFT JOIN cm_order co ON cop.orderId = co.orderId
+        WHERE cop.shopOrderID = #{shopOrderId}
+          AND IF(co.userBeans = 0, 1 = 1, cop.shopid != 998)
+        ORDER BY cop.discountPrice DESC
+    </select>
+    <select id="findShopFee" resultType="java.lang.Double">
+        select totalAmount
+        from cm_shop_order
+        where shopOrderID = #{shopOrderId}
+    </select>
 </mapper>

+ 39 - 7
src/main/resources/mapper/PayOrderMapper.xml

@@ -22,6 +22,9 @@
         <if test="paySuccessCounter != null and paySuccessCounter != ''">
             ,paySuccessCounter = #{paySuccessCounter}
         </if>
+        <if test="onlinePayFlag != null">
+            ,onlinePayFlag = #{onlinePayFlag}
+        </if>
         ,updateDate = #{updateDate}
         WHERE orderID = #{orderId}
     </update>
@@ -41,9 +44,9 @@
     </delete>
     <insert id="insertOrderPayLink" keyColumn="id" keyProperty="id"  parameterType="com.caimei365.order.model.vo.OrderPayLinkVo" useGeneratedKeys="true">
         INSERT INTO cm_order_pay_link (orderId, vipRecordId, authVipRecordId, vipMonth, linkLogo, unpaidAmount,
-                                       generateTime, effectiveTime, payStatus, payType, delFlag)
+                                       generateTime, effectiveTime, payStatus, payType, delFlag, shopOrderId)
         VALUES (#{orderId}, #{vipRecordId}, #{authVipRecordId}, #{vipMonth}, #{linkLogo}, #{unpaidAmount},
-                #{generateTime}, #{effectiveTime}, #{payStatus}, #{payType}, #{delFlag})
+                #{generateTime}, #{effectiveTime}, #{payStatus}, #{payType}, #{delFlag}, #{shopOrderId})
     </insert>
     <insert id="insertSplitAccount" keyColumn="id" keyProperty="id"  parameterType="com.caimei365.order.model.po.SplitAccountPo" useGeneratedKeys="true">
         INSERT INTO cm_split_account (orderId, productId, orderProductId, shopId, couponRecordId,vipRecordId, authVipRecordId, type, subUserNo, splitAccount,
@@ -88,7 +91,7 @@
     <update id="updateOrderPayLink">
         UPDATE cm_order_pay_link SET
             orderId = #{orderId}, vipRecordId = #{vipRecordId}, authVipRecordId = #{authVipRecordId}, vipMonth = #{vipMonth}, linkLogo = #{linkLogo}, unpaidAmount = #{unpaidAmount}, generateTime = #{generateTime},
-            effectiveTime = #{effectiveTime}, payStatus = #{payStatus}, payType = #{payType}, delFlag = #{delFlag}
+            effectiveTime = #{effectiveTime}, payStatus = #{payStatus}, payType = #{payType}, delFlag = #{delFlag} , shopOrderId = #{shopOrderId}
         WHERE id = #{id}
     </update>
     <update id="updateOrderPayLinkStatus">
@@ -141,6 +144,11 @@
             mbOrderId = #{mbOrderId}
         WHERE orderRequestNo = #{orderRequestNo}
     </update>
+    <update id="updateShopOrder">
+        UPDATE cm_shop_order SET
+        receiptStatus = #{receiptStatus}, receiptAmount = #{receiptAmount},paySuccessCounter =#{paySuccessCounter}
+        WHERE shopOrderID = #{shopOrderId}
+    </update>
     <select id="getPayOnLineSwitch" resultType="java.lang.Integer">
         SELECT STATUS FROM cm_pay_online_switch WHERE id=1
     </select>
@@ -163,7 +171,7 @@
             delFlag
         FROM
         cm_order_pay_link
-        WHERE orderId = #{orderId}
+        WHERE shopOrderId = #{orderId}
         <if test="amount != null">
             AND unpaidAmount = #{amount}
         </if>
@@ -194,6 +202,7 @@
     <select id="getPayLinkByLinkLogo" resultType="com.caimei365.order.model.vo.OrderPayLinkVo">
         SELECT
             id,
+            shopOrderId,
             orderId,
             vipRecordId,
             authVipRecordId,
@@ -214,8 +223,8 @@
         SELECT id FROM cm_promotions_order WHERE orderId = #{orderId} LIMIT 1
     </select>
     <select id="getDbPaySuccessCounter" resultType="java.lang.Integer">
-        SELECT paySuccessCounter FROM cm_order
-        WHERE orderID = #{orderId} AND delFlag = '0'
+        SELECT ifnull(paySuccessCounter,0) FROM cm_shop_order
+        WHERE shopOrderID = #{shopOrderId} AND delFlag = '0'
     </select>
 
     <select id="getOpenidListByPermission" resultType="java.lang.String">
@@ -301,7 +310,10 @@
         from cm_bankcode
     </select>
     <select id="getCouponPrice" resultType="java.lang.Double">
-        select moneyCouponPrice from cm_coupon where id = #{couponId}
+        SELECT cc.moneyCouponPrice
+        FROM  cm_coupon cc
+        LEFT JOIN cm_coupon_buyrecord ccb ON cc.id=ccb.couponId
+        WHERE ccb.id = #{recordId}
     </select>
     <select id="findPayStatus" resultType="java.lang.Integer">
         select payStatus from cm_coupon_buyrecord where id = #{recordId}
@@ -357,4 +369,24 @@
     <select id="findShopOrderSplitCode" resultType="java.lang.String">
         select splitCode from cm_shop_order where shopOrderID = #{shopOrderId}
     </select>
+    <select id="getOrderId" resultType="java.lang.Integer">
+        select orderId from cm_shop_order where shopOrderID = #{shopOrderId}
+    </select>
+    <select id="findB2BBankCode" resultType="com.caimei365.order.model.vo.BankCodeVo">
+        select id, bankName, B2B, bankLogo, delFlag
+        from cm_bankcode
+        where B2B is not null
+          and B2B != ''
+          and delFlag = 0
+    </select>
+    <select id="findB2CBankCode" resultType="com.caimei365.order.model.vo.BankCodeVo">
+        select id, bankName, B2C, bankLogo, delFlag
+        from cm_bankcode
+        where B2C is not null
+          and B2C != ''
+          and delFlag = 0
+    </select>
+    <select id="getSplitCodeByShopOrderId" resultType="java.lang.String">
+        select splitCode from cm_shop_order where shopOrderID = #{shopOrderId}
+    </select>
 </mapper>

+ 33 - 13
src/main/resources/mapper/SubmitMapper.xml

@@ -35,13 +35,13 @@
                                    totalAmount, productAmount, needPayAmount, shopProductAmount, shopPostFee,
                                    shopTaxFee,
                                    shouldPayShopAmount, orderTime, orderSubmitType, splitFlag, payStatus,
-                                   payedShopAmount,splitCode,realPay,eachDiscount)
+                                   payedShopAmount, splitCode, realPay, eachDiscount, receiptStatus)
         VALUES (#{shopOrderNo}, #{orderId}, #{orderNo}, #{shopId}, #{note}, #{userId}, #{clubId}, #{orderType},
                 #{spId}, #{orderPromotionsId}, #{promotionFullReduction}, #{svipShopReduction}, #{brokerage},
                 #{canRefundAmount}, #{itemCount},
                 #{totalAmount}, #{productAmount}, #{needPayAmount}, #{shopProductAmount}, #{shopPostFee}, #{shopTaxFee},
                 #{shouldPayShopAmount}, #{orderTime}, #{orderSubmitType}, #{splitFlag}, #{payStatus},
-                #{payedShopAmount},#{splitCode},#{realPay},#{eachDiscount})
+                #{payedShopAmount}, #{splitCode}, #{realPay}, #{eachDiscount}, 1)
     </insert>
     <insert id="insertOrderProduct" keyColumn="orderProductID" keyProperty="orderProductId"
             parameterType="com.caimei365.order.model.po.OrderProductPo" useGeneratedKeys="true">
@@ -74,9 +74,9 @@
     <insert id="insertOrderPromotions" keyColumn="id" keyProperty="id"
             parameterType="com.caimei365.order.model.vo.PromotionsVo" useGeneratedKeys="true">
         INSERT INTO cm_promotions_order (orderId, promotionsId, name, description, type, mode, touchPrice, reducedPrice,
-                                         status, beginTime, endTime)
-        VALUES (#{orderId}, #{id}, #{name}, #{description}, #{type}, #{mode}, #{touchPrice}, #{reducedPrice}, #{status},
-                #{beginTime}, #{endTime})
+                                         discount,status, beginTime, endTime)
+        VALUES (#{orderId}, #{id}, #{name}, #{description}, #{type}, #{mode}, #{touchPrice}, #{reducedPrice}, #{discount},
+                #{status}, #{beginTime}, #{endTime})
     </insert>
     <insert id="insertLadderPrices" keyColumn="id" keyProperty="id"
             parameterType="com.caimei365.order.model.vo.LadderPriceVo" useGeneratedKeys="true">
@@ -184,10 +184,10 @@
         WHERE userID = #{userId}
     </select>
     <select id="getProductDetails" resultType="com.caimei365.order.model.po.OrderProductPo">
-        SELECT p.productID        AS productId,
-               p.shopID           AS shopId,
-               p.`name`           AS `name`,
-               p.mainImage        AS image,
+        SELECT p.productID                AS productId,
+               p.shopID                   AS shopId,
+               p.`name`                   AS `name`,
+               p.mainImage                AS image,
                p.price,
                p.costPrice,
                IFNULL(p.costCheckFlag, 1) AS costCheckFlag,
@@ -196,11 +196,11 @@
                p.ladderPriceFlag,
                p.includedTax,
                p.invoiceType,
-               p.taxPoint         AS taxRate,
-               p.unit             AS productUnit,
+               p.taxPoint                 AS taxRate,
+               p.unit                     AS productUnit,
                p.normalPrice,
-               p.supplierTaxPoint AS shopTaxRate,
-               p.splitCode
+               p.supplierTaxPoint         AS shopTaxRate,
+               p.splitCode as splitCode
         FROM product p
         WHERE p.productId = #{productId}
     </select>
@@ -245,4 +245,24 @@
           and orderTime <![CDATA[ > ]]> #{orderTime}
           and userID = #{userId}
     </select>
+    <select id="findShops" resultType="com.caimei365.order.model.po.OrderShopPo">
+        SELECT DISTINCT
+            s.shopID AS shopId,
+            p.splitCode
+        FROM shop s
+        LEFT JOIN product p ON p.shopID = s.shopID
+        WHERE p.productID IN
+        <foreach collection="productIdList" open="(" separator="," close=")" item="productId">
+            #{productId}
+        </foreach>
+        GROUP BY s.shopID,p.splitCode
+    </select>
+    <select id="findSplitResult" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM product
+        WHERE productId IN
+        <foreach collection="productIdList" open="(" separator="," close=")" item="productId">
+            #{productId}
+        </foreach>
+        AND (splitcode IS NULL OR splitcode ='')
+    </select>
 </mapper>

+ 6 - 0
src/test/java/com/caimei365/order/OrderApplicationTests.java

@@ -2,9 +2,13 @@
 //
 //import com.alibaba.fastjson.JSON;
 //import com.alibaba.fastjson.JSONObject;
+//import com.caimei365.order.mapper.SubmitMapper;
+//import com.caimei365.order.model.po.OrderShopPo;
+//import com.caimei365.order.model.vo.ShopOrderVo;
 //import org.junit.jupiter.api.Test;
 //import org.springframework.boot.test.context.SpringBootTest;
 //
+//import javax.annotation.Resource;
 //import java.io.IOException;
 //import java.io.InputStream;
 //import java.lang.reflect.Type;
@@ -19,6 +23,8 @@
 // */
 //@SpringBootTest
 //class OrderApplicationTests {
+//    @Resource
+//    private SubmitMapper submitMapper;
 //
 //    @Test
 //    void contextLoads() throws IOException {

Some files were not shown because too many files changed in this diff