plf 4 lat temu
rodzic
commit
a578b529f9
26 zmienionych plików z 4954 dodań i 57 usunięć
  1. 119 0
      src/main/java/com/caimei/controller/OrderSubmitApi.java
  2. 89 0
      src/main/java/com/caimei/controller/ShoppingCartApi.java
  3. 119 0
      src/main/java/com/caimei/mapper/OrderSubmitMapper.java
  4. 83 0
      src/main/java/com/caimei/mapper/ShoppingCartMapper.java
  5. 34 0
      src/main/java/com/caimei/model/dto/CartDto.java
  6. 0 52
      src/main/java/com/caimei/model/dto/HeHeUserDto.java
  7. 76 0
      src/main/java/com/caimei/model/po/BpOrderUserInfoPo.java
  8. 30 0
      src/main/java/com/caimei/model/po/CmCartPo.java
  9. 104 0
      src/main/java/com/caimei/model/po/CmHeHeProductPo.java
  10. 319 0
      src/main/java/com/caimei/model/po/CmOrderPo.java
  11. 337 0
      src/main/java/com/caimei/model/po/CmOrderProductPo.java
  12. 360 0
      src/main/java/com/caimei/model/po/CmShopOrderPo.java
  13. 49 0
      src/main/java/com/caimei/model/po/OrderProductLadderPricePo.java
  14. 391 0
      src/main/java/com/caimei/model/po/UserPo.java
  15. 92 0
      src/main/java/com/caimei/model/vo/CartProductVo.java
  16. 0 1
      src/main/java/com/caimei/model/vo/ProductVo.java
  17. 52 0
      src/main/java/com/caimei/model/vo/ShopVo.java
  18. 36 0
      src/main/java/com/caimei/service/OrderSubmitService.java
  19. 60 0
      src/main/java/com/caimei/service/ShoppingCartService.java
  20. 670 0
      src/main/java/com/caimei/service/impl/OrderSubmitServiceImpl.java
  21. 10 4
      src/main/java/com/caimei/service/impl/ProductServiceImpl.java
  22. 125 0
      src/main/java/com/caimei/service/impl/ShoppingCartServiceImpl.java
  23. 71 0
      src/main/java/com/caimei/util/OrderNoUtils.java
  24. 3 0
      src/main/resources/backup.sql
  25. 1601 0
      src/main/resources/mapper/OrderSubmitMapper.xml
  26. 124 0
      src/main/resources/mapper/ShoppingCartMapper.xml

+ 119 - 0
src/main/java/com/caimei/controller/OrderSubmitApi.java

@@ -0,0 +1,119 @@
+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 lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/4/25
+ */
+@Api(tags = "订单结算")
+@Slf4j
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/order")
+public class OrderSubmitApi {
+    private final OrderSubmitService orderSubmitService;
+
+    /**
+     * 商品结算
+     */
+    @ApiOperation("商品结算")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "productIds", value = "商品ID串用逗号隔开", required = true),
+            @ApiImplicitParam(name = "productCount", value = "立即购买商品数量", required = false),
+            @ApiImplicitParam(name = "userId", value = "用户id", required = true)
+    })
+    @GetMapping("/confirm")
+    public ResponseJson<Map<String, Object>> orderConfirm(String productIds, Integer productCount, Integer userId) {
+        return orderSubmitService.orderConfirm(productIds, productCount, userId);
+    }
+
+    /**
+     * 提交订单
+     *
+     * @param params 参数格式:{
+     *               *   "userId": 10708,        //机构用户ID
+     *               *   "cartType":3,               //购买类型:(1购物车提交[对应表cm_cart],2直接购买提交)
+     *               *   "addressId": 2732,          //地址ID
+     *               *   "orderInfo": [
+     *               *                   { "shopId":1001,    // 供应商ID
+     *               *                     "note":备注,
+     *               *                     "productInfo":[   // 商品id,数量
+     *               *                         {"productId": 2789, "productNum": 1},
+     *               *                         {"productId": 2789, "productNum": 1}
+     *               *                      ]
+     *               *                   },
+     *               *                   {多个供应商商品数据结构同上}
+     *               *                ]
+     *               *
+     *               *   "payInfo": {               // 订单信息
+     *               *       "orderShouldPayFee": 609.11
+     *               *   }
+     * @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 userId = null;
+        Integer cartType = 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);
+            }
+            userId = paramsMap.getInteger("userId");
+            if (null == userId) {
+                return ResponseJson.error("机构用户Id异常", null);
+            }
+            cartType = paramsMap.getInteger("cartType");
+            if (null == cartType) {
+                return ResponseJson.error("购买类型异常", 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);
+            }
+        } catch (Exception e) {
+            log.error("<<<<< 系统异常 >>>>>" + e);
+            return ResponseJson.error("数据异常", null);
+        }
+
+        log.info("****** 提交订单参数:【机构自己下单】:" + params);
+        return orderSubmitService.orderSubmit(userId, cartType, addressId, orderInfo, payInfo);
+    }
+}

+ 89 - 0
src/main/java/com/caimei/controller/ShoppingCartApi.java

@@ -0,0 +1,89 @@
+package com.caimei.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.caimei.model.ResponseJson;
+import com.caimei.model.dto.CartDto;
+import com.caimei.service.ShoppingCartService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/23
+ */
+@Api(tags = "购物车")
+@RestController
+@RequiredArgsConstructor
+@RequestMapping("/shopping")
+public class ShoppingCartApi {
+    private final ShoppingCartService shoppingCartService;
+
+    /**
+     * 加入购物车
+     */
+    @ApiOperation("加入购物车")
+    @PostMapping("/add/cart")
+    public synchronized ResponseJson<Integer> addShoppingCart(@RequestBody CartDto cart) {
+        if (cart.getUserId() == null || cart.getProductId() == null || cart.getProductCount() == null) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return shoppingCartService.addShoppingCart(cart);
+    }
+
+    /**
+     * 统计购物车数量
+     */
+    @ApiOperation("统计购物车数量")
+    @ApiImplicitParam(name = "userId", value = "用户id", required = true)
+    @GetMapping("/quantity")
+    public ResponseJson<Integer> getCartQuantity(Integer userId) {
+        if (userId == null) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return shoppingCartService.getCartQuantity(userId);
+    }
+
+    /**
+     * 购物车数据
+     */
+    @ApiOperation("购物车数据")
+    @ApiImplicitParam(name = "userId", value = "用户id", required = true)
+    @GetMapping("/info")
+    public ResponseJson<Map<String, Object>> shoppingInfo(Integer userId) {
+        if (userId == null) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return shoppingCartService.shoppingInfo(userId);
+    }
+
+    /**
+     * 更新购物车商品数量
+     */
+    @ApiOperation("更新购物车商品数量")
+    @ApiImplicitParam(name = "params", value = "cartId:购物车id;productCount:商品数量", required = true)
+    @PostMapping("/update")
+    public void updateNumber(@RequestBody Map<String, Integer> params) {
+        Integer cartId = params.get("cartId");
+        Integer productCount = params.get("productCount");
+        shoppingCartService.updateNumber(cartId, productCount);
+    }
+
+    /**
+     * 删除购物车商品
+     */
+    @ApiOperation("删除购物车商品")
+    @ApiImplicitParam(name = "cartIds", value = "购物车id,以','隔开", required = true)
+    @PostMapping("/delete")
+    public ResponseJson<String> deleteCart(@RequestBody String cartIds) {
+        JSONObject jsonObject = JSONObject.parseObject(cartIds);
+        cartIds = jsonObject.getString("cartIds");
+        return shoppingCartService.deleteCart(cartIds);
+    }
+}

