Prechádzať zdrojové kódy

接口/线上线下判断

zhijiezhao 3 rokov pred
rodič
commit
76c7c40809

+ 26 - 1
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);
+    }
+
 
     /**
      * 生成网银支付链接

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

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

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

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

+ 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;
     /**
      * 商品分账商户号
      */

+ 9 - 1
src/main/java/com/caimei365/order/model/vo/ShopOrderVo.java

@@ -77,6 +77,14 @@ public class ShopOrderVo implements Serializable {
      * (付款供应商)付款状态:1待付款、2部分付款、3已付款
      */
     private Integer payStatus;
+    /**
+     *  用户待付(realPay-receiptAmount)
+     */
+    private Double  obligation;
+    /**
+     * 均摊优惠的金额
+     */
+    private Double eachDiscount;
     /**
      * 已付款金额
      */
@@ -114,7 +122,7 @@ public class ShopOrderVo implements Serializable {
      */
     private Double receiptAmount;
     /**
-     * 优惠均摊后真实付金额needpay
+     * 优惠均摊后真实付金额needpay
      */
     private Double realPay;
     /**

+ 3 - 4
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,7 @@ import java.beans.IntrospectionException;
 import java.lang.reflect.InvocationTargetException;
 import java.security.NoSuchAlgorithmException;
 import java.security.spec.InvalidKeySpecException;
+import java.util.List;
 
 /**
  * Description
@@ -50,4 +48,5 @@ public interface HeliPayService {
      */
     String unionCallback(UnionResVo res) throws IntrospectionException, InvocationTargetException, IllegalAccessException;
 
+    ResponseJson<List<ShopOrderVo>> getShopOrders(Integer orderId);
 }

+ 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);
+
 //    /**
 //     * 手动临时分账
 //     */

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

@@ -19,6 +19,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 +31,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 +80,8 @@ public class HeliPayServiceImpl implements HeliPayService {
     private RemoteCallService remoteCallService;
     @Resource
     private WeChatService weChatService;
+    @Value("${caimei.wwwDomain}")
+    private String domain;
 
     /**
      * 微信/支付宝扫码接口
@@ -1125,6 +1129,60 @@ 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());
+            shopOrder.setOrderProductList(orderProductList);
+            shopOrder.setShopLogo(ImageUtil.getImageUrl("shopLogo", shopOrder.getShopLogo(), domain));
+        });
+        return ResponseJson.success(shopOrderList);
+    }
+
     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()) {

+ 115 - 36
src/main/java/com/caimei365/order/service/impl/PayOrderServiceImpl.java

@@ -214,13 +214,13 @@ 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,7 +236,7 @@ public class PayOrderServiceImpl implements PayOrderService {
                     log.error("【订单发货通知】获取微信公众号access_token异常!", e);
                 }
             }
-            log.info("支付成功"+order.getUserId());
+            log.info("支付成功" + order.getUserId());
         }
         Map<String, Object> map = new HashMap<>(2);
         map.put("order", order);
@@ -318,7 +318,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 +326,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);
     }
 
@@ -638,6 +635,89 @@ 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);
+        if (!discernReceiptList.isEmpty()) {
+            AtomicDouble receiptAmount = new AtomicDouble(0d);
+            AtomicBoolean offlineFlag = new AtomicBoolean(false);
+            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());
+        }
+        // 总成本
+        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 +886,28 @@ public class PayOrderServiceImpl implements PayOrderService {
             log.info("【支付异步回调】>>>>>>>>>>>>>>订单(全部支付),修改订单状态:" + order.getStatus() + ",orderId:" + orderId);
             log.info("************************订单支付完成消息推送*********************");
             //判断是否是二手订单和返佣订单
-                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);
+            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 {
             // 部分支付
@@ -1019,14 +1099,14 @@ public class PayOrderServiceImpl implements PayOrderService {
         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);
@@ -1203,7 +1283,6 @@ public class PayOrderServiceImpl implements PayOrderService {
     }
 
     /**
-     *
      * 分账详情
      */
     private List<SplitAccountPo> setSplitAccountDetail(OrderVo order, PayParamBo payParam) {

+ 2 - 0
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -1145,6 +1145,8 @@ public class SubmitServiceImpl implements SubmitService {
                 //无优惠金额
                 shopOrderList.forEach(so -> {
                     double realPay = so.getNeedPayAmount();
+                    so.setRealPay(realPay);
+                    so.setEachDiscount(0d);
                     double charge = MathUtil.mul(realPay, 0.0065, 2).doubleValue() > 10 ? MathUtil.mul(realPay, 0.0065, 2).doubleValue() : 10;
                     double bro = so.getBrokerage();
                     if (bro < charge) {

+ 3 - 0
src/main/resources/mapper/BaseMapper.xml

@@ -349,4 +349,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>

+ 62 - 3
src/main/resources/mapper/OrderCommonMapper.xml

@@ -34,7 +34,10 @@
         cso.sendOutStatus,
         s.name AS shopName,
         s.logo AS shopLogo,
-        s.shopType as shopType
+        s.shopType as shopType,
+        cso.receiptAmount,
+        cso.eachDiscount,
+        cso.realPay
         FROM cm_shop_order cso
         LEFT JOIN shop s ON cso.shopID = s.shopID
         WHERE cso.delFlag = 0
@@ -108,7 +111,8 @@
         cop.svipPriceType,
         cop.svipDiscount,
         p.productCategory as productCategory,
-        p.productType
+        p.productType,
+        p.productCode
         FROM cm_order_product cop
         LEFT JOIN product p ON cop.productID = p.productID
         WHERE cop.shopOrderID = #{shopOrderId}
@@ -584,7 +588,7 @@
             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'
+        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>
@@ -623,4 +627,59 @@
         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>
 </mapper>

+ 9 - 9
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">
@@ -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,10 +196,10 @@
                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.supplierTaxPoint         AS shopTaxRate,
                p.splitCode
         FROM product p
         WHERE p.productId = #{productId}