소스 검색

提交订单,订单商品整理

chao 4 년 전
부모
커밋
8601a9fe68

+ 32 - 1
src/main/java/com/caimei365/order/mapper/SubmitMapper.java

@@ -2,6 +2,9 @@ package com.caimei365.order.mapper;
 
 import com.caimei365.order.model.bo.OrderUserBo;
 import com.caimei365.order.model.bo.ProductBo;
+import com.caimei365.order.model.po.InvoicePo;
+import com.caimei365.order.model.po.OrderPo;
+import com.caimei365.order.model.vo.PromotionsVo;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
@@ -38,5 +41,33 @@ public interface SubmitMapper {
      * @param productId 商品Id
      */
     ProductBo getProductDetails(Integer productId);
-
+    /**
+     * 抵扣后更新用户余额
+     * @param userMoney 账户余额
+     * @param ableUserMoney 账户实际可用余额
+     * @param userId 机构用户Id
+     */
+    void updateUserMoney(Double userMoney, Double ableUserMoney, Integer userId);
+    /**
+     * 获取条款名称
+     * @param clauseId 条款Id
+     */
+    String getClauseNameById(Integer clauseId);
+    /**
+     * 保存主订单数据
+     */
+    void insertMainOrder(OrderPo mainOrder);
+    /**
+     * 保存订单促销
+     */
+    void insertOrderPromotions(PromotionsVo promotions);
+    /**
+     * 删除老的订单增值税信息
+     * @param orderId 订单Id
+     */
+    void deleteOrderInvoiceByOrderId(Integer orderId);
+    /**
+     * 保存 订单发票信息
+     */
+    void insertOrderInvoice(InvoicePo invoice);
 }

+ 22 - 1
src/main/java/com/caimei365/order/model/bo/ProductBo.java

@@ -3,7 +3,6 @@ package com.caimei365.order.model.bo;
 import lombok.Data;
 
 import java.io.Serializable;
-import java.math.BigDecimal;
 
 /**
  * Description
@@ -174,4 +173,26 @@ public class ProductBo implements Serializable {
      * 下单时商品购买价格类型快照 0 机构价,1活动价 ,2阶梯价
      */
     private Integer actProduct;
+    /**
+     * 订单号(保存订单用)
+     */
+    private Integer orderId;
+    /**
+     * 订单编号(保存订单用)
+     */
+    private String orderNo;
+    /**
+     * 子订单ID(保存订单用)
+     */
+    private Integer shopOrderId;
+    /**
+     * 子订单编号(保存订单用)
+     */
+    private String shopOrderNo;
+    /**
+     * 订单促销id
+     */
+    private Integer orderPromotionsId;
+
+
 }

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

@@ -53,4 +53,8 @@ public class InvoicePo implements Serializable {
      * 开户银行
      */
     private String openBank;
+    /**
+     * 订单号(保存订单用)
+     */
+    private Integer orderId;
 }

+ 20 - 5
src/main/java/com/caimei365/order/model/po/OrderPo.java

@@ -3,7 +3,6 @@ package com.caimei365.order.model.po;
 import lombok.Data;
 
 import java.io.Serializable;
-import java.math.BigDecimal;
 
 /**
  * Description
@@ -38,10 +37,6 @@ public class OrderPo implements Serializable {
      * 下单人Id(协销Id,或运营人Id,或用户Id)
      */
     private Integer buyUserId;
-    /**
-     * 协销Id
-     */
-    private Integer serviceProviderId;
     /**
      * 订单提交时间
      */
@@ -171,4 +166,24 @@ public class OrderPo implements Serializable {
      * 订单确认时间
      */
     private String confirmTime;
+    /**
+     * 订单支付时间
+     */
+    private String payTime;
+    /**
+     * 返佣订单标识 0非返佣订单,1返佣订单
+     */
+    private Integer rebateFlag;
+    /**
+     * 条款ID
+     */
+    private Integer clauseId;
+    /**
+     * 条款名称
+     */
+    private String clauseName;
+    /**
+     * 子订单ID
+     */
+    private String shopOrderIds;
 }

