Jelajahi Sumber

提交订单

plf 4 tahun lalu
induk
melakukan
db20ac2963

+ 113 - 7
src/main/java/com/caimei/controller/OrderSubmitApi.java

@@ -1,17 +1,16 @@
 package com.caimei.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.caimei.model.ResponseJson;
 import com.caimei.service.OrderSubmitService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.*;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -51,4 +50,111 @@ public class OrderSubmitApi {
     public ResponseJson<Map<String, Object>> orderConfirm(String productIds, Integer count, Integer userId) {
         return orderSubmitService.orderConfirm(productIds, count, userId);
     }
+
+    /**
+     * 提交订单
+     *
+     * @param params 参数格式:{
+     *               *   "cartType":3,               //购买类型:(1购物车提交[对应表cm_cart],2直接购买提交, 3协销下单)
+     *               *   "orderSource": 2,           //订单来源:1WWW、2CRM、3APP[历史数据]、4客服[适用后台下单]、5外单[适用后台下单]、6小程序[采美,星范等]
+     *               *   "serviceProviderId": 1378,  //协销ID(小程序忽略)
+     *               *   "clubUserId": 10708,        //机构用户ID
+     *               *   "addressId": 2732,          //地址ID
+     *               *   "orderInfo": [
+     *               *                   { "shopId":1001,    // 供应商ID
+     *               *                     "note":备注,
+     *               *                     "productInfo":[   // 商品id,数量,赠品数,商品类型
+     *               *                         {"productId": 2789, "productNum": 1, "presentNum":0,"productType":2},
+     *               *                         {"productId": 2789, "productNum": 1, "presentNum":0,"productType":0}
+     *               *                      ]
+     *               *                   },
+     *               *                   {多个供应商商品数据结构同上}
+     *               *                ]
+     *               *
+     *               *   "payInfo": {               // 订单信息
+     *               *       "orderShouldPayFee": 609.11,
+     *               *       "balancePayFlag": 0,
+     *               *       "clauseId": "2",
+     *               *       "freight": "15",
+     *               *       "freePostFlag": 1,
+     *               *       "rebateFlag":0
+     *               *   },
+     *               *   "orderInvoice": {}// 发票信息: {"type": 0},// 不开发票
+     *               *                   {
+     *               *                       "type": 1,             // 普通发票
+     *               *                       "invoiceContent": "明细 ",
+     *               *                       "invoiceTitleType": 1,
+     *               *                       "corporationTaxNum": "XXX4156465465",
+     *               *                       "invoiceTitle": "企业抬头"
+     *               *                   },
+     *               *                   {
+     *               *                       "type": 2,             // 增值税发票
+     *               *                       "invoiceTitle": "单位名称",
+     *               *                       "corporationTaxNum": "NSRSBM97897",
+     *               *                       "registeredAddress": "注册地址",
+     *               *                       "registeredPhone": "15814011616",
+     *               *                       "openBank": "开户银行",
+     *               *                       "bankAccountNo": "987987465465464"
+     *               *                   }
+     *               *}
+     * @return code: -1=(用户账户异常,数据异常,操作异常等),
+     * 1提交成功(支付完成),
+     * 2提交成功(未支付),
+     * code为1和2的情况下出现 data{orderNo:订单号,orderID:订单ID,payTotalFee:订单金额,orderMark:订单标识}
+     */
+    @ApiOperation("提交订单")
+    @PostMapping("/submit")
+    public ResponseJson<Map<String, String>> orderSubmit(@RequestBody String params) {
+        if (StringUtils.isBlank(params)) {
+            return ResponseJson.error("数据异常", null);
+        }
+        Integer cartType = null;
+        String orderSource = null;
+        Integer clubUserId = null;
+        Integer addressId = null;
+        List<Map<String, Object>> orderInfo = null;
+        Map<String, Object> payInfo = null;
+        Map<String, Object> orderInvoice = null;
+        // 校验传入参数的正确性
+        try {
+            JSONObject paramsMap = JSON.parseObject(params);
+            if (null == paramsMap) {
+                return ResponseJson.error("数据异常,参数不能为空", null);
+            }
+            orderSource = paramsMap.getString("orderSource");
+            if (StringUtils.isEmpty(orderSource)) {
+                return ResponseJson.error("订单来源异常", null);
+            }
+            cartType = paramsMap.getInteger("cartType");
+            if (null == cartType) {
+                return ResponseJson.error("购买类型异常", null);
+            }
+            clubUserId = paramsMap.getInteger("clubUserId");
+            if (null == clubUserId) {
+                return ResponseJson.error("机构用户Id异常", null);
+            }
+            addressId = paramsMap.getInteger("addressId");
+            if (null == addressId) {
+                return ResponseJson.error("地址数据异常", null);
+            }
+            orderInfo = (List<Map<String, Object>>) paramsMap.get("orderInfo");
+            if (null == orderInfo) {
+                return ResponseJson.error("订单商品数据异常", null);
+            }
+            payInfo = paramsMap.getJSONObject("payInfo");
+            if (null == payInfo) {
+                return ResponseJson.error("订单金额数据异常", null);
+            }
+            orderInvoice = paramsMap.getJSONObject("orderInvoice");
+            if (null == orderInvoice) {
+                return ResponseJson.error("订单发票数据异常", null);
+            }
+        } catch (Exception e) {
+            log.error("<<<<< 系统异常 >>>>>" + e);
+            return ResponseJson.error("数据异常", null);
+        }
+
+        log.info("****** 提交订单参数:【机构自己下单】:" + params);
+        return orderSubmitService.orderSubmit(cartType, orderSource, clubUserId, addressId, orderInfo, payInfo, orderInvoice);
+    }
 }

+ 1 - 1
src/main/java/com/caimei/controller/ShoppingCartApi.java