+ 119 - 0
src/main/java/com/caimei/mapper/OrderSubmitMapper.java

@@ -0,0 +1,119 @@
+package com.caimei.mapper;
+
+import com.caimei.model.po.*;
+import com.caimei.model.vo.AddressVo;
+import com.caimei.model.vo.CartProductVo;
+import com.caimei.model.vo.ShopVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/4/25
+ */
+@Mapper
+public interface OrderSubmitMapper {
+    /**
+     * 根据商品集合查询供应商信息
+     *
+     * @param productIds
+     * @return
+     */
+    List<ShopVo> findShopByproductIds(@Param("productIds") String[] productIds);
+
+    /**
+     * 查询购物车商品信息
+     *
+     * @param shopId
+     * @param productId
+     * @param userId
+     * @return
+     */
+    List<CartProductVo> findByShopCartProduct(@Param("shopId") Integer shopId, @Param("productIds") String[] productId, @Param("userId") Integer userId);
+
+    /**
+     * 查询用户信息
+     *
+     * @param userId
+     * @return
+     */
+    UserPo findUser(Integer userId);
+
+    /**
+     * 查询商品信息
+     *
+     * @param productId
+     * @return
+     */
+    CmHeHeProductPo getProduct(Integer productId);
+
+    /**
+     * 删除购物车
+     *
+     * @param userId    用户id
+     * @param productId 商品id
+     */
+    void deleteCartByProductId(@Param("userId") Integer userId, @Param("productId") Integer productId);
+
+    /**
+     * 保存订单信息
+     *
+     * @param order
+     */
+    void insertOrder(CmOrderPo order);
+
+    /**
+     * 查询子订单编号
+     *
+     * @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 addressId
+     * @return
+     */
+    AddressVo findByAddressId(Integer addressId);
+
+    /**
+     * 保存订单地址信息
+     *
+     * @param userInfo
+     */
+    void insertUserInfo(BpOrderUserInfoPo userInfo);
+}

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

@@ -0,0 +1,83 @@
+package com.caimei.mapper;
+
+import com.caimei.model.dto.CartDto;
+import com.caimei.model.po.CmCartPo;
+import com.caimei.model.vo.CartProductVo;
+import com.caimei.model.vo.ShopVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/23
+ */
+@Mapper
+public interface ShoppingCartMapper {
+    /**
+     * 查询购物车
+     *
+     * @param userId    机构id
+     * @param productId 组织商品id
+     * @return
+     */
+    CmCartPo findCartProduct(@Param("userId") Integer userId, @Param("productId") Integer productId);
+
+    /**
+     * 保存购物车
+     *
+     * @param cart
+     */
+    void insertCart(CartDto cart);
+
+    /**
+     * 修改购物车数量
+     *
+     * @param cartId
+     * @param productCount
+     */
+    void updateByProductCount(@Param("cartId") Integer cartId, @Param("productCount") int productCount);
+
+    /**
+     * 查询购物车数量
+     *
+     * @param userId
+     * @return
+     */
+    Integer getCartQuantity(Integer userId);
+
+    /**
+     * 查询购物车对应供应商
+     *
+     * @param userId
+     * @return
+     */
+    List<ShopVo> findCartShop(Integer userId);
+
+    /**
+     * 查询购物车该供应商下商品
+     *
+     * @param shopId
+     * @param userId
+     * @return
+     */
+    List<CartProductVo> findByShopCartProduct(@Param("shopId") Integer shopId, @Param("userId") Integer userId);
+
+    /**
+     * 查询失效购物车商品
+     *
+     * @param userId
+     * @return
+     */
+    List<CartProductVo> findExpiredGoods(Integer userId);
+
+    /**
+     * 删除购物车
+     *
+     * @param cartId
+     */
+    void deleteCart(String cartId);
+}