+ 44 - 0
src/main/java/com/caimei365/order/model/po/ShopOrderPo.java

@@ -0,0 +1,44 @@
+package com.caimei365.order.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/7/12
+ */
+@Data
+public class ShopOrderPo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 子订单ID
+     */
+    private Integer shopOrderId;
+    /**
+     * 子订单编号
+     */
+    private String shopOrderNo;
+    /**
+     * 订单号
+     */
+    private Integer orderId;
+    /**
+     * 订单编号
+     */
+    private String orderNo;
+    /**
+     * 供应商Id
+     */
+    private Integer shopId;
+    /**
+     * 子订单备注信息
+     */
+    private String note;
+    /**
+     * 购买机构Id
+     */
+    private Integer clubId;
+}

+ 8 - 0
src/main/java/com/caimei365/order/model/vo/PromotionsVo.java

@@ -74,4 +74,12 @@ public class PromotionsVo implements Serializable {
      * 该优惠下赠品品
      */
     private List<CartItemVo> giftList;
+    /**
+     * 主订单id(保存订单促销用)
+     */
+    private Integer orderId;
+    /**
+     * 促销id(保存订单促销用)
+     */
+    private Integer promotionsId;
 }

+ 150 - 139
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -11,6 +11,7 @@ import com.caimei365.order.model.dto.SubmitDto;
 import com.caimei365.order.model.bo.OrderUserBo;
 import com.caimei365.order.model.po.InvoicePo;
 import com.caimei365.order.model.po.OrderPo;
+import com.caimei365.order.model.po.ShopOrderPo;
 import com.caimei365.order.model.vo.*;
 import com.caimei365.order.service.SubmitService;
 import com.caimei365.order.utils.CodeUtil;
@@ -122,13 +123,13 @@ public class SubmitServiceImpl implements SubmitService {
             log.error("订单参数解析异常try-catch:", e);
             return ResponseJson.error("订单参数解析异常!", null);
         }