@@ -46,7 +46,7 @@ public class ShoppingCartApi {
      */
     @ApiOperation("统计购物车数量")
     @ApiImplicitParam(name = "userId", value = "机构用户id", required = true)
-    @PostMapping("/quantity")
+    @GetMapping("/quantity")
     public ResponseJson<Integer> getCartQuantity(Integer userId) {
         if (userId == null) {
             return ResponseJson.error("参数异常", null);

+ 105 - 1
src/main/java/com/caimei/mapper/OrderSubmitMapper.java

@@ -1,6 +1,7 @@
 package com.caimei.mapper;
 
-import com.caimei.model.po.CmUserInvoiceInfoPo;
+import com.caimei.model.po.*;
+import com.caimei.model.po.AddressPo;
 import com.caimei.model.vo.CartProductVo;
 import com.caimei.model.vo.ShopVo;
 import org.apache.ibatis.annotations.Mapper;
@@ -56,4 +57,107 @@ public interface OrderSubmitMapper {
      * @return
      */
     ShopVo getShop(Integer shopId);
+
+    /**
+     * 查询用户信息
+     *
+     * @param userId
+     * @return
+     */
+    UserPo findUser(Integer userId);
+
+    /**
+     * 保存主订单信息
+     *
+     * @param order
+     */
+    void insertOrder(CmOrderPo order);
+
+    /**
+     * 保存订单促销信息
+     *
+     * @param promotions
+     */
+    void insertOrderPromotions(PromotionsPo promotions);
+
+    /**
+     * 查询订单促销表
+     *
+     * @param orderId
+     * @param promotionsId
+     * @return
+     */
+    PromotionsPo findOrderPromotions(@Param("orderId") Long orderId, @Param("promotionsId") Integer promotionsId);
+
+    /**
+     * 查询子订单编号
+     *
+     * @param orderId
+     * @return
+     */
+    String findMaxShopOrderNo(Long orderId);
+
+    /**
+     * 保存子订单信息
+     *
+     * @param shopOrder
+     */
+    void insertShopOrder(CmShopOrderPo shopOrder);
+
+    /**
+     * 保存订单商品信息
+     *
+     * @param orderProduct
+     */
+    void insertOrderProduct(CmOrderProductPo orderProduct);
+
+    /**
+     * 保存订单阶梯价格信息
+     *
+     * @param ladderPrice
+     */
+    void insertOrderProductLadderPrice(OrderProductLadderPricePo ladderPrice);
+
+    /**
+     * 更新主订单数据
+     *
+     * @param order
+     */
+    void updateOrder(CmOrderPo order);
+
+    /**
+     * 查询订单发票信息
+     *
+     * @param orderId
+     * @return
+     */
+    BpOrderInvoicePo getOrderInvoice(Long orderId);
+
+    /**
+     * 保存订单地址信息
+     *
+     * @param userInfo
+     */
+    void insertUserInfo(BpOrderUserInfoPo userInfo);
+
+    /**
+     * 更新订单发票信息
+     *
+     * @param invoice
+     */
+    void updateOrderInvoice(BpOrderInvoicePo invoice);
+
+    /**
+     * 保存订单发票信息
+     *
+     * @param invoice
+     */
+    void insertOrderInvoice(BpOrderInvoicePo invoice);
+
+    /**
+     * 查询地址信息
+     * @param addressId
+     * @return
+     */
+    AddressPo findByAddressId(Integer addressId);
 }

+ 24 - 4
src/main/java/com/caimei/mapper/ProductMapper.java

@@ -1,9 +1,6 @@
 package com.caimei.mapper;
 
-import com.caimei.model.po.ProductDetailInfoPo;
-import com.caimei.model.po.ProductImagePo;
-import com.caimei.model.po.PromotionsPo;
-import com.caimei.model.po.RelatedParametersPo;
+import com.caimei.model.po.*;
 import com.caimei.model.vo.CartProductVo;
 import com.caimei.model.vo.ClubVo;
 import com.caimei.model.vo.LadderPriceVo;
@@ -96,4 +93,27 @@ public interface ProductMapper {
     String findBrandNameByBrandId(Integer brandId);
 
     List<RelatedParametersPo> findParametersByOriginalId(Integer originalProductId);
+
+    /**
+     * 查询组织商品信息
+     *
+     * @param productId 组织商品id
+     * @return
+     */
+    CmOrganizeProductPo getProduct(Integer productId);
+
+    /**
+     * 查询促销活动信息
+     *
+     * @param promotionsId
+     * @return
+     */
+    PromotionsPo findParameterById(Integer promotionsId);
+
+    /**
+     * 查询采美运费商品
+     *
+     * @return
+     */
+    ProductPo findPostFeeProduct();
 }

+ 8 - 0
src/main/java/com/caimei/mapper/ShoppingCartMapper.java

@@ -88,4 +88,12 @@ public interface ShoppingCartMapper {
      * @return
      */
     List<CartProductVo> findProductGifts(Integer promotionsId);
+
+    /**
+     * 根据用户id商品id删除购物车
+     *
+     * @param userId
+     * @param productId
+     */
+    void deleteCartByProductId(@Param("userId") Integer userId, @Param("productId") Integer productId);
 }

+ 85 - 0
src/main/java/com/caimei/model/po/AddressPo.java

@@ -0,0 +1,85 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * address
+ *
+ * @author
+ */
+@Data
+public class AddressPo implements Serializable {
+    /**
+     * 用户地址ID
+     */
+    private Integer addressId;
+
+    /**
+     * 用户ID
+     */
+    private Integer userId;
+
+    /**
+     * 收货人
+     */
+    private String shouHuoRen;
+
+    /**
+     * 区ID
+     */
+    private Integer townId;
+
+    /**
+     * 地址
+     */
+    private String address;
+
+    /**
+     * 邮编
+     */
+    private String postalCode;
+
+    /**
+     * 电话
+     */
+    private String phone;
+
+    /**
+     * 手机
+     */
+    private String mobile;
+
+    /**
+     * 是否默认收货地址(0 不是默认,1 默认)
+     */
+    private String defaultFlag;
+
+    /**
+     * 市id
+     */
+    private Integer cityId;
+
+    /**
+     * 县id
+     */
+    private Integer provinceId;
+
+    /**
+     * 区名称
+     */
+    private String townName;
+
+    /**
+     * 市名称
+     */
+    private String cityName;
+
+    /**
+     * 县名称
+     */
+    private String provinceName;
+
+    private static final long serialVersionUID = 1L;
+}

+ 70 - 0
src/main/java/com/caimei/model/po/BpOrderInvoicePo.java

@@ -0,0 +1,70 @@
+package com.caimei.model.po;
+
+import java.io.Serializable;
+import lombok.Data;
+
+/**
+ * bp_order_invoice
+ * @author 
+ */
+@Data
+public class BpOrderInvoicePo implements Serializable {
+    private Long id;
+
+    /**
+     * 订单ID
+     */
+    private Long orderId;
+
+    /**
+     * 发票抬头
+     */
+    private String invoiceTitle;
+
+    /**
+     * 发票类型0不开发票 1普通发票 2增值税发票
+     */
+    private Long type;
+
+    /**
+     * 发票类型
+     */
+    private String invoiceType;
+
+    /**
+     * 发票内容
+     */
+    private String invoiceContent;
+
+    /**
+     * 发票抬头类型 0个人  1 企业
+     */
+    private String invoiceTitleType;
+
+    /**
+     * 企业税号
+     */
+    private String corporationTaxNum;
+
+    /**
+     * 注册地址
+     */
+    private String registeredAddress;
+
+    /**
+     * 注册电话
+     */
+    private String registeredPhone;
+
+    /**
+     * 开户银行账户
+     */
+    private String bankAccountNo;
+
+    /**
+     * 开户银行
+     */
+    private String openBank;
+
+    private static final long serialVersionUID = 1L;
+}

+ 76 - 0
src/main/java/com/caimei/model/po/BpOrderUserInfoPo.java

@@ -0,0 +1,76 @@
+package com.caimei.model.po;
+
+import java.io.Serializable;
+
+import lombok.Data;
+
+/**
+ * bp_order_userinfo
+ *
+ * @author
+ */
+@Data
+public class BpOrderUserInfoPo implements Serializable {
+    private Long id;
+
+    /**
+     * 订单ID
+     */
+    private Long orderId;
+
+    private Long clubId;
+
+    private Long userId;
+
+    /**
+     * 买家
+     */
+    private String name;
+
+    /**
+     * 收货人
+     */
+    private String shouHuoRen;
+
+    /**
+     * 手机
+     */
+    private String mobile;
+
+    /**
+     * 电话
+     */
+    private String phone;
+
+    /**
+     * 邮编
+     */
+    private String postalCode;
+
+    /**
+     * 县区ID
+     */
+    private Integer townId;
+
+    /**
+     * 省、直辖市
+     */
+    private String province;
+
+    /**
+     * 市
+     */
+    private String city;
+
+    /**
+     * 县、区
+     */
+    private String town;
+
+    /**
+     * 收货地址
+     */
+    private String address;
+
+    private static final long serialVersionUID = 1L;
+}

+ 317 - 0
src/main/java/com/caimei/model/po/CmOrderPo.java

@@ -0,0 +1,317 @@
+package com.caimei.model.po;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import lombok.Data;
+
+/**
+ * cm_order
+ * @author 
+ */
+@Data
+public class CmOrderPo implements Serializable {
+    /**
+     * orderID
+     */
+    private Long orderID;
+
+    /**
+     * 订单编号(后台:p,网站:W,小程序:x,第三方:T)
+     */
+    private String orderNo;
+
+    /**
+     * 采美组织默认为0,具体对应cm_mall_organize表ID
+     */
+    private Integer organizeID;
+
+    private Long userID;
+
+    /**
+     * 下单人
+     */
+    private Integer buyUserID;
+
+    /**
+     * 子订单ID
+     */
+    private String shopOrderIDs;
+
+    /**
+     * 0:个人自己下单 1:企业自己下单 2:员工帮会所下单 3:协销帮会所下单  4:后台下单 5:采美豆订单【1、5已弃用】
+     */
+    private Integer orderSubmitType;
+
+    /**
+     * 订单类型 0协销订单、 1普通订单 
+     */
+    private Integer orderType;
+
+    /**
+     * 二手商品订单标识  0非二手商品订单、 1二手商品订单 
+     */
+    private String secondHandOrderFlag;
+
+    /**
+     * 确认付款供应商标志,0未确认,1已确认
+     */
+    private String affirmPaymentFlag;
+
+    /**
+     * 是否包含活动商品(受订单未支付自动关闭时间影响)  0 否 1 是
+     */
+    private String hasActProduct;
+
+    /**
+     * 订单自动关闭时间点单位毫秒(v5.0版本已废弃)
+     */
+    private BigDecimal autoCloseTimeMills;
+
+    /**
+     * 0待确认,11待收待发,12待收部发,13待收全发,21部收待发,22部收部发,23部收全发,31已收待发,32已收部发,33已收全发,4交易完成,5订单完成,6已关闭,7交易全退
+     */
+    private String status;
+
+    /**
+     * (收款买家)收款状态:1待收款、2部分收款、3已收款
+     */
+    private String receiptStatus;
+
+    /**
+     * (付款供应商)付款状态:1待付款、2部分付款、3已付款
+     */
+    private String payStatus;
+
+    /**
+     * 发货状态:1待发货、2部分发货、3已发货
+     */
+    private String sendOutStatus;
+
+    /**
+     * 退货退款类型:1部分退、2全部退
+     */
+    private String refundType;
+
+    /**
+     * 已支付成功次数统计(适用线上多笔付款用来确认当前是哪一笔)
+     */
+    private Integer paySuccessCounter;
+
+    /**
+     * 是否已支付 未支付0 已支付1
+     */
+    private String payFlag;
+
+    /**
+     * 是否能走线上支付 0可以 1不可以 只能线下
+     */
+    private String onlinePayFlag;
+
+    /**
+     * 商品总金额 (商品单价乘以数量,再加上税费)
+     */
+    private BigDecimal productTotalFee;
+
+    /**
+     * 小计金额 (商品折后单价乘以数量,再加上税费)
+     */
+    private BigDecimal orderTotalFee;
+
+    /**
+     * 订单总额(小计金额减去经理折扣后,再加上运费)
+     */
+    private BigDecimal payTotalFee;
+
+    /**
+     * 真实支付金额(订单总额减去抵扣的账户余额)
+     */
+    private BigDecimal payableAmount;
+
+    /**
+     * 余额支付金额
+     */
+    private BigDecimal balancePayFee;
+
+    /**
+     * 总优惠 自助下单活动优惠 协销下单price-折后单价
+     */
+    private BigDecimal preferential;
+
+    /**
+     * 经理折扣
+     */
+    private BigDecimal discountFee;
+
+    /**
+     * 促销满减优惠
+     */
+    private BigDecimal promotionFullReduction;
+
+    private Long spID;
+
+    private Long mainSpID;
+
+    /**
+     * 订单备注
+     */
+    private String note;
+
+    /**
+     * 会所ID
+     */
+    private Long clubID;
+
+    /**
+     * 会所扫描确认时间
+     */
+    private String clubScanTime;
+
+    /**
+     * 支付方式,(协销订单可能会存在多种进账方式用,隔开)(v5.0版本已废弃)
+     */
+    private String payWay;
+
+    /**
+     * 订单来源:1WWW、2CRM、3APP[历史数据]、4客服、5外单、6小程序[采美,星范等]
+     */
+    private String orderSource;
+
+    /**
+     * 订单取消时间
+     */
+    private String closeTime;
+
+    /**
+     * 订单确认时间
+     */
+    private String confirmTime;
+
+    /**
+     * 订单支付时间
+     */
+    private String payTime;
+
+    /**
+     * 订单提交时间
+     */
+    private String orderTime;
+
+    /**
+     * 购买总数
+     */
+    private Integer productCount;
+
+    /**
+     * 赠送总数  不计算价格
+     */
+    private Integer presentCount;
+
+    /**
+     * 促销赠品总数
+     */
+    private Integer promotionalGiftsCount;
+
+    /**
+     * 库分期免息状态 0、免息 1、不免息[V5.0.0版本已废弃]
+     */
+    private String cooFreeFlag;
+
+    /**
+     * 库分期分期费率[V5.0.0版本已废弃]
+     */
+    private Integer cooFreeRate;
+
+    /**
+     * 库分期免息金额[V5.0.0版本已废弃]
+     */
+    private BigDecimal cooFreeAmount;
+
+    /**
+     * 是否开发票 没开发票 0 开个人发票 1 开企业发票2
+     */
+    private String invoiceFlag;
+
+    /**
+     * 订单确认标志,0否,1后台确认,2买家确认(适用协销订单并且1或2都算已确认订单,主动订单默认1为确认)
+     */
+    private String confirmFlag;
+
+    /**
+     * 条款ID
+     */
+    private Long clauseID;
+
+    /**
+     * 条款内容
+     */
+    private String clauseContent;
+
+    /**
+     * 条款名称
+     */
+    private String clauseName;
+
+    /**
+     * 更新时间
+     */
+    private String updateDate;
+
+    /**
+     * 免邮标志  运费:-1到付,0包邮,1需要运费,-2仪器到付其它包邮
+     */
+    private String freePostFlag;
+
+    /**
+     * -1到付,0包邮,大于0具体金额,-2仪器到付其它包邮(且运费已使用商品形式存储)
+     */
+    private BigDecimal freight;
+
+    /**
+     * 订单状态 0 有效  其它无效
+     */
+    private String delFlag;
+
+    /**
+     * 包邮券ID  保留字段
+     */
+    private Integer freePostageTicketID;
+
+    /**
+     * 订单是否可拆分   1可拆分 0不可拆分
+     */
+    private String splitFlag;
+
+    /**
+     * 订单取消原因
+     */
+    private String closeReason;
+
+    /**
+     * 邮费订单标识(适用于补录邮费订单) 1是邮费订单  0不是邮费订单
+     */
+    private String postageOrderFlag;
+
+    /**
+     * 第三方订单编号(绑定第三方订单关系),适用第三方发起订单
+     */
+    private String thirdPartyOrderNo;
+
+    /**
+     * 订单是否同步发货物流给第三方,0未同步,1已同步
+     */
+    private String synchronizeFlag;
+
+    private Boolean authority;
+
+    /**
+     * 返佣订单标识,0非返佣订单,1返佣订单
+     */
+    private String rebateFlag;
+
+    /**
+     * 订单0成本标识:订单不是0成本,1订单0成本(订单中所有商品成本为0)
+     */
+    private Integer zeroCostFlag;
+
+    private static final long serialVersionUID = 1L;
+}

+ 335 - 0
src/main/java/com/caimei/model/po/CmOrderProductPo.java

@@ -0,0 +1,335 @@
+package com.caimei.model.po;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import lombok.Data;
+
+/**
+ * cm_order_product
+ * @author 
+ */
+@Data
+public class CmOrderProductPo implements Serializable {
+    private Integer orderProductID;
+
+    /**
+     * 主订单编号
+     */
+    private String orderNo;
+
+    /**
+     * 主订单ID
+     */
+    private Long orderID;
+
+    /**
+     * 订单Id
+     */
+    private Integer shopOrderID;
+
+    /**
+     * 子订单编号
+     */
+    private String shopOrderNo;
+
+    /**
+     * 供应商ID
+     */
+    private Long shopID;
+
+    /**
+     * 商品Id(采美商城和组织小程序都保存product表ID)
+     */
+    private Integer productID;
+
+    /**
+     * 组织的商品Id,关联cm_mall_organize_products表ID[适用于组织订单]
+     */
+    private Integer organizeProductID;
+
+    /**
+     * 采美组织默认为null,具体对应cm_mall_organize表ID[适用于组织订单]
+     */
+    private Integer organizeID;
+
+    /**
+     * 购买数量
+     */
+    private Integer num;
+
+    /**
+     * 赠送数量
+     */
+    private Integer presentNum;
+
+    /**
+     * 出库类型 0 采美出库  1 供应商出库
+     */
+    private String outStoreType;
+
+    /**
+     * skuId
+     */
+    private Integer skuID;
+
+    /**
+     * sku属性
+     */
+    private String props;
+
+    /**
+     * 属性名
+     */
+    private String propName;
+
+    /**
+     * 商品编号
+     */
+    private String productNo;
+
+    /**
+     * 商品价格(协销 市场价 普通 购买价)
+     */
+    private BigDecimal price;
+
+    /**
+     * 市场价 = 商品表市场价
+     */
+    private BigDecimal normalPrice;
+
+    /**
+     * 购买时商品成本价
+     */
+    private BigDecimal costPrice;
+
+    /**
+     * 记录普通用户购买时价格  活动价优先
+     */
+    private BigDecimal price0;
+
+    /**
+     * 记录会员用户购买时价格  活动价优先
+     */
+    private BigDecimal price1;
+
+    /**
+     * 总价  = price X num
+     */
+    private BigDecimal totalAmount;
+
+    /**
+     * 总价  = discountPrice X num + totalAddedValueTax
+     */
+    private BigDecimal totalFee;
+
+    /**
+     * 应付金额 = totalFee - discountFee
+     */
+    private BigDecimal shouldPayFee;
+
+    /**
+     * 折扣比例
+     */
+    private BigDecimal discount;
+
+    /**
+     * 折后单价
+     */
+    private BigDecimal discountPrice;
+
+    /**
+     * 是否含税 0不含税 1含税 2未知
+     */
+    private String includedTax;
+
+    /**
+     * 发票类型 1增值税专用发票 2增值税普通发票 3不开发票
+     */
+    private String invoiceType;
+
+    /**
+     * 启用阶梯价格标识 0否 1是
+     */
+    private String ladderPriceFlag;
+
+    /**
+     * 后台设置该商品税率
+     */
+    private BigDecimal taxRate;
+
+    /**
+     * 供应商税率:增值专用发票默认13%,增值税普通发票6%取值范围[0-100]
+     */
+    private BigDecimal supplierTaxRate;
+
+    /**
+     * 单个税费=税率X折后单价 
+     */
+    private BigDecimal addedValueTax;
+
+    /**
+     * 总税费=单个税费X购买数量
+     */
+    private BigDecimal totalAddedValueTax;
+
+    /**
+     * 总税费(应付税费)默认值和应收税费一样
+     */
+    private BigDecimal shouldPayTotalTax;
+
+    /**
+     * 单个付供应商税费
+     */
+    private BigDecimal singleShouldPayTotalTax;
+
+    /**
+     * 商品费
+     */
+    private BigDecimal shopProductAmount;
+
+    /**
+     * 该商品总的应付供应商金额
+     */
+    private BigDecimal shopFee;
+
+    /**
+     * 该商品总的应付第三方金额
+     */
+    private BigDecimal otherFee;
+
+    /**
+     * 该商品总的应付采美金额 (受赠品影响)
+     */
+    private BigDecimal cmFee;
+
+    /**
+     * 后台设置的单个应付供应商金额
+     */
+    private BigDecimal singleShopFee;
+
+    /**
+     * 后台设置单个应付第三方金额
+     */
+    private BigDecimal singleOtherFee;
+
+    /**
+     * 后台计算的单个应付采美金额
+     */
+    private BigDecimal singleCmFee;
+
+    /**
+     * 订单商品状态
+     */
+    private String status;
+
+    /**
+     * 是否已评论:1是,空或0未评论(V5.0.0版本后已废弃--)
+     */
+    private String commentFlag;
+
+    /**
+     * 获取到的总采美豆值
+     */
+    private BigDecimal totalBeans;
+
+    /**
+     * 使用余额金额
+     */
+    private Double useBalanceAmount;
+
+    /**
+     * 使用采美豆数量
+     */
+    private Integer useBeanAmount;
+
+    /**
+     * 未出库数量
+     */
+    private Integer notOutStore;
+
+    /**
+     * 当前采美豆专区价格(采美豆)
+     */
+    private Integer cmbeanPrice;
+
+    /**
+     * 下单时商品购买价格类型快照 0 机构价,1活动价 ,2阶梯价
+     */
+    private String isActProduct;
+
+    /**
+     * 是否是赠品 0 不是 1 是
+     */
+    private String isGiftProduct;
+
+    /**
+     * 活动信息 已享受满XX减XX 之类
+     */
+    private String productActInfo;
+
+    /**
+     * 订单商品再次购买标识 0否 1是
+     */
+    private String buyAgainFlag;
+
+    /**
+     * 订单商品供应商确认标志 0否 1是
+     */
+    private String confirmProductFlag;
+
+    /**
+     * 支付状态 0 未进账 1 待财务审核 2 已进账(适用协销的单笔线下进账和自助订单线下或异常进账)
+     */
+    private String payStatus;
+
+    /**
+     * 供应商名称
+     */
+    private String shopName;
+
+    /**
+     * 商品名称
+     */
+    private String name;
+
+    /**
+     * 商品单位
+     */
+    private String productUnit;
+
+    private String productImage;
+
+    /**
+     * 活动类型 1000 热卖 1001 团购 1003 满减 1004满赠 1005 买赠
+     */
+    private String actType;
+
+    /**
+     * 活动优惠  类似满减优惠金额
+     */
+    private BigDecimal actPreferential;
+
+    /**
+     * 商品类型(0正常商品,1协商赠品,2促销赠品)
+     */
+    private String productType;
+
+    /**
+     * 订单促销id
+     */
+    private Integer orderPromotionsId;
+
+    /**
+     * 优惠 (price - discountPrice) * num 
+     */
+    private BigDecimal preferential;
+
+    /**
+     * 协销订单:经理折扣(平摊到每个商品上,  按照每种商品的总价占订单总价的比例来均分);普通订单 无
+     */
+    private BigDecimal discountFee;
+
+    private Integer cancelNum;
+
+    private static final long serialVersionUID = 1L;
+}

+ 134 - 0
src/main/java/com/caimei/model/po/CmOrganizeProductPo.java

@@ -0,0 +1,134 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * cm_organize_product
+ *
+ * @author
+ */
+@Data
+public class CmOrganizeProductPo implements Serializable {
+    private Integer id;
+
+    /**
+     * 组织Id
+     */
+    private Integer organizeId;
+
+    /**
+     * 商品Id
+     */
+    private Integer productId;
+
+    /**
+     * 启用阶梯价格标识 0否 1是
+     */
+    private Integer ladderPriceFlag;
+
+    /**
+     * 机构价
+     */
+    private BigDecimal price;
+
+    /**
+     * 是否含税   0不含税,1含税,2未知
+     */
+    private Integer includedTax;
+
+    /**
+     * 发票类型(基于是否含税基础)   1增值税专用发票,2增值税普通发票, 3不能开票
+     */
+    private Integer invoiceType;
+
+    /**
+     * 最小起订量
+     */
+    private Integer minBuyNumber;
+
+    /**
+     * 成本价类型:1固定成本 2比例成本
+     */
+    private Integer costType;
+
+    /**
+     * 机构税率 :增值税默认13%,普通票6%取值范围[0-100]
+     */
+    private BigDecimal clubTaxPoint;
+
+    /**
+     * 供应商税率:增值专用发票默认13%,增值税普通发票6%取值范围[0-100]
+     */
+    private BigDecimal shopTaxPoint;
+
+    /**
+     * 成本价
+     */
+    private BigDecimal costPrice;
+
+    /**
+     * 比例成本百分比
+     */
+    private BigDecimal costProportional;
+
+    /**
+     * 是否包邮 0包邮 1到付 2默认(遵循运费规则)
+     */
+    private Integer postageType;
+
+    /**
+     * 商品状态:0已下架,1已上架
+     */
+    private Integer status;
+
+    /**
+     * 添加时间
+     */
+    private Date addTime;
+
+    /**
+     * 删除标识:0未删除,1已删除
+     */
+    private Integer delFlag;
+
+    /**
+     * 是否开启促销活动,1开启,0不开启
+     */
+    private Integer actStatus;
+
+    /**
+     * 供应商id
+     */
+    private Integer shopId;
+
+    /**
+     * 规格
+     */
+    private String unit;
+
+    /**
+     * 市场价
+     */
+    private BigDecimal normalPrice;
+
+    /**
+     * 商品名称
+     */
+    private String name;
+
+    /**
+     * 商品主图
+     */
+    private String mainImage;
+
+    /**
+     * 供应商名称
+     */
+    private String shopName;
+
+    private static final long serialVersionUID = 1L;
+}

+ 358 - 0
src/main/java/com/caimei/model/po/CmShopOrderPo.java

@@ -0,0 +1,358 @@
+package com.caimei.model.po;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * cm_shop_order
+ * @author 
+ */
+@Data
+public class CmShopOrderPo implements Serializable {
+    /**
+     * 子订单ID
+     */
+    private Integer shopOrderID;
+
+    /**
+     * 子订单编号
+     */
+    private String shopOrderNo;
+
+    /**
+     * 订单编号
+     */
+    private String orderNo;
+
+    /**
+     * 主订单ID
+     */
+    private Long orderID;
+
+    /**
+     * 采美组织默认为null,具体对应cm_mall_organize表ID
+     */
+    private Integer organizeID;
+
+    /**
+     * 用户Id
+     */
+    private Integer userID;
+
+    /**
+     * 供应商Id
+     */
+    private Integer shopID;
+
+    /**
+     * 订单促销id(主要针对店铺促销)
+     */
+    private Integer orderPromotionsId;
+
+    /**
+     * 普通订单 1 协销订单0 与cm_order一样
+     */
+    private Integer orderType;
+
+    /**
+     * 0:个人自己下单 1:企业自己下单 2:员工帮会所下单 3:协销帮会所下单  4:后台下单 5:采美豆订单
+     */
+    private Integer orderSubmitType;
+
+    /**
+     * 赠品数
+     */
+    private Integer presentNum;
+
+    /**
+     *   购买数量
+     */
+    private Integer itemCount;
+
+    /**
+     * 已经发货的商品数量
+     */
+    private Integer outStoreNum;
+
+    /**
+     * 子订单发货批次 默认值 = 0 即没过发货
+     */
+    private Integer outStoreTimes;
+
+    /**
+     * 收货地址县区Id
+     */
+    private Integer townID;
+
+    /**
+     * 子订单备注信息
+     */
+    private String note;
+
+    /**
+     * 运费:-1到付,0包邮,其他为具体运费(v5.0版本已废弃,运费已使用商品形式存储)
+     */
+    private Double fee;
+
+    /**
+     * 余额支付时使用的金额
+     */
+    private BigDecimal accountAmount;
+
+    /**
+     * 总金额 = 订单商品totalAmount
+     */
+    private BigDecimal productAmount;
+
+    /**
+     * 总价 = totalFee
+     */
+    private BigDecimal totalAmount;
+
+    /**
+     * 需要支付金额 shouldPayFee +运费
+     */
+    private BigDecimal needPayAmount;
+
+    private BigDecimal discountAmount;
+
+    /**
+     * 经理折扣(v5.0版本已废弃,经理折扣只和主订单有关)
+     */
+    private BigDecimal discountFee;
+
+    /**
+     * 订单总优惠
+     */
+    private BigDecimal preferential;
+
+    /**
+     * 促销满减优惠(不考虑凑单促销)
+     */
+    private BigDecimal promotionFullReduction;
+
+    /**
+     * 是否已支付:1是,0否
+     */
+    private String payFlag;
+
+    /**
+     * 订单提交时间
+     */
+    private String orderTime;
+
+    /**
+     * 支付时间
+     */
+    private String payTime;
+
+    /**
+     * 订单完成时间
+     */
+    private String finishTime;
+
+    /**
+     * 订单彻底完成时间 不能售后 毫秒
+     */
+    private Long autoOverTimeMills;
+
+    /**
+     * 订单状态:见表c_orderstatus或枚举OrderStatus(v5.0版本已废弃只有主订单状态)
+     */
+    private Integer status;
+
+    /**
+     * (付款供应商)付款状态:1待付款、2部分付款、3已付款
+     */
+    private String payStatus;
+
+    /**
+     * 发货状态:1待发货、2部分发货、3已发货
+     */
+    private String sendOutStatus;
+
+    private Integer refundStatus;
+
+    private Integer returnGoodsStatus;
+
+    /**
+     * 收货时间
+     */
+    private String receiveGoodsTime;
+
+    /**
+     * 自动收货时间点 毫秒计算 
+     */
+    private Long autoReceiveTimeMills;
+
+    /**
+     * 总税费
+     */
+    private BigDecimal totalAddedValueTax;
+
+    /**
+     * 可退款金额 = 余额抵扣金额
+     */
+    private Double canRefundAmount;
+
+    /**
+     * 退款金额
+     */
+    private Double refundAmount;
+
+    private Integer clubID;
+
+    private Integer spID;
+
+    private Integer mainSpID;
+
+    /**
+     * 订单采美豆个数
+     */
+    private Integer orderBeanAmount;
+
+    /**
+     * 使用采美豆数量
+     */
+    private Integer useBeanAmount;
+
+    /**
+     * 是否使用采美豆
+     */
+    private Integer useBeanFlag;
+
+    /**
+     * 是否可以退货 1可以退款/退货 0不可退款/退货
+     */
+    private Integer canRefundFlag;
+
+    /**
+     * 是否使用余额
+     */
+    private Integer useBalanceFlag;
+
+    /**
+     * 可以退还的采美豆个数
+     */
+    private Integer canRefundBeans;
+
+    /**
+     * 订单包邮时本该支付的运费
+     */
+    private BigDecimal freePostageFee;
+
+    /**
+     * 使用的包邮券Id,为空表示未使用包邮券  保留
+     */
+    private Integer freePostageTicketID;
+
+    /**
+     * 佣金 =  应付采美
+     */
+    private BigDecimal brokerage;
+
+    /**
+     * 后台删除状态 0正常,其他删除
+     */
+    private String delFlag;
+
+    /**
+     * 订单退款金额
+     */
+    private BigDecimal refundsAmount;
+
+    /**
+     * 订单状态标识,1:非退货退款订单、2:退货退款中、3退货退款完成
+     */
+    private String orderStatusFlag;
+
+    /**
+     * 购买状态
+     */
+    private String buyStatus;
+
+    /**
+     * 全部发货时间
+     */
+    private String deliveryTimeMills;
+
+    private Integer orderDeliveryID;
+
+    /**
+     * 订单能否拆分 1 为可拆分, 0为不可拆分
+     */
+    private String splitFlag;
+
+    /**
+     * 是否处于给供应商状态中   0不是的,  1是的
+     */
+    private String paying;
+
+    /**
+     * 商品费
+     */
+    private BigDecimal shopProductAmount;
+
+    /**
+     * 运费
+     */
+    private BigDecimal shopPostFee;
+
+    /**
+     * 税费
+     */
+    private BigDecimal shopTaxFee;
+
+    /**
+     * 付供应商 = 商品费 + 运费 + 税费
+     */
+    private BigDecimal shouldPayShopAmount;
+
+    /**
+     * 已付款金额
+     */
+    private BigDecimal payedShopAmount;
+
+    /**
+     * 付第三方
+     */
+    private BigDecimal shopOtherFee;
+
+    private String receiptedFlag;
+
+    private String receiptedType;
+
+    /**
+     * 固定成本1,  比例成本2  为空就是还没有设置过
+     */
+    private String costType;
+
+    /**
+     * 比例成本的比例值
+     */
+    private BigDecimal proportional;
+
+    /**
+     * 修改应付必填备注信息
+     */
+    private String modifyShouldPayNote;
+
+    /**
+     * 修改应付金额的用户ID
+     */
+    private Long modifyShouldPayUserID;
+
+    /**
+     * 修改应付金额的时间
+     */
+    private Date modifyShouldPayDate;
+
+    /**
+     * 子订单0成本标识:0子订单不是0成本,1子订单0成本(子订单中所有商品成本为0)
+     */
+    private Integer zeroCostFlag;
+
+    private static final long serialVersionUID = 1L;
+}

+ 47 - 0
src/main/java/com/caimei/model/po/OrderProductLadderPricePo.java

@@ -0,0 +1,47 @@
+package com.caimei.model.po;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * order_product_ladder_price
+ * @author 
+ */
+@Data
+public class OrderProductLadderPricePo implements Serializable {
+    private Integer id;
+
+    /**
+     * 订单商品Id
+     */
+    private Integer orderProductId;
+
+    /**
+     * 第几阶梯
+     */
+    private Integer ladderNum;
+
+    /**
+     * 购买数量
+     */
+    private Integer buyNum;
+
+    /**
+     * 购买价格
+     */
+    private BigDecimal buyPrice;
+
+    /**
+     * 创建时间
+     */
+    private Date createDate;
+
+    /**
+     * 更新时间
+     */
+    private Date updateDate;
+
+    private static final long serialVersionUID = 1L;
+}

+ 633 - 0
src/main/java/com/caimei/model/po/ProductPo.java

@@ -0,0 +1,633 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * product
+ *
+ * @author
+ */
+@Data
+public class ProductPo implements Serializable {
+    private Integer productID;
+
+    /**
+     * 品牌Id
+     */
+    private Integer brandID;
+
+    /**
+     * 一级分类ID
+     */
+    private Integer bigTypeID;
+
+    /**
+     * 二级分类ID
+     */
+    private Integer smallTypeID;
+
+    /**
+     * 三级分类Id
+     */
+    private Integer tinyTypeID;
+
+    /**
+     * 小程序商品分类Id(已废弃)
+     */
+    private Integer classifyId;
+
+    /**
+     * 商品的类别:1正常商品(默认),2二手商品
+     */
+    private String productCategory;
+
+    /**
+     * 常用商品001,精品推荐010,热门推荐100,三者同时存在111
+     */
+    private Integer preferredFlag;
+
+    private Integer selfTypeID;
+
+    /**
+     * 所属供应商Id
+     */
+    private Integer shopID;
+
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * 内部商品名称
+     */
+    private String aliasName;
+
+    /**
+     * 搜索关键词,4个用双##区分,不存在的直接逗号隔空(顺序参考:品牌,学名,市场称呼,大类别,小类别)
+     */
+    private String searchKey;
+
+    /**
+     * 商品备注
+     */
+    private String productRemarks;
+
+    /**
+     * 市场价
+     */
+    private Double normalPrice;
+
+    private Double price;
+
+    /**
+     * 最低价【V6.2.0版本已废弃】
+     */
+    private Double highestUserLevelPrice;
+
+    /**
+     * 最高价【V6.2.0版本已废弃】
+     */
+    private Double lowestUserLevelPrice;
+
+    /**
+     * 最高价会员等级【V6.2.0版本已废弃】
+     */
+    private Integer lowestUserLevelID;
+
+    /**
+     * 普通用户价格,【V6.2.0版本已废弃】
+     */
+    private Double price0;
+
+    /**
+     * 普通用户价格等级(范围1-5)【V6.2.0版本已废弃】
+     */
+    private String price0Grade;
+
+    /**
+     * 普通用户价格文字【V6.2.0版本已废弃】
+     */
+    private String price0Text;
+
+    /**
+     * 普通用户文字展示标志 0显示价格 1显示文字 2显示等级【V6.2.0版本已废弃】
+     */
+    private String price0TextFlag;
+
+    /**
+     * 机构价格(同为二手商品的交易价)
+     */
+    private Double price1;
+
+    /**
+     * 机构用户价格等级(范围1-5)【V6.2.0版本已废弃-根据价格范围显示等级】
+     */
+    private String price1Grade;
+
+    /**
+     * 机构用户价格文字【V6.2.0版本已废弃-目前都是前端直接写死】
+     */
+    private String price1Text;
+
+    /**
+     * 是否公开机构价 0公开价格 1不公开价格 2仅对会员机构公开
+     */
+    private String price1TextFlag;
+
+    /**
+     * 游客价格【V6.2.0版本已废弃】
+     */
+    private Double price8;
+
+    /**
+     * 游客用户价格等级(范围1-5)【V6.2.0版本已废弃】
+     */
+    private String price8Grade;
+
+    /**
+     * 游客价格文字【V6.2.0版本已废弃】
+     */
+    private String price8Text;
+
+    /**
+     * 游客用户文字展示标志 0显示价格 1显示文字 2显示等级【V6.2.0版本已废弃】
+     */
+    private String price8TextFlag;
+
+    /**
+     * 启用阶梯价格标识 0否 1是
+     */
+    private String ladderPriceFlag;
+
+    /**
+     * 银卡价【V6.2.0版本已废弃】
+     */
+    private Double price2;
+
+    /**
+     * 金卡价【V6.2.0版本已废弃】
+     */
+    private Double price3;
+
+    /**
+     * 铂金价【V6.2.0版本已废弃】
+     */
+    private Double price4;
+
+    /**
+     * 钻石价【V6.2.0版本已废弃】
+     */
+    private Double price5;
+
+    /**
+     * 普通服务商价【V6.2.0版本已废弃】
+     */
+    private Double price6;
+
+    /**
+     * 金牌服务商价【V6.2.0版本已废弃】
+     */
+    private Double price7;
+
+    /**
+     * 运费【V6.2.0版本已废弃】
+     */
+    private Double fee;
+
+    /**
+     * 库存(同为二手商品的数量)
+     */
+    private Integer stock;
+
+    /**
+     * 是否有sku:1有, 0没有
+     */
+    private String hasSkuFlag;
+
+    /**
+     * 主图
+     */
+    private String mainImage;
+
+    /**
+     * sku属性
+     */
+    private String propertiesInfo;
+
+    /**
+     * 添加时间
+     */
+    private String addTime;
+
+    /**
+     * 更新时间
+     */
+    private String updateTime;
+
+    /**
+     * 小程序分类添加时间(已废弃)
+     */
+    private Date classifyAddTime;
+
+    /**
+     * 销量
+     */
+    private Integer sellNumber;
+
+    private Integer weekSellNumber;
+
+    private String beforeValidFlag;
+
+    /**
+     * 商品状态,见表c_productstatus或枚举ProductStatus,0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已隐身 10已冻结
+     */
+    private String validFlag;
+
+    /**
+     * 收藏量
+     */
+    private Integer favoriteTimes;
+
+    /**
+     * 评论分数
+     */
+    private Double commentScore;
+
+    /**
+     * 评论次数
+     */
+    private Integer commentTimes;
+
+    private String selfRecommendFlag;
+
+    private String sysRecommendFlag;
+
+    /**
+     * 排序值
+     */
+    private Integer sortIndex;
+
+    /**
+     * 供应商主推商品标志 0否 1是
+     */
+    private String featuredFlag;
+
+    /**
+     * 供应商主推商品排序
+     */
+    private Integer featuredSortIndex;
+
+    /**
+     * 商品货号
+     */
+    private String productCode;
+
+    private Double rate1;
+
+    private Double rate2;
+
+    /**
+     * 包装规格
+     */
+    private String unit;
+
+    /**
+     * 是否推送到ERP,1已推送, 空或0未推送
+     */
+    private String synToERPFlag;
+
+    /**
+     * 销售区域:1全部区域, 0指定区域
+     */
+    private String allAreaFlag;
+
+    /**
+     * 指定的销售区域
+     */
+    private String provinceIDs;
+
+    /**
+     * 服务起订量
+     */
+    private String serviceNumber;
+
+    /**
+     * 最大购买量
+     */
+    private Integer maxBuyNumber;
+
+    private String virtualFlag;
+
+    /**
+     * 最小购买量
+     */
+    private Integer minBuyNumber;
+
+    /**
+     * 最小包装数量
+     */
+    private Integer packageCount;
+
+    /**
+     * 运费:0买家承担, 1卖家承担
+     */
+    private String byFlag;
+
+    /**
+     * 普通商品标志 1是
+     */
+    private Integer normalProductFlag;
+
+    private Integer wholeSaleProductFlag;
+
+    private Integer promotionProductFlag;
+
+    private Integer groupBuyProductFlag;
+
+    /**
+     * 购买数量: 1逐步增长,2以起订量增长(起订量的倍数增长)
+     */
+    private Integer step;
+
+    private String speCommisionFlag;
+
+    private Double speCommision;
+
+    private String videourl;
+
+    private String props;
+
+    private String providers;
+
+    private Double serviceCommissionRatio;
+
+    private Double reCommissionRatio;
+
+    /**
+     * 推送到ERP的原商品名称 name字段的名称可能做修改已适应平台的搜索
+     */
+    private String pushToERPName;
+
+    private Integer prodBeans;
+
+    /**
+     * 该商品是否可以使用采美豆购买
+     */
+    private Integer useBeansFlag;
+
+    /**
+     * 0开放市场 1私有市场
+     */
+    private Integer privateFlag;
+
+    private String invisibleServiceProviderIDs;
+
+    private String displayOnCRMFlag;
+
+    private String needServiceFlag;
+
+    /**
+     * 是否使用活动角标:1是,空或0不是[与actType搭配使用,仅用于标识非真正活动]
+     */
+    private Integer actFlag;
+
+    /**
+     * 商品是否处于活动状态:1是,空或0不是[活动商品和actFlag含义不同]
+     */
+    private Integer actStatus;
+
+    /**
+     * 活动商品排序
+     */
+    private Long actSort;
+
+    /**
+     * 普通用户活动价格【V6.2.0版本已废弃】
+     */
+    private BigDecimal actPrice0;
+
+    /**
+     * 机构活动价(对应actStatus的活动下使用)
+     */
+    private BigDecimal actPrice1;
+
+    /**
+     * 银卡会员活动价【V6.2.0版本已废弃】
+     */
+    private BigDecimal actPrice2;
+
+    /**
+     * 金卡会员活动价【V6.2.0版本已废弃】
+     */
+    private BigDecimal actPrice3;
+
+    /**
+     * 铂金会员活动价【V6.2.0版本已废弃】
+     */
+    private BigDecimal actPrice4;
+
+    /**
+     * 钻石会员活动价【V6.2.0版本已废弃】
+     */
+    private BigDecimal actPrice5;
+
+    /**
+     * 普通服务商活动价【V6.2.0版本已废弃】
+     */
+    private BigDecimal actPrice6;
+
+    /**
+     * 金牌服务商活动价【V6.2.0版本已废弃】
+     */
+    private BigDecimal actPrice7;
+
+    /**
+     * 首页活动角标标识类型:1推荐热销、2推荐上新
+     */
+    private Integer actType;
+
+    /**
+     * 活动创建时间(对应actStatus的活动下使用)
+     */
+    private Date actCreateTime;
+
+    /**
+     * 满减金额(达到该金额后可享直减)
+     */
+    private BigDecimal actFullReduceAmount;
+
+    /**
+     * 购买直减金额(达到满金额后)
+     */
+    private BigDecimal actReduceAmount;
+
+    /**
+     * 商品可见度:(3:所有人可见,2:普通机构可见,1:会员机构可见)
+     */
+    private String visibility;
+
+    /**
+     * 满增金额(达到满赠金额后可享赠品) 【V6.4.2版本已废弃】
+     */
+    private BigDecimal actFullGiftAmount;
+
+    /**
+     * 买赠数量(达到该数量后可享赠品)【V6.4.2版本已废弃】
+     */
+    private Long actBuyGiftNum;
+
+    /**
+     * 活动开始时间(对应actStatus的活动下使用)
+     */
+    private Date beginTime;
+
+    /**
+     * 活动结束时间(对应actStatus的活动下使用)
+     */
+    private Date endTime;
+
+    /**
+     * 【V6.2.0版本已废弃】
+     */
+    private Integer shopIndexModuleID;
+
+    /**
+     * 上架时间
+     */
+    private Date onlineTime;
+
+    /**
+     * 下架时间
+     */
+    private Date downlineTime;
+
+    /**
+     * 是否包邮 0包邮 1到付 2默认(遵循运费规则)
+     */
+    private String freePostFlag;
+
+    /**
+     * crm一级商品分类
+     */
+    private Integer crmBigTypeId;
+
+    /**
+     * crm二级商品分类
+     */
+    private Integer crmSmallTypeId;
+
+    /**
+     * 成本价
+     */
+    private BigDecimal costPrice;
+
+    /**
+     * 比例成本百分比
+     */
+    private BigDecimal costProportional;
+
+    /**
+     * 成本价选中标志:1固定成本 2比例成
+     */
+    private String costCheckFlag;
+
+    private String precisehKey;
+
+    private Double docBoost;
+
+    /**
+     * 是否采美豆专区商品(0 否,1 是)
+     */
+    private String cmbeanFlag;
+
+    /**
+     * 采美豆专区价格(采美豆)
+     */
+    private Integer cmbeanPrice;
+
+    /**
+     * 采美豆专区排序(值越大越前)
+     */
+    private Short cmbeanSort;
+
+    /**
+     * 商品标签用英文逗号隔开,中文逗号或其它一律不作切割
+     */
+    private String tags;
+
+    private String surplusTime;
+
+    /**
+     * 商品类型:0其它类型(默认),1妆字号,2械字号
+     */
+    private String productType;
+
+    /**
+     * 械字号类型   (基于械字号基础) ,1:一类,2:二类,3:三类
+     */
+    private String machineType;
+
+    /**
+     * 械字号资质证书图 (基于械字号基础)
+     */
+    private String qualificationImg;
+
+    /**
+     * 是否含税   0不含税,1含税,2未知
+     */
+    private String includedTax;
+
+    /**
+     * 开票税点(基于不含税基础) :增值税默认13%,普通票6%取值范围[0-100]
+     */
+    private BigDecimal taxPoint;
+
+    /**
+     * 供应商税率:增值专用发票默认13%,增值税普通发票6%取值范围[0-100]
+     */
+    private BigDecimal supplierTaxPoint;
+
+    /**
+     * 发票类型(基于是否含税基础)   1增值税票,2普通票, 3不能开票
+     */
+    private String invoiceType;
+
+    /**
+     * 相关推荐类型 0自动选择; 1手动推荐
+     */
+    private String recommendType;
+
+    private Integer skuID;
+
+    /**
+     * V6.2.0版本已废弃】
+     */
+    private String priceType;
+
+    /**
+     * 商品组合Id、(cm_product_combination表Id)
+     */
+    private Integer combinationID;
+
+    /**
+     * 组合商品排序
+     */
+    private Integer combinationSort;
+
+    /**
+     * 商品属性:1产品,2仪器
+     */
+    private String commodityType;
+
+    /**
+     * 供应商名称
+     */
+    private String shopName;
+
+    private static final long serialVersionUID = 1L;
+}

+ 5 - 0
src/main/java/com/caimei/model/po/PromotionsPo.java

@@ -58,4 +58,9 @@ public class PromotionsPo implements Serializable {
      * 时效:1永久,2区间过期,其它无效
      */
     private Integer status;
+
+    /**
+     * 主订单id
+     */
+    private Integer orderId;
 }

+ 389 - 0
src/main/java/com/caimei/model/po/UserPo.java

@@ -0,0 +1,389 @@
+package com.caimei.model.po;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import lombok.Data;
+
+/**
+ * user
+ * @author 
+ */
+@Data
+public class UserPo implements Serializable {
+    private Integer userID;
+
+    /**
+     * 采美组织默认为0,具体对应cm_mall_organize表ID
+     */
+    private Integer userOrganizeID;
+
+    /**
+     * 企业账号名【供应商,目前只存数据不能用于登录】
+     */
+    private String account;
+
+    /**
+     * 个人手机号码(协销)
+     */
+    private String mobile;
+
+    /**
+     * 企业绑定手机号(机构,供应商)
+     */
+    private String bindMobile;
+
+    /**
+     * 用户权限 0游客 1 普通用户 2 会员机构 3 供应商 4 协销 5 普通机构【V6.2.0版本后0和1不存在】
+     */
+    private Integer userPermission;
+
+    /**
+     * 用户身份 0、个人 1、协销 2、会员机构 3、供应商 4.普通机构【V6.2.0版本后0不存在】
+     */
+    private Integer userIdentity;
+
+    /**
+     * 邮箱
+     */
+    private String email;
+
+    /**
+     * 用户名(机构联系人,供应商简称)
+     */
+    private String userName;
+
+    /**
+     * 真实姓名(供应商的联系人,机构不使用)
+     */
+    private String realName;
+
+    /**
+     * 注册来源: 0网站 1小程序
+     */
+    private String source;
+
+    /**
+     * 头像
+     */
+    private String image;
+
+    /**
+     * 密码
+     */
+    private String password;
+
+    /**
+     * 用户会员等级,见表c_userlevel或枚举UserLevel【V6.2.0版本已废弃】
+     */
+    private Integer userLevelID;
+
+    /**
+     * 名称(机构名称,供应商的公司名称)
+     */
+    private String name;
+
+    /**
+     * 昵称【V6.2.0版本已废弃】
+     */
+    private String nick;
+
+    /**
+     * 性别【V2021已废弃】
+     */
+    private String sex;
+
+    /**
+     * 见枚举UserType(1供应商,2协销经理,32协销,3会员机构,4普通机构)
+     */
+    private Integer registerUserTypeID;
+
+    /**
+     * 所属企业用户对应UserID【V6.2.0版本已废弃】
+     */
+    private Integer companyUserID;
+
+    /**
+     * 微信openID【V6.2.0版本已废弃】
+     */
+    private String openID;
+
+    /**
+     * 是否是供应商,1是 空或0否【V6.2.0版本已废弃】
+     */
+    private String manufacturerFlag;
+
+    /**
+     * 供应商状态, 3待审核, 90已上线,91已下线,92审核不通过
+     */
+    private Integer manufacturerStatus;
+
+    /**
+     * 供应商Id
+     */
+    private Integer shopID;
+
+    /**
+     * 是否创客,1是 空或0否【V6.2.0版本已废弃】
+     */
+    private String serviceProviderFlag;
+
+    /**
+     * 是否会所,1是 空或0否【V6.2.0版本已废弃】
+     */
+    private String clubFlag;
+
+    /**
+     * 达人标志【V6.2.0版本已废弃】
+     */
+    private String masterFlag;
+
+    /**
+     * 【V6.2.0版本已废弃】
+     */
+    private String normalFlag;
+
+    /**
+     * 审核状态
+     */
+    private String auditStatus;
+
+    /**
+     * 审核时间
+     */
+    private String auditTime;
+
+    /**
+     * 审核备注
+     */
+    private String auditNote;
+
+    /**
+     * 注册时间
+     */
+    private String registerTime;
+
+    /**
+     * 注册ip
+     */
+    private String registerIP;
+
+    /**
+     * 登录时间
+     */
+    private String loginTime;
+
+    /**
+     * 登录ip
+     */
+    private String loginIP;
+
+    /**
+     * 用户状态,1正常,0冻结
+     */
+    private String validFlag;
+
+    /**
+     * 【V6.2.0版本已废弃】
+     */
+    private String emailCheckFlag;
+
+    /**
+     * 【V6.2.0版本已废弃】
+     */
+    private String mobileCheckFlag;
+
+    /**
+     * 会所状态,见表c_clubstatus或枚举ClubStatus
+     */
+    private Integer clubStatus;
+
+    /**
+     * 会所Id
+     */
+    private Integer clubID;
+
+    /**
+     * 同意协议标志
+     */
+    private String agreeFlag;
+
+    /**
+     * 【已废弃】
+     */
+    private String activationCode;
+
+    /**
+     * 【已废弃】
+     */
+    private String activationDate;
+
+    /**
+     * 创客状态
+     */
+    private Integer serviceProviderStatus;
+
+    /**
+     * 创客Id
+     */
+    private Integer serviceProviderID;
+
+    /**
+     * 【已废弃】达人状态
+     */
+    private Integer masterStatus;
+
+    /**
+     * 【已废弃】达人ID
+     */
+    private Integer masterID;
+
+    /**
+     * 账户余额
+     */
+    private BigDecimal userMoney;
+
+    /**
+     * 账户实际可用余额(提交订单未支付的被抵扣后的余额)
+     */
+    private BigDecimal ableUserMoney;
+
+    /**
+     * 积分【V6.2.0版本已废弃】
+     */
+    private Integer point;
+
+    /**
+     * 开通ERP标志【V6.2.0版本已废弃】
+     */
+    private String shopERPFlag;
+
+    /**
+     * 邀请人Id【V6.2.0版本已废弃】
+     */
+    private Integer fromUserID;
+
+    /**
+     * 邀请人名称【V6.2.0版本已废弃】
+     */
+    private String fromUserName;
+
+    /**
+     * 退出时间
+     */
+    private String logoffTime;
+
+    private String appKey;
+
+    private String appSecret;
+
+    /**
+     * 【已废弃】
+     */
+    private String sampleFlag;
+
+    /**
+     * 扫描标志(4 CRM拉上来的会所) 0待扫描 1 已扫描 2已上线
+     */
+    private Integer scanFlag;
+
+    /**
+     * 【已废弃】
+     */
+    private Integer sysroleid;
+
+    /**
+     * 【已废弃】
+     */
+    private String gender;
+
+    /**
+     * 年龄【V2021已废弃】
+     */
+    private Integer age;
+
+    /**
+     * 【V2021已废弃】
+     */
+    private String salerbuyer;
+
+    /**
+     * 【V2021已废弃】
+     */
+    private String position;
+
+    /**
+     * 【V2021已废弃】
+     */
+    private String skill;
+
+    /**
+     * 【V2021已废弃】
+     */
+    private BigDecimal workage;
+
+    /**
+     * 微信号【V2021已废弃】
+     */
+    private String wechat;
+
+    /**
+     * QQ号【V2021已废弃】
+     */
+    private String qq;
+
+    /**
+     * 短信是否发送成功【V2021已废弃】
+     */
+    private String smsFlag;
+
+    /**
+     * 采美豆数量【V2021已废弃】
+     */
+    private Integer userBeans;
+
+    /**
+     * 【已废弃】平台商标志位0非平台商 1平台商
+     */
+    private Integer privateShopFlag;
+
+    /**
+     * 【已废弃】平台会所标志位0非平台会所 1平台会所
+     */
+    private Integer privateClubFlag;
+
+    /**
+     * 是否创客授权【V2021已废弃】
+     */
+    private Integer isMeiDaoAuthorized;
+
+    /**
+     * 是否已经引导过(供应商首次登陆操作引导)
+     */
+    private Integer guideFlag;
+
+    private Integer loginFailTime;
+
+    /**
+     * 用户申请加入企业的时间【V2021已废弃】
+     */
+    private String applyTime;
+
+    private String tipStatus;
+
+    /**
+     * 企业账号由哪一个用户升级而来,对应一个userID【V6.2.0版本已废弃】
+     */
+    private Integer upgradeBy;
+
+    /**
+     * 小程序openId【V6.2.0版本已废弃】
+     */
+    private String miniProgramOpenId;
+
+    /**
+     * 小程序用户Id【V6.2.0版本已废弃】
+     */
+    private String miniProgramId;
+
+    private static final long serialVersionUID = 1L;
+}

+ 14 - 0
src/main/java/com/caimei/service/OrderSubmitService.java

@@ -2,6 +2,7 @@ package com.caimei.service;
 
 import com.caimei.model.ResponseJson;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -21,4 +22,17 @@ public interface OrderSubmitService {
      */
     ResponseJson<Map<String, Object>> orderConfirm(String productIds, Integer count, Integer userId);
 
+    /**
+     * 提交订单
+     *
+     * @param cartType
+     * @param orderSource
+     * @param clubUserId
+     * @param addressId
+     * @param orderInfo
+     * @param payInfo
+     * @param orderInvoice
+     * @return
+     */
+    ResponseJson<Map<String, String>> orderSubmit(Integer cartType, String orderSource, Integer clubUserId, Integer addressId, List<Map<String, Object>> orderInfo, Map<String, Object> payInfo, Map<String, Object> orderInvoice);
 }

+ 960 - 2
src/main/java/com/caimei/service/impl/OrderSubmitServiceImpl.java

@@ -2,19 +2,27 @@ package com.caimei.service.impl;
 
 import com.caimei.mapper.OrderSubmitMapper;
 import com.caimei.mapper.ProductMapper;
+import com.caimei.mapper.ShoppingCartMapper;
 import com.caimei.model.ResponseJson;
-import com.caimei.model.po.CmUserInvoiceInfoPo;
-import com.caimei.model.po.PromotionsPo;
+import com.caimei.model.po.*;
+import com.caimei.model.po.AddressPo;
 import com.caimei.model.vo.CartProductVo;
+import com.caimei.model.vo.LadderPriceVo;
 import com.caimei.model.vo.ShopVo;
 import com.caimei.service.OrderSubmitService;
 import com.caimei.service.ShoppingCartService;
 import com.caimei.util.MathUtil;
+import com.caimei.util.OrderNoUtils;
+import com.caimei.util.ProductUtils;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -31,6 +39,12 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
     private OrderSubmitMapper orderSubmitMapper;
     @Resource
     private ShoppingCartService shoppingCartService;
+    @Resource
+    private ProductMapper productMapper;
+    @Resource
+    private ShoppingCartMapper shoppingCartMapper;
+    @Value("${caimei.oldapi}")
+    private String domain;
 
     @Override
     public ResponseJson<Map<String, Object>> orderConfirm(String productIds, Integer count, Integer userId) {
@@ -92,4 +106,948 @@ public class OrderSubmitServiceImpl implements OrderSubmitService {
             return ResponseJson.error("登录后才能购买", null);
         }
     }
+
+    @Override
+    public ResponseJson<Map<String, String>> orderSubmit(Integer cartType, String orderSource, Integer clubUserId, Integer addressId, List<Map<String, Object>> orderInfo, Map<String, Object> payInfo, Map<String, Object> orderInvoice) {
+        /*
+         * 逻辑处理 start
+         */
+        log.info("******************** 提交订单逻辑处理 start *******************");
+        //机构用户
+        UserPo user = orderSubmitMapper.findUser(clubUserId);
+        if (null == user) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 商品总数量
+        Integer productCount = 0;
+        // 赠品数量
+        Integer presentCount = 0;
+        //促销赠品数量
+        Integer promotionalGiftsCount = 0;
+        // 商品总金额 (商品单价乘以数量,再加上税费[默认0])
+        BigDecimal productTotalFee = BigDecimal.ZERO;
+        // 小计金额(商品折后单价乘以数量,再加上税费[默认0])
+        BigDecimal orderTotalFee = BigDecimal.ZERO;
+        // 订单总额(小计金额减去经理折扣后,再加上运费[默认0])
+        BigDecimal payTotalFee = BigDecimal.ZERO;
+        // 真实支付金额(订单总额减去抵扣的账户余额)
+        BigDecimal payableAmount = BigDecimal.ZERO;
+        // 余额支付金额
+        BigDecimal balancePayFee = BigDecimal.ZERO;
+        // 促销满减优惠
+        BigDecimal promotionFullReduction = BigDecimal.ZERO;
+        // 运费
+        if (null == payInfo.get("freePostFlag") || null == payInfo.get("freight")) {
+            return ResponseJson.error("运费数据异常", null);
+        }
+        Integer freePostFlag = (Integer) payInfo.get("freePostFlag");
+        BigDecimal freight = new BigDecimal(payInfo.get("freight").toString());
+        /*
+         * 发票信息获取
+         */
+        boolean invoiceFlag = false;
+        BpOrderInvoicePo invoice = new BpOrderInvoicePo();
+        Integer invoiceType = (Integer) orderInvoice.get("type");
+        if (null == invoiceType) {
+            return ResponseJson.error("发票类型不能为空", null);
+        } else {
+            invoice.setType(invoiceType.longValue());
+            if (0 != invoiceType) {
+                // 发票类型 0不开发票 1普通发票 2增值税发票
+                invoiceFlag = true;
+                if (setInvoiceParam(orderInvoice, invoice, invoiceType)) {
+                    return ResponseJson.error("发票信息不完整", null);
+                }
+            }
+        }
+
+        /*
+         * 初始化主订单参数
+         */
+        CmOrderPo order = new CmOrderPo();
+        String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date());
+        // 订单号
+        String orderNo = null;
+        orderNo = OrderNoUtils.getOrderNo("A");
+        order.setOrderNo(orderNo);
+        // 运营人员下单
+        order.setBuyUserID(user.getUserID());
+        order.setOrderType(1);
+        order.setOrderSubmitType(2);
+        order.setConfirmFlag("2");
+        order.setUserID(user.getUserID().longValue());
+        // 机构ID
+        order.setClubID(user.getClubID().longValue());
+        // 订单来源
+        order.setOrderSource(orderSource);
+        order.setUpdateDate(curDateStr);
+        order.setPayFlag("0");
+        order.setCooFreeFlag("0");
+        order.setCooFreeAmount(BigDecimal.ZERO);
+        order.setCooFreeRate(0);
+        order.setOnlinePayFlag("0");
+        order.setPreferential(BigDecimal.ZERO);
+        order.setDiscountFee(BigDecimal.ZERO);
+        // 订单提交时间
+        order.setOrderTime(curDateStr);
+        // 默认订单可以拆分
+        order.setSplitFlag("1");
+        // 发票类型
+        order.setInvoiceFlag(invoiceType.toString());
+        order.setReceiptStatus("1");
+        order.setPayStatus("1");
+        order.setZeroCostFlag(0);
+        order.setSendOutStatus("1");
+        order.setRefundType("0");
+        // 是否包含活动商品(受订单未支付自动关闭时间影响)  0 否 1 是
+        order.setHasActProduct("0");
+        // 订单状态 0 有效  其它无效
+        order.setDelFlag("0");
+        // 是否确认付款供应商
+        order.setAffirmPaymentFlag("0");
+        //促销活动ids
+        List<Integer> promotionsIds = new ArrayList<>();
+        //订单下商品信息
+        List<Map<String, Integer>> productInfo = new ArrayList<>();
+        /*
+         * 订单商品
+         */
+        List<CmOrderProductPo> orderProductList = new ArrayList<>();
+        for (Map<String, Object> shopOrderInfo : orderInfo) {
+            Integer shopId = (Integer) shopOrderInfo.get("shopId");
+            if (null == shopId) {
+                return ResponseJson.error("供应商数据异常", null);
+            }
+            // 一个子订单对应的商品信息
+            List<Map<String, Integer>> productInfoList = (List<Map<String, Integer>>) shopOrderInfo.get("productInfo");
+            if (null == productInfoList) {
+                return ResponseJson.error(-1, "订单商品数据异常", null);
+            }
+            /*
+             * 整理订单商品信息
+             */
+            if (!CollectionUtils.isEmpty(productInfoList)) {
+                // 商品信息ids
+                List<Integer> productIds = new ArrayList<>();
+                // 遍历所有商品
+                for (Map<String, Integer> productTemp : productInfoList) {
+                    Integer productId = productTemp.get("productId");
+                    Integer productNum = productTemp.get("productNum");
+                    Integer presentNum = productTemp.get("presentNum");
+                    Integer productType = productTemp.get("productType");
+                    productType = null == productType ? 0 : productType;
+                    productIds.add(productId);
+                    // 统计商品总数量
+                    productCount += productNum;
+                    // 赠品数
+                    presentCount += presentNum;
+                    if (2 == productType) {
+                        promotionalGiftsCount++;
+                    }
+                    // 获取商品信息
+                    CmOrganizeProductPo product = productMapper.getProduct(productId);
+                    if (null == product) {
+                        return ResponseJson.error("订单商品数据异常", null);
+                    }
+                    if (null == productNum || productNum == 0) {
+                        return ResponseJson.error("商品购买数量异常", null);
+                    }
+                    // 获取商品购买价格(活动价格>>>阶梯价格>>>复购价格库>>>商品原始价)
+                    BigDecimal productPrice = product.getPrice();
+                    // 成本价
+                    BigDecimal costPrice = BigDecimal.ZERO;
+                    // 机构税费(单)
+                    BigDecimal addedValueTax = new BigDecimal(0);
+
+                    // 商品是否处于活动状态
+                    PromotionsPo promotions = productMapper.findPromotionByProductId(product.getId());
+                    int priceType = 0;
+                    if (productType != 2) {
+                        if (promotions != null) {
+                            // 是否包含活动商品(受订单未支付自动关闭时间影响)  0 否 1 是
+                            order.setHasActProduct("1");
+                            product.setActStatus(1);
+                            if (!promotionsIds.contains(promotions.getId())) {
+                                promotionsIds.add(promotions.getId());
+                            }
+                            productInfo.add(productTemp);
+                            priceType = 1;
+                        } else if (1 == product.getLadderPriceFlag()) {
+                            // 启用了阶梯价格
+                            List<LadderPriceVo> ladderPriceList = productMapper.findLadderPriceByProductId(product.getId());
+                            // 判断阶梯价格的购买数量校验
+                            long minBuyNumber = null != ladderPriceList.get(0) ? ladderPriceList.get(0).getBuyNum() : 0L;
+                            if (productNum < minBuyNumber) {
+                                return ResponseJson.error("商品购买量低于最小起订量", null);
+                            }
+                            //根据商品购买数量获取商品对应阶梯价格
+                            for (LadderPriceVo ladderPrice : ladderPriceList) {
+                                if (productNum >= ladderPrice.getBuyNum()) {
+                                    productPrice = ladderPrice.getBuyPrice();
+                                }
+                            }
+                            product.setActStatus(2);
+                            priceType = 2;
+                        }
+                        //不含税可开票商品计算税费
+                        if (0 == product.getIncludedTax() && (1 == product.getInvoiceType() || 2 == product.getInvoiceType())) {
+                            if (promotions != null && promotions.getType() == 1 && promotions.getMode() == 1) {
+                                addedValueTax = MathUtil.div(MathUtil.mul(promotions.getTouchPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100));
+                                productPrice = MathUtil.add(promotions.getTouchPrice(), addedValueTax);
+                            } else {
+                                addedValueTax = MathUtil.div(MathUtil.mul(productPrice, product.getClubTaxPoint()), BigDecimal.valueOf(100));
+                                productPrice = MathUtil.add(productPrice, addedValueTax);
+                            }
+                        } else if (promotions != null && promotions.getType() == 1 && promotions.getMode() == 1) {
+                            //单品优惠商品设置售价
+                            productPrice = promotions.getTouchPrice();
+                        }
+                        if (MathUtil.compare(productPrice, BigDecimal.ZERO) == 0) {
+                            return ResponseJson.error("商品购买价格不能为0", null);
+                        }
+                        // 单个商品的金额
+                        BigDecimal productFee = MathUtil.mul(productPrice, productNum);
+                        // 统计商品总金额
+                        productTotalFee = MathUtil.add(productTotalFee, productFee);
+                    }
+                    // 判断是否选中固定成本价
+                    if (MathUtil.compare(product.getCostPrice(), 0) > 0 && 1 == product.getCostType()) {
+                        costPrice = product.getCostPrice();
+                    }
+                    // 判断是否选中比例成本价
+                    if (MathUtil.compare(product.getCostProportional(), 0) > 0 && 2 == product.getCostType()) {
+                        // 通过售价*比例得到成本价
+                        costPrice = BigDecimal.valueOf(MathUtil.div(MathUtil.mul(productPrice, product.getCostProportional()), 100).floatValue());
+                    }
+                    product.setCostPrice(costPrice);
+
+                    /*
+                     * 整理订单商品数据
+                     */
+                    CmOrderProductPo orderProduct = setOrderProduct(productNum, product, productPrice, priceType, productType, addedValueTax);
+                    // 加入订单商品列表
+                    orderProductList.add(orderProduct);
+
+                    shoppingCartMapper.deleteCartByProductId(user.getUserID(), product.getId());
+                    log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>删除用户购物车数据productId:" + product.getId());
+
+                }
+            }
+        }
+        //订单下所有在进行的促销活动
+        List<PromotionsPo> promotionsList = new ArrayList<>();
+        //促销活动,凑单满减
+        for (Integer promotionsId : promotionsIds) {
+            PromotionsPo promotionsVo = productMapper.findParameterById(promotionsId);
+            //只针对活动满减满赠
+            if (promotionsVo.getMode() == 2 || promotionsVo.getMode() == 3) {
+                //凑单金额
+                AtomicReference<BigDecimal> poolAmount = new AtomicReference<>(BigDecimal.ZERO);
+                productInfo.forEach(map -> {
+                    Integer productId = map.get("productId");
+                    Integer productNum = map.get("productNum");
+                    CmOrganizeProductPo product = productMapper.getProduct(productId);
+                    PromotionsPo promotions = productMapper.findPromotionByProductId(productId);
+                    if (promotions != null && promotionsId.equals(promotions.getId())) {
+                        //添加税费
+                        if (0 == product.getIncludedTax() && (1 == product.getInvoiceType() || 2 == product.getInvoiceType())) {
+                            BigDecimal taxes = MathUtil.div(MathUtil.mul(product.getPrice(), product.getClubTaxPoint()), 100);
+                            product.setPrice(MathUtil.add(taxes, product.getPrice()));
+                        }
+                        poolAmount.set(MathUtil.add(poolAmount.get(), MathUtil.mul(productNum, product.getPrice())));
+                    }
+                });
+                //判断是否达到满减满赠要求
+                if (MathUtil.compare(poolAmount.get(), promotionsVo.getTouchPrice()) > -1) {
+                    if (promotionsVo.getMode() == 2) {
+                        promotionFullReduction = MathUtil.add(promotionFullReduction, promotionsVo.getReducedPrice());
+                        productTotalFee = MathUtil.sub(productTotalFee, promotionsVo.getReducedPrice());
+                    }
+                    promotionsList.add(promotionsVo);
+                }
+            } else {
+                promotionsList.add(promotionsVo);
+            }
+        }
+
+        // 设置是否是二手订单
+        order.setSecondHandOrderFlag("0");
+        order.setPromotionFullReduction(promotionFullReduction);
+        // 商品总数量
+        order.setProductCount(productCount);
+        // 赠品数量
+        order.setPresentCount(presentCount);
+        //促销赠品数量
+        order.setPromotionalGiftsCount(promotionalGiftsCount);
+        // 获取地址信息
+        AddressPo address = orderSubmitMapper.findByAddressId(addressId);
+        // 0包邮 -1到付 1 有运费
+        order.setFreePostFlag(freePostFlag.toString());
+        order.setFreight(freight);
+        // 商品总额
+        order.setProductTotalFee(productTotalFee);
+        // 订单总额(商品金额+运费)
+        if (1 == freePostFlag) {
+            // 机构用户 计算商品运费
+            if (cartType != 3 && null != address) {
+                Double freightFee = computedPostageFee(address.getProvinceId(), address.getCityId());
+                freight = BigDecimal.valueOf(freightFee);
+            }
+            order.setFreight(freight);
+            payTotalFee = MathUtil.add(productTotalFee, freight);
+        } else {
+            payTotalFee = productTotalFee;
+        }
+        orderTotalFee = productTotalFee;
+        order.setOrderTotalFee(orderTotalFee);
+        order.setPayTotalFee(payTotalFee);
+        payableAmount = payTotalFee;
+        // 订单状态
+        if (cartType == 3) {
+            // 协销用户
+            order.setStatus("0");
+        } else {
+            // 机构用户
+            order.setStatus("11");
+            order.setConfirmTime(curDateStr);
+        }
+        // 是否完成支付(默认不是,只有余额抵扣才算)
+        boolean isPaySuccessFlag = false;
+        // 余额支付金额
+        order.setBalancePayFee(balancePayFee);
+        // 实际支付金额(商品金额+运费-余额抵扣)
+        order.setPayableAmount(payableAmount);
+        // 售后条款
+        order.setClauseID(1L);
+        order.setClauseName("无条款");
+        // 是否返佣订单
+        order.setRebateFlag("0");
+        // 判断前端传入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 ResponseJson.error("订单付款金额异常", null);
+        }
+
+        /*
+         * 保存主订单数据
+         */
+        orderSubmitMapper.insertOrder(order);
+        log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>新增主订单(insert[cm_order])orderId:" + order.getOrderID());
+
+        //设置订单促销订单号,并保存
+        promotionsList.forEach(promotions -> {
+            promotions.setOrderId(order.getOrderID().intValue());
+            orderSubmitMapper.insertOrderPromotions(promotions);
+            log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>新增订单促销活动(insert[cm_promotions_order])id:" + promotions.getId());
+        });
+
+        /*
+         * 设置订单商品订单号
+         */
+        for (CmOrderProductPo orderProduct : orderProductList) {
+            orderProduct.setOrderID(order.getOrderID());
+            orderProduct.setOrderNo(order.getOrderNo());
+            PromotionsPo promotions = productMapper.findPromotionByProductId(orderProduct.getProductID());
+            if (promotions != null) {
+                PromotionsPo orderPromotions = orderSubmitMapper.findOrderPromotions(orderProduct.getOrderID(), promotions.getId());
+                if (orderPromotions != null) {
+                    orderProduct.setOrderPromotionsId(orderPromotions.getId());
+                }
+
+            }
+        }
+
+        /*
+         * 整理 子订单信息
+         */
+        // 收集子订单供应商ID字符串
+        String shopOrderIds = "";
+        for (Map<String, Object> shopOrderInfo : orderInfo) {
+            Integer shopId = (Integer) shopOrderInfo.get("shopId");
+            String shopNote = (String) shopOrderInfo.get("note");
+            // 初始化子订单信息
+            CmShopOrderPo shopOrder = saveShopOrder(order, orderProductList, shopId, shopNote);
+            // 保存子订单号
+            shopOrderIds += (("".equals(shopOrderIds) ? "" : ",") + shopOrder.getShopOrderID());
+            // 设置订单商品子订单号
+            for (CmOrderProductPo orderProduct : orderProductList) {
+                if (shopId.longValue() == orderProduct.getShopID()) {
+                    orderProduct.setShopOrderID(shopOrder.getShopOrderID());
+                    orderProduct.setShopOrderNo(shopOrder.getShopOrderNo());
+                }
+            }
+        }
+        /*
+         * 保存订单商品
+         */
+        List<OrderProductLadderPricePo> orderProductLadderPriceList = new ArrayList<>();
+        for (CmOrderProductPo orderProduct : orderProductList) {
+            // 保存订单商品数据
+            orderSubmitMapper.insertOrderProduct(orderProduct);
+            log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>保存订单商品(insert[cm_order_product])OrderProductID:" + orderProduct.getOrderProductID());
+            if ("1".equals(orderProduct.getLadderPriceFlag())) {
+                //使用阶梯价格的订单商品保存下单时的阶梯价格列表
+                List<LadderPriceVo> ladderPriceList = productMapper.findLadderPriceByProductId(orderProduct.getProductID());
+                ladderPriceList.forEach(ladderPriceVo -> {
+                    OrderProductLadderPricePo orderProductLadderPrice = new OrderProductLadderPricePo();
+                    orderProductLadderPrice.setOrderProductId(orderProduct.getOrderProductID());
+                    orderProductLadderPrice.setBuyNum(ladderPriceVo.getBuyNum());
+                    orderProductLadderPrice.setBuyPrice(ladderPriceVo.getBuyPrice());
+                    orderProductLadderPrice.setCreateDate(new Date());
+                    orderProductLadderPrice.setLadderNum(ladderPriceVo.getLadderNum());
+                    orderProductLadderPriceList.add(orderProductLadderPrice);
+                });
+            }
+        }
+        if (!CollectionUtils.isEmpty(orderProductLadderPriceList)) {
+            orderProductLadderPriceList.forEach(ladderPrice -> {
+                orderSubmitMapper.insertOrderProductLadderPrice(ladderPrice);
+            });
+        }
+
+        /*
+         * 设置邮费子订单
+         */
+        if ("1".equals(order.getFreePostFlag())) {
+            shopOrderIds = setPostFeeShopOrder(order, shopOrderIds, orderInfo.size());
+        }
+
+        // 更新主订单信息, 子订单ID:1000,1002
+        order.setShopOrderIDs(shopOrderIds);
+        orderSubmitMapper.updateOrder(order);
+
+        /*
+         * 保存 订单用户地址
+         */
+        if (null != address) {
+            //保存地址信息
+            BpOrderUserInfoPo userInfo = new BpOrderUserInfoPo();
+            userInfo.setOrderId(order.getOrderID());
+            userInfo.setClubId(user.getClubID().longValue());
+            userInfo.setUserId(user.getUserID().longValue());
+            userInfo.setName(user.getName() == null ? user.getUserName() : user.getName());
+            userInfo.setShouHuoRen(address.getShouHuoRen());
+            userInfo.setMobile(address.getMobile());
+            userInfo.setPostalCode(address.getPhone());
+            userInfo.setPostalCode(address.getPostalCode());
+            userInfo.setTownId(address.getTownId());
+            userInfo.setProvince(address.getProvinceName());
+            userInfo.setCity(address.getCityName());
+            userInfo.setTown(address.getTownName());
+            userInfo.setAddress(address.getAddress());
+            orderSubmitMapper.insertUserInfo(userInfo);
+            log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>保存订单用户地址(insert[bp_order_userinfo])orderId:" + order.getOrderID());
+        } else {
+            //设置手动回滚事务
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            return ResponseJson.error("订单地址异常", null);
+        }
+
+        /*
+         * 保存 订单发票信息
+         */
+        if (invoiceFlag) {
+            // 开发票才保存
+            invoice.setOrderId(order.getOrderID());
+            // 查询是否存在老的增值税信息
+            BpOrderInvoicePo userInvoice = orderSubmitMapper.getOrderInvoice(order.getOrderID());
+            if (null != userInvoice) {
+                // 更新 发票信息
+                orderSubmitMapper.updateOrderInvoice(invoice);
+                log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>更新发票信息(update[bp_order_invoice])orderId:" + order.getOrderID());
+            } else {
+                //  保存 发票信息
+                orderSubmitMapper.insertOrderInvoice(invoice);
+                log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>新增发票信息(insert[bp_order_invoice])orderId:" + order.getOrderID());
+            }
+        }
+
+        log.info("******************** 提交订单逻辑处理 end *******************");
+        /*
+         * 构造返回参数
+         */
+        Map<String, String> info = new HashMap<>(5);
+        info.put("orderID", String.valueOf(order.getOrderID()));
+        info.put("orderNo", String.valueOf(order.getOrderNo()));
+        info.put("orderMark", "#" + order.getOrderID() + "#");
+        //应付订单金额
+        info.put("payTotalFee", String.valueOf(order.getPayTotalFee()));
+        //真实需要付款金额
+        info.put("payableAmount", String.valueOf(order.getPayableAmount()));
+        return ResponseJson.success(info);
+    }
+
+    /**
+     * 设置订单发票
+     *
+     * @param orderInvoice
+     * @param invoice
+     * @param invoiceType
+     * @return
+     */
+    private boolean setInvoiceParam(Map<String, Object> orderInvoice, BpOrderInvoicePo invoice, Integer invoiceType) {
+        String invoiceTitle = (String) (null != orderInvoice.get("invoiceTitle") ? orderInvoice.get("invoiceTitle") : "");
+        invoice.setInvoiceTitle(invoiceTitle);
+        if (1 == invoiceType) {
+            // 普通发票:发票类型、发票内容(商品明细)、抬头(公司名称)、纳税人识别号[普通发票的公司]
+            String invoiceContent = (String) (null != orderInvoice.get("invoiceContent") ? orderInvoice.get("invoiceContent") : "");
+            String invoiceTitleType = (null != orderInvoice.get("invoiceTitleType") ? orderInvoice.get("invoiceTitleType") : "").toString();
+            if ("".equals(invoiceTitle) || "".equals(invoiceContent) || "".equals(invoiceTitleType)) {
+                return true;
+            }
+            if ("1".equals(invoiceTitleType)) {
+                // 企业
+                String corporationTaxNum = (String) (null != orderInvoice.get("corporationTaxNum") ? orderInvoice.get("corporationTaxNum") : "");
+                if ("".equals(corporationTaxNum)) {
+                    return true;
+                }
+                invoice.setCorporationTaxNum(corporationTaxNum);
+            }
+
+            invoice.setInvoiceContent(invoiceContent);
+            invoice.setInvoiceTitleType(invoiceTitleType);
+        } else if (2 == invoiceType) {
+            // 增值税发票:发票类型、发票、抬头(公司名称)、纳税人识别号、注册地址、注册电话、开户银行、开户银行账户
+            String corporationTaxNum = (String) (null != orderInvoice.get("corporationTaxNum") ? orderInvoice.get("corporationTaxNum") : "");
+            String registeredAddress = (String) (null != orderInvoice.get("registeredAddress") ? orderInvoice.get("registeredAddress") : "");
+            String registeredPhone = (String) (null != orderInvoice.get("registeredPhone") ? orderInvoice.get("registeredPhone") : "");
+            String openBank = (String) (null != orderInvoice.get("openBank") ? orderInvoice.get("openBank") : "");
+            String bankAccountNo = (String) (null != orderInvoice.get("bankAccountNo") ? orderInvoice.get("bankAccountNo") : "");
+            boolean flag = "".equals(invoiceTitle) || "".equals(corporationTaxNum) || "".equals(registeredAddress) || "".equals(registeredPhone) || "".equals(openBank) || "".equals(bankAccountNo);
+            if (flag) {
+                return true;
+            }
+            invoice.setCorporationTaxNum(corporationTaxNum);
+            invoice.setRegisteredAddress(registeredAddress);
+            invoice.setRegisteredPhone(registeredPhone);
+            invoice.setOpenBank(openBank);
+            invoice.setBankAccountNo(bankAccountNo);
+        }
+        return false;
+    }
+
+    /**
+     * 整理订单商品数据
+     *
+     * @param productNum
+     * @param product
+     * @param productPrice
+     * @param priceType    0正常商品 1促销商品 2阶梯价 3复购价
+     * @param productType
+     * @return
+     */
+    private CmOrderProductPo setOrderProduct(Integer productNum, CmOrganizeProductPo product, BigDecimal productPrice, Integer priceType, Integer productType, BigDecimal addedValueTax) {
+        CmOrderProductPo orderProduct = new CmOrderProductPo();
+        orderProduct.setShopID(product.getShopId().longValue());
+        orderProduct.setProductID(product.getId());
+        // 预留在保存保存子订单的时候添加
+        orderProduct.setProductNo(null);
+        orderProduct.setNum(productNum);
+        orderProduct.setPresentNum(0);
+        orderProduct.setProductUnit(product.getUnit());
+        if (MathUtil.compare(product.getNormalPrice(), 0) > 0) {
+            orderProduct.setNormalPrice(product.getNormalPrice());
+        } else {
+            orderProduct.setNormalPrice(BigDecimal.ZERO);
+        }
+        orderProduct.setCostPrice(product.getCostPrice());
+        orderProduct.setPrice0(product.getPrice());
+        orderProduct.setPrice1(product.getPrice());
+        orderProduct.setTotalAmount(MathUtil.mul(product.getPrice(), productNum));
+
+        orderProduct.setDiscount(new BigDecimal(100));
+        // 经理折扣(优惠金额)
+        orderProduct.setDiscountFee(new BigDecimal(0));
+        //机构税率
+        orderProduct.setTaxRate(product.getClubTaxPoint() == null ? new BigDecimal(0) : product.getClubTaxPoint());
+        //供应商税率
+        orderProduct.setSupplierTaxRate(BigDecimal.valueOf(0));
+        orderProduct.setIncludedTax(product.getIncludedTax().toString());
+        orderProduct.setInvoiceType(product.getInvoiceType().toString());
+        BigDecimal singleShouldPayTotalTax = new BigDecimal(0);
+        if (productType == 2) {
+            //促销赠品置机构税率和供应商税率为0
+            orderProduct.setTaxRate(BigDecimal.ZERO);
+            orderProduct.setSupplierTaxRate(BigDecimal.ZERO);
+        } else {
+            //不含税可开发票商品设置税费
+            if (0 == product.getIncludedTax() && (1 == product.getInvoiceType() || 2 == product.getInvoiceType())) {
+                //供应商税费(单)=成本价 * 供应商税率
+                if (product.getShopTaxPoint() == null) {
+                    orderProduct.setSupplierTaxRate(product.getClubTaxPoint());
+                } else {
+                    orderProduct.setSupplierTaxRate(product.getShopTaxPoint());
+                }
+                singleShouldPayTotalTax = MathUtil.div(MathUtil.mul(product.getCostPrice(), orderProduct.getSupplierTaxRate()), BigDecimal.valueOf(100));
+            } else if (1 == product.getIncludedTax()) {
+                //含税商品设置供应商税率
+                if (product.getShopTaxPoint() == null) {
+                    orderProduct.setSupplierTaxRate(product.getClubTaxPoint());
+                } else {
+                    orderProduct.setSupplierTaxRate(product.getShopTaxPoint());
+                }
+            } else if ((0 == product.getIncludedTax() && 3 == product.getInvoiceType()) || 2 == product.getIncludedTax()) {
+                //不含税不可开票商品和未知商品,税率置为0
+                orderProduct.setTaxRate(BigDecimal.ZERO);
+                orderProduct.setSupplierTaxRate(BigDecimal.ZERO);
+            }
+        }
+
+        orderProduct.setAddedValueTax(addedValueTax);
+        //机构税费(总)=机构税费(单) * 商品数量
+        orderProduct.setTotalAddedValueTax(MathUtil.mul(addedValueTax, productNum));
+        orderProduct.setSingleShouldPayTotalTax(singleShouldPayTotalTax);
+        //供应商税费(总)=供应商税费(单) * 商品数量
+        orderProduct.setShouldPayTotalTax(MathUtil.mul(singleShouldPayTotalTax, productNum));
+        orderProduct.setTotalFee(MathUtil.mul(productPrice, productNum));
+        orderProduct.setShouldPayFee(MathUtil.mul(productPrice, productNum));
+
+        // 商品费=成本价快照*(购买数量  + 赠品数量)
+        orderProduct.setShopProductAmount(MathUtil.mul(product.getCostPrice(), BigDecimal.valueOf(productNum)));
+        //不含税可开票商品,单价/折后单价=售价-税费
+        if (priceType == 0 || priceType == 1) {
+            //正常价格和促销价格
+            orderProduct.setPrice(product.getPrice());
+            orderProduct.setDiscountPrice(product.getPrice());
+        } else if (priceType == 2) {
+            //阶梯价
+            BigDecimal price1 = productPrice;
+            //不含税可开票商品,单价/折后单价=售价-税费
+            if (0 == product.getIncludedTax() && (1 == product.getInvoiceType() || 2 == product.getInvoiceType())) {
+                price1 = MathUtil.sub(productPrice, orderProduct.getAddedValueTax());
+            }
+            orderProduct.setPrice(price1);
+            orderProduct.setDiscountPrice(price1);
+        }
+        //应付供应商(单)=成本价+供应商税费(单)
+        BigDecimal singleShopFee = MathUtil.add(product.getCostPrice(), singleShouldPayTotalTax);
+        orderProduct.setSingleShopFee(singleShopFee);
+        // 应付供应商(总)=应付供应商(单) * 商品数量
+        orderProduct.setShopFee(MathUtil.mul(singleShopFee, BigDecimal.valueOf(productNum)));
+        orderProduct.setOtherFee(new BigDecimal(0));
+        orderProduct.setSingleOtherFee(new BigDecimal(0));
+
+        //应付采美(单)=单价+机构税费(单)-(成本(单)+供应商税费(单))
+        BigDecimal singleCmFee = MathUtil.sub(MathUtil.add(product.getPrice(), orderProduct.getAddedValueTax()), MathUtil.add(product.getCostPrice(), singleShouldPayTotalTax));
+        orderProduct.setSingleCmFee(singleCmFee);
+        // 应付采美(总)=应付采美(单)*商品数量
+        BigDecimal cmFee = MathUtil.mul(singleCmFee, BigDecimal.valueOf(productNum));
+        orderProduct.setCmFee(cmFee);
+
+        orderProduct.setTotalBeans(new BigDecimal(0));
+        orderProduct.setUseBalanceAmount(0d);
+        // 优惠金额
+        orderProduct.setPreferential(new BigDecimal(0));
+        orderProduct.setUseBalanceAmount(0d);
+        // 订单商品供应商确认标志 0否 1是
+        orderProduct.setConfirmProductFlag("0");
+
+        orderProduct.setShopName(product.getShopName());
+        orderProduct.setName(product.getName());
+        orderProduct.setPayStatus("0");
+        orderProduct.setBuyAgainFlag("0");
+        // 未出库数量
+        orderProduct.setNotOutStore(productNum);
+        // 是否已评论 1 是 0 未评论
+        orderProduct.setCommentFlag("0");
+        orderProduct.setActPreferential(new BigDecimal(0));
+        orderProduct.setActType(null);
+
+        orderProduct.setIsActProduct(product.getActStatus().toString());
+        orderProduct.setLadderPriceFlag(product.getActStatus() == 2 ? "1" : "0");
+        orderProduct.setProductImage(ProductUtils.getImageURL("product", product.getMainImage(), 0, domain));
+        orderProduct.setProductType(productType.toString());
+        //促销赠品
+        if (productType == 2) {
+            orderProduct.setPrice0(BigDecimal.ZERO);
+            orderProduct.setPrice1(BigDecimal.ZERO);
+            orderProduct.setTotalAmount(BigDecimal.ZERO);
+            orderProduct.setTotalFee(BigDecimal.ZERO);
+            orderProduct.setDiscountPrice(BigDecimal.ZERO);
+            orderProduct.setTotalAddedValueTax(BigDecimal.ZERO);
+            orderProduct.setShouldPayTotalTax(BigDecimal.ZERO);
+        }
+        return orderProduct;
+    }
+
+    /**
+     * 计算总运费
+     *
+     * @param provinceId
+     * @param cityId
+     * @return totalPostageFee
+     */
+    public Double computedPostageFee(Integer provinceId, Integer cityId) {
+        if (202 == cityId) {
+            // 深圳市内运费10元
+            return 10d;
+        } else if (19 == provinceId) {
+            // 广东省内深圳市外运费15元
+            return 15d;
+        } else {
+            return -1d;
+        }
+    }
+
+    /**
+     * 保存子订单,并返回子订单ids
+     *
+     * @param order
+     * @param orderProductList
+     * @param shopId
+     * @param shopNote
+     * @return
+     */
+    private CmShopOrderPo saveShopOrder(CmOrderPo order, List<CmOrderProductPo> orderProductList, Integer shopId, String shopNote) {
+        /*
+         *  初始化子订单信息
+         */
+        CmShopOrderPo shopOrder = new CmShopOrderPo();
+        // 子订单编号
+        String shopOrderNo = "";
+        String maxShopOrderNo = orderSubmitMapper.findMaxShopOrderNo(order.getOrderID());
+        if (null == maxShopOrderNo || "".equals(maxShopOrderNo)) {
+            shopOrderNo = maxShopOrderNo;
+            shopOrder.setShopOrderNo(OrderNoUtils.getShopOrderNo(order.getOrderNo(), Integer.parseInt(shopOrderNo.substring(shopOrderNo.length() - 2, shopOrderNo.length())) + 1));
+        } else {
+            shopOrder.setShopOrderNo(OrderNoUtils.getShopOrderNo(order.getOrderNo(), 1));
+        }
+        shopOrder.setShopID(shopId);
+        shopOrder.setClubID(order.getClubID().intValue());
+        if (null != order.getSpID()) {
+            // 协销下单 则设置协销ID
+            shopOrder.setSpID(order.getSpID().intValue());
+            shopOrder.setMainSpID(order.getMainSpID().intValue());
+        }
+        shopOrder.setOrderID(order.getOrderID());
+        shopOrder.setOrderNo(order.getOrderNo());
+        shopOrder.setUserID(order.getUserID().intValue());
+        /*
+         *  统计子订单金额信息
+         */
+        // 订单总金额
+        BigDecimal totalAmount = new BigDecimal(0);
+        // 商品总金额
+        BigDecimal productAmount = new BigDecimal(0);
+        // 需要支付金额
+        BigDecimal needPayAmount = new BigDecimal(0);
+        // 优惠金额
+        BigDecimal preferential = new BigDecimal(0);
+        // 佣金
+        BigDecimal brokerage = new BigDecimal(0);
+        // 商品费
+        BigDecimal shopProductAmount = new BigDecimal(0);
+        // 供应商税费
+        BigDecimal shopTaxFee = new BigDecimal(0);
+        // 总购买数
+        Integer buyNum = 0;
+        // 计算子订单信息
+        for (CmOrderProductPo orderProduct : orderProductList) {
+            if (shopId.longValue() == orderProduct.getShopID()) {
+                // 商品总金额
+                productAmount = MathUtil.add(productAmount, orderProduct.getTotalAmount());
+                // 订单总金额 包括税费
+                totalAmount = MathUtil.add(totalAmount, orderProduct.getTotalFee());
+                // 应付金额
+                needPayAmount = MathUtil.add(needPayAmount, orderProduct.getShouldPayFee());
+                // 总购买数
+                buyNum += orderProduct.getNum();
+                preferential = MathUtil.add(preferential, orderProduct.getPreferential());
+                brokerage = MathUtil.add(brokerage, orderProduct.getCmFee());
+                if (null != orderProduct.getShopProductAmount()) {
+                    shopProductAmount = MathUtil.add(shopProductAmount, orderProduct.getShopProductAmount());
+                }
+                if (null != orderProduct.getShouldPayTotalTax()) {
+                    shopTaxFee = MathUtil.add(shopTaxFee, orderProduct.getShouldPayTotalTax());
+                }
+            }
+        }
+        shopOrder.setPromotionFullReduction(BigDecimal.ZERO);
+        if (MathUtil.compare(shopOrder.getPromotionFullReduction(), 0) > 0) {
+            totalAmount = MathUtil.sub(totalAmount, shopOrder.getPromotionFullReduction());
+            productAmount = MathUtil.sub(productAmount, shopOrder.getPromotionFullReduction());
+            needPayAmount = MathUtil.sub(needPayAmount, shopOrder.getPromotionFullReduction());
+        }
+
+        // freePostFlag: 0包邮 -1到付 1 有运费
+        // fee: 运费:-1到付,0包邮,其他为具体运费(v5.0版本已废弃,运费已使用商品形式存储)
+        if ("1".equals(order.getFreePostFlag())) {
+            shopOrder.setFee(0d);
+        } else {
+            shopOrder.setFee(Double.parseDouble(order.getFreePostFlag()));
+        }
+        shopOrder.setNote(shopNote);
+        shopOrder.setOrderTime(order.getOrderTime());
+        shopOrder.setDiscountFee(BigDecimal.ZERO);
+        shopOrder.setCanRefundFlag(1);
+        shopOrder.setCanRefundAmount(needPayAmount.doubleValue());
+        shopOrder.setAccountAmount(BigDecimal.ZERO);
+        // 佣金 采美应收
+        shopOrder.setBrokerage(brokerage);
+        shopOrder.setBuyStatus("1");
+        shopOrder.setPresentNum(0);
+        shopOrder.setUseBeanFlag(0);
+        shopOrder.setUseBeanAmount(0);
+        shopOrder.setUseBalanceFlag(0);
+        shopOrder.setRefundStatus(0);
+        shopOrder.setRefundsAmount(BigDecimal.ZERO);
+        shopOrder.setPayStatus("1");
+        shopOrder.setZeroCostFlag(0);
+        shopOrder.setSendOutStatus("1");
+        shopOrder.setPayFlag("0");
+        // 订单状态标识,1:非退货退款订单、2:退货退款中、3退货退款完成
+        shopOrder.setOrderStatusFlag("1");
+        shopOrder.setDelFlag("0");
+        shopOrder.setOrderBeanAmount(0);
+        // 购买商品数
+        shopOrder.setItemCount(buyNum);
+        // 普通订单 1 协销订单0 与cm_order一样
+        shopOrder.setOrderType(0);
+        shopOrder.setStatus(1);
+        shopOrder.setOrderSubmitType(order.getOrderSubmitType());
+        shopOrder.setTotalAmount(totalAmount);
+        shopOrder.setProductAmount(productAmount);
+        shopOrder.setNeedPayAmount(needPayAmount);
+        shopOrder.setPreferential(preferential);
+        shopOrder.setShopProductAmount(shopProductAmount);
+        // 付给供应商运费
+        shopOrder.setShopPostFee(BigDecimal.ZERO);
+        // 付给供应商税费
+        shopOrder.setShopTaxFee(shopTaxFee);
+        // 已付款金额
+        shopOrder.setPayedShopAmount(BigDecimal.ZERO);
+        // 付第三方
+        shopOrder.setShopOtherFee(BigDecimal.ZERO);
+        // 付供应商 = 商品费 + 运费 + 税费
+        shopOrder.setShouldPayShopAmount(MathUtil.add(shopProductAmount, shopTaxFee));
+        // 订单能否拆分 1 为可拆分, 0为不可拆分
+        if (buyNum > 1) {
+            shopOrder.setSplitFlag("1");
+        } else {
+            shopOrder.setSplitFlag("0");
+        }
+        /*
+         * 保存子订单信息到数据库
+         */
+        orderSubmitMapper.insertShopOrder(shopOrder);
+        log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>新增子订单(insert[cm_shop_order])shopOrderId:" + shopOrder.getShopOrderID());
+        return shopOrder;
+    }
+
+    /**
+     * 保存运费子订单,并返回子订单ids
+     *
+     * @param order
+     * @param num
+     * @return
+     */
+    private String setPostFeeShopOrder(CmOrderPo order, String shopOrderIds, int num) {
+        ProductPo product = productMapper.findPostFeeProduct();
+        CmShopOrderPo newShopOrder = new CmShopOrderPo();
+        String shopOrderNo = OrderNoUtils.getShopOrderNo(order.getOrderNo(), num + 1);
+        newShopOrder.setShopOrderNo(shopOrderNo);
+        newShopOrder.setOrderNo(order.getOrderNo());
+        newShopOrder.setOrderID(order.getOrderID());
+        newShopOrder.setUserID(order.getUserID().intValue());
+        newShopOrder.setOrderType(order.getOrderType());
+        newShopOrder.setOrderSubmitType(order.getOrderSubmitType());
+        newShopOrder.setPresentNum(0);
+        newShopOrder.setItemCount(1);
+        //运费商品供应商ID默认998
+        newShopOrder.setShopID(product.getShopID());
+        newShopOrder.setFee(order.getFreight().doubleValue());
+        newShopOrder.setProductAmount(order.getFreight());
+        newShopOrder.setTotalAmount(order.getFreight());
+        newShopOrder.setNeedPayAmount(order.getFreight());
+        newShopOrder.setDiscountAmount(BigDecimal.ZERO);
+        newShopOrder.setPayFlag("0");
+        newShopOrder.setOrderTime(order.getOrderTime());
+        newShopOrder.setPayStatus("1");
+        newShopOrder.setSendOutStatus("3");
+        newShopOrder.setTotalAddedValueTax(BigDecimal.ZERO);
+        newShopOrder.setCanRefundAmount(0D);
+        newShopOrder.setRefundAmount(0D);
+        newShopOrder.setRefundStatus(0);
+        newShopOrder.setClubID(order.getClubID().intValue());
+        if (null != order.getSpID()) {
+            newShopOrder.setSpID(order.getSpID().intValue());
+        }
+        if (null != order.getMainSpID()) {
+            newShopOrder.setMainSpID(order.getMainSpID().intValue());
+        }
+        newShopOrder.setAutoOverTimeMills(0L);
+        newShopOrder.setAutoReceiveTimeMills(0L);
+        newShopOrder.setOrderBeanAmount(0);
+        newShopOrder.setUseBeanFlag(0);
+        newShopOrder.setUseBeanAmount(0);
+        newShopOrder.setAccountAmount(BigDecimal.ZERO);
+        newShopOrder.setCanRefundFlag(1);
+        newShopOrder.setBuyStatus("1");
+        newShopOrder.setOutStoreNum(0);
+        newShopOrder.setDelFlag("0");
+        newShopOrder.setPayFlag("0");
+        // 订单默认可拆分
+        newShopOrder.setSplitFlag("1");
+        /*
+         * 保存子订单信息到数据库
+         */
+        orderSubmitMapper.insertShopOrder(newShopOrder);
+        log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>新增子订单(运费商品)(insert[cm_shop_order])shopOrderId:" + newShopOrder.getShopOrderID());
+
+        /*
+         * 插入订单 运费商品
+         */
+        CmOrderProductPo feeOrderProduct = new CmOrderProductPo();
+        feeOrderProduct.setProductType("0");
+        feeOrderProduct.setOrderNo(order.getOrderNo());
+        feeOrderProduct.setOrderID(order.getOrderID());
+        feeOrderProduct.setShopOrderID(newShopOrder.getShopOrderID());
+        feeOrderProduct.setShopOrderNo(newShopOrder.getShopOrderNo());
+        feeOrderProduct.setShopID(product.getShopID().longValue());
+        feeOrderProduct.setProductID(999);
+        feeOrderProduct.setNum(1);
+        feeOrderProduct.setPresentNum(0);
+        feeOrderProduct.setOutStoreType("0");
+        feeOrderProduct.setProps(product.getProps());
+        feeOrderProduct.setProductNo(product.getProductCode());
+        feeOrderProduct.setPrice(order.getFreight());
+        feeOrderProduct.setNormalPrice(order.getFreight());
+        feeOrderProduct.setPrice0(order.getFreight());
+        feeOrderProduct.setPrice1(order.getFreight());
+        feeOrderProduct.setTotalAmount(order.getFreight());
+        feeOrderProduct.setTotalFee(order.getFreight());
+        feeOrderProduct.setShouldPayFee(order.getFreight());
+        feeOrderProduct.setDiscount(new BigDecimal(100));
+        feeOrderProduct.setDiscountPrice(order.getFreight());
+        feeOrderProduct.setTaxRate(new BigDecimal(100));
+        feeOrderProduct.setAddedValueTax(order.getFreight());
+        feeOrderProduct.setTotalAddedValueTax(BigDecimal.ZERO);
+        feeOrderProduct.setShopFee(BigDecimal.ZERO);
+        feeOrderProduct.setOtherFee(BigDecimal.ZERO);
+        feeOrderProduct.setCmFee(order.getFreight());
+        feeOrderProduct.setSingleShopFee(BigDecimal.ZERO);
+        feeOrderProduct.setSingleOtherFee(BigDecimal.ZERO);
+        feeOrderProduct.setSingleCmFee(order.getFreight());
+        feeOrderProduct.setTotalBeans(BigDecimal.ZERO);
+        feeOrderProduct.setUseBalanceAmount(0D);
+        feeOrderProduct.setUseBeanAmount(0);
+        feeOrderProduct.setNotOutStore(0);
+        feeOrderProduct.setCmbeanPrice(0);
+        feeOrderProduct.setBuyAgainFlag("0");
+        feeOrderProduct.setShopName(product.getShopName());
+        feeOrderProduct.setName(product.getName());
+        feeOrderProduct.setIncludedTax(product.getIncludedTax());
+        feeOrderProduct.setInvoiceType(product.getInvoiceType());
+        // 保存订单商品数据
+        orderSubmitMapper.insertOrderProduct(feeOrderProduct);
+        log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>保存订单运费商品(insert[cm_order_product])orderId:" + feeOrderProduct.getOrderProductID());
+
+        shopOrderIds += (("".equals(shopOrderIds) ? "" : ",") + newShopOrder.getShopOrderID());
+        return shopOrderIds;
+    }
 }