+ 34 - 0
src/main/java/com/caimei/model/dto/CartDto.java

@@ -0,0 +1,34 @@
+package com.caimei.model.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/24
+ */
+@Data
+public class CartDto implements Serializable {
+
+    /**
+     * 商品id
+     */
+    @ApiModelProperty("商品id")
+    private Integer productId;
+
+    /**
+     * 用户ID
+     */
+    @ApiModelProperty("用户id")
+    private Integer userId;
+
+    /**
+     * 商品数量
+     */
+    @ApiModelProperty("商品数量")
+    private Integer productCount;
+}

+ 0 - 52
src/main/java/com/caimei/model/dto/HeHeUserDto.java

@@ -1,52 +0,0 @@
-package com.caimei.model.dto;
-
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-import javax.validation.constraints.NotNull;
-
-/**
- * Description
- *
- * @author : plf
- * @date : 2021/4/22
- */
-@ApiModel("呵呵小程序登录")
-@Data
-public class HeHeUserDto {
-    /**
-     * 手机号
-     */
-    @NotNull
-    @ApiModelProperty("手机号")
-    private String mobile;
-
-    /**
-     * 验证码
-     */
-    @NotNull
-    @ApiModelProperty("验证码")
-    private String verificationCode;
-
-    /**
-     * 微信昵称
-     */
-    @NotNull
-    @ApiModelProperty("微信昵称")
-    private String nickName;
-
-    /**
-     * 微信头像
-     */
-    @NotNull
-    @ApiModelProperty("微信头像")
-    private String headImgUrl;
-
-    /**
-     * 微信openid
-     */
-    @NotNull
-    @ApiModelProperty("微信openid")
-    private String openId;
-}

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

@@ -0,0 +1,76 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 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;
+}

+ 30 - 0
src/main/java/com/caimei/model/po/CmCartPo.java

@@ -0,0 +1,30 @@
+package com.caimei.model.po;
+
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * cm_cart
+ * @author 
+ */
+@Data
+public class CmCartPo implements Serializable {
+    private Integer cartId;
+
+    private Integer productID;
+
+    private Integer userID;
+
+    private Integer productCount;
+
+    private Date addTime;
+
+    private String isOutOfTime;
+
+    private String skuID;
+
+    private String reBuyFlag;
+
+    private static final long serialVersionUID = 1L;
+}

+ 104 - 0
src/main/java/com/caimei/model/po/CmHeHeProductPo.java

@@ -0,0 +1,104 @@
+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 CmHeHeProductPo implements Serializable {
+    private Integer id;
+
+    /**
+     * 商品Id
+     */
+    private Integer productId;
+
+    /**
+     * 机构价
+     */
+    private BigDecimal price;
+
+    /**
+     * 是否含税   0不含税,1含税,2未知
+     */
+    private Integer includedTax;
+
+    /**
+     * 发票类型(基于是否含税基础)   1增值税专用发票,2增值税普通发票, 3不能开票
+     */
+    private Integer invoiceType;
+
+    /**
+     * 成本价类型: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已上架
+     */
+    private Integer status;
+
+    /**
+     * 添加时间
+     */
+    private Date addTime;
+
+    /**
+     * 供应商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;
+}

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

@@ -0,0 +1,319 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 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普通订单、 2呵呵订单
+     */
+    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;
+}

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

@@ -0,0 +1,337 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 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;
+}

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

@@ -0,0 +1,360 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 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;
+}

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

@@ -0,0 +1,49 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 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;
+}

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

@@ -0,0 +1,391 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 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;
+}

+ 92 - 0
src/main/java/com/caimei/model/vo/CartProductVo.java

@@ -0,0 +1,92 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/24
+ */
+@Data
+public class CartProductVo implements Serializable {
+    /**
+     * 购物车id
+     */
+    private Integer cartId;
+
+    /**
+     * 供应商id
+     */
+    private Integer shopId;
+
+    /**
+     * 商品Id
+     */
+    private Integer productId;
+
+    /**
+     * 商品名称
+     */
+    private String productName;
+
+    /**
+     * 商品图片
+     */
+    private String mainImage;
+
+    /**
+     * 机构价
+     */
+    private BigDecimal price;
+
+    /**
+     * 规格
+     */
+    private String unit;
+
+    /**
+     * 起订量
+     */
+    private Integer minBuyNumber;
+
+    /**
+     * 是否含税   0不含税,1含税,2未知
+     */
+    private String includedTax;
+
+    /**
+     * 发票类型(基于是否含税基础)   1增值税票,2普通票, 3不能开票
+     */
+    private String invoiceType;
+
+    /**
+     * 开票税点(基于不含税基础) :增值税默认13%,普通票6%取值范围[0-100]
+     */
+    private BigDecimal clubTaxPoint;
+
+    /**
+     * 活动状态:0没有活动,1活动价
+     */
+    private Integer activeStatus = 0;
+
+    /**
+     * 商品数量
+     */
+    private Integer productCount;
+
+    /**
+     * 前端选中状态
+     */
+    private boolean productsChecked = false;
+
+    /**
+     * 活动阶梯数据
+     */
+    private List<ActivityLadderVo> ladderList;
+}
+

+ 0 - 1
src/main/java/com/caimei/model/vo/ProductVo.java

