소스 검색

修改订单

zhijiezhao 1 년 전
부모
커밋
3647cf53aa

+ 63 - 47
src/main/java/com/caimei365/order/controller/OrderSubmitApi.java

@@ -3,6 +3,8 @@ package com.caimei365.order.controller;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.RechargeDto;
 import com.caimei365.order.model.dto.SubmitDto;
+import com.caimei365.order.model.po.OrderProductPo;
+import com.caimei365.order.model.vo.OrderProductVo;
 import com.caimei365.order.service.SubmitService;
 import com.caimei365.order.utils.MathUtil;
 import io.swagger.annotations.Api;
@@ -13,6 +15,7 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -21,7 +24,7 @@ import java.util.Map;
  * @author : Charles
  * @date : 2021/7/6
  */
-@Api(tags="提交订单API")
+@Api(tags = "提交订单API")
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/order/submit")
@@ -39,76 +42,76 @@ public class OrderSubmitApi {
      *                  "cartType":3,               //购买类型:(1自主下单(购物车),2自主下单(立即购买),3协销下单)
      *                  "serviceProviderId": 1378,  //协销ID(小程序忽略)
      *                  "clubCouponId": ""          //优惠券Id
-     *                   "orderSeen":               //订单对机构可见度,1可见,2不可见
+     *                  "orderSeen":               //订单对机构可见度,1可见,2不可见
      *                  "orderInfo": [              //【订单商品】
-     *                      { "shopId":1001,                         // 供应商Id
-     *                        "splitCode:E123123"       //分账号
-     *                        "note":备注,
-     *                        "productInfo":[                      // skuId,数量,赠品数,商品类型
-     *                              {"skuId": 2789, "productNum": 1, "presentNum":0,"productType":2},
-     *                              {"skuId": 2789, "productNum": 1, "presentNum":0,"productType":0}
-     *                          ]
-     *                      },{多个供应商商品数据结构同上}
+     *                  { "shopId":1001,                         // 供应商Id
+     *                  "splitCode:E123123"       //分账号
+     *                  "note":备注,
+     *                  "productInfo":[                      // skuId,数量,赠品数,商品类型
+     *                  {"skuId": 2789, "productNum": 1, "presentNum":0,"productType":2},
+     *                  {"skuId": 2789, "productNum": 1, "presentNum":0,"productType":0}
+     *                  ]
+     *                  },{多个供应商商品数据结构同上}
      *                  ],
      *                  "payInfo": {                //【订单金额】
-     *                      "orderShouldPayFee": 609.11,
-     *                      "balancePayFlag": 0,
-     *                      "clauseId": "2",
-     *                      "postage": "15",
-     *                      "postageFlag": 1,
-     *                      "userBeans": 100,//抵扣采美豆数量
-     *                      "rebateFlag":0,
-     *                      "rebateFee":0.00 //普通订单返佣服务费
+     *                  "orderShouldPayFee": 609.11,
+     *                  "balancePayFlag": 0,
+     *                  "clauseId": "2",
+     *                  "postage": "15",
+     *                  "postageFlag": 1,
+     *                  "userBeans": 100,//抵扣采美豆数量
+     *                  "rebateFlag":0,
+     *                  "rebateFee":0.00 //普通订单返佣服务费
      *                  },
      *                  "orderInvoice":             //【发票信息】
-     *                          {"type": 0 // 不开发票  }
-     *                      或: { // 普通发票
-     *                              "type": 1,
-     *                              "invoiceTitle": "企业抬头",
-     *                              "invoiceTitleType": 1,
-     *                              "corporationTaxNum": "XXX4156465465",
-     *                              "invoiceContent": "明细 "
-     *                          }
-     *                      或: { // 增值税发票
-     *                              "type": 2,
-     *                              "invoiceTitle": "单位名称",
-     *                              "corporationTaxNum": "NSRSBM97897",
-     *                              "registeredAddress": "注册地址",
-     *                              "registeredPhone": "15814011616",
-     *                              "openBank": "开户银行",
-     *                              "bankAccountNo": "987987465465464"
-     *                          }
-     *
-     *              }
+     *                  {"type": 0 // 不开发票  }
+     *                  或: { // 普通发票
+     *                  "type": 1,
+     *                  "invoiceTitle": "企业抬头",
+     *                  "invoiceTitleType": 1,
+     *                  "corporationTaxNum": "XXX4156465465",
+     *                  "invoiceContent": "明细 "
+     *                  }
+     *                  或: { // 增值税发票
+     *                  "type": 2,
+     *                  "invoiceTitle": "单位名称",
+     *                  "corporationTaxNum": "NSRSBM97897",
+     *                  "registeredAddress": "注册地址",
+     *                  "registeredPhone": "15814011616",
+     *                  "openBank": "开户银行",
+     *                  "bankAccountNo": "987987465465464"
+     *                  }
+     *                  <p>
+     *                  }
      */
 
 
     @ApiOperation("提交订单(旧:/order/submit)(/seller/order/submit)")
     @PostMapping("/generate")
-    public ResponseJson<Map<String, Object>> generateOrder(SubmitDto submitDto){
-        if(null == submitDto.getOrderSource()){
+    public ResponseJson<Map<String, Object>> generateOrder(SubmitDto submitDto) {
+        if (null == submitDto.getOrderSource()) {
             return ResponseJson.error("订单来源不能为空!", null);
         }
         // 1,www来源    2,crm来源    6,小程序来源
-        if (null == submitDto.getOrderSource()  || !(1 == submitDto.getOrderSource() || 2 == submitDto.getOrderSource() || 6 == submitDto.getOrderSource())) {
+        if (null == submitDto.getOrderSource() || !(1 == submitDto.getOrderSource() || 2 == submitDto.getOrderSource() || 6 == submitDto.getOrderSource())) {
             return ResponseJson.error("订单来源异常!", null);
         }
-        if(null == submitDto.getCartType()){
+        if (null == submitDto.getCartType()) {
             return ResponseJson.error("购买类型不能为空!", null);
         }
-        if(null == submitDto.getClubId()){
+        if (null == submitDto.getClubId()) {
             return ResponseJson.error("机构Id不能为空!", null);
         }
-        if(null == submitDto.getAddressId()){
+        if (null == submitDto.getAddressId()) {
             return ResponseJson.error("收货地址Id不能为空!", null);
         }
-        if (StringUtils.isEmpty(submitDto.getOrderInfo())){
+        if (StringUtils.isEmpty(submitDto.getOrderInfo())) {
             return ResponseJson.error("订单商品数据不能为空!", null);
         }
-        if (StringUtils.isEmpty(submitDto.getPayInfo())){
+        if (StringUtils.isEmpty(submitDto.getPayInfo())) {
             return ResponseJson.error("订单金额数据不能为空!", null);
         }
-        if (StringUtils.isEmpty(submitDto.getOrderInvoice())){
+        if (StringUtils.isEmpty(submitDto.getOrderInvoice())) {
             return ResponseJson.error("发票信息数据不能为空!", null);
         }
         if (3 == submitDto.getCartType() && null == submitDto.getServiceProviderId()) {
@@ -119,6 +122,7 @@ public class OrderSubmitApi {
 
     /**
      * 生成充值商品订单
+     *
      * @param rechargeDto {
      *                    serviceProviderId 协销id
      *                    clubId            机构id
@@ -129,7 +133,7 @@ public class OrderSubmitApi {
      */
     @ApiOperation("提交充值商品订单(旧:/order/submit/rechargeOrder)")
     @PostMapping("/recharge")
-    public ResponseJson<Map<String, Object>> generateRechargeOrder(RechargeDto rechargeDto){
+    public ResponseJson<Map<String, Object>> generateRechargeOrder(RechargeDto rechargeDto) {
         if (null == rechargeDto.getServiceProviderId()) {
             return ResponseJson.error("协销Id不能为空!", null);
         }
@@ -145,4 +149,16 @@ public class OrderSubmitApi {
         return submitService.generateRechargeOrder(rechargeDto);
     }
 
+    /**
+     * 生成充值商品订单
+     */
+    @ApiOperation("修改订单")
+    @PostMapping("/update")
+    public ResponseJson updateOrder(List<OrderProductVo> orderProducts) {
+        if (null == orderProducts) {
+            return ResponseJson.error("订单不能为空!", null);
+        }
+        return submitService.updateOrder(orderProducts);
+    }
+
 }

+ 80 - 13
src/main/java/com/caimei365/order/mapper/BaseMapper.java

@@ -20,6 +20,7 @@ import java.util.List;
 public interface BaseMapper {
     /**
      * 获取用户组织Id -- userId
+     *
      * @param userId
      * @return
      */
@@ -27,28 +28,36 @@ public interface BaseMapper {
 
     /**
      * 获取用户组织Id -- shopOrderId
+     *
      * @param shopOrderId
      * @return
      */
     Integer getOrganizeIdShop(@Param("shopOrderId") Integer shopOrderId);
+
     /**
      * 供应商名称
+     *
      * @param shopId 供应商Id
      */
     String getShopNameById(Integer shopId);
+
     /**
      * 供应商名称
+     *
      * @param clubId 供应商Id
      */
     String getClubNameById(Integer clubId);
+
     /**
      * 获取商品供应商Id
+     *
      * @param skuId skuId
      */
     Integer getShopIdByproductId(Integer skuId);
 
     /**
      * 获取机构一级分类
+     *
      * @param clubId
      * @return
      */
@@ -56,152 +65,200 @@ public interface BaseMapper {
 
     /**
      * 商品对应械字号类型
+     *
      * @param skuIds
      * @return
      */
     List<String> machineTypeByID(List<String> skuIds);
+
     /**
      * 获取机构用户Id
+     *
      * @param clubId 机构Id
      */
     Integer getUserIdByClubId(Integer clubId);
+
     /**
      * 根据用户Id查询用户身份
      */
     Integer getIdentityByUserId(Integer userId);
+
     /**
      * 根据用户Id查询公司名
      */
     String getUserNameByUserId(Integer userId);
+
     /**
      * 根据用户Id查询手机号
      */
     String getBindMobileByUserId(Integer userId);
+
     /**
      * 根据商品ID查询阶梯价列表
      */
     List<LadderPriceVo> getLadderPriceList(Integer skuId);
+
     /**
      * 根据skuId和用户ID 查询复购价
      */
     Double getRepurchasePrice(@Param("skuId") Integer skuId, @Param("userId") Integer userId);
+
     /**
      * 供应商促销优惠活动
+     *
      * @param shopId 供应商Id
      */
     PromotionsVo getPromotionByShopId(Integer shopId);
+
     /**
      * 商品促销优惠活动
+     *
      * @param productId 商品Id
      */
     PromotionsVo getPromotionByProductId(Integer productId);
+
     /**
      * 促销优惠活动赠品列表
+     *
      * @param promotionsId 促销Id
      */
     List<CartItemVo> getPromotionGifts(Integer promotionsId);
+
     /**
      * 根据商品Id获取供应商
+     *
      * @param productId 商品Id
      */
     CartShopVo getShopByProductId(Integer productId);
+
     /**
      * 发票信息
+     *
      * @param userId 用户Id
      */
     InvoiceVo getUserInvoice(Integer userId);
+
     /**
      * 根据用户Id获取用户余额
+     *
      * @param userId 用户Id
      */
     Double getUserMoney(Integer userId);
+
     /**
      * 可用余额
+     *
      * @param userId 用户Id
      */
     Double getAbleUserMoney(Integer userId);
+
     /**
      * 可用采美豆
+     *
      * @param userId 用户Id
      */
     Integer getUserBeans(Integer userId);
+
     /**
      * 获取商品运费 (0包邮 1到付 2默认(遵循运费规则))
-     * @param skuIds    skuId列表
+     *
+     * @param skuIds skuId列表
      */
     List<ProductPostageVo> getPostageFlagList(@Param("skuIds") List<String> skuIds);
+
     /**
      * 获取商品运费 (0包邮 1到付 2默认(遵循运费规则)) -- 组织
-     * @param skuIds    skuId列表
+     *
+     * @param skuIds skuId列表
      */
     List<ProductPostageVo> getPostageFlagOrganizeList(@Param("skuIds") List<String> skuIds);
 
     /**
      * 获取购物车商品数据
+     *
      * @param userId
      * @param skuIds
      * @return
      */
     List<CartPo> getCart(Integer userId, @Param("skuIds") List<String> skuIds);
+
     /**
      * 统计用户订单数
+     *
      * @param userId 用户Id
      */
     Integer countUserOrder(Integer userId);
+
     /**
      * 获取根据地区Id获取省市地址信息
+     *
      * @param townId 地区Id
      */
     AddressVo getProvinceIdAndCityId(Integer townId);
+
     /**
      * 获取详细地址信息
+     *
      * @param addressId 地址Id
      */
     Integer getTownIdByAddressId(Integer addressId);
+
     /**
      * 更新用户增值税发票
      */
     void updateUserInvoiceByUserId(InvoiceVo invoice);
+
     /**
      * 新增用户增值税发票
      */
     void insertUserInvoiceByUserId(InvoiceVo userInvoice);
+
     /**
      * 查询当前商品复购价信息
-     * @param userId    机构用户Id
-     * @param skuId     skuId
+     *
+     * @param userId 机构用户Id
+     * @param skuId  skuId
      */
     PurchasePricePo getPurchasePricePo(Integer userId, Integer skuId);
+
     /**
      * 更新复购价格库
      */
     void updatePurchasePrice(PurchasePricePo purchase);
+
     /**
      * 新增复购价格库
      */
     void insertPurchasePrice(PurchasePricePo purchase);
+
     /**
      * 新增历史复购价记录
      */
     void insertPurchaseHistory(PurchaseHistoryPo purchaseHistory);
+
     /**
      * 保存 收款记录
      */
     void insertDiscernReceipt(DiscernReceiptPo discernReceipt);
+
     /**
      * 保存 收款项和订单关系
      */
     void insertOrderReceiptRelation(OrderReceiptRelationPo relation);
+
     /**
      * 保存 采美豆使用记录
      */
     void insertBeansHistory(UserBeansHistoryPo beansHistory);
+
     /**
      * 更新用户剩余采美豆数量
+     *
      * @param userBeans 采美豆数量
-     * @param userId 机构用户Id
+     * @param userId    机构用户Id
      */
     void updateUserBeans(Integer userId, int userBeans);
+
     /**
      * 抵扣后更新用户余额
      *
@@ -210,31 +267,37 @@ public interface BaseMapper {
      * @param userId        机构用户Id
      */
     void updateUserMoney(Double userMoney, Double ableUserMoney, Integer userId);
+
     /**
      * 保存余额到余额收支记录
      */
     void insertBalanceRecord(BalanceRecordPo balanceRecord);
+
     /**
      * 获取条款列表
      */
     List<ClauseVo> getClauseList();
+
     /**
      * 查询超级会员用户id
-     * @param userId    用户id
+     *
+     * @param userId 用户id
      * @return
      */
     Integer getSvipUserIdByUserId(Integer userId);
 
     /**
      * 查询超级会员用户id
-     * @param clubId    机构id
+     *
+     * @param clubId 机构id
      * @return
      */
     Integer getSvipUserIdByClubId(Integer clubId);
 
     /**
      * 查询机构状态
-     * @param userId    用户id
+     *
+     * @param userId 用户id
      * @return
      */
     Integer getClubStatus(Integer userId);
@@ -250,24 +313,26 @@ public interface BaseMapper {
     /**
      * 更新user机构状态
      *
-     * @param clubStatus    机构状态
-     * @param userId        用户id
+     * @param clubStatus 机构状态
+     * @param userId     用户id
      */
     void updateUserClubStatus(@Param("clubStatus") int clubStatus, @Param("userId") Integer userId);
 
     /**
      * 更新club机构状态
      *
-     * @param clubStatus    机构状态
-     * @param userId        用户id
+     * @param clubStatus 机构状态
+     * @param userId     用户id
      */
     void updateClubStatus(@Param("clubStatus") int clubStatus, @Param("userId") Integer userId);
 
     UserBeansHistoryPo findLowOrder(Integer orderId);
 
     Integer findBeans(Integer userId);
+
     /**
      * 查询认证通用户名称
+     *
      * @param userId
      * @return
      */
@@ -283,5 +348,7 @@ public interface BaseMapper {
 
     VipSkuPriceDto getSvipSku(Integer skuId);
 
-    Double getTouchPriceBySku(Integer skuId,Integer promotionId);
+    Double getTouchPriceBySku(Integer skuId, Integer promotionId);
+
+    List<BalanceRecordPo> findShopOrderBalanceRecord(Integer shopOrderId);
 }

+ 7 - 4
src/main/java/com/caimei365/order/mapper/SubmitMapper.java

@@ -2,10 +2,7 @@ package com.caimei365.order.mapper;
 
 import com.caimei365.order.model.bo.OrderParamBo;
 import com.caimei365.order.model.po.*;
-import com.caimei365.order.model.vo.AddressVo;
-import com.caimei365.order.model.vo.LadderPriceVo;
-import com.caimei365.order.model.vo.PromotionsVo;
-import com.caimei365.order.model.vo.ShopOrderVo;
+import com.caimei365.order.model.vo.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -171,4 +168,10 @@ public interface SubmitMapper {
     Integer findSplitResult(List<String> productIdList);
 
     OrderProductPo getRechargeProductDetails(Integer productId);
+
+    List<OrderProductVo> findOrderProducts(List<Integer> orderProductIds);
+
+    void updateOrderProduct(OrderProductPo o);
+
+    void updateShopOrder(ShopOrderVo shopOrder);
 }

+ 6 - 0
src/main/java/com/caimei365/order/model/vo/OrderProductVo.java

@@ -15,6 +15,12 @@ import java.math.BigDecimal;
 public class OrderProductVo implements Serializable {
     private static final long serialVersionUID = 1L;
 
+    private Integer organizeId;
+    /**
+     * 商品类型(0正常商品,1协商赠品,2促销赠品)
+     */
+    private Integer productType;
+
     private Integer skuId;
     /**
      * 商品货号

+ 4 - 0
src/main/java/com/caimei365/order/model/vo/ShopOrderVo.java

@@ -17,6 +17,10 @@ import java.util.List;
 @Data
 public class ShopOrderVo implements Serializable {
     private static final long serialVersionUID = 1L;
+    /**
+     * 虚拟字段,不包含店铺满减的子订单应付
+     */
+    private Double realNeedPay;
     /**
      * 返佣服务费
      */

+ 5 - 0
src/main/java/com/caimei365/order/service/SubmitService.java

@@ -3,7 +3,10 @@ package com.caimei365.order.service;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.RechargeDto;
 import com.caimei365.order.model.dto.SubmitDto;
+import com.caimei365.order.model.po.OrderProductPo;
+import com.caimei365.order.model.vo.OrderProductVo;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -29,4 +32,6 @@ public interface SubmitService {
      *                    }
      */
     ResponseJson<Map<String, Object>> generateRechargeOrder(RechargeDto rechargeDto);
+
+    ResponseJson updateOrder(List<OrderProductVo> orderProducts);
 }

+ 548 - 60
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -68,8 +68,7 @@ public class SubmitServiceImpl implements SubmitService {
     @Resource
     private RemoteCallService remoteCallService;
     @Resource
-    private PayOrderMapper payOrderMapper;
-
+    private ShipMapper shipMapper;
 
 
     /**
@@ -129,7 +128,7 @@ public class SubmitServiceImpl implements SubmitService {
     @Transactional(rollbackFor = Exception.class)
     @Override
     public ResponseJson<Map<String, Object>> generateOrder(SubmitDto submitDto) {
-        log.info("submitDto==="+submitDto);
+        log.info("submitDto===" + submitDto);
         // 获取机构用户Id
         Integer clubUserId = baseMapper.getUserIdByClubId(submitDto.getClubId());
         if (null == clubUserId || clubUserId == 0) {
@@ -259,54 +258,54 @@ public class SubmitServiceImpl implements SubmitService {
             }
         } else {
             // 联合丽格*/
-            if (1 == invoiceType || 2 == invoiceType) {
-                InvoicePo invoice = new InvoicePo();
-                String invoiceTitle = (String) orderInvoice.get("invoiceTitle");
-                if (StringUtils.isEmpty(invoiceTitle)) {
-                    return ResponseJson.error("发票抬头信息不正确!", null);
-                }
-                invoice.setType(invoiceType);
-                invoice.setInvoiceTitle(invoiceTitle);
-                String corporationTaxNum = (String) orderInvoice.get("corporationTaxNum");
-                if (1 == invoiceType) {
-                    // 普通发票:发票类型、发票内容(商品明细)、抬头(公司名称)、纳税人识别号[普通发票的公司]
-                    Integer invoiceTitleType = (Integer) orderInvoice.get("invoiceTitleType");
-                    String registeredAddress = (String) orderInvoice.get("registeredAddress");
-                    String registeredPhone = (String) orderInvoice.get("registeredPhone");
-                    String openBank = (String) orderInvoice.get("openBank");
-                    String bankAccountNo = (String) orderInvoice.get("bankAccountNo");
-                    // 抬头类型
-                    Integer headingType = (Integer) orderInvoice.get("headingType");
-                    if (0 != headingType) {
-                        if (StringUtils.isEmpty(corporationTaxNum)) {
-                            return ResponseJson.error("纳税人识别号信息不正确!", null);
-                        }
+        if (1 == invoiceType || 2 == invoiceType) {
+            InvoicePo invoice = new InvoicePo();
+            String invoiceTitle = (String) orderInvoice.get("invoiceTitle");
+            if (StringUtils.isEmpty(invoiceTitle)) {
+                return ResponseJson.error("发票抬头信息不正确!", null);
+            }
+            invoice.setType(invoiceType);
+            invoice.setInvoiceTitle(invoiceTitle);
+            String corporationTaxNum = (String) orderInvoice.get("corporationTaxNum");
+            if (1 == invoiceType) {
+                // 普通发票:发票类型、发票内容(商品明细)、抬头(公司名称)、纳税人识别号[普通发票的公司]
+                Integer invoiceTitleType = (Integer) orderInvoice.get("invoiceTitleType");
+                String registeredAddress = (String) orderInvoice.get("registeredAddress");
+                String registeredPhone = (String) orderInvoice.get("registeredPhone");
+                String openBank = (String) orderInvoice.get("openBank");
+                String bankAccountNo = (String) orderInvoice.get("bankAccountNo");
+                // 抬头类型
+                Integer headingType = (Integer) orderInvoice.get("headingType");
+                if (0 != headingType) {
+                    if (StringUtils.isEmpty(corporationTaxNum)) {
+                        return ResponseJson.error("纳税人识别号信息不正确!", null);
                     }
-                    invoice.setCorporationTaxNum(corporationTaxNum);
-                    invoice.setHeadingType(headingType);
-                    invoice.setInvoiceTitleType(invoiceTitleType);
-                    invoice.setRegisteredAddress(registeredAddress);
-                    invoice.setRegisteredPhone(registeredPhone);
-                    invoice.setOpenBank(openBank);
-                    invoice.setBankAccountNo(bankAccountNo);
                 }
-                if (2 == invoiceType) {
-                    // 增值税发票:发票类型、发票、抬头(公司名称)、纳税人识别号、注册地址、注册电话、开户银行、开户银行账户
-                    String registeredAddress = (String) orderInvoice.get("registeredAddress");
-                    String registeredPhone = (String) orderInvoice.get("registeredPhone");
-                    String openBank = (String) orderInvoice.get("openBank");
-                    String bankAccountNo = (String) orderInvoice.get("bankAccountNo");
-                    if (StringUtils.isEmpty(registeredAddress) || StringUtils.isEmpty(registeredPhone) || StringUtils.isEmpty(openBank) || StringUtils.isEmpty(bankAccountNo)) {
-                        return ResponseJson.error("发票信息不完整!", null);
-                    }
-                    invoice.setCorporationTaxNum(corporationTaxNum);
-                    invoice.setRegisteredAddress(registeredAddress);
-                    invoice.setRegisteredPhone(registeredPhone);
-                    invoice.setOpenBank(openBank);
-                    invoice.setBankAccountNo(bankAccountNo);
+                invoice.setCorporationTaxNum(corporationTaxNum);
+                invoice.setHeadingType(headingType);
+                invoice.setInvoiceTitleType(invoiceTitleType);
+                invoice.setRegisteredAddress(registeredAddress);
+                invoice.setRegisteredPhone(registeredPhone);
+                invoice.setOpenBank(openBank);
+                invoice.setBankAccountNo(bankAccountNo);
+            }
+            if (2 == invoiceType) {
+                // 增值税发票:发票类型、发票、抬头(公司名称)、纳税人识别号、注册地址、注册电话、开户银行、开户银行账户
+                String registeredAddress = (String) orderInvoice.get("registeredAddress");
+                String registeredPhone = (String) orderInvoice.get("registeredPhone");
+                String openBank = (String) orderInvoice.get("openBank");
+                String bankAccountNo = (String) orderInvoice.get("bankAccountNo");
+                if (StringUtils.isEmpty(registeredAddress) || StringUtils.isEmpty(registeredPhone) || StringUtils.isEmpty(openBank) || StringUtils.isEmpty(bankAccountNo)) {
+                    return ResponseJson.error("发票信息不完整!", null);
                 }
-                orderParamBo.setOrderInvoice(invoice);
+                invoice.setCorporationTaxNum(corporationTaxNum);
+                invoice.setRegisteredAddress(registeredAddress);
+                invoice.setRegisteredPhone(registeredPhone);
+                invoice.setOpenBank(openBank);
+                invoice.setBankAccountNo(bankAccountNo);
             }
+            orderParamBo.setOrderInvoice(invoice);
+        }
         // 返佣订单标识 0非返佣订单,1返佣订单,2普通订单含有返佣服务费
         Integer rebateFlag = (Integer) payInfo.get("rebateFlag");
         // rebateflag=2时,有rebateFee
@@ -503,7 +502,7 @@ public class SubmitServiceImpl implements SubmitService {
             if (1252 == shopId) {
                 secondHandOrderFlag = true;
             }
-            log.info("postageFlag*****************"+postageFlag);
+            log.info("postageFlag*****************" + postageFlag);
             // 运费
             Double postage = Double.parseDouble(postageString);
             // 供应商名称
@@ -871,7 +870,7 @@ public class SubmitServiceImpl implements SubmitService {
                     costAmount = MathUtil.mul(product.getPrice(), MathUtil.add(productNum, presentNum)).doubleValue();
                 }
                 product.setShopProductAmount(costAmount);
-                log.info("product.getShopProductAmount()***"+product.getShopProductAmount());
+                log.info("product.getShopProductAmount()***" + product.getShopProductAmount());
                 //应付供应商(单)=成本价+供应商税费(单)
                 Double singleShopFee = MathUtil.add(product.getCostPrice(), shopTax).doubleValue();
                 product.setSingleShopFee(singleShopFee);
@@ -914,8 +913,8 @@ public class SubmitServiceImpl implements SubmitService {
                 // 商品总金额
                 shopAmount.set(MathUtil.add(shopAmount.get(), product.getTotalAmount()).doubleValue());
                 // 付供应商 商品费
-                log.info("shopProductAmount.get()"+shopProductAmount.get());
-                log.info("product.getShopProductAmount()"+product.getShopProductAmount());
+                log.info("shopProductAmount.get()" + shopProductAmount.get());
+                log.info("product.getShopProductAmount()" + product.getShopProductAmount());
                 shopProductAmount.set(MathUtil.add(shopProductAmount.get(), product.getShopProductAmount()).doubleValue());
                 // 付供应商税费
                 shopTaxFee.set(MathUtil.add(shopTaxFee.get(), product.getShouldPayTotalTax()).doubleValue());
@@ -932,18 +931,18 @@ public class SubmitServiceImpl implements SubmitService {
                 skuIdList.add(product.getSkuId().toString());
             }
             // 设置运费
-            if (( 1 == postageFlag && 0 == mainOrder.getUserBeans() ) || ( 0 == postageFlag && isColdChina.get() > 0.00d && 0 != organizeId ) || ( -1 == postageFlag && isColdChina.get() > 0.00d && 0 != organizeId )) {
+            if ((1 == postageFlag && 0 == mainOrder.getUserBeans()) || (0 == postageFlag && isColdChina.get() > 0.00d && 0 != organizeId) || (-1 == postageFlag && isColdChina.get() > 0.00d && 0 != organizeId)) {
                 // postage = MathUtil.add(shopIsColdChina.get(), postage).doubleValue();
                 shopOrder.setShopPostFee(postage);
             }
             // 需要支付金额 shouldPayFee +运费
             // needPayAmount.set(MathUtil.add(needPayAmount.get(), postage).doubleValue());
-            log.info("postage=-***===="+postage);
+            log.info("postage=-***====" + postage);
             isColdChina.set(MathUtil.add(isColdChina.get(), shopIsColdChina.get()).doubleValue());
-            log.info("isColdChina.get()=------=-=-===="+isColdChina.get());
+            log.info("isColdChina.get()=------=-=-====" + isColdChina.get());
             // 统计总运费
             postageFee.set(MathUtil.add(postageFee.get(), postage).doubleValue());
-            log.info("统计总运费+--+-+-"+postageFee.get());
+            log.info("统计总运费+--+-+-" + postageFee.get());
             Integer count = submitMapper.findSplitResult(productIdList);
             if (count > 0) {
                 //有商品无分帐号,走线下
@@ -1031,7 +1030,7 @@ public class SubmitServiceImpl implements SubmitService {
             }
             // 运费标记
             shopOrder.setShopPostFlag(postageFlag);
-            log.info("shopOrder.getShopPostFlag()*****************"+shopOrder.getShopPostFlag());
+            log.info("shopOrder.getShopPostFlag()*****************" + shopOrder.getShopPostFlag());
             // 添加到子订单列表
             shopOrderList.add(shopOrder);
             // 统计商品总金额
@@ -1136,7 +1135,7 @@ public class SubmitServiceImpl implements SubmitService {
         // 设置运费
         // mainOrder.setPostage(orderParamBo.getPostage());
         // 订单总额 = 商品费 + 运费
-        log.info("总运费"+postageFee.get());
+        log.info("总运费" + postageFee.get());
         payTotalFee.set(MathUtil.add(productTotalFee.get(), postageFee.get()).doubleValue());
         // 运费标志:0包邮 -1到付 1遵循运费规则
         // mainOrder.setPostageFlag(orderParamBo.getPostageFlag());
@@ -1224,7 +1223,7 @@ public class SubmitServiceImpl implements SubmitService {
             mainOrder.setRebateFee(orderParamBo.getRebateFee());
         }
 
-        log.info("订单总额"+payTotalFee.get());
+        log.info("订单总额" + payTotalFee.get());
         // 判断前端传入orderShouldPayFee订单应付金额,和后台计算应付金额对比
         // orderParamBo.setOrderShouldPayFee(MathUtil.sub(orderParamBo.getOrderShouldPayFee(), isColdChina.get()).doubleValue());
         log.info("【提交订单】>>>>>后台计算payableAmount:" + payableAmount.get() + " ,前端传入orderShouldPayFee:" + orderParamBo.getOrderShouldPayFee());
@@ -1438,7 +1437,7 @@ public class SubmitServiceImpl implements SubmitService {
             if (!shopFlag) {
                 shopOrder.setShopPostFee(0d);
             }*/
-            log.info("shopOrder.getIsColdChina()******"+shopOrder.getIsColdChina()+"=====shopOrder.getShopPostFee()"+shopOrder.getShopPostFee());
+            log.info("shopOrder.getIsColdChina()******" + shopOrder.getIsColdChina() + "=====shopOrder.getShopPostFee()" + shopOrder.getShopPostFee());
             /*
              * 保存子订单
              */
@@ -1660,7 +1659,7 @@ public class SubmitServiceImpl implements SubmitService {
         }
         submitMapper.updateOnlinePayFlag(onlinePayFlag, mainOrder.getOrderId());
         // 更新子订单线上支付
-        if(0 != organizeId && item) {
+        if (0 != organizeId && item) {
             String onlinePayWays = "1,2,3,4,5";
             submitMapper.updateOnlinePayWays(onlinePayWays, mainOrder.getOrderId());
         }
@@ -2253,4 +2252,493 @@ public class SubmitServiceImpl implements SubmitService {
         return ResponseJson.success(info);
     }
 
+    @Override
+    public ResponseJson updateOrder(List<OrderProductVo> orderProducts) {
+        /**
+         * 仅未付款可修改订单
+         * 当前版本仅修改订单商品价格
+         * 余额抵扣修改时,未确认修改抵扣记录抵扣金额,已确认则根据差价修改抵扣记录,并返还余额/或再抵扣
+         */
+        ShopOrderVo shopOrder = shipMapper.getShopOrder(orderProducts.get(0).getShopOrderId());
+
+        // 店铺促销活动状态
+        PromotionsVo shopPromotions = baseMapper.getPromotionByShopId(shopOrder.getShopId());
+        if (shopPromotions != null && shopPromotions.getSeen() != null && shopPromotions.getSeen() == 2) {
+            shopPromotions = null;
+        }
+        boolean svipUserFlag = null != baseMapper.getSvipUserIdByUserId(shopOrder.getUserId());
+        // 用户组织Id
+        Integer organizeId = baseMapper.getOrganizeId(orderProducts.get(0).getOrganizeId());
+        // 是否包含活动商品
+        boolean hasActProductFlag = false;
+        // 超级会员优惠
+        AtomicDouble svipFullReduction = new AtomicDouble(0);
+        // 促销满减优惠
+        AtomicDouble promotionFullReduction = new AtomicDouble(0);
+        //促销活动ids
+        List<Integer> promotionsIds = new ArrayList<>();
+        // 促销活动信息
+        List<PromotionsVo> promotionList = new ArrayList<>();
+        // 商品总数量
+        AtomicInteger shopProductCount = new AtomicInteger(0);
+        // 佣金 =  应付采美
+        AtomicDouble brokerage = new AtomicDouble(0);
+        // 需要支付金额
+        AtomicDouble needPayAmount = new AtomicDouble(0);
+        // 商品总金额
+        AtomicDouble shopAmount = new AtomicDouble(0);
+        // 付供应商 商品费
+        AtomicDouble shopProductAmount = new AtomicDouble(0);
+        // 付供应商税费
+        AtomicDouble shopTaxFee = new AtomicDouble(0);
+        // 商品费
+        AtomicDouble shopProductFee = new AtomicDouble(0);
+        // 供应商下参与店铺促销的商品总价
+        AtomicDouble shopPromotionFee = new AtomicDouble(0);
+        // 供应商超级会员优惠
+        AtomicDouble svipShopReduction = new AtomicDouble(0);
+        // 不包含店铺满减的子订单应付
+        AtomicDouble realNeedPay = new AtomicDouble(0);
+        // 订单商品列表
+        List<OrderProductPo> orderProductList = new ArrayList<>();
+
+        for (OrderProductVo orderProduct : orderProducts) {
+            Integer skuId = orderProduct.getSkuId();
+            Integer productNum = orderProduct.getNum();
+            Integer presentNum = orderProduct.getPresentNum();
+            Integer productType = orderProduct.getProductType();
+            if (null == skuId) {
+                return ResponseJson.error("订单商品数据异常!", null);
+            }
+            if (null == productNum || productNum == 0) {
+                return ResponseJson.error("商品购买数量异常!", null);
+            }
+            // 获取数据库商品信息
+            OrderProductPo dbProduct = null;
+            if (0 == organizeId) {
+                dbProduct = submitMapper.getProductDetails(skuId);
+            } else {
+                dbProduct = submitMapper.getProductOrganizeDetails(skuId);
+            }
+            OrderProductPo product = new OrderProductPo();
+            BeanUtils.copyProperties(dbProduct, product);
+            product.setOrderProductId(orderProduct.getOrderProductId());
+            product.setPrice(orderProduct.getPrice());
+
+            if (null == product) {
+                return ResponseJson.error("订单商品不存在!", null);
+            }
+
+            // 是否添加税费,不含税商品 开票需添加税费
+            boolean taxFlag = false;
+            if (0 == organizeId) {
+                taxFlag = (Integer.valueOf(0).equals(product.getIncludedTax()) && (Integer.valueOf(1).equals(product.getInvoiceType()) || Integer.valueOf(2).equals(product.getInvoiceType())));
+            }
+            Double shopTax = 0d;
+
+            // 超级会员优惠商品详情
+            SvipProductPo svipProductPo = submitMapper.getSvipProductDetails(product.getSkuId());
+            // 是否以超级会员优惠价格购买
+            boolean svipPriceFlag = null != svipProductPo && 1 == svipProductPo.getSvipProductFlag() && svipUserFlag;
+            // 是否是促销赠品
+            if (productType == 2) {
+                // 促销赠品数+1
+                product.setPrice(0d);
+                product.setDiscountPrice(0d);
+                product.setDiscount(0d);
+                product.setTotalAmount(0d);
+                product.setTotalFee(0d);
+                product.setTaxRate(0d);
+                product.setAddedValueTax(0d);
+                product.setTotalAddedValueTax(0d);
+            } else {
+                // 不是赠品,获取商品购买价格(超级会员优惠商品价格>>>活动价格>>>阶梯价格>>>复购价格库>>>商品原始价)
+                Double productPrice = product.getPrice();
+                Double discountPrice = product.getPrice();
+                // 商品税费
+                Double productTax = 0d;
+                Double discountTax = 0d;
+                // 商品是否处于活动状态
+                PromotionsVo promotions = null;
+                // 店铺促销优先
+                if (null == shopPromotions) {
+                    promotions = baseMapper.getPromotionByProductId(product.getProductId());
+                    if (null != promotions && 1 == promotions.getType() && 1 == promotions.getMode()) {
+                        //单品促销的优惠价时,touchPrice取当前sku的
+                        promotions.setTouchPrice(baseMapper.getTouchPriceBySku(skuId, promotions.getId()));
+                    }
+                }
+                //促销活动如果协销不可见,置为空
+                if (promotions != null && promotions.getSeen() != null && promotions.getSeen() == 2) {
+                    promotions = null;
+                }
+                // 计算单价
+                // 超级会员单价折扣计算
+                if (0 == organizeId) {
+                    if (null != svipProductPo && 1 == svipProductPo.getSvipProductFlag()) {
+                        // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
+                        if (svipUserFlag) {
+                            if (1 == svipProductPo.getSvipPriceType()) {
+                                // 折扣价
+                                discountPrice = MathUtil.div(MathUtil.mul(productPrice, svipProductPo.getSvipDiscount()), 100, 2).doubleValue();
+                            } else if (2 == svipProductPo.getSvipPriceType()) {
+                                // 直接优惠价
+                                discountPrice = svipProductPo.getSvipDiscountPrice();
+                            }
+                            // 商品超级会员优惠
+                            BigDecimal svipReduction = MathUtil.sub(productPrice, discountPrice);
+                            if (taxFlag) {
+                                // 商品税费超级会员优惠
+                                BigDecimal svipTaxReduction = MathUtil.div(MathUtil.mul(svipReduction, product.getTaxRate()), 100, 2);
+                                svipReduction = MathUtil.add(svipReduction, svipTaxReduction);
+                            }
+                            // 统计超级会员优惠
+                            product.setSvipReduction(svipReduction.doubleValue());
+                            svipShopReduction.set(MathUtil.add(svipShopReduction, MathUtil.mul(svipReduction, productNum)).doubleValue());
+                            svipFullReduction.set(MathUtil.add(svipFullReduction, MathUtil.mul(svipReduction, productNum)).doubleValue());
+                            // 保存订单商品svip数据
+                            product.setSvipPriceFlag(1);
+                            product.setSvipPriceType(svipProductPo.getSvipPriceType());
+                            product.setSvipDiscount(1 == svipProductPo.getSvipPriceType() ? svipProductPo.getSvipDiscount() : 0.00d);
+                        }
+                    }
+                    // 有单品优惠价促销活动
+                    else if (null != promotions || null != shopPromotions) {
+                        // 是否包含活动商品(受订单未支付自动关闭时间影响)  0 否 1 是
+                        hasActProductFlag = true;
+                        // 关闭阶梯价格,活动优先
+                        product.setLadderPriceFlag(0);
+                        product.setActProduct(1);
+                        if (null != promotions && promotions.getType() == 1 && promotions.getMode() == 1) {
+                            discountPrice = promotions.getTouchPrice();
+                        }
+                    }
+
+                    //有阶梯价
+                    else if (1 == product.getLadderPriceFlag()) {
+                        // 启用了阶梯价格
+                        List<LadderPriceVo> ladderPrices = baseMapper.getLadderPriceList(skuId);
+                        // 判断阶梯价格的购买数量校验
+                        int minBuyNumber = null != ladderPrices.get(0) ? ladderPrices.get(0).getBuyNum() : 0;
+                        if (productNum < minBuyNumber) {
+                            return ResponseJson.error("商品购买量低于最小起订量!", null);
+                        }
+                        //根据商品购买数量获取商品对应阶梯价格
+                        for (LadderPriceVo ladderPrice : ladderPrices) {
+                            if (productNum >= ladderPrice.getBuyNum()) {
+                                discountPrice = ladderPrice.getBuyPrice();
+                            }
+                        }
+                        product.setLadderPrices(ladderPrices);
+                        product.setActProduct(2);
+                    } else {
+                        // 复购价
+                        Double repurchase = baseMapper.getRepurchasePrice(skuId, shopOrder.getUserId());
+                        if (null != repurchase && repurchase > 0) {
+                            discountPrice = repurchase;
+                        }
+                        product.setActProduct(0);
+                    }
+                }
+                if (MathUtil.compare(discountPrice, BigDecimal.ZERO) == 0) {
+                    return ResponseJson.error("商品购买价格不能为0!", null);
+                }
+                // 不含税可开票商品计算税费
+                if (null == product.getTaxRate() || product.getTaxRate() <= 0) {
+                    product.setTaxRate(0d);
+                }
+                if (taxFlag) {
+                    productTax = MathUtil.div(MathUtil.mul(productPrice, product.getTaxRate()), 100, 2).doubleValue();
+                    discountTax = MathUtil.div(MathUtil.mul(discountPrice, product.getTaxRate()), 100, 2).doubleValue();
+                } else if (!Integer.valueOf(1).equals(product.getIncludedTax())) {
+                    // 不含税不可开票商品和未知商品,税率置为0
+                    product.setTaxRate(0d);
+                }
+                // 商品价格
+                product.setPrice(productPrice);
+                // 商品税后价格
+                Double productTaxPrice = MathUtil.add(productPrice, productTax).doubleValue();
+                // 折后税后单价
+                Double discountTaxPrice = MathUtil.add(discountPrice, discountTax).doubleValue();
+                // 折扣率 = 折后单价/机构价
+                Double discountRate = MathUtil.mul(MathUtil.div(discountTaxPrice, productTaxPrice), 100).doubleValue();
+                // 单个商品的金额
+                Double productAmount = MathUtil.mul(productTaxPrice, productNum).doubleValue();
+                // 单个商品的折后金额
+                Double productFee = MathUtil.mul(discountTaxPrice, productNum).doubleValue();
+                // 不包含单品满减的商品金额
+                Double realProductFee = productFee;
+                // 单个商品总税费
+                Double taxFee = MathUtil.mul(discountTax, productNum).doubleValue();
+                if (hasActProductFlag && null != promotions) {
+                    // 单品促销
+                    if (0 == organizeId) {
+                        if (promotions.getType() == 1) {
+                            // 是否满足单品优惠条件(满足优惠价或者满减在这里进行设值)
+                            if (promotions.getMode() == 1 || MathUtil.compare(productFee, promotions.getTouchPrice()) >= 0) {
+                                // 满减
+                                if (promotions.getMode() == 2) {
+                                    if (promotions.getDiscount() != null && promotions.getDiscount() == 1) {
+                                        //叠加优惠计算
+                                        //叠加倍数
+                                        Double floor = Math.floor(MathUtil.div(productFee, promotions.getTouchPrice()).doubleValue());
+                                        promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue());
+                                        productFee = MathUtil.sub(productFee, MathUtil.mul(promotions.getReducedPrice(), floor)).doubleValue();
+                                    } else {
+                                        // 统计订单总满减金额
+                                        promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), promotions.getReducedPrice()).doubleValue());
+                                        // 统计单个商品的折后金额
+                                        productFee = MathUtil.sub(productFee, promotions.getReducedPrice()).doubleValue();
+                                    }
+                                }
+                                // 添加到总促销
+                                if (!promotionsIds.contains(promotions.getId())) {
+                                    promotionsIds.add(promotions.getId());
+                                    promotions.setPromotionsId(promotions.getId());
+                                    promotionList.add(promotions);
+                                }
+                                product.setOrderPromotionsId(promotions.getId());
+                            }
+                            // 凑单优惠
+                        } else if (promotions.getType() == 2) {
+                            // 商品添加到总促销
+                            PromotionPriceVo promotionPrice = new PromotionPriceVo();
+                            promotionPrice.setProductId(product.getProductId());
+                            promotionPrice.setNumber(productNum);
+                            promotionPrice.setPrice(discountTaxPrice);
+                            if (null == promotions.getProductList()) {
+                                promotions.setProductList(new ArrayList<>());
+                            }
+                            promotions.getProductList().add(promotionPrice);
+                            if (!promotionsIds.contains(promotions.getId())) {
+                                promotionsIds.add(promotions.getId());
+                                promotions.setPromotionsId(promotions.getId());
+                                promotionList.add(promotions);
+                            } else {
+                                PromotionsVo finalPromotions = promotions;
+                                promotionList.forEach(promotionsTemp -> {
+                                    if (finalPromotions.getId().equals(promotionsTemp.getId())) {
+                                        promotionsTemp.getProductList().add(promotionPrice);
+                                    }
+                                });
+                            }
+                            product.setOrderPromotionsId(promotions.getId());
+                        }
+                    }
+                }
+                // 折后单价
+                product.setDiscountPrice(discountPrice);
+                // 折扣率 = 折后单价/机构价
+                product.setDiscount(discountRate);
+                if (svipPriceFlag || (null != promotions && promotions.getType() == 1 && promotions.getMode() == 1)) {
+                    // 超级会员价/单品优惠折扣率设置为100%
+                    product.setDiscount(100d);
+                }
+                // 单个商品的金额
+                product.setTotalAmount(productAmount);
+                // 单个商品的折后金额
+                product.setTotalFee(productFee);
+                product.setShouldPayFee(productFee);
+                product.setRealProductFee(realProductFee);
+                // 税费
+                product.setAddedValueTax(discountTax);
+                product.setTotalAddedValueTax(taxFee);
+            }
+            // 成本价
+            Double costPrice = null;
+            // 判断是否选中固定成本价
+            if (null != product.getCostPrice() && 1 == product.getCostCheckFlag() && product.getCostPrice() >= 0d) {
+                costPrice = product.getCostPrice();
+            }
+            // 判断是否选中比例成本价
+            if (null != product.getCostProportional() && 2 == product.getCostCheckFlag() && product.getCostProportional() > 0d) {
+                // 通过售价*比例得到成本价
+                double discountTax = 0d;
+                if (taxFlag) {
+                    discountTax = MathUtil.div(MathUtil.mul(product.getDiscountPrice(), product.getTaxRate()), 100, 2).doubleValue();
+                }
+                costPrice = MathUtil.div(MathUtil.mul(MathUtil.add(product.getDiscountPrice(), discountTax), product.getCostProportional()), 100, 2).doubleValue();
+            }
+            if (null == costPrice) {
+                return ResponseJson.error("订单商品成本异常!", null);
+            }
+            product.setCostPrice(costPrice);
+            // 付供应商税费
+            if (null == product.getShopTaxRate() || product.getShopTaxRate() <= 0) {
+                product.setShopTaxRate(product.getTaxRate());
+            }
+            if (taxFlag) {
+                shopTax = MathUtil.div(MathUtil.mul(costPrice, product.getShopTaxRate()), 100, 2).doubleValue();
+            } else if (!Integer.valueOf(1).equals(product.getIncludedTax())) {
+                // 不含税不可开票商品和未知商品,税率置为0
+                product.setShopTaxRate(0d);
+            }
+            // 单个付供应商税费
+            product.setSingleShouldPayTotalTax(shopTax);
+            // 单个商品付供应商总税费
+            product.setShouldPayTotalTax(MathUtil.mul(shopTax, productNum).doubleValue());
+            // 付供应商 商品费=成本价*(购买数量  + 赠品数量)
+            Double costAmount = null;
+            if (0 == organizeId) {
+                costAmount = MathUtil.mul(costPrice, MathUtil.add(productNum, presentNum)).doubleValue();
+            } else {
+                costAmount = MathUtil.mul(product.getPrice(), MathUtil.add(productNum, presentNum)).doubleValue();
+            }
+            product.setShopProductAmount(costAmount);
+
+            //应付供应商(单)=成本价+供应商税费(单)
+            Double singleShopFee = MathUtil.add(product.getCostPrice(), shopTax).doubleValue();
+            product.setSingleShopFee(singleShopFee);
+            // 应付供应商(总)=应付供应商(单) * 商品数量
+            Double shopFee = MathUtil.add(product.getCostPrice(), shopTax).doubleValue();
+            product.setShopFee(shopFee);
+            // 付第三方,默认0
+            product.setOtherFee(0d);
+            product.setSingleOtherFee(0d);
+            //应付采美(单)=单价+机构税费(单)-(成本(单)+供应商税费(单))
+            Double singleCmFee = MathUtil.sub(MathUtil.add(BigDecimal.valueOf(product.getPrice()), product.getAddedValueTax()), MathUtil.add(product.getCostPrice(), shopTax)).doubleValue();
+            product.setSingleCmFee(singleCmFee);
+            // 应付采美(总)=应付采美(单)*商品数量
+            Double cmFee = MathUtil.mul(singleCmFee, productNum).doubleValue();
+            product.setCmFee(cmFee);
+            // 默认未支付
+            product.setPayStatus(0);
+            // 默认非再次购买商品
+            product.setBuyAgainFlag(0);
+            // 未出库数量
+            product.setNotOutStore(productNum);
+            /*
+             * 子订单金额计算
+             */
+
+            // 佣金 = 应付采美
+            brokerage.set(MathUtil.add(brokerage.get(), product.getCmFee()).doubleValue());
+            // 需要支付金额 shouldPayFee +运费
+            needPayAmount.set(MathUtil.add(needPayAmount.get(), product.getShouldPayFee()).doubleValue());
+            // 不包含单品满减的子订单需付金额
+            realNeedPay.set(MathUtil.add(realNeedPay.get(), product.getRealProductFee()).doubleValue());
+            // 统计 总金额 包括税费
+            shopProductFee.set(MathUtil.add(shopProductFee.get(), product.getTotalFee()).doubleValue());
+            // 统计子订单内可参与店铺促销的商品总金额
+            if (!svipPriceFlag) {
+                // 超级会员购买优惠商品,不能参与店铺促销
+                shopPromotionFee.set(MathUtil.add(shopPromotionFee.get(), product.getTotalFee()).doubleValue());
+            }
+            // 商品总金额
+            shopAmount.set(MathUtil.add(shopAmount.get(), product.getTotalAmount()).doubleValue());
+            // 付供应商 商品费
+            log.info("shopProductAmount.get()" + shopProductAmount.get());
+            log.info("product.getShopProductAmount()" + product.getShopProductAmount());
+            shopProductAmount.set(MathUtil.add(shopProductAmount.get(), product.getShopProductAmount()).doubleValue());
+            // 付供应商税费
+            shopTaxFee.set(MathUtil.add(shopTaxFee.get(), product.getShouldPayTotalTax()).doubleValue());
+            if (0 != organizeId) {
+                // 佣金比例  外部商城sku配置比例
+                CmOrganizeSkuPo organizeSkuInfo = submitMapper.getOrganizeSkuInfo(skuId);
+                product.setCmPercent(organizeSkuInfo.getCmPercent());
+                product.setOrganizePercent(organizeSkuInfo.getOrganizePercent());
+                product.setShopPercent(organizeSkuInfo.getShopPercent());
+            }
+            // 加入订单商品列表
+            orderProductList.add(product);
+        }
+
+
+        if (0 == organizeId) {
+            if (null != shopPromotions) {
+                // 是否满足满减满赠
+                if (MathUtil.compare(shopPromotionFee.get(), shopPromotions.getTouchPrice()) >= 0) {
+                    // 是否包含活动商品(受订单未支付自动关闭时间影响)  0 否 1 是
+                    hasActProductFlag = true;
+                    // 满减
+                    if (shopPromotions.getMode() == 2) {
+                        if (shopPromotions.getDiscount() != null && shopPromotions.getDiscount() == 1) {
+                            //叠加优惠计算
+                            //叠加倍数
+                            Double floor = Math.floor(MathUtil.div(shopPromotionFee.get(), shopPromotions.getTouchPrice()).doubleValue());
+                            // 供应商满减金额
+                            shopOrder.setPromotionFullReduction(MathUtil.mul(shopPromotions.getReducedPrice(), floor).doubleValue());
+                            // 统计订单总满减金额
+                            promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), MathUtil.mul(shopPromotions.getReducedPrice(), floor)).doubleValue());
+                            // 统计店铺商品总金额
+                            shopProductFee.set(MathUtil.sub(shopProductFee.get(), MathUtil.mul(shopPromotions.getReducedPrice(), floor)).doubleValue());
+                            // 统计需要支付金额
+                            needPayAmount.set(MathUtil.sub(needPayAmount.get(), MathUtil.mul(shopPromotions.getReducedPrice(), floor)).doubleValue());
+                            // 统计需要支付金额
+                            shopAmount.set(MathUtil.sub(shopAmount.get(), MathUtil.mul(shopPromotions.getReducedPrice(), floor)).doubleValue());
+                        } else {
+                            // 供应商满减金额
+                            shopOrder.setPromotionFullReduction(shopPromotions.getReducedPrice());
+                            // 统计订单总满减金额
+                            promotionFullReduction.set(MathUtil.add(promotionFullReduction.get(), shopPromotions.getReducedPrice()).doubleValue());
+                            // 统计店铺商品总金额
+                            shopProductFee.set(MathUtil.sub(shopProductFee.get(), shopPromotions.getReducedPrice()).doubleValue());
+                            // 统计需要支付金额
+                            needPayAmount.set(MathUtil.sub(needPayAmount.get(), shopPromotions.getReducedPrice()).doubleValue());
+                            // 统计需要支付金额
+                            shopAmount.set(MathUtil.sub(shopAmount.get(), shopPromotions.getReducedPrice()).doubleValue());
+                        }
+                    }
+                    // 添加到总促销
+                    if (!promotionsIds.contains(shopPromotions.getId())) {
+                        promotionsIds.add(shopPromotions.getId());
+                        shopPromotions.setPromotionsId(shopPromotions.getId());
+                        promotionList.add(shopPromotions);
+                    }
+                    shopOrder.setOrderPromotionsId(shopPromotions.getId());
+                }
+            }
+        }
+        // 佣金 采美应收
+        shopOrder.setBrokerage(brokerage.get());
+        // 可退款金额 = 余额抵扣金额
+        shopOrder.setCanRefundAmount(needPayAmount.get());
+        // 购买商品数
+        shopOrder.setItemCount(shopProductCount.get());
+        // 超级会员优惠金额
+        shopOrder.setSvipShopReduction(svipShopReduction.get());
+        // 总价(含税) = totalFee
+        shopOrder.setTotalAmount(MathUtil.add(shopProductFee.get(), shopOrder.getShopPostFee()).doubleValue());
+        // 总金额 = 订单商品totalAmount
+        shopOrder.setProductAmount(shopAmount.get());
+        // 需要支付金额 shouldPayFee +运费
+        shopOrder.setNeedPayAmount(needPayAmount.get());
+        // 设值
+        shopOrder.setRealNeedPay(realNeedPay.get());
+        // 付供应商 商品费=成本价*(购买数量  + 赠品数量)
+        shopOrder.setShopProductAmount(shopProductAmount.get());
+        // 付给供应商税费
+        shopOrder.setShopTaxFee(shopTaxFee.get());
+        // 付供应商 = 商品费 + 运费 + 税费
+        shopOrder.setShouldPayShopAmount(MathUtil.add(shopProductAmount.get(), shopTaxFee.get()).doubleValue());
+
+        orderProductList.forEach(o -> submitMapper.updateOrderProduct(o));
+        /**
+         *  由于余额抵扣过的子订单可以修改,有收款非余额抵扣的仅需改变子订单相关应收/应付金额
+         *  如果有余额抵扣,应计算余额抵扣金额,如果子订单应收总金额减少且余额抵扣金额大于应收,
+         *  则退还余额给用户,同时计算子订单的收款状态修改
+         */
+        List<BalanceRecordPo> records = baseMapper.findShopOrderBalanceRecord(shopOrder.getShopOrderId());
+        if (null != records && records.size() > 0) {
+            double total = records.stream().mapToDouble(BalanceRecordPo::getAmount).sum();
+            /**
+             * 总抵扣金额 < 子订单应收,改变子订单状态,子订单部分收,抵扣金额>子订单应收,退余额,子订单已收
+             * shopOrderStatus:  0待确认,11待收待发,12待收部发,13待收全发,21部收待发,22部收部发,23部收全发,31已收待发,
+             *                  32已收部发,33已收全发,4交易完成,5订单完成,6已关闭,7交易全退
+             */
+            String status = shopOrder.getStatus().toString();
+            if (total < shopOrder.getNeedPayAmount()) {
+                shopOrder.setReceiptStatus(2);
+            }else{
+                shopOrder.setReceiptStatus(3);
+                shopOrder.setAccountAmount(total);
+            }
+
+        }
+        submitMapper.updateShopOrder(shopOrder);
+        return ResponseJson.success();
+    }
+
+
 }
+

+ 21 - 1
src/main/resources/mapper/BaseMapper.xml

@@ -178,7 +178,8 @@
                cs.unit      AS unit,
                cs.stock     AS stock,
                cpg.skuId    AS giftSkuId,
-               IFNULL((SELECT validFlag FROM cm_organize_product_info  WHERE productId = p.productID AND organizeId = 0), 999) AS validFlag,
+               IFNULL((SELECT validFlag FROM cm_organize_product_info WHERE productId = p.productID AND organizeId = 0),
+                      999)  AS validFlag,
                p.productType
         FROM cm_promotions_gift cpg
                  LEFT JOIN cm_sku cs ON cpg.skuId = cs.skuId
@@ -451,4 +452,23 @@
         where skuId = #{skuId}
           and promotionId = #{promotionId}
     </select>
+    <select id="findShopOrderBalanceRecord" resultType="com.caimei365.order.model.po.BalanceRecordPo">
+        select id,
+               userId,
+               type,
+               balanceType,
+               addDate,
+               amount,
+               orderId,
+               shopOrderId,
+               receiptId,
+               returnedId,
+               remark,
+               delFlag
+        from cm_user_balance_record
+        where shopOrderId = #{shopOrderId}
+        and delFlag = 0
+        and type = 2
+        and balanceType = 1
+    </select>
 </mapper>

+ 1 - 0
src/main/resources/mapper/OrderCommonMapper.xml

@@ -103,6 +103,7 @@
                cop.shopOrderID    AS shopOrderId,
                cop.shopOrderNo,
                cop.orderPromotionsId,
+               cop.organizeId,
                cop.productId,
                cop.shopId,
                cop.name,

+ 1 - 0
src/main/resources/mapper/ShipMapper.xml

@@ -240,6 +240,7 @@
             orderTime,
             orderSubmitType,
             payStatus,
+            shopStatus as status,
             sendOutStatus,
             splitFlag
         FROM cm_shop_order

+ 203 - 63
src/main/resources/mapper/SubmitMapper.xml

@@ -3,7 +3,8 @@
 <mapper namespace="com.caimei365.order.mapper.SubmitMapper">
     <insert id="insertMainOrder" keyColumn="orderID" keyProperty="orderId"
             parameterType="com.caimei365.order.model.po.OrderPo" useGeneratedKeys="true">
-        INSERT INTO cm_order (orderSeen, orderSource, orderNo, userID, clubID, organizeID, buyUserID, spID, orderTime, updateDate,
+        INSERT INTO cm_order (orderSeen, orderSource, orderNo, userID, clubID, organizeID, buyUserID, spID, orderTime,
+                              updateDate,
                               delFlag,
                               userBeans, orderType, orderSubmitType, confirmFlag, onlinePayFlag, splitFlag, payFlag,
                               receiptStatus, payStatus, zeroCostFlag, sendOutStatus, refundType, affirmPaymentFlag,
@@ -12,8 +13,9 @@
                               productTotalFee,
                               orderTotalFee, payTotalFee, payableAmount, balancePayFee, couponAmount, status,
                               confirmTime,
-                              payTime, rebateFlag,rebateFee, clauseID, clauseName)
-        VALUES (#{orderSeen}, #{orderSource}, #{orderNo}, #{userId}, #{clubId}, #{organizeId}, #{buyUserId}, #{spId}, #{orderTime},
+                              payTime, rebateFlag, rebateFee, clauseID, clauseName)
+        VALUES (#{orderSeen}, #{orderSource}, #{orderNo}, #{userId}, #{clubId}, #{organizeId}, #{buyUserId}, #{spId},
+                #{orderTime},
                 #{updateDate},
                 #{delFlag},
                 #{userBeans}, #{orderType}, #{orderSubmitType}, #{confirmFlag}, #{onlinePayFlag}, #{splitFlag},
@@ -24,22 +26,26 @@
                 #{secondHandOrderFlag}, #{invoiceFlag}, #{postageFlag}, #{postage}, #{productTotalFee},
                 #{orderTotalFee},
                 #{payTotalFee}, #{payableAmount}, #{balancePayFee}, #{couponAmount}, #{status}, #{confirmTime},
-                #{payTime}, #{rebateFlag},#{rebateFee},
+                #{payTime}, #{rebateFlag}, #{rebateFee},
                 #{clauseId}, #{clauseName})
     </insert>
     <insert id="insertShopOrder" keyColumn="shopOrderID" keyProperty="shopOrderId"
             parameterType="com.caimei365.order.model.po.OrderShopPo" useGeneratedKeys="true">
-        INSERT INTO cm_shop_order (onlinePayWays, shopOrderNo, orderID, orderNo, organizeID, isColdChina, shopID, note, userID, clubID, orderType,
+        INSERT INTO cm_shop_order (onlinePayWays, shopOrderNo, orderID, orderNo, organizeID, isColdChina, shopID, note,
+                                   userID, clubID, orderType,
                                    spID, orderPromotionsId, promotionFullReduction, svipShopReduction, brokerage,
                                    canRefundAmount, itemCount, shopStatus,
-                                   totalAmount, productAmount, needPayAmount, shopProductAmount, shopPostFee, shopPostFlag,
+                                   totalAmount, productAmount, needPayAmount, shopProductAmount, shopPostFee,
+                                   shopPostFlag,
                                    shopTaxFee,
                                    shouldPayShopAmount, orderTime, orderSubmitType, splitFlag, payStatus,
                                    payedShopAmount, splitCode, realPay, eachDiscount, receiptStatus)
-        VALUES (#{onlinePayWays}, #{shopOrderNo}, #{orderId}, #{orderNo}, #{organizeId},#{isColdChina}, #{shopId}, #{note}, #{userId}, #{clubId}, #{orderType},
+        VALUES (#{onlinePayWays}, #{shopOrderNo}, #{orderId}, #{orderNo}, #{organizeId}, #{isColdChina}, #{shopId},
+                #{note}, #{userId}, #{clubId}, #{orderType},
                 #{spId}, #{orderPromotionsId}, #{promotionFullReduction}, #{svipShopReduction}, #{brokerage},
                 #{canRefundAmount}, #{itemCount}, #{shopStatus},
-                #{totalAmount}, #{productAmount}, #{needPayAmount}, #{shopProductAmount}, #{shopPostFee}, #{shopPostFlag}, #{shopTaxFee},
+                #{totalAmount}, #{productAmount}, #{needPayAmount}, #{shopProductAmount}, #{shopPostFee},
+                #{shopPostFlag}, #{shopTaxFee},
                 #{shouldPayShopAmount}, #{orderTime}, #{orderSubmitType}, #{splitFlag}, #{payStatus},
                 #{payedShopAmount}, #{splitCode}, #{realPay}, #{eachDiscount}, 1)
     </insert>
@@ -50,7 +56,8 @@
     </update>
     <insert id="insertOrderProduct" keyColumn="orderProductID" keyProperty="orderProductId"
             parameterType="com.caimei365.order.model.po.OrderProductPo" useGeneratedKeys="true">
-        INSERT INTO cm_order_product (orderID, orderNo, shopOrderID, shopOrderNo, organizeID, orderPromotionsId, productId, shopId,
+        INSERT INTO cm_order_product (orderID, orderNo, shopOrderID, shopOrderNo, organizeID, orderPromotionsId,
+                                      productId, shopId,
                                       name,
                                       productImage, price, shopName, costPrice, normalPrice, ladderPriceFlag,
                                       discountPrice, discount,
@@ -62,8 +69,9 @@
                                       cmFee,
                                       payStatus, buyAgainFlag, notOutStore, isActProduct, productType, svipPriceFlag,
                                       svipPriceType,
-                                      svipDiscount, svipReduction,skuID, cmPercent, organizePercent, shopPercent)
-        VALUES (#{orderId}, #{orderNo}, #{shopOrderId}, #{shopOrderNo}, #{organizeId}, #{orderPromotionsId}, #{productId}, #{shopId},
+                                      svipDiscount, svipReduction, skuID, cmPercent, organizePercent, shopPercent)
+        VALUES (#{orderId}, #{orderNo}, #{shopOrderId}, #{shopOrderNo}, #{organizeId}, #{orderPromotionsId},
+                #{productId}, #{shopId},
                 #{name},
                 #{image}, #{price}, #{shopName}, #{costPrice}, #{normalPrice}, #{ladderPriceFlag},
                 #{discountPrice}, #{discount},
@@ -74,13 +82,15 @@
                 #{shopProductAmount}, #{singleShopFee}, #{shopFee}, #{singleOtherFee}, #{otherFee}, #{singleCmFee},
                 #{cmFee},
                 #{payStatus}, #{buyAgainFlag}, #{notOutStore}, #{actProduct}, #{productType}, #{svipPriceFlag},
-                #{svipPriceType}, #{svipDiscount}, #{svipReduction},#{skuId}, #{cmPercent}, #{organizePercent}, #{shopPercent})
+                #{svipPriceType}, #{svipDiscount}, #{svipReduction}, #{skuId}, #{cmPercent}, #{organizePercent},
+                #{shopPercent})
     </insert>
     <insert id="insertOrderPromotions" keyColumn="id" keyProperty="id"
             parameterType="com.caimei365.order.model.vo.PromotionsVo" useGeneratedKeys="true">
         INSERT INTO cm_promotions_order (orderId, promotionsId, name, description, type, mode, touchPrice, reducedPrice,
-                                         discount,status, beginTime, endTime)
-        VALUES (#{orderId}, #{id}, #{name}, #{description}, #{type}, #{mode}, #{touchPrice}, #{reducedPrice}, #{discount},
+                                         discount, status, beginTime, endTime)
+        VALUES (#{orderId}, #{id}, #{name}, #{description}, #{type}, #{mode}, #{touchPrice}, #{reducedPrice},
+                #{discount},
                 #{status}, #{beginTime}, #{endTime})
     </insert>
     <insert id="insertLadderPrices" keyColumn="id" keyProperty="id"
@@ -158,19 +168,71 @@
         SET onlinePayWays = #{onlinePayWays}
         WHERE orderID = #{orderId}
     </update>
+    <update id="updateOrderProduct">
+        update cm_order_product
+        set price                   = #{price},
+            costPrice               = #{costPrice},
+            totalAmount             = #{totalAmount},
+            totalFee                = #{totalFee},
+            shouldPayFee            = #{shouldPayFee},
+            ladderPriceFlag         = #{ladderPriceFlag},
+            taxRate                 = #{taxRate},
+            addedValueTax           = #{addedValueTax},
+            totalAddedValueTax      = #{totalAddedValueTax},
+            shouldPayTotalTax       = #{shouldPayTotalTax},
+            singleShouldPayTotalTax = #{singleShouldPayTotalTax},
+            shopProductAmount       = #{shopProductAmount},
+            singleShopFee           = #{singleShopFee}
+        where orderProductId = #{orderProductId}
+    </update>
+    <update id="updateShopOrder">
+        update cm_shop_order
+        set
+        <if test="status != null">
+            shopStatus = #{status},
+        </if>
+        <if test="realPay != null">
+            realPay = #{realPay},
+        </if>
+        <if test="receiptAmount != null">
+            receiptAmount = #{receiptAmount},
+        </if>
+        <if test="accountAmount != null">
+            accountAmount = #{accountAmount},
+        </if>
+        <if test="productAmount != null">
+            productAmount = #{productAmount},
+        </if>
+        <if test="totalAmount != null">
+            totalAmount = #{totalAmount},
+        </if>
+        <if test="needPayAmount != null">
+            needPayAmount = #{needPayAmount},
+        </if>
+        <if test="promotionFullReduction != null">
+            promotionFullReduction = #{promotionFullReduction},
+        </if>
+        <if test="receiptStatus != null">
+            receiptStatus = #{receiptStatus},
+        </if>
+        <if test="shopProductAmount != null">
+            shopProductAmount = #{shopProductAmount}
+        </if>
+        where shopOrderId = #{shopOrderId}
+    </update>
     <select id="getOrganizeSkuInfo" resultType="com.caimei365.order.model.po.CmOrganizeSkuPo">
-        SELECT
-            skuId,
-            productId,
-            minBuyNumber,
-            price,
-            unit,
-            stock,
-            organizePercent,
-            shopPercent,
-            cmPercent
+        SELECT skuId,
+               productId,
+               minBuyNumber,
+               price,
+               unit,
+               stock,
+               organizePercent,
+               shopPercent,
+               cmPercent
         FROM cm_sku
-            where skuId = #{skuId} and organizeId = 4
+        where skuId = #{skuId}
+          and organizeId = 4
     </select>
     <select id="getOrderInvoice" resultType="com.caimei365.order.model.po.InvoicePo">
         SELECT id,
@@ -208,45 +270,46 @@
         WHERE userID = #{userId}
     </select>
     <select id="getProductDetails" resultType="com.caimei365.order.model.po.OrderProductPo">
-        SELECT cs.skuId                   AS skuId,
-               p.productID                AS productId,
-               p.shopID                   AS shopId,
-               p.`name`                   AS `name`,
-               p.mainImage                AS image,
+        SELECT cs.skuId                    AS skuId,
+               p.productID                 AS productId,
+               p.shopID                    AS shopId,
+               p.`name`                    AS `name`,
+               p.mainImage                 AS image,
                cs.price,
                cs.costPrice,
                IFNULL(cs.costCheckFlag, 1) AS costCheckFlag,
-               cs.shopPercent as costProportional,
+               cs.shopPercent              as costProportional,
                p.productCategory,
                cs.ladderPriceFlag,
                p.includedTax,
                p.invoiceType,
-               p.taxPoint                 AS taxRate,
+               p.taxPoint                  AS taxRate,
                cs.unit                     AS productUnit,
                cs.normalPrice,
-               p.supplierTaxPoint         AS shopTaxRate,
-               p.splitCode as splitCode
+               p.supplierTaxPoint          AS shopTaxRate,
+               p.splitCode                 as splitCode
         FROM product p
-        LEFT JOIN cm_sku cs on p.productID = cs.productId
-        WHERE cs.skuId = #{skuId} and cs.organizeId = 0
+                 LEFT JOIN cm_sku cs on p.productID = cs.productId
+        WHERE cs.skuId = #{skuId}
+          and cs.organizeId = 0
     </select>
     <select id="getProductOrganizeDetails" resultType="com.caimei365.order.model.po.OrderProductPo">
-        SELECT cs.skuId                   AS skuId,
-               p.productID                AS productId,
-               p.shopID                   AS shopId,
-               p.`name`                   AS `name`,
-               p.mainImage                AS image,
+        SELECT cs.skuId           AS skuId,
+               p.productID        AS productId,
+               p.shopID           AS shopId,
+               p.`name`           AS `name`,
+               p.mainImage        AS image,
                cs.price,
                p.productCategory,
                cs.ladderPriceFlag,
                p.includedTax,
                p.invoiceType,
-               p.taxPoint                 AS taxRate,
-               cs.unit                     AS productUnit,
-               p.supplierTaxPoint         AS shopTaxRate,
-               p.splitCode as splitCode
+               p.taxPoint         AS taxRate,
+               cs.unit            AS productUnit,
+               p.supplierTaxPoint AS shopTaxRate,
+               p.splitCode        as splitCode
         FROM product p
-                 LEFT JOIN cm_sku cs  ON cs.productId = p.productId
+                 LEFT JOIN cm_sku cs ON cs.productId = p.productId
         WHERE cs.skuId = #{skuId}
     </select>
     <select id="getClauseNameById" resultType="java.lang.String">
@@ -276,13 +339,13 @@
     </select>
     <select id="getSvipProductDetails" resultType="com.caimei365.order.model.po.SvipProductPo">
         select if(id is not null and csp.status = 0, 1, 0) as svipProductFlag,
-               priceType                as svipPriceType,
-               discount                 as svipDiscount,
-               discountPrice            as svipDiscountPrice
+               priceType                                   as svipPriceType,
+               discount                                    as svipDiscount,
+               discountPrice                               as svipDiscountPrice
         from cm_svip_product_sku
-        left join cm_svip_product csp on cm_svip_product_sku.productId = csp.productId
+                 left join cm_svip_product csp on cm_svip_product_sku.productId = csp.productId
         where skuId = #{skuId}
-        and csp.status=0
+          and csp.status = 0
     </select>
     <select id="findLowOrder" resultType="java.lang.Integer">
         select orderID
@@ -294,8 +357,8 @@
     </select>
     <select id="findShops" resultType="com.caimei365.order.model.po.OrderShopPo">
         SELECT DISTINCT
-            s.shopID AS shopId,
-            p.splitCode
+        s.shopID AS shopId,
+        p.splitCode
         FROM shop s
         LEFT JOIN product p ON p.shopID = s.shopID
         WHERE p.productID IN
@@ -313,26 +376,103 @@
         AND (splitcode IS NULL OR splitcode ='')
     </select>
     <select id="getRechargeProductDetails" resultType="com.caimei365.order.model.po.OrderProductPo">
-        SELECT cs.skuId                   AS skuId,
-               p.productID                AS productId,
-               p.shopID                   AS shopId,
-               p.`name`                   AS `name`,
-               p.mainImage                AS image,
+        SELECT cs.skuId                    AS skuId,
+               p.productID                 AS productId,
+               p.shopID                    AS shopId,
+               p.`name`                    AS `name`,
+               p.mainImage                 AS image,
                cs.price,
                cs.costPrice,
                IFNULL(cs.costCheckFlag, 1) AS costCheckFlag,
-               cs.shopPercent as costProportional,
+               cs.shopPercent              as costProportional,
                p.productCategory,
                cs.ladderPriceFlag,
                p.includedTax,
                p.invoiceType,
-               p.taxPoint                 AS taxRate,
+               p.taxPoint                  AS taxRate,
                cs.unit                     AS productUnit,
                cs.normalPrice,
-               p.supplierTaxPoint         AS shopTaxRate,
-               p.splitCode as splitCode
+               p.supplierTaxPoint          AS shopTaxRate,
+               p.splitCode                 as splitCode
         FROM product p
                  LEFT JOIN cm_sku cs on p.productID = cs.productId
-        WHERE cs.productId = #{productId} and cs.organizeId = 0
+        WHERE cs.productId = #{productId}
+          and cs.organizeId = 0
+    </select>
+    <select id="findOrderProducts" resultType="com.caimei365.order.model.vo.OrderProductVo">
+        select
+        orderProductId,
+        orderNo,
+        orderId,
+        shopOrderId,
+        shopOrderNo,
+        shopID,
+        productId,
+        organizeId,
+        num,
+        presentNum,
+        outStoreType,
+        skuId,
+        productNo,
+        price,
+        normalPrice,
+        costPrice,
+        totalAmount,
+        totalFee,
+        shouldPayFee,
+        discount,
+        discountPrice,
+        includedTax,
+        invoiceType,
+        ladderPriceFlag,
+        taxRate,
+        supplierTaxRate,
+        addedValueTax,
+        totalAddedValueTax,
+        shouldPayTotalTax,
+        singleShouldPayTotalTax,
+        shopProductAmount,
+        shopFee,
+        otherFee,
+        cmFee,
+        singleShopFee,
+        singleOtherFee,
+        singleCmFee,
+        status,
+        totalBeans,
+        useBalanceAmount,
+        useBeanAmount,
+        notOutStore,
+        cmbeanPrice,
+        isActProduct,
+        isGiftProduct,
+        productActInfo,
+        buyAgainFlag,
+        confirmProductFlag,
+        payStatus,
+        shopName,
+        name,
+        productUnit,
+        productImage,
+        actType,
+        actPreferential,
+        ifnull(productType,0) as productType,
+        orderPromotionsId,
+        preferential,
+        discountFee,
+        cancelNum,
+        heUserId,
+        svipPriceFlag,
+        svipPriceType,
+        svipDiscount,
+        svipReduction,
+        cmPercent,
+        organizePercent,
+        shopPercent
+        from cm_order_product
+        where orderProductID in
+        <foreach item="orderProductId" index="index" collection="orderProductIds" open="(" separator="," close=")">
+            #{orderProductId}
+        </foreach>
     </select>
 </mapper>