+ 71 - 0
src/main/java/com/caimei/util/OrderNoUtils.java

@@ -0,0 +1,71 @@
+package com.caimei.util;
+
+
+import java.util.Random;
+
+/**
+ * 订单编号
+ *
+ * @author : Charles
+ * @date : 2020/3/19
+ */
+public class OrderNoUtils {
+    /**
+     * 订单模块生成新订单号
+     *
+     * @param platform
+     * @return
+     */
+    public static String getOrderNo(String platform) {
+        Random rand = new Random();
+        String code = "";
+        for (int j = 0; j < 5; j++) {
+            code += rand.nextInt(10) + "";
+        }
+        return platform + System.currentTimeMillis() / 1000 + code;
+    }
+
+
+    /***
+     * 子订单编号生成
+     * @param orderNo
+     * @param num
+     * @return
+     */
+    public static String getShopOrderNo(String orderNo, Integer num) {
+        if (num < 10) {
+            return orderNo + "0" + num;
+        } else {
+            return orderNo + num;
+        }
+    }
+
+    /**
+     * 根据订单列表类型获取订单状态
+     *
+     * @param listType
+     * @return status
+     */
+    public static int[] getStatusByListType(Integer listType) {
+        // listType:列表类型(1:待确认,2:待支付,3:待发货,4:已发货,5:退货退款)
+        switch (listType) {
+            case 1:
+                // status待确认(0)
+                return new int[]{0};
+            case 2:
+                // status待支付(21,22,23,11,12,13)
+                return new int[]{21, 22, 23, 11, 12, 13};
+            case 3:
+                // status待发货(11,12,21,22,31,32),
+                return new int[]{11, 12, 21, 22, 31, 32};
+            case 4:
+                // status已发货(12,13,22,23,32,33),
+                return new int[]{12, 13, 22, 23, 32, 33};
+            case 5:
+                // status退货退款(1,2)
+                return new int[]{1, 2, 7};
+            default:
+                return null;
+        }
+    }
+}