@@ -4,7 +4,6 @@ import lombok.Data;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
-import java.util.List;
 
 /**
  * Description

+ 52 - 0
src/main/java/com/caimei/model/vo/ShopVo.java

@@ -0,0 +1,52 @@
+package com.caimei.model.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/24
+ */
+@Data
+public class ShopVo implements Serializable {
+    /**
+     * 供应商id
+     */
+    @ApiModelProperty("供应商id")
+    private Integer shopId;
+
+    /**
+     * 供应商名称
+     */
+    @ApiModelProperty("供应商名称")
+    private String name;
+
+    /**
+     * 供应商logo
+     */
+    @ApiModelProperty("供应商logo")
+    private String logo;
+
+    /**
+     * 购物车该供应商下总价
+     */
+    @ApiModelProperty("购物车该供应商下总价")
+    private BigDecimal shopTotalPrice;
+
+    /**
+     * 前端选中状态
+     */
+    private boolean checked = false;
+
+    /**
+     * 供应商下商品信息
+     */
+    @ApiModelProperty("供应商下商品信息")
+    private List<CartProductVo> productList;
+}

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

@@ -0,0 +1,36 @@
+package com.caimei.service;
+
+import com.caimei.model.ResponseJson;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/4/25
+ */
+public interface OrderSubmitService {
+    /**
+     * 商品结算
+     *
+     * @param productIds   商品ID串用逗号隔开。
+     * @param productCount 立即购买商品数量
+     * @param userId       用户id。
+     * @return
+     */
+    ResponseJson<Map<String, Object>> orderConfirm(String productIds, Integer productCount, Integer userId);
+
+    /**
+     * 提交订单
+     *
+     * @param userId
+     * @param cartType
+     * @param addressId
+     * @param orderInfo
+     * @param payInfo
+     * @return
+     */
+    ResponseJson<Map<String, String>> orderSubmit(Integer userId, Integer cartType, Integer addressId, List<Map<String, Object>> orderInfo, Map<String, Object> payInfo);
+}

+ 60 - 0
src/main/java/com/caimei/service/ShoppingCartService.java

@@ -0,0 +1,60 @@
+package com.caimei.service;
+
+import com.caimei.model.ResponseJson;
+import com.caimei.model.dto.CartDto;
+import com.caimei.model.vo.CartProductVo;
+
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/23
+ */
+public interface ShoppingCartService {
+    /**
+     * 加入购物车
+     *
+     * @param cart
+     * @return
+     */
+    ResponseJson<Integer> addShoppingCart(CartDto cart);
+
+    /**
+     * 统计购物车数量
+     *
+     * @param userId
+     * @return
+     */
+    ResponseJson<Integer> getCartQuantity(Integer userId);
+
+    /**
+     * 购物车数据
+     *
+     * @param userId
+     * @return
+     */
+    ResponseJson<Map<String, Object>> shoppingInfo(Integer userId);
+
+    /**
+     * 更新购物车商品数量
+     *
+     * @param cartId
+     * @param productCount
+     */
+    void updateNumber(Integer cartId, Integer productCount);
+
+    /**
+     * 删除购物车商品
+     *
+     * @param cartIds
+     * @return
+     */
+    ResponseJson<String> deleteCart(String cartIds);
+
+    /**
+     * 设置活动价格阶梯
+     */
+    void setPrice(CartProductVo product);
+}

+ 670 - 0
src/main/java/com/caimei/service/impl/OrderSubmitServiceImpl.java

