浏览代码

供应商pc后台结算管理

zhijiezhao 4 月之前
父节点
当前提交
b829e809ad

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

@@ -73,7 +73,7 @@ public class ShipApi {
             @ApiImplicitParam(required = true, name = "shopId", value = "供应商Id"),
             @ApiImplicitParam(required = false, name = "shopOrderNo", value = "订单编号"),
             @ApiImplicitParam(required = false, name = "payStatus", value = "结算状态"),
-            @ApiImplicitParam(required = false, name = "name", value = "买家名称"),
+            @ApiImplicitParam(required = false, name = "name", value = "机构名称"),
             @ApiImplicitParam(required = false, name = "beginTime", value = "订单开始时间"),
             @ApiImplicitParam(required = false, name = "endTime", value = "订单结束时间"),
             @ApiImplicitParam(required = false, name = "refundStatus", value = "退款状态"),
@@ -106,14 +106,14 @@ public class ShipApi {
     public void exportExcel(Integer shopId, String shopOrderNo, Integer payStatus, String name, String beginTime, String endTime, Integer refundStatus, HttpServletResponse response) {
         String file = "结算列表数据";
         try {
-            List<SettlementDto> list = shipService.exportExcel(shopId, payStatus, shopOrderNo, name, beginTime, endTime, refundStatus);
-            SettlementDto settLementDto = new SettlementDto();
+            List<SettlementVo> list = shipService.exportExcel(shopId, payStatus, shopOrderNo, name, beginTime, endTime, refundStatus);
+            SettlementVo settlementVo = new SettlementVo();
             response.setContentType("application/vnd.ms-excel");
             response.setCharacterEncoding("utf-8");
             // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
             String fileName = URLEncoder.encode(file, "UTF-8").replaceAll("\\+", "%20");
             response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
-            EasyExcel.write(response.getOutputStream(), settLementDto.getClass()).autoCloseStream(Boolean.TRUE).sheet("数据").doWrite(list);
+            EasyExcel.write(response.getOutputStream(), settlementVo.getClass()).autoCloseStream(Boolean.TRUE).sheet("数据").doWrite(list);
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 0 - 80
src/main/java/com/caimei365/order/model/dto/SettlementDto.java

@@ -1,80 +0,0 @@
-package com.caimei365.order.model.dto;
-
-import com.alibaba.excel.annotation.ExcelIgnore;
-import com.alibaba.excel.annotation.ExcelProperty;
-import lombok.Data;
-
-/**
- * Description
- *
- * @author : Charles
- * @date : 2023/6/19
- */
-@Data
-public class SettlementDto {
-    /**
-     * 子订单编号
-     */
-    @ExcelProperty(value = "子订单编号", index = 0)
-    private String shopOrderNo;
-    /**
-     * 订单提交时间
-     */
-    @ExcelProperty(value = "订单提交时间", index = 1)
-    private String orderTime;
-    /**
-     * 用户名称
-     */
-    @ExcelProperty(value = "用户名称", index = 2)
-    private String name;
-    /**
-     * 商品信息
-     */
-    @ExcelProperty(value = "商品信息", index = 3)
-    private String productInfo;
-    /**
-     * 订单金额
-     */
-    @ExcelProperty(value = "订单金额", index = 4)
-    private Double totalAmount;
-    /**
-     * 退款状态 1无退款、3有退款
-     */
-    @ExcelProperty(value = "退款状态", index = 5)
-    private String refundStatus;
-    /**
-     * 退款金额
-     */
-    @ExcelProperty(value = "退款金额", index = 6)
-    private Double refundAmount;
-    /**
-     * 支付手续费
-     */
-    @ExcelProperty(value = "支付手续费", index = 7)
-    private Double paymentCommission;
-    /**
-     * 分帐手续费
-     */
-    @ExcelProperty(value = "分帐手续费", index = 8)
-    private Double prorateCommission;
-    /**
-     * (付款供应商)付款状态:1待付款、2部分付款、3已付款
-     */
-    @ExcelProperty(value = "结算状态", index = 9)
-    private String payStatus;
-    /**
-     * 付供应商 = 商品费 + 运费 + 税费
-     */
-    @ExcelProperty(value = "总结算金额", index = 10)
-    private Double shouldPayShopAmount;
-    /**
-     * 已付款金额
-     */
-    @ExcelProperty(value = "已结算金额", index = 11)
-    private Double settleAmount;
-    /**
-     * 未结算金额
-     */
-    @ExcelProperty(value = "未结算金额", index = 12)
-    private Double unsettledAmount;
-}

+ 47 - 25
src/main/java/com/caimei365/order/model/vo/SettlementVo.java

@@ -15,9 +15,7 @@ import java.util.List;
 @Data
 public class SettlementVo {
     private static final long serialVersionUID = 1L;
-    /**
-     * 子订单ID
-     */
+
     @ExcelIgnore
     private Integer shopOrderId;
     /**
@@ -30,50 +28,74 @@ public class SettlementVo {
      */
     @ExcelProperty(value = "订单提交时间", index = 1)
     private String orderTime;
+
+    @ExcelProperty(value = "机构名称", index = 2)
+    private String clubName;
     /**
-     * 用户名称
+     * 协销名称
      */
-    private String name;
+    @ExcelProperty(value = "销售名称", index = 3)
+    private String spName;
+
+    @ExcelProperty(value = "服务商名称", index = 4)
+    private String cpName;
     /**
-     * 1 未结算 2 部分结算 3 已结算
+     * 供应商结算成本
      */
-    @ExcelProperty(value = "结算状态", index = 9)
-    private Integer settlestatus;
+    @ExcelProperty(value = "供应商结算金额", index = 5)
+    private Double shopSettleAmount;
     /**
-     * 订单金额
+     * 采美结算佣金
      */
-    @ExcelProperty(value = "订单金额", index = 4)
-    private Double totalAmount;
+    @ExcelProperty(value = "采美结算金额", index = 6)
+    private Double cmSettleAmount;
     /**
-     * 退款状态 1无退款、3有退款
+     * 服务商结算佣金
      */
-    @ExcelProperty(value = "退款状态 1无退款、3有退款", index = 5)
-    private Integer refundStatus;
+    @ExcelProperty(value = "服务商结算金额", index = 7)
+    private Double otherSettleAmount;
     /**
-     * 退款金额
+     * 商品信息
      */
-    @ExcelProperty(value = "退款金额", index = 6)
-    private Double refundAmount;
+    @ExcelProperty(value = "商品信息", index = 8)
+    private String productInfo;
+
+    /**
+     * 子订单可能包含多个商品,当前展示为总数量
+     * (锦波业务一般下单商品)
+     */
+    @ExcelProperty(value = "商品总数量", index = 9)
+    private Integer productNum;
+    /**
+     * 订单金额
+     */
+    @ExcelProperty(value = "订单金额", index = 10)
+    private Double totalAmount;
     /**
      * 支付手续费
      */
-    @ExcelProperty(value = "支付手续费", index = 7)
+    @ExcelProperty(value = "支付手续费", index = 11)
     private Double paymentCommission;
     /**
      * 分帐手续费
      */
-    @ExcelProperty(value = "分帐手续费", index = 8)
+    @ExcelProperty(value = "分帐手续费", index = 12)
     private Double prorateCommission;
     /**
-     * 付供应商 = 商品费 + 运费 + 税费
+     * (付款供应商)付款状态:1待付款、2部分付款、3已付款
      */
-    @ExcelProperty(value = "付供应商", index = 10)
-    private Double shouldPayShopAmount;
+    @ExcelProperty(value = "结算状态", index = 13)
+    private Integer settleStatus;
     /**
-     * 已结算金额
+     * 退款状态 1无退款、3有退款
+     */
+    @ExcelProperty(value = "退款状态", index = 14)
+    private Integer refundStatus;
+    /**
+     * 退款金额
      */
-    @ExcelProperty(value = "已结算金额", index = 11)
-    private Double settleAmount;
+    @ExcelProperty(value = "退款金额", index = 15)
+    private Double refundAmount;
     /**
      * 订单商品信息
      */

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

@@ -53,7 +53,7 @@ public interface ShipService {
      * @param refundStatus
      * @return
      */
-    List<SettlementDto> exportExcel(Integer shopId, Integer payStatus, String shopOrderNo, String name, String beginTime, String endTime, Integer refundStatus);
+    List<SettlementVo> exportExcel(Integer shopId, Integer payStatus, String shopOrderNo, String name, String beginTime, String endTime, Integer refundStatus);
     /**
      * 供应商子订单详情
      * @param shopOrderId 子订单Id

+ 72 - 153
src/main/java/com/caimei365/order/service/impl/ShipServiceImpl.java

@@ -94,6 +94,7 @@ public class ShipServiceImpl implements ShipService {
     private WeChatService weChatService;
     @Resource
     private ToolsFeign toolsFeign;
+
     /**
      * 供应商订单列表
      *
@@ -140,94 +141,12 @@ public class ShipServiceImpl implements ShipService {
         // 分页请求数据
         PageHelper.startPage(pageNum, pageSize);
         List<SettlementVo> settlementList = shipMapper.getSettlementList(shopId, payStatus, shopOrderNo, name, beginTime, endTime, refundStatus);
-        settlementList.forEach(settlement -> {
-            if (null != settlement) {
-                List<OrderProductVo> orderProductList = orderCommonMapper.getShopOrderProduct(settlement.getShopOrderId());
-                settlement.setOrderProductList(orderProductList);
-            }
-            // 退款金额
-            AtomicDouble refund = new AtomicDouble(0);
-            // 付款手续费
-            double procedureFee = 0d;
-            // 付款记录
-            List<DiscernReceiptVo> shopOrderRelation = shipMapper.getShopOrderRelation(settlement.getShopOrderId());
-            for (DiscernReceiptVo discernReceipt : shopOrderRelation) {
-                // 本次支付金额,单位/元
-                double splitAmount = discernReceipt.getAssociateAmount();
-                double payAmount;
-                if (1 == discernReceipt.getPayWay()) {
-                    if (12 == discernReceipt.getPayType()) {
-                        // 网银支付
-                        payAmount = 10.00;
-                    } else if (17 == discernReceipt.getPayType()) {
-                        //b2c网银
-                        //b2c 0.2%
-                        payAmount = MathUtil.mul(splitAmount, 0.002, 2).doubleValue();
-                        //b2c最低手续费0.1
-                        if (payAmount < 0.1) {
-                            payAmount = 0.1;
-                        }
-                    } else if (8 == discernReceipt.getPayType() || 13 == discernReceipt.getPayType() || 15 == discernReceipt.getPayType()) {
-                        //微信0.65%手续费
-                        //微信0.65%
-                        payAmount = MathUtil.mul(splitAmount, 0.0065, 2).doubleValue();
-                    } else if (29 == discernReceipt.getPayType()) {
-                        //快捷支付 借记卡支付29,
-
-                        payAmount = MathUtil.mul(splitAmount, 0.003, 2).doubleValue();
-                        if (payAmount < 0.1) {
-                            payAmount = 0.1;
-                        }
-                    } else if (30 == discernReceipt.getPayType()) {
-                        //快捷支付 贷记卡支付30
-                        payAmount = MathUtil.mul(splitAmount, 0.006, 2).doubleValue();
-                        if (payAmount < 0.1) {
-                            payAmount = 0.1;
-                        }
-                    } else {
-                        //手续费 其他0.25%
-                        payAmount = MathUtil.mul(splitAmount, 0.0025, 2).doubleValue();
-                    }
-                    if (MathUtil.compare(payAmount, 0.01) <= 0) {
-                        payAmount = 0.01;
-                    }
-                    procedureFee = MathUtil.add(procedureFee, payAmount).doubleValue();
-                }
-            }
-            // 退款记录
-            List<CmReturnedPurchase> refundPurchase = shipMapper.getRefundPurchase(settlement.getShopOrderId());
-            for (CmReturnedPurchase refundPur : refundPurchase) {
-                refund.set(MathUtil.add(refund.get(), refundPur.getReturnedPurchaseFee()).doubleValue());
-            }
-            // 支付手续费
-            settlement.setPaymentCommission(procedureFee);
-            // 分帐记录
-            Double splitAccount = shipMapper.getSplitAccount(settlement.getShopOrderId());
-            // 分帐手续费
-            settlement.setProrateCommission(MathUtil.mul(splitAccount, 0.001).doubleValue());
-            // 总退款金额
-            settlement.setRefundAmount(refund.get());
-        });
+        settleListFunction(settlementList);
         PageInfo<SettlementVo> pageInfo = new PageInfo(settlementList);
         return ResponseJson.success(pageInfo);
     }
 
-    /**
-     * 导出excel
-     *
-     * @param shopId
-     * @param payStatus
-     * @param shopOrderNo
-     * @param name
-     * @param beginTime
-     * @param endTime
-     * @param refundStatus
-     * @return
-     */
-    @Override
-    public List<SettlementDto> exportExcel(Integer shopId, Integer payStatus, String shopOrderNo, String name, String beginTime, String endTime, Integer refundStatus) {
-        List<SettlementVo> settlementList = shipMapper.getSettlementList(shopId, payStatus, shopOrderNo, name, beginTime, endTime, refundStatus);
-        List<SettlementDto> settlementDtoList = new ArrayList<>();
+    private void settleListFunction(List<SettlementVo> settlementList) {
         settlementList.forEach(settlement -> {
             if (null != settlement) {
                 List<OrderProductVo> orderProductList = orderCommonMapper.getShopOrderProduct(settlement.getShopOrderId());
@@ -239,7 +158,7 @@ public class ShipServiceImpl implements ShipService {
             double procedureFee = 0d;
             // 付款记录
             List<DiscernReceiptVo> shopOrderRelation = shipMapper.getShopOrderRelation(settlement.getShopOrderId());
-            for (DiscernReceiptVo discernReceipt:shopOrderRelation) {
+            for (DiscernReceiptVo discernReceipt : shopOrderRelation) {
                 // 本次支付金额,单位/元
                 double splitAmount = discernReceipt.getAssociateAmount();
                 double payAmount;
@@ -260,19 +179,18 @@ public class ShipServiceImpl implements ShipService {
                     payAmount = MathUtil.mul(splitAmount, 0.0065, 2).doubleValue();
                 } else if (29 == discernReceipt.getPayType()) {
                     //快捷支付 借记卡支付29,
-
                     payAmount = MathUtil.mul(splitAmount, 0.003, 2).doubleValue();
                     if (payAmount < 0.1) {
                         payAmount = 0.1;
                     }
-                }else if (30 == discernReceipt.getPayType()) {
+                } else if (30 == discernReceipt.getPayType()) {
                     //快捷支付 贷记卡支付30
                     payAmount = MathUtil.mul(splitAmount, 0.006, 2).doubleValue();
                     if (payAmount < 0.1) {
                         payAmount = 0.1;
                     }
                 } else {
-                    //手续费 其他0.25%
+                    //手续费 支付宝0.25%
                     payAmount = MathUtil.mul(splitAmount, 0.0025, 2).doubleValue();
                 }
                 if (MathUtil.compare(payAmount, 0.01) <= 0) {
@@ -290,43 +208,40 @@ public class ShipServiceImpl implements ShipService {
             // 分帐记录
             Double splitAccount = shipMapper.getSplitAccount(settlement.getShopOrderId());
             // 分帐手续费
-            settlement.setProrateCommission(MathUtil.mul(splitAccount, 0.001).doubleValue());
+            Double splitCommission = MathUtil.mul(splitAccount, 0.001).doubleValue();
+            splitCommission = splitCommission <= 0 ? 0.01 : splitCommission;
+            settlement.setProrateCommission(splitCommission);
             // 总退款金额
             settlement.setRefundAmount(refund.get());
-            // 设置返回数据
-            SettlementDto lementDto = new SettlementDto();
-            lementDto.setShopOrderNo(settlement.getShopOrderNo());
-            lementDto.setOrderTime(settlement.getOrderTime());
-            lementDto.setName(settlement.getName());
-            if(settlement.getOrderProductList().size() > 0) {
+            if (settlement.getOrderProductList().size() > 0) {
                 String names = "";
                 for (OrderProductVo sett : settlement.getOrderProductList()) {
                     names = names + sett.getName();
                 }
-                lementDto.setProductInfo(names);
-            }
-            lementDto.setTotalAmount(settlement.getTotalAmount());
-            if (1 == settlement.getRefundStatus()) {
-                lementDto.setRefundStatus("无退款");
-            } else {
-                lementDto.setRefundStatus("有退款");
+                settlement.setProductInfo(names);
             }
-            lementDto.setRefundAmount(settlement.getRefundAmount());
-            lementDto.setPaymentCommission(settlement.getPaymentCommission());
-            lementDto.setProrateCommission(settlement.getProrateCommission());
-            if (1 == settlement.getSettlestatus()) {
-                lementDto.setPayStatus("未结算");
-            } else if (2 == settlement.getSettlestatus()){
-                lementDto.setPayStatus("部分结算");
-            } else {
-                lementDto.setPayStatus("已结算");
-            }
-            lementDto.setShouldPayShopAmount(settlement.getShouldPayShopAmount());
-            lementDto.setSettleAmount(settlement.getSettleAmount());
-            lementDto.setUnsettledAmount(MathUtil.sub(settlement.getShouldPayShopAmount(), settlement.getSettleAmount()).doubleValue());
-            settlementDtoList.add(lementDto);
+            settlement.setPaymentCommission(settlement.getPaymentCommission());
+            settlement.setProrateCommission(settlement.getProrateCommission());
         });
-        return settlementDtoList;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param shopId
+     * @param payStatus
+     * @param shopOrderNo
+     * @param name
+     * @param beginTime
+     * @param endTime
+     * @param refundStatus
+     * @return
+     */
+    @Override
+    public List<SettlementVo> exportExcel(Integer shopId, Integer payStatus, String shopOrderNo, String name, String beginTime, String endTime, Integer refundStatus) {
+        List<SettlementVo> settlementList = shipMapper.getSettlementList(shopId, payStatus, shopOrderNo, name, beginTime, endTime, refundStatus);
+        settleListFunction(settlementList);
+        return settlementList;
     }
 
     /**
@@ -590,14 +505,14 @@ public class ShipServiceImpl implements ShipService {
             logisticsInformation.setUpdateDate(date);
             // 保存 物流跟踪信息
             shipMapper.insertLogisticsInformation(logisticsInformation);
-            if(2==shopOrder.getOrderType()){
+            if (2 == shopOrder.getOrderType()) {
                 String openId = baseMapper.getWechatHeheOpenId(shopOrder.getUserId());
                 //微信模板消息
-                Map<String,Object> keyWords = new HashMap<>();
-                keyWords.put("character_string3",shopOrder.getOrderNo());
-                keyWords.put("time10",DateUtils.formatDate(date, "yyyy-MM-dd HH:mm"));
-                keyWords.put("thing9",logisticsCompanyName);
-                keyWords.put("character_string8",number);
+                Map<String, Object> keyWords = new HashMap<>();
+                keyWords.put("character_string3", shopOrder.getOrderNo());
+                keyWords.put("time10", DateUtils.formatDate(date, "yyyy-MM-dd HH:mm"));
+                keyWords.put("thing9", logisticsCompanyName);
+                keyWords.put("character_string8", number);
                 MessageModel<WechatTemplateMessage> wechatTemplateMessageMessageModel = new MessageModel<WechatTemplateMessage>()
                         .code(MessageType.WECHAT_TEMPLATE_MESSAGE)
                         .mqInfo(new MqInfo().topic("MessageLine").delay(3).async(1))
@@ -610,7 +525,7 @@ public class ShipServiceImpl implements ShipService {
                                 .templateId("0Ruf-Ypu0Eahk0vY9orVN0-QqE0auk2N89LqjtGq4p8")
                                 .mapKeyWords(keyWords)
                                 .remark("您购买的商品已发货,收到货后请记得确认收货哟~")
-                                .pagePath("pages/views/order/order-detail?orderId="+shopOrder.getOrderId()));
+                                .pagePath("pages/views/order/order-detail?orderId=" + shopOrder.getOrderId()));
                 toolsFeign.sendCommonMessage(wechatTemplateMessageMessageModel);
                 //站内信
                 MessageModel<InsideMessage> insideMessageMessageModel = new MessageModel<>();
@@ -681,11 +596,13 @@ public class ShipServiceImpl implements ShipService {
 //                }
 //            }
 //        }
-                return ResponseJson.success(logisticsBatch.getId());
+        return ResponseJson.success(logisticsBatch.getId());
 
     }
+
     /**
      * 修改主订单发货状态
+     *
      * @param shopOrder 子订单
      */
     private void setMainOrderStatus(ShopOrderVo shopOrder) {
@@ -789,7 +706,8 @@ public class ShipServiceImpl implements ShipService {
     }
 
     /**
-     *  设置 已发,已退,已取消发货数量
+     * 设置 已发,已退,已取消发货数量
+     *
      * @param recordVo 发货记录
      */
     private void setLogisticsRecordNum(LogisticsRecordVo recordVo) {
@@ -890,8 +808,8 @@ public class ShipServiceImpl implements ShipService {
      *                          remark: 备注,
      *                          remarkImage: 图片备注,
      *                          logistics:[  // 物流信息
-     *                              {number:'45646464646',logisticsCompanyName:'顺丰物流',logisticsCompanyCode:'物流英文代码'},
-     *                              {number:'45646464646',logisticsCompanyName:'顺丰物流',logisticsCompanyCode:'物流英文代码'}
+     *                          {number:'45646464646',logisticsCompanyName:'顺丰物流',logisticsCompanyCode:'物流英文代码'},
+     *                          {number:'45646464646',logisticsCompanyName:'顺丰物流',logisticsCompanyCode:'物流英文代码'}
      *                          ]
      *                          }
      */
@@ -919,7 +837,7 @@ public class ShipServiceImpl implements ShipService {
             return ResponseJson.error("添加物流参数异常!", null);
         }
         Date date = new Date();
-        for (Object logisticObj: logistics) {
+        for (Object logisticObj : logistics) {
             JSONObject logistic = (JSONObject) logisticObj;
             String number = (String) logistic.get("number");
             String logisticsCompanyName = (String) logistic.get("logisticsCompanyName");
@@ -931,7 +849,7 @@ public class ShipServiceImpl implements ShipService {
 
             //推送信息中心-交易物流
             String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
-            MessageCenter messageCenter=new MessageCenter();
+            MessageCenter messageCenter = new MessageCenter();
             messageCenter.setShopID(logisticsBatch.getShopId());
             messageCenter.setClubID(null);
             messageCenter.setUserType(2);
@@ -965,14 +883,15 @@ public class ShipServiceImpl implements ShipService {
 
     /**
      * 扫码添加物流
-     * @param number      快递单号
-     * @param mobile      收/寄件人的电话号码(顺丰必填)
+     *
+     * @param number 快递单号
+     * @param mobile 收/寄件人的电话号码(顺丰必填)
      */
     @Override
     public ResponseJson<CompanyVo> scanGetLogisticsInfo(String number, String mobile) {
         String result = remoteCallService.getLogisticsByNumber(number, null, mobile);
         String errorMsg = "查询失败!";
-        if (StringUtils.isNotEmpty(result)){
+        if (StringUtils.isNotEmpty(result)) {
             JSONObject resultJson = JSONObject.parseObject(result);
             String comCode = resultJson.getString("com");
             if (StringUtils.isNotEmpty(comCode)) {
@@ -1067,7 +986,7 @@ public class ShipServiceImpl implements ShipService {
         calendar.add(Calendar.DATE, 3);
         // 获取数据库已有分享码
         OrderShareCodeVo orderCodeVo = shipMapper.getShipShareCode(null, shopOrderId);
-        if (orderCodeVo != null && orderCodeVo.getExpiredTime().compareTo(date) >= 0 ) {
+        if (orderCodeVo != null && orderCodeVo.getExpiredTime().compareTo(date) >= 0) {
             // 旧分享码还未过期,直接返回
             return ResponseJson.success(orderCodeVo.getShareCode());
         } else if (orderCodeVo != null) {
@@ -1107,7 +1026,7 @@ public class ShipServiceImpl implements ShipService {
     public ResponseJson<Map<String, Object>> checkShipShareCode(Integer source, Integer shopOrderId, String shareCode, String code, String encryptedData, String iv, HttpHeaders headers) {
         // 微信小程序授权登录(调用user服务,发送服务间调用POST请求)
         String loginData = remoteCallService.appletsAuthorization(code, encryptedData, iv, headers);
-        if (StringUtils.isEmpty(loginData)){
+        if (StringUtils.isEmpty(loginData)) {
             return ResponseJson.error("微信授权登录异常!", null);
         }
         // 解析登录后得到 userIdentity,  openId等
@@ -1212,18 +1131,18 @@ public class ShipServiceImpl implements ShipService {
      * 保存商品资质
      *
      * @param jsonParamsDto params:[{
-     *                         recordId: 商品发货记录id,
-     *                         sn:       sn码,
-     *                         files:    [{fileName:"文件名称",ossName:"oss文件名称"},{fileName:"文件名称",ossName:"oss文件名称"}...]
-     *                         images:   ["图片","图片",...]
-     *                         }, {}]
+     *                      recordId: 商品发货记录id,
+     *                      sn:       sn码,
+     *                      files:    [{fileName:"文件名称",ossName:"oss文件名称"},{fileName:"文件名称",ossName:"oss文件名称"}...]
+     *                      images:   ["图片","图片",...]
+     *                      }, {}]
      */
     @Transactional(rollbackFor = Exception.class)
     @Override
     public ResponseJson<Void> saveProductQualification(JsonParamsDto jsonParamsDto) {
         try {
             JSONArray paramsArray = parseArray(jsonParamsDto.getParams());
-            for (Object paramObj: paramsArray) {
+            for (Object paramObj : paramsArray) {
                 JSONObject jsonObject = (JSONObject) paramObj;
                 Integer recordId = jsonObject.getInteger("recordId");
                 String sn = jsonObject.getString("sn");
@@ -1233,7 +1152,7 @@ public class ShipServiceImpl implements ShipService {
                 if (!filesArray.isEmpty()) {
                     QualificationPo qualificationFile = new QualificationPo();
                     qualificationFile.setRecordId(recordId);
-                    for (Object fileObj: filesArray) {
+                    for (Object fileObj : filesArray) {
                         JSONObject file = (JSONObject) fileObj;
                         qualificationFile.setFileName(file.getString("fileName"));
                         qualificationFile.setOssName(file.getString("ossName"));
@@ -1245,7 +1164,7 @@ public class ShipServiceImpl implements ShipService {
                 // 删除旧的资质图片
                 shipMapper.deleteQualificationImage(recordId);
                 if (!imagesArray.isEmpty()) {
-                    for (Object imageObj: imagesArray) {
+                    for (Object imageObj : imagesArray) {
                         String image = String.valueOf(imageObj);
                         // 保存资质图片
                         shipMapper.insertQualificationImage(image, recordId);
@@ -1300,7 +1219,7 @@ public class ShipServiceImpl implements ShipService {
         if (0 == wait - amount) {
             status = 3;
             //分销人员下单修改报备记录
-            Integer identity = baseMapper.getUserIdentity(null,orderId, null);
+            Integer identity = baseMapper.getUserIdentity(null, orderId, null);
             if (identity == 8) {
                 CmReportingClub byCmReportingClub = cmReportingClubMapper.getByCmReportingClub(new CmReportingClub()
                         .orderId(orderId)
@@ -1335,9 +1254,9 @@ public class ShipServiceImpl implements ShipService {
         // 获取订单下子订单收款状态
         List<Integer> receiptStatus = shipMapper.getReceiptStatus(orderId);
         Integer sta = 1;
-        if (receiptStatus.stream().allMatch(r -> r==3)) {
+        if (receiptStatus.stream().allMatch(r -> r == 3)) {
             sta = 3;
-        } else if (receiptStatus.stream().allMatch(r -> r==1)) {
+        } else if (receiptStatus.stream().allMatch(r -> r == 1)) {
             sta = 1;
         } else {
             sta = 2;
@@ -1539,14 +1458,14 @@ public class ShipServiceImpl implements ShipService {
                 // 过滤保存已上架商品
                 List<CartItemVo> productList = shipMapper.getProductsOrganize(shop.getShopId(), organizeId, finalIdList, shop.getSplitCode());
                 // 设置该商品购买数量
-                productList.forEach( p -> {
+                productList.forEach(p -> {
                     CmOrganizeSkuPo organizeSkuInfo = shipMapper.getOrganizeSkuInfo(p.getSkuId(), organizeId);
                     //前端传入修改后商品的价格
                     double price = productPriceInfos.get(p.getSkuId().toString());
                     // 该商品成本计算
                     if (null != organizeSkuInfo) {
                         // 商品为固定成本
-                        if ( StringUtils.isNotBlank(organizeSkuInfo.getCostCheckFlag()) && "1".equals(organizeSkuInfo.getCostCheckFlag())) {
+                        if (StringUtils.isNotBlank(organizeSkuInfo.getCostCheckFlag()) && "1".equals(organizeSkuInfo.getCostCheckFlag())) {
                             // 系统商城商品的成本之和
                             double sysProductPrice = MathUtil.add(organizeSkuInfo.getCostPrice(), MathUtil.add(organizeSkuInfo.getCmCostPrice(), organizeSkuInfo.getOrganizeCostPrice())).doubleValue();
                             // 系统商品成本之和小于修改的价格,修改价格异常,不允许下单
@@ -1607,7 +1526,7 @@ public class ShipServiceImpl implements ShipService {
                             } else {
                                 Double postage = (Double) postageMap.get("postage");
                                 shopPostage.set(MathUtil.add(shopPostage.get(), postage).doubleValue());
-                                log.info("shopPostage.get()======"+shopPostage.get());
+                                log.info("shopPostage.get()======" + shopPostage.get());
                             }
                         }
                         // 该供应商下商品种类 +1
@@ -1634,9 +1553,9 @@ public class ShipServiceImpl implements ShipService {
                     } else {
                         shop.setIsColdChina(false);
                     }
-                    log.info("shop.getPostage()******"+shop.getPostage());
+                    log.info("shop.getPostage()******" + shop.getPostage());
                     // 供应商总金额
-                    shopPrice.set(MathUtil.add(MathUtil.add(shopPrice.get(), shop.getPostage()),coldChain).doubleValue());
+                    shopPrice.set(MathUtil.add(MathUtil.add(shopPrice.get(), shop.getPostage()), coldChain).doubleValue());
                     if (shopKindCount.get() > 0) {
                         // 供应商商品
                         shop.setCartList(productList);
@@ -1684,7 +1603,7 @@ public class ShipServiceImpl implements ShipService {
         // 联合丽格冷链费
         double coldChain = 0.00d;
         if (null != totalProductList) {
-            for (CartItemVo cart :totalProductList) {
+            for (CartItemVo cart : totalProductList) {
                 if (7881 == cart.getProductId()) {
                     if (cart.getNumber() >= 100) {
                         coldChain = 0.00d;
@@ -1736,5 +1655,5 @@ public class ShipServiceImpl implements ShipService {
             log.info("【删除订单】>>>>>>>>>逻辑删除主订单(update[cm_order])orderId:" + shopOrder.getOrderId());
         }
         return ResponseJson.success("订单取消成功", null);
-        }
+    }
 }

+ 15 - 9
src/main/resources/mapper/ShipMapper.xml

@@ -198,16 +198,20 @@
             so.shopOrderID AS shopOrderId,
             so.orderTime,
             so.settlestatus,
-            user.userName AS name,
-            IFNULL(so.shouldPayShopAmount, 0) AS shouldPayShopAmount,
-            so.payedShopAmount,
-            ifnull(csr.settleAmount, 0) as settleAmount,
+            c.name AS clubName,
+            sp.name AS spName,
+            cp.name AS cpName,
+            IFNULL((SELECT settleAmount FROM cm_settle_record WHERE shopOrderId = so.shopOrderId AND settleType = 1),0) AS shopSettleAmount,
+            IFNULL((SELECT settleAmount FROM cm_settle_record WHERE shopOrderId = so.shopOrderId AND settleType = 2),0) AS cmSettleAmount,
+            IFNULL((SELECT settleAmount FROM cm_settle_record WHERE shopOrderId = so.shopOrderId AND settleType = 3),0) AS otherSettleAmount,
             so.totalAmount,
-            so.refundStatus,
-            IFNULL(so.refundAmount, 0) AS refundAmount
+            so.refundStatus as refundStatus,
+            IFNULL(so.refundAmount, 0) AS refundAmount,
+            IFNULL(so.itemCount,0)+IFNULL(so.presentNum,0) AS productNum
         FROM cm_shop_order so
-        LEFT JOIN cm_settle_record csr ON so.shopOrderId = csr.shopOrderId
-        LEFT JOIN USER ON user.userID = so.userID
+        LEFT JOIN club c ON c.clubId = so.clubId
+        LEFT JOIN serviceprovider sp ON c.spId = sp.serviceProviderID
+        LEFT JOIN cm_providers cp ON cp.id = sp.providerId
         <where>
             <if test="shopOrderNo != null and shopOrderNo != ''">
                 AND so.shopOrderNo = #{shopOrderNo}
@@ -221,7 +225,7 @@
                 </if>
             </if>
             <if test="name != null and name != ''">
-                AND user.userName like concat('%',#{name},'%')
+                AND c.name like concat('%',#{name},'%')
             </if>
             <if test="beginTime != null and beginTime != ''">
                 AND so.orderTime <![CDATA[ >= ]]> #{beginTime}
@@ -234,6 +238,7 @@
             </if>
             AND so.shopID = #{shopId}
             AND so.delFlag='0'
+            AND so.shopStatus != 4
             ORDER BY so.orderTime DESC
         </where>
     </select>
@@ -253,6 +258,7 @@
         FROM cm_split_account
         WHERE shopOrderId = #{shopOrderId}
           AND payStatus = 1
+          AND productType != 1
     </select>
     <select id="getShopOrder" resultType="com.caimei365.order.model.vo.ShopOrderVo">
         SELECT