+ 1681 - 0
src/main/resources/mapper/OrderSubmitMapper.xml

@@ -93,4 +93,1685 @@
         WHERE
           shopID = #{shopId}
     </select>
+
+    <select id="findUser" resultType="com.caimei.model.po.UserPo">
+        SELECT
+          userID,
+          userOrganizeID,
+          mobile,
+          bindMobile,
+          userName,
+          realName,
+          name
+        FROM
+          user
+        WHERE
+          userID = #{userId}
+    </select>
+
+    <insert id="insertOrder" keyColumn="orderID" keyProperty="orderID" parameterType="com.caimei.model.po.CmOrderPo" useGeneratedKeys="true">
+        insert into cm_order
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="orderNo != null">
+                orderNo,
+            </if>
+            <if test="userID != null">
+                userID,
+            </if>
+            <if test="buyUserID != null">
+                buyUserID,
+            </if>
+            <if test="shopOrderIDs != null">
+                shopOrderIDs,
+            </if>
+            <if test="orderSubmitType != null">
+                orderSubmitType,
+            </if>
+            <if test="orderType != null">
+                orderType,
+            </if>
+            <if test="secondHandOrderFlag != null">
+                secondHandOrderFlag,
+            </if>
+            <if test="hasActProduct != null">
+                hasActProduct,
+            </if>
+            <if test="autoCloseTimeMills != null">
+                autoCloseTimeMills,
+            </if>
+            <if test="status != null">
+                `status`,
+            </if>
+            <if test="receiptStatus != null">
+                receiptStatus,
+            </if>
+            <if test="payStatus != null">
+                payStatus,
+            </if>
+            <if test="sendOutStatus != null">
+                sendOutStatus,
+            </if>
+            <if test="refundType != null">
+                refundType,
+            </if>
+            <if test="payFlag != null">
+                payFlag,
+            </if>
+            <if test="onlinePayFlag != null">
+                onlinePayFlag,
+            </if>
+            <if test="productTotalFee != null">
+                productTotalFee,
+            </if>
+            <if test="orderTotalFee != null">
+                orderTotalFee,
+            </if>
+            <if test="payTotalFee != null">
+                payTotalFee,
+            </if>
+            <if test="payableAmount != null">
+                payableAmount,
+            </if>
+            <if test="balancePayFee != null">
+                balancePayFee,
+            </if>
+            <if test="preferential != null">
+                preferential,
+            </if>
+            <if test="discountFee != null">
+                discountFee,
+            </if>
+            <if test="promotionFullReduction != null">
+                promotionFullReduction,
+            </if>
+            <if test="spID != null">
+                spID,
+            </if>
+            <if test="mainSpID != null">
+                mainSpID,
+            </if>
+            <if test="note != null">
+                note,
+            </if>
+            <if test="clubID != null">
+                clubID,
+            </if>
+            <if test="clubScanTime != null">
+                clubScanTime,
+            </if>
+            <if test="payWay != null">
+                payWay,
+            </if>
+            <if test="orderSource != null">
+                orderSource,
+            </if>
+            <if test="closeTime != null">
+                closeTime,
+            </if>
+            <if test="confirmTime != null">
+                confirmTime,
+            </if>
+            <if test="payTime != null">
+                payTime,
+            </if>
+            <if test="orderTime != null">
+                orderTime,
+            </if>
+            <if test="productCount != null">
+                productCount,
+            </if>
+            <if test="presentCount != null">
+                presentCount,
+            </if>
+            <if test="promotionalGiftsCount != null">
+                promotionalGiftsCount,
+            </if>
+            <if test="cooFreeFlag != null">
+                cooFreeFlag,
+            </if>
+            <if test="cooFreeRate != null">
+                cooFreeRate,
+            </if>
+            <if test="cooFreeAmount != null">
+                cooFreeAmount,
+            </if>
+            <if test="invoiceFlag != null">
+                invoiceFlag,
+            </if>
+            <if test="confirmFlag != null">
+                confirmFlag,
+            </if>
+            <if test="clauseID != null">
+                clauseID,
+            </if>
+            <if test="clauseContent != null">
+                clauseContent,
+            </if>
+            <if test="clauseName != null">
+                clauseName,
+            </if>
+            <if test="updateDate != null">
+                updateDate,
+            </if>
+            <if test="freePostFlag != null">
+                freePostFlag,
+            </if>
+            <if test="freight != null">
+                freight,
+            </if>
+            <if test="delFlag != null">
+                delFlag,
+            </if>
+            <if test="freePostageTicketID != null">
+                freePostageTicketID,
+            </if>
+            <if test="splitFlag != null">
+                splitFlag,
+            </if>
+            <if test="closeReason != null">
+                closeReason,
+            </if>
+            <if test="postageOrderFlag != null">
+                postageOrderFlag,
+            </if>
+            <if test="thirdPartyOrderNo != null">
+                thirdPartyOrderNo,
+            </if>
+            <if test="affirmPaymentFlag != null">
+                affirmPaymentFlag,
+            </if>
+            <if test="rebateFlag != null">
+                rebateFlag,
+            </if>
+            <if test="zeroCostFlag != null">
+                zeroCostFlag,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="orderNo != null">
+                #{orderNo,jdbcType=VARCHAR},
+            </if>
+            <if test="userID != null">
+                #{userID,jdbcType=BIGINT},
+            </if>
+            <if test="buyUserID != null">
+                #{buyUserID,jdbcType=INTEGER},
+            </if>
+            <if test="shopOrderIDs != null">
+                #{shopOrderIDs,jdbcType=VARCHAR},
+            </if>
+            <if test="orderSubmitType != null">
+                #{orderSubmitType,jdbcType=INTEGER},
+            </if>
+            <if test="orderType != null">
+                #{orderType,jdbcType=INTEGER},
+            </if>
+            <if test="secondHandOrderFlag != null">
+                #{secondHandOrderFlag,jdbcType=VARCHAR},
+            </if>
+            <if test="hasActProduct != null">
+                #{hasActProduct,jdbcType=CHAR},
+            </if>
+            <if test="autoCloseTimeMills != null">
+                #{autoCloseTimeMills,jdbcType=DECIMAL},
+            </if>
+            <if test="status != null">
+                #{status,jdbcType=CHAR},
+            </if>
+            <if test="receiptStatus != null">
+                #{receiptStatus,jdbcType=CHAR},
+            </if>
+            <if test="payStatus != null">
+                #{payStatus,jdbcType=CHAR},
+            </if>
+            <if test="sendOutStatus != null">
+                #{sendOutStatus,jdbcType=CHAR},
+            </if>
+            <if test="refundType != null">
+                #{refundType,jdbcType=CHAR},
+            </if>
+            <if test="payFlag != null">
+                #{payFlag,jdbcType=CHAR},
+            </if>
+            <if test="onlinePayFlag != null">
+                #{onlinePayFlag,jdbcType=CHAR},
+            </if>
+            <if test="productTotalFee != null">
+                #{productTotalFee,jdbcType=DECIMAL},
+            </if>
+            <if test="orderTotalFee != null">
+                #{orderTotalFee,jdbcType=DECIMAL},
+            </if>
+            <if test="payTotalFee != null">
+                #{payTotalFee,jdbcType=DECIMAL},
+            </if>
+            <if test="payableAmount != null">
+                #{payableAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="balancePayFee != null">
+                #{balancePayFee,jdbcType=DECIMAL},
+            </if>
+            <if test="preferential != null">
+                #{preferential,jdbcType=DECIMAL},
+            </if>
+            <if test="discountFee != null">
+                #{discountFee,jdbcType=DECIMAL},
+            </if>
+            <if test="promotionFullReduction != null">
+                #{promotionFullReduction,jdbcType=DECIMAL},
+            </if>
+            <if test="spID != null">
+                #{spID,jdbcType=BIGINT},
+            </if>
+            <if test="mainSpID != null">
+                #{mainSpID,jdbcType=BIGINT},
+            </if>
+            <if test="note != null">
+                #{note,jdbcType=VARCHAR},
+            </if>
+            <if test="clubID != null">
+                #{clubID,jdbcType=BIGINT},
+            </if>
+            <if test="clubScanTime != null">
+                #{clubScanTime,jdbcType=VARCHAR},
+            </if>
+            <if test="payWay != null">
+                #{payWay,jdbcType=VARCHAR},
+            </if>
+            <if test="orderSource != null">
+                #{orderSource,jdbcType=CHAR},
+            </if>
+            <if test="closeTime != null">
+                #{closeTime,jdbcType=VARCHAR},
+            </if>
+            <if test="confirmTime != null">
+                #{confirmTime,jdbcType=VARCHAR},
+            </if>
+            <if test="payTime != null">
+                #{payTime,jdbcType=VARCHAR},
+            </if>
+            <if test="orderTime != null">
+                #{orderTime,jdbcType=VARCHAR},
+            </if>
+            <if test="productCount != null">
+                #{productCount,jdbcType=INTEGER},
+            </if>
+            <if test="presentCount != null">
+                #{presentCount,jdbcType=INTEGER},
+            </if>
+            <if test="promotionalGiftsCount != null">
+                #{promotionalGiftsCount,jdbcType=INTEGER},
+            </if>
+            <if test="cooFreeFlag != null">
+                #{cooFreeFlag,jdbcType=CHAR},
+            </if>
+            <if test="cooFreeRate != null">
+                #{cooFreeRate,jdbcType=INTEGER},
+            </if>
+            <if test="cooFreeAmount != null">
+                #{cooFreeAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="invoiceFlag != null">
+                #{invoiceFlag,jdbcType=CHAR},
+            </if>
+            <if test="confirmFlag != null">
+                #{confirmFlag,jdbcType=CHAR},
+            </if>
+            <if test="clauseID != null">
+                #{clauseID,jdbcType=BIGINT},
+            </if>
+            <if test="clauseContent != null">
+                #{clauseContent,jdbcType=VARCHAR},
+            </if>
+            <if test="clauseName != null">
+                #{clauseName,jdbcType=VARCHAR},
+            </if>
+            <if test="updateDate != null">
+                #{updateDate,jdbcType=VARCHAR},
+            </if>
+            <if test="freePostFlag != null">
+                #{freePostFlag,jdbcType=CHAR},
+            </if>
+            <if test="freight != null">
+                #{freight,jdbcType=DECIMAL},
+            </if>
+            <if test="delFlag != null">
+                #{delFlag,jdbcType=CHAR},
+            </if>
+            <if test="freePostageTicketID != null">
+                #{freePostageTicketID,jdbcType=INTEGER},
+            </if>
+            <if test="splitFlag != null">
+                #{splitFlag,jdbcType=CHAR},
+            </if>
+            <if test="closeReason != null">
+                #{closeReason,jdbcType=VARCHAR},
+            </if>
+            <if test="postageOrderFlag != null">
+                #{postageOrderFlag,jdbcType=CHAR},
+            </if>
+            <if test="thirdPartyOrderNo != null">
+                #{thirdPartyOrderNo,jdbcType=CHAR},
+            </if>
+            <if test="affirmPaymentFlag != null">
+                #{affirmPaymentFlag,jdbcType=CHAR},
+            </if>
+            <if test="rebateFlag != null">
+                #{rebateFlag,jdbcType=CHAR},
+            </if>
+            <if test="zeroCostFlag != null">
+                #{zeroCostFlag,jdbcType=INTEGER},
+            </if>
+        </trim>
+    </insert>
+
+    <insert id="insertOrderPromotions" keyColumn="id" keyProperty="id" 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>
+
+    <select id="findOrderPromotions" resultType="com.caimei.model.po.PromotionsPo">
+        SELECT
+          id,
+          name,
+          description,
+          orderId,
+          type,
+          mode,
+          touchPrice,
+          reducedPrice,
+          beginTime,
+          endTime,
+          status
+        FROM
+          cm_promotions_order
+        WHERE
+          orderId = #{orderId}
+          AND promotionsId = #{promotionsId}
+    </select>
+
+    <select id="findMaxShopOrderNo" resultType="java.lang.String">
+        SELECT shopOrderNo
+        FROM cm_shop_order
+        WHERE orderID IS NOT NULL
+        ORDER BY shopOrderNo DESC
+        LIMIT 1
+    </select>
+
+    <insert id="insertShopOrder" keyColumn="shopOrderID" keyProperty="shopOrderID" parameterType="com.caimei.model.po.CmShopOrderPo" useGeneratedKeys="true">
+        insert into cm_shop_order
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="shopOrderNo != null">
+                shopOrderNo,
+            </if>
+            <if test="orderNo != null">
+                orderNo,
+            </if>
+            <if test="orderID != null">
+                orderID,
+            </if>
+            <if test="organizeID != null">
+                organizeID,
+            </if>
+            <if test="userID != null">
+                userID,
+            </if>
+            <if test="shopID != null">
+                shopID,
+            </if>
+            <if test="orderPromotionsId != null">
+                orderPromotionsId,
+            </if>
+            <if test="orderType != null">
+                orderType,
+            </if>
+            <if test="orderSubmitType != null">
+                orderSubmitType,
+            </if>
+            <if test="presentNum != null">
+                presentNum,
+            </if>
+            <if test="itemCount != null">
+                itemCount,
+            </if>
+            <if test="outStoreNum != null">
+                outStoreNum,
+            </if>
+            <if test="outStoreTimes != null">
+                outStoreTimes,
+            </if>
+            <if test="townID != null">
+                townID,
+            </if>
+            <if test="note != null">
+                note,
+            </if>
+            <if test="fee != null">
+                fee,
+            </if>
+            <if test="accountAmount != null">
+                accountAmount,
+            </if>
+            <if test="productAmount != null">
+                productAmount,
+            </if>
+            <if test="totalAmount != null">
+                totalAmount,
+            </if>
+            <if test="needPayAmount != null">
+                needPayAmount,
+            </if>
+            <if test="discountAmount != null">
+                discountAmount,
+            </if>
+            <if test="discountFee != null">
+                discountFee,
+            </if>
+            <if test="preferential != null">
+                preferential,
+            </if>
+            <if test="promotionFullReduction != null">
+                promotionFullReduction,
+            </if>
+            <if test="payFlag != null">
+                payFlag,
+            </if>
+            <if test="orderTime != null">
+                orderTime,
+            </if>
+            <if test="payTime != null">
+                payTime,
+            </if>
+            <if test="finishTime != null">
+                finishTime,
+            </if>
+            <if test="autoOverTimeMills != null">
+                autoOverTimeMills,
+            </if>
+            <if test="status != null">
+                `status`,
+            </if>
+            <if test="payStatus != null">
+                payStatus,
+            </if>
+            <if test="sendOutStatus != null">
+                sendOutStatus,
+            </if>
+            <if test="refundStatus != null">
+                refundStatus,
+            </if>
+            <if test="returnGoodsStatus != null">
+                returnGoodsStatus,
+            </if>
+            <if test="receiveGoodsTime != null">
+                receiveGoodsTime,
+            </if>
+            <if test="autoReceiveTimeMills != null">
+                autoReceiveTimeMills,
+            </if>
+            <if test="totalAddedValueTax != null">
+                totalAddedValueTax,
+            </if>
+            <if test="canRefundAmount != null">
+                canRefundAmount,
+            </if>
+            <if test="refundAmount != null">
+                refundAmount,
+            </if>
+            <if test="clubID != null">
+                clubID,
+            </if>
+            <if test="spID != null">
+                spID,
+            </if>
+            <if test="mainSpID != null">
+                mainSpID,
+            </if>
+            <if test="orderBeanAmount != null">
+                orderBeanAmount,
+            </if>
+            <if test="useBeanAmount != null">
+                useBeanAmount,
+            </if>
+            <if test="useBeanFlag != null">
+                useBeanFlag,
+            </if>
+            <if test="canRefundFlag != null">
+                canRefundFlag,
+            </if>
+            <if test="useBalanceFlag != null">
+                useBalanceFlag,
+            </if>
+            <if test="canRefundBeans != null">
+                canRefundBeans,
+            </if>
+            <if test="freePostageFee != null">
+                freePostageFee,
+            </if>
+            <if test="freePostageTicketID != null">
+                freePostageTicketID,
+            </if>
+            <if test="brokerage != null">
+                brokerage,
+            </if>
+            <if test="delFlag != null">
+                delFlag,
+            </if>
+            <if test="refundsAmount != null">
+                refundsAmount,
+            </if>
+            <if test="orderStatusFlag != null">
+                orderStatusFlag,
+            </if>
+            <if test="buyStatus != null">
+                buyStatus,
+            </if>
+            <if test="deliveryTimeMills != null">
+                deliveryTimeMills,
+            </if>
+            <if test="orderDeliveryID != null">
+                orderDeliveryID,
+            </if>
+            <if test="splitFlag != null">
+                splitFlag,
+            </if>
+            <if test="receiptedFlag != null">
+                receiptedFlag,
+            </if>
+            <if test="receiptedType != null">
+                receiptedType,
+            </if>
+            <if test="paying != null">
+                paying,
+            </if>
+            <if test="shopProductAmount != null">
+                shopProductAmount,
+            </if>
+            <if test="shopPostFee != null">
+                shopPostFee,
+            </if>
+            <if test="shopTaxFee != null">
+                shopTaxFee,
+            </if>
+            <if test="shouldPayShopAmount != null">
+                shouldPayShopAmount,
+            </if>
+            <if test="payedShopAmount != null">
+                payedShopAmount,
+            </if>
+            <if test="shopOtherFee != null">
+                shopOtherFee,
+            </if>
+            <if test="refunding != null">
+                refunding,
+            </if>
+            <if test="costType != null">
+                costType,
+            </if>
+            <if test="proportional != null">
+                proportional,
+            </if>
+            <if test="modifyShouldPayNote != null">
+                modifyShouldPayNote,
+            </if>
+            <if test="modifyShouldPayUserID != null">
+                modifyShouldPayUserID,
+            </if>
+            <if test="modifyShouldPayDate != null">
+                modifyShouldPayDate,
+            </if>
+            <if test="zeroCostFlag != null">
+                zeroCostFlag,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="shopOrderNo != null">
+                #{shopOrderNo,jdbcType=VARCHAR},
+            </if>
+            <if test="orderNo != null">
+                #{orderNo,jdbcType=VARCHAR},
+            </if>
+            <if test="orderID != null">
+                #{orderID,jdbcType=BIGINT},
+            </if>
+            <if test="organizeID != null">0,</if>
+            <if test="userID != null">
+                #{userID,jdbcType=INTEGER},
+            </if>
+            <if test="shopID != null">
+                #{shopID,jdbcType=INTEGER},
+            </if>
+            <if test="orderPromotionsId != null">
+                #{orderPromotionsId},
+            </if>
+            <if test="orderType != null">
+                #{orderType,jdbcType=INTEGER},
+            </if>
+            <if test="orderSubmitType != null">
+                #{orderSubmitType,jdbcType=INTEGER},
+            </if>
+            <if test="presentNum != null">
+                #{presentNum,jdbcType=INTEGER},
+            </if>
+            <if test="itemCount != null">
+                #{itemCount,jdbcType=INTEGER},
+            </if>
+            <if test="outStoreNum != null">
+                #{outStoreNum,jdbcType=INTEGER},
+            </if>
+            <if test="outStoreTimes != null">
+                #{outStoreTimes,jdbcType=INTEGER},
+            </if>
+            <if test="townID != null">
+                #{townID,jdbcType=INTEGER},
+            </if>
+            <if test="note != null">
+                #{note,jdbcType=VARCHAR},
+            </if>
+            <if test="fee != null">
+                #{fee,jdbcType=FLOAT},
+            </if>
+            <if test="accountAmount != null">
+                #{accountAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="productAmount != null">
+                #{productAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="totalAmount != null">
+                #{totalAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="needPayAmount != null">
+                #{needPayAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="discountAmount != null">
+                #{discountAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="discountFee != null">
+                #{discountFee,jdbcType=DECIMAL},
+            </if>
+            <if test="preferential != null">
+                #{preferential,jdbcType=DECIMAL},
+            </if>
+            <if test="promotionFullReduction != null">
+                #{promotionFullReduction},
+            </if>
+            <if test="payFlag != null">
+                #{payFlag,jdbcType=CHAR},
+            </if>
+            <if test="orderTime != null">
+                #{orderTime,jdbcType=VARCHAR},
+            </if>
+            <if test="payTime != null">
+                #{payTime,jdbcType=VARCHAR},
+            </if>
+            <if test="finishTime != null">
+                #{finishTime,jdbcType=VARCHAR},
+            </if>
+            <if test="autoOverTimeMills != null">
+                #{autoOverTimeMills,jdbcType=BIGINT},
+            </if>
+            <if test="status != null">
+                #{status,jdbcType=INTEGER},
+            </if>
+            <if test="payStatus != null">
+                #{payStatus,jdbcType=CHAR},
+            </if>
+            <if test="sendOutStatus != null">
+                #{sendOutStatus,jdbcType=CHAR},
+            </if>
+            <if test="refundStatus != null">
+                #{refundStatus,jdbcType=INTEGER},
+            </if>
+            <if test="returnGoodsStatus != null">
+                #{returnGoodsStatus,jdbcType=INTEGER},
+            </if>
+            <if test="receiveGoodsTime != null">
+                #{receiveGoodsTime,jdbcType=VARCHAR},
+            </if>
+            <if test="autoReceiveTimeMills != null">
+                #{autoReceiveTimeMills,jdbcType=BIGINT},
+            </if>
+            <if test="totalAddedValueTax != null">
+                #{totalAddedValueTax,jdbcType=DECIMAL},
+            </if>
+            <if test="canRefundAmount != null">
+                #{canRefundAmount,jdbcType=FLOAT},
+            </if>
+            <if test="refundAmount != null">
+                #{refundAmount,jdbcType=FLOAT},
+            </if>
+            <if test="clubID != null">
+                #{clubID,jdbcType=INTEGER},
+            </if>
+            <if test="spID != null">
+                #{spID,jdbcType=INTEGER},
+            </if>
+            <if test="mainSpID != null">
+                #{mainSpID,jdbcType=INTEGER},
+            </if>
+            <if test="orderBeanAmount != null">
+                #{orderBeanAmount,jdbcType=INTEGER},
+            </if>
+            <if test="useBeanAmount != null">
+                #{useBeanAmount,jdbcType=INTEGER},
+            </if>
+            <if test="useBeanFlag != null">
+                #{useBeanFlag,jdbcType=INTEGER},
+            </if>
+            <if test="canRefundFlag != null">
+                #{canRefundFlag,jdbcType=INTEGER},
+            </if>
+            <if test="useBalanceFlag != null">
+                #{useBalanceFlag,jdbcType=INTEGER},
+            </if>
+            <if test="canRefundBeans != null">
+                #{canRefundBeans,jdbcType=INTEGER},
+            </if>
+            <if test="freePostageFee != null">
+                #{freePostageFee,jdbcType=DECIMAL},
+            </if>
+            <if test="freePostageTicketID != null">
+                #{freePostageTicketID,jdbcType=INTEGER},
+            </if>
+            <if test="brokerage != null">
+                #{brokerage,jdbcType=DECIMAL},
+            </if>
+            <if test="delFlag != null">
+                #{delFlag,jdbcType=VARCHAR},
+            </if>
+            <if test="refundsAmount != null">
+                #{refundsAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="orderStatusFlag != null">
+                #{orderStatusFlag,jdbcType=CHAR},
+            </if>
+            <if test="buyStatus != null">
+                #{buyStatus,jdbcType=VARCHAR},
+            </if>
+            <if test="deliveryTimeMills != null">
+                #{deliveryTimeMills,jdbcType=VARCHAR},
+            </if>
+            <if test="orderDeliveryID != null">
+                #{orderDeliveryID,jdbcType=INTEGER},
+            </if>
+            <if test="splitFlag != null">
+                #{splitFlag,jdbcType=CHAR},
+            </if>
+            <if test="receiptedFlag != null">
+                #{receiptedFlag,jdbcType=VARCHAR},
+            </if>
+            <if test="receiptedType != null">
+                #{receiptedType,jdbcType=VARCHAR},
+            </if>
+            <if test="paying != null">
+                #{paying,jdbcType=CHAR},
+            </if>
+            <if test="shopProductAmount != null">
+                #{shopProductAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="shopPostFee != null">
+                #{shopPostFee,jdbcType=DECIMAL},
+            </if>
+            <if test="shopTaxFee != null">
+                #{shopTaxFee,jdbcType=DECIMAL},
+            </if>
+            <if test="shouldPayShopAmount != null">
+                #{shouldPayShopAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="payedShopAmount != null">
+                #{payedShopAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="shopOtherFee != null">
+                #{shopOtherFee,jdbcType=DECIMAL},
+            </if>
+            <if test="refunding != null">
+                #{refunding,jdbcType=CHAR},
+            </if>
+            <if test="costType != null">
+                #{costType,jdbcType=CHAR},
+            </if>
+            <if test="proportional != null">
+                #{proportional,jdbcType=DECIMAL},
+            </if>
+            <if test="modifyShouldPayNote != null">
+                #{modifyShouldPayNote,jdbcType=VARCHAR},
+            </if>
+            <if test="modifyShouldPayUserID != null">
+                #{modifyShouldPayUserID,jdbcType=BIGINT},
+            </if>
+            <if test="modifyShouldPayDate != null">
+                #{modifyShouldPayDate,jdbcType=TIMESTAMP},
+            </if>
+            <if test="zeroCostFlag != null">
+                #{zeroCostFlag,jdbcType=INTEGER},
+            </if>
+        </trim>
+    </insert>
+
+    <insert id="insertOrderProduct" keyColumn="orderProductID" keyProperty="orderProductID" parameterType="com.caimei.model.po.CmOrderProductPo" useGeneratedKeys="true">
+        insert into cm_order_product
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="orderNo != null">
+                orderNo,
+            </if>
+            <if test="orderID != null">
+                orderID,
+            </if>
+            <if test="shopOrderID != null">
+                shopOrderID,
+            </if>
+            <if test="shopOrderNo != null">
+                shopOrderNo,
+            </if>
+            <if test="shopID != null">
+                shopID,
+            </if>
+            <if test="productID != null">
+                productID,
+            </if>
+            <if test="organizeProductID != null">
+                organizeProductID,
+            </if>
+            <if test="organizeID != null">
+                organizeID,
+            </if>
+            <if test="num != null">
+                num,
+            </if>
+            <if test="presentNum != null">
+                presentNum,
+            </if>
+            <if test="outStoreType != null">
+                outStoreType,
+            </if>
+            <if test="skuID != null">
+                skuID,
+            </if>
+            <if test="props != null">
+                props,
+            </if>
+            <if test="propName != null">
+                propName,
+            </if>
+            <if test="productNo != null">
+                productNo,
+            </if>
+            <if test="price != null">
+                price,
+            </if>
+            <if test="normalPrice != null">
+                normalPrice,
+            </if>
+            <if test="costPrice != null">
+                costPrice,
+            </if>
+            <if test="price0 != null">
+                price0,
+            </if>
+            <if test="price1 != null">
+                price1,
+            </if>
+            <if test="totalAmount != null">
+                totalAmount,
+            </if>
+            <if test="totalFee != null">
+                totalFee,
+            </if>
+            <if test="shouldPayFee != null">
+                shouldPayFee,
+            </if>
+            <if test="discount != null">
+                discount,
+            </if>
+            <if test="discountPrice != null">
+                discountPrice,
+            </if>
+            <if test="taxRate != null">
+                taxRate,
+            </if>
+            <if test="addedValueTax != null">
+                addedValueTax,
+            </if>
+            <if test="totalAddedValueTax != null">
+                totalAddedValueTax,
+            </if>
+            <if test="shouldPayTotalTax != null">
+                shouldPayTotalTax,
+            </if>
+            <if test="singleShouldPayTotalTax != null">
+                singleShouldPayTotalTax,
+            </if>
+            <if test="shopProductAmount != null">
+                shopProductAmount,
+            </if>
+            <if test="shopFee != null">
+                shopFee,
+            </if>
+            <if test="otherFee != null">
+                otherFee,
+            </if>
+            <if test="cmFee != null">
+                cmFee,
+            </if>
+            <if test="singleShopFee != null">
+                singleShopFee,
+            </if>
+            <if test="singleOtherFee != null">
+                singleOtherFee,
+            </if>
+            <if test="singleCmFee != null">
+                singleCmFee,
+            </if>
+            <if test="status != null">
+                `status`,
+            </if>
+            <if test="commentFlag != null">
+                commentFlag,
+            </if>
+            <if test="totalBeans != null">
+                totalBeans,
+            </if>
+            <if test="useBalanceAmount != null">
+                useBalanceAmount,
+            </if>
+            <if test="useBeanAmount != null">
+                useBeanAmount,
+            </if>
+            <if test="notOutStore != null">
+                notOutStore,
+            </if>
+            <if test="cmbeanPrice != null">
+                cmbeanPrice,
+            </if>
+            <if test="isActProduct != null">
+                isActProduct,
+            </if>
+            <if test="isGiftProduct != null">
+                isGiftProduct,
+            </if>
+            <if test="productActInfo != null">
+                productActInfo,
+            </if>
+            <if test="buyAgainFlag != null">
+                buyAgainFlag,
+            </if>
+            <if test="confirmProductFlag != null">
+                confirmProductFlag,
+            </if>
+            <if test="payStatus != null">
+                payStatus,
+            </if>
+            <if test="shopName != null">
+                shopName,
+            </if>
+            <if test="name != null">
+                `name`,
+            </if>
+            <if test="productUnit != null">
+                productUnit,
+            </if>
+            <if test="productImage != null">
+                productImage,
+            </if>
+            <if test="actType != null">
+                actType,
+            </if>
+            <if test="actPreferential != null">
+                actPreferential,
+            </if>
+            <if test="productType != null">
+                productType,
+            </if>
+            <if test="orderPromotionsId != null">
+                orderPromotionsId,
+            </if>
+            <if test="preferential != null">
+                preferential,
+            </if>
+            <if test="discountFee != null">
+                discountFee,
+            </if>
+            <if test="cancelNum != null">
+                cancelNum,
+            </if>
+            <if test="supplierTaxRate != null">
+                supplierTaxRate,
+            </if>
+            <if test="includedTax != null">
+                includedTax,
+            </if>
+            <if test="invoiceType != null">
+                invoiceType,
+            </if>
+            <if test="ladderPriceFlag != null">
+                ladderPriceFlag,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="orderNo != null">
+                #{orderNo,jdbcType=VARCHAR},
+            </if>
+            <if test="orderID != null">
+                #{orderID,jdbcType=BIGINT},
+            </if>
+            <if test="shopOrderID != null">
+                #{shopOrderID,jdbcType=INTEGER},
+            </if>
+            <if test="shopOrderNo != null">
+                #{shopOrderNo,jdbcType=VARCHAR},
+            </if>
+            <if test="shopID != null">
+                #{shopID,jdbcType=BIGINT},
+            </if>
+            <if test="productID != null">
+                #{productID,jdbcType=INTEGER},
+            </if>
+            <if test="organizeProductID != null">
+                #{organizeProductID,jdbcType=INTEGER},
+            </if>
+            <if test="organizeID != null">0,</if>
+            <if test="num != null">
+                #{num,jdbcType=INTEGER},
+            </if>
+            <if test="presentNum != null">
+                #{presentNum,jdbcType=INTEGER},
+            </if>
+            <if test="outStoreType != null">
+                #{outStoreType,jdbcType=CHAR},
+            </if>
+            <if test="skuID != null">
+                #{skuID,jdbcType=INTEGER},
+            </if>
+            <if test="props != null">
+                #{props,jdbcType=VARCHAR},
+            </if>
+            <if test="propName != null">
+                #{propName,jdbcType=VARCHAR},
+            </if>
+            <if test="productNo != null">
+                #{productNo,jdbcType=VARCHAR},
+            </if>
+            <if test="price != null">
+                #{price,jdbcType=DECIMAL},
+            </if>
+            <if test="normalPrice != null">
+                #{normalPrice,jdbcType=DECIMAL},
+            </if>
+            <if test="costPrice != null">
+                #{costPrice,jdbcType=DECIMAL},
+            </if>
+            <if test="price0 != null">
+                #{price0,jdbcType=DECIMAL},
+            </if>
+            <if test="price1 != null">
+                #{price1,jdbcType=DECIMAL},
+            </if>
+            <if test="totalAmount != null">
+                #{totalAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="totalFee != null">
+                #{totalFee,jdbcType=DECIMAL},
+            </if>
+            <if test="shouldPayFee != null">
+                #{shouldPayFee,jdbcType=DECIMAL},
+            </if>
+            <if test="discount != null">
+                #{discount,jdbcType=DECIMAL},
+            </if>
+            <if test="discountPrice != null">
+                #{discountPrice,jdbcType=DECIMAL},
+            </if>
+            <if test="taxRate != null">
+                #{taxRate,jdbcType=DECIMAL},
+            </if>
+            <if test="addedValueTax != null">
+                #{addedValueTax,jdbcType=DECIMAL},
+            </if>
+            <if test="totalAddedValueTax != null">
+                #{totalAddedValueTax,jdbcType=DECIMAL},
+            </if>
+            <if test="shouldPayTotalTax != null">
+                #{shouldPayTotalTax,jdbcType=DECIMAL},
+            </if>
+            <if test="singleShouldPayTotalTax != null">
+                #{singleShouldPayTotalTax,jdbcType=DECIMAL},
+            </if>
+            <if test="shopProductAmount != null">
+                #{shopProductAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="shopFee != null">
+                #{shopFee,jdbcType=DECIMAL},
+            </if>
+            <if test="otherFee != null">
+                #{otherFee,jdbcType=DECIMAL},
+            </if>
+            <if test="cmFee != null">
+                #{cmFee,jdbcType=DECIMAL},
+            </if>
+            <if test="singleShopFee != null">
+                #{singleShopFee,jdbcType=DECIMAL},
+            </if>
+            <if test="singleOtherFee != null">
+                #{singleOtherFee,jdbcType=DECIMAL},
+            </if>
+            <if test="singleCmFee != null">
+                #{singleCmFee,jdbcType=DECIMAL},
+            </if>
+            <if test="status != null">
+                #{status,jdbcType=CHAR},
+            </if>
+            <if test="commentFlag != null">
+                #{commentFlag,jdbcType=CHAR},
+            </if>
+            <if test="totalBeans != null">
+                #{totalBeans,jdbcType=DECIMAL},
+            </if>
+            <if test="useBalanceAmount != null">
+                #{useBalanceAmount,jdbcType=DOUBLE},
+            </if>
+            <if test="useBeanAmount != null">
+                #{useBeanAmount,jdbcType=INTEGER},
+            </if>
+            <if test="notOutStore != null">
+                #{notOutStore,jdbcType=INTEGER},
+            </if>
+            <if test="cmbeanPrice != null">
+                #{cmbeanPrice,jdbcType=INTEGER},
+            </if>
+            <if test="isActProduct != null">
+                #{isActProduct,jdbcType=VARCHAR},
+            </if>
+            <if test="isGiftProduct != null">
+                #{isGiftProduct,jdbcType=VARCHAR},
+            </if>
+            <if test="productActInfo != null">
+                #{productActInfo,jdbcType=VARCHAR},
+            </if>
+            <if test="buyAgainFlag != null">
+                #{buyAgainFlag,jdbcType=CHAR},
+            </if>
+            <if test="confirmProductFlag != null">
+                #{confirmProductFlag,jdbcType=CHAR},
+            </if>
+            <if test="payStatus != null">
+                #{payStatus,jdbcType=CHAR},
+            </if>
+            <if test="shopName != null">
+                #{shopName,jdbcType=VARCHAR},
+            </if>
+            <if test="name != null">
+                #{name,jdbcType=VARCHAR},
+            </if>
+            <if test="productUnit != null">
+                #{productUnit,jdbcType=VARCHAR},
+            </if>
+            <if test="productImage != null">
+                #{productImage,jdbcType=VARCHAR},
+            </if>
+            <if test="actType != null">
+                #{actType,jdbcType=VARCHAR},
+            </if>
+            <if test="actPreferential != null">
+                #{actPreferential,jdbcType=DECIMAL},
+            </if>
+            <if test="productType != null">
+                #{productType},
+            </if>
+            <if test="orderPromotionsId != null">
+                #{orderPromotionsId},
+            </if>
+            <if test="preferential != null">
+                #{preferential,jdbcType=DECIMAL},
+            </if>
+            <if test="discountFee != null">
+                #{discountFee,jdbcType=DECIMAL},
+            </if>
+            <if test="cancelNum != null">
+                #{cancelNum,jdbcType=INTEGER},
+            </if>
+            <if test="supplierTaxRate != null">
+                #{supplierTaxRate,jdbcType=DECIMAL},
+            </if>
+            <if test="includedTax != null">
+                #{includedTax,jdbcType=VARCHAR},
+            </if>
+            <if test="invoiceType != null">
+                #{invoiceType,jdbcType=VARCHAR},
+            </if>
+            <if test="ladderPriceFlag != null">
+                #{ladderPriceFlag,jdbcType=INTEGER},
+            </if>
+        </trim>
+    </insert>
+
+    <insert id="insertOrderProductLadderPrice"  keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.caimei.model.po.OrderProductLadderPricePo">
+        insert into order_product_ladder_price (
+            orderProductId, ladderNum, buyNum, buyPrice, createDate
+        )
+        values (
+            #{orderProductId},#{ladderNum},#{buyNum},#{buyPrice},#{createDate}
+        )
+    </insert>
+
+    <update id="updateOrder" parameterType="com.caimei.model.po.CmOrderPo">
+        update cm_order
+        <set>
+            <if test="orderNo != null">
+                orderNo = #{orderNo,jdbcType=VARCHAR},
+            </if>
+            <if test="organizeID != null">
+                organizeID = 0,
+            </if>
+            <if test="userID != null">
+                userID = #{userID,jdbcType=BIGINT},
+            </if>
+            <if test="buyUserID != null">
+                buyUserID = #{buyUserID,jdbcType=INTEGER},
+            </if>
+            <if test="shopOrderIDs != null">
+                shopOrderIDs = #{shopOrderIDs,jdbcType=VARCHAR},
+            </if>
+            <if test="orderSubmitType != null">
+                orderSubmitType = #{orderSubmitType,jdbcType=INTEGER},
+            </if>
+            <if test="orderType != null">
+                orderType = #{orderType,jdbcType=INTEGER},
+            </if>
+            <if test="hasActProduct != null">
+                hasActProduct = #{hasActProduct,jdbcType=CHAR},
+            </if>
+            <if test="autoCloseTimeMills != null">
+                autoCloseTimeMills = #{autoCloseTimeMills,jdbcType=DECIMAL},
+            </if>
+            <if test="status != null">
+                `status` = #{status,jdbcType=CHAR},
+            </if>
+            <if test="receiptStatus != null">
+                receiptStatus = #{receiptStatus,jdbcType=CHAR},
+            </if>
+            <if test="payStatus != null">
+                payStatus = #{payStatus,jdbcType=CHAR},
+            </if>
+            <if test="sendOutStatus != null">
+                sendOutStatus = #{sendOutStatus,jdbcType=CHAR},
+            </if>
+            <if test="refundType != null">
+                refundType = #{refundType,jdbcType=CHAR},
+            </if>
+            <if test="payFlag != null">
+                payFlag = #{payFlag,jdbcType=CHAR},
+            </if>
+            <if test="onlinePayFlag != null">
+                onlinePayFlag = #{onlinePayFlag,jdbcType=CHAR},
+            </if>
+            <if test="productTotalFee != null">
+                productTotalFee = #{productTotalFee,jdbcType=DECIMAL},
+            </if>
+            <if test="orderTotalFee != null">
+                orderTotalFee = #{orderTotalFee,jdbcType=DECIMAL},
+            </if>
+            <if test="payTotalFee != null">
+                payTotalFee = #{payTotalFee,jdbcType=DECIMAL},
+            </if>
+            <if test="payableAmount != null">
+                payableAmount = #{payableAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="balancePayFee != null">
+                balancePayFee = #{balancePayFee,jdbcType=DECIMAL},
+            </if>
+            <if test="preferential != null">
+                preferential = #{preferential,jdbcType=DECIMAL},
+            </if>
+            <if test="discountFee != null">
+                discountFee = #{discountFee,jdbcType=DECIMAL},
+            </if>
+            <if test="spID != null">
+                spID = #{spID,jdbcType=BIGINT},
+            </if>
+            <if test="mainSpID != null">
+                mainSpID = #{mainSpID,jdbcType=BIGINT},
+            </if>
+            <if test="note != null">
+                note = #{note,jdbcType=VARCHAR},
+            </if>
+            <if test="clubID != null">
+                clubID = #{clubID,jdbcType=BIGINT},
+            </if>
+            <if test="clubScanTime != null">
+                clubScanTime = #{clubScanTime,jdbcType=VARCHAR},
+            </if>
+            <if test="payWay != null">
+                payWay = #{payWay,jdbcType=VARCHAR},
+            </if>
+            <if test="orderSource != null">
+                orderSource = #{orderSource,jdbcType=CHAR},
+            </if>
+            <if test="closeTime != null">
+                closeTime = #{closeTime,jdbcType=VARCHAR},
+            </if>
+            <if test="confirmTime != null">
+                confirmTime = #{confirmTime,jdbcType=VARCHAR},
+            </if>
+            <if test="payTime != null">
+                payTime = #{payTime,jdbcType=VARCHAR},
+            </if>
+            <if test="orderTime != null">
+                orderTime = #{orderTime,jdbcType=VARCHAR},
+            </if>
+            <if test="productCount != null">
+                productCount = #{productCount,jdbcType=INTEGER},
+            </if>
+            <if test="presentCount != null">
+                presentCount = #{presentCount,jdbcType=INTEGER},
+            </if>
+            <if test="cooFreeFlag != null">
+                cooFreeFlag = #{cooFreeFlag,jdbcType=CHAR},
+            </if>
+            <if test="cooFreeRate != null">
+                cooFreeRate = #{cooFreeRate,jdbcType=INTEGER},
+            </if>
+            <if test="cooFreeAmount != null">
+                cooFreeAmount = #{cooFreeAmount,jdbcType=DECIMAL},
+            </if>
+            <if test="invoiceFlag != null">
+                invoiceFlag = #{invoiceFlag,jdbcType=CHAR},
+            </if>
+            <if test="confirmFlag != null">
+                confirmFlag = #{confirmFlag,jdbcType=CHAR},
+            </if>
+            <if test="clauseID != null">
+                clauseID = #{clauseID,jdbcType=BIGINT},
+            </if>
+            <if test="clauseContent != null">
+                clauseContent = #{clauseContent,jdbcType=VARCHAR},
+            </if>
+            <if test="clauseName != null">
+                clauseName = #{clauseName,jdbcType=VARCHAR},
+            </if>
+            <if test="updateDate != null">
+                updateDate = #{updateDate,jdbcType=VARCHAR},
+            </if>
+            <if test="freePostFlag != null">
+                freePostFlag = #{freePostFlag,jdbcType=CHAR},
+            </if>
+            <if test="freight != null">
+                freight = #{freight,jdbcType=DECIMAL},
+            </if>
+            <if test="delFlag != null">
+                delFlag = #{delFlag,jdbcType=CHAR},
+            </if>
+            <if test="freePostageTicketID != null">
+                freePostageTicketID = #{freePostageTicketID,jdbcType=INTEGER},
+            </if>
+            <if test="splitFlag != null">
+                splitFlag = #{splitFlag,jdbcType=CHAR},
+            </if>
+            <if test="closeReason != null">
+                closeReason = #{closeReason,jdbcType=VARCHAR},
+            </if>
+            <if test="postageOrderFlag != null">
+                postageOrderFlag = #{postageOrderFlag,jdbcType=CHAR},
+            </if>
+            <if test="affirmPaymentFlag != null">
+                affirmPaymentFlag = #{affirmPaymentFlag,jdbcType=CHAR},
+            </if>
+            <if test="rebateFlag != null">
+                rebateFlag = #{rebateFlag,jdbcType=CHAR},
+            </if>
+            <if test="zeroCostFlag != null">
+                zeroCostFlag = #{zeroCostFlag,jdbcType=INTEGER},
+            </if>
+        </set>
+        where orderID = #{orderID,jdbcType=BIGINT}
+    </update>
+
+    <select id="getOrderInvoice" resultType="com.caimei.model.po.BpOrderInvoicePo">
+        SELECT
+          id,
+          orderId,
+          invoiceTitle,
+          `type`,
+          invoiceType,
+          invoiceContent,
+          invoiceTitleType,
+          corporationTaxNum,
+          registeredAddress,
+          registeredPhone,
+          bankAccountNo,
+          openBank
+        FROM
+          bp_order_invoice
+        WHERE
+          orderId = #{orderId}
+    </select>
+
+    <insert id="insertUserInfo" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.po.BpOrderUserInfoPo" useGeneratedKeys="true">
+        insert into bp_order_userinfo
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="orderId != null">
+                orderId,
+            </if>
+            <if test="clubId != null">
+                clubId,
+            </if>
+            <if test="userId != null">
+                userId,
+            </if>
+            <if test="name != null">
+                `name`,
+            </if>
+            <if test="shouHuoRen != null">
+                shouHuoRen,
+            </if>
+            <if test="mobile != null">
+                mobile,
+            </if>
+            <if test="phone != null">
+                phone,
+            </if>
+            <if test="postalCode != null">
+                postalCode,
+            </if>
+            <if test="townId != null">
+                townId,
+            </if>
+            <if test="province != null">
+                province,
+            </if>
+            <if test="city != null">
+                city,
+            </if>
+            <if test="town != null">
+                town,
+            </if>
+            <if test="address != null">
+                address,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="orderId != null">
+                #{orderId,jdbcType=BIGINT},
+            </if>
+            <if test="clubId != null">
+                #{clubId,jdbcType=BIGINT},
+            </if>
+            <if test="userId != null">
+                #{userId,jdbcType=BIGINT},
+            </if>
+            <if test="name != null">
+                #{name,jdbcType=VARCHAR},
+            </if>
+            <if test="shouHuoRen != null">
+                #{shouHuoRen,jdbcType=VARCHAR},
+            </if>
+            <if test="mobile != null">
+                #{mobile,jdbcType=VARCHAR},
+            </if>
+            <if test="phone != null">
+                #{phone,jdbcType=VARCHAR},
+            </if>
+            <if test="postalCode != null">
+                #{postalCode,jdbcType=VARCHAR},
+            </if>
+            <if test="townId != null">
+                #{townId,jdbcType=INTEGER},
+            </if>
+            <if test="province != null">
+                #{province,jdbcType=VARCHAR},
+            </if>
+            <if test="city != null">
+                #{city,jdbcType=VARCHAR},
+            </if>
+            <if test="town != null">
+                #{town,jdbcType=VARCHAR},
+            </if>
+            <if test="address != null">
+                #{address,jdbcType=VARCHAR},
+            </if>
+        </trim>
+    </insert>
+
+    <update id="updateOrderInvoice">
+        update bp_order_invoice
+        <set>
+            <if test="invoiceTitle != null">
+                invoiceTitle = #{invoiceTitle,jdbcType=VARCHAR},
+            </if>
+            <if test="invoiceType != null">
+                invoiceType = #{invoiceType,jdbcType=VARCHAR},
+            </if>
+            <if test="type != null">
+                type = #{type,jdbcType=CHAR},
+            </if>
+            <if test="invoiceContent != null">
+                invoiceContent = #{invoiceContent,jdbcType=VARCHAR},
+            </if>
+            <if test="invoiceTitleType != null">
+                invoiceTitleType = #{invoiceTitleType,jdbcType=VARCHAR},
+            </if>
+            <if test="corporationTaxNum != null">
+                corporationTaxNum = #{corporationTaxNum,jdbcType=VARCHAR},
+            </if>
+            <if test="registeredAddress != null">
+                registeredAddress = #{registeredAddress,jdbcType=VARCHAR},
+            </if>
+            <if test="registeredPhone != null">
+                registeredPhone = #{registeredPhone,jdbcType=VARCHAR},
+            </if>
+            <if test="bankAccountNo != null">
+                bankAccountNo = #{bankAccountNo,jdbcType=VARCHAR},
+            </if>
+            <if test="openBank != null">
+                openBank = #{openBank,jdbcType=VARCHAR},
+            </if>
+        </set>
+        where orderId = #{orderId,jdbcType=BIGINT}
+    </update>
+
+    <insert id="insertOrderInvoice" keyColumn="id" keyProperty="id" parameterType="com.caimei.model.po.BpOrderInvoicePo" useGeneratedKeys="true">
+        insert into bp_order_invoice
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="orderId != null">
+                orderId,
+            </if>
+            <if test="invoiceTitle != null">
+                invoiceTitle,
+            </if>
+            <if test="invoiceType != null">
+                invoiceType,
+            </if>
+            <if test="type != null">
+                `type`,
+            </if>
+            <if test="invoiceContent != null">
+                invoiceContent,
+            </if>
+            <if test="invoiceTitleType != null">
+                invoiceTitleType,
+            </if>
+            <if test="corporationTaxNum != null">
+                corporationTaxNum,
+            </if>
+            <if test="registeredAddress != null">
+                registeredAddress,
+            </if>
+            <if test="registeredPhone != null">
+                registeredPhone,
+            </if>
+            <if test="bankAccountNo != null">
+                bankAccountNo,
+            </if>
+            <if test="openBank != null">
+                openBank,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="orderId != null">
+                #{orderId,jdbcType=BIGINT},
+            </if>
+            <if test="invoiceTitle != null">
+                #{invoiceTitle,jdbcType=VARCHAR},
+            </if>
+            <if test="invoiceType != null">
+                #{invoiceType,jdbcType=VARCHAR},
+            </if>
+            <if test="type != null">
+                #{type,jdbcType=CHAR},
+            </if>
+            <if test="invoiceContent != null">
+                #{invoiceContent,jdbcType=VARCHAR},
+            </if>
+            <if test="invoiceTitleType != null">
+                #{invoiceTitleType,jdbcType=VARCHAR},
+            </if>
+            <if test="corporationTaxNum != null">
+                #{corporationTaxNum,jdbcType=VARCHAR},
+            </if>
+            <if test="registeredAddress != null">
+                #{registeredAddress,jdbcType=VARCHAR},
+            </if>
+            <if test="registeredPhone != null">
+                #{registeredPhone,jdbcType=VARCHAR},
+            </if>
+            <if test="bankAccountNo != null">
+                #{bankAccountNo,jdbcType=VARCHAR},
+            </if>
+            <if test="openBank != null">
+                #{openBank,jdbcType=VARCHAR},
+            </if>
+        </trim>
+    </insert>
+
+    <select id="findByAddressId" resultType="com.caimei.model.po.AddressPo">
+        SELECT a.addressID AS addressId,
+               a.userID AS userId,
+               a.shouHuoRen,
+               a.townID AS townId,
+               a.address,
+               a.postalCode,
+               a.phone,
+               a.mobile,
+               a.defaultFlag,
+               c.cityID AS cityId,
+               p.provinceID AS provinceId,
+               t.name AS townName,
+               c.name AS cityName,
+               p.name AS provinceName
+        FROM address a
+                 LEFT JOIN town t ON t.townID = a.townID
+                 LEFT JOIN city c ON c.cityID = t.cityID
+                 LEFT JOIN province p ON p.provinceID = c.provinceID
+        WHERE a.addressID = #{addressId}
+    </select>
 </mapper>