@@ -0,0 +1,670 @@
+package com.caimei.service.impl;
+
+import com.caimei.mapper.OrderSubmitMapper;
+import com.caimei.mapper.ProductMapper;
+import com.caimei.model.ResponseJson;
+import com.caimei.model.po.*;
+import com.caimei.model.vo.ActivityLadderVo;
+import com.caimei.model.vo.AddressVo;
+import com.caimei.model.vo.CartProductVo;
+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.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+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;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/4/25
+ */
+@Slf4j
+@Service
+public class OrderSubmitServiceImpl implements OrderSubmitService {
+    @Resource
+    private OrderSubmitMapper orderSubmitMapper;
+    @Resource
+    private ShoppingCartService shoppingCartService;
+    @Resource
+    private ProductMapper productMapper;
+    @Value("${caimei.oldapi}")
+    private String domain;
+
+    @Override
+    public ResponseJson<Map<String, Object>> orderConfirm(String productIds, Integer productCount, Integer userId) {
+        Map<String, Object> confirmData = new HashMap<>(5);
+        if (userId != null) {
+            log.info("<<<<< 结算订单 >>>>>");
+            //商品总金额
+            AtomicReference<BigDecimal> totalPrice = new AtomicReference<BigDecimal>(BigDecimal.ZERO);
+            String[] productId = productIds.split(",");
+            List<ShopVo> shopList = orderSubmitMapper.findShopByproductIds(productId);
+            shopList.forEach(shop -> {
+                shop.setLogo(ProductUtils.getImageURL("shopLogo", shop.getLogo(), 0, domain));
+                List<CartProductVo> products = orderSubmitMapper.findByShopCartProduct(shop.getShopId(), productId, userId);
+                BigDecimal shopTotalPrice = BigDecimal.ZERO;
+                for (CartProductVo product : products) {
+                    //立即购买
+                    if (productCount != null && productCount > 0) {
+                        product.setProductCount(productCount);
+                    }
+                    shoppingCartService.setPrice(product);
+                    shopTotalPrice = MathUtil.add(shopTotalPrice, MathUtil.mul(product.getProductCount(), product.getPrice()));
+                }
+                shop.setShopTotalPrice(shopTotalPrice);
+                shop.setProductList(products);
+                totalPrice.set(MathUtil.add(totalPrice.get(), shopTotalPrice));
+            });
+            confirmData.put("totalPrice", totalPrice);
+            confirmData.put("shopList", shopList);
+            return ResponseJson.success(confirmData);
+        } else {
+            return ResponseJson.error("登录后才能购买", null);
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public ResponseJson<Map<String, String>> orderSubmit(Integer userId, Integer cartType, Integer addressId, List<Map<String, Object>> orderInfo, Map<String, Object> payInfo) {
+        /*
+         * 逻辑处理 start
+         */
+        log.info("******************** 提交订单逻辑处理 start *******************");
+        //机构用户
+        UserPo user = orderSubmitMapper.findUser(userId);
+        if (null == user) {
+            return ResponseJson.error("用户信息异常", null);
+        }
+        // 商品总数量
+        Integer productCount = 0;
+        // 商品总金额 (商品单价乘以数量,再加上税费[默认0])
+        BigDecimal productTotalFee = BigDecimal.ZERO;
+        // 小计金额(商品折后单价乘以数量,再加上税费[默认0])
+        BigDecimal orderTotalFee = BigDecimal.ZERO;
+        // 订单总额(小计金额减去经理折扣后,再加上运费[默认0])
+        BigDecimal payTotalFee = BigDecimal.ZERO;
+        // 真实支付金额(订单总额减去抵扣的账户余额)
+        BigDecimal payableAmount = BigDecimal.ZERO;
+
+        /*
+         * 初始化主订单参数
+         */
+        CmOrderPo order = new CmOrderPo();
+        String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date());
+        // 订单号
+        String orderNo = null;
+        orderNo = OrderNoUtils.getOrderNo("H");
+        order.setOrderNo(orderNo);
+        // 运营人员下单
+        order.setBuyUserID(user.getUserID());
+        order.setOrderType(2);
+        order.setOrderSubmitType(0);
+        order.setConfirmFlag("2");
+        order.setUserID(user.getUserID().longValue());
+        // 订单来源
+        order.setOrderSource("6");
+        order.setOrganizeID(0);
+        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("0");
+        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");
+        /*
+         * 订单商品
+         */
+        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)) {
+                // 遍历所有商品
+                for (Map<String, Integer> productTemp : productInfoList) {
+                    Integer productId = productTemp.get("productId");
+                    Integer productNum = productTemp.get("productNum");
+                    // 统计商品总数量
+                    productCount += productNum;
+
+                    // 获取商品信息
+                    CmHeHeProductPo product = orderSubmitMapper.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);
+                    int priceType = 0;
+                    //不含税可开票商品计算税费
+                    Integer activityId = productMapper.findActivityByProductId(product.getProductId());
+                    if (activityId != null && activityId > 0) {
+                        //活动阶梯
+                        List<ActivityLadderVo> ladderList = productMapper.findActivityLadder(activityId, product.getProductId());
+                        if (ladderList != null && ladderList.size() > 0) {
+                            priceType = 1;
+                            for (ActivityLadderVo ladder : ladderList) {
+                                if (productNum >= ladder.getBuyNum()) {
+                                    productPrice = ladder.getBuyPrice();
+                                }
+                            }
+                        }
+                    }
+                    //税费
+                    boolean addTaxFlag = (0 == product.getIncludedTax()) && (1 == product.getInvoiceType() || 2 == product.getInvoiceType());
+                    if (addTaxFlag) {
+                        addedValueTax = MathUtil.div(MathUtil.mul(productPrice, product.getClubTaxPoint()), BigDecimal.valueOf(100));
+                        productPrice = MathUtil.add(productPrice, addedValueTax);
+                        product.setPrice(productPrice);
+                    }
+                    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, priceType, productPrice, addedValueTax);
+                    // 加入订单商品列表
+                    orderProductList.add(orderProduct);
+
+                    if (cartType == 1) {
+                        orderSubmitMapper.deleteCartByProductId(user.getUserID(), product.getProductId());
+                        log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>删除用户购物车数据productId:" + product.getProductId());
+                    }
+                }
+            }
+        }
+
+        // 设置是否是二手订单
+        order.setSecondHandOrderFlag("0");
+        order.setPromotionFullReduction(BigDecimal.ZERO);
+        // 商品总数量
+        order.setProductCount(productCount);
+        // 赠品数量
+        order.setPresentCount(0);
+        //促销赠品数量
+        order.setPromotionalGiftsCount(0);
+        // 0包邮 -1到付 1 有运费
+        order.setFreePostFlag("0");
+        order.setFreight(BigDecimal.ZERO);
+        // 商品总额
+        order.setProductTotalFee(productTotalFee);
+        // 订单总额(商品金额+运费)
+        payTotalFee = productTotalFee;
+        orderTotalFee = productTotalFee;
+        order.setOrderTotalFee(orderTotalFee);
+        order.setPayTotalFee(payTotalFee);
+        payableAmount = payTotalFee;
+        // 订单状态
+        order.setStatus("11");
+        order.setConfirmTime(curDateStr);
+
+        // 余额支付金额
+        order.setBalancePayFee(BigDecimal.ZERO);
+        // 实际支付金额(商品金额+运费-余额抵扣)
+        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());
+
+        /**
+         * 设置订单商品订单号
+         */
+        for (CmOrderProductPo orderProduct : orderProductList) {
+            orderProduct.setOrderID(order.getOrderID());
+            orderProduct.setOrderNo(order.getOrderNo());
+            orderProduct.setOrganizeID(order.getOrganizeID());
+        }
+
+        /**
+         * 整理 子订单信息
+         */
+        // 收集子订单供应商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())) {
+                //使用阶梯价格的订单商品保存下单时的阶梯价格列表
+                Integer activityId = productMapper.findActivityByProductId(orderProduct.getProductID());
+                if (activityId != null && activityId > 0) {
+                    List<ActivityLadderVo> ladderPriceList = productMapper.findActivityLadder(activityId, orderProduct.getProductID());
+                    int ladderNum = 0;
+                    for (ActivityLadderVo ladder : ladderPriceList) {
+                        ladderNum++;
+                        OrderProductLadderPricePo orderProductLadderPrice = new OrderProductLadderPricePo();
+                        orderProductLadderPrice.setOrderProductId(orderProduct.getOrderProductID());
+                        orderProductLadderPrice.setBuyNum(ladder.getBuyNum());
+                        orderProductLadderPrice.setBuyPrice(ladder.getBuyPrice());
+                        orderProductLadderPrice.setCreateDate(new Date());
+                        orderProductLadderPrice.setLadderNum(ladderNum);
+                        orderProductLadderPriceList.add(orderProductLadderPrice);
+                    }
+                }
+            }
+        }
+        if (!CollectionUtils.isEmpty(orderProductLadderPriceList)) {
+            orderProductLadderPriceList.forEach(ladderPrice -> {
+                orderSubmitMapper.insertOrderProductLadderPrice(ladderPrice);
+            });
+        }
+
+        // 更新主订单信息, 子订单ID:1000,1002
+        order.setShopOrderIDs(shopOrderIds);
+        orderSubmitMapper.updateOrder(order);
+
+        /**
+         * 保存 订单用户地址
+         */
+        // 获取地址信息
+        AddressVo address = orderSubmitMapper.findByAddressId(addressId);
+        if (null != address) {
+            //保存地址信息
+            BpOrderUserInfoPo userInfo = new BpOrderUserInfoPo();
+            userInfo.setOrderId(order.getOrderID());
+            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);
+        }
+
+        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 productNum
+     * @param product
+     * @param priceType    0机构价,1活动阶梯价
+     * @param productPrice
+     * @return
+     */
+    private CmOrderProductPo setOrderProduct(Integer productNum, CmHeHeProductPo product, int priceType, BigDecimal productPrice, BigDecimal addedValueTax) {
+        CmOrderProductPo orderProduct = new CmOrderProductPo();
+        orderProduct.setShopID(product.getShopId().longValue());
+        orderProduct.setProductID(product.getProductId());
+        orderProduct.setOrganizeProductID(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 (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)));
+        //不含税可开票商品,单价/折后单价=售价-税费
+
+        //阶梯价
+        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);
+        if (priceType == 1) {
+            orderProduct.setIsActProduct("1");
+            orderProduct.setLadderPriceFlag("1");
+        } else {
+            orderProduct.setIsActProduct("1");
+            orderProduct.setLadderPriceFlag("0");
+        }
+        orderProduct.setProductImage(ProductUtils.getImageURL("product", product.getMainImage(), 0, domain));
+        orderProduct.setProductType("0");
+        return orderProduct;
+    }
+
+    /**
+     * 保存子订单,并返回子订单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 (StringUtils.isNotBlank(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.setOrderID(order.getOrderID());
+        shopOrder.setOrderNo(order.getOrderNo());
+        shopOrder.setUserID(order.getUserID().intValue());
+        shopOrder.setOrganizeID(order.getOrganizeID());
+        /*
+         *  统计子订单金额信息
+         */
+        // 订单总金额
+        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;
+    }
+}