-        if (null == orderInfo){
+        if (null == orderInfo || orderInfo.isEmpty()){
             return ResponseJson.error("订单商品数据异常!", null);
         }
-        if (null == payInfo){
+        if (null == payInfo || payInfo.isEmpty()){
             return ResponseJson.error("订单金额数据异常!", null);
         }
-        if (null == orderInvoice){
+        if (null == orderInvoice || orderInvoice.isEmpty()){
             return ResponseJson.error("发票信息数据异常!", null);
         }
         // 打印参数
@@ -219,15 +220,9 @@ public class SubmitServiceImpl implements SubmitService {
         }
         orderUserBo.setBuyUserId(buyUserId);
         orderUserBo.setAddressId(submitDto.getAddressId());
-
-
-//     *                  "unionId":"",               //微信unionId
-//     *                  "cartType":3,               //购买类型:(1自主下单, 3协销下单)
-//     *                  "serviceProviderId": 1378,  //协销ID(小程序忽略)
-//     *                  "clubUserId": 10708,        //机构用户ID
-//     *                  "addressId": 2732,          //地址ID
-
-
+        /*
+         * 保存订单
+         */
         return saveOrder(orderUserBo);
     }
 
@@ -262,8 +257,6 @@ public class SubmitServiceImpl implements SubmitService {
             mainOrder.setOrderSubmitType(3);
             // 订单未确认
             mainOrder.setConfirmFlag(0);
-            // 协销Id
-            mainOrder.setServiceProviderId(orderUserBo.getBuyUserId());
         } else {
             // 普通订单
             mainOrder.setOrderType(1);
@@ -487,6 +480,7 @@ public class SubmitServiceImpl implements SubmitService {
                         promotions.getProductList().add(promotionPrice);
                         if (!promotionsIds.contains(promotions.getId())) {
                             promotionsIds.add(promotions.getId());
+                            promotions.setPromotionsId(promotions.getId());
                             promotionList.add(promotions);
                         } else {
                             promotionList.forEach(promotionsTemp -> {
@@ -495,6 +489,7 @@ public class SubmitServiceImpl implements SubmitService {
                                 }
                             });
                         }
+                        product.setOrderPromotionsId(promotions.getId());
                     }
                 }
                 // 统计商品总金额
@@ -545,6 +540,9 @@ public class SubmitServiceImpl implements SubmitService {
                 productIdList.add(product.getProductId().toString());
             }
         }
+        if (orderProductList.size()==0){
+            return ResponseJson.error("订单商品数据异常!", null);
+        }
         // 设置是否是二手订单
         if (secondHandOrderFlag) {
             mainOrder.setSecondHandOrderFlag(1);
@@ -595,6 +593,8 @@ public class SubmitServiceImpl implements SubmitService {
         /*
          * 发票信息
          */
+        boolean hasInvoiceFlag = false;
+        InvoicePo invoice = new InvoicePo();
         mainOrder.setInvoiceFlag(orderUserBo.getInvoiceType());
         // 发票类型 0不开发票 1普通发票 2增值税发票
         if (1== orderUserBo.getInvoiceType() || 2 == orderUserBo.getInvoiceType()){
@@ -608,7 +608,6 @@ public class SubmitServiceImpl implements SubmitService {
             if (StringUtils.isNotEmpty(corporationTaxNum)){
                 return ResponseJson.error("纳税人识别号信息不正确!", null);
             }
-            InvoicePo invoice = new InvoicePo();
             invoice.setType(invoiceType);
             invoice.setInvoiceTitle(invoiceTitle);
             invoice.setCorporationTaxNum(corporationTaxNum);
@@ -621,6 +620,7 @@ public class SubmitServiceImpl implements SubmitService {
                 }
                 invoice.setInvoiceContent(invoiceContent);
                 invoice.setInvoiceTitleType(invoiceTitleType);
+                hasInvoiceFlag = true;
             }
             if (2== orderUserBo.getInvoiceType()) {
                 // 增值税发票:发票类型、发票、抬头(公司名称)、纳税人识别号、注册地址、注册电话、开户银行、开户银行账户
@@ -635,6 +635,7 @@ public class SubmitServiceImpl implements SubmitService {
                 invoice.setRegisteredPhone(registeredPhone);
                 invoice.setOpenBank(openBank);
                 invoice.setBankAccountNo(bankAccountNo);
+                hasInvoiceFlag = true;
             }
         }
 
@@ -683,6 +684,7 @@ public class SubmitServiceImpl implements SubmitService {
             mainOrder.setStatus(11);
             mainOrder.setConfirmTime(curDateStr);
         }
+
         // 是否完成支付(默认不是,只有余额抵扣才算)
         boolean isPaySuccessFlag = false;
         // 余额支付标识,0不使用,1使用
@@ -717,103 +719,138 @@ public class SubmitServiceImpl implements SubmitService {
                 mainOrder.setPayFlag(1);
                 isPaySuccessFlag = true;
             }
+            // 抵扣后更新用户余额
+            submitMapper.updateUserMoney(lastUserMoney, lastAbleUserMoney, orderUserBo.getUserId());
+            log.info("【提交订单】>>>>>更新用户余额,抵扣后剩余:[userMoney:" + lastUserMoney + "] ,ableUserMoney:" + lastAbleUserMoney);
+            // 支付时间
+            mainOrder.setPayTime(curDateStr);
+        }
+        // 余额支付金额
+        mainOrder.setBalancePayFee(balancePayFee.get());
+        // 实际支付金额(商品金额+运费-余额抵扣)
+        mainOrder.setPayableAmount(payableAmount.get());
+
+        // 是否返佣订单
+        Integer rebateFlag = (null == orderUserBo.getRebateFlag() ? 0 : orderUserBo.getRebateFlag());
+        mainOrder.setRebateFlag(rebateFlag);
+
+        // 判断前端传入orderShouldPayFee订单应付金额,和后台计算应付金额对比
+        log.info("【提交订单】>>>>>后台计算payableAmount:" + payableAmount.get() + " ,前端传入orderShouldPayFee:" + orderUserBo.getOrderShouldPayFee());
+        // compare return[-1:v1<v2, 0:v1=v2, 1:v1>v2]
+        int compare = MathUtil.compare(orderUserBo.getOrderShouldPayFee(), payableAmount.get());
+        if (compare != 0) {
+            // 设置手动回滚事务
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            return ResponseJson.error("订单付款金额不正确!", null);
+        }
 
+        // 售后条款
+        Integer clauseId = orderUserBo.getClauseId();
+        String clauseName = null;
+        if (null != clauseId) {
+            clauseName = submitMapper.getClauseNameById(clauseId);
+        }
+        if (StringUtils.isNotEmpty(clauseName)) {
+            mainOrder.setClauseId(clauseId);
+            mainOrder.setClauseName(clauseName);
+        } else {
+            mainOrder.setClauseId(1);
+            mainOrder.setClauseName("无条款");
+        }
 
+        /*
+         * 保存主订单数据
+         */
+        submitMapper.insertMainOrder(mainOrder);
+        log.info("【提交订单】>>>>>>>>>>>>>>>>>>>>>>>>>>新增主订单(insert[cm_order])orderId:" + mainOrder.getOrderId());
 
+        /*
+         * 保存订单促销
+         */
+        promotionList.forEach(promotions -> {
+            promotions.setOrderId(mainOrder.getOrderId());
+            submitMapper.insertOrderPromotions(promotions);
+            log.info("【提交订单】>>>>>>>>>>>>>>>>>>>>>>>>>>新增订单促销活动(insert[cm_promotions_order])id:" + promotions.getId());
+        });
 
+        /*
+         * 保存订单发票信息
+         */
+        if (hasInvoiceFlag) {
+            // 开发票才保存
+            invoice.setOrderId(mainOrder.getOrderId());
+            // 一个订单只有一条发票信息,删除老的订单增值税信息
+            submitMapper.deleteOrderInvoiceByOrderId(mainOrder.getOrderId());
+            //  保存 订单发票信息
+            submitMapper.insertOrderInvoice(invoice);
+            log.info("【提交订单】>>>>>>>>>>>>>>>>>>>>>>>>>>保存订单发票信息(insert[bp_order_invoice])orderId:" + mainOrder.getOrderId());
 
-//            userDao.updateMoney(user.getUserMoney(), user.getAbleUserMoney(), user.getUserID());
-//
-//
-//
-//            log.info(">>>>>更新余额抵扣:[userMoney:" + user.getUserMoney() + "] ,ableUserMoney:" + user.getAbleUserMoney());
-//            // 支付时间
-//            mainOrder.setPayTime(curDateStr);
+        }
 
+        /*
+         * 整理 子订单信息
+         */
+        // 收集子订单供应商ID字符串
+        String shopOrderIds = "";
+        for (Object infoObject: orderInfo) {
+            JSONObject shopInfo = (JSONObject) infoObject;
+            Integer shopId = (Integer) shopInfo.get("shopId");
+            String shopNote = (String) shopInfo.get("note");
+            // 初始化子订单信息
+            ShopOrderPo shopOrder = new ShopOrderPo();
+            shopOrder.setShopId(shopId);
+            shopOrder.setNote(shopNote);
+            shopOrder.setOrderId(mainOrder.getOrderId());
+            shopOrder.setOrderNo(mainOrder.getOrderNo());
+            shopOrder.setClubId(mainOrder.getClubId());
+            // 子订单设值并 保存
+            //saveShopOrder(shopOrder, orderProductList, promotionList);
+            // 记录子订单编号
+            shopOrderIds = (StringUtils.isEmpty(shopOrderIds) ? ""+shopOrder.getShopOrderId() : ","+shopOrder.getShopOrderId());
+            // 设置订单商品订单号
+//            for (ProductBo orderProduct : orderProductList) {
+//                if (shopId.equals(orderProduct.getShopId())) {
+//                    orderProduct.setShopOrderId(shopOrder.getShopOrderId());
+//                    orderProduct.setShopOrderNo(shopOrder.getShopOrderNo());
+//                    orderProduct.setOrderId(mainOrder.getOrderId());
+//                    orderProduct.setOrderNo(mainOrder.getOrderNo());
+//                    if (null != orderProduct.getOrderPromotionsId()) {
+//                        promotionList.forEach(promotions -> {
+//                            if (orderProduct.getOrderPromotionsId().equals(promotions.getPromotionsId())){
+//                                orderProduct.setOrderPromotionsId(promotions.getId());
+//                            }
+//                        });
+//                    }
+//                }
+//            }
 
+        }
 
+        /*
+         * 设置邮费子订单
+         */
+        if (1 == mainOrder.getFreePostFlag()) {
+            //Integer postageOrderId = setPostageOrder(mainOrder, shopOrderIds, orderInfo.size());
+            // 记录子订单编号
+            //shopOrderIds = (StringUtils.isEmpty(shopOrderIds) ? ""+postageOrderId : ","+postageOrderId);
+        }
 
+        /*
+         * 更新主订单的子订单Id信息,如:1000,1002
+         */
+        if (StringUtils.isNotEmpty(shopOrderIds)) {
+            mainOrder.setShopOrderIds(shopOrderIds);
+            //submitMapper.updateShopOrderIds(shopOrderIds, mainOrder.getOrderId());
+        } else {
+            // 设置手动回滚事务
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            return ResponseJson.error("生成子订单异常!", null);
         }
-//        // 余额支付金额
-//        mainOrder.setBalancePayFee(balancePayFee);
-//        // 实际支付金额(商品金额+运费-余额抵扣)
-//        mainOrder.setPayableAmount(payableAmount);
-//        // 售后条款
-//        if (payInfo.get("clauseId") != null) {
-//            ClauseVo clauseById = sellerDao.findClauseById(Integer.parseInt(payInfo.get("clauseId").toString()));
-//            if (clauseById != null) {
-//                mainOrder.setClauseID(Long.parseLong(payInfo.get("clauseId").toString()));
-//                mainOrder.setClauseName(clauseById.getName());
-//            } else {
-//                mainOrder.setClauseID(1L);
-//                mainOrder.setClauseName("无条款");
-//            }
-//        } else {
-//            mainOrder.setClauseID(1L);
-//            mainOrder.setClauseName("无条款");
-//        }
-//        // 是否返佣订单
-//        mainOrder.setRebateFlag(payInfo.get("rebateFlag") == null ? "0" : payInfo.get("rebateFlag").toString());
-//        // 判断前端传入orderShouldPayFee订单应付金额,和后台计算应付金额对比
-//        BigDecimal orderShouldPayFee = new BigDecimal(payInfo.get("orderShouldPayFee").toString());
-//        double v = MathUtil.sub(payableAmount, orderShouldPayFee).doubleValue();
-//        log.info(">>>>>payableAmount:" + payableAmount + " ,orderShouldPayFee:" + orderShouldPayFee);
-//        // 考虑前端计算不精确
-//        if (v < -0.1d || v > 0.1d) {
-//            // 设置手动回滚事务
-//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-//            return JsonModel.newInstance().error(-1, "订单付款金额异常");
-//        }
-//
-//        /*
-//         * 保存主订单数据
-//         */
-//        orderSubmitDao.insertSelective(mainOrder);
-//        log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>新增主订单(insert[cm_order])orderId:" + mainOrder.getOrderID());
-//
-//        //设置订单促销订单号,并保存
-//        promotionsList.forEach(promotions -> {
-//            promotions.setOrderId(mainOrder.getOrderID().intValue());
-//            orderSubmitDao.insertOrderPromotions(promotions);
-//            log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>新增订单促销活动(insert[cm_promotions_order])id:" + promotions.getId());
-//        });
-//
-//        /*
-//         * 设置订单商品订单号
-//         */
-//        for (OrderProductVo orderProduct : orderProductList) {
-//            orderProduct.setOrderID(mainOrder.getOrderID());
-//            orderProduct.setOrderNo(mainOrder.getOrderNo());
-//            PromotionsVo promotions = promotionsDao.getPromotionsByProductId(orderProduct.getProductID());
-//            if (promotions != null) {
-//                PromotionsVo promotionsVo = promotionsDao.findOrderPromotions(orderProduct.getOrderID(), promotions.getId());
-//                if (promotionsVo != null) {
-//                    orderProduct.setOrderPromotionsId(promotionsVo.getId());
-//                }
-//
-//            }
-//        }
-//
-//        /*
-//         * 整理 子订单信息
-//         */
-//        // 收集子订单供应商ID字符串
-//        String shopOrderIds = "";
-//        for (Map<String, Object> shopOrderInfo : orderInfo) {
-//            Integer shopId = (Integer) shopOrderInfo.get("shopId");
-//            String shopNote = (String) shopOrderInfo.get("note");
-//            // 初始化子订单信息
-//            ShopOrderVo shopOrder = saveShopOrder(mainOrder, orderProductList, shopId, shopNote);
-//            // 保存子订单号
-//            shopOrderIds += (("".equals(shopOrderIds) ? "" : ",") + shopOrder.getShopOrderID());
-//            // 设置订单商品子订单号
-//            for (OrderProductVo orderProduct : orderProductList) {
-//                if (shopId.longValue() == orderProduct.getShopID()) {
-//                    orderProduct.setShopOrderID(shopOrder.getShopOrderID());
-//                    orderProduct.setShopOrderNo(shopOrder.getShopOrderNo());
-//                }
-//            }
-//        }
+
+
+
+
+
 //        /*
 //         * 保存订单商品
 //         */
@@ -844,16 +881,7 @@ public class SubmitServiceImpl implements SubmitService {
 //            });
 //        }
 //
-//        /*
-//         * 设置邮费子订单
-//         */
-//        if ("1".equals(mainOrder.getFreePostFlag())) {
-//            shopOrderIds = setPostFeeShopOrder(mainOrder, shopOrderIds, orderInfo.size());
-//        }
-//
-//        // 更新主订单信息, 子订单ID:1000,1002
-//        mainOrder.setShopOrderIDs(shopOrderIds);
-//        orderSubmitDao.updateSelective(mainOrder);
+
 //
 //        /*
 //         * 保存 订单用户地址
@@ -861,7 +889,7 @@ public class SubmitServiceImpl implements SubmitService {
 //        if (null != address) {
 //            //保存地址信息
 //            UserinfoVo userInfo = new UserinfoVo();
-//            userInfo.setOrderId(mainOrder.getOrderID());
+//            userInfo.setOrderId(mainOrder.getOrderId());
 //            userInfo.setClubId(user.getClubID().longValue());
 //            userInfo.setUserId(user.getUserID().longValue());
 //            userInfo.setName(user.getName() == null ? user.getUserName() : user.getName());
@@ -875,7 +903,7 @@ public class SubmitServiceImpl implements SubmitService {
 //            userInfo.setTown(address.getTown());
 //            userInfo.setAddress(address.getAddress());
 //            orderSubmitDao.insertUserInfo(userInfo);
-//            log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>保存订单用户地址(insert[bp_order_userinfo])orderId:" + mainOrder.getOrderID());
+//            log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>保存订单用户地址(insert[bp_order_userinfo])orderId:" + mainOrder.getOrderId());
 //        } else {
 //            //设置手动回滚事务
 //            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -887,31 +915,14 @@ public class SubmitServiceImpl implements SubmitService {
 //         */
 //        if (1 == balancePayFlag && MathUtil.compare(balancePayFee, 0) > 0) {
 //            // 余额支付标识,0不使用,1使用
-//            saveBalanceRecord(balancePayFee, mainOrder.getOrderID().intValue(), user.getUserID());
+//            saveBalanceRecord(balancePayFee, mainOrder.getOrderId().intValue(), user.getUserID());
 //            //保存余额到收款记录
 //            if (cartType != 3) {
-//                saveDiscernReceipt(balancePayFee, mainOrder.getOrderID().intValue());
+//                saveDiscernReceipt(balancePayFee, mainOrder.getOrderId().intValue());
 //            }
 //        }
 //
-//        /*
-//         * 保存 订单发票信息
-//         */
-//        if (invoiceFlag) {
-//            // 开发票才保存
-//            invoice.setOrderId(mainOrder.getOrderID());
-//            // 查询是否存在老的增值税信息
-//            OrderInvoiceVo userInvoice = orderDao.getOrderInvoice(mainOrder.getOrderID().intValue());
-//            if (null != userInvoice) {
-//                // 更新 发票信息
-//                orderSubmitDao.updateOrderInvoice(invoice);
-//                log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>更新发票信息(update[bp_order_invoice])orderId:" + mainOrder.getOrderID());
-//            } else {
-//                //  保存 发票信息
-//                orderSubmitDao.insertOrderInvoice(invoice);
-//                log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>新增发票信息(insert[bp_order_invoice])orderId:" + mainOrder.getOrderID());
-//            }
-//        }
+
 //
 //        /*
 //         * pc商城提交订单,保存更新用户增值税发票
@@ -934,7 +945,7 @@ public class SubmitServiceImpl implements SubmitService {
 //        if (userBeans > 0) {
 //            UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
 //            beansHistory.setUserId(user.getUserID());
-//            beansHistory.setOrderId(mainOrder.getOrderID().intValue());
+//            beansHistory.setOrderId(mainOrder.getOrderId().intValue());
 //            beansHistory.setBeansType(10);
 //            beansHistory.setType(2);
 //            beansHistory.setNum(userBeans);
@@ -950,9 +961,9 @@ public class SubmitServiceImpl implements SubmitService {
 //         * 构造返回参数
 //         */
 //        Map<String, String> info = new HashMap<>();
-//        info.put("orderID", String.valueOf(mainOrder.getOrderID()));
+//        info.put("orderID", String.valueOf(mainOrder.getOrderId()));
 //        info.put("orderNo", String.valueOf(mainOrder.getOrderNo()));
-//        info.put("orderMark", "#" + mainOrder.getOrderID() + "#");
+//        info.put("orderMark", "#" + mainOrder.getOrderId() + "#");
 //        //应付订单金额
 //        info.put("payTotalFee", String.valueOf(mainOrder.getPayTotalFee()));
 //        //真实需要付款金额
@@ -960,7 +971,7 @@ public class SubmitServiceImpl implements SubmitService {
 //
 //        //下单推送
 //        if (org.apache.commons.lang.StringUtils.isNotBlank(user.getBindMobile())) {
-//            String shortLink = orderPushService.getShortLink(8, 3, domain + "/user/mainOrder/detail.html?orderId=" + mainOrder.getOrderID());
+//            String shortLink = orderPushService.getShortLink(8, 3, domain + "/user/mainOrder/detail.html?orderId=" + mainOrder.getOrderId());
 //            String name = productName.toString();
 //            if (name.length() > 10) {
 //                name = name.substring(0, 10);
@@ -969,7 +980,7 @@ public class SubmitServiceImpl implements SubmitService {
 //                    "您可关注采美公众号或者访问采美微信小程序和网站查看并支付订单。平台公众号:微信搜索“采美365网”; 微信小程序:微信搜索“采美采购商城”;网址:www.caimei365.com/t/" + shortLink;
 //            boolean sendSms = orderPushService.getSendSms(3, user.getBindMobile(), content);
 //            if (!sendSms) {
-//                log.info("下单推送失败,orderId>>>>" + mainOrder.getOrderID());
+//                log.info("下单推送失败,orderId>>>>" + mainOrder.getOrderId());
 //            }
 //        }
 //

+ 41 - 9
src/main/resources/mapper/SubmitMapper.xml

@@ -1,12 +1,43 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.order.mapper.SubmitMapper">
+    <insert id="insertMainOrder" keyColumn="orderID" keyProperty="orderId" parameterType="com.caimei365.order.model.po.OrderPo" useGeneratedKeys="true">
+        INSERT INTO cm_order (orderSource, orderNo, userID, clubID, buyUserID, orderTime, updateDate, delFlag,
+                              userBeans, orderType, orderSubmitType, confirmFlag, onlinePayFlag, splitFlag, payFlag,
+                              receiptStatus, payStatus, zeroCostFlag, sendOutStatus, refundType, affirmPaymentFlag,
+                              productCount, presentCount, promotionalGiftsCount, hasActProduct, promotionFullReduction,
+                              secondHandOrderFlag, invoiceFlag, freePostFlag, freight, productTotalFee, orderTotalFee,
+                              payTotalFee, payableAmount, balancePayFee, status, confirmTime, payTime, rebateFlag,
+                              clauseID, clauseName)
+        VALUES (#{orderSource},#{orderNo},#{userId},#{clubId},#{buyUserId},#{orderTime},#{updateDate},#{delFlag},
+                #{userBeans},#{orderType},#{orderSubmitType},#{confirmFlag},#{onlinePayFlag},#{splitFlag},#{payFlag},
+                #{receiptStatus},#{payStatus},#{zeroCostFlag},#{sendOutStatus},#{refundType},#{affirmPaymentFlag},
+                #{productCount},#{presentCount},#{promotionalGiftsCount},#{hasActProduct},#{promotionFullReduction},
+                #{secondHandOrderFlag},#{invoiceFlag},#{freePostFlag},#{freight},#{productTotalFee},#{orderTotalFee},
+                #{payTotalFee},#{payableAmount},#{balancePayFee},#{status},#{confirmTime},#{payTime},#{rebateFlag},
+                #{clauseId},#{clauseName})
+    </insert>
+    <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})
+    </insert>
+    <insert id="insertOrderInvoice" keyColumn="id" keyProperty="id" parameterType="com.caimei365.order.model.po.InvoicePo" useGeneratedKeys="true">
+        INSERT INTO bp_order_invoice (orderId, invoiceTitle, corporationTaxNum, registeredAddress, registeredPhone, bankAccountNo, openBank)
+        VALUES (#{orderId}, #{invoiceTitle}, #{corporationTaxNum}, #{registeredAddress}, #{registeredPhone}, #{bankAccountNo}, #{openBank})
+    </insert>
+    <update id="updateUserMoney">
+        UPDATE USER SET userMoney = #{userMoney}, ableUserMoney = #{ableUserMoney}
+        WHERE userID = #{userId}
+    </update>
+    <delete id="deleteOrderInvoiceByOrderId">
+        DELETE FROM bp_order_invoice WHERE orderId = #{orderId}
+    </delete>
     <select id="getOperationIdByUnionId" resultType="java.lang.Integer">
         SELECT `id` FROM cm_mall_operation_user
         WHERE unionId = #{unionId} AND userID = #{userId} AND delFlag = '0'
     </select>
     <select id="getServiceProviderUserId" resultType="java.lang.Integer">
-        select userID from serviceprovider where serviceProviderID = #{serviceProviderId}
+        SELECT userID FROM serviceprovider WHERE serviceProviderID = #{serviceProviderId}
     </select>
     <select id="getOrderUserBoById" resultType="com.caimei365.order.model.bo.OrderUserBo">
         SELECT
@@ -24,7 +55,7 @@
         SELECT `name` FROM shop WHERE shopID = #{shopId}
     </select>
     <select id="getProductDetails" resultType="com.caimei365.order.model.bo.ProductBo">
-        select
+        SELECT
             p.productID AS productId,
             p.shopID AS shopId,
             p.`name` AS `name`,
@@ -38,13 +69,14 @@
             p.includedTax,
             p.invoiceType,
             p.taxPoint AS taxRate,
-        p.unit AS productUnit,
-        p.normalPrice,
-        p.supplierTaxPoint AS shopTaxRate,
-
-
-        from product p
-        where p.productId = #{productId}
+            p.unit AS productUnit,
+            p.normalPrice,
+            p.supplierTaxPoint AS shopTaxRate
+        FROM product p
+        WHERE p.productId = #{productId}
+    </select>
+    <select id="getClauseNameById" resultType="java.lang.String">
+        SELECT `name` FROM bp_clause WHERE id = #{clauseId}
     </select>