+ 74 - 0
src/main/resources/mapper/ProductMapper.xml

@@ -132,4 +132,78 @@
         AND delFlag = '0'
     </select>
 
+    <select id="getProduct" resultType="com.caimei.model.po.CmOrganizeProductPo">
+        SELECT
+          cop.id,
+          cop.organizeId,
+          cop.productId,
+          cop.ladderPriceFlag,
+          cop.price,
+          cop.includedTax,
+          cop.invoiceType,
+          cop.minBuyNumber,
+          cop.costType,
+          cop.clubTaxPoint,
+          cop.shopTaxPoint,
+          cop.costPrice,
+          cop.costProportional,
+          cop.postageType,
+          p.shopID AS shopId,
+          p.unit,
+          p.normalPrice,
+          p.name,
+          p.mainImage,
+          s.name AS shopName
+        FROM
+          cm_organize_product cop
+          LEFT JOIN product p ON cop.productId = p.productID
+          LEFT JOIN shop s ON p.shopID = s.shopID
+        WHERE
+          cop.id = #{productId}
+    </select>
+
+    <select id="findParameterById" resultType="com.caimei.model.po.PromotionsPo">
+        SELECT
+          id,
+          NAME,
+          description,
+          TYPE,
+          MODE,
+          touchPrice,
+          reducedPrice,
+          beginTime,
+          endTime,
+          STATUS
+        FROM
+          cm_organize_promotions
+        WHERE
+          id = #{promotionsId}
+    </select>
+
+    <select id="findPostFeeProduct" resultType="com.caimei.model.po.ProductPo">
+        SELECT
+          p.productID,
+          p.ladderPriceFlag,
+          p.price1,
+          p.includedTax,
+          p.invoiceType,
+          p.minBuyNumber,
+          p.taxPoint,
+          p.supplierTaxPoint,
+          p.costPrice,
+          p.costProportional,
+          p.shopID,
+          p.unit,
+          p.normalPrice,
+          p.name,
+          p.mainImage,
+          p.productCode,
+          s.name AS shopName
+        FROM
+          product p
+          LEFT JOIN shop s ON p.shopID = s.shopID
+        WHERE
+          p.productID = 999
+    </select>
+
 </mapper>

+ 5 - 1
src/main/resources/mapper/ShoppingCartMapper.xml

@@ -149,6 +149,10 @@
           cm_organize_promotions_gift copg
           LEFT JOIN cm_organize_product cop ON copg.productId = cop.id
           LEFT JOIN product p ON cop.productId = p.productID
-          AND copg.promotionsId = #{promotionsId}
+          WHERE copg.promotionsId = #{promotionsId}
     </select>
+
+    <delete id="deleteCartByProductId">
+        DELETE FROM cm_mall_cart WHERE userID = #{cartId} AND productID = #{productId}
+    </delete>
 </mapper>