+ 10 - 4
src/main/java/com/caimei/service/impl/ProductServiceImpl.java

@@ -50,10 +50,10 @@ public class ProductServiceImpl implements ProductService {
             product.setMainImage(ProductUtils.getImageURL("product", product.getMainImage(), 0, domain));
             Integer activityId = productMapper.findActivityByProductId(product.getProductId());
             if (activityId != null && activityId > 0) {
-                product.setActiveStatus(1);
                 //活动阶梯
                 List<ActivityLadderVo> ladderList = productMapper.findActivityLadder(activityId, product.getProductId());
                 if (ladderList != null && ladderList.size() > 0) {
+                    product.setActiveStatus(1);
                     product.setPrice(ladderList.get(0).getBuyPrice());
                 }
             }
@@ -130,18 +130,24 @@ public class ProductServiceImpl implements ProductService {
         List<RelatedParametersVo> parametersList = productMapper.findParameters(product.getProductId());
         product.setParametersList(parametersList);
 
+        //税费
+        boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
         Integer activityId = productMapper.findActivityByProductId(product.getProductId());
         if (activityId != null && activityId > 0) {
-            product.setActiveStatus(1);
             //活动阶梯
             List<ActivityLadderVo> ladderList = productMapper.findActivityLadder(activityId, product.getProductId());
             if (ladderList != null && ladderList.size() > 0) {
                 product.setPrice(ladderList.get(0).getBuyPrice());
+                product.setActiveStatus(1);
+                for (ActivityLadderVo ladder : ladderList) {
+                    if (addTaxFlag) {
+                        BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(ladder.getBuyPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100));
+                        ladder.setBuyPrice(MathUtil.add(addedValueTax, ladder.getBuyPrice()));
+                    }
+                }
             }
             product.setLadderList(ladderList);
         }
-        //税费
-        boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
         if (addTaxFlag) {
             BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(product.getPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100));
             BigDecimal price = MathUtil.add(product.getPrice(), addedValueTax);

+ 125 - 0
src/main/java/com/caimei/service/impl/ShoppingCartServiceImpl.java

@@ -0,0 +1,125 @@
+package com.caimei.service.impl;
+
+import com.caimei.mapper.ProductMapper;
+import com.caimei.mapper.ShoppingCartMapper;
+import com.caimei.model.ResponseJson;
+import com.caimei.model.dto.CartDto;
+import com.caimei.model.po.CmCartPo;
+import com.caimei.model.vo.ActivityLadderVo;
+import com.caimei.model.vo.CartProductVo;
+import com.caimei.model.vo.ShopVo;
+import com.caimei.service.ShoppingCartService;
+import com.caimei.util.MathUtil;
+import com.caimei.util.ProductUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/23
+ */
+@Service
+public class ShoppingCartServiceImpl implements ShoppingCartService {
+    @Resource
+    private ShoppingCartMapper shoppingCartMapper;
+    @Resource
+    private ProductMapper productMapper;
+    @Value("${caimei.oldapi}")
+    private String domain;
+
+    @Override
+    public ResponseJson<Integer> addShoppingCart(CartDto cart) {
+        CmCartPo cartPo = shoppingCartMapper.findCartProduct(cart.getUserId(), cart.getProductId());
+        if (cartPo == null) {
+            shoppingCartMapper.insertCart(cart);
+        } else {
+            int productCount = cartPo.getProductCount() + cart.getProductCount();
+            shoppingCartMapper.updateByProductCount(cartPo.getCartId(), productCount);
+        }
+        Integer cartQuantity = shoppingCartMapper.getCartQuantity(cart.getUserId());
+        return ResponseJson.success(cartQuantity);
+    }
+
+    @Override
+    public ResponseJson<Integer> getCartQuantity(Integer userId) {
+        Integer cartQuantity = shoppingCartMapper.getCartQuantity(userId);
+        return ResponseJson.success(cartQuantity);
+    }
+
+    @Override
+    public ResponseJson<Map<String, Object>> shoppingInfo(Integer userId) {
+        Map<String, Object> map = new HashMap<>(3);
+        List<ShopVo> shopList = shoppingCartMapper.findCartShop(userId);
+        shopList.forEach(shop -> {
+            shop.setLogo(ProductUtils.getImageURL("shopLogo", shop.getLogo(), 0, domain));
+            BigDecimal shopTotalPrice = BigDecimal.ZERO;
+            List<CartProductVo> productList = shoppingCartMapper.findByShopCartProduct(shop.getShopId(), userId);
+            for (CartProductVo product : productList) {
+                setPrice(product);
+                shopTotalPrice = MathUtil.add(shopTotalPrice, MathUtil.mul(product.getProductCount(), product.getPrice()));
+            }
+            shop.setShopTotalPrice(shopTotalPrice);
+            shop.setProductList(productList);
+        });
+        map.put("shopList", shopList);
+        //失效商品
+        List<CartProductVo> products = shoppingCartMapper.findExpiredGoods(userId);
+        map.put("products", products);
+        //商品数量
+        Integer cartQuantity = shoppingCartMapper.getCartQuantity(userId);
+        map.put("cartQuantity", cartQuantity);
+        return ResponseJson.success(map);
+    }
+
+    /**
+     * 设置活动价格阶梯
+     */
+    @Override
+    public void setPrice(CartProductVo product) {
+        //税费
+        boolean addTaxFlag = ("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType())));
+        Integer activityId = productMapper.findActivityByProductId(product.getProductId());
+        if (activityId != null && activityId > 0) {
+            //活动阶梯
+            List<ActivityLadderVo> ladderList = productMapper.findActivityLadder(activityId, product.getProductId());
+            if (ladderList != null && ladderList.size() > 0) {
+                product.setActiveStatus(1);
+                for (ActivityLadderVo ladder : ladderList) {
+                    if (addTaxFlag) {
+                        BigDecimal addedValueTax = MathUtil.div(MathUtil.mul(ladder.getBuyPrice(), product.getClubTaxPoint()), BigDecimal.valueOf(100));
+                        ladder.setBuyPrice(MathUtil.add(addedValueTax, ladder.getBuyPrice()));
+                    }
+                    if (product.getProductCount() >= ladder.getBuyNum()) {
+                        product.setPrice(ladder.getBuyPrice());
+                    }
+                }
+            }
+            product.setLadderList(ladderList);
+        }
+    }
+
+    @Override
+    public void updateNumber(Integer cartId, Integer productCount) {
+        shoppingCartMapper.updateByProductCount(cartId, productCount);
+    }
+
+    @Override
+    public ResponseJson<String> deleteCart(String cartIds) {
+        String[] split = cartIds.split(",");
+        for (String cartId : split) {
+            if (!StringUtils.isEmpty(cartId)) {
+                shoppingCartMapper.deleteCart(cartId);
+            }
+        }
+        return ResponseJson.success("删除购物车成功");
+    }
+}

+ 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;
+        }
+    }
+}

+ 3 - 0
src/main/resources/backup.sql

@@ -89,3 +89,6 @@ CREATE TABLE `cm_hehe_user_activity`(
   PRIMARY KEY (`id`)
 ) ENGINE=INNODB CHARSET=utf8mb4
 COMMENT='呵呵分销用户活动商品表';
+
+ALTER TABLE `cm_order`
+  CHANGE `orderType` `orderType` INT NULL   COMMENT '订单类型 0协销订单、 1普通订单、 2呵呵订单';

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

@@ -0,0 +1,1601 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei.mapper.OrderSubmitMapper">
+    <select id="findShopByproductIds" resultType="com.caimei.model.vo.ShopVo">
+        SELECT
+          s.shopID AS shopId,
+          s.name,
+          s.logo
+        FROM
+          cm_hehe_product chp
+          LEFT JOIN product p ON chp.productId = p.productID
+          LEFT JOIN shop s ON p.shopID = s.shopID
+          LEFT JOIN cm_cart cc ON chp.productId = cc.productID
+        WHERE
+          chp.productId IN
+        <foreach item="productId" index="index" collection="productIds" open="(" separator="," close=")">
+            #{productId}
+        </foreach>
+        GROUP BY
+          s.shopID
+        ORDER BY
+          MAX(cc.addTime) DESC
+    </select>
+
+    <select id="findByShopCartProduct" resultType="com.caimei.model.vo.CartProductVo">
+        SELECT
+          cc.cm_cartID AS cartId,
+          cc.productID AS productId,
+          cc.productCount,
+          chp.price,
+          chp.includedTax,
+          chp.invoiceType,
+          chp.clubTaxPoint,
+          p.name AS productName,
+          p.shopID AS shopId,
+          p.mainImage,
+          p.unit
+        FROM
+          cm_cart cc
+          LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
+          LEFT JOIN product p ON cc.productID = p.productID
+        WHERE
+          cc.userID = #{userId}
+          AND chp.validFlag = 1
+          AND p.shopID = #{shopId}
+          AND chp.productId IN
+        <foreach item="productId" index="index" collection="productIds" open="(" separator="," close=")">
+            #{productId}
+        </foreach>
+    </select>
+
+    <select id="findUser" resultType="com.caimei.model.po.UserPo">
+        SELECT
+          userID,
+          mobile,
+          bindMobile,
+          userName,
+          name
+        FROM
+          user
+        WHERE
+          userID = #{userId}
+    </select>
+
+    <select id="getProduct" resultType="com.caimei.model.po.CmHeHeProductPo">
+        SELECT
+          chp.id,
+          chp.productId,
+          chp.price,
+          chp.includedTax,
+          chp.invoiceType,
+          p.costCheckFlag AS costType,
+          chp.clubTaxPoint,
+          chp.shopTaxPoint,
+          p.costPrice,
+          p.costProportional,
+          p.shopID AS shopId,
+          p.unit,
+          p.normalPrice,
+          p.name,
+          p.mainImage,
+          s.name AS shopName
+        FROM
+          cm_hehe_product chp
+          LEFT JOIN product p ON chp.productId = p.productID
+          LEFT JOIN shop s ON p.shopID = s.shopID
+        WHERE
+          chp.productId = #{productId}
+    </select>
+
+    <delete id="deleteCartByProductId">
+        DELETE FROM cm_cart WHERE userID = #{userId} AND productID = #{productId}
+    </delete>
+
+    <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="organizeID != null">
+                organizeID,
+            </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="organizeID != null">
+                #{organizeID},
+            </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>
+
+    <select id="findMaxShopOrderNo" resultType="java.lang.String">
+        SELECT
+          shopOrderNo
+        FROM
+          cm_shop_order
+        WHERE
+          orderID = #{orderId}
+        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="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">
+                #{organizeID},
+            </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="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">
+                #{organizeID},
+            </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="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="findByAddressId" resultType="com.caimei.model.vo.AddressVo">
+        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>
+
+    <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>
+</mapper>

+ 124 - 0
src/main/resources/mapper/ShoppingCartMapper.xml

@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei.mapper.ShoppingCartMapper">
+    <select id="findCartProduct" resultType="com.caimei.model.po.CmCartPo">
+        SELECT
+          cm_cartID AS cartId,
+          productID,
+          userID,
+          productCount,
+          addTime,
+          isOutOfTime,
+          skuID,
+          reBuyFlag
+        FROM
+          cm_cart
+        WHERE
+          userID = #{userId}
+          AND productID = #{productId}
+    </select>
+
+    <insert id="insertCart">
+        INSERT INTO cm_cart (
+          productID, userID, productCount, ADDTIME,
+          reBuyFlag
+        )
+        VALUES
+          (
+            #{productId}, #{userId}, #{productCount}, NOW(),
+            0
+          )
+    </insert>
+
+    <update id="updateByProductCount">
+        UPDATE
+          cm_cart
+        SET
+          productCount = #{productCount},
+          addTime = NOW()
+        WHERE
+          cm_cartID = #{cartId}
+    </update>
+
+    <select id="getCartQuantity" resultType="integer">
+        SELECT
+          COUNT(cc.productID)
+        FROM
+          cm_cart cc
+          LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
+        WHERE
+          cc.userID = #{userId}
+          AND chp.validFlag = 1
+    </select>
+
+    <select id="findCartShop" resultType="com.caimei.model.vo.ShopVo">
+        SELECT
+          s.shopID AS shopId,
+          s.name,
+          s.logo
+        FROM
+          cm_cart cc
+          LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
+          LEFT JOIN product p ON cc.productID = p.productID
+          LEFT JOIN shop s ON p.shopID = s.shopID
+        WHERE
+          cc.userID = #{userId}
+          AND chp.validFlag = 1
+        GROUP BY
+          s.shopID
+        ORDER BY
+          MAX(cc.addTime) DESC
+
+    </select>
+
+    <select id="findByShopCartProduct" resultType="com.caimei.model.vo.CartProductVo">
+        SELECT
+          cc.cm_cartID AS cartId,
+          cc.productID AS productId,
+          cc.productCount,
+          chp.price,
+          chp.includedTax,
+          chp.invoiceType,
+          chp.clubTaxPoint,
+          p.name AS productName,
+          p.shopID AS shopId,
+          p.mainImage,
+          p.unit
+        FROM
+          cm_cart cc
+          LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
+          LEFT JOIN product p ON cc.productID = p.productID
+        WHERE
+          cc.userID = #{userId}
+          AND chp.validFlag = 1
+          AND p.shopID = #{shopId}
+    </select>
+
+    <select id="findExpiredGoods" resultType="com.caimei.model.vo.CartProductVo">
+        SELECT
+          cc.cm_cartID AS cartId,
+          cc.productID AS productId,
+          cc.productCount,
+          chp.price,
+          chp.includedTax,
+          chp.invoiceType,
+          chp.clubTaxPoint,
+          p.name AS productName,
+          p.shopID AS shopId,
+          p.mainImage,
+          p.unit
+        FROM
+          cm_cart cc
+          LEFT JOIN cm_hehe_product chp ON cc.productID = chp.productId
+          LEFT JOIN product p ON cc.productID = p.productID
+        WHERE
+          cc.userID = #{userId}
+          AND chp.validFlag = 2
+    </select>
+
+    <delete id="deleteCart">
+        DELETE FROM cm_cart WHERE cm_cartID = #{cartId}
+    </delete>
+</mapper>