Forráskód Böngészése

Merge remote-tracking branch 'origin/developer' into developerA

zhijiezhao 1 éve
szülő
commit
eb2614d802
100 módosított fájl, 7163 hozzáadás és 3644 törlés
  1. 23 5
      src/main/java/com/caimei/modules/archive/entity/CmProductArchiveContent.java
  2. 2 0
      src/main/java/com/caimei/modules/bulkpurchase/web/CmRefundsProductController.java
  3. 1 0
      src/main/java/com/caimei/modules/coupon/web/CmCouponController.java
  4. 8 1
      src/main/java/com/caimei/modules/hehe/dao/CmHeheProductDao.java
  5. 2 0
      src/main/java/com/caimei/modules/hehe/service/CmHeheProductService.java
  6. 112 108
      src/main/java/com/caimei/modules/hehe/service/HeHeNewOrderService.java
  7. 115 0
      src/main/java/com/caimei/modules/info/dao/CmRelatedMapper.java
  8. 20 1
      src/main/java/com/caimei/modules/info/dao/InfoDao.java
  9. 9 2
      src/main/java/com/caimei/modules/info/dao/InfoTypeDao.java
  10. 54 0
      src/main/java/com/caimei/modules/info/entity/CmRelated.java
  11. 46 0
      src/main/java/com/caimei/modules/info/entity/Info.java
  12. 19 41
      src/main/java/com/caimei/modules/info/entity/InfoType.java
  13. 194 0
      src/main/java/com/caimei/modules/info/service/CmRelatedService.java
  14. 35 1
      src/main/java/com/caimei/modules/info/service/InfoService.java
  15. 47 8
      src/main/java/com/caimei/modules/info/service/InfoTypeService.java
  16. 129 0
      src/main/java/com/caimei/modules/info/web/InfoController.java
  17. 37 15
      src/main/java/com/caimei/modules/info/web/InfoTypeController.java
  18. 9 197
      src/main/java/com/caimei/modules/landing/domain/CmBrandLanding.java
  19. 23 7
      src/main/java/com/caimei/modules/landing/mapper/CmBrandLandingMapper.java
  20. 2 0
      src/main/java/com/caimei/modules/order/dao/CmPayShopDao.java
  21. 6 2
      src/main/java/com/caimei/modules/order/dao/CmReceiptOrderRelationDao.java
  22. 105 4
      src/main/java/com/caimei/modules/order/dao/NewOrderDao.java
  23. 108 0
      src/main/java/com/caimei/modules/order/dao/NewShopOrderDao.java
  24. 1 1
      src/main/java/com/caimei/modules/order/entity/ChangePayShopDifference.java
  25. 23 0
      src/main/java/com/caimei/modules/order/entity/ChangePayShopOther.java
  26. 10 0
      src/main/java/com/caimei/modules/order/entity/CmPayShop.java
  27. 61 1
      src/main/java/com/caimei/modules/order/entity/NewOrder.java
  28. 55 2
      src/main/java/com/caimei/modules/order/entity/NewOrderProduct.java
  29. 135 8
      src/main/java/com/caimei/modules/order/entity/NewShopOrder.java
  30. 11 1
      src/main/java/com/caimei/modules/order/entity/OrderProductVo.java
  31. 6 363
      src/main/java/com/caimei/modules/order/entity/ShopOrderVo.java
  32. 1 1
      src/main/java/com/caimei/modules/order/entity/SplitAccountPo.java
  33. 175 51
      src/main/java/com/caimei/modules/order/service/CmPayShopService.java
  34. 16 0
      src/main/java/com/caimei/modules/order/service/CmRefundShopService.java
  35. 19 19
      src/main/java/com/caimei/modules/order/service/CmReturnedPurchaseService.java
  36. 47 38
      src/main/java/com/caimei/modules/order/service/NewOrderService.java
  37. 422 35
      src/main/java/com/caimei/modules/order/service/NewShopOrderService.java
  38. 262 288
      src/main/java/com/caimei/modules/order/service/SplitAccountService.java
  39. 181 79
      src/main/java/com/caimei/modules/order/web/CmPayShopController.java
  40. 57 17
      src/main/java/com/caimei/modules/order/web/CmShopOrderController.java
  41. 2 1
      src/main/java/com/caimei/modules/order/web/NewOrderController.java
  42. 2 2
      src/main/java/com/caimei/modules/product/dao/CmOrganizeProductInfoMapper.java
  43. 2 0
      src/main/java/com/caimei/modules/product/dao/CmPromotionDao.java
  44. 2 8
      src/main/java/com/caimei/modules/product/dao/ProductDao.java
  45. 12 0
      src/main/java/com/caimei/modules/product/entity/CmOrganizeProductInfo.java
  46. 19 1
      src/main/java/com/caimei/modules/product/entity/CmSku.java
  47. 6 1474
      src/main/java/com/caimei/modules/product/entity/Product.java
  48. 3 1
      src/main/java/com/caimei/modules/product/entity/Shop.java
  49. 21 1
      src/main/java/com/caimei/modules/product/service/CmPromotionService.java
  50. 23 9
      src/main/java/com/caimei/modules/product/service/ProductService.java
  51. 21 24
      src/main/java/com/caimei/modules/product/web/CmPromotionController.java
  52. 0 5
      src/main/java/com/caimei/modules/product/web/ProductController.java
  53. 11 4
      src/main/java/com/caimei/modules/product/web/ProductNewController.java
  54. 27 0
      src/main/java/com/caimei/modules/user/entity/NewCmShop.java
  55. 12 12
      src/main/java/com/caimei/modules/user/service/ClubPortraitService.java
  56. 4 0
      src/main/java/com/caimei/modules/user/web/NewCmShopController.java
  57. 8 7
      src/main/java/com/thinkgem/jeesite/common/persistence/DataEntity.java
  58. 51 36
      src/main/java/com/thinkgem/jeesite/common/persistence/Page.java
  59. 1 1
      src/main/resources/config/dev/caimei.properties
  60. 21 15
      src/main/resources/mappings/modules/archive/CmProductArchiveContentMapper.xml
  61. 4 2
      src/main/resources/mappings/modules/bulkpurchase/PurchaseProductMapper.xml
  62. 2 1
      src/main/resources/mappings/modules/cmpage/CmPageCentreMapper.xml
  63. 12 2
      src/main/resources/mappings/modules/hehe/CmHeheProductMapper.xml
  64. 30 20
      src/main/resources/mappings/modules/hehe/CmHeheUserMapper.xml
  65. 443 0
      src/main/resources/mappings/modules/info/CmRelatedMapper.xml
  66. 243 4
      src/main/resources/mappings/modules/info/InfoMapper.xml
  67. 116 22
      src/main/resources/mappings/modules/info/InfoTypeMapper.xml
  68. 76 1
      src/main/resources/mappings/modules/landing/CmBrandLandingMapper.xml
  69. 3 0
      src/main/resources/mappings/modules/order/CmDiscernReceiptMapper.xml
  70. 85 3
      src/main/resources/mappings/modules/order/CmPayShopMapper.xml
  71. 20 1
      src/main/resources/mappings/modules/order/CmReceiptOrderRelationMapper.xml
  72. 848 21
      src/main/resources/mappings/modules/order/OrderMapper.xml
  73. 15 2
      src/main/resources/mappings/modules/order/OrderProductMapper.xml
  74. 1511 136
      src/main/resources/mappings/modules/order/ShopOrderMapper.xml
  75. 7 4
      src/main/resources/mappings/modules/product/CmOrganizeProductInfoMapper.xml
  76. 1 3
      src/main/resources/mappings/modules/product/CmProductCombinationMapper.xml
  77. 25 9
      src/main/resources/mappings/modules/product/CmPromotionMapper.xml
  78. 1 1
      src/main/resources/mappings/modules/product/CmSecondHandDetailMapper.xml
  79. 275 193
      src/main/resources/mappings/modules/product/ProductMapper.xml
  80. 14 4
      src/main/resources/mappings/modules/product/ProductNewMapper.xml
  81. 1 1
      src/main/resources/mappings/modules/product/RepeatPurchasePriceMapper.xml
  82. 17 14
      src/main/resources/mappings/modules/user/CmPortraitMapper.xml
  83. 21 0
      src/main/resources/mappings/modules/user/NewCmShopMapper.xml
  84. 1 1
      src/main/resources/mappings/modules/weisha/CmOrganizeProductMapper.xml
  85. 11 0
      src/main/webapp/WEB-INF/views/modules/archive/addFileForm.jsp
  86. 2 0
      src/main/webapp/WEB-INF/views/modules/archive/addVideoForm.jsp
  87. 11 2
      src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveContentList.jsp
  88. 1 1
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderConfirmReturnRecord.jsp
  89. 1 1
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/refundRecord.jsp
  90. 9 9
      src/main/webapp/WEB-INF/views/modules/coupon/MoneyCouponForm.jsp
  91. 1 1
      src/main/webapp/WEB-INF/views/modules/coupon/cmCouponForm.jsp
  92. 3 3
      src/main/webapp/WEB-INF/views/modules/coupon/cmCouponList.jsp
  93. 3 3
      src/main/webapp/WEB-INF/views/modules/coupon/couponShopList.jsp
  94. 4 4
      src/main/webapp/WEB-INF/views/modules/coupon/redemptionCodeCouponForm.jsp
  95. 9 9
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheProductForm.jsp
  96. 4 4
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheProductList.jsp
  97. 253 220
      src/main/webapp/WEB-INF/views/modules/hehe/heheNewOrderDetail.jsp
  98. 44 44
      src/main/webapp/WEB-INF/views/modules/hehe/heheNewOrderList.jsp
  99. 1 1
      src/main/webapp/WEB-INF/views/modules/hehe/userActivityProductList.jsp
  100. 199 0
      src/main/webapp/WEB-INF/views/modules/info/addInfoForm.jsp

+ 23 - 5
src/main/java/com/caimei/modules/archive/entity/CmProductArchiveContent.java

@@ -14,12 +14,14 @@ import com.thinkgem.jeesite.common.persistence.DataEntity;
  * @version 2021-09-06
  */
 public class CmProductArchiveContent extends DataEntity<CmProductArchiveContent> {
-	
+
 	private static final long serialVersionUID = 1L;
 	private Integer productArchiveId;		// 商品资料库id
 	private String title;		// 资料标题
 	private Integer type;		// 资料类型:1图片资料,2视频资料,3文件资料
 	private Date addTime;		// 添加时间
+	private Integer actualPv;		//浏览量
+	private String content;		//内容
 
 	private List<CmProductArchiveFile> fileList;	//图片列表
     private Integer fileId;                 //上传的文件id
@@ -30,6 +32,22 @@ public class CmProductArchiveContent extends DataEntity<CmProductArchiveContent>
 	private String ossUrl;			//oss链接
 	private String waterOssUrl;			//水印图片oss链接
 
+	public String getContent() {
+		return content;
+	}
+
+	public void setContent(String content) {
+		this.content = content;
+	}
+
+	public Integer getActualPv() {
+		return actualPv;
+	}
+
+	public void setActualPv(Integer actualPv) {
+		this.actualPv = actualPv;
+	}
+
 	public CmProductArchiveContent() {
 		super();
 	}
@@ -45,7 +63,7 @@ public class CmProductArchiveContent extends DataEntity<CmProductArchiveContent>
 	public void setProductArchiveId(Integer productArchiveId) {
 		this.productArchiveId = productArchiveId;
 	}
-	
+
 	@Length(min=0, max=50, message="资料标题长度必须介于 0 和 50 之间")
 	public String getTitle() {
 		return title;
@@ -54,7 +72,7 @@ public class CmProductArchiveContent extends DataEntity<CmProductArchiveContent>
 	public void setTitle(String title) {
 		this.title = title;
 	}
-	
+
 	public Integer getType() {
 		return type;
 	}
@@ -62,7 +80,7 @@ public class CmProductArchiveContent extends DataEntity<CmProductArchiveContent>
 	public void setType(Integer type) {
 		this.type = type;
 	}
-	
+
 	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 	public Date getAddTime() {
 		return addTime;
@@ -135,4 +153,4 @@ public class CmProductArchiveContent extends DataEntity<CmProductArchiveContent>
 	public void setWaterOssUrl(String waterOssUrl) {
 		this.waterOssUrl = waterOssUrl;
 	}
-}
+}

+ 2 - 0
src/main/java/com/caimei/modules/bulkpurchase/web/CmRefundsProductController.java

@@ -601,6 +601,7 @@ public class CmRefundsProductController extends BaseController {
             model.addAttribute("bpClauses", bpClauses);
             model.addAttribute("cmReturnedPurchaseList", dataList);
             model.addAttribute("order", newOrder);
+            model.addAttribute("orderType", cmReturnedPurchase.getOrderType());
             model.addAttribute("returnedPurchaseFee", returnedPurchaseFee);
             model.addAttribute("refundFee", refundFee);
         } catch (Exception e) {
@@ -753,6 +754,7 @@ public class CmRefundsProductController extends BaseController {
         model.addAttribute("refundFee", refundFee);
         model.addAttribute("from", from);
         model.addAttribute("orderID", cmReturnedPurchase.getOrderID().toString());
+        model.addAttribute("orderType", cmReturnedPurchase.getOrderType());
 
         return "modules/bulkpurchase/refundRecord";
     }

+ 1 - 0
src/main/java/com/caimei/modules/coupon/web/CmCouponController.java

@@ -183,6 +183,7 @@ public class CmCouponController extends BaseController {
      */
     @RequestMapping(value = "toAddProduct")
     public String toAddProduct(Product product, Model model, HttpServletRequest request, HttpServletResponse response) {
+        //todo 当前版本限制死为仅选取综合供应商的商品
         Page<Product> page = cmCouponService.findProductList(new Page<Product>(request, response), product);
         model.addAttribute("page", page);
         model.addAttribute("productIds", product.getProductIds());

+ 8 - 1
src/main/java/com/caimei/modules/hehe/dao/CmHeheProductDao.java

@@ -41,6 +41,13 @@ public interface CmHeheProductDao extends CrudDao<CmHeheProduct> {
      */
     void deleteActivityProduct(Integer productId);
 
+    /**
+     * 删除活动商品sku
+     *
+     * @param productId
+     */
+    void deleteCmHeHeSku(Integer productId);
+
     /**
      *
      * @param product
@@ -89,4 +96,4 @@ public interface CmHeheProductDao extends CrudDao<CmHeheProduct> {
     void updateHeHeSkuPrice(@Param("skuId") Integer skuId, @Param("price") Double price);
 
     List<CmLadderPrice> findLadderList(Integer skuId);
-}
+}

+ 2 - 0
src/main/java/com/caimei/modules/hehe/service/CmHeheProductService.java

@@ -99,6 +99,8 @@ public class CmHeheProductService extends CrudService<CmHeheProductDao, CmHehePr
         super.delete(cmHeheProduct);
         //删除活动商品
         cmHeheProductDao.deleteActivityProduct(cmHeheProduct.getProductId());
+        //删除活动商品sku
+        cmHeheProductDao.deleteCmHeHeSku(cmHeheProduct.getProductId());
         //删除分销者活动商品
         activityProductDao.deleteUserActivity(cmHeheProduct.getProductId());
         //删除活动阶梯

+ 112 - 108
src/main/java/com/caimei/modules/hehe/service/HeHeNewOrderService.java

@@ -5,6 +5,8 @@ import com.caimei.modules.hehe.entity.CmHeheCouponOrderRecord;
 import com.caimei.modules.order.dao.*;
 import com.caimei.modules.order.entity.*;
 import com.caimei.modules.order.service.CmReceiptOrderRelationService;
+import com.caimei.modules.order.service.NewOrderService;
+import com.caimei.modules.order.service.NewShopOrderService;
 import com.caimei.modules.order.service.OrderUserInfoService;
 import com.caimei.modules.order.utils.NewOrderStatus;
 import com.caimei.modules.product.dao.CmPromotionDao;
@@ -52,6 +54,8 @@ public class HeHeNewOrderService extends CrudService<HeHeNewOrderDao, NewOrder>
     @Resource
     private NewShopOrderDao newShopOrderDao;
     @Resource
+    private NewOrderService newOrderService;
+    @Resource
     private CmUserDao cmUserDao;
     @Resource
     private CmDiscernReceiptDao cmDiscernReceiptDao;
@@ -68,114 +72,114 @@ public class HeHeNewOrderService extends CrudService<HeHeNewOrderDao, NewOrder>
 
     @Override
     public NewOrder get(String id) {
-        NewOrder newOrder = super.get(id);
-        CmUser user = cmUserDao.get(newOrder.getUserID().toString());
-        if (user != null) {
-            //查询用户余额,机构名
-            newOrder.setBuyer(user.getName());
-            Double ableUserMoney = user.getAbleUserMoney() == null ? 0d : user.getAbleUserMoney();
-            newOrder.setAbleUserMoney(ableUserMoney);
-        }
-        List<Integer> l = new ArrayList<>();
-        l.add(newOrder.getOrderID());
-        List<Integer> orderIds = cmDiscernReceiptDao.findRebateOrderID(l);
-        if (orderIds.contains(newOrder.getOrderID()))
-            newOrder.setRebateOrder("1");
-        else
-            newOrder.setRebateOrder("0");
-        if (null != newOrder) {
-            // 获取订单优惠券使用记录
-            if (newOrder.getCouponAmount() != null && newOrder.getCouponAmount() > 0) {
-                CmHeheCouponOrderRecord couponRecord = heHeNewOrderDao.findOrderCouponRecord(newOrder.getOrderID());
-                if (couponRecord != null) {
-                    newOrder.setReceiveCouponId(couponRecord.getReceiveCouponId());
-                    newOrder.setHeheCouponRecord(couponRecord);
-                }
-            }
-            // 获取订单分享减免记录
-            if (newOrder.getReductionAmount() != null && newOrder.getReductionAmount() > 0) {
-                Double reductionTouchPrice = heHeNewOrderDao.findReductionTouchPrice(newOrder.getOrderID());
-                newOrder.setReductionTouchPrice(reductionTouchPrice);
-            }
-            //获取订单客户
-            OrderUserInfo orderUserInfo = orderUserInfoService.findByOrderID(newOrder.getOrderID());
-            if (null != orderUserInfo) {
-                newOrder.setBpOrderUserinfo(orderUserInfo);
-            }
-            //获取订单商品
-            List<NewOrderProduct> list = new ArrayList<>();
-            List<NewShopOrder> shopOrders = newShopOrderDao.findListByOrderID(newOrder.getOrderID());
-            if (CollectionUtils.isNotEmpty(shopOrders)) {
-                for (NewShopOrder shopOrder : shopOrders) {
-                    List<NewOrderProduct> pList = newOrderProductDao.findListByShopOrderID(shopOrder.getShopOrderID());
-                    pList.forEach(orderProduct -> {
-                        if (orderProduct.getLadderPriceFlag() == 1) {
-                            // 查询订单商品阶梯价格
-                            List<OrderProductLadderPrice> ladderPriceList = newOrderProductDao.findladderPriceList(orderProduct.getOrderProductID());
-                            if (null != ladderPriceList && ladderPriceList.size() > 0) {
-                                IntStream.range(0, ladderPriceList.size()).forEach(i -> {
-                                    if (i == ladderPriceList.size() - 1) {
-                                        ladderPriceList.get(i).setBuyNumRangeShow("≥" + ladderPriceList.get(i).getBuyNum());
-                                    } else {
-                                        String buyNumRangeShow = ladderPriceList.get(i).getBuyNum() + "~" + (ladderPriceList.get(i + 1).getBuyNum() - 1);
-                                        ladderPriceList.get(i).setBuyNumRangeShow(buyNumRangeShow);
-                                    }
-                                });
-                                orderProduct.setOrderProductLadderPriceList(ladderPriceList);
-                            }
-                        }
-                        //分销者名称
-                        if (orderProduct.getHeUserId() != null && orderProduct.getHeUserId() > 0) {
-                            String name = heHeNewOrderDao.findHeUser(orderProduct.getHeUserId());
-                            orderProduct.setHeUserName(name);
-                        }
-                    });
-                    list.addAll(pList);
-                    shopOrder.setNewOrderProducts(pList);
-                    if (pList.stream().anyMatch(p -> p.getProductID() == 999))
-                        shopOrder.setPostFeeCos("1");
-                    pList.forEach(item -> {
-                        if (NewOrderStatus.hasReturn(newOrder.getStatus())) {
-                            Integer returningNum = newOrderProductDao.getReturningNum(item.getOrderProductID());
-                            Integer returnedNum = newOrderProductDao.getReturnedNum(item.getOrderProductID());
-                            item.setReturningNum(returningNum);
-                            item.setReturnedNum(returnedNum);
-                        }
-                        /**确认收货信息*/
-                        if (NewOrderStatus.hasReceived(newOrder.getStatus())) {
-                            Integer receivedNum = newOrderProductDao.getReceivedNum(item.getOrderProductID());
-                            item.setReceivedNum(receivedNum);
-                        }
-                        String domain = SysConfig.getStringConfig("crm.server.domain");
-                        item.setProductImage(AppUtils.getProductImageURL(item.getProductImage(), AppKeys.ORIGINAL_PICTURE, domain));
-                        if (item != null && item.getOrderPromotionsId() != null && item.getOrderPromotionsId() > 0) {
-                            item.setProductPromotion(cmPromotionDao.findOrderPromotions(item.getOrderPromotionsId()));
-                        }
-                    });
-                    Double payed = cmPayShopRecordDao.sumByShopOrderID(shopOrder.getShopOrderID());
-                    shopOrder.setPayed(payed);
-                }
-                newOrder.setNewShopOrders(shopOrders);
-            }
-            if (CollectionUtils.isNotEmpty(list)) {
-                newOrder.setOrderProduct(list);
-                double freight = 0D;
-                double totalAddedValueTax = 0D;
-                for (NewOrderProduct op : list) {
-                    if (op.getProductID().intValue() == 999) { //邮费商品
-                        freight += op.getPrice();
-                    }
-                    totalAddedValueTax += op.getTotalAddedValueTax();
-                }
-                if ("1".equals(newOrder.getFreePostFlag())) newOrder.setFreight(freight);
-                newOrder.setTotalAddedValueTax(totalAddedValueTax);
-            }
-            shopOrders.sort((so1, so2) -> {
-                //给子订单排序  邮费排在最后  其余的按shopOrderID  asc
-                if ("1".equals(so1.getPostFeeCos())) return 1;
-                return so1.getShopOrderID() - so2.getShopOrderID();
-            });
-        }
+        NewOrder newOrder = newOrderService.get(id);
+//        CmUser user = cmUserDao.get(newOrder.getUserID().toString());
+//        if (user != null) {
+//            //查询用户余额,机构名
+//            newOrder.setBuyer(user.getName());
+//            Double ableUserMoney = user.getAbleUserMoney() == null ? 0d : user.getAbleUserMoney();
+//            newOrder.setAbleUserMoney(ableUserMoney);
+//        }
+//        List<Integer> l = new ArrayList<>();
+//        l.add(newOrder.getOrderID());
+//        List<Integer> orderIds = cmDiscernReceiptDao.findRebateOrderID(l);
+//        if (orderIds.contains(newOrder.getOrderID()))
+//            newOrder.setRebateOrder("1");
+//        else
+//            newOrder.setRebateOrder("0");
+//        if (null != newOrder) {
+//            // 获取订单优惠券使用记录
+//            if (newOrder.getCouponAmount() != null && newOrder.getCouponAmount() > 0) {
+//                CmHeheCouponOrderRecord couponRecord = heHeNewOrderDao.findOrderCouponRecord(newOrder.getOrderID());
+//                if (couponRecord != null) {
+//                    newOrder.setReceiveCouponId(couponRecord.getReceiveCouponId());
+//                    newOrder.setHeheCouponRecord(couponRecord);
+//                }
+//            }
+//            // 获取订单分享减免记录
+//            if (newOrder.getReductionAmount() != null && newOrder.getReductionAmount() > 0) {
+//                Double reductionTouchPrice = heHeNewOrderDao.findReductionTouchPrice(newOrder.getOrderID());
+//                newOrder.setReductionTouchPrice(reductionTouchPrice);
+//            }
+//            //获取订单客户
+//            OrderUserInfo orderUserInfo = orderUserInfoService.findByOrderID(newOrder.getOrderID());
+//            if (null != orderUserInfo) {
+//                newOrder.setBpOrderUserinfo(orderUserInfo);
+//            }
+//            //获取订单商品
+//            List<NewOrderProduct> list = new ArrayList<>();
+//            List<NewShopOrder> shopOrders = newShopOrderDao.findListByOrderID(newOrder.getOrderID());
+//            if (CollectionUtils.isNotEmpty(shopOrders)) {
+//                for (NewShopOrder shopOrder : shopOrders) {
+//                    List<NewOrderProduct> pList = newOrderProductDao.findListByShopOrderID(shopOrder.getShopOrderID());
+//                    pList.forEach(orderProduct -> {
+//                        if (orderProduct.getLadderPriceFlag() == 1) {
+//                            // 查询订单商品阶梯价格
+//                            List<OrderProductLadderPrice> ladderPriceList = newOrderProductDao.findladderPriceList(orderProduct.getOrderProductID());
+//                            if (null != ladderPriceList && ladderPriceList.size() > 0) {
+//                                IntStream.range(0, ladderPriceList.size()).forEach(i -> {
+//                                    if (i == ladderPriceList.size() - 1) {
+//                                        ladderPriceList.get(i).setBuyNumRangeShow("≥" + ladderPriceList.get(i).getBuyNum());
+//                                    } else {
+//                                        String buyNumRangeShow = ladderPriceList.get(i).getBuyNum() + "~" + (ladderPriceList.get(i + 1).getBuyNum() - 1);
+//                                        ladderPriceList.get(i).setBuyNumRangeShow(buyNumRangeShow);
+//                                    }
+//                                });
+//                                orderProduct.setOrderProductLadderPriceList(ladderPriceList);
+//                            }
+//                        }
+//                        //分销者名称
+//                        if (orderProduct.getHeUserId() != null && orderProduct.getHeUserId() > 0) {
+//                            String name = heHeNewOrderDao.findHeUser(orderProduct.getHeUserId());
+//                            orderProduct.setHeUserName(name);
+//                        }
+//                    });
+//                    list.addAll(pList);
+//                    shopOrder.setNewOrderProducts(pList);
+//                    if (pList.stream().anyMatch(p -> p.getProductID() == 999))
+//                        shopOrder.setPostFeeCos("1");
+//                    pList.forEach(item -> {
+//                        if (NewOrderStatus.hasReturn(newOrder.getStatus())) {
+//                            Integer returningNum = newOrderProductDao.getReturningNum(item.getOrderProductID());
+//                            Integer returnedNum = newOrderProductDao.getReturnedNum(item.getOrderProductID());
+//                            item.setReturningNum(returningNum);
+//                            item.setReturnedNum(returnedNum);
+//                        }
+//                        /**确认收货信息*/
+//                        if (NewOrderStatus.hasReceived(newOrder.getStatus())) {
+//                            Integer receivedNum = newOrderProductDao.getReceivedNum(item.getOrderProductID());
+//                            item.setReceivedNum(receivedNum);
+//                        }
+//                        String domain = SysConfig.getStringConfig("crm.server.domain");
+//                        item.setProductImage(AppUtils.getProductImageURL(item.getProductImage(), AppKeys.ORIGINAL_PICTURE, domain));
+//                        if (item != null && item.getOrderPromotionsId() != null && item.getOrderPromotionsId() > 0) {
+//                            item.setProductPromotion(cmPromotionDao.findOrderPromotions(item.getOrderPromotionsId()));
+//                        }
+//                    });
+//                    Double payed = cmPayShopRecordDao.sumByShopOrderID(shopOrder.getShopOrderID());
+//                    shopOrder.setPayed(payed);
+//                }
+//                newOrder.setNewShopOrders(shopOrders);
+//            }
+//            if (CollectionUtils.isNotEmpty(list)) {
+//                newOrder.setOrderProduct(list);
+//                double freight = 0D;
+//                double totalAddedValueTax = 0D;
+//                for (NewOrderProduct op : list) {
+//                    if (op.getProductID().intValue() == 999) { //邮费商品
+//                        freight += op.getPrice();
+//                    }
+//                    totalAddedValueTax += op.getTotalAddedValueTax();
+//                }
+//                if ("1".equals(newOrder.getFreePostFlag())) newOrder.setFreight(freight);
+//                newOrder.setTotalAddedValueTax(totalAddedValueTax);
+//            }
+//            shopOrders.sort((so1, so2) -> {
+//                //给子订单排序  邮费排在最后  其余的按shopOrderID  asc
+//                if ("1".equals(so1.getPostFeeCos())) return 1;
+//                return so1.getShopOrderID() - so2.getShopOrderID();
+//            });
+//        }
         return newOrder;
     }
 

+ 115 - 0
src/main/java/com/caimei/modules/info/dao/CmRelatedMapper.java

@@ -0,0 +1,115 @@
+package com.caimei.modules.info.dao;
+
+import java.util.List;
+
+import com.caimei.modules.info.entity.InfoAd;
+import com.thinkgem.jeesite.common.persistence.CrudDao;
+import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
+import org.apache.ibatis.annotations.Param;
+import com.caimei.modules.info.entity.CmRelated;
+
+/**
+ * 相关资源Mapper接口
+ *
+ * @author Kaick
+ * @date 2023-08-02
+ */
+@MyBatisDao
+public interface CmRelatedMapper extends CrudDao<CmRelated>
+{
+    /**
+     * 通过对象查询相关资源列表
+     *
+     * @param cmRelated 相关资源
+     * @return 相关资源集合
+     */
+    public List<CmRelated> getCmRelatedList(CmRelated cmRelated);
+
+    /**
+     * 通过Id查询相关资源对象
+     *
+     * @param id 相关资源主键
+     * @return 相关资源
+     */
+    public CmRelated getCmRelatedById(String id);
+
+    /**
+     * 通过对象查询相关资源对象
+     *
+     * @param cmRelated 相关资源
+     * @return 相关资源
+     */
+    public CmRelated getByCmRelated(CmRelated cmRelated);
+
+    /**
+     * 通过对象查询相关资源Id
+     *
+     * @param cmRelated 相关资源
+     * @return String
+     */
+    public String getById(CmRelated cmRelated);
+
+    /**
+     * 通过对象查询相关资源Ids
+     *
+     * @param cmRelated 相关资源
+     * @return List<String>
+     */
+    public List<String> getByIds(CmRelated cmRelated);
+
+    /**
+     * 通过对象查询相关资源记录总数
+     *
+     * @param cmRelated 相关资源
+     * @return 相关资源Integer
+     */
+    public int getCmRelatedCount(CmRelated cmRelated);
+
+    /**
+     * 新增相关资源
+     *
+     * @param cmRelated 相关资源
+     * @return 结果
+     */
+    public int addCmRelated(CmRelated cmRelated);
+
+    /**
+     * 修改相关资源
+     *
+     * @param cmRelated 相关资源
+     * @return 结果
+     */
+    public int updateCmRelated(CmRelated cmRelated);
+
+    /**
+     * 删除相关资源
+     *
+     * @param id 相关资源主键
+     * @return 结果
+     */
+    public int delCmRelatedByAuthorId( @Param("type")String type,@Param("authorId")String authorId);
+
+    /**
+     * 删除相关资源
+     *
+     * @param id 相关资源主键
+     * @return 结果
+     */
+    public int delCmRelatedById(String id);
+
+    /**
+     * 批量删除相关资源
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int delCmRelatedByIds(@Param("ids") String[] ids);
+
+    /**
+     * 修改批量删除相关资源
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int updateDelCmRelatedByIds(@Param("ids") String[] ids,@Param("delFlag") Integer delFlag);
+}

+ 20 - 1
src/main/java/com/caimei/modules/info/dao/InfoDao.java

@@ -37,4 +37,23 @@ public interface InfoDao extends CrudDao<Info> {
     String getSensitiveWords(@Param("checkPoint") Integer checkPoint);
 
     void deleteInfo(String id);
-}
+
+	/**
+	 * 通过对象查询信息基础列表
+	 *
+	 * @param info 信息基础
+	 * @return 信息基础集合
+	 */
+	public List<Info> getInfoList(Info info);
+
+	/**
+	 * 通过对象查询信息基础对象
+	 *
+	 * @param info 信息基础
+	 * @return 信息基础
+	 */
+	public Info getByInfo(Info info);
+
+	public int updateInfo(Info info);
+
+}

+ 9 - 2
src/main/java/com/caimei/modules/info/dao/InfoTypeDao.java

@@ -4,8 +4,11 @@ import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import com.caimei.modules.info.entity.InfoType;
 
+import java.util.List;
+
 /**
  * 信息分类DAO接口
+ *
  * @author LG
  * @version 2016-06-27
  */
@@ -13,5 +16,9 @@ import com.caimei.modules.info.entity.InfoType;
 public interface InfoTypeDao extends CrudDao<InfoType> {
 
 	int countEnabledStatus(String enabledStatus);
-	
-}
+
+	InfoType getByInfoType(InfoType infoType);
+
+	List<InfoType> getByInfoTypeList(InfoType infoType);
+
+}

+ 54 - 0
src/main/java/com/caimei/modules/info/entity/CmRelated.java

@@ -0,0 +1,54 @@
+package com.caimei.modules.info.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.thinkgem.jeesite.common.persistence.DataEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import java.io.Serializable;
+import java.util.Date;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.apache.ibatis.type.Alias;
+
+/**
+ * 相关资源对象 cm_related
+ *
+ * @author Kaick
+ * @date 2023-08-02
+ */
+//@Accessors(chain  = true )
+@Data
+@Alias("CmRelated")
+public class CmRelated extends DataEntity<CmRelated> implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    private String id;
+
+    /** 分类: 1 (info)相关文章 */
+    private String type;
+
+    /** 归属者Id(type字段表Id) */
+    private String authorId;
+
+    /** 相关Id(type字段表Id) */
+    private String relatedId;
+
+    /** 删除状态 0正常,其他删除 */
+    private String delFlag;
+
+    /** 修改时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    /** 添加时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+    /** 排序值  */
+    private Integer sort;
+    //相关文章
+    private Info info;
+}
+

+ 46 - 0
src/main/java/com/caimei/modules/info/entity/Info.java

@@ -1,6 +1,7 @@
 package com.caimei.modules.info.entity;
 
 import java.util.Date;
+import java.util.List;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.thinkgem.jeesite.common.persistence.DataEntity;
@@ -14,6 +15,9 @@ public class Info extends DataEntity<Info> {
 
 	private static final long serialVersionUID = 1L;
 	private InfoType infoType;		// 信息分类
+	private String typeId;		// 信息分类Id
+	private String typeName;		// 信息分类名称
+	private String cmRelatedType;		// 相关文章分类
 	private String title;		// 标题
 	private String label;		// 信息标签
 	private String publisher;		// 发布人
@@ -27,6 +31,7 @@ public class Info extends DataEntity<Info> {
 	private String homePageImage;		// 商城首页图
 	private Date pubdate;		// 发布时间
 	private String recommendStatus;		// 推荐状态
+	private String autoStatus;		// 推荐状态
 	private Long basePraise;		// 基础点赞
 	private Long realPraise;		// 实际点赞
 	private Long basePv;		// 基础阅读量
@@ -45,6 +50,39 @@ public class Info extends DataEntity<Info> {
 	private String relatedLabels; //关联标签库
 	private String labelIds;
 	private String isRelevance;
+	List<CmRelated> cmRelatedList;
+
+	public String getCmRelatedType() {
+		return cmRelatedType;
+	}
+
+	public void setCmRelatedType(String cmRelatedType) {
+		this.cmRelatedType = cmRelatedType;
+	}
+
+	public List<CmRelated> getCmRelatedList() {
+		return cmRelatedList;
+	}
+
+	public void setCmRelatedList(List<CmRelated> cmRelatedList) {
+		this.cmRelatedList = cmRelatedList;
+	}
+
+	public String getTypeName() {
+		return typeName;
+	}
+
+	public void setTypeName(String typeName) {
+		this.typeName = typeName;
+	}
+
+	public String getTypeId() {
+		return typeId;
+	}
+
+	public void setTypeId(String typeId) {
+		this.typeId = typeId;
+	}
 
 	public Info() {
 		super();
@@ -70,6 +108,14 @@ public class Info extends DataEntity<Info> {
 		this.relatedLabels = relatedLabels;
 	}
 
+	public String getAutoStatus() {
+		return autoStatus;
+	}
+
+	public void setAutoStatus(String autoStatus) {
+		this.autoStatus = autoStatus;
+	}
+
 	//	@Length(min=0, max=11, message="信息分类长度必须介于 0 和 11 之间")
 //	public String getTypeId() {
 //		return typeId;

+ 19 - 41
src/main/java/com/caimei/modules/info/entity/InfoType.java

@@ -1,56 +1,34 @@
 package com.caimei.modules.info.entity;
 
+import com.caimei.modules.landing.domain.CmBrandLanding;
+import lombok.Data;
 import org.hibernate.validator.constraints.Length;
 
 import com.thinkgem.jeesite.common.persistence.DataEntity;
 
+import java.util.List;
+
 /**
  * 信息分类Entity
  * @author LG
  * @version 2016-06-27
  */
+@Data
 public class InfoType extends DataEntity<InfoType> {
-	
+
 	private static final long serialVersionUID = 1L;
 	private String name;		// 分类名称
 	private Integer sort;		// 排序(升序)
-	private Integer shopUseFlag;	// 是否供应商可用:0否,1是
-	
-	public InfoType() {
-		super();
-	}
-
-	public InfoType(String id){
-		super(id);
-	}
-
-	public InfoType(String id,String enabledStatus){
-		super();
-		this.id=id;
-		this.enabledStatus=enabledStatus;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-	
-	public Integer getSort() {
-		return sort;
-	}
-
-	public void setSort(Integer sort) {
-		this.sort = sort;
-	}
-
-	public Integer getShopUseFlag() {
-		return shopUseFlag;
-	}
-
-	public void setShopUseFlag(Integer shopUseFlag) {
-		this.shopUseFlag = shopUseFlag;
-	}
-}
+	private Integer shopUseFlag;	// 是否供应商可用:0否,
+	/** 分类: 1 信息中心导航栏 */
+	private String type;
+
+	/** 父级编号 */
+	private String parentId;
+
+	/** 所有父级编号 */
+	private String parentIds;
+	/** 图片资源type=4 */
+	private List<CmBrandLanding> cmBrandLandingList;
+
+}

+ 194 - 0
src/main/java/com/caimei/modules/info/service/CmRelatedService.java

@@ -0,0 +1,194 @@
+package com.caimei.modules.info.service;
+
+import java.util.Date;
+import java.util.List;
+
+import com.caimei.modules.info.dao.CmInfoDocSynDao;
+import com.caimei.modules.info.entity.CmInfoDocSyn;
+import com.caimei.modules.info.entity.Info;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.service.CrudService;
+import com.thinkgem.jeesite.common.utils.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.caimei.modules.info.dao.CmRelatedMapper;
+import com.caimei.modules.info.entity.CmRelated;
+import com.caimei.modules.info.service.CmRelatedService;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * 相关资源Service业务层处理
+ *
+ * @author Kaick
+ * @date 2023-08-02
+ */
+@Service
+public class CmRelatedService extends CrudService<CmRelatedMapper, CmRelated> {
+    @Autowired
+    private CmRelatedMapper cmRelatedMapper;
+    @Autowired
+    private InfoService infoService;
+
+    public Page<CmRelated> findPage(Page<CmRelated> page, CmRelated cmRelated) {
+        Page<CmRelated> cmRelatedPage = super.findPage(page, cmRelated);
+        cmRelatedPage.getList().forEach(cmRelated1 -> {
+            cmRelated1.setInfo(infoService.get(cmRelated1.getRelatedId()));
+        });
+        return cmRelatedPage;
+    }
+
+    public List<CmRelated> getCmRelatedList(CmRelated cmRelated) {
+        List<CmRelated> cmRelatedList = cmRelatedMapper.getCmRelatedList(cmRelated);
+        cmRelatedList.forEach(cmRelated1 -> {
+            cmRelated1.setInfo(infoService.get(cmRelated1.getRelatedId()));
+        });
+        return cmRelatedList;
+    }
+
+    /**
+     * 通过Id查询相关资源
+     *
+     * @param id 相关资源主键
+     * @return 相关资源
+     */
+
+    public CmRelated getCmRelatedById(String id) {
+        CmRelated cmRelated = cmRelatedMapper.getCmRelatedById(id);
+        cmRelated.setInfo(infoService.get(cmRelated.getRelatedId()));
+        return cmRelated;
+    }
+
+    /**
+     * 通过对象查询相关资源
+     *
+     * @param cmRelated 相关资源
+     * @return 相关资源
+     */
+
+    public CmRelated getByCmRelated(CmRelated cmRelated) {
+        CmRelated byCmRelated = cmRelatedMapper.getByCmRelated(cmRelated);
+        byCmRelated.setInfo(infoService.get(cmRelated.getRelatedId()));
+        return byCmRelated;
+    }
+
+    /**
+     * 通过对象查询相关资源Id
+     *
+     * @param cmRelated 相关资源
+     * @return String
+     */
+
+    public String getById(CmRelated cmRelated) {
+        return cmRelatedMapper.getById(cmRelated);
+    }
+
+    /**
+     * 通过对象查询相关资源Ids
+     *
+     * @param cmRelated 相关资源
+     * @return List<String>
+     */
+
+    public List<String> getByIds(CmRelated cmRelated) {
+        return cmRelatedMapper.getByIds(cmRelated);
+    }
+
+    /**
+     * 通过对象查询相关资源记录总数
+     *
+     * @param cmRelated 相关资源
+     * @return int
+     */
+
+    public int getCmRelatedCount(CmRelated cmRelated) {
+        return cmRelatedMapper.getCmRelatedCount(cmRelated);
+    }
+
+    /**
+     * 新增相关资源
+     *
+     * @param cmRelated 相关资源
+     * @return 结果
+     */
+    @Transactional(readOnly = false)
+    public int addCmRelated(CmRelated cmRelated) {
+        cmRelated.setCreateTime(new Date());
+        return cmRelatedMapper.addCmRelated(cmRelated);
+    }
+
+    /**
+     * 修改相关资源
+     *
+     * @param cmRelated 相关资源
+     * @return 结果
+     */
+    @Transactional(readOnly = false)
+    public int updateCmRelated(CmRelated cmRelated) {
+        cmRelated.setUpdateTime(new Date());
+        return cmRelatedMapper.updateCmRelated(cmRelated);
+    }
+
+    /**
+     * 删除相关资源信息
+     *
+     * @param id 相关资源主键
+     * @return 结果
+     */
+    @Transactional(readOnly = false)
+    public int delCmRelatedById(String id) {
+        CmRelated cmRelated = new CmRelated();
+        cmRelated.setId(id);
+        cmRelated.setDelFlag("1");
+        return cmRelatedMapper.updateCmRelated(cmRelated);
+        //return cmRelatedMapper.delCmRelatedById(id);
+    }
+
+    /**
+     * 删除相关资源信息
+     *
+     * @param authorId 相关资源主键
+     * @return 结果
+     */
+    @Transactional(readOnly = false)
+    public int delCmRelatedByAuthorId(String type, String authorId) {
+        return cmRelatedMapper.delCmRelatedByAuthorId(type, authorId);
+    }
+
+    /**
+     * 批量删除相关资源
+     *
+     * @param ids 需要删除的相关资源主键
+     * @return 结果
+     */
+    @Transactional(readOnly = false)
+    public int delCmRelatedByIds(String[] ids) {
+        return cmRelatedMapper.updateDelCmRelatedByIds(ids, 1);
+        //return cmRelatedMapper.delCmRelatedByIds(ids);
+    }
+
+    /**
+     * 批量新增相关资源
+     *
+     * @param cmRelatedList 相关资源列表
+     * @return 结果
+     */
+    @Transactional(readOnly = false)
+    public void batchAddCmRelated(List<CmRelated> cmRelatedList) {
+        for (CmRelated cmRelated : cmRelatedList) {
+            cmRelatedMapper.addCmRelated(cmRelated);
+        }
+    }
+
+    /**
+     * 批量修改相关资源
+     *
+     * @param cmRelatedList 相关资源列表
+     * @return 结果
+     */
+    @Transactional(readOnly = false)
+    public void batchUpdateCmRelated(List<CmRelated> cmRelatedList) {
+        for (CmRelated cmRelated : cmRelatedList) {
+            cmRelatedMapper.updateCmRelated(cmRelated);
+        }
+    }
+}

+ 35 - 1
src/main/java/com/caimei/modules/info/service/InfoService.java

@@ -6,6 +6,7 @@ import java.util.List;
 import javax.servlet.http.HttpServletRequest;
 
 import com.caimei.modules.basesetting.dao.KeywordDao;
+import com.caimei.modules.hehe.entity.cmHeHeUserActivity;
 import com.caimei.modules.live.entity.NewPageLive;
 import com.caimei.modules.sys.utils.UploadImageUtils;
 import com.caimei.modules.utils.RequestUtil;
@@ -13,6 +14,7 @@ import com.caimei.modules.utils.message.InsideMessage;
 import com.caimei.modules.utils.message.MessageModel;
 import com.caimei.modules.utils.message.MqInfo;
 import com.caimei.modules.utils.message.enums.MessageType;
+import com.caimei.utils.StringUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
@@ -89,6 +91,38 @@ public class InfoService extends CrudService<InfoDao, Info> {
         });
         return infoPage;
     }
+    /**
+     * 通过对象查询信息基础列表
+     *
+     * @return 信息基础
+     */
+    public List<Info> getInfoList(Info info)
+    {
+        return infoDao.getInfoList(info);
+    }
+
+    /**
+     * 通过对象查询信息基础
+     *
+     * @param info 信息基础
+     * @return 信息基础
+     */
+    public Info getByInfo(Info info)
+    {
+        return infoDao.getByInfo(info);
+    }
+    /**
+     * 修改信息基础
+     *
+     * @param info 信息基础
+     * @return 结果
+     */
+    @Transactional(readOnly = false)
+    public int updateInfo(Info info)
+    {
+        info.setUpdateDate(new Date());
+        return infoDao.updateInfo(info);
+    }
 
     @Transactional(readOnly = false)
     public void save(Info info, HttpServletRequest request) {
@@ -336,4 +370,4 @@ public class InfoService extends CrudService<InfoDao, Info> {
     public void offlineInfo(Integer id) {
         infoDao.offlineInfo(id);
     }
-}
+}

+ 47 - 8
src/main/java/com/caimei/modules/info/service/InfoTypeService.java

@@ -1,7 +1,12 @@
 package com.caimei.modules.info.service;
 
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
 import java.util.List;
 
+import com.caimei.modules.hehe.util.UploadPicUtils;
+import com.caimei.modules.landing.mapper.CmBrandLandingMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -22,36 +27,70 @@ public class InfoTypeService extends CrudService<InfoTypeDao, InfoType> {
 
 	@Autowired
 	private InfoTypeDao infoTypedao;
-	
+	@Autowired
+	private CmBrandLandingMapper cmBrandLandingMapper;
+
 	public InfoType get(String id) {
 		return super.get(id);
 	}
-	
+
 	public List<InfoType> findList(InfoType infoType) {
 		return super.findList(infoType);
 	}
-	
+
 	public Page<InfoType> findPage(Page<InfoType> page, InfoType infoType) {
 		return super.findPage(page, infoType);
 	}
-	
+
 	@Transactional(readOnly = false)
 	public void save(InfoType infoType) {
+		if ("0".equals(infoType.getParentId())) {
+			infoType.setParentIds("0");
+		} else {
+			InfoType infoType1 = infoTypedao.get(infoType.getParentId());
+			infoType.setParentIds(infoType1.getParentIds() + "," + infoType.getParentId());
+		}
 		super.save(infoType);
+		cmBrandLandingMapper.delCmBrandLandingByAuthorId(infoType.getId());
+		//封装数据
+		infoType.getCmBrandLandingList().forEach(cmBrandLanding -> {
+			cmBrandLanding.setHeadPcBanner(UploadPicUtils.saveImageToServer(cmBrandLanding.getHeadPcBanner()));
+			cmBrandLanding.setHeadAppBanner(UploadPicUtils.saveImageToServer(cmBrandLanding.getHeadAppBanner()));
+			cmBrandLanding.setType(4);
+			cmBrandLanding.setAuthorId(infoType.getId());
+			cmBrandLanding.setAddTime(new Date());
+			cmBrandLandingMapper.insertCmBrandLanding(cmBrandLanding);
+		});
+
 	}
-	
+
 	@Transactional(readOnly = false)
 	public void delete(InfoType infoType) {
 		super.delete(infoType);
+		cmBrandLandingMapper.delCmBrandLandingByAuthorId(infoType.getId());
+		InfoType infoType1 = new InfoType();
+		infoType1.setParentIds(infoType.getId());
+		List<InfoType> byInfoTypeIdList = getByInfoTypeList(infoType1);
+		if(0<byInfoTypeIdList.size()){
+			byInfoTypeIdList.forEach(byInfoTypeId -> {
+				super.delete(byInfoTypeId);
+				cmBrandLandingMapper.delCmBrandLandingByAuthorId(byInfoTypeId.getId());
+			});
+		}
+
+	}
+
+	public List<InfoType> getByInfoTypeList(InfoType infoType) {
+		return infoTypedao.getByInfoTypeList(infoType);
 	}
 
 	@Transactional(readOnly = false)
 	public void updateEnabledStatusByIds(String enabledStatus, String[] ids) {
-		infoTypedao.updateEnabledStatusByIds(enabledStatus,ids);
+		infoTypedao.updateEnabledStatusByIds(enabledStatus, ids);
 	}
 
 	public int countEnabledStatus(String enabledStatus) {
 		return infoTypedao.countEnabledStatus(enabledStatus);
 	}
-	
-}
+
+}

+ 129 - 0
src/main/java/com/caimei/modules/info/web/InfoController.java

@@ -7,9 +7,12 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import com.alibaba.fastjson.JSONArray;
+import com.caimei.modules.hehe.entity.CmHeheProduct;
 import com.caimei.modules.info.dao.InfoDao;
 import com.caimei.modules.info.entity.CmInfoDocSyn;
+import com.caimei.modules.info.entity.CmRelated;
 import com.caimei.modules.info.service.CmInfoDocSynService;
+import com.caimei.modules.info.service.CmRelatedService;
 import com.caimei.modules.opensearch.GenerateUtils;
 import com.caimei.modules.opensearch.CoreServiceUitls;
 import com.caimei.modules.product.dao.KeywordFrequencyDao;
@@ -48,6 +51,8 @@ public class InfoController extends BaseController {
 
     @Autowired
     private InfoService infoService;
+    @Autowired
+    private CmRelatedService cmRelatedService;
 
     @Autowired
     private InfoTypeService infoTypeService;
@@ -100,6 +105,7 @@ public class InfoController extends BaseController {
             }
         }
         InfoType infoType = new InfoType();
+        infoType.setType("1");
         infoType.setEnabledStatus("1");
         List<InfoType> typeList = infoTypeService.findList(infoType);
         List<Info> topList = infoService.findTopList();
@@ -157,6 +163,120 @@ public class InfoController extends BaseController {
         return "modules/info/infoForm";
     }
 
+    @RequiresPermissions("info:info:view")
+    @RequestMapping(value = "relatedForm")
+    public String relatedForm(Info info, String ltype, Model model) {
+        CmRelated cmRelated = new CmRelated();
+        cmRelated.setAuthorId(info.getId());
+        cmRelated.setType("1");
+        info.setCmRelatedList(cmRelatedService.getCmRelatedList(cmRelated));
+        model.addAttribute("info", info);
+        model.addAttribute("ltype", ltype);
+        return "modules/info/infoRelatedForm";
+    }
+
+
+    /**
+     * 精选推荐,文章数据
+     */
+    @RequestMapping(value = "infoSelectedPage")
+    public String infoSelectedList(CmRelated cmRelated, Model model, HttpServletRequest request, HttpServletResponse response) {
+        cmRelated.setType("2");
+        Page<CmRelated> page = cmRelatedService.findPage(new Page<CmRelated>(request, response), cmRelated);
+        InfoType infoType = new InfoType();
+        infoType.setType("1");
+        infoType.setEnabledStatus("1");
+        List<InfoType> typeList = infoTypeService.findList(infoType);
+        model.addAttribute("typeList", typeList);
+        model.addAttribute("page", page);
+        return "modules/info/infoSelectedList";
+    }
+
+    /**
+     * 选择文章,文章数据
+     */
+    @RequestMapping(value = "findInfoPage")
+    public String findInfoPage(Info info, Model model, HttpServletRequest request, HttpServletResponse response) {
+        info.setOnlineStatus(2);
+        Page<Info> page = infoService.findPage(new Page<Info>(request, response), info);
+        InfoType infoType = new InfoType();
+        infoType.setType("1");
+        infoType.setEnabledStatus("1");
+        List<InfoType> typeList = infoTypeService.findList(infoType);
+        model.addAttribute("typeList", typeList);
+        model.addAttribute("page", page);
+        return "modules/info/addInfoForm";
+    }
+
+
+    /**
+     * 添加精选文章文章数据
+     */
+    @RequestMapping(value = "addSelectedInfos")
+    @ResponseBody
+    public Map<String, Object> addSelectedInfos(String infoIds) {
+        for (String relatedId : infoIds.split(",")) {
+            CmRelated cmRelated = new CmRelated();
+            cmRelated.setRelatedId(relatedId);
+            cmRelated.setType("2");
+            cmRelated.setSort(0);
+            cmRelated.setDelFlag("0");
+            cmRelated.setCreateTime(new Date());
+            cmRelatedService.addCmRelated(cmRelated);
+        }
+        HashMap<String, Object> map = new HashMap<>(2);
+        map.put("success", true);
+        map.put("info", "添加文章成功");
+        return map;
+    }
+
+    /**
+     * 添加文章数据
+     */
+    @RequestMapping(value = "addInfos")
+    @ResponseBody
+    public Map<String, Object> addInfos(String infoIds) {
+        Info info = new Info();
+        info.setId("IN=" + infoIds);
+        info.setEnabledStatus("1");
+        List<Info> infoList = infoService.getInfoList(info);
+        HashMap<String, Object> map = new HashMap<>(2);
+        map.put("infoList", infoList);
+        map.put("success", true);
+        map.put("info", "添加文章成功");
+        return map;
+    }
+
+    @RequestMapping(value = "relatedSave")
+    public String relatedSave(Info info, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request) {
+        Info byInfo = new Info();
+        byInfo.setId(info.getId());
+        byInfo.setAutoStatus(info.getAutoStatus());
+        infoService.updateInfo(byInfo);
+        if ("1".equals(info.getAutoStatus())) {
+            cmRelatedService.delCmRelatedByAuthorId("1", info.getId());
+            info.getCmRelatedList().forEach(cmRelated -> {
+                cmRelated.setType("1");
+                cmRelated.setDelFlag("0");
+                cmRelated.setCreateTime(new Date());
+                cmRelatedService.addCmRelated(cmRelated);
+            });
+        }
+        addMessage(redirectAttributes, "保存信息成功");
+        // 更新索引
+        coreServiceUitls.updateArticleIndex(Integer.valueOf(info.getId()));
+        return "redirect:" + Global.getAdminPath() + "/info/info/list?repage&publishSource=" + info.getPublishSource();
+    }
+
+    @RequestMapping(value = "infoSelectedListSave")
+    public String infoSelectedListSave(Info info, Model model, RedirectAttributes redirectAttributes, HttpServletRequest request) {
+        info.getCmRelatedList().forEach(cmRelated -> {
+            cmRelatedService.updateCmRelated(cmRelated);
+        });
+        addMessage(redirectAttributes, "更新排序成功");
+        return "redirect:" + Global.getAdminPath() + "/info/info/infoSelectedPage";
+    }
+
     @RequiresPermissions("info:info:edit")
     @RequestMapping(value = "save")
     public String save(Info info, Model model, String ltype, RedirectAttributes redirectAttributes, HttpServletRequest request) {
@@ -201,6 +321,7 @@ public class InfoController extends BaseController {
         return "redirect:" + Global.getAdminPath() + "/info/info/list?repage&publishSource=" + info.getPublishSource();
     }
 
+
     @RequiresPermissions("info:info:delete")
     @RequestMapping(value = "delete")
     public String delete(Info info, RedirectAttributes redirectAttributes) {
@@ -217,6 +338,14 @@ public class InfoController extends BaseController {
         return "redirect:" + Global.getAdminPath() + "/info/info/?repage&publishSource=1";
     }
 
+    @RequiresPermissions("info:info:delete")
+    @RequestMapping(value = "delInfoSelected")
+    public String delete(CmRelated cmRelated, RedirectAttributes redirectAttributes) {
+        cmRelatedService.delCmRelatedById(cmRelated.getId());
+        addMessage(redirectAttributes, "删除文章成功");
+        return "redirect:" + Global.getAdminPath() + "/info/info/infoSelectedPage";
+    }
+
     /**
      * 批量修改启用、停用状态
      *

+ 37 - 15
src/main/java/com/caimei/modules/info/web/InfoTypeController.java

@@ -6,6 +6,9 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.caimei.modules.hehe.util.UploadPicUtils;
+import com.caimei.modules.landing.domain.CmBrandLanding;
+import com.caimei.modules.landing.service.CmBrandLandingService;
 import com.caimei.modules.opensearch.CoreServiceUitls;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -39,18 +42,23 @@ public class InfoTypeController extends BaseController {
 
 	@Autowired
 	private InfoTypeService infoTypeService;
-
+	@Autowired
+	private CmBrandLandingService cmBrandLandingService;
 	@Autowired
 	private InfoService infoService;
 
-    @Autowired
-    private CoreServiceUitls coreServiceUitls;
+	@Autowired
+	private CoreServiceUitls coreServiceUitls;
 
 	@ModelAttribute
-	public InfoType get(@RequestParam(required=false) String id) {
+	public InfoType get(@RequestParam(required = false) String id) {
 		InfoType entity = null;
-		if (StringUtils.isNotBlank(id)){
+		if (StringUtils.isNotBlank(id)) {
 			entity = infoTypeService.get(id);
+			CmBrandLanding cmBrandLanding = new CmBrandLanding();
+			cmBrandLanding.setType(4);
+			cmBrandLanding.setAuthorId(id);
+			entity.setCmBrandLandingList(cmBrandLandingService.selectCmBrandLandingList(cmBrandLanding));
 		}
 		if (entity == null){
 			entity = new InfoType();
@@ -76,32 +84,46 @@ public class InfoTypeController extends BaseController {
 	@RequiresPermissions("info:infoType:edit")
 	@RequestMapping(value = "save")
 	public String save(InfoType infoType, Model model, RedirectAttributes redirectAttributes) {
-		if (!beanValidator(model, infoType)){
-			return form(infoType, model);
-		}
+//		if (!beanValidator(model, infoType)) {
+//			return form(infoType, model);
+//		}
 		infoTypeService.save(infoType);
 		addMessage(redirectAttributes, "保存信息分类成功");
 		// 更新全部文章索引
-		coreServiceUitls.updateAllArticleIndex();
-		return "redirect:"+Global.getAdminPath()+"/info/infoType/?repage";
+//		coreServiceUitls.updateAllArticleIndex();
+		return "redirect:" + Global.getAdminPath() + "/info/infoType/?repage&type=" + infoType.getType() + "&parentId=" + infoType.getParentId();
 	}
 
 	@RequiresPermissions("info:infoType:delete")
 	@RequestMapping(value = "delete")
 	public String delete(InfoType infoType, RedirectAttributes redirectAttributes) {
-		Info info=new Info();
+		Info info = new Info();
 		info.setInfoType(infoType);
 		List<Info> list = infoService.findList(info);
-		if(CollectionUtils.isNotEmpty(list)){
+		//子级菜单
+		InfoType infoType1 = new InfoType();
+		infoType1.setParentIds(infoType.getId());
+		List<InfoType> byInfoTypeIdList = infoTypeService.getByInfoTypeList(infoType1);
+		if (CollectionUtils.isNotEmpty(byInfoTypeIdList)) {
+			for (InfoType byInfoType : byInfoTypeIdList) {
+				Info byInfo = new Info();
+				info.setInfoType(byInfoType);
+				List<Info> byList = infoService.findList(byInfo);
+				if (CollectionUtils.isNotEmpty(byList)) {
+					addMessage(redirectAttributes, "删除信息分类失败,请先把该分类的所有子级信息删除");
+					return "redirect:" + Global.getAdminPath() + "/info/infoType/?repage&type=" + infoType.getType() + "&parentId=" + infoType.getParentId();
+				}
+			}
+		} else if (CollectionUtils.isNotEmpty(list)) {
 			addMessage(redirectAttributes, "删除信息分类失败,请先把该分类的所有信息删除");
-		}else{
+		} else {
 			infoService.deleteByTypeId(infoType.getId());
 			infoTypeService.delete(infoType);
 			addMessage(redirectAttributes, "删除信息分类成功");
 			// 更新全部文章索引
-			coreServiceUitls.updateAllArticleIndex();
+//			coreServiceUitls.updateAllArticleIndex();
 		}
-		return "redirect:"+Global.getAdminPath()+"/info/infoType/?repage";
+		return "redirect:" + Global.getAdminPath() + "/info/infoType/?repage&type=" + infoType.getType() + "&parentId=" + infoType.getParentId();
 	}
 
 	/**

+ 9 - 197
src/main/java/com/caimei/modules/landing/domain/CmBrandLanding.java

@@ -3,6 +3,7 @@ package com.caimei.modules.landing.domain;
 import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.thinkgem.jeesite.common.persistence.DataEntity;
+import lombok.Data;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import org.apache.ibatis.type.Alias;
@@ -12,10 +13,11 @@ import java.util.List;
 
 /**
  * 供应商落地页资源对象 cm_brand_landing
- * 
+ *
  * @author Kaick
  * @date 2023-05-24
  */
+@Data
 @Alias("CmBrandLanding")
 public class CmBrandLanding extends DataEntity<CmBrandLanding> implements Serializable
 {
@@ -23,13 +25,17 @@ public class CmBrandLanding extends DataEntity<CmBrandLanding> implements Serial
 
     /** id */
     private String id;
-
     /** 供应商id */
     private Integer authUserId;
 
-    /** 分类:1成功案例,2增长社区-视频列表,3增长社区-文章列表 */
+    /** 分类:1成功案例,2增长社区-视频列表,3增长社区-文章列表, 4信息中心导航栏(info_type) */
     private Integer type;
 
+    /** 子级分类: 信息中心导航栏(info_type):{1 大图,2小图} */
+    private Integer levelType;
+
+    /** 归属者Id(type字段表Id) */
+    private String authorId;
     /** pc端picture */
     private String headPcBanner;
 
@@ -72,8 +78,6 @@ public class CmBrandLanding extends DataEntity<CmBrandLanding> implements Serial
     private String delFlag;
     /** 文件名称*/
     private List<CmBrandFiles> cmBrandFiles;
-
-
     /** 修改时间 */
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date updateTime;
@@ -81,196 +85,4 @@ public class CmBrandLanding extends DataEntity<CmBrandLanding> implements Serial
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date addTime;
 
-    public List<CmBrandFiles> getCmBrandFiles() {
-        return cmBrandFiles;
-    }
-
-    public void setCmBrandFiles(List<CmBrandFiles> cmBrandFiles) {
-        this.cmBrandFiles = cmBrandFiles;
-    }
-
-    public Date getUpdateTime() {
-        return updateTime;
-    }
-
-    public void setUpdateTime(Date updateTime) {
-        this.updateTime = updateTime;
-    }
-    public void setId(String id)
-    {
-        this.id = id;
-    }
-
-    public String getId()
-    {
-        return id;
-    }
-    public void setAuthUserId(Integer authUserId) 
-    {
-        this.authUserId = authUserId;
-    }
-
-    public Integer getAuthUserId() 
-    {
-        return authUserId;
-    }
-    public void setType(Integer type) 
-    {
-        this.type = type;
-    }
-
-    public Integer getType() 
-    {
-        return type;
-    }
-    public void setHeadPcBanner(String headPcBanner) 
-    {
-        this.headPcBanner = headPcBanner;
-    }
-
-    public String getHeadPcBanner() 
-    {
-        return headPcBanner;
-    }
-    public void setHeadAppBanner(String headAppBanner) 
-    {
-        this.headAppBanner = headAppBanner;
-    }
-
-    public String getHeadAppBanner() 
-    {
-        return headAppBanner;
-    }
-    public void setJumpStatus(Integer jumpStatus) 
-    {
-        this.jumpStatus = jumpStatus;
-    }
-
-    public Integer getJumpStatus() 
-    {
-        return jumpStatus;
-    }
-    public void setJumpPcPicture(String jumpPcPicture) 
-    {
-        this.jumpPcPicture = jumpPcPicture;
-    }
-
-    public String getJumpPcPicture() 
-    {
-        return jumpPcPicture;
-    }
-    public void setJumpAppPicture(String jumpAppPicture) 
-    {
-        this.jumpAppPicture = jumpAppPicture;
-    }
-
-    public String getJumpAppPicture() 
-    {
-        return jumpAppPicture;
-    }
-    public void setJumpLink(String jumpLink) 
-    {
-        this.jumpLink = jumpLink;
-    }
-
-    public String getJumpLink() 
-    {
-        return jumpLink;
-    }
-    public void setTitle(String title) 
-    {
-        this.title = title;
-    }
-
-    public String getTitle() 
-    {
-        return title;
-    }
-    public void setContent(String content) 
-    {
-        this.content = content;
-    }
-
-    public String getContent() 
-    {
-        return content;
-    }
-    public void setVideo(String video) 
-    {
-        this.video = video;
-    }
-
-    public String getVideo() 
-    {
-        return video;
-    }
-    public void setSort(Integer sort) 
-    {
-        this.sort = sort;
-    }
-
-    public Integer getSort() 
-    {
-        return sort;
-    }
-    public void setPcStatus(Integer pcStatus) 
-    {
-        this.pcStatus = pcStatus;
-    }
-
-    public Integer getPcStatus() 
-    {
-        return pcStatus;
-    }
-    public void setAppStatus(Integer appStatus) 
-    {
-        this.appStatus = appStatus;
-    }
-
-    public Integer getAppStatus() 
-    {
-        return appStatus;
-    }
-    public void setDelFlag(String delFlag)
-    {
-        this.delFlag = delFlag;
-    }
-
-    public String getDelFlag()
-    {
-        return delFlag;
-    }
-    public void setAddTime(Date addTime) 
-    {
-        this.addTime = addTime;
-    }
-
-    public Date getAddTime() 
-    {
-        return addTime;
-    }
-
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
-            .append("authUserId", getAuthUserId())
-            .append("type", getType())
-            .append("headPcBanner", getHeadPcBanner())
-            .append("headAppBanner", getHeadAppBanner())
-            .append("jumpStatus", getJumpStatus())
-            .append("jumpPcPicture", getJumpPcPicture())
-            .append("jumpAppPicture", getJumpAppPicture())
-            .append("jumpLink", getJumpLink())
-            .append("title", getTitle())
-            .append("content", getContent())
-            .append("video", getVideo())
-            .append("sort", getSort())
-            .append("pcStatus", getPcStatus())
-            .append("appStatus", getAppStatus())
-            .append("delFlag", getDelFlag())
-            .append("updateTime", getUpdateTime())
-            .append("addTime", getAddTime())
-            .toString();
-    }
 }

+ 23 - 7
src/main/java/com/caimei/modules/landing/mapper/CmBrandLandingMapper.java

@@ -11,7 +11,7 @@ import java.util.List;
 
 /**
  * 供应商落地页资源Mapper接口
- * 
+ *
  * @author Kaick
  * @date 2023-05-24
  */
@@ -24,7 +24,7 @@ public interface CmBrandLandingMapper  extends CrudDao<CmBrandLanding>
     public int updateSort(@Param("id") String id, @Param("sort") String sort);
     /**
      * 查询供应商落地页资源
-     * 
+     *
      * @param id 供应商落地页资源主键
      * @return 供应商落地页资源
      */
@@ -32,7 +32,15 @@ public interface CmBrandLandingMapper  extends CrudDao<CmBrandLanding>
 
     /**
      * 查询供应商落地页资源列表
-     * 
+     *
+     * @param cmBrandLanding 供应商落地页资源
+     * @return 供应商落地页资源集合
+     */
+    public String getById(CmBrandLanding cmBrandLanding);
+
+    /**
+     * 查询供应商落地页资源列表
+     *
      * @param cmBrandLanding 供应商落地页资源
      * @return 供应商落地页资源集合
      */
@@ -40,7 +48,7 @@ public interface CmBrandLandingMapper  extends CrudDao<CmBrandLanding>
 
     /**
      * 新增供应商落地页资源
-     * 
+     *
      * @param cmBrandLanding 供应商落地页资源
      * @return 结果
      */
@@ -48,7 +56,7 @@ public interface CmBrandLandingMapper  extends CrudDao<CmBrandLanding>
 
     /**
      * 修改供应商落地页资源
-     * 
+     *
      * @param cmBrandLanding 供应商落地页资源
      * @return 结果
      */
@@ -56,15 +64,23 @@ public interface CmBrandLandingMapper  extends CrudDao<CmBrandLanding>
 
     /**
      * 删除供应商落地页资源
-     * 
+     *
      * @param id 供应商落地页资源主键
      * @return 结果
      */
     public int deleteCmBrandLandingById(String id);
 
+    /**
+     * 删除供应商落地页资源
+     *
+     * @param authorId 供应商落地页资源主键
+     * @return 结果
+     */
+    public int delCmBrandLandingByAuthorId(String authorId);
+
     /**
      * 批量删除供应商落地页资源
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */

+ 2 - 0
src/main/java/com/caimei/modules/order/dao/CmPayShopDao.java

@@ -33,4 +33,6 @@ public interface CmPayShopDao extends CrudDao<CmPayShop> {
     List<CmDiscernReceipt> getDiscernReceipts(Integer shopOrderId);
 
     List<Product> priceNum(@Param("orderNo") String orderNo);
+
+    List<CmPayShop> payThirdParties(CmPayShop cmPayShop);
 }

+ 6 - 2
src/main/java/com/caimei/modules/order/dao/CmReceiptOrderRelationDao.java

@@ -26,9 +26,13 @@ public interface CmReceiptOrderRelationDao extends CrudDao<CmReceiptOrderRelatio
 
     Double findPayFeeByOrderID(@Param("orderID")String orderID);
 
+    Double findReceiptByShopOrderId(@Param("shopOrderId")String shopOrderId);
+
     List<Integer> toAudit(@Param("orderID")Integer orderID);
 
-    CmReceiptOrderRelation findOrderRelation(Integer orderID);
+    CmReceiptOrderRelation findOrderRelation(@Param("orderId") Integer orderId, @Param("shopOrderId") Integer shopOrderId);
+
+    Integer getDiscernPayWay(Integer orderID);
 
     Date findOnlinePayment(Integer orderID);
 
@@ -37,4 +41,4 @@ public interface CmReceiptOrderRelationDao extends CrudDao<CmReceiptOrderRelatio
     String findUserId(Integer orderId);
 
     List<CmReceiptOrderRelation> findByShopOrderIds(@Param("shopOrderIds")List<Integer> shopOrderIds);
-}
+}

+ 105 - 4
src/main/java/com/caimei/modules/order/dao/NewOrderDao.java

@@ -5,6 +5,7 @@ import com.caimei.modules.coupon.entity.CmCouponOrderRecord;
 import com.caimei.modules.order.entity.*;
 import com.caimei.modules.product.entity.CmPromotion;
 import com.caimei.modules.user.entity.NewCmSp;
+import com.caimei.po.neworder.CmOrder;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import org.apache.ibatis.annotations.Param;
@@ -202,9 +203,6 @@ public interface NewOrderDao extends CrudDao<NewOrder> {
     List<OrderReceiptRelationPo> getUndividedPaidReceipt(@Param("currentTime")String currentTime,@Param("shopOrderIds")String shopOrderIds);
 
     List<OrderProductVo> getOrderProductByOrderId(Integer orderId);
-
-    Double getOrderProductPaidAmount(Integer orderProductId);
-
     ShopOrderVo getShopOrderListByOrderId(Integer shopOrderId);
 
     List<ShopOrderVo> getShopOrderByOrderId(Integer orderId);
@@ -267,5 +265,108 @@ public interface NewOrderDao extends CrudDao<NewOrder> {
 
     List<SplitAccountPo> getSplitRecord(Integer orderID);
 
-    Integer getSplitTime(Integer shopOrderId);
+    Integer getSplitTime(String shopOrderId);
+
+    /**
+     * 查询用户模块重构-主订单
+     *
+     * @param orderID 用户模块重构-主订单主键
+     * @return 用户模块重构-主订单
+     */
+    NewOrder getCmOrderByOrderID(String orderID);
+
+    /**
+     * 查询用户模块重构-主订单Id
+     *
+     * @param cmOrder 用户模块重构-主订单
+     * @return String
+     */
+    public String getById(NewOrder cmOrder);
+
+    /**
+     * 查询用户模块重构-主订单Ids
+     *
+     * @param cmOrder 用户模块重构-主订单
+     * @return List<String>
+     */
+    public List<String> getByIds(NewOrder cmOrder);
+
+    /**
+     * 查询用户模块重构-主订单
+     *
+     * @param cmOrder 用户模块重构-主订单
+     * @return 用户模块重构-主订单集合
+     */
+    public NewOrder getByCmOrder(NewOrder cmOrder);
+
+    /**
+     * 查询用户模块重构-主订单列表
+     *
+     * @param cmOrder 用户模块重构-主订单
+     * @return 用户模块重构-主订单集合
+     */
+    public List<NewOrder> getCmOrderList(NewOrder cmOrder);
+    /**
+     * 查询用户模块重构-主订单记录总数
+     *
+     * @param cmOrder 用户模块重构-主订单
+     * @return 用户模块重构-主订单Integer
+     */
+    public int getCmOrderCount(NewOrder cmOrder);
+
+    /**
+     * 新增用户模块重构-主订单
+     *
+     * @param cmOrder 用户模块重构-主订单
+     * @return 结果
+     */
+    public int addCmOrder(NewOrder cmOrder);
+
+    /**
+     * 修改用户模块重构-主订单
+     *
+     * @param cmOrder 用户模块重构-主订单
+     * @return 结果
+     */
+    public int updateCmOrder(NewOrder cmOrder);
+
+    /**
+     * 删除用户模块重构-主订单
+     *
+     * @param orderID 用户模块重构-主订单主键
+     * @return 结果
+     */
+    public int delCmOrderByOrderID(String orderID);
+
+    /**
+     * 批量删除用户模块重构-主订单
+     *
+     * @param orderIDs 需要删除的数据主键集合
+     * @return 结果
+     */
+    int delCmOrderByOrderIDs(@Param("orderIDs") String[] orderIDs);
+
+    /**
+     * 修改批量删除用户模块重构-主订单
+     *
+     * @param orderIDs 需要删除的数据主键集合
+     * @return 结果
+     */
+    int updateDelCmOrderByOrderIDs(@Param("orderIDs") String[] orderIDs,@Param("delFlag") Integer delFlag);
+
+    Double getPaidOrganizePrice(Integer shopOrderId);
+
+    String findSplitCodeByOrganize(Integer organizeId);
+
+    double findPayOther(Integer shopOrderId);
+
+    Double getShopOrderPaidAmount(Integer shopOrderId);
+
+    Double getOtherPaid(String shopOrderId);
+
+    Double findShopCost(String shopOrderId);
+
+    Double findPayOrganize(String shopOrderId);
+
+    String findOrganizeSplitByShopOrder(String shopOrderId);
 }

+ 108 - 0
src/main/java/com/caimei/modules/order/dao/NewShopOrderDao.java

@@ -2,6 +2,8 @@ package com.caimei.modules.order.dao;
 
 import com.caimei.modules.order.entity.NewShopOrder;
 import com.caimei.modules.order.entity.SettleRecord;
+import com.caimei.modules.product.entity.Shop;
+import com.caimei.po.neworder.CmShopOrder;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import org.apache.ibatis.annotations.Param;
@@ -25,8 +27,14 @@ public interface NewShopOrderDao extends CrudDao<NewShopOrder> {
 
     NewShopOrder findByShopOrderID(@Param("shopOrderID") Integer shopOrderID);
 
+    Double findByPayShopID(@Param("shopOrderID") Integer shopOrderID);
+
     List<NewShopOrder> findListByOrderID(@Param("orderID") Integer orderID);
 
+    Double getFreightAmount(Integer productId);
+
+    Shop getShopOrderId(@Param("shopId") Integer shopId);
+
     List<String> findCommercialCode(@Param("orderID") Integer orderID);
 
     String FromUnionId(Integer orderId);
@@ -45,6 +53,20 @@ public interface NewShopOrderDao extends CrudDao<NewShopOrder> {
 
     List<NewShopOrder> findPayOrderList(NewShopOrder shopOrder);
 
+    List<NewShopOrder> payThirdParties(NewShopOrder shopOrder);
+
+    List<NewShopOrder> findShopOrderList(NewShopOrder shopOrder);
+
+    Double payAmountByShopOrderId(Integer shopOrderId);
+
+    Double settleAmountByShopOrderId(Integer shopOrderId);
+
+    Double payShopAmountShopOrderId(Integer shopOrderId);
+
+    Double returnedPurchaseFeeByShopOrderId(Integer shopOrderId);
+
+    Integer findSplitCount(Integer shopOrderId);
+
     void updatePayShopAmount(NewShopOrder shopOrder);
 
     List<NewShopOrder> findByShopOrderIDs(@Param("shopOrderIDs") List<String> shopOrderIDs);
@@ -85,4 +107,90 @@ public interface NewShopOrderDao extends CrudDao<NewShopOrder> {
 
     //查询子订单是 线上 还是 线上
     List<Integer> payWay(Integer shopOrderID);
+    /**
+     * 查询子订单
+     *
+     * @param shopOrderID 子订单主键
+     * @return 子订单
+     */
+    public NewShopOrder getCmShopOrderByShopOrderID(String shopOrderID);
+
+    /**
+     * 查询子订单Id
+     *
+     * @param cmShopOrder 子订单
+     * @return String
+     */
+    public String getById(NewShopOrder cmShopOrder);
+
+    /**
+     * 查询子订单Ids
+     *
+     * @param cmShopOrder 子订单
+     * @return List<String>
+     */
+    public List<String> getByIds(NewShopOrder cmShopOrder);
+
+    /**
+     * 查询子订单
+     *
+     * @param cmShopOrder 子订单
+     * @return 子订单集合
+     */
+    public NewShopOrder getByCmShopOrder(NewShopOrder cmShopOrder);
+
+    /**
+     * 查询子订单列表
+     *
+     * @param cmShopOrder 子订单
+     * @return 子订单集合
+     */
+    public List<NewShopOrder> getCmShopOrderList(NewShopOrder cmShopOrder);
+    /**
+     * 查询子订单记录总数
+     *
+     * @param cmShopOrder 子订单
+     * @return 子订单Integer
+     */
+    public int getCmShopOrderCount(NewShopOrder cmShopOrder);
+
+    /**
+     * 新增子订单
+     *
+     * @param cmShopOrder 子订单
+     * @return 结果
+     */
+    public int addCmShopOrder(NewShopOrder cmShopOrder);
+
+    /**
+     * 修改子订单
+     *
+     * @param cmShopOrder 子订单
+     * @return 结果
+     */
+    public int updateCmShopOrder(NewShopOrder cmShopOrder);
+
+    /**
+     * 删除子订单
+     *
+     * @param shopOrderID 子订单主键
+     * @return 结果
+     */
+    public int delCmShopOrderByShopOrderID(String shopOrderID);
+
+    /**
+     * 批量删除子订单
+     *
+     * @param shopOrderIDs 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int delCmShopOrderByShopOrderIDs(@Param("shopOrderIDs") String[] shopOrderIDs);
+
+    /**
+     * 修改批量删除子订单
+     *
+     * @param shopOrderIDs 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int updateDelCmShopOrderByShopOrderIDs(@Param("shopOrderIDs") String[] shopOrderIDs,@Param("delFlag") Integer delFlag);
 }

+ 1 - 1
src/main/java/com/caimei/modules/order/entity/ChangePayShopDifference.java

@@ -33,7 +33,7 @@ public class ChangePayShopDifference implements Serializable {
     private BigDecimal differencePrice;
 
     /**
-     * 差价类型:1 少付;2 多付
+     * 差价类型:1 成本上升;2 成本降低
      */
     private Integer type;
 

+ 23 - 0
src/main/java/com/caimei/modules/order/entity/ChangePayShopOther.java

@@ -11,6 +11,11 @@ import java.util.Date;
  * @date : 2021/5/26
  */
 public class ChangePayShopOther implements Serializable {
+
+    /**
+     * 1线下付第三方  2 线上付三方
+     */
+    private Integer payType;
     private Integer id;
     /**
      * 子订单Id
@@ -94,6 +99,8 @@ public class ChangePayShopOther implements Serializable {
      */
     private Integer payShopId;
 
+    private Integer redirectType;
+
     public Integer getId() {
         return id;
     }
@@ -102,6 +109,14 @@ public class ChangePayShopOther implements Serializable {
         this.id = id;
     }
 
+    public Integer getPayType() {
+        return payType;
+    }
+
+    public void setPayType(Integer payType) {
+        this.payType = payType;
+    }
+
     public Integer getShopOrderId() {
         return shopOrderId;
     }
@@ -237,4 +252,12 @@ public class ChangePayShopOther implements Serializable {
     public void setPayShopId(Integer payShopId) {
         this.payShopId = payShopId;
     }
+
+    public Integer getRedirectType() {
+        return redirectType;
+    }
+
+    public void setRedirectType(Integer redirectType) {
+        this.redirectType = redirectType;
+    }
 }

+ 10 - 0
src/main/java/com/caimei/modules/order/entity/CmPayShop.java

@@ -69,6 +69,8 @@ public class CmPayShop extends DataEntity<CmPayShop> {
     //  付款账号的类型 0公账, 1私账
     private String typeStr;
 
+    private Integer redirectType;
+
     public String getRebateFee() {
         return rebateFee;
     }
@@ -460,4 +462,12 @@ public class CmPayShop extends DataEntity<CmPayShop> {
     public void setPaymentType(Integer paymentType) {
         this.paymentType = paymentType;
     }
+
+    public Integer getRedirectType() {
+        return redirectType;
+    }
+
+    public void setRedirectType(Integer redirectType) {
+        this.redirectType = redirectType;
+    }
 }

+ 61 - 1
src/main/java/com/caimei/modules/order/entity/NewOrder.java

@@ -25,6 +25,7 @@ public class NewOrder extends DataEntity<NewOrder> {
     private Integer organizeStoreId;    // 组织门店id
     private Integer shopOrderID;        // varchar(100) comment '子订单ID',
     private String shopOrderIDs;        // varchar(100) comment '子订单ID',
+    private String shopOrderNoAndId;     // 子订单Id和子订单编号
     private String orderSubmitType;     // char(2) comment '订单提交类型',
     private String status;      // char(2) comment '订单状态'
     // v5.0.0新状态 '0待确认,11待收待发,12待收部发,13待收全发,21部收待发,22部收部发,23部收全发,31已收待发,32已收部发,33已收全发,4交易完成,5订单完成,6已关闭,7交易全退'
@@ -165,12 +166,63 @@ public class NewOrder extends DataEntity<NewOrder> {
     private Integer numbers;    // 总数
     private Double totalMoney;  // 总金额
 
-
+    /** 已支付成功次数统计(适用线上多笔付款用来确认当前是哪一笔) */
+    private Integer paySuccessCounter;
+    /** 包邮券ID  保留字段 */
+    private Integer freePostageTicketID;
+    /** 第三方订单编号(绑定第三方订单关系),适用第三方发起订单 */
+    private String thirdPartyOrderNo;
+    /** 订单是否同步发货物流给第三方,0未同步,1已同步 */
+    private String synchronizeFlag;
+
+    /** 消息推送用户ID */
+    private String unionID;
     /**
      * 呵呵商城优惠券
      */
     private Integer receiveCouponId;
     private CmHeheCouponOrderRecord heheCouponRecord;   //优惠券信息
+
+    public Integer getPaySuccessCounter() {
+        return paySuccessCounter;
+    }
+
+    public void setPaySuccessCounter(Integer paySuccessCounter) {
+        this.paySuccessCounter = paySuccessCounter;
+    }
+
+    public Integer getFreePostageTicketID() {
+        return freePostageTicketID;
+    }
+
+    public void setFreePostageTicketID(Integer freePostageTicketID) {
+        this.freePostageTicketID = freePostageTicketID;
+    }
+
+    public String getThirdPartyOrderNo() {
+        return thirdPartyOrderNo;
+    }
+
+    public void setThirdPartyOrderNo(String thirdPartyOrderNo) {
+        this.thirdPartyOrderNo = thirdPartyOrderNo;
+    }
+
+    public String getSynchronizeFlag() {
+        return synchronizeFlag;
+    }
+
+    public void setSynchronizeFlag(String synchronizeFlag) {
+        this.synchronizeFlag = synchronizeFlag;
+    }
+
+    public String getUnionID() {
+        return unionID;
+    }
+
+    public void setUnionID(String unionID) {
+        this.unionID = unionID;
+    }
+
     public Integer getShopOrderID() {
         return shopOrderID;
     }
@@ -371,6 +423,14 @@ public class NewOrder extends DataEntity<NewOrder> {
         this.userID = userID;
     }
 
+    public String getShopOrderNoAndId() {
+        return shopOrderNoAndId;
+    }
+
+    public void setShopOrderNoAndId(String shopOrderNoAndId) {
+        this.shopOrderNoAndId = shopOrderNoAndId;
+    }
+
     public String getShopOrderIDs() {
         return shopOrderIDs;
     }

+ 55 - 2
src/main/java/com/caimei/modules/order/entity/NewOrderProduct.java

@@ -31,6 +31,7 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private Double totalAmount;//     float comment '总价',
     private Double discount;//     decimal(20,6) comment '折扣',
     private Double discountPrice;//     decimal(20,6) comment '折后单价',
+    private Double oldDiscountPrice;//     decimal(20,6) comment '折后单价',
     private String includedTax;//   char(2) comment '是否含税 0不含税 1含税 2未知',
     private String invoiceType;//   char(2) comment '发票类型 1增值税专用发票 2增值税普通发票 3不开发票',
     private Double taxRate;//     decimal(20,0) comment '税率',
@@ -45,6 +46,7 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private Double singleOtherFee;//   decimal(20,6) comment '单个应付第三方金额',
     private Double singleCmFee;//   decimal(20,6) comment '单个应付采美金额',
     private Double shouldPayFee;//   decimal(20,6) comment '应付金额',
+    private Double brokerage;   // 利润
     //private String commentFlag;//        national char(1) comment '是否已评论:1是,空或0未评论',
 //    private Double price0;//   float(10,2),
 //    private Double price1;//   float comment '普通会员价',
@@ -75,7 +77,7 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private Integer orderPromotionsId; //` INT(11) NULL   COMMENT '订单促销id
     private String image; // 商品图片
     private Double discountFee; //协销订单:经理折扣(平摊到每个商品上,  按照每种商品的总价占订单总价的比例来均分);普通订单 无'
-    private String productUnit;
+    private String productUnit; // sku规格
     private String productImage;
     private String shopFee1; // 单个应付供应商金额
     private String otherFee1; // 单个应付第三方金额
@@ -87,6 +89,8 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private Integer deliveryNum; // 发货数量
     private Integer outStoreTimes;  // 发货批次
     private Double costPrice; // 成本价(快照商品成本价格)
+    private Double organizeCostPrice; // 集团成本价
+    private Double cmCostPrice; // 采美成本价
     private Integer stock; // 库存
     private Integer status; // 状态
     private String logisticsBatchID; // 发货批次ID
@@ -94,7 +98,9 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
     private List<NewCmFinanceReceipts> newCmFinanceReceiptsList; //订单商品id对应一个进账记录  订单id对应多个
     private String splitFlag;//订单商品是否可拆分   1可拆分(不可以进账确认) 0不可拆分----统计子订单中的
     private String costCheckFlag; //成本价选中标志:1固定成本 2比例成
-    private Double shopPercent;//比例成本百分比
+    private Double shopPercent;//供应商成本百分比
+    private Double organizePercent;//集团百分比
+    private Double cmPercent;//采美百分比
     private Integer heUserId; //分销者id(呵呵商城订单使用)
     private String heUserName; //分销者名称
     private List<CmProductSn> cmProductSnList; //(重光电/轻光电)SN码
@@ -335,6 +341,14 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
         this.discountPrice = discountPrice;
     }
 
+    public Double getOldDiscountPrice() {
+        return oldDiscountPrice;
+    }
+
+    public void setOldDiscountPrice(Double oldDiscountPrice) {
+        this.oldDiscountPrice = oldDiscountPrice;
+    }
+
     public Double getTaxRate() {
         return taxRate;
     }
@@ -415,6 +429,13 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
         this.shouldPayFee = shouldPayFee;
     }
 
+    public Double getBrokerage() {
+        return brokerage;
+    }
+
+    public void setBrokerage(Double brokerage) {
+        this.brokerage = brokerage;
+    }
 //    public String getCommentFlag() {
 //        return commentFlag;
 //    }
@@ -634,6 +655,22 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
         this.costPrice = costPrice;
     }
 
+    public Double getOrganizeCostPrice() {
+        return organizeCostPrice;
+    }
+
+    public void setOrganizeCostPrice(Double organizeCostPrice) {
+        this.organizeCostPrice = organizeCostPrice;
+    }
+
+    public Double getCmCostPrice() {
+        return cmCostPrice;
+    }
+
+    public void setCmCostPrice(Double cmCostPrice) {
+        this.cmCostPrice = cmCostPrice;
+    }
+
     @Transient
     public Integer getStock() {
         return stock;
@@ -767,6 +804,22 @@ public class NewOrderProduct extends DataEntity<NewOrderProduct> {
         this.shopPercent = shopPercent;
     }
 
+    public Double getOrganizePercent() {
+        return organizePercent;
+    }
+
+    public void setOrganizePercent(Double organizePercent) {
+        this.organizePercent = organizePercent;
+    }
+
+    public Double getCmPercent() {
+        return cmPercent;
+    }
+
+    public void setCmPercent(Double cmPercent) {
+        this.cmPercent = cmPercent;
+    }
+
     public List<CmProductSn> getCmProductSnList() {
         return cmProductSnList;
     }

+ 135 - 8
src/main/java/com/caimei/modules/order/entity/NewShopOrder.java

@@ -15,7 +15,7 @@ import java.util.List;
  */
 public class NewShopOrder extends DataEntity<NewShopOrder> {
     private Integer onlineFlag;    //是否线上支付过1是,0否
-    private Double couponAmount;   //订单使用优惠券金额
+    private Double couponAmount;   //订单使用优惠券金额
     private Integer shopOrderID;//        int(11) not null auto_increment comment '子订单ID',
     private Integer organizeID;//        组织Id
     private String shopOrderNo;//       varchar(30) comment '子订单编号',
@@ -50,6 +50,7 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
     private Double eachDiscount;        // 分摊优惠金额
     private Double receiptAmount;       // 已付金额
     private Double restAmount;      // 待付金额
+    private Double payShopAmount;   // 已付金额 -- 付供应商
     private Integer shopReceiptStatus;      // 子订单收款状态:1待收款,2部分收款,3已收款
     private String splitCode;   // 分账号
     private Double canRefundAmount;//   float comment '退款金额',
@@ -67,12 +68,17 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
     private Double freePostageFee;//    decimal(10,2) comment '订单包邮时本该支付的运费',
     private String associationType;//订单关联方式: 1手动 2自动
     private String confirmType;    // 收款确认类型(1 小额抹平确认,2 大额抹平确认,3 大额退款余额,4 确认关联)
+    private String confirmTime;    // 订单确认时间
     private boolean receiptOrderFlag;// 判断订单中抹平的订单是否是和多个订单一起支付的,
     private Double orderReceivedAmount;//订单已收金额(此收款只计算线上线下收款记录payableAmount表金额)
     private Double returnBalanceAmount;// 退款余额金额
+    private Double allServeAmount;   // 总平台服务费
 
 
 
+    private String rebateOrder;  //是不是返佣订单 是的1,  不是的0
+    private Integer splitCount; //分账记录数
+    private Integer settleRecordNum;   //佣金结算数量
     private Integer isColdChina;//    是否包含冷链费 0不包含 1包含
     private Integer freePostageTicketID;//  int(11) comment '使用的包邮券Id,为空表示未使用包邮券',
     private Double brokerage;//        decimal(11,2) comment '佣金',
@@ -83,8 +89,8 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
     private NewOrder order;
     private List<NewOrderProduct> newOrderProducts;
     private Double preferential; //订单商品的总优惠
-    private int orderSubmitType;
-    private int orderType;             // 订单类型
+    private Integer orderSubmitType;
+    private Integer orderType;             // 订单类型
     private String orderTime;//下单时间
     private Integer presentNum;//赠品数量
     private Integer outStoreNum;//已经发货的商品数量
@@ -105,6 +111,7 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
     private Integer userBeans; //订单采美豆数量
     private Double svipShopReduction;   //超级会员优惠
     private Integer settleStatus;    //结算状态   1未结算2部分结算3已结算
+    private Double settleAmount;    // 结算金额
     private Integer payWay; //线上支付状态 1线上 2线下 3余额抵扣
     //-------------        虚拟字段   ----------------------------
     private Double income;       //主订单总佣金
@@ -149,9 +156,24 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
     private String clubName; //会所名称
     private Integer orderArchiveId; //订单资料id
     private String rebateFee; //主订单返佣服务费
-    private String shopPostFlag; //免邮标志 运费:-1到付,0包邮,1需要运费,-2仪器到付其它包邮
+    private String shopPostFlag; //免邮标志 运费:2到付,0包邮,1需要运费,-2仪器到付其它包邮
     private String postageInfo; //运费字符串
 
+    /**  */
+    private Integer returnGoodsStatus;
+
+    /** 二手商品订单标识  0非二手商品订单、 1二手商品订单 */
+    private String secondHandOrderFlag;
+    /** 外部商城付采美佣金 */
+    private BigDecimal payCmAmount;
+    /**  */
+    private String receiptedFlag;
+
+    /**  */
+    private String receiptedType;
+    /** 子订单已支付成功次数统计 */
+    private Integer paySuccessCounter;
+
 
 
     private List<CmOrderPaymentVoucherVo> voucherVo; //支付凭证
@@ -168,6 +190,55 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
     private String remarkImage9;
     private String remarkImage10;
 
+    public Integer getReturnGoodsStatus() {
+        return returnGoodsStatus;
+    }
+
+    public void setReturnGoodsStatus(Integer returnGoodsStatus) {
+        this.returnGoodsStatus = returnGoodsStatus;
+    }
+
+    public String getSecondHandOrderFlag() {
+        return secondHandOrderFlag;
+    }
+
+    public void setSecondHandOrderFlag(String secondHandOrderFlag) {
+        this.secondHandOrderFlag = secondHandOrderFlag;
+    }
+
+    public BigDecimal getPayCmAmount() {
+        return payCmAmount;
+    }
+
+    public void setPayCmAmount(BigDecimal payCmAmount) {
+        this.payCmAmount = payCmAmount;
+    }
+
+    public String getReceiptedFlag() {
+        return receiptedFlag;
+    }
+
+    public void setReceiptedFlag(String receiptedFlag) {
+        this.receiptedFlag = receiptedFlag;
+    }
+
+    public String getReceiptedType() {
+        return receiptedType;
+    }
+
+    public void setReceiptedType(String receiptedType) {
+        this.receiptedType = receiptedType;
+    }
+
+    public Integer getPaySuccessCounter() {
+        return paySuccessCounter;
+    }
+
+    public void setPaySuccessCounter(Integer paySuccessCounter) {
+        this.paySuccessCounter = paySuccessCounter;
+    }
+
+
     public String getShopPostFlag() {
         return shopPostFlag;
     }
@@ -218,6 +289,13 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
         this.settleStatus = settleStatus;
     }
 
+    public Double getSettleAmount() {
+        return settleAmount;
+    }
+
+    public void setSettleAmount(Double settleAmount) {
+        this.settleAmount = settleAmount;
+    }
 
     public Integer getPayWay() {
         return payWay;
@@ -274,6 +352,31 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
     public void setPromotionFullReduction(Double promotionFullReduction) {
         this.promotionFullReduction = promotionFullReduction;
     }
+
+    public String getRebateOrder() {
+        return rebateOrder;
+    }
+
+    public void setRebateOrder(String rebateOrder) {
+        this.rebateOrder = rebateOrder;
+    }
+
+    public Integer getSplitCount() {
+        return splitCount;
+    }
+
+    public void setSplitCount(Integer splitCount) {
+        this.splitCount = splitCount;
+    }
+
+    public Integer getSettleRecordNum() {
+        return settleRecordNum;
+    }
+
+    public void setSettleRecordNum(Integer settleRecordNum) {
+        this.settleRecordNum = settleRecordNum;
+    }
+
     public Integer getIsColdChina() {
         return isColdChina;
     }
@@ -577,6 +680,14 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
         this.confirmType = confirmType;
     }
 
+    public String getConfirmTime() {
+        return confirmTime;
+    }
+
+    public void setConfirmTime(String confirmTime) {
+        this.confirmTime = confirmTime;
+    }
+
     public boolean isReceiptOrderFlag() {
         return receiptOrderFlag;
     }
@@ -601,6 +712,14 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
         this.returnBalanceAmount = returnBalanceAmount;
     }
 
+    public Double getAllServeAmount() {
+        return allServeAmount;
+    }
+
+    public void setAllServeAmount(Double allServeAmount) {
+        this.allServeAmount = allServeAmount;
+    }
+
     public Integer getFreePostageTicketID() {
         return freePostageTicketID;
     }
@@ -675,11 +794,11 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
         this.orderID = orderID;
     }
 
-    public int getOrderType() {
+    public Integer getOrderType() {
         return orderType;
     }
 
-    public void setOrderType(int orderType) {
+    public void setOrderType(Integer orderType) {
         this.orderType = orderType;
     }
 
@@ -788,11 +907,11 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
         this.preferential = preferential;
     }
 
-    public int getOrderSubmitType() {
+    public Integer getOrderSubmitType() {
         return orderSubmitType;
     }
 
-    public void setOrderSubmitType(int orderSubmitType) {
+    public void setOrderSubmitType(Integer orderSubmitType) {
         this.orderSubmitType = orderSubmitType;
     }
 
@@ -1333,6 +1452,14 @@ public class NewShopOrder extends DataEntity<NewShopOrder> {
         this.restAmount = restAmount;
     }
 
+    public Double getPayShopAmount() {
+        return payShopAmount;
+    }
+
+    public void setPayShopAmount(Double payShopAmount) {
+        this.payShopAmount = payShopAmount;
+    }
+
     public Integer getShopReceiptStatus() {
         return shopReceiptStatus;
     }

+ 11 - 1
src/main/java/com/caimei/modules/order/entity/OrderProductVo.java

@@ -15,6 +15,8 @@ import java.math.BigDecimal;
 @Data
 public class OrderProductVo implements Serializable {
     private static final long serialVersionUID = 1L;
+
+    private Integer organizeId;
     /**
      * 商品分账商户号
      */
@@ -52,7 +54,15 @@ public class OrderProductVo implements Serializable {
      */
     private Integer costCheckFlag;
     /**
-     * 成本价
+     * 集团/组织固定成本
+     */
+    private Double organizeCostPrice;
+    /**
+     * 平台服务费,采美固定成本
+     */
+    private Double cmCostPrice;
+    /**
+     * 供应商成本价,商品成本
      */
     private Double costPrice;
     /**

+ 6 - 363
src/main/java/com/caimei/modules/order/entity/ShopOrderVo.java

@@ -1,6 +1,8 @@
 package com.caimei.modules.order.entity;
 
 
+import lombok.Data;
+
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.List;
@@ -11,8 +13,12 @@ import java.util.List;
  * @author : Charles
  * @date : 2021/7/20
  */
+@Data
 public class ShopOrderVo implements Serializable {
     private static final long serialVersionUID = 1L;
+
+    private Double couponAmount;
+    private Integer organizeId;
     /**
      * 子订单ID
      */
@@ -194,367 +200,4 @@ public class ShopOrderVo implements Serializable {
      */
     private String splitCode;
 
-    public String getSplitCode() {
-        return splitCode;
-    }
-
-    public void setSplitCode(String splitCode) {
-        this.splitCode = splitCode;
-    }
-
-    public static long getSerialVersionUID() {
-        return serialVersionUID;
-    }
-
-    public Integer getShopOrderId() {
-        return shopOrderId;
-    }
-
-    public void setShopOrderId(Integer shopOrderId) {
-        this.shopOrderId = shopOrderId;
-    }
-
-    public String getShopOrderNo() {
-        return shopOrderNo;
-    }
-
-    public void setShopOrderNo(String shopOrderNo) {
-        this.shopOrderNo = shopOrderNo;
-    }
-
-    public Integer getOrderId() {
-        return orderId;
-    }
-
-    public void setOrderId(Integer orderId) {
-        this.orderId = orderId;
-    }
-
-    public String getOrderNo() {
-        return orderNo;
-    }
-
-    public void setOrderNo(String orderNo) {
-        this.orderNo = orderNo;
-    }
-
-    public Integer getShopId() {
-        return shopId;
-    }
-
-    public void setShopId(Integer shopId) {
-        this.shopId = shopId;
-    }
-
-    public String getShopName() {
-        return shopName;
-    }
-
-    public void setShopName(String shopName) {
-        this.shopName = shopName;
-    }
-
-    public String getShopLogo() {
-        return shopLogo;
-    }
-
-    public void setShopLogo(String shopLogo) {
-        this.shopLogo = shopLogo;
-    }
-
-    public String getNote() {
-        return note;
-    }
-
-    public void setNote(String note) {
-        this.note = note;
-    }
-
-    public Integer getUserId() {
-        return userId;
-    }
-
-    public void setUserId(Integer userId) {
-        this.userId = userId;
-    }
-
-    public Integer getClubId() {
-        return clubId;
-    }
-
-    public void setClubId(Integer clubId) {
-        this.clubId = clubId;
-    }
-
-    public Integer getSpId() {
-        return spId;
-    }
-
-    public void setSpId(Integer spId) {
-        this.spId = spId;
-    }
-
-    public Integer getOrderPromotionsId() {
-        return orderPromotionsId;
-    }
-
-    public void setOrderPromotionsId(Integer orderPromotionsId) {
-        this.orderPromotionsId = orderPromotionsId;
-    }
-
-    public Double getPromotionFullReduction() {
-        return promotionFullReduction;
-    }
-
-    public void setPromotionFullReduction(Double promotionFullReduction) {
-        this.promotionFullReduction = promotionFullReduction;
-    }
-
-    public Double getSvipShopReduction() {
-        return svipShopReduction;
-    }
-
-    public void setSvipShopReduction(Double svipShopReduction) {
-        this.svipShopReduction = svipShopReduction;
-    }
-
-    public Integer getPayStatus() {
-        return payStatus;
-    }
-
-    public void setPayStatus(Integer payStatus) {
-        this.payStatus = payStatus;
-    }
-
-    public Double getPayedShopAmount() {
-        return payedShopAmount;
-    }
-
-    public void setPayedShopAmount(Double payedShopAmount) {
-        this.payedShopAmount = payedShopAmount;
-    }
-
-    public Double getBrokerage() {
-        return brokerage;
-    }
-
-    public void setBrokerage(Double brokerage) {
-        this.brokerage = brokerage;
-    }
-
-    public Double getCanRefundAmount() {
-        return canRefundAmount;
-    }
-
-    public void setCanRefundAmount(Double canRefundAmount) {
-        this.canRefundAmount = canRefundAmount;
-    }
-
-    public Integer getItemCount() {
-        return itemCount;
-    }
-
-    public void setItemCount(Integer itemCount) {
-        this.itemCount = itemCount;
-    }
-
-    public Double getTotalAmount() {
-        return totalAmount;
-    }
-
-    public void setTotalAmount(Double totalAmount) {
-        this.totalAmount = totalAmount;
-    }
-
-    public Double getProductAmount() {
-        return productAmount;
-    }
-
-    public void setProductAmount(Double productAmount) {
-        this.productAmount = productAmount;
-    }
-
-    public Double getNeedPayAmount() {
-        return needPayAmount;
-    }
-
-    public void setNeedPayAmount(Double needPayAmount) {
-        this.needPayAmount = needPayAmount;
-    }
-
-    public Double getShopProductAmount() {
-        return shopProductAmount;
-    }
-
-    public void setShopProductAmount(Double shopProductAmount) {
-        this.shopProductAmount = shopProductAmount;
-    }
-
-    public Double getShopPostFee() {
-        return shopPostFee;
-    }
-
-    public void setShopPostFee(Double shopPostFee) {
-        this.shopPostFee = shopPostFee;
-    }
-
-    public Double getShopTaxFee() {
-        return shopTaxFee;
-    }
-
-    public void setShopTaxFee(Double shopTaxFee) {
-        this.shopTaxFee = shopTaxFee;
-    }
-
-    public Double getShouldPayShopAmount() {
-        return shouldPayShopAmount;
-    }
-
-    public void setShouldPayShopAmount(Double shouldPayShopAmount) {
-        this.shouldPayShopAmount = shouldPayShopAmount;
-    }
-
-    public Integer getOutStoreNum() {
-        return outStoreNum;
-    }
-
-    public void setOutStoreNum(Integer outStoreNum) {
-        this.outStoreNum = outStoreNum;
-    }
-
-    public Integer getOutStoreTimes() {
-        return outStoreTimes;
-    }
-
-    public void setOutStoreTimes(Integer outStoreTimes) {
-        this.outStoreTimes = outStoreTimes;
-    }
-
-    public Integer getSendOutStatus() {
-        return sendOutStatus;
-    }
-
-    public void setSendOutStatus(Integer sendOutStatus) {
-        this.sendOutStatus = sendOutStatus;
-    }
-
-    public Integer getPresentNum() {
-        return presentNum;
-    }
-
-    public void setPresentNum(Integer presentNum) {
-        this.presentNum = presentNum;
-    }
-
-    public String getOrderTime() {
-        return orderTime;
-    }
-
-    public void setOrderTime(String orderTime) {
-        this.orderTime = orderTime;
-    }
-
-    public Integer getOrderSubmitType() {
-        return orderSubmitType;
-    }
-
-    public void setOrderSubmitType(Integer orderSubmitType) {
-        this.orderSubmitType = orderSubmitType;
-    }
-
-    public Integer getSplitFlag() {
-        return splitFlag;
-    }
-
-    public void setSplitFlag(Integer splitFlag) {
-        this.splitFlag = splitFlag;
-    }
-
-    public Double getShopOtherFee() {
-        return shopOtherFee;
-    }
-
-    public void setShopOtherFee(Double shopOtherFee) {
-        this.shopOtherFee = shopOtherFee;
-    }
-
-    public PromotionsVo getShopPromotion() {
-        return shopPromotion;
-    }
-
-    public void setShopPromotion(PromotionsVo shopPromotion) {
-        this.shopPromotion = shopPromotion;
-    }
-
-    public List<OrderProductVo> getOrderProductList() {
-        return orderProductList;
-    }
-
-    public void setOrderProductList(List<OrderProductVo> orderProductList) {
-        this.orderProductList = orderProductList;
-    }
-
-    public List<LogisticsRecordVo> getLogisticsRecordList() {
-        return logisticsRecordList;
-    }
-
-    public void setLogisticsRecordList(List<LogisticsRecordVo> logisticsRecordList) {
-        this.logisticsRecordList = logisticsRecordList;
-    }
-
-    public OrderUserinfoVo getUserInfo() {
-        return userInfo;
-    }
-
-    public void setUserInfo(OrderUserinfoVo userInfo) {
-        this.userInfo = userInfo;
-    }
-
-    public Integer getReceiptStatus() {
-        return receiptStatus;
-    }
-
-    public void setReceiptStatus(Integer receiptStatus) {
-        this.receiptStatus = receiptStatus;
-    }
-
-    public BigDecimal getShopRefundAmount() {
-        return shopRefundAmount;
-    }
-
-    public void setShopRefundAmount(BigDecimal shopRefundAmount) {
-        this.shopRefundAmount = shopRefundAmount;
-    }
-
-    public String getHaveReturning() {
-        return haveReturning;
-    }
-
-    public void setHaveReturning(String haveReturning) {
-        this.haveReturning = haveReturning;
-    }
-
-    public Integer getReceiptedFlag() {
-        return receiptedFlag;
-    }
-
-    public void setReceiptedFlag(Integer receiptedFlag) {
-        this.receiptedFlag = receiptedFlag;
-    }
-
-    public Integer getReceiptedType() {
-        return receiptedType;
-    }
-
-    public void setReceiptedType(Integer receiptedType) {
-        this.receiptedType = receiptedType;
-    }
-
-    public OrderVo getMainOrder() {
-        return mainOrder;
-    }
-
-    public void setMainOrder(OrderVo mainOrder) {
-        this.mainOrder = mainOrder;
-    }
 }

+ 1 - 1
src/main/java/com/caimei/modules/order/entity/SplitAccountPo.java

@@ -71,7 +71,7 @@ public class SplitAccountPo implements Serializable {
      */
     private Integer payStatus;
     /**
-     * 商品类型:1商品成本,2供应商运费,3佣金,4二手发布
+     * 商品类型:1商品成本,2供应商运费,3佣金,4二手发布,5组织佣金
      */
     private Integer productType;
     /**

+ 175 - 51
src/main/java/com/caimei/modules/order/service/CmPayShopService.java

@@ -15,10 +15,8 @@ import com.caimei.modules.product.entity.Product;
 import com.caimei.modules.sys.utils.UploadImageUtils;
 import com.caimei.modules.user.dao.NewCmShopDao;
 import com.caimei.modules.user.entity.NewCmShop;
-import com.caimei.redis.RedisService;
 import com.caimei.utils.MathUtil;
 import com.caimei.utils.StringUtil;
-import com.opensymphony.module.sitemesh.html.CustomTag;
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.service.CrudService;
@@ -32,8 +30,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.beans.IntrospectionException;
-import java.lang.reflect.InvocationTargetException;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -75,8 +71,6 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
     private HeHeNewOrderDao heHeNewOrderDao;
     @Resource
     private CmRefundShopDao cmRefundShopDao;
-    @Resource
-    private RedisService redisService;
 
 
     public List<CmPayShop> exports(Page<CmPayShop> cmPayShopPage, CmPayShop cmPayShop) {
@@ -195,6 +189,44 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
         return page1.setList(list);
     }
 
+    public Page<CmPayShop> payThirdPage(Page<CmPayShop> page, CmPayShop cmPayShop) {
+        cmPayShop.setPage(page);
+        List<CmPayShop> payList = cmPayShopDao.payThirdParties(cmPayShop);
+
+        for (CmPayShop payShop : payList) {
+            List<NewShopOrder> newShopOrders = cmPayShopDao.orderList(payShop.getId());
+            payShop.setShopOrders(newShopOrders);
+            if (payShop.getStatus().equals("2")) {
+                List<Integer> ids = new ArrayList<>();
+                for (NewShopOrder newShopOrder : newShopOrders) {
+                    ids.add(newShopOrder.getShopOrderID());
+                }
+                List<Integer> id = cmPayShopDao.hasReapply(payShop.getId(), ids);
+                if (id.isEmpty()) {
+                    //可以重申
+                    payShop.setRePayment("1");
+                } else {
+                    //不能重申
+                    payShop.setRePayment("2");
+                }
+            }
+            newShopOrders.forEach(shopOrder -> {
+                if (null != shopOrder) {
+                    NewOrder order = newOrderDao.findByOrderID(shopOrder.getOrderID());
+                    if (null != order && "2".equals(order.getOrderType())) {
+                        //呵呵商城订单
+                        shopOrder.setOrderType(2);
+                        if (StringUtils.isBlank(shopOrder.getClubName())) {
+                            String name = heHeNewOrderDao.findHeUser(order.getUserID());
+                            shopOrder.setClubName(name);
+                        }
+                    }
+                }
+            });
+        }
+        return page.setList(payList);
+    }
+
     @Transactional(readOnly = false)
     public void save(CmPayShop cmPayShop) {
         super.save(cmPayShop);
@@ -231,6 +263,10 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 } else if (so.getDifferenceType() != null && so.getDifferenceType() == 2) {
                     totalAmount = MathUtil.sub(totalAmount, so.getDifferencePrice()).doubleValue();
                 }
+                // 子订单已收金额
+                Double receiptAmount = cmReceiptOrderRelationDao.findReceiptByShopOrderId(so.getShopOrderID().toString());
+                so.setReceiptAmount(receiptAmount);
+                totalAmount -= so.getShopOtherFee();
                 List<NewOrderProduct> orderProductList = newOrderProductDao.findByShopOrderID(so.getShopOrderID());
                 /*
                  1. 若发生退货,数量要减去已退货和已取消的数量
@@ -238,11 +274,52 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                  */
 
                 Integer returnNum = 0;
+                Double returnNumAmount = 0d;
+                // 平台服务费
+                Double allServeAmount = 0d;
+                Double brokerage = 0d;
                 for (NewOrderProduct p : orderProductList) {
                     returnNum = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
                     returnNum = returnNum == null ? 0 : returnNum;
                     p.setReturnedNum(returnNum);
+                    // 还原下单时商品成本
+                    /*Double newCostPrice = 0d;
+                    newCostPrice = p.getCostPrice();
+                    p.setCostPrice(MathUtil.div(p.getCostPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100),100)).doubleValue());
+                    p.setNewCostPrice(newCostPrice);*/
+
+                    p.setOldDiscountPrice(p.getDiscountPrice());
+                    /*if ("0".equals(p.getIncludedTax()) && null != p.getTaxRate() && p.getTaxRate() > 0d) {
+                        p.setDiscountPrice(MathUtil.div(p.getDiscountPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100), 100)).doubleValue());
+                    }*/
+                    // 付采美总金额
+                    allServeAmount = MathUtil.add(allServeAmount, MathUtil.mul(p.getNum(), p.getCmCostPrice())).doubleValue();
+                    // 子订单利润
+                    if (p.getReturnedNum().equals(p.getNum())) {
+                        if (p.getProductType() == 0) {
+                            brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(), p.getNum())).doubleValue();
+                        } else {
+                            brokerage = MathUtil.add(brokerage, 0).doubleValue();
+                        }
+                    } else if (p.getReturnedNum() < p.getNum()) {
+                        if (p.getProductType() == 0) {
+                            brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(), MathUtil.sub(p.getNum(), p.getReturnedNum()))).doubleValue();
+                        } else {
+                            brokerage = MathUtil.add(brokerage, 0).doubleValue();
+                        }
+                    } else {
+                        if (p.getProductType() == 0) {
+                            brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(), p.getNum())).doubleValue();
+                        } else {
+                            brokerage = MathUtil.add(brokerage, 0).doubleValue();
+                        }
+                    }
+                    allServeAmount = MathUtil.sub(allServeAmount, MathUtil.mul(returnNum, p.getCmCostPrice())).doubleValue();
+                    // 应退的成本
+                    returnNumAmount = MathUtil.mul(returnNum, p.getCostPrice()).doubleValue();
                 }
+                so.setBrokerage(brokerage);
+                so.setAllServeAmount(allServeAmount);
                 so.setNewOrderProducts(orderProductList);
                 so.setWaitPayShop((so.getShouldPayShopAmount() == null ? 0D : so.getShouldPayShopAmount()) - (so.getPayedShopAmount() == null ? 0D : so.getPayedShopAmount()));
                 if (so.getDifferenceType() != null && so.getDifferenceType() == 1) {
@@ -252,6 +329,9 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                     BigDecimal waitPayShop = MathUtil.sub(so.getWaitPayShop(), so.getDifferencePrice());
                     so.setWaitPayShop(waitPayShop.doubleValue());
                 }
+                so.setWaitPayShop(MathUtil.sub(so.getWaitPayShop(), returnNumAmount).doubleValue());
+                so.setShopProductAmount(MathUtil.sub(so.getShopProductAmount(), returnNumAmount).doubleValue());
+                so.setShouldPayShopAmount(MathUtil.sub(so.getShouldPayShopAmount(), returnNumAmount).doubleValue());
 
                 //统计该子订单的主的收款金额和收款状态
                 NewOrder newOrder = newOrderDao.get(so.getOrderID().toString());
@@ -288,12 +368,12 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 List<Product> product = cmPayShopDao.priceNum(so.getOrderNo());
                 // 计算订单总佣金
                 Double income = newShopOrderDao.findIncome(so.getOrderID());
-                if(returnNum != null) {
-                    if(product != null) {
+                if (returnNum != null) {
+                    if (product != null) {
                         for (Product pro : product) {
                             Integer number = newOrderProductDao.CountReturnedPurchaseProduct(pro.getShopOrderID(), pro.getOrderProductID());
                             Double commission = 0.0;
-                            if(number != null && number != 0) {
+                            if (number != null && number != 0) {
                                 if (pro.getTaxRate() != null && pro.getTaxRate() != 0) {
                                     commission = (pro.getPrice() + pro.getPrice() * (pro.getTaxRate() / 100)) - (Double.parseDouble(pro.getCostPrice()) + Double.parseDouble(pro.getCostPrice()) * (pro.getTaxRate() / 100));
                                 } else {
@@ -310,22 +390,19 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 }
                 //若成本下降太多导致部分收款的钱,已经大于成本重新计算佣金
                 if ("0".equals(newOrder.getOnlinePayFlag()) && so.getShopReceiptStatus() == 2) {
-                    double mum = so.getProductAmount();
+                    // double mum = so.getProductAmount();
                     System.out.println(so.getReceiptTotalFee());
                     System.out.println(so.getShouldPayShopAmount());
                     BigDecimal getShouldPayShopAmount = MathUtil.sub(so.getShouldPayShopAmount(), so.getDifferencePrice());
-                    if (so.getReceiptTotalFee() > Double.valueOf(getShouldPayShopAmount.toString())) {
+                    /*if (so.getReceiptTotalFee() > Double.valueOf(getShouldPayShopAmount.toString())) {
                         //子订单佣金
-
                         mum -= so.getShopOtherFee() + Double.valueOf(getShouldPayShopAmount.toString());
                         // 子订单佣金减供应商运费
-                        mum -= so.getShopPostFee();
+                        mum -= null == so.getShopPostFee()?0:so.getShopPostFee();
                         so.setBrokerage(mum);
                     } else {
                         so.setBrokerage(null);
-                    }
-                } else {
-                    so.setBrokerage(null);
+                    }*/
                 }
                 //要是不大于成本默认显示
 
@@ -373,14 +450,37 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 } else {
                     so.setWaitPayShop(cmPayShopRecord.getPayAmount());
                 }
+                // 子订单已收金额
+                Double receiptAmount = cmReceiptOrderRelationDao.findReceiptByShopOrderId(so.getShopOrderID().toString());
+                so.setReceiptAmount(receiptAmount);
                 List<NewOrderProduct> orderProductList = newOrderProductDao.findByShopOrderID(so.getShopOrderID());
                 /* 退货数量 */
                 Integer count = 0;
+                Double allServeAmount = 0d;
+                Double brokerage = 0d;
                 for (NewOrderProduct p : orderProductList) {
                     count = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
                     count = count == null ? 0 : count;
                     p.setReturnedNum(count);
+                    // 还原下单时商品成本
+                    /*Double newCostPrice = 0d;
+                    newCostPrice = p.getCostPrice();
+                    p.setCostPrice(MathUtil.div(p.getCostPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100),100)).doubleValue());
+                    p.setNewCostPrice(newCostPrice);*/
+                    p.setOldDiscountPrice(p.getDiscountPrice());
+                    /*if ("0".equals(p.getIncludedTax()) && null != p.getTaxRate() && p.getTaxRate() > 0d) {
+                        p.setDiscountPrice(MathUtil.div(p.getDiscountPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100), 100)).doubleValue());
+                    }*/
+                    // 付采美总金额
+                    allServeAmount = MathUtil.add(allServeAmount, MathUtil.mul(p.getNum(), p.getCmCostPrice())).doubleValue();
+                    if (p.getProductType() == 0) {
+                        brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(), p.getNum())).doubleValue();
+                    } else {
+                        brokerage = MathUtil.add(brokerage, 0).doubleValue();
+                    }
                 }
+                so.setBrokerage(brokerage);
+                so.setAllServeAmount(allServeAmount);
                 if (so.getShopPostFee() == null) so.setShopPostFee(0D);
                 if (so.getShopTaxFee() == null) so.setShopTaxFee(0D);
                 if (so.getShopOtherFee() == null) so.setShopOtherFee(0D);
@@ -426,11 +526,11 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 List<Product> product = cmPayShopDao.priceNum(so.getOrderNo());
                 // 计算佣金
                 Double income = newShopOrderDao.findIncome(so.getOrderID());
-                if(count != 0) {
-                    for(Product pro: product) {
+                if (count != 0) {
+                    for (Product pro : product) {
                         Double commission = pro.getPrice() - Double.parseDouble(pro.getCostPrice());
                         Integer number = newOrderProductDao.CountReturnedPurchaseProduct(pro.getShopOrderID(), pro.getOrderProductID());
-                        if(number != null && number != 0) {
+                        if (number != null && number != 0) {
                             if (pro.getTaxRate() != null && pro.getTaxRate() != 0) {
                                 commission = (pro.getPrice() + pro.getPrice() * (pro.getTaxRate() / 100)) - (Double.parseDouble(pro.getCostPrice()) + Double.parseDouble(pro.getCostPrice()) * (pro.getTaxRate() / 100));
                             } else {
@@ -496,10 +596,10 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
             //保存每个子订单的付款金额记录  等待审核付款
             NewCmShop shop = newCmShopDao.get(cmPayShop.getShopID());
             shop.setAbleRebateAmount(shop.getAbleRebateAmount() == null ? 0D : shop.getAbleRebateAmount() - cmPayShop.getBalancePayFee());
-            shop.setBankAccount(cmPayShop.getBankAccount());
-            shop.setBankAccountName(cmPayShop.getBankAccountName());
-            shop.setBankName(cmPayShop.getBankName());
-            newCmShopDao.update(shop);
+//            shop.setBankAccount(cmPayShop.getBankAccount());
+//            shop.setBankAccountName(cmPayShop.getBankAccountName());
+//            shop.setBankName(cmPayShop.getBankName());
+//            newCmShopDao.update(shop);
             Integer orderID = null;//记录一下子订单的id 下面需要用它去查询运费子订单
             for (String p : payInfo) {
                 CmPayShopRecord record = new CmPayShopRecord();
@@ -661,10 +761,10 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                 NewShopOrder shopOrder = newShopOrderDao.get(record.getShopOrderID());
                 Double wipePayment = cmPayShopRecordDao.sumWipePaymentNoStatus(Integer.valueOf(record.getShopOrderID()));
                 wipePayment = wipePayment != null ? wipePayment : 0d;
-                // 本次付款金额 + 抹平金额 + 原来已经付过的金额
-                BigDecimal payedFee = MathUtil.add(MathUtil.add(record.getPayAmount(), wipePayment), shopOrder.getPayedShopAmount());
+                // 本次付款金额 + 抹平金额 + 原来已经付过的金额 - 付第三方
+                BigDecimal payedFee = MathUtil.add(MathUtil.sub(MathUtil.add(record.getPayAmount(), wipePayment), shopOrder.getShopOtherFee()), shopOrder.getPayedShopAmount());
                 // 总共要付的金额
-                BigDecimal shouldPayFee = BigDecimal.valueOf(shopOrder.getShouldPayShopAmount());
+                BigDecimal shouldPayFee = MathUtil.sub(shopOrder.getShouldPayShopAmount(), shopOrder.getShopOtherFee());
                 //判断是否有差价金额
                 if (shopOrder.getDifferenceType() != null && shopOrder.getDifferenceType() == 1) {
                     shouldPayFee = MathUtil.add(shouldPayFee, shopOrder.getDifferencePrice());
@@ -684,7 +784,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                     logger.info("check ----> 付款金额异常, 付款金额大于待付款金额");
                     throw new Exception("付款金额异常, 付款金额大于待付款金额");
                 }
-                shopOrder.setPayedShopAmount(shopOrder.getPayedShopAmount() == null ? 0D : shopOrder.getPayedShopAmount() + record.getPayAmount());
+                shopOrder.setPayedShopAmount(shopOrder.getPayedShopAmount() == null ? 0D : MathUtil.add(shopOrder.getPayedShopAmount(), MathUtil.sub(record.getPayAmount(), shopOrder.getShopOtherFee())).doubleValue());
                 shopOrder.setPaying("0"); //退出付款进行状态
                 newShopOrderDao.update(shopOrder);
                 record.setStatus("1");
@@ -809,7 +909,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
             //修改每一条子订单的已付款金额
             for (CmPayShopRecord record : records) {
                 NewShopOrder shopOrder = newShopOrderDao.get(record.getShopOrderID());
-                shopOrder.setPayedShopAmount(shopOrder.getPayedShopAmount() - record.getPayAmount());
+                shopOrder.setPayedShopAmount(shopOrder.getPayedShopAmount() - record.getPayAmount() + shopOrder.getShopOtherFee());
                 if (shopOrder.getPayedShopAmount() == 0D) {
                     // 本次付款金额 + 原来已经付过的金额  < 总共要付的金额
                     shopOrder.setPayStatus("1");
@@ -946,6 +1046,10 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
 
     @Transactional(readOnly = false)
     public void saveShopOtherFee(ChangePayShopOther payShopOther) {
+        /**
+         * payType = 2为线上付第三方,创建付款单,无付款银行,开户行,帐号
+         * 生成的记录,审核人/审核时间/审核状态,分别置为:系统自动/同申请时间/审核通过
+         */
         String[] remarkImages = payShopOther.getRemarkImages();
         if (remarkImages != null && remarkImages.length > 0) {
             StringBuilder remarkImage = new StringBuilder();
@@ -967,17 +1071,28 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
         CmPayShop payShop = new CmPayShop();
         payShop.setShopID(shopOrder.getShopID().toString());
         payShop.setName(payShopOther.getName());
-        payShop.setBankAccountName(payShopOther.getBankAccountName());
-        payShop.setBankAccount(payShopOther.getBankAccount());
-        payShop.setBankName(payShopOther.getBankName());
-        payShop.setType(payShopOther.getType().toString());
+        String status = "0";
+        if (null != payShopOther.getPayType() && 2 == payShopOther.getPayType()) {
+            String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
+            payShop.setApplyTime(format);
+            payShop.setReviewTime(format);
+            status = "1";
+            //已付第三方金额
+            BigDecimal shopOtherFee = cmPayShopRecordDao.findPayShopOtherFee(payShopOther.getShopOrderId());
+            newShopOrderDao.updateByShopOtherFee(MathUtil.add(shopOtherFee, payShopOther.getShopOtherFee()), payShopOther.getShopOrderId());
+        } else {
+            payShop.setBankAccountName(payShopOther.getBankAccountName());
+            payShop.setBankAccount(payShopOther.getBankAccount());
+            payShop.setBankName(payShopOther.getBankName());
+            payShop.setType(payShopOther.getType().toString());
+        }
         payShop.setTotalAmount(payShopOther.getShopOtherFee().doubleValue());
         payShop.setBalancePayFee(0d);
         payShop.setTransferPayFee(payShopOther.getShopOtherFee().doubleValue());
         payShop.setWipePayment(0d);
         payShop.setApplicant(currentUser.getId());
         payShop.setApplyTime(time);
-        payShop.setStatus("0");
+        payShop.setStatus(status);
         payShop.setDelFlag("0");
         if (payShopOther.getPayShopId() == null) {
             cmPayShopDao.insert(payShop);
@@ -994,7 +1109,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
         payShopRecord.setWipePayment(0d);
         payShopRecord.setPaymentType(3);
         payShopRecord.setPayShopID(payShop.getId());
-        payShopRecord.setStatus("0");
+        payShopRecord.setStatus(status);
         payShopRecord.setDelFlag("0");
         if (payShopOther.getPayShopId() == null) {
             cmPayShopRecordDao.insert(payShopRecord);
@@ -1012,7 +1127,8 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
         BigDecimal waitPayShop = BigDecimal.ZERO;
         if (shopOrder != null) {
             payShopDifference.setPayStatus(shopOrder.getPayStatus());
-            waitPayShop = MathUtil.sub(shopOrder.getShouldPayShopAmount(), shopOrder.getDifferencePrice());
+            Double paShopAmount = newShopOrderDao.findByPayShopID(shopOrderId);
+            waitPayShop = MathUtil.sub(MathUtil.sub(shopOrder.getShouldPayShopAmount(), shopOrder.getDifferencePrice()), paShopAmount);
             NewCmShop shop = newCmShopDao.get(shopOrder.getShopID().toString());
             payShopDifference.setBankAccount(shop.getBankAccount());
             payShopDifference.setBankAccountName(shop.getBankAccountName());
@@ -1110,7 +1226,7 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
 //       List<Integer> payWay= newShopOrderDao.payWay(shopOrderId);
 //       if(payWay==1 && shopOrder.getShopReceiptStatus()==2) {
         if (payShopDifference.getType() == 2 && MathUtil.compare(differencePrice, waitPayShop) > 0) {
-            //多付且差价大于待付金额,会发生供应商退款操作
+            //成本降低且差价大于待付金额,会发生供应商退款操作
             BigDecimal waitRefund = MathUtil.sub(differencePrice, waitPayShop);
             String refundWay = payShopDifference.getRefundWay();
             BigDecimal refundAmount = payShopDifference.getRefundAmount();
@@ -1288,18 +1404,28 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
     }
 
     @Transactional(readOnly = false, rollbackFor = Exception.class)
-    public void settlement(String shopOrderId, Double settleAmount) throws Exception {
+    public void settlement(String shopOrderId) throws Exception {
         // 结算付供应商
         String format = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.SSS").format(new Date());
         String substring = format.substring(20);
         String P3_customerNumber = newOrderDao.findSplitCode(shopOrderId);
-        redisService.set("SDJSS", 1, 120L);
-        settleOrder("JSCB" + shopOrderId + substring, settleAmount, P3_customerNumber, shopOrderId, 1);
+        Double shopCost = newOrderDao.findShopCost(shopOrderId);
+        settleOrder("JSCB" + shopOrderId + substring, shopCost, P3_customerNumber, shopOrderId, 1);
         // 结算佣金 佣金目前分到网络
         Double payAmount = newOrderDao.findPayAmount(shopOrderId);
         if (null != payAmount && payAmount > 0) {
             settleOrder("JSYJ" + shopOrderId + substring, payAmount, Constant.CUSTOMERNUM2, shopOrderId, 2);
         }
+        // 有组织佣金/付第三方的情况下,还需要结算组织佣金,付第三方
+        Double payOrganize = newOrderDao.findPayOrganize(shopOrderId);
+        if (null != payOrganize && payOrganize > 0) {
+            String split = newOrderDao.findOrganizeSplitByShopOrder(shopOrderId);
+            settleOrder("JSZZ" + shopOrderId + substring, payOrganize, split, shopOrderId, 3);
+        }
+        Double payOther = newOrderDao.getOtherPaid(shopOrderId);
+        if (null != payOther && payOther > 0) {
+            settleOrder("JSDSF" + shopOrderId + substring, payOther, Constant.CUSTOMERNUM3, shopOrderId, 4);
+        }
     }
 
     @Transactional(readOnly = false, rollbackFor = Exception.class)
@@ -1343,16 +1469,16 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                     newOrderDao.insertSettleRecord(settleRecord);
                     // 修改cm_split_account settlestatus
                     newOrderDao.updateSettleStatus(shopOrderId, 1);
-                    //计算供应商成本,结算金额,修改结算状态
-                    Double shouldPayShopAmount = newOrderDao.findShouldPayShopAmount(shopOrderId);
-                    Double settleSum = newOrderDao.findSettleSum(shopOrderId);
-                    if (shouldPayShopAmount > settleSum) {
-                        //成本>结算金额,部分结算
-                        newOrderDao.updateShopOrderSettleStatus(shopOrderId, 2);
-                    } else {
-                        //成本=结算金额 全部结算
-                        newOrderDao.updateShopOrderSettleStatus(shopOrderId, 3);
-                    }
+//                    //计算供应商成本,结算金额,修改结算状态
+//                    Double shouldPayShopAmount = newOrderDao.findShouldPayShopAmount(shopOrderId);
+//                    Double settleSum = newOrderDao.findSettleSum(shopOrderId);
+//                    if (shouldPayShopAmount > settleSum) {
+//                        //成本>结算金额,部分结算
+//                        newOrderDao.updateShopOrderSettleStatus(shopOrderId, 2);
+//                    } else {
+                    //成本=结算金额 全部结算
+                    newOrderDao.updateShopOrderSettleStatus(shopOrderId, 3);
+//                    }
                 } else {
                     //佣金结算
                     settleRecord.setSettleType(settleFlag);
@@ -1363,8 +1489,6 @@ public class CmPayShopService extends CrudService<CmPayShopDao, CmPayShop> {
                     // 修改cm_split_account settlestatus
                     newOrderDao.updateSettleStatus(shopOrderId, 3);
                 }
-                //解锁
-                redisService.remove("SDJSS");
             }
         }
     }

+ 16 - 0
src/main/java/com/caimei/modules/order/service/CmRefundShopService.java

@@ -180,11 +180,19 @@ public class CmRefundShopService extends CrudService<CmRefundShopDao, CmRefundSh
                  1. 若发生退货,数量要减去已退货和已取消的数量
                  2. 有赠品的商品只能全退
                  */
+                Double brokerage = 0d;
                 for (NewOrderProduct p : orderProductList) {
                     Integer returnNum = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
                     returnNum = returnNum == null ? 0 : returnNum;
                     p.setReturnedNum(returnNum);
+                    // 子订单利润
+                    if (p.getProductType() == 0) {
+                        brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(), p.getNum())).doubleValue();
+                    } else {
+                        brokerage = MathUtil.add(brokerage, 0).doubleValue();
+                    }
                 }
+                so.setBrokerage(brokerage);
                 so.setNewOrderProducts(orderProductList);
                 //主订单退款(退货)总金额
                 so.setReturnedPurchaseTotalFee(newShopOrderService.getOrderReturnedPurchaseFee(so));
@@ -247,11 +255,19 @@ public class CmRefundShopService extends CrudService<CmRefundShopDao, CmRefundSh
                  1. 若发生退货,数量要减去已退货和已取消的数量
                  2. 有赠品的商品只能全退
                  */
+                Double brokerage = 0d;
                 for (NewOrderProduct p : orderProductList) {
                     Integer returnNum = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
                     returnNum = returnNum == null ? 0 : returnNum;
                     p.setReturnedNum(returnNum);
+                    // 子订单利润
+                    if (p.getProductType() == 0) {
+                        brokerage = MathUtil.add(brokerage, MathUtil.mul(p.getBrokerage(), p.getNum())).doubleValue();
+                    } else {
+                        brokerage = MathUtil.add(brokerage, 0).doubleValue();
+                    }
                 }
+                so.setBrokerage(brokerage);
                 so.setNewOrderProducts(orderProductList);
                 so.setRefundAmount(record.getRefundAmount());
                 //主订单退款(退货)总金额

+ 19 - 19
src/main/java/com/caimei/modules/order/service/CmReturnedPurchaseService.java

@@ -665,25 +665,25 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
                     userBeans = userBeans - num;
                     cmUserDao.updateUserBeans(newOrder.getUserID(), userBeans);
                 }
-                //订单低于1000扣500豆子退回
-                if (newOrder.getPayTotalFee() != null && newOrder.getPayTotalFee() < 1000) {
-                    //查本单是否扣豆子,有就返回
-                    UserBeansHistory bean = newCmClubDao.findLowOrder(newOrder.getOrderID());
-                    if (bean != null) {
-                        //有扣豆子记录
-                        UserBeansHistory beanHistory = new UserBeansHistory();
-                        beanHistory.setUserId(newOrder.getUserID());
-                        beanHistory.setOrderId(newOrder.getOrderID());
-                        beanHistory.setBeansType(16);
-                        beanHistory.setType(1);
-                        beanHistory.setNum(500);
-                        beanHistory.setPushStatus(0);
-                        beanHistory.setAddTime(new Date());
-                        newCmClubDao.insertBeansHistory(beanHistory);
-                        int beans = cmUserDao.findUserBeans(newOrder.getUserID()) + 500;
-                        cmUserDao.updateUserBeans(newOrder.getUserID(), beans);
-                    }
-                }
+//                //订单低于1000扣500豆子退回
+//                if (newOrder.getPayTotalFee() != null && newOrder.getPayTotalFee() < 1000) {
+//                    //查本单是否扣豆子,有就返回
+//                    UserBeansHistory bean = newCmClubDao.findLowOrder(newOrder.getOrderID());
+//                    if (bean != null) {
+//                        //有扣豆子记录
+//                        UserBeansHistory beanHistory = new UserBeansHistory();
+//                        beanHistory.setUserId(newOrder.getUserID());
+//                        beanHistory.setOrderId(newOrder.getOrderID());
+//                        beanHistory.setBeansType(16);
+//                        beanHistory.setType(1);
+//                        beanHistory.setNum(500);
+//                        beanHistory.setPushStatus(0);
+//                        beanHistory.setAddTime(new Date());
+//                        newCmClubDao.insertBeansHistory(beanHistory);
+//                        int beans = cmUserDao.findUserBeans(newOrder.getUserID()) + 500;
+//                        cmUserDao.updateUserBeans(newOrder.getUserID(), beans);
+//                    }
+//                }
             }
             //优惠券退回
             CmCouponOrderRecord couponOrderRecord = newOrder.getCouponOrderRecord();

+ 47 - 38
src/main/java/com/caimei/modules/order/service/NewOrderService.java

@@ -3,7 +3,6 @@ package com.caimei.modules.order.service;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei.constants.UserType;
-import com.caimei.exception.BusinessException;
 import com.caimei.modules.bulkpurchase.dao.OrderInvoiceDao;
 import com.caimei.modules.bulkpurchase.entity.OrderInvoice;
 import com.caimei.modules.bulkpurchase.service.OrderInvoiceService;
@@ -1342,23 +1341,10 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                         }
                     }
                     //拼接运费
-                    Double ColdChina = Double.valueOf(700);
-                    String shopPostFlag = shopOrder.getShopPostFlag()!=null?shopOrder.getShopPostFlag():"-2";
+                    String shopPostFlag = shopOrder.getShopPostFlag()!=null?shopOrder.getShopPostFlag():"0";
                     String PostageInfo = null;
-                    if (null != shopOrder.getIsColdChina() && shopOrder.getIsColdChina() == 1) {
-                        if ("2" == shopOrder.getShopPostFlag()) {
-                            // 到付
-                            PostageInfo = "¥" + ColdChina + "(" + (shopOrder.getIsColdChina() == 1 ? "冷链费: ¥" + ColdChina + "," : "") + "其他: 到付)";
-                        } else if ("0" == shopOrder.getShopPostFlag()) {
-                            // 包邮
-                            PostageInfo = "¥" + ColdChina + "(" + (shopOrder.getIsColdChina() == 1 ? "冷链费: ¥" + ColdChina + "," : "") + "其他: 包邮)";
-                        } else {
-                            // 有运费
-                            PostageInfo = "¥" + MathUtil.add(shopOrder.getShopPostFee(), ColdChina) + "(" + (shopOrder.getIsColdChina() == 1 ? "冷链费: ¥" + ColdChina + "," : "") + "其他: ¥" + shopOrder.getShopPostFee() + ")";
-                        }
-                    } else {
-                        PostageInfo = shopPostFlag.equals("2") ? "到付" : shopPostFlag.equals("0") ? "包邮" : "¥" + shopOrder.getShopPostFee();
-                    }
+
+                    PostageInfo = shopPostFlag.equals("2") ? "到付" : shopPostFlag.equals("0") ? "包邮" : "¥" + shopOrder.getShopPostFee();
 
                     //支付凭证
                     List<CmOrderPaymentVoucherVo> voucherVo = newOrderService.findVoucherVoOrderID(shopOrder.getShopOrderID() );
@@ -1457,6 +1443,25 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                             shopOrder.setRestAmount(0d);
                         }
                     }
+                    // 子订单来自采美平台的第三方供应商的线下转账账号为空或者为采美账号
+                    Shop shop = newShopOrderDao.getShopOrderId(shopOrder.getShopID());
+                    boolean flag = null == shop.getBankAccount() || 0 == shop.getAccountOwnership();
+                    // 订单收款路径 线上、 线下
+                    Integer discernPayWay = cmReceiptOrderRelationDao.getDiscernPayWay(shopOrder.getOrderID());
+                    /** 排除以下情况的订单
+                     * (1)采美自营供应商(综合供应商)的子订单
+                     * (2)颜选商城的子订单
+                     * (3)来自采美平台的第三方供应商的线下转账账号为空或者为采美账号的子订单
+                     * (4)商品分账号是采美信息的商品的子订单(走了线上支付才排除)
+                     */
+                    if ((1161 != shopOrder.getShopID() || 2 != shopOrder.getOrderType() || !flag ||
+                            (!"E1807059160".equals(shopOrder.getSplitCode()) &&  null != discernPayWay && 1 == discernPayWay))) {
+                        // 线下支付的订单
+                        if (null != discernPayWay && 1 != discernPayWay) {
+                            // 订单下线收款, 付款状态与收款状态同步显示
+                            shopOrder.setPayStatus(shopOrder.getReceiptStatus());
+                        }
+                    }
                     // 订单已收款才会出现抹平或者多收退余额,(已收再退款或者撤销退款订单即使存在抹平也需要当未抹平重新计算付款)
                     String receiptStatus = shopOrder.getReceiptStatus();
                     if (StringUtils.equals("3", receiptStatus)) {
@@ -1633,7 +1638,6 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
 
         order.getNewShopOrders().get(0).setStatus(1);//已确认
 
-
 //        //修改订单状态(余额抵扣)
 //        if (order.getPayableAmount() != null) {
 //            if (order.getPayableAmount() == 0 && order.getBalancePayFee() != null && order.getBalancePayFee() > 0) {
@@ -1649,7 +1653,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
         Double balancePayFee = order.getNewShopOrders().get(0).getAccountAmount();
         //修改子订单状态(余额抵扣)
         if (order.getNewShopOrders().get(0).getUseBalanceFlag() !=null&&order.getNewShopOrders().get(0).getUseBalanceFlag() == 1) {
-            if ( balancePayFee != null && balancePayFee ==order.getNewShopOrders().get(0).getRealPay()) {
+            if ( balancePayFee != null && balancePayFee .equals(order.getNewShopOrders().get(0).getRealPay())) {
                 order.getNewShopOrders().get(0).setReceiptStatus("3");
             } else if ( balancePayFee != null && balancePayFee <order.getNewShopOrders().get(0).getRealPay()) {
                 order.getNewShopOrders().get(0).setReceiptStatus("2");
@@ -1660,6 +1664,8 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
         String curDateStr = sdf.format(date);
         order.setConfirmTime(curDateStr);
 
+        // 订单确认时间
+        order.getNewShopOrders().get(0).setConfirmTime(curDateStr);
 //        if (order.getBalancePayFee() != null && order.getBalancePayFee() > 0) {
         if (balancePayFee != null && balancePayFee > 0) {
             //已付金额
@@ -1772,24 +1778,24 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
             cmUserDao.updateUserBeans(order.getUserID(), userBeans);
         }
 
-        if (order.getPayTotalFee() != null && order.getPayTotalFee() < 1000) {
-            //查本单是否扣豆子,有就返回
-            UserBeansHistory bean = newCmClubDao.findLowOrder(order.getOrderID());
-            if (bean != null) {
-                //有扣豆子记录
-                UserBeansHistory beansHistory = new UserBeansHistory();
-                beansHistory.setUserId(order.getUserID());
-                beansHistory.setOrderId(order.getOrderID());
-                beansHistory.setBeansType(16);
-                beansHistory.setType(1);
-                beansHistory.setNum(500);
-                beansHistory.setPushStatus(0);
-                beansHistory.setAddTime(new Date());
-                newCmClubDao.insertBeansHistory(beansHistory);
-                int beans = cmUserDao.findUserBeans(order.getUserID()) + 500;
-                cmUserDao.updateUserBeans(order.getUserID(), beans);
-            }
-        }
+//        if (order.getPayTotalFee() != null && order.getPayTotalFee() < 1000) {
+//            //查本单是否扣豆子,有就返回
+//            UserBeansHistory bean = newCmClubDao.findLowOrder(order.getOrderID());
+//            if (bean != null) {
+//                //有扣豆子记录
+//                UserBeansHistory beansHistory = new UserBeansHistory();
+//                beansHistory.setUserId(order.getUserID());
+//                beansHistory.setOrderId(order.getOrderID());
+//                beansHistory.setBeansType(16);
+//                beansHistory.setType(1);
+//                beansHistory.setNum(500);
+//                beansHistory.setPushStatus(0);
+//                beansHistory.setAddTime(new Date());
+//                newCmClubDao.insertBeansHistory(beansHistory);
+//                int beans = cmUserDao.findUserBeans(order.getUserID()) + 500;
+//                cmUserDao.updateUserBeans(order.getUserID(), beans);
+//            }
+//        }
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String current = dateFormat.format(new Date());
         MessageCenter messageCenter = new MessageCenter();
@@ -2365,6 +2371,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                 order.setShopName(shopOrders.get(0).getShopName());
             }
             int count = 0;
+            String shopOrderNoAndId = "";
             for (NewShopOrder shopOrder : order.getNewShopOrders()) {
                 shopOrder.setOrderID(order.getOrderID());
                 shopOrder.setOrderNo(order.getOrderNo());
@@ -2381,6 +2388,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                 //通过子订单ID查询子订单信息
                 NewShopOrder newShopOrder = newShopOrderDao.get(String.valueOf(shopOrderID));
                 if (null != newShopOrder) {
+                    shopOrderNoAndId += "<b style=\"font-size: 15px;\">"+newShopOrder.getShopOrderID()+"</b>"+"("+newShopOrder.getShopOrderNo()+")<br>";
                     shopOrder.setFee(newShopOrder.getFee());
                     shopOrder.setShouldPayProduct(newShopOrder.getShouldPayProduct());
                     List<NewOrderProduct> pList = newOrderProductDao.findListByShopOrderID(shopOrderID);
@@ -2395,6 +2403,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                     shopOrder.setShouldPayProduct(0d);
                 }
             }
+            order.setShopOrderNoAndId(shopOrderNoAndId);
             //一个子订单只有一个商品时,不可拆分
             if (order.getProductCount() == null) {
                 order.setProductCount(1);
@@ -2441,7 +2450,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
     }
 
     /**
-     * 判断是否是游客
+     * 判断是否是游客b
      *
      * @param userId
      * @return

+ 422 - 35
src/main/java/com/caimei/modules/order/service/NewShopOrderService.java

@@ -2,18 +2,34 @@ package com.caimei.modules.order.service;
 
 
 import com.caimei.modules.bulkpurchase.entity.BpOrderUserinfo;
+import com.caimei.modules.bulkpurchase.entity.OrderInvoice;
+import com.caimei.modules.coupon.entity.CmCouponOrderRecord;
 import com.caimei.modules.hehe.dao.HeHeNewOrderDao;
+import com.caimei.modules.hehe.entity.CmHeheCouponOrderRecord;
 import com.caimei.modules.order.dao.*;
 import com.caimei.modules.order.entity.*;
+import com.caimei.modules.order.utils.NewOrderStatus;
 import com.caimei.modules.product.dao.CmPromotionDao;
+import com.caimei.modules.product.dao.CmSecondHandDetailDao;
 import com.caimei.modules.product.dao.ProductDao;
 import com.caimei.modules.product.entity.CmPromotion;
+import com.caimei.modules.product.entity.CmSecondHandDetail;
+import com.caimei.modules.product.entity.CmSku;
+import com.caimei.modules.product.entity.OrderProductLadderPrice;
+import com.caimei.modules.user.entity.CmUser;
+import com.caimei.modules.user.entity.NewCmClub;
+import com.caimei.po.neworder.CmShopOrder;
+import com.caimei.utils.AppKeys;
+import com.caimei.utils.AppUtils;
+import com.caimei.utils.MathUtil;
+import com.caimei.utils.SysConfig;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.service.CrudService;
 import com.thinkgem.jeesite.common.utils.StringUtils;
 import com.thinkgem.jeesite.modules.sys.entity.User;
 import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
 import org.apache.commons.collections.CollectionUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -22,6 +38,7 @@ import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.IntStream;
 
 @Service
 @Transactional(readOnly = true)
@@ -63,6 +80,12 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
     private HeHeNewOrderDao heHeNewOrderDao;
     @Resource
     private CmPayShopDao cmPayShopDao;
+    @Autowired
+    private CmSecondHandDetailDao cmSecondHandDetailDao;
+    @Resource
+    private CmDiscernReceiptService cmDiscernReceiptService;
+    @Resource
+    private NewOrderService newOrderService;
 
     public NewShopOrder findByShopOrderID(Integer shopOrderID) {
         NewShopOrder shopOrder = newShopOrderDao.findByShopOrderID(shopOrderID);
@@ -169,6 +192,7 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
         //查询这个子订单所有的发货批次记录
         List<LogisticsBatch> lbs = logisticsBatchDao.findBatch(orderID, logisticsBatchID);
         if(null!=shopOrderID){
+            //过滤子订单
             lbs=lbs.stream().filter(s -> s.getShopOrderID().equals(shopOrderID)).collect(Collectors.toList());
         }
 
@@ -253,6 +277,20 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
         return page;
     }
 
+
+    @Transactional(readOnly = false)
+    public Page<NewShopOrder> payThirdParties(Page<NewShopOrder> page, NewShopOrder shopOrder) {
+        shopOrder.setPage(page);
+        if (StringUtils.isNotBlank(shopOrder.getPayStatus())) {
+            String[] split = shopOrder.getPayStatus().split(",");
+            shopOrder.setPs(split);
+        }
+        List<NewShopOrder> payOrderList = newShopOrderDao.payThirdParties(shopOrder);
+        page.setList(payOrderList);
+        setValue(payOrderList);
+        return page;
+    }
+
     public void setValue(List<NewShopOrder> payOrderList) {
         for (NewShopOrder so : payOrderList) {
             Integer onlineFlag = newOrderDao.findOnlinePay(so.getOrderID()) > 0 ? 1 : 0;
@@ -270,10 +308,41 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
             } else {
                 so.setReceiptStatus("1");
             }
+            // 主订单已收金额
             double receiptTotalFee = cmReceiptOrderRelationDao.findPayFeeByOrderID(so.getOrderID().toString());
-
             so.setReceiptTotalFee(receiptTotalFee);
-
+            // 子订单已收金额
+            Double receiptAmount = cmReceiptOrderRelationDao.findReceiptByShopOrderId(so.getShopOrderID().toString());
+            so.setReceiptAmount(receiptAmount);
+            // 子订单已付金额
+            Double shopAmountShopOrderId = newShopOrderDao.payShopAmountShopOrderId(so.getShopOrderID());
+            so.setPayShopAmount(shopAmountShopOrderId);
+            // 已结金额
+            Double settleAmountByShopOrderId = newShopOrderDao.settleAmountByShopOrderId(so.getShopOrderID());
+            so.setSettleAmount(settleAmountByShopOrderId);
+            // 退款金额
+            Double returnedPurchaseFeeByShopOrderId = newShopOrderDao.returnedPurchaseFeeByShopOrderId(so.getShopOrderID());
+            so.setCanRefundAmount(returnedPurchaseFeeByShopOrderId);
+            //结算记录
+            List<SettleRecord> settleRecord = newShopOrderDao.findSettleRecord(so.getShopOrderID().toString());
+            Integer num = null == settleRecord ? 0 : settleRecord.size();
+            so.setSettleRecordNum(num);
+            //分账记录数
+            Integer splitCount = newShopOrderDao.findSplitCount(so.getShopOrderID());
+            so.setSplitCount(splitCount);
+            // 订单收款路径 线上、 线下
+            Integer discernPayWay = cmReceiptOrderRelationDao.getDiscernPayWay(so.getOrderID());
+            if (null != discernPayWay && 1 != discernPayWay) {
+                // 线下收款,结算金额设置为已付金额
+                so.setSettleAmount(shopAmountShopOrderId);
+                if ( so.getSettleAmount() > 0 && (MathUtil.sub(so.getShouldPayShopAmount(), so.getShopOtherFee()).doubleValue()) == so.getSettleAmount()) {
+                    so.setSettleStatus(3);
+                } else if(so.getSettleAmount() > 0 &&  (MathUtil.sub(so.getShouldPayShopAmount(), so.getShopOtherFee()).doubleValue()) > so.getSettleAmount()) {
+                    so.setSettleStatus(2);
+                } else {
+                    so.setSettleStatus(1);
+                }
+            }
             //第一次收款收款时间
             Date receiptDate = cmReceiptOrderRelationDao.findOnlinePayment(so.getOrderID());
             if (receiptDate != null) {
@@ -291,6 +360,15 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
                 Integer returnNum = newOrderProductDao.CountReturnedPurchaseProduct(so.getShopOrderID(), p.getOrderProductID());
                 returnNum = returnNum == null ? 0 : returnNum;
                 p.setReturnedNum(returnNum);
+                // 还原下单时商品成本
+                /*Double newCostPrice = 0d;
+                newCostPrice = p.getCostPrice();
+                p.setCostPrice(MathUtil.div(p.getCostPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100),100)).doubleValue());
+                p.setNewCostPrice(newCostPrice);*/
+                p.setOldDiscountPrice(p.getDiscountPrice());
+                /*if ("0".equals(p.getIncludedTax()) && null != p.getTaxRate() && p.getTaxRate() > 0d) {
+                    p.setDiscountPrice(MathUtil.div(p.getDiscountPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100), 100)).doubleValue());
+                }*/
             }
             if (so.getShopPostFee() == null) so.setShopPostFee(0D);
             if (so.getShopTaxFee() == null) so.setShopTaxFee(0D);
@@ -410,16 +488,17 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
         }
     }
 
-    public Page<NewOrder> findPaymentOrderList(Page<NewOrder> page, NewOrder newOrder) {
-        newOrder.setPage(page);
-        if (newOrder.getPayStatus() != null && newOrder.getPayStatus() != "") {
-            String[] split = newOrder.getPayStatus().split(",");
-            newOrder.setPs(split);
+    public Page<NewShopOrder> findPaymentOrderList(Page<NewShopOrder> page, NewShopOrder shopOrder) {
+        shopOrder.setPage(page);
+        if (StringUtils.isNotBlank(shopOrder.getPayStatus())) {
+            String[] split = shopOrder.getPayStatus().split(",");
+            shopOrder.setPs(split);
         }
-        List<NewOrder> orderList = newOrderDao.findOrderList(newOrder);
-        page.setList(orderList);
-
-        List<Integer> oId = orderList.stream().map(NewOrder::getOrderID).collect(Collectors.toList());
+        // List<NewOrder> orderList = newOrderDao.findOrderList(newOrder);
+        List<NewShopOrder> payOrderList = newShopOrderDao.findShopOrderList(shopOrder);
+        page.setList(payOrderList);
+        setValue(payOrderList);
+        /*List<Integer> oId = orderList.stream().map(NewOrder::getOrderID).collect(Collectors.toList());
         //看看这些订单有哪些是返佣订单 返回他们的orderID
         List<Integer> orderIds = null;
         if (CollectionUtils.isNotEmpty(oId)) {
@@ -485,7 +564,7 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
                 if (newShopOrder.getShopID() != 998) {
                     //统计子订单下的商品信息
                     List<NewOrderProduct> orderProductList = newOrderProductDao.findByShopOrderID(newShopOrder.getShopOrderID());
-                    /* 退货数量 */
+                     // 退货数量
                     for (NewOrderProduct p : orderProductList) {
                         Integer count = newOrderProductDao.CountReturnedPurchaseProduct(newShopOrder.getShopOrderID(), p.getOrderProductID());
                         p.setReturnedNum(count == null ? 0 : count);
@@ -494,6 +573,7 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
                     list.add(newShopOrder);
                 }
             }
+            order.setShopOrderID(shopOrders.get(0).getShopOrderID());
             //退款(退货)总金额
             Double returnedPurchaseFee = cmReturnedPurchaseDao.refundTotalMoney(order.getOrderID());
             Double returnValue = 0d;   //退货价值
@@ -518,31 +598,27 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
                 String name = heHeNewOrderDao.findHeUser(order.getUserID());
                 order.setClubName(name);
             }
-        }
+        }*/
         return page;
     }
 
-    public NewOrder findRefundRecord(Integer orderID) {
-        NewOrder order = newOrderDao.get(orderID.toString());
-        CmReceiptOrderRelation receiptOrderRelations = cmReceiptOrderRelationDao.findOrderRelation(orderID);
+    public NewShopOrder findRefundRecord(Integer shopOrderId) {
+        // NewOrder order = newOrderDao.get(orderID.toString());
+        NewShopOrder shopOrder = newShopOrderDao.get(shopOrderId.toString());
+        CmReceiptOrderRelation receiptOrderRelations = cmReceiptOrderRelationDao.findOrderRelation(shopOrder.getOrderID(), shopOrderId);
         if (receiptOrderRelations != null && receiptOrderRelations.getRelationType().equals("1")) {
-            order.setRebateOrder("1");
-            order.setReceiptStatus("4");
-            order.setAlreadyReceipt("----");
-            order.setPayStatus("4");
-            order.setPaid("----");
+            shopOrder.setRebateOrder("1");
+            shopOrder.setReceiptStatus("4");
+            shopOrder.setAlreadyReceipt("----");
+            shopOrder.setPayStatus("4");
+            shopOrder.setPaid("----");
         } else {
-            order.setRebateOrder("0");
-            //统计该主订单的收款金额
-            Double receiptTotalFee = cmReceiptOrderRelationDao.findPayFeeByOrderID(orderID.toString());
-            if (receiptTotalFee == null) receiptTotalFee = 0d;
-            order.setAlreadyReceipt(String.valueOf(receiptTotalFee));
-            //统计该主订单的付款金额
-            Double paid = newOrderDao.findPaidOrderID(order.getOrderID());
-            if (paid == null) paid = 0d;
-            order.setPaid(String.valueOf(paid));
-        }
-        if (order.getTotalDiscount() == null) order.setTotalDiscount(0d);
+            shopOrder.setRebateOrder("0");
+        }
+        ArrayList<NewShopOrder> newShopOrders = new ArrayList<>();
+        newShopOrders.add(shopOrder);
+        setValue(newShopOrders);
+        /*if (order.getTotalDiscount() == null) order.setTotalDiscount(0d);
         List<NewShopOrder> shopOrders = newShopOrderDao.findListByOrderID(orderID);
         List<NewShopOrder> list = new ArrayList();
         //统计所有子订单付供应商金额之和
@@ -561,7 +637,7 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
             if (newShopOrder.getShopID() != 998) {
                 //统计子订单下的商品信息
                 List<NewOrderProduct> orderProductList = newOrderProductDao.findByShopOrderID(newShopOrder.getShopOrderID());
-                /* 退货数量 */
+                // 退货数量
                 for (NewOrderProduct p : orderProductList) {
                     Integer count = newOrderProductDao.CountReturnedPurchaseProduct(newShopOrder.getShopOrderID(), p.getOrderProductID());
                     p.setReturnedNum(count == null ? 0 : count);
@@ -587,8 +663,8 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
         returnedFreightFlag = returnedFreightNum == null ? false : returnedFreightNum > 0 ? true : false;
         order.setReturnedFreightFlag(returnedFreightFlag);
         order.setShouldPayShopAmount(shouldPayShopAmount);
-        order.setNewShopOrders(list);
-        return order;
+        order.setNewShopOrders(list);*/
+        return newShopOrders.get(0);
     }
 
     @Transactional(readOnly = false)
@@ -684,4 +760,315 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
     public List<Integer> payWay(Integer shoprderID) {
         return newShopOrderDao.payWay(shoprderID);
     }
+
+    /**
+     * 查询子订单
+     *
+     * @param shopOrderID 子订单主键
+     * @return 子订单
+     */
+
+    public NewShopOrder getCmShopOrderByShopOrderID(String shopOrderID) {
+        NewShopOrder newShopOrder = new NewShopOrder();
+        newShopOrder.setShopOrderID(Integer.valueOf(shopOrderID));
+        NewShopOrder byCmShopOrder = newShopOrderDao.getByCmShopOrder(newShopOrder);
+        initCmShopOrder(byCmShopOrder);
+        return byCmShopOrder;
+    }
+
+    /**
+     * 查询子订单Id
+     *
+     * @param cmShopOrder 子订单
+     * @return String
+     */
+
+    public String getById(NewShopOrder cmShopOrder) {
+        return newShopOrderDao.getById(cmShopOrder);
+    }
+
+    /**
+     * 查询子订单Ids
+     *
+     * @param cmShopOrder 子订单
+     * @return List<String>
+     */
+
+    public List<String> getByIds(NewShopOrder cmShopOrder) {
+        return newShopOrderDao.getByIds(cmShopOrder);
+    }
+
+    /**
+     * 查询子订单
+     *
+     * @param cmShopOrder 子订单
+     * @return 子订单
+     */
+    public NewShopOrder getByCmShopOrder(NewShopOrder cmShopOrder) {
+        NewShopOrder byCmShopOrder = newShopOrderDao.getByCmShopOrder(cmShopOrder);
+        initCmShopOrder(byCmShopOrder);
+        return byCmShopOrder;
+    }
+
+    /**
+     * 查询子订单列表
+     *
+     * @param cmShopOrder 子订单
+     * @return 子订单
+     */
+    public List<NewShopOrder> getCmShopOrderList(NewShopOrder cmShopOrder) {
+        List<NewShopOrder> cmShopOrderList = newShopOrderDao.getCmShopOrderList(cmShopOrder);
+        initCmShopOrders(cmShopOrderList);
+        return cmShopOrderList;
+    }
+
+    /**
+     * 查询子订单记录总数
+     *
+     * @param cmShopOrder 子订单
+     * @return 子订单
+     */
+    public int getCmShopOrderCount(NewShopOrder cmShopOrder) {
+        return newShopOrderDao.getCmShopOrderCount(cmShopOrder);
+    }
+
+    /**
+     * 新增子订单
+     *
+     * @param cmShopOrder 子订单
+     * @return 结果
+     */
+    public int addCmShopOrder(NewShopOrder cmShopOrder) {
+        cmShopOrder.setCreateDate(new Date());
+        return newShopOrderDao.addCmShopOrder(cmShopOrder);
+    }
+
+    /**
+     * 修改子订单
+     *
+     * @param cmShopOrder 子订单
+     * @return 结果
+     */
+    public int updateCmShopOrder(NewShopOrder cmShopOrder) {
+        cmShopOrder.setUpdateDate(new Date());
+        return newShopOrderDao.updateCmShopOrder(cmShopOrder);
+    }
+
+    /**
+     * 批量删除子订单
+     *
+     * @param shopOrderIDs 需要删除的子订单主键
+     * @return 结果
+     */
+    public int delCmShopOrderByShopOrderIDs(String[] shopOrderIDs) {
+        return newShopOrderDao.updateDelCmShopOrderByShopOrderIDs(shopOrderIDs, 1);
+        //return newShopOrderDao.delCmShopOrderByShopOrderIDs(shopOrderIDs);
+    }
+
+    /**
+     * 删除子订单信息
+     *
+     * @param shopOrderID 子订单主键
+     * @return 结果
+     */
+    public int delCmShopOrderByShopOrderID(Integer shopOrderID) {
+        NewShopOrder newShopOrder = new NewShopOrder();
+        newShopOrder.setShopOrderID(shopOrderID);
+        newShopOrder.setDelFlag("1");
+        return newShopOrderDao.updateCmShopOrder(newShopOrder);
+        //return newShopOrderDao.delCmShopOrderByShopOrderID(shopOrderID);
+    }
+
+    /**
+     * 批量新增子订单
+     *
+     * @param cmShopOrderList 子订单列表
+     * @return 结果
+     */
+    public void batchAddCmShopOrder(List<NewShopOrder> cmShopOrderList) {
+        for (NewShopOrder cmShopOrder : cmShopOrderList) {
+            newShopOrderDao.addCmShopOrder(cmShopOrder);
+        }
+    }
+
+    /**
+     * 批量修改子订单
+     *
+     * @param cmShopOrderList 子订单列表
+     * @return 结果
+     */
+    public void batchUpdateCmShopOrder(List<NewShopOrder> cmShopOrderList) {
+        for (NewShopOrder cmShopOrder : cmShopOrderList) {
+            newShopOrderDao.updateCmShopOrder(cmShopOrder);
+        }
+    }
+
+    /**
+     * 功能描述: 初始化子订单集合
+     *
+     * @param cmShopOrderList
+     * @return [cmShopOrderList]
+     * @auther: Kaick
+     * @date: 2023/7/25 10:57
+     */
+    public void initCmShopOrders(List<NewShopOrder> cmShopOrderList) {
+        //获取订单商品
+        if (CollectionUtils.isNotEmpty(cmShopOrderList)) {
+            for (NewShopOrder shopOrder : cmShopOrderList) {
+                initCmShopOrder(shopOrder);
+            }
+        }
+        cmShopOrderList.sort((so1, so2) -> {
+            //给子订单排序  邮费排在最后  其余的按shopOrderID  asc
+            if ("1".equals(so1.getPostFeeCos())) return 1;
+            return so1.getShopOrderID() - so2.getShopOrderID();
+        });
+    }
+
+    /**
+     * 功能描述: 初始化子订单
+     *
+     * @param shopOrder
+     * @return [shopOrder]
+     * @auther: Kaick
+     * @date: 2023/7/25 10:56
+     */
+    public void initCmShopOrder(NewShopOrder shopOrder) {
+        //子订单已付金额
+        Double shoOrderIDReceipt = cmDiscernReceiptService.findShoOrderIDReceipt(shopOrder.getShopOrderID());
+        BigDecimal add = MathUtil.add(shopOrder.getReceiptAmount(), shoOrderIDReceipt != null ? shoOrderIDReceipt : 0);
+        shopOrder.setReceiptAmount(add.doubleValue());
+        //子订单待付金额
+        BigDecimal sub = MathUtil.sub((shopOrder.getRealPay() != null ? shopOrder.getRealPay() : shopOrder.getNeedPayAmount()).doubleValue()
+                , shopOrder.getReceiptAmount().doubleValue());
+        shopOrder.setRestAmount(sub.doubleValue());
+        if (1 == shopOrder.getStatus()) {
+            if ("1".equals(shopOrder.getReceiptStatus()) && "1".equals(shopOrder.getSendOutStatus())) {
+                shopOrder.setStatus(11);
+            } else if ("1".equals(shopOrder.getReceiptStatus()) && "2".equals(shopOrder.getSendOutStatus())) {
+                shopOrder.setStatus(12);
+            } else if ("1".equals(shopOrder.getReceiptStatus()) && "3".equals(shopOrder.getSendOutStatus())) {
+                shopOrder.setStatus(13);
+            } else if ("2".equals(shopOrder.getReceiptStatus()) && "1".equals(shopOrder.getSendOutStatus())) {
+                shopOrder.setStatus(21);
+            } else if ("2".equals(shopOrder.getReceiptStatus()) && "2".equals(shopOrder.getSendOutStatus())) {
+                shopOrder.setStatus(22);
+            } else if ("2".equals(shopOrder.getReceiptStatus()) && "3".equals(shopOrder.getSendOutStatus())) {
+                shopOrder.setStatus(23);
+            } else if ("3".equals(shopOrder.getReceiptStatus()) && "1".equals(shopOrder.getSendOutStatus())) {
+                shopOrder.setStatus(31);
+            } else if ("3".equals(shopOrder.getReceiptStatus()) && "2".equals(shopOrder.getSendOutStatus())) {
+                shopOrder.setStatus(32);
+            } else if ("3".equals(shopOrder.getReceiptStatus()) && "3".equals(shopOrder.getSendOutStatus())) {
+                shopOrder.setStatus(33);
+            }
+        }
+        //拼接运费
+        Double ColdChina = 700d;
+        String shopPostFlag = shopOrder.getShopPostFlag() != null ? shopOrder.getShopPostFlag() : "-2";
+        String PostageInfo = null;
+        if (null != shopOrder.getIsColdChina() && shopOrder.getIsColdChina() == 1) {
+            if ("2" == shopOrder.getShopPostFlag()) {
+                // 到付
+                PostageInfo = "¥" + ColdChina + "(" + (shopOrder.getIsColdChina() == 1 ? "冷链费: ¥" + ColdChina + "," : "") + "其他: 到付)";
+            } else if ("0" == shopOrder.getShopPostFlag()) {
+                // 包邮
+                PostageInfo = "¥" + ColdChina + "(" + (shopOrder.getIsColdChina() == 1 ? "冷链费: ¥" + ColdChina + "," : "") + "其他: 包邮)";
+            } else {
+                // 有运费
+                PostageInfo = "¥" + MathUtil.add(shopOrder.getShopPostFee(), ColdChina) + "(" + (shopOrder.getIsColdChina() == 1 ? "冷链费: ¥" + ColdChina + "," : "") + "其他: ¥" + shopOrder.getShopPostFee() + ")";
+            }
+        } else {
+            PostageInfo = shopPostFlag.equals("2") ? "到付" : shopPostFlag.equals("0") ? "包邮" : "¥" + shopOrder.getShopPostFee();
+        }
+        shopOrder.setPostageInfo(PostageInfo);
+        //支付凭证
+        List<CmOrderPaymentVoucherVo> voucherVo = newOrderService.findVoucherVoOrderID(shopOrder.getShopOrderID());
+        shopOrder.setVoucherVo(voucherVo);
+        List<String> code = newShopOrderDao.findCommercialCode(shopOrder.getOrderID());
+        for (String str : code) {
+            if ("E1807059160".equals(str)) {
+                shopOrder.setCommercialCode("E1807059160");
+            }
+        }
+        //子订单商品信息
+        List<NewOrderProduct> pList = newOrderProductDao.findListByShopOrderID(shopOrder.getShopOrderID());
+        pList.forEach(orderProduct -> {
+            initCmOrderProduct(orderProduct);
+        });
+        shopOrder.setNewOrderProducts(pList);
+        if (pList.stream().anyMatch(p -> p.getProductID().intValue() == 999)){
+            shopOrder.setPostFeeCos("1");
+        }
+        Double payed = cmPayShopRecordDao.sumByShopOrderID(shopOrder.getShopOrderID());
+        shopOrder.setPayed(payed);
+        //查询是否存在店铺促销活动
+        CmPromotion shopPromotion = null;
+        if (shopOrder.getOrderPromotionsId() != null && shopOrder.getOrderPromotionsId() > 0) {
+            shopPromotion = cmPromotionDao.findOrderPromotions(shopOrder.getOrderPromotionsId());
+            shopOrder.setShopPromotion(shopPromotion);
+        }
+        CmSecondHandDetail cmSecondHandDetail = cmSecondHandDetailDao.selectContactDockingPeople(shopOrder.getShopOrderNo());
+        if (null != cmSecondHandDetail) {
+            shopOrder.setContactName(cmSecondHandDetail.getContactName());
+            shopOrder.setDockingPeopleName(cmSecondHandDetail.getDockingPeopleName());
+        }
+    }
+
+    public void initCmOrderProduct(NewOrderProduct orderProduct) {
+//                        //是否二手订单
+//                        if ("2".equals(orderProduct.getProductCategory())) {
+//                            newOrder.setSecondHandOrderFlag("1");
+//                        }
+//                        //充值定金商品
+//                        if (6060 == orderProduct.getProductID()) {
+//                            newOrder.setRechargeGoods(1);
+//                        }
+        if (orderProduct.getLadderPriceFlag() == 1) {
+            // 查询订单商品阶梯价格
+            List<OrderProductLadderPrice> ladderPriceList = newOrderProductDao.findladderPriceList(orderProduct.getOrderProductID());
+            if (null != ladderPriceList && ladderPriceList.size() > 0) {
+                IntStream.range(0, ladderPriceList.size()).forEach(i -> {
+                    if (i == ladderPriceList.size() - 1) {
+                        ladderPriceList.get(i).setBuyNumRangeShow("≥" + ladderPriceList.get(i).getBuyNum());
+                    } else {
+                        String buyNumRangeShow = ladderPriceList.get(i).getBuyNum() + "~" + (ladderPriceList.get(i + 1).getBuyNum() - 1);
+                        ladderPriceList.get(i).setBuyNumRangeShow(buyNumRangeShow);
+                    }
+                });
+                orderProduct.setOrderProductLadderPriceList(ladderPriceList);
+            }
+        }
+        // 设置超级会员税费优惠
+        if (null != orderProduct.getSvipPriceFlag() && orderProduct.getSvipPriceFlag() == 1 && "0".equals(orderProduct.getIncludedTax()) && ("1".equals(orderProduct.getInvoiceType()) || "2".equals(orderProduct.getInvoiceType()))) {
+            orderProduct.setSvipTaxReduction(orderProduct.getSvipReduction() - (orderProduct.getPrice() - orderProduct.getDiscountPrice()));
+        } else {
+            orderProduct.setSvipTaxReduction(0d);
+        }
+        // sku信息
+        List<CmSku> skuList = productDao.findSkuList(orderProduct.getProductID());
+        orderProduct.setSkuList(skuList);
+        //商品退货信息
+        Integer returningNum = newOrderProductDao.getReturningNum(orderProduct.getOrderProductID());
+        Integer returnedNum = newOrderProductDao.getReturnedNum(orderProduct.getOrderProductID());
+        orderProduct.setReturningNum(returningNum);
+        orderProduct.setReturnedNum(returnedNum);
+        /**确认收货信息*/
+        Integer receivedNum = newOrderProductDao.getReceivedNum(orderProduct.getOrderProductID());
+        orderProduct.setReceivedNum(receivedNum);
+        String domain = SysConfig.getStringConfig("crm.server.domain");
+        orderProduct.setProductImage(AppUtils.getProductImageURL(orderProduct.getProductImage(), AppKeys.ORIGINAL_PICTURE, domain));
+        if (orderProduct != null && orderProduct.getOrderPromotionsId() != null && orderProduct.getOrderPromotionsId() > 0) {
+            orderProduct.setProductPromotion(cmPromotionDao.findOrderPromotions(orderProduct.getOrderPromotionsId()));
+            //单品优惠
+            if (orderProduct.getOrderPromotionsId() != null) {
+                CmPromotion promotions = cmPromotionDao.findOrderPromotions(orderProduct.getOrderPromotionsId());
+                if (promotions != null && "1".equals(promotions.getMode())) {
+                    //取对应sku的优惠价
+                    Double price = productDao.getTouchPriceBySku(orderProduct.getSkuId());
+                    orderProduct.setDiscountPrice(price);
+                }
+            }
+        }
+    }
 }

+ 262 - 288
src/main/java/com/caimei/modules/order/service/SplitAccountService.java

@@ -21,6 +21,8 @@ import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
 
 
 @Service
@@ -40,344 +42,316 @@ public class SplitAccountService extends BaseService {
     private NewShopOrderDao newShopOrderDao;
 
     @Transactional(readOnly = false, rollbackFor = Exception.class)
-    public void SplitAccount(String shopOrderIds) {
+    public void SplitAccount(String[] shopOrderIds) {
         logger.info("【手动分账开始】>>>>>>>>>>手动分账");
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(new Date());
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String currentTime = format.format(calendar.getTime());
-        // 查询未分账已支付收款
-        List<OrderReceiptRelationPo> orderRelations = newOrderDao.getUndividedPaidReceipt(currentTime, shopOrderIds);
-        if (null != orderRelations && orderRelations.size() > 0) {
+        List<String> ids = new ArrayList<>();
+        ids = Arrays.stream(shopOrderIds).collect(Collectors.toList());
+
+        ids.forEach(i -> {
+            // 查询未分账已支付收款
+            List<OrderReceiptRelationPo> orderRelations = newOrderDao.getUndividedPaidReceipt(currentTime, i);
+            List<SplitAccountPo> splitBillDetail = new ArrayList<>();
+            AtomicReference<Double> costPrice = new AtomicReference<Double>(0d);
+            AtomicReference<Double> cmCostPrice = new AtomicReference<Double>(0d);
+            AtomicReference<Double> organizeCostPrice = new AtomicReference<Double>(0d);
+            AtomicReference<Double> total = new AtomicReference<Double>(0d);
+            // 收款对应的订单信息
+            ShopOrderVo shopOrder = newOrderDao.getShopOrderListByOrderId(Integer.valueOf(i));
             for (OrderReceiptRelationPo orderRelation : orderRelations) {
                 logger.info("【分账】>>>>>>>>>>子订单id:" + orderRelation.getShopOrderId() + "进入分账");
-                // 收款对应的订单信息
-                ShopOrderVo shopOrder = newOrderDao.getShopOrderListByOrderId(orderRelation.getShopOrderId());
-                PayParamBo payParam = new PayParamBo();
-                //支付金额
-                payParam.setAllPay(orderRelation.getAssociateAmount());
-                if (12 == orderRelation.getPayType()) {
-                    // 网银支付
-                    payParam.setPayWay("UNIONPAY");
-                }
-                if (17 == orderRelation.getPayType()) {
-                    //b2c网银
-                    payParam.setPayWay("B2C");
-                }
-                //微信0.65%手续费
-                if (8 == orderRelation.getPayType() || 13 == orderRelation.getPayType() || 15 == orderRelation.getPayType()) {
-                    payParam.setPayWay("WX");
+                setSplitAccountDetail(costPrice, organizeCostPrice, cmCostPrice, total, shopOrder, orderRelation);
+            }
+            /** todo
+             *  当前版本优惠券和促销活动为商家承担
+             */
+            if (shopOrder.getCouponAmount() > 0 || shopOrder.getPromotionFullReduction() > 0) {
+                costPrice.set(MathUtil.sub(costPrice, MathUtil.add(shopOrder.getCouponAmount(), shopOrder.getPromotionFullReduction())).doubleValue());
+            }
+            if (MathUtil.compare(total, MathUtil.add(MathUtil.add(costPrice, cmCostPrice), organizeCostPrice)) <= 0) {
+                logger.info("收款总金额不足分帐------------->total: " + total.get()
+                        + "costPrice: " + costPrice.get() + "----------"
+                        + "cmCostPrice: " + cmCostPrice.get() + "-------------"
+                        + "organizeCostPrice: " + organizeCostPrice.get() + "---------------");
+                return;
+            }
+            /**
+             *   线上订单,付第三方如果不为0,需要从供应商成本中支付
+             */
+            double payOther = newOrderDao.findPayOther(Integer.valueOf(i));
+            if (MathUtil.compare(payOther, 0) > 0) {
+                SplitAccountPo splitAccount = new SplitAccountPo();
+                splitAccount.setOrderId(shopOrder.getOrderId());
+                splitAccount.setShopOrderId(shopOrder.getShopOrderId());
+                splitAccount.setSplitAccount(payOther);
+                splitAccount.setProductType(6);
+                splitAccount.setType(6);
+                splitAccount.setSubUserNo(Constant.CUSTOMERNUM3);
+                logger.info("付第三方分账参数------------->" + splitAccount);
+                splitBillDetail.add(splitAccount);
+                // 当前版本付第三方从供应商成本支出
+                costPrice.updateAndGet(v -> MathUtil.sub(v, payOther).doubleValue());
+            }
+            if (costPrice.get() > 0) {
+                SplitAccountPo splitAccount = new SplitAccountPo();
+                splitAccount.setShopOrderId(shopOrder.getShopOrderId());
+                splitAccount.setOrderId(shopOrder.getOrderId());
+                splitAccount.setSplitAccount(costPrice.get());
+                splitAccount.setProductType(1);
+                // 该商品设置了商户号
+                splitAccount.setType(4);
+                splitAccount.setSubUserNo(shopOrder.getSplitCode());
+                logger.info("成本分账参数------------->" + splitAccount.toString());
+                splitBillDetail.add(splitAccount);
+            }
+            /** 成本分完,金额未尽,有组织佣金的情况,优先组织佣金
+             *  当前版本,采美供应商上架丽格商城,会存在三成本均>0的情况
+             *  若无组织佣金,所有剩余金额归于采美佣金
+             */
+            if (organizeCostPrice.get() > 0) {
+                SplitAccountPo splitAccount = new SplitAccountPo();
+                splitAccount.setShopOrderId(shopOrder.getShopOrderId());
+                splitAccount.setOrderId(shopOrder.getOrderId());
+                splitAccount.setSplitAccount(organizeCostPrice.get());
+                splitAccount.setProductType(5);
+                // 该商品设置了商户号
+                splitAccount.setType(4);
+                String code = newOrderDao.findSplitCodeByOrganize(shopOrder.getOrganizeId());
+                if (StringUtils.isBlank(code)) {
+                    logger.info("组织的分帐号未空,无法分帐组织佣金!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+                    return;
                 }
-                //快捷支付 借记卡支付29,贷记卡支付30
-                if (29 == orderRelation.getPayType()) {
-                    payParam.setPayWay("DEBIT");
+                splitAccount.setSubUserNo(code);
+                logger.info("组织佣金分账参数------------->" + splitAccount.toString());
+                splitBillDetail.add(splitAccount);
+            }
+            /**  当前版本还要考虑分组织/集团佣金
+             *   如果还有钱则为佣金,分到网络
+             */
+            if (cmCostPrice.get() > 0) {
+                // 此处不考虑手续费,外部计算总额
+                SplitAccountPo splitAccount = new SplitAccountPo();
+                splitAccount.setOrderId(shopOrder.getOrderId());
+                splitAccount.setShopOrderId(shopOrder.getShopOrderId());
+                splitAccount.setSplitAccount(cmCostPrice.get());
+                splitAccount.setProductType(3);
+                splitAccount.setType(5);
+                splitAccount.setSubUserNo(Constant.CUSTOMERNUM2);
+                logger.info("佣金分账参数------------->" + splitAccount);
+                splitBillDetail.add(splitAccount);
+            }
+
+            HashMap<String, BigDecimal> sbm = new HashMap<>();
+            for (SplitAccountPo splitAccountPo : splitBillDetail) {
+                String subUserNo = splitAccountPo.getSubUserNo();
+                // 计算当前商户号总分账金额
+                if (sbm.containsKey(subUserNo)) {
+                    BigDecimal v = MathUtil.add(sbm.get(subUserNo), splitAccountPo.getSplitAccount());
+                    sbm.put(subUserNo, v);
+                } else {
+                    sbm.put(subUserNo, BigDecimal.valueOf(splitAccountPo.getSplitAccount()));
                 }
-                if (30 == orderRelation.getPayType()) {
-                    payParam.setPayWay("CREDIT");
+                // splitcode相同的收款的时候已经是成本已分帐
+                if (subUserNo.equals(shopOrder.getSplitCode())) {
+                    // 供应商自己收款,此部分金额留在自己商户号,作为成本分账
+                    splitAccountPo.setPayStatus(1);
+                    // 保存分账详情
+                    newOrderDao.insertSplitAccount(splitAccountPo);
                 }
-                List<SplitAccountPo> splitBillDetail = setSplitAccountDetail(shopOrder, payParam);
-                HashMap<String, BigDecimal> sbm = new HashMap<>();
-                for (SplitAccountPo splitAccountPo : splitBillDetail) {
-                    String subUserNo = splitAccountPo.getSubUserNo();
-                    // 计算当前商户号总分账金额
-                    if (sbm.containsKey(subUserNo)) {
-                        BigDecimal v = MathUtil.add(sbm.get(subUserNo), splitAccountPo.getSplitAccount());
-                        sbm.put(subUserNo, v);
-                    } else {
-                        sbm.put(subUserNo, BigDecimal.valueOf(splitAccountPo.getSplitAccount()));
-                    }
-                    // splitcode相同的收款的时候已经是成本已分帐
-                    if (subUserNo.equals(shopOrder.getSplitCode())) {
-                        splitAccountPo.setMbOrderId(orderRelation.getMbOrderId());
-                        splitAccountPo.setOrderRequestNo(orderRelation.getOrderRequestNo());
-                        // 供应商自己收款,此部分金额留在自己商户号,作为成本分账
-                        splitAccountPo.setPayStatus(1);
-                        // 保存分账详情
-                        newOrderDao.insertSplitAccount(splitAccountPo);
+            }
+            ArrayList<AccountPayOrder.AccountPayOrderExt.SplitBillRule> splitBillRules = new ArrayList<>();
+            sbm.forEach((key, value) -> {
+                /**
+                 *   不是自己的splitcode分走,是自己的不动
+                 *   把成本之外的金额加入splitRule分账参数,延续上面逻辑,供应商自己的成本由自己的商户号收款,
+                 *   自己成本部分不需要加入分账参数,仅需在else中做业务表参数处理
+                 */
+                if (!key.equals(shopOrder.getSplitCode())) {
+                    // 佣金
+                    AccountPayOrder.AccountPayOrderExt.SplitBillRule splitBillRule = new AccountPayOrder.AccountPayOrderExt.SplitBillRule();
+                    // 分账计算的时候未处理手续费,总额处理手续费   x + x * 0.1% = value
+                    BigDecimal div = MathUtil.div(value, 1.001, 2);
+                    if (MathUtil.sub(value, div).doubleValue() < 0.01) {
+                        // 如果手续费小于最低手续费,取0.01
+                        div = MathUtil.round(MathUtil.sub(value, 0.01), 2);
                     }
-                }
-                ArrayList<AccountPayOrder.AccountPayOrderExt.SplitBillRule> splitBillRules = new ArrayList<>();
-                sbm.forEach((key, value) -> {
-                    /**
-                     *   不是自己的splitcode分走,是自己的不动
-                     *   把成本之外的金额加入splitRule分账参数,延续上面逻辑,供应商自己的成本由自己的商户号收款,
-                     *   自己成本部分不需要加入分账参数,仅需在else中做业务表参数处理
-                     */
-                    if (!key.equals(shopOrder.getSplitCode())) {
-                        // 佣金
-                        AccountPayOrder.AccountPayOrderExt.SplitBillRule splitBillRule = new AccountPayOrder.AccountPayOrderExt.SplitBillRule();
-                        // 分账计算的时候未处理手续费,总额处理手续费   x + x * 0.1% = value
-                        BigDecimal div = MathUtil.div(value, 1.001, 2);
-                        if (MathUtil.sub(value, div).doubleValue() < 0.01) {
-                            // 如果手续费小于最低手续费,取0.01
-                            div = MathUtil.round(MathUtil.sub(value, 0.01), 2);
+                    splitBillRule.setSplitBillAmount(div);
+                    splitBillRule.setSplitBillMerchantNo(key);
+                    splitBillRules.add(splitBillRule);
+                } else {
+                    // 修改子订单付款状态及付款金额
+                    newOrderDao.updateShopOrderByPayStatus(Integer.valueOf(i), value.doubleValue(), shopOrder.getPayStatus());
+                    SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                    String currentTime2 = format2.format(new Date());
+                    // 保存付款单表
+                    PayShopPo payShop = new PayShopPo();
+                    payShop.setShopId(shopOrder.getShopId());
+                    payShop.setName("线上支付分账");
+                    payShop.setTotalAmount(value.doubleValue());
+                    payShop.setWipePayment(0d);
+                    payShop.setPayType(6);
+                    payShop.setStatus(1);
+                    payShop.setDelFlag(0);
+                    payShop.setApplyTime(currentTime2);
+                    payShop.setReviewTime(currentTime2);
+                    payShop.setPayTime(currentTime2);
+                    newOrderDao.insertPayShop(payShop);
+                    // 保存 付供应商记录
+                    PayShopRecordPo shopRecord = new PayShopRecordPo();
+                    shopRecord.setShopId(shopOrder.getShopId());
+                    shopRecord.setShopOrderId(shopOrder.getShopOrderId());
+                    shopRecord.setShopOrderNo(shopOrder.getShopOrderNo());
+                    shopRecord.setPayAmount(value.doubleValue());
+                    shopRecord.setWipePayment(0d);
+                    shopRecord.setPayType(6);
+                    shopRecord.setPayTime(currentTime2);
+                    shopRecord.setPayShopId(payShop.getId());
+                    shopRecord.setStatus(1);
+                    shopRecord.setDelFlag(0);
+                    newOrderDao.insertPayShopRecord(shopRecord);
+                    // 子订单是否全部付款
+                    List<String> payStatus = newShopOrderDao.findPayStatusByOrderID(shopOrder.getOrderId());
+                    boolean isPay = true;
+                    for (String shops : payStatus) {
+                        if (!"3".equals(shops)) {
+                            isPay = false;
+                            break;
                         }
-                        splitBillRule.setSplitBillAmount(div);
-                        splitBillRule.setSplitBillMerchantNo(key);
-                        splitBillRules.add(splitBillRule);
+                    }
+                    // 修改主订单付款状态
+                    if (isPay) {
+                        newOrderDao.updateOrderByPayStatus(shopOrder.getOrderId(), 3);
                     } else {
-                        /**
-                         *  成本分账处理
-                         *  子订单的splitcode和分账对象的splitcode一样的是留在账户里的钱,实际在付款完成后,付款状态就为已付款,分账状态就为已分账
-                         *  为维持业务完整性,保持原来的分账流程不变
-                         */
-                        List<SplitAccountPo> splitAccountList = newOrderDao.getSplitAccountList(orderRelation.getMbOrderId());
-                        if (splitAccountList != null && splitAccountList.size() > 0) {
-                            Integer orderId = splitAccountList.get(0).getOrderId();
-                            List<ShopOrderVo> shopOrderList = newOrderDao.getShopOrderByOrderId(orderId);
-                            Integer shopOrderId = null;
-                            String shopOrderNo = "";
-                            for (SplitAccountPo account : splitAccountList) {
-                                // 本次付供应商金额(分账金额)
-                                Double splitAmount = account.getSplitAccount();
-                                orderId = account.getOrderId();
-                                Integer shopId = account.getShopId();
-                                for (ShopOrderVo shop : shopOrderList) {
-                                    if (shopId.equals(shop.getShopId())) {
-                                        shopOrderId = shop.getShopOrderId();
-                                        shopOrderNo = shop.getShopOrderNo();
-                                        // 已付供应商金额
-                                        Double paidAmount = newOrderDao.getPaidShopAmount(shopOrderId);
-                                        Double paidShop = MathUtil.add(paidAmount, splitAmount).doubleValue();
-                                        shopOrder.setPayedShopAmount(paidShop);
-                                        if (MathUtil.compare(shopOrder.getShouldPayShopAmount(), paidShop) == 0) {
-                                            shopOrder.setPayStatus(3);
-                                        } else {
-                                            shopOrder.setPayStatus(2);
-                                        }
-                                        // 修改子订单付款状态及付款金额
-                                        newOrderDao.updateShopOrderByPayStatus(shopOrderId, paidShop, shopOrder.getPayStatus());
-                                    }
-                                }
-                                SimpleDateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                                String currentTime2 = format2.format(new Date());
-                                // 保存付款单表
-                                PayShopPo payShop = new PayShopPo();
-                                payShop.setShopId(shopId);
-                                payShop.setName("线上支付分账");
-                                payShop.setTotalAmount(splitAmount);
-                                payShop.setWipePayment(0d);
-                                payShop.setPayType(6);
-                                payShop.setStatus(1);
-                                payShop.setDelFlag(0);
-                                payShop.setApplyTime(currentTime2);
-                                payShop.setReviewTime(currentTime2);
-                                payShop.setPayTime(currentTime2);
-                                newOrderDao.insertPayShop(payShop);
-                                // 保存 付供应商记录
-                                PayShopRecordPo shopRecord = new PayShopRecordPo();
-                                shopRecord.setShopId(shopId);
-                                shopRecord.setShopOrderId(shopOrderId);
-                                shopRecord.setShopOrderNo(shopOrderNo);
-                                shopRecord.setPayAmount(splitAmount);
-                                shopRecord.setWipePayment(0d);
-                                shopRecord.setPayType(6);
-                                shopRecord.setPayTime(currentTime2);
-                                shopRecord.setPayShopId(payShop.getId());
-                                shopRecord.setStatus(1);
-                                shopRecord.setDelFlag(0);
-                                newOrderDao.insertPayShopRecord(shopRecord);
-                            }
-                            // 子订单是否全部付款
-                            List<String> payStatus = newShopOrderDao.findPayStatusByOrderID(orderRelation.getOrderId());
-                            boolean isPay = true;
-                            for (String shops : payStatus) {
-                                if (!"3".equals(shops)) {
-                                    isPay = false;
-                                    break;
-                                }
-                            }
-                            // 修改主订单付款状态
-                            if (isPay) {
-                                newOrderDao.updateOrderByPayStatus(orderId, 3);
-                            } else {
-                                newOrderDao.updateOrderByPayStatus(orderId, 2);
-                            }
-                        }
+                        newOrderDao.updateOrderByPayStatus(shopOrder.getOrderId(), 2);
                     }
-                });
-                /**
-                 *  在上述else代码逻辑中已完成成本的业务表参数处理,在分账详情中排除成本,剩余佣金部分在分账结束收到
-                 *  成功返回码时处理(成本不参与分账)
-                 */
-                splitBillDetail.removeIf(s -> s.getSubUserNo().equals(shopOrder.getSplitCode()));
-                if (null != splitBillRules && splitBillRules.size() > 0) {
-                    //第三方分账接口
-                    try {
-                        AccountPayOrder accountPayOrder = new AccountPayOrder();
-                        accountPayOrder.setP1_bizType("AccountPaySub");
-                        accountPayOrder.setP2_signType("MD5");
-                        String format1 = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.SSS").format(new Date());
-                        accountPayOrder.setP3_timestamp(format1);
-                        String substring = format1.substring(20);
-                        // fz+当前微秒时间+原唯一订单号
-                        accountPayOrder.setP4_orderId("FZ" + substring + orderRelation.getOrderRequestNo());
-                        //付款账户子订单绑定商户号
-                        accountPayOrder.setP5_customerNumber(shopOrder.getSplitCode());
-                        AccountPayOrder.AccountPayOrderExt accountPayOrderExt = new AccountPayOrder.AccountPayOrderExt();
-                        //收款账户商编  填写splitBillRules时候不填写MerchantNo,Amount并且即使填写这两个参数不生效!!
-                        //accountPayOrderExt.setInMerchantNo(splitMoneyVo.getName());
-                        //accountPayOrderExt.setAmount(splitMoneyVo.getSplitMoney());
-                        accountPayOrderExt.setOrderType(AccountPayOrderType.TRANSFER);
-                        accountPayOrderExt.setServerCallbackUrl(Constant.prodSplit);
-                        accountPayOrderExt.setGoodsName("分账");
-                        if (null != splitBillRules && splitBillRules.size() > 0) {
-                            accountPayOrderExt.setSplitBillRules(splitBillRules);
-                        }
-                        String ext = JSON.toJSONString(accountPayOrderExt);
-                        logger.info("分账规则串json串:" + ext);
-                        accountPayOrder.setP6_ext(ext);
-                        // 生成签名
-                        StringBuilder builder = new StringBuilder();
-                        builder.append(Constant.SPLIT)
-                                .append(accountPayOrder.getP1_bizType()).append(Constant.SPLIT)
-                                .append(accountPayOrder.getP2_signType()).append(Constant.SPLIT)
-                                .append(accountPayOrder.getP3_timestamp()).append(Constant.SPLIT)
-                                .append(accountPayOrder.getP4_orderId()).append(Constant.SPLIT)
-                                .append(accountPayOrder.getP5_customerNumber()).append(Constant.SPLIT)
-                                .append(accountPayOrder.getP6_ext()).append(Constant.SPLIT)
-                                .append(Constant.XUNI);
-                        String sign = Disguiser.disguiseMD5(builder.toString().trim());
-                        Map<String, String> bean = convertBean(accountPayOrder);
-                        logger.info("--------------------> 发送分账参数:  " + bean);
-                        Map<String, String> map = postForm(bean, Constant.FZ, sign, Map.class);
-                        logger.info("----------------分账返回数据: " + map.toString());
-                        if (map != null) {
-                            String code = map.get("rt5_retCode");
-                            if (!"0000".equals(code)) {
-                                String msg = map.get("rt6_retMsg");
-                                logger.info("【手动分账】>>>>>>>>>>手动分账失败>>>>>>>msg:" + msg);
-                            } else {
-                                for (SplitAccountPo splitAccount : splitBillDetail) {
-                                    splitAccount.setMbOrderId(orderRelation.getMbOrderId());
-                                    splitAccount.setOrderRequestNo(orderRelation.getOrderRequestNo());
-                                    splitAccount.setPayStatus(1);
-                                    // 保存分账详情
-                                    newOrderDao.insertSplitAccount(splitAccount);
-                                }
-                                redisService.remove("XSFZMDS");
-                                logger.info("【手动分账】>>>>>>>>>>此订单分账结束");
+                }
+            });
+            /**
+             *  在上述else代码逻辑中已完成成本的业务表参数处理,在分账详情中排除成本,剩余佣金部分在分账结束收到
+             *  成功返回码时处理(成本不参与分账)
+             */
+            splitBillDetail.removeIf(s -> s.getSubUserNo().equals(shopOrder.getSplitCode()));
+            if (null != splitBillRules && splitBillRules.size() > 0) {
+                //第三方分账接口
+                try {
+                    AccountPayOrder accountPayOrder = new AccountPayOrder();
+                    accountPayOrder.setP1_bizType("AccountPaySub");
+                    accountPayOrder.setP2_signType("MD5");
+                    String format1 = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss.SSS").format(new Date());
+                    accountPayOrder.setP3_timestamp(format1);
+                    String substring = format1.substring(20);
+                    // fz+当前微秒时间+原唯一订单号
+                    accountPayOrder.setP4_orderId("FZ" + substring + shopOrder.getShopOrderId());
+                    //付款账户子订单绑定商户号
+                    accountPayOrder.setP5_customerNumber(shopOrder.getSplitCode());
+                    AccountPayOrder.AccountPayOrderExt accountPayOrderExt = new AccountPayOrder.AccountPayOrderExt();
+                    //收款账户商编  填写splitBillRules时候不填写MerchantNo,Amount并且即使填写这两个参数不生效!!
+                    //accountPayOrderExt.setInMerchantNo(splitMoneyVo.getName());
+                    //accountPayOrderExt.setAmount(splitMoneyVo.getSplitMoney());
+                    accountPayOrderExt.setOrderType(AccountPayOrderType.TRANSFER);
+                    accountPayOrderExt.setServerCallbackUrl(Constant.prodSplit);
+                    accountPayOrderExt.setGoodsName("分账");
+                    if (null != splitBillRules && splitBillRules.size() > 0) {
+                        accountPayOrderExt.setSplitBillRules(splitBillRules);
+                    }
+                    String ext = JSON.toJSONString(accountPayOrderExt);
+                    logger.info("分账规则串json串:" + ext);
+                    accountPayOrder.setP6_ext(ext);
+                    // 生成签名
+                    StringBuilder builder = new StringBuilder();
+                    builder.append(Constant.SPLIT)
+                            .append(accountPayOrder.getP1_bizType()).append(Constant.SPLIT)
+                            .append(accountPayOrder.getP2_signType()).append(Constant.SPLIT)
+                            .append(accountPayOrder.getP3_timestamp()).append(Constant.SPLIT)
+                            .append(accountPayOrder.getP4_orderId()).append(Constant.SPLIT)
+                            .append(accountPayOrder.getP5_customerNumber()).append(Constant.SPLIT)
+                            .append(accountPayOrder.getP6_ext()).append(Constant.SPLIT)
+                            .append(Constant.XUNI);
+                    String sign = Disguiser.disguiseMD5(builder.toString().trim());
+                    Map<String, String> bean = convertBean(accountPayOrder);
+                    logger.info("--------------------> 发送分账参数:  " + bean);
+                    Map<String, String> map = postForm(bean, Constant.FZ, sign, Map.class);
+                    logger.info("----------------分账返回数据: " + map.toString());
+                    if (map != null) {
+                        String code = map.get("rt5_retCode");
+                        if (!"0000".equals(code)) {
+                            String msg = map.get("rt6_retMsg");
+                            logger.info("【手动分账】>>>>>>>>>>手动分账失败>>>>>>>msg:" + msg);
+                        } else {
+                            for (SplitAccountPo splitAccount : splitBillDetail) {
+                                splitAccount.setPayStatus(1);
+                                // 保存分账详情
+                                newOrderDao.insertSplitAccount(splitAccount);
                             }
+                            redisService.remove("XSFZMDS");
+                            logger.info("【手动分账】>>>>>>>>>>此订单分账结束");
                         }
-                    } catch (Exception e) {
-                        logger.error("【手动分账】>>>>>>>>>>错误信息", e);
                     }
-                } else {
-                    // 没有佣金分账,全是成本,本笔交易已分帐
-                    newOrderDao.updateBySplitStatus(orderRelation.getMbOrderId());
-                    //没有佣金分账也解锁
-                    redisService.remove("XSFZMDS");
+                } catch (Exception e) {
+                    logger.error("【手动分账】>>>>>>>>>>错误信息", e);
                 }
             }
-        }
+        });
     }
 
 
-    public List<SplitAccountPo> setSplitAccountDetail(ShopOrderVo shopOrder, PayParamBo payParam) {
-        List<SplitAccountPo> list = new ArrayList<>();
-        // 本次支付金额,单位/元
-        double payAmount = payParam.getAllPay();
+    public void setSplitAccountDetail(AtomicReference<Double> costPrice, AtomicReference<Double> organizePrice,
+                                      AtomicReference<Double> cmCostPrice, AtomicReference<Double> total,
+                                      ShopOrderVo shopOrder, OrderReceiptRelationPo orderRelation) {
         // 待分账总金额
-        double splitAmount = payAmount;
+        double splitAmount = orderRelation.getAssociateAmount();
+        total.updateAndGet(v -> MathUtil.add(v, splitAmount).doubleValue());
         // 总手续费
         double procedureFee;
-        if ("UNIONPAY".equals(payParam.getPayWay())) {
+        if (12 == orderRelation.getPayType()) {
             procedureFee = 10.00;
-        } else if ("B2C".equals(payParam.getPayWay())) {
+        } else if (17 == orderRelation.getPayType()) {
             //b2c 0.2%
-            procedureFee = MathUtil.mul(payAmount, 0.002, 2).doubleValue();
+            procedureFee = MathUtil.mul(splitAmount, 0.002, 2).doubleValue();
             //b2c最低手续费0.1
             if (procedureFee < 0.1) {
                 procedureFee = 0.1;
             }
-        } else if ("WX".equals(payParam.getPayWay())) {
+        } else if (13 == orderRelation.getPayType() || 15 == orderRelation.getPayType()) {
             //微信0.65%
-            procedureFee = MathUtil.mul(payAmount, 0.0065, 2).doubleValue();
-        } else if ("DEBIT".equals(payParam.getPayWay())) {
-            procedureFee = MathUtil.mul(payAmount, 0.003, 2).doubleValue();
+            procedureFee = MathUtil.mul(splitAmount, 0.0065, 2).doubleValue();
+        } else if (29 == orderRelation.getPayType()) {
+            procedureFee = MathUtil.mul(splitAmount, 0.003, 2).doubleValue();
             if (procedureFee < 0.1) {
                 procedureFee = 0.1;
             }
-        } else if ("CREDIT".equals(payParam.getPayWay())) {
-            procedureFee = MathUtil.mul(payAmount, 0.006, 2).doubleValue();
+        } else if (30 == orderRelation.getPayType()) {
+            procedureFee = MathUtil.mul(splitAmount, 0.006, 2).doubleValue();
             if (procedureFee < 0.1) {
                 procedureFee = 0.1;
             }
         } else {
             //手续费 其他0.25%
-            procedureFee = MathUtil.mul(payAmount, 0.0025, 2).doubleValue();
+            procedureFee = MathUtil.mul(splitAmount, 0.0025, 2).doubleValue();
         }
         if (MathUtil.compare(procedureFee, 0.01) <= 0) {
             procedureFee = 0.01;
         }
-        //手续费承担方 线上支付手续费:默认1采美承担,2供应商承担
-        Integer supportFlag = newOrderDao.findSupport(shopOrder.getShopOrderId());
-        //减去收款手续费
-        splitAmount = MathUtil.sub(splitAmount, procedureFee).doubleValue();
-
         // 商品数据
         List<OrderProductVo> orderProductList = newOrderDao.getOrderProductByShopOrderId(shopOrder.getShopOrderId());
-
         for (OrderProductVo orderProduct : orderProductList) {
-            // 价格 * 数量 * 供应商成本比例/100
-            double costPrice = MathUtil.mul(orderProduct.getTotalAmount(), orderProduct.getShopPercent() / 100, 2).doubleValue();
-            if (2 == supportFlag) {
-                //供应商自己承担手续费
-                costPrice = MathUtil.sub(costPrice, procedureFee).doubleValue();
-            }
-            /**
-             * todo
-             * 出于兼容性考虑,且多次支付手续费不同,分账方式为循环每次支付记录,
-             * 当前业务满足子订单支付完成才进行分账,可以循环子订单统计支付金额,
-             * 进行一次性分账,在当前模式下如果用户分多次支付,精度损失问题较为常见。
+            /**   价格 * 数量
+             *    前版本为全比例成本,当前版本重新加回固定成本,新增字段cmCostPrice(平台服务费,分帐分采美),organizeCostPrice(组织/集团成本。分帐分组织)
+             *    在此规则下,分帐方式取cop固定成本值。因存在成本修改,不能取cm_sku实时更新成本!
              */
-            // 判断是否支付过
-            Double paidAmount = newOrderDao.getOrderProductPaidAmount(orderProduct.getOrderProductId());
-            // 支付过金额大于0
-            if (null != paidAmount && MathUtil.compare(paidAmount, 0) > 0) {
-                //已付>0,成本-已付
-                costPrice = MathUtil.sub(costPrice, paidAmount).doubleValue();
-            }
-            // 待分账金额>成本
-            if (MathUtil.compare(splitAmount, costPrice) > 0) {
-                // 待分账金额-成本
-                splitAmount = MathUtil.sub(splitAmount, costPrice).doubleValue();
-            } else {
-                costPrice = splitAmount;
-                splitAmount = 0.00;
-            }
-            if (costPrice > 0) {
-                SplitAccountPo splitAccount = new SplitAccountPo();
-                splitAccount.setShopOrderId(shopOrder.getShopOrderId());
-                splitAccount.setOrderId(shopOrder.getOrderId());
-                splitAccount.setOrderProductId(orderProduct.getOrderProductId());
-                splitAccount.setShopId(orderProduct.getShopId());
-                splitAccount.setSplitAccount(costPrice);
-                splitAccount.setProductType(1);
-                // 该商品设置了商户号
-                splitAccount.setType(4);
-                splitAccount.setSubUserNo(shopOrder.getSplitCode());
-                logger.info("成本分账参数------------->" + splitAccount.toString());
-                list.add(splitAccount);
-            }
-            if (MathUtil.compare(splitAmount, 0) == 0) {
-                break;
-            }
+            costPrice.updateAndGet(v -> MathUtil.add(v, MathUtil.mul(orderProduct.getCostPrice(), orderProduct.getNum(), 2)).doubleValue());
+            organizePrice.updateAndGet(v -> MathUtil.add(v, MathUtil.mul(orderProduct.getOrganizeCostPrice(), orderProduct.getNum(), 2)).doubleValue());
+            cmCostPrice.updateAndGet(v -> MathUtil.add(v, MathUtil.mul(orderProduct.getCmCostPrice(), orderProduct.getNum(), 2)).doubleValue());
         }
-        // 如果还有钱则为佣金,分到网络
-        if (MathUtil.compare(splitAmount, 0) > 0) {
-            // 此处不考虑手续费,外部计算总额
-            SplitAccountPo splitAccount = new SplitAccountPo();
-            splitAccount.setOrderId(shopOrder.getOrderId());
-            splitAccount.setShopOrderId(shopOrder.getShopOrderId());
-            splitAccount.setSplitAccount(splitAmount);
-            splitAccount.setProductType(3);
-            splitAccount.setType(5);
-            splitAccount.setSubUserNo(Constant.CUSTOMERNUM2);
-            logger.info("佣金分账参数------------->" + splitAccount);
-            list.add(splitAccount);
+        //手续费承担方 线上支付手续费:默认1采美承担,2供应商承担
+        Integer supportFlag = newOrderDao.findSupport(shopOrder.getShopOrderId());
+        if (2 == supportFlag) {
+            //供应商自己承担手续费
+            costPrice.set(costPrice.get() - procedureFee);
         }
-        return list;
     }
 
     public <T> T postForm(Map<String, String> params, String url, String sign, Class<T> clazz) {

+ 181 - 79
src/main/java/com/caimei/modules/order/web/CmPayShopController.java

@@ -8,11 +8,9 @@ import com.caimei.modules.order.dao.NewOrderDao;
 import com.caimei.modules.order.dao.NewOrderProductDao;
 import com.caimei.modules.order.entity.*;
 import com.caimei.modules.order.service.*;
-import com.caimei.modules.order.utils.OrderUtil;
 import com.caimei.modules.sys.utils.UploadImageUtils;
 import com.caimei.modules.user.entity.CmUserOrganize;
 import com.caimei.modules.user.service.CmUserOrganizeService;
-import com.caimei.redis.RedisService;
 import com.caimei.utils.MathUtil;
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
@@ -20,7 +18,6 @@ import com.thinkgem.jeesite.common.utils.Encodes;
 import com.thinkgem.jeesite.common.utils.StringUtils;
 import com.thinkgem.jeesite.common.web.BaseController;
 import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
-import org.apache.commons.collections.CollectionUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -33,12 +30,12 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import java.io.UnsupportedEncodingException;
 import java.math.BigDecimal;
-import java.net.URLEncoder;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
 
 /**
  * 付款单表Controller
@@ -49,9 +46,6 @@ import java.util.concurrent.atomic.AtomicReference;
 @Controller
 @RequestMapping(value = "${adminPath}/order/cmPayShop")
 public class CmPayShopController extends BaseController {
-    
-    @Resource
-    private RedisService redisService;
     @Resource
     private CmPayShopService cmPayShopService;
     @Resource
@@ -118,6 +112,33 @@ public class CmPayShopController extends BaseController {
         return "modules/order/cmPayFormList";
     }
 
+    @RequiresPermissions("order:cmPayShop:view")
+    @RequestMapping(value = "payList")
+    public String payList(CmPayShop cmPayShop, HttpServletRequest request, HttpServletResponse response, Model model) {
+        if (null != cmPayShop.getStartTime() && !"".equals(cmPayShop.getStartTime()) && !cmPayShop.getStartTime().endsWith("00:00:00")) {
+            model.addAttribute("startTime", cmPayShop.getStartTime());
+            cmPayShop.setStartTime(cmPayShop.getStartTime().trim() + " 00:00:00");
+        }
+        if (null != cmPayShop.getEndTime() && !"".equals(cmPayShop.getEndTime()) && !cmPayShop.getEndTime().endsWith("23:59:59")) {
+            model.addAttribute("endTime", cmPayShop.getEndTime());
+            cmPayShop.setEndTime(cmPayShop.getEndTime().trim() + " 23:59:59");
+        }
+        if (null != cmPayShop.getStartTime2() && !"".equals(cmPayShop.getStartTime2()) && !cmPayShop.getStartTime2().endsWith("00:00:00")) {
+            model.addAttribute("startTime2", cmPayShop.getStartTime2());
+            cmPayShop.setStartTime2(cmPayShop.getStartTime2().trim() + " 00:00:00");
+        }
+        if (null != cmPayShop.getEndTime2() && !"".equals(cmPayShop.getEndTime2()) && !cmPayShop.getEndTime2().endsWith("23:59:59")) {
+            model.addAttribute("endTime2", cmPayShop.getEndTime2());
+            cmPayShop.setEndTime2(cmPayShop.getEndTime2().trim() + " 23:59:59");
+        }
+        Page<CmPayShop> page = cmPayShopService.payThirdPage(new Page<CmPayShop>(request, response), cmPayShop);
+        //获取组织列表
+        List<CmUserOrganize> cmUserOrganizeList = cmUserOrganizeService.findOrganize();
+        model.addAttribute("cmUserOrganizeList", cmUserOrganizeList);
+        model.addAttribute("page", page);
+        return "modules/order/cmPayList";
+    }
+
     @RequiresPermissions("order:cmPayShop:view")
     @RequestMapping(value = "form")
     public String form(CmPayShop cmPayShop, Model model) {
@@ -176,6 +197,10 @@ public class CmPayShopController extends BaseController {
 
     @RequestMapping("saveChangePayShopAmount")
     public String saveChangePayShopAmount(NewShopOrder newShopOrder) {
+        /**
+         * couponAmount 优惠券优惠金额
+         * promotionFullReduction   促销满减优惠(不考虑凑单促销)
+         */
         String shopOrderID = newShopOrder.getId();
         Double freight = newShopOrder.getShopPostFee();
         Double thirdPartyFee = newShopOrder.getShopOtherFee() == null ? 0d : newShopOrder.getShopOtherFee();
@@ -299,16 +324,23 @@ public class CmPayShopController extends BaseController {
         //如果子订单填写了成本方式,那么页面上传过来的成本方式必须和数据库相同
         //子订单的成本方式第一次填写以后就不能修改了
         // 固定成本
-        if ("1".equals(costType)) {
+        //if ("1".equals(costType)) {
             // List<CmReturnedPurchaseProduct> rL = cmReturnedPurchaseProductService.findReturnedByShopOrderID(Integer.parseInt(shopOrderID));
             for (NewOrderProduct product : newOrderProducts) {
                 Integer orderProductID = product.getOrderProductID();
                 Double costPrice = product.getCostPrice() == null ? 0d : product.getCostPrice();
+                Double organizeCostPrice = product.getOrganizeCostPrice() == null ? 0d : product.getOrganizeCostPrice();
+                Double cmCostPrice = product.getCmCostPrice() == null ? 0d : product.getCmCostPrice();
                 if (soZeroCostFlag && costPrice > 0) {
                     soZeroCostFlag = false;
                 }
+                // 在订单商品含税的情况下, 成本计算税费
+                if ("0".equals(product.getIncludedTax()) && null != product.getTaxRate() && product.getTaxRate() > 0d) {
+                    costPrice = MathUtil.add(costPrice, MathUtil.div(MathUtil.mul(costPrice, product.getTaxRate()), 100)).doubleValue();
+                }
+                // product.setSingleShouldPayTotalTax(MathUtil.div(MathUtil.mul(MathUtil.div(product.getCostPrice(), MathUtil.div(MathUtil.add(product.getTaxRate(), 100),100)), product.getSupplierTaxRate()), 100).doubleValue());
                 Double singleShouldPayTotalTax = product.getSingleShouldPayTotalTax() == null ? 0d : product.getSingleShouldPayTotalTax();
-                Double supplierTaxRate = product.getSupplierTaxRate() == null ? 0d : product.getSupplierTaxRate();
+                Double supplierTaxRate = product.getTaxRate() == null ? 0d : product.getTaxRate();
                 // 获取已被退款的商品数量
                 Integer returnNum = newOrderProductDao.CountReturnedPurchaseProduct(Integer.parseInt(shopOrderID), orderProductID);
                 returnNum = returnNum == null ? 0 : returnNum;
@@ -328,14 +360,19 @@ public class CmPayShopController extends BaseController {
                     cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId));
                     cmChangePayShopProduct.setOrderProductId(orderProductID);
                     cmChangePayShopProduct.setOrderProductName(product.getName());
-                    cmChangePayShopProduct.setSupplierTaxRate(orderProduct.getSupplierTaxRate());
+                    // 同步使用机构税率 作为供应商税率
+                    cmChangePayShopProduct.setSupplierTaxRate(product.getTaxRate());
                     cmChangePayShopProduct.setCostPrice(orderProduct.getNewCostPrice());
                     cmChangePayShopProduct.setSingleShouldPayTotalTax(orderProduct.getSingleShouldPayTotalTax());
                     cmChangePayShopProductService.save(cmChangePayShopProduct);
                 }
 
                 orderProduct.setCostPrice(costPrice);
+                orderProduct.setOrganizeCostPrice(organizeCostPrice);
+                orderProduct.setCmCostPrice(cmCostPrice);
+                // 同步使用机构税率 作为供应商税率
                 orderProduct.setSupplierTaxRate(supplierTaxRate);
+                orderProduct.setTaxRate(product.getTaxRate());
                 orderProduct.setSingleShouldPayTotalTax(singleShouldPayTotalTax);
                 orderProducts.add(orderProduct);
                 int num = orderProduct.getNum() == null ? 0 : orderProduct.getNum();
@@ -355,44 +392,101 @@ public class CmPayShopController extends BaseController {
                 cmChangePayShopProduct.setSingleShouldPayTotalTax(product.getSingleShouldPayTotalTax());
                 cmChangePayShopProductService.save(cmChangePayShopProduct);
             }
-            shopOrder.setShopTaxFee(totalTaxesFee); //总税费
-            shopOrder.setShopProductAmount(totalCostFee); //商品费
-        }
+            //总税费
+            shopOrder.setShopTaxFee(totalTaxesFee);
+            //商品费
+            shopOrder.setShopProductAmount(totalCostFee);
+        //}
         // 比例成本
-        if ("2".equals(costType)) {
-            // 保存修改之前的记录
-            List<NewOrderProduct> orderProductList = newOrderProductService.getListByShopOrderID(Integer.parseInt(shopOrderID));
-            if (CollectionUtils.isNotEmpty(orderProductList)) {
-                for (NewOrderProduct orderProduct : orderProductList) {
-                    // 修改前
-                    if (StringUtils.isEmpty(dbcostType)) {
-                        CmChangePayShopProduct cmChangePayShopProduct = new CmChangePayShopProduct();
-                        cmChangePayShopProduct.setRecondType("1");
-                        cmChangePayShopProduct.setChangeType("1");
-                        cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId));
-                        cmChangePayShopProduct.setOrderProductId(orderProduct.getOrderProductID());
-                        cmChangePayShopProduct.setOrderProductName(orderProduct.getName());
-                        cmChangePayShopProduct.setSupplierTaxRate(orderProduct.getSupplierTaxRate());
-                        cmChangePayShopProduct.setCostPrice(orderProduct.getCostPrice());
-                        cmChangePayShopProduct.setSingleShouldPayTotalTax(orderProduct.getSingleShouldPayTotalTax());
-                        cmChangePayShopProductService.save(cmChangePayShopProduct);
-                    }
-                    //售价
-                    Double price = orderProduct.getTouchPrice() == null ? orderProduct.getDiscountPrice() : orderProduct.getTouchPrice();
-                    orderProduct.setCostPrice(price * proportional / 100);
-                    orderProducts.add(orderProduct);
-                    if (soZeroCostFlag && orderProduct.getCostPrice() <= 0) {
-                        soZeroCostFlag = false;
-                    }
+        /*if ("2".equals(costType)) {
+            for (NewOrderProduct product : newOrderProducts) {
+                Integer orderProductID = product.getOrderProductID();
+                Double costPrice = product.getCostPrice() == null ? 0d : product.getCostPrice();
+                if (soZeroCostFlag && costPrice > 0) {
+                    soZeroCostFlag = false;
                 }
+                Double singleShouldPayTotalTax = product.getSingleShouldPayTotalTax() == null ? 0d : product.getSingleShouldPayTotalTax();
+                Double supplierTaxRate = product.getSupplierTaxRate() == null ? 0d : product.getSupplierTaxRate();
+                // 获取已被退款的商品数量
+                Integer returnNum = newOrderProductDao.CountReturnedPurchaseProduct(Integer.parseInt(shopOrderID), orderProductID);
+                returnNum = returnNum == null ? 0 : returnNum;
+                NewOrderProduct orderProduct = newOrderProductService.get(String.valueOf(orderProductID));
+                // 修改前
+                if (StringUtils.isEmpty(dbcostType)) {
+                    CmChangePayShopProduct cmChangePayShopProduct = new CmChangePayShopProduct();
+                    cmChangePayShopProduct.setRecondType("1");
+                    cmChangePayShopProduct.setChangeType("1");
+                    cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId));
+                    cmChangePayShopProduct.setOrderProductId(orderProductID);
+                    cmChangePayShopProduct.setOrderProductName(product.getName());
+                    cmChangePayShopProduct.setSupplierTaxRate(orderProduct.getSupplierTaxRate());
+                    cmChangePayShopProduct.setCostPrice(orderProduct.getNewCostPrice());
+                    cmChangePayShopProduct.setSingleShouldPayTotalTax(orderProduct.getSingleShouldPayTotalTax());
+                    cmChangePayShopProductService.save(cmChangePayShopProduct);
+                }
+                // 设置比例
+                orderProduct.setShopPercent(product.getShopPercent());
+                orderProduct.setOrganizePercent(product.getOrganizePercent());
+                orderProduct.setCmPercent(product.getCmPercent());
+                //售价
+                Double price = orderProduct.getTouchPrice() == null ? orderProduct.getDiscountPrice() : orderProduct.getTouchPrice();
+                // 成本 = 售价 * 供应商比例
+                orderProduct.setCostPrice(price * product.getShopPercent() / 100);
+                orderProduct.setSupplierTaxRate(supplierTaxRate);
+                orderProduct.setSingleShouldPayTotalTax(singleShouldPayTotalTax);
+                int num = orderProduct.getNum() == null ? 0 : orderProduct.getNum();
+                int presentNum = orderProduct.getPresentNum() == null ? 0 : orderProduct.getPresentNum();
+                totalCostFee += (num + presentNum - returnNum) * costPrice;
+                orderProduct.setShouldPayTotalTax(singleShouldPayTotalTax * (num + presentNum - returnNum));
+                totalTaxesFee += singleShouldPayTotalTax * (num + presentNum - returnNum);
+                orderProducts.add(orderProduct);
+                // 修改后
+                CmChangePayShopProduct cmChangePayShopProduct = new CmChangePayShopProduct();
+                cmChangePayShopProduct.setRecondType("2");
+                cmChangePayShopProduct.setChangeType(costType);
+                cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId2));
+                cmChangePayShopProduct.setOrderProductId(orderProductID);
+                cmChangePayShopProduct.setOrderProductName(product.getName());
+                cmChangePayShopProduct.setSupplierTaxRate(supplierTaxRate);
+                cmChangePayShopProduct.setCostPrice(product.getCostPrice());
+                cmChangePayShopProduct.setSingleShouldPayTotalTax(product.getSingleShouldPayTotalTax());
+                cmChangePayShopProductService.save(cmChangePayShopProduct);
             }
+            shopOrder.setShopTaxFee(totalTaxesFee); //总税费
+            shopOrder.setShopProductAmount(totalCostFee); //商品费
+//            // 保存修改之前的记录
+//            List<NewOrderProduct> orderProductList = newOrderProductService.getListByShopOrderID(Integer.parseInt(shopOrderID));
+//            if (CollectionUtils.isNotEmpty(orderProductList)) {
+//                for (NewOrderProduct orderProduct : orderProductList) {
+//                    // 修改前
+//                    if (StringUtils.isEmpty(dbcostType)) {
+//                        CmChangePayShopProduct cmChangePayShopProduct = new CmChangePayShopProduct();
+//                        cmChangePayShopProduct.setRecondType("1");
+//                        cmChangePayShopProduct.setChangeType("1");
+//                        cmChangePayShopProduct.setChangePayShopId(Integer.parseInt(cmChangePayShopRecondId));
+//                        cmChangePayShopProduct.setOrderProductId(orderProduct.getOrderProductID());
+//                        cmChangePayShopProduct.setOrderProductName(orderProduct.getName());
+//                        cmChangePayShopProduct.setSupplierTaxRate(orderProduct.getSupplierTaxRate());
+//                        cmChangePayShopProduct.setCostPrice(orderProduct.getCostPrice());
+//                        cmChangePayShopProduct.setSingleShouldPayTotalTax(orderProduct.getSingleShouldPayTotalTax());
+//                        cmChangePayShopProductService.save(cmChangePayShopProduct);
+//                    }
+//                    //售价
+//                    Double price = orderProduct.getTouchPrice() == null ? orderProduct.getDiscountPrice() : orderProduct.getTouchPrice();
+//                    orderProduct.setCostPrice(price * proportional / 100);
+//                    orderProducts.add(orderProduct);
+//                    if (soZeroCostFlag && orderProduct.getCostPrice() <= 0) {
+//                        soZeroCostFlag = false;
+//                    }
+//                }
+//            }
+//
+//            shopOrder.setProportional(proportional);
+//            shopOrder.setShopTaxFee(0D); //总税费
+//            Double productAmount = shopOrder.getProductAmount();//子订单金额
+//            shopOrder.setShopProductAmount(productAmount * proportional / 100); //商品费
 
-            shopOrder.setProportional(proportional);
-            shopOrder.setShopTaxFee(0D); //总税费
-            Double productAmount = shopOrder.getProductAmount();//子订单金额
-            shopOrder.setShopProductAmount(productAmount * proportional / 100); //商品费
-
-        }
+        }*/
         shopOrder.setPayStatus(soZeroCostFlag ? "3" : "1");
         shopOrder.setZeroCostFlag(soZeroCostFlag ? 1 : 0);
         //当子订单0成本时,若主订单中其他子订单(除了运费子订单)都为0成本,设主订单为已付款,否则设为部分付款
@@ -438,10 +532,11 @@ public class CmPayShopController extends BaseController {
         shopOrder.setModifyShouldPayNote(modifyShouldPayNote);  //备注
         shopOrder.setModifyShouldPayUserID(UserUtils.getUser().getId());  //修改人的用户id
         shopOrder.setModifyShouldPayDate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));  //修改时间
-        double shouldPayShopAmount = shopOrder.getShopProductAmount() + shopOrder.getShopPostFee() + shopOrder.getShopTaxFee();
+        double shouldPayShopAmount = shopOrder.getShopProductAmount() + shopOrder.getShopPostFee(); // + shopOrder.getShopTaxFee();
         if (shopOrder.getPayedShopAmount() != null && shouldPayShopAmount == shopOrder.getPayedShopAmount())
             shopOrder.setPayStatus("3");
-        shopOrder.setShouldPayShopAmount(shouldPayShopAmount);
+        // 付供应商 - 优惠券 - 促销满减优惠
+        shopOrder.setShouldPayShopAmount(MathUtil.sub(shouldPayShopAmount , MathUtil.add(shopOrder.getCouponAmount(), shopOrder.getPromotionFullReduction())).doubleValue());
         newShopOrderService.modifyPayShopAmount(shopOrder, orderProducts);
 
         /*if(shopOrder.getShopReceiptStatus()==1){
@@ -614,23 +709,26 @@ public class CmPayShopController extends BaseController {
 
     @RequestMapping("settleTime")
     @ResponseBody
-    public Map<String, Object> settleTime(@RequestParam("shopOrderId") Integer shopOrderId) {
+    public Map<String, Object> settleTime(@RequestParam("shopOrderIds") String[] shopOrderIds) {
+        List<String> ids = Arrays.stream(shopOrderIds).collect(Collectors.toList());
         Map<String, Object> map = new HashMap<>();
         Calendar instance = Calendar.getInstance();
-        int flag = 0;
+        AtomicInteger flag = new AtomicInteger(0);
         int weekIdx = instance.get(Calendar.DAY_OF_WEEK) - 1;
         String format = new SimpleDateFormat("HH:mm:ss").format(new Date());
         Integer substring = Integer.valueOf(format.substring(0, 2));
-        //当前时间周五下午到周日都返回1不能结算,其他时间看够不够24小时
-        if ((5 == weekIdx && substring > 14) || 6 == weekIdx || 7 == weekIdx) {
-            flag = 1;
-        } else {
-            Integer val = newOrderDao.getSplitTime(shopOrderId);
-            if (val <= 0) {
-                flag = 1;
+        ids.forEach(i->{
+            //当前时间周五下午到周日都返回1不能结算,其他时间看够不够24小时
+            if ((5 == weekIdx && substring > 14) || 6 == weekIdx || 7 == weekIdx) {
+                flag.set(1);
+            } else {
+                Integer val = newOrderDao.getSplitTime(i);
+                if (val <= 0) {
+                    flag.set(1);
+                }
             }
-        }
-        map.put("flag", flag);
+        });
+        map.put("flag", flag.get());
         map.put("msg", "添加成功");
         return map;
     }
@@ -673,13 +771,10 @@ public class CmPayShopController extends BaseController {
 
     @RequestMapping("splitEdit")
     public String splitEdit(String[] shopOrderIDs, RedirectAttributes redirectAttributes, Model model) {
-        splitAccountService.SplitAccount(shopOrderIDs[0]);
 
-//        Page<NewShopOrder> page = newShopOrderService.findSplitList(new Page<NewShopOrder>(),new NewShopOrder());
-//        model.addAttribute("page", page);
+        splitAccountService.SplitAccount(shopOrderIDs);
         addMessage(redirectAttributes, "分账成功!");
         return "redirect:" + Global.getAdminPath() + "/shopOrder/splitList";
-//        return "modules/order/cmSplitAccountList";
     }
 
     /**
@@ -819,25 +914,21 @@ public class CmPayShopController extends BaseController {
      * @return
      */
     @RequestMapping("settlement")
-    public String settlement(Double settleAmount, String shopOrderId, RedirectAttributes redirectAttributes) throws Exception {
-        Double shouldPayShopAmount = newOrderDao.findShouldPayShopAmount(shopOrderId);
-        Double settleSum = newOrderDao.findSettleSum(shopOrderId);
-        if (settleSum >= shouldPayShopAmount) {
-            addMessage(redirectAttributes, "此订单已结算完毕!");
-            return "redirect:" + Global.getAdminPath() + "/shopOrder/settlement";
-        }
-        Integer SDJSS = (Integer) redisService.get("SDJSS");
-        //验锁
-        if (null != SDJSS && SDJSS > 0) {
-            addMessage(redirectAttributes, "请勿短时间内重复结算,等待支付公司返回结算结果!");
-            return "redirect:" + Global.getAdminPath() + "/shopOrder/splitList/?repage";
-        }
-        cmPayShopService.settlement(shopOrderId, settleAmount);
+    public String settlement(String[] shopOrderIds, RedirectAttributes redirectAttributes) throws Exception {
+        List<String> ids = Arrays.stream(shopOrderIds).collect(Collectors.toList());
+        for (String shopOrderId : ids) {
+            Double shouldPayShopAmount = newOrderDao.findShouldPayShopAmount(shopOrderId);
+            Double settleSum = newOrderDao.findSettleSum(shopOrderId);
+            if (settleSum >= shouldPayShopAmount) {
+                addMessage(redirectAttributes, "此订单已结算完毕!");
+                return "redirect:" + Global.getAdminPath() + "/shopOrder/settlement";
+            }
+            cmPayShopService.settlement(shopOrderId);
+        }
         return "redirect:" + Global.getAdminPath() + "/shopOrder/settlement";
     }
 
 
-    ////applyPayWipe
     @RequiresPermissions("order:cmPayShop:edit")
     @RequestMapping("applyPayWipe")
     public String applyPayWipe(CmPayShop cmPayShop, Model model, RedirectAttributes redirectAttributes) {
@@ -923,6 +1014,9 @@ public class CmPayShopController extends BaseController {
             logger.info(e.getMessage());
             e.printStackTrace();
         }
+        if (null != cmPayShop.getRedirectType() && 2 == cmPayShop.getRedirectType()) {
+            return "redirect:" + Global.getAdminPath() + "/order/cmPayShop/payList?repage";
+        }
         return "redirect:" + Global.getAdminPath() + "/order/cmPayShop/?repage";
     }
 
@@ -947,14 +1041,18 @@ public class CmPayShopController extends BaseController {
                 addMessage(redirectAttributes, e.getMessage());
             }
         }
+        if (null != cmPayShop.getRedirectType() && 2 == cmPayShop.getRedirectType()) {
+            return "redirect:" + Global.getAdminPath() + "/order/cmPayShop/payList?repage";
+        }
         return "redirect:" + Global.getAdminPath() + "/order/cmPayShop/?repage";
+
     }
 
     /**
      * 付第三方数据回显
      */
     @RequestMapping("shopOtherFeeForm")
-    public String shopOtherFeeForm(Integer shopOrderId, Model model) {
+    public String shopOtherFeeForm(Integer shopOrderId,Integer payType, Model model) {
         ChangePayShopOther payShopOther = cmPayShopService.shopOtherFeeForm(shopOrderId);
         payShopOther.setShopOrderId(shopOrderId);
         NewShopOrder shopOrder = newShopOrderService.findByShopOrderID(shopOrderId);
@@ -964,6 +1062,7 @@ public class CmPayShopController extends BaseController {
         brokerage = brokerage == null ? 0d : brokerage;
         model.addAttribute("brokerage", brokerage);
         model.addAttribute("payShopOther", payShopOther);
+        model.addAttribute("payType", payType);
         return "modules/order/shopOtherFeeForm";
     }
 
@@ -974,7 +1073,10 @@ public class CmPayShopController extends BaseController {
     public String saveShopOtherFee(ChangePayShopOther payShopOther, RedirectAttributes redirectAttributes) {
         cmPayShopService.saveShopOtherFee(payShopOther);
         addMessage(redirectAttributes, "保存成功");
-        return "redirect:" + Global.getAdminPath() + "/order/cmPayShop/";
+        if ((null != payShopOther.getPayType() && 2 == payShopOther.getPayType()) || 2 == payShopOther.getRedirectType() ) {
+            return "redirect:" + Global.getAdminPath() + "/order/cmPayShop/payList?repage";
+        }
+        return "redirect:" + Global.getAdminPath() + "/order/cmPayShop/?repage";
     }
 
     /**

+ 57 - 17
src/main/java/com/caimei/modules/order/web/CmShopOrderController.java

@@ -7,6 +7,7 @@ import com.caimei.modules.order.service.CmChangePayShopRecondService;
 import com.caimei.modules.order.service.NewShopOrderService;
 import com.caimei.modules.user.entity.CmUserOrganize;
 import com.caimei.modules.user.service.CmUserOrganizeService;
+import com.caimei.utils.MathUtil;
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.utils.StringUtils;
@@ -88,6 +89,37 @@ public class CmShopOrderController extends BaseController {
         return "modules/order/cmPayShopList";
     }
 
+    /**
+     * 申请付第三方
+     * @param newShopOrder
+     * @param request
+     * @param response
+     * @param model
+     * @return
+     */
+    @RequiresPermissions("order:cmPayShop:view")
+    @RequestMapping("payThirdParties")
+    public String payThirdParties(NewShopOrder newShopOrder, HttpServletRequest request, HttpServletResponse response, Model model) {
+        if (null != newShopOrder.getStartTime() && !"".equals(newShopOrder.getStartTime()) && !newShopOrder.getStartTime().endsWith("00:00:00")) {
+            model.addAttribute("startTime", newShopOrder.getStartTime());
+            newShopOrder.setStartTime(newShopOrder.getStartTime().trim() + " 00:00:00");
+        }
+        if (null != newShopOrder.getEndTime() && !"".equals(newShopOrder.getEndTime()) && !newShopOrder.getEndTime().endsWith("23:59:59")) {
+            model.addAttribute("endTime", newShopOrder.getEndTime());
+            newShopOrder.setEndTime(newShopOrder.getEndTime().trim() + " 23:59:59");
+        }
+        Page<NewShopOrder> page = newShopOrderService.payThirdParties(new Page<>(request, response), newShopOrder);
+
+        //获取组织列表
+        List<CmUserOrganize> cmUserOrganizeList = cmUserOrganizeService.findOrganize();
+        model.addAttribute("cmUserOrganizeList", cmUserOrganizeList);
+        model.addAttribute("page", page);
+        model.addAttribute("operatingMode", newShopOrder.getOperatingMode());
+
+        //申请付第三方
+        return "modules/order/payThirdParties";
+    }
+
     @RequiresPermissions("order:cmPayShop:view")
     @RequestMapping("refundRecordList")
     public String refundRecordList(NewShopOrder newShopOrder, HttpServletRequest request, HttpServletResponse response, Model model) {
@@ -164,6 +196,14 @@ public class CmShopOrderController extends BaseController {
         if (CollectionUtils.isNotEmpty(list) && list.size() == 1) {
             dbCostType = list.get(0).getCostType();
         }
+        for (NewOrderProduct p : list.get(0).getNewOrderProducts()) {
+            Double newCostPrice = 0d;
+            newCostPrice = p.getCostPrice();
+            if ("0".equals(p.getIncludedTax()) && null != p.getTaxRate() && p.getTaxRate() > 0d) {
+                p.setCostPrice(MathUtil.div(p.getCostPrice(), MathUtil.div(MathUtil.add(p.getTaxRate(), 100), 100)).doubleValue());
+            }
+            p.setNewCostPrice(newCostPrice);
+        }
         BigDecimal payShopOtherFee = cmPayShopRecordDao.findPayShopOtherFee(newShopOrder.getShopOrderID());
         model.addAttribute("payShopOtherFee", payShopOtherFee);
         model.addAttribute("dbCostType", dbCostType);
@@ -213,16 +253,16 @@ public class CmShopOrderController extends BaseController {
 
     @RequiresPermissions("order:cmPayShop:view")
     @RequestMapping("checkPaymentOrder")
-    public String checkPaymentOrder(NewOrder newOrder, HttpServletRequest request, HttpServletResponse response, Model model) {
-        if (null != newOrder.getStartTime() && !"".equals(newOrder.getStartTime()) && !newOrder.getStartTime().endsWith("00:00:00")) {
-            model.addAttribute("startTime", newOrder.getStartTime());
-            newOrder.setStartTime(newOrder.getStartTime().trim() + " 00:00:00");
+    public String checkPaymentOrder(NewShopOrder newShopOrder, HttpServletRequest request, HttpServletResponse response, Model model) {
+        if (null != newShopOrder.getStartTime() && !"".equals(newShopOrder.getStartTime()) && !newShopOrder.getStartTime().endsWith("00:00:00")) {
+            model.addAttribute("startTime", newShopOrder.getStartTime());
+            newShopOrder.setStartTime(newShopOrder.getStartTime().trim() + " 00:00:00");
         }
-        if (null != newOrder.getEndTime() && !"".equals(newOrder.getEndTime()) && !newOrder.getEndTime().endsWith("23:59:59")) {
-            model.addAttribute("endTime", newOrder.getEndTime());
-            newOrder.setEndTime(newOrder.getEndTime().trim() + " 23:59:59");
+        if (null != newShopOrder.getEndTime() && !"".equals(newShopOrder.getEndTime()) && !newShopOrder.getEndTime().endsWith("23:59:59")) {
+            model.addAttribute("endTime", newShopOrder.getEndTime());
+            newShopOrder.setEndTime(newShopOrder.getEndTime().trim() + " 23:59:59");
         }
-        Page<NewOrder> page = newShopOrderService.findPaymentOrderList(new Page<NewOrder>(request, response), newOrder);
+        Page<NewShopOrder> page = newShopOrderService.findPaymentOrderList(new Page<NewShopOrder>(request, response), newShopOrder);
         List<CmUserOrganize> organizeList = cmUserOrganizeService.findOrganize();
         model.addAttribute("page", page);
         model.addAttribute("organizeList", organizeList);
@@ -235,23 +275,23 @@ public class CmShopOrderController extends BaseController {
      */
     @RequiresPermissions("order:cmPayShop:view")
     @RequestMapping("refundRecord")
-    public String refundRecord(Integer orderID, Model model) {
-        NewOrder order = newShopOrderService.findRefundRecord(orderID);
-        List<Integer> shopOrderIDs = newShopOrderService.findIDsByOrderID(orderID);
+    public String refundRecord(Integer shopOrderId, Model model) {
+        NewShopOrder shopOrder = newShopOrderService.findRefundRecord(shopOrderId);
+        // List<Integer> shopOrderIDs = newShopOrderService.findIDsByOrderID(orderID);
         List<CmPayShopRecord> pr = new ArrayList<>();
         List<CmRefundShopRecord> rr = new ArrayList<>();
         List<CmDiscernReceipt> receipts = new ArrayList<>();
-        for (Integer shopOrderID : shopOrderIDs) {
-            List<CmPayShopRecord> payShopRecordList = newShopOrderService.getPayedRecords(shopOrderID.toString());
+        // for (Integer shopOrderID : shopOrderIDs) {
+            List<CmPayShopRecord> payShopRecordList = newShopOrderService.getPayedRecords(shopOrderId.toString());
             pr.addAll(payShopRecordList);
-            List<CmRefundShopRecord> refundShopRecordList = newShopOrderService.getRefundedRecords(shopOrderID.toString());
+            List<CmRefundShopRecord> refundShopRecordList = newShopOrderService.getRefundedRecords(shopOrderId.toString());
             rr.addAll(refundShopRecordList);
-            List<CmDiscernReceipt> receiptList = newShopOrderService.getDiscernReceipts(shopOrderID);
+            List<CmDiscernReceipt> receiptList = newShopOrderService.getDiscernReceipts(shopOrderId);
             receipts.addAll(receiptList);
-        }
+        // }
         model.addAttribute("pr", pr);
         model.addAttribute("rr", rr);
-        model.addAttribute("order", order);
+        model.addAttribute("shopOrder", shopOrder);
         model.addAttribute("receipts", receipts);
         return "modules/order/refundRecord";
     }

+ 2 - 1
src/main/java/com/caimei/modules/order/web/NewOrderController.java

@@ -1221,7 +1221,8 @@ public class NewOrderController extends BaseController {
     @RequestMapping("detail")
     public String detail(NewOrder order, Model model) {
         if(order.getShopOrderID()!=null){
-            List<NewShopOrder>  newShopOrders= order.getNewShopOrders().stream().filter(newShopOrder -> newShopOrder.getShopOrderID().equals(order.getShopOrderID())).collect(Collectors.toList());
+            List<NewShopOrder>  newShopOrders= order.getNewShopOrders().stream()
+                    .filter(newShopOrder -> newShopOrder.getShopOrderID().equals(order.getShopOrderID())).collect(Collectors.toList());
             order.setNewShopOrders(newShopOrders);
         }
         BpClause bpClause = new BpClause();

+ 2 - 2
src/main/java/com/caimei/modules/product/dao/CmOrganizeProductInfoMapper.java

@@ -74,8 +74,8 @@ public interface CmOrganizeProductInfoMapper extends CrudDao<CmOrganizeProductIn
     /**
      * 批量修改商品组织信息(采购平台独立字段)
      *
-     * @param organizeIds 需要删除的数据主键集合
+     * @param organizeId
      * @return 结果
      */
-    public int updateNotCmOrganizeProductInfos(@Param("organizeIds") Integer[] organizeIds,  @Param("productId")Integer productId,@Param("validFlag")Integer validFlag);
+    int updateNotCmOrganizeProductInfos(@Param("organizeId") Integer organizeId,  @Param("productId")Integer productId,@Param("costCheckFlag") Integer costCheckFlag,@Param("validFlag")Integer validFlag);
 }

+ 2 - 0
src/main/java/com/caimei/modules/product/dao/CmPromotionDao.java

@@ -111,4 +111,6 @@ public interface CmPromotionDao extends CrudDao<CmPromotion> {
     void deleteOldTouchPrice(String promotionId);
 
     void insertNewTouchPrice(@Param("skuId")Integer skuId,@Param("touchPrice") Double touchPrice,@Param("promotionId")  String promotionId);
+
+    Integer findShopId(Integer productID);
 }

+ 2 - 8
src/main/java/com/caimei/modules/product/dao/ProductDao.java

@@ -59,14 +59,6 @@ public interface ProductDao extends CrudDao<Product> {
      */
      List<GiftProduct> getGiftProductInfo(GiftProduct giftProduct);
 
-    /**
-     * 后去商品购买库存
-     *
-     * @param productId
-     * @return
-     */
-     Sku getProductSku(@Param("productId") Integer productId);
-
     /**
      * 更新赠送
      *
@@ -196,6 +188,8 @@ public interface ProductDao extends CrudDao<Product> {
 
     List<CmSku> findSkuList(Integer productID);
 
+    Integer getCostCheckFlag(@Param("productId") Integer productId,@Param("organizeId") Integer organizeId);
+
     List<CmSku> findSkuListProduct(Integer productID);
 
     List<CmSku> findSkuOrganizeList(Integer productID);

+ 12 - 0
src/main/java/com/caimei/modules/product/entity/CmOrganizeProductInfo.java

@@ -28,6 +28,10 @@ public class CmOrganizeProductInfo  extends DataEntity<CmOrganizeProductInfo> im
      * 商品id
      */
     private Integer productId;
+    /**
+     * 成本类型:1固定成本 2比例成本
+     */
+    private Integer costCheckFlag;
     /**
      * 0逻辑删除 1待审核 2已上架 3已下架 8审核未通过 9已隐身 10已冻结
      */
@@ -49,6 +53,14 @@ public class CmOrganizeProductInfo  extends DataEntity<CmOrganizeProductInfo> im
         this.productId = productId;
     }
 
+    public Integer getCostCheckFlag() {
+        return costCheckFlag;
+    }
+
+    public void setCostCheckFlag(Integer costCheckFlag) {
+        this.costCheckFlag = costCheckFlag;
+    }
+
     public Integer getValidFlag() {
         return validFlag;
     }

+ 19 - 1
src/main/java/com/caimei/modules/product/entity/CmSku.java

@@ -24,7 +24,9 @@ public class CmSku extends DataEntity<CmSku> {
     private String stock;        // 库存
     private Integer costCheckFlag;        // 成本价选中标志:1固定成本 2比例成本
     private Double shopPercent;        // 比例成本百分比
-    private Double costPrice;        // 成本价
+    private Double costPrice;        // 供应商成本价
+    private Double organizeCostPrice;        // 集团成本价
+    private Double cmCostPrice;        // 采美成本价
     private Double price;        // 机构价
     private Integer ladderPriceFlag;        // 启用阶梯价格标识 0否 1是
     private Integer minBuyNumber;        // 无阶梯价起订量
@@ -156,6 +158,22 @@ public class CmSku extends DataEntity<CmSku> {
         this.costPrice = costPrice;
     }
 
+    public Double getOrganizeCostPrice() {
+        return organizeCostPrice;
+    }
+
+    public void setOrganizeCostPrice(Double organizeCostPrice) {
+        this.organizeCostPrice = organizeCostPrice;
+    }
+
+    public Double getCmCostPrice() {
+        return cmCostPrice;
+    }
+
+    public void setCmCostPrice(Double cmCostPrice) {
+        this.cmCostPrice = cmCostPrice;
+    }
+
     public Double getPrice() {
         return price;
     }

+ 6 - 1474
src/main/java/com/caimei/modules/product/entity/Product.java

@@ -4,6 +4,7 @@ import com.caimei.modules.brand.entity.CmBrand;
 import com.caimei.po.ProductLadderPrice;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.thinkgem.jeesite.common.persistence.DataEntity;
+import lombok.Data;
 
 import java.beans.Transient;
 import java.math.BigDecimal;
@@ -11,6 +12,7 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
+@Data
 public class Product extends DataEntity<Product> {
     private String name;
     private String shopName;//供应商名称
@@ -70,6 +72,7 @@ public class Product extends DataEntity<Product> {
     private String shopPercent;        // 比例成本百分比
     private Double sqlShopPercent;     //入数据库字段
     private String costCheckFlag;        // 成本价选中标志:1固定成本 2比例成
+    private String mallCostCheckFlag;        // 成本价选中标志:1固定成本 2比例成
     private String precisehKey;        // 精确关键字
     private String giftFlag;//是否可以参加赠送(0:无法参加,1:可以参加赠送,2:已参加过赠送)
     private String beginTimeStr;//活动开始时间串
@@ -115,7 +118,9 @@ public class Product extends DataEntity<Product> {
     private Double sqlSupplierTaxPoint;//供应商开票税点(基于不含税基础) :增值税默认13%,普通票6%取值范围[0-100]
     private Integer giftNumber;//赠品数量
     private BigDecimal reducedPrice;//优惠价格
-    private String promotionType;//促销类型
+    private String promotionType;//促销类型 1单品促销,2凑单促销,3店铺促销
+
+    private Integer promotionMode;//    促销方式:1优惠,2满减,3满赠
     private String delProductIds;//删除商品id
     private List<Integer> delIdList;//删除商品
     private String sold;//是否已售:0和空未出售,1已出售
@@ -299,1478 +304,5 @@ public class Product extends DataEntity<Product> {
     private Integer orderProductID;
     //税率
     private Double taxRate;
-    public List<CmOrganizeProductInfo> getCmOrganizeProductInfos() {
-        return cmOrganizeProductInfos;
-    }
-
-    public void setCmOrganizeProductInfos(List<CmOrganizeProductInfo> cmOrganizeProductInfos) {
-        this.cmOrganizeProductInfos = cmOrganizeProductInfos;
-    }
-    public String getOrganizeNameValidFlag() {
-        return organizeNameValidFlag;
-    }
-
-    public void setOrganizeNameValidFlag(String organizeNameValidFlag) {
-        this.organizeNameValidFlag = organizeNameValidFlag;
-    }
-
-    public String getLabelIds() {
-        return labelIds;
-    }
-
-    public void setLabelIds(String labelIds) {
-        this.labelIds = labelIds;
-    }
-
-    public String getRelatedLabels() {
-        return relatedLabels;
-    }
-
-    public void setRelatedLabels(String relatedLabels) {
-        this.relatedLabels = relatedLabels;
-    }
-
-    public Integer getSkuId() {
-        return skuId;
-    }
-
-    public void setSkuId(Integer skuId) {
-        this.skuId = skuId;
-    }
-
-    public List<CmSku> getSkuList() {
-        return skuList;
-    }
-
-    public void setSkuList(List<CmSku> skuList) {
-        this.skuList = skuList;
-    }
-
-    public List<CmSku> getMallSkuList() {
-        return mallSkuList;
-    }
-
-    public void setMallSkuList(List<CmSku> mallSkuList) {
-        this.mallSkuList = mallSkuList;
-    }
-
-    public String[] getValidFlagString() {
-        return validFlagString;
-    }
-
-    public void setValidFlagString(String[] validFlagString) {
-        this.validFlagString = validFlagString;
-    }
-
-    public String getQualificationNo() {
-        return qualificationNo;
-    }
-
-    public void setQualificationNo(String qualificationNo) {
-        this.qualificationNo = qualificationNo;
-    }
-
-    public String getProductName() {
-        return productName;
-    }
-
-    public void setProductName(String productName) {
-        this.productName = productName;
-    }
-
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    public String getQualificationTime() {
-        return qualificationTime;
-    }
-
-    public void setQualificationTime(String qualificationTime) {
-        this.qualificationTime = qualificationTime;
-    }
-
-    public String getQualificationLink() {
-        return qualificationLink;
-    }
-
-    public void setQualificationLink(String qualificationLink) {
-        this.qualificationLink = qualificationLink;
-    }
-
-    public Integer getNewProductType() {
-        return newProductType;
-    }
-
-    public void setNewProductType(Integer newProductType) {
-        this.newProductType = newProductType;
-    }
-
-    public Integer getShowFlag() {
-        return showFlag;
-    }
-
-    public void setShowFlag(Integer showFlag) {
-        this.showFlag = showFlag;
-    }
-
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    public String getShowTime() {
-        return showTime;
-    }
-
-    public void setShowTime(String showTime) {
-        this.showTime = showTime;
-    }
-
-
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    public String getNewshowTime() {
-        return newshowTime;
-    }
-
-    public void setNewshowTime(String newshowTime) {
-        this.newshowTime = newshowTime;
-    }
-
-    public Integer getRecommend() {
-        return recommend;
-    }
-
-    public void setRecommend(Integer recommend) {
-        this.recommend = recommend;
-    }
-
-    public Integer getNewvalidFlag() {
-        return newvalidFlag;
-    }
-
-    public void setNewvalidFlag(Integer newvalidFlag) {
-        this.newvalidFlag = newvalidFlag;
-    }
-
-    public String getBeautyActFlag() {
-        return beautyActFlag;
-    }
-
-    public void setBeautyActFlag(String beautyActFlag) {
-        this.beautyActFlag = beautyActFlag;
-    }
-
-    public Integer getAnnounType() {
-        return announType;
-    }
-
-    public void setAnnounType(Integer announType) {
-        this.announType = announType;
-    }
-
-    public Double getSqlShopPercent() {
-        return sqlShopPercent;
-    }
-
-    public void setSqlShopPercent(Double sqlShopPercent) {
-        this.sqlShopPercent = sqlShopPercent;
-    }
-
-    public Double getSqlTaxPoint() {
-        return sqlTaxPoint;
-    }
-
-    public void setSqlTaxPoint(Double sqlTaxPoint) {
-        this.sqlTaxPoint = sqlTaxPoint;
-    }
-
-    public Double getSqlCostPrice() {
-        return SqlCostPrice;
-    }
-
-    public void setSqlCostPrice(Double sqlCostPrice) {
-        SqlCostPrice = sqlCostPrice;
-    }
-
-    public Integer getShopType() {
-        return shopType;
-    }
-
-    public void setShopType(Integer shopType) {
-        this.shopType = shopType;
-    }
-
-    public Double getSqlSupplierTaxPoint() {
-        return sqlSupplierTaxPoint;
-    }
-
-    public void setSqlSupplierTaxPoint(Double sqlSupplierTaxPoint) {
-        this.sqlSupplierTaxPoint = sqlSupplierTaxPoint;
-    }
-
-    public String getCompanyName() {
-        return companyName;
-    }
-
-    public void setCompanyName(String companyName) {
-        this.companyName = companyName;
-    }
-
-    public String getImage1() {
-        return image1;
-    }
-
-    public void setImage1(String image1) {
-        this.image1 = image1;
-    }
-
-    public String getImage2() {
-        return image2;
-    }
-
-    public void setImage2(String image2) {
-        this.image2 = image2;
-    }
-
-    public String getImage3() {
-        return image3;
-    }
-
-    public void setImage3(String image3) {
-        this.image3 = image3;
-    }
-
-    public String getImage4() {
-        return image4;
-    }
-
-    public void setImage4(String image4) {
-        this.image4 = image4;
-    }
-
-    public String getImage5() {
-        return image5;
-    }
-
-    public void setImage5(String image5) {
-        this.image5 = image5;
-    }
-
-    public String getSplitCode() {
-        return splitCode;
-    }
-
-    public void setSplitCode(String splitCode) {
-        this.splitCode = splitCode;
-    }
-
-    public Integer getPublishIdentity() {
-        return publishIdentity;
-    }
-
-    public void setPublishIdentity(Integer publishIdentity) {
-        this.publishIdentity = publishIdentity;
-    }
-
-    public String getProductDescribe() {
-        return productDescribe;
-    }
-
-    public void setProductDescribe(String productDescribe) {
-        this.productDescribe = productDescribe;
-    }
-
-    public String getProductDetail() {
-        return productDetail;
-    }
-
-    public void setProductDetail(String productDetail) {
-        this.productDetail = productDetail;
-    }
-
-    public String getCommonDetailInfo() {
-        return commonDetailInfo;
-    }
-
-    public void setCommonDetailInfo(String commonDetailInfo) {
-        this.commonDetailInfo = commonDetailInfo;
-    }
-
-    public List<ProductLadderPrice> getLadderPriceList() {
-        return ladderPriceList;
-    }
-
-    public void setLadderPriceList(List<ProductLadderPrice> ladderPriceList) {
-        this.ladderPriceList = ladderPriceList;
-    }
-
-    public String getProductIds() {
-        return productIds;
-    }
-
-    public void setProductIds(String productIds) {
-        this.productIds = productIds;
-    }
-
-    public String getGroundMall() {
-        return groundMall;
-    }
-
-    public void setGroundMall(String groundMall) {
-        this.groundMall = groundMall;
-    }
-
-    public List<String> getOrganizeNames() {
-        return organizeNames;
-    }
-
-    public void setOrganizeNames(List<String> organizeNames) {
-        this.organizeNames = organizeNames;
-    }
-
-    public BigDecimal getActivityPrice() {
-        return activityPrice;
-    }
-
-    public void setActivityPrice(BigDecimal activityPrice) {
-        this.activityPrice = activityPrice;
-    }
-
-    public boolean isStoreStatus() {
-        return storeStatus;
-    }
-
-    public void setStoreStatus(boolean storeStatus) {
-        this.storeStatus = storeStatus;
-    }
-
-    public String getItemsList() {
-        return itemsList;
-    }
-
-    public void setItemsList(String itemsList) {
-        this.itemsList = itemsList;
-    }
-
-    public List<Integer> getIds() {
-        return ids;
-    }
-
-    public void setIds(List<Integer> ids) {
-        this.ids = ids;
-    }
-
-    private static final long serialVersionUID = 1L;
-
-    public String getDetailInfo() {
-        return detailInfo;
-    }
-
-    public void setDetailInfo(String detailInfo) {
-        this.detailInfo = detailInfo;
-    }
-
-    public String getServiceInfo() {
-        return serviceInfo;
-    }
-
-    public void setServiceInfo(String serviceInfo) {
-        this.serviceInfo = serviceInfo;
-    }
-
-    public String getOrderInfo() {
-        return orderInfo;
-    }
-
-    public void setOrderInfo(String orderInfo) {
-        this.orderInfo = orderInfo;
-    }
-
-    public Product() {
-        super();
-    }
-
-    public Product(String id) {
-        super(id);
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getValidFlag() {
-        return validFlag;
-    }
-
-    public void setValidFlag(String validFlag) {
-        this.validFlag = validFlag;
-    }
-
-    public String getDisplayOnCRMFlag() {
-        return displayOnCRMFlag;
-    }
-
-    public void setDisplayOnCRMFlag(String displayOnCRMFlag) {
-        this.displayOnCRMFlag = displayOnCRMFlag;
-    }
-
-    public Integer getProductID() {
-        return productID;
-    }
-
-    public void setProductID(Integer productID) {
-        this.productID = productID;
-    }
-
-    public Integer getBrandID() {
-        return brandID;
-    }
-
-    public void setBrandID(Integer brandID) {
-        this.brandID = brandID;
-    }
-
-    public Integer getTinyTypeID() {
-        return tinyTypeID;
-    }
-
-    public void setTinyTypeID(Integer tinyTypeID) {
-        this.tinyTypeID = tinyTypeID;
-    }
-
-    public Integer getShopID() {
-        return shopID;
-    }
-
-    public void setShopID(Integer shopID) {
-        this.shopID = shopID;
-    }
-
-    public String getSearchKey() {
-        return searchKey;
-    }
-
-    public void setSearchKey(String searchKey) {
-        this.searchKey = searchKey;
-    }
-
-    public String getPriceFlag() {
-        return priceFlag;
-    }
-
-    public void setPriceFlag(String priceFlag) {
-        this.priceFlag = priceFlag;
-    }
-
-
-    public String getLadderPriceFlag() {
-        return ladderPriceFlag;
-    }
-
-    public void setLadderPriceFlag(String ladderPriceFlag) {
-        this.ladderPriceFlag = ladderPriceFlag;
-    }
-
-    public String getStock() {
-        return stock;
-    }
-
-    public void setStock(String stock) {
-        this.stock = stock;
-    }
-
-    public String getHasSkuFlag() {
-        return hasSkuFlag;
-    }
-
-    public void setHasSkuFlag(String hasSkuFlag) {
-        this.hasSkuFlag = hasSkuFlag;
-    }
-
-    public String getMainImage() {
-        return mainImage;
-    }
-
-    public void setMainImage(String mainImage) {
-        this.mainImage = mainImage;
-    }
-
-    public String getPropertiesInfo() {
-        return propertiesInfo;
-    }
-
-    public void setPropertiesInfo(String propertiesInfo) {
-        this.propertiesInfo = propertiesInfo;
-    }
-
-    public String getAddTime() {
-        return addTime;
-    }
-
-    public void setAddTime(String addTime) {
-        this.addTime = addTime;
-    }
-
-    public String getUpdateTime() {
-        return updateTime;
-    }
-
-    public void setUpdateTime(String updateTime) {
-        this.updateTime = updateTime;
-    }
-
-    public String getSellNumber() {
-        return sellNumber;
-    }
-
-    public void setSellNumber(String sellNumber) {
-        this.sellNumber = sellNumber;
-    }
-
-    public String getBeforeValidFlag() {
-        return beforeValidFlag;
-    }
-
-    public void setBeforeValidFlag(String beforeValidFlag) {
-        this.beforeValidFlag = beforeValidFlag;
-    }
-
-    public String getFavoriteTimes() {
-        return favoriteTimes;
-    }
-
-    public void setFavoriteTimes(String favoriteTimes) {
-        this.favoriteTimes = favoriteTimes;
-    }
-
-    public String getCommentScore() {
-        return commentScore;
-    }
-
-    public void setCommentScore(String commentScore) {
-        this.commentScore = commentScore;
-    }
-
-    public String getCommentTimes() {
-        return commentTimes;
-    }
-
-    public void setCommentTimes(String commentTimes) {
-        this.commentTimes = commentTimes;
-    }
-
-    public String getSortIndex() {
-        return sortIndex;
-    }
-
-    public void setSortIndex(String sortIndex) {
-        this.sortIndex = sortIndex;
-    }
-
-    public String getFeaturedFlag() {
-        return featuredFlag;
-    }
-
-    public void setFeaturedFlag(String featuredFlag) {
-        this.featuredFlag = featuredFlag;
-    }
-
-    public String getFeaturedSortIndex() {
-        return featuredSortIndex;
-    }
-
-    public void setFeaturedSortIndex(String featuredSortIndex) {
-        this.featuredSortIndex = featuredSortIndex;
-    }
-
-    public String getProductCode() {
-        return productCode;
-    }
-
-    public void setProductCode(String productCode) {
-        this.productCode = productCode;
-    }
-
-    public String getUnit() {
-        return unit;
-    }
-
-    public void setUnit(String unit) {
-        this.unit = unit;
-    }
-
-    public String getAllAreaFlag() {
-        return allAreaFlag;
-    }
-
-    public void setAllAreaFlag(String allAreaFlag) {
-        this.allAreaFlag = allAreaFlag;
-    }
-
-    public String getProvinceIDs() {
-        return provinceIDs;
-    }
-
-    public void setProvinceIDs(String provinceIDs) {
-        this.provinceIDs = provinceIDs;
-    }
-
-    public String getServiceNumber() {
-        return serviceNumber;
-    }
-
-    public void setServiceNumber(String serviceNumber) {
-        this.serviceNumber = serviceNumber;
-    }
-
-    public String getMaxBuyNumber() {
-        return maxBuyNumber;
-    }
-
-    public void setMaxBuyNumber(String maxBuyNumber) {
-        this.maxBuyNumber = maxBuyNumber;
-    }
-
-    public String getMinBuyNumber() {
-        return minBuyNumber;
-    }
-
-    public void setMinBuyNumber(String minBuyNumber) {
-        this.minBuyNumber = minBuyNumber;
-    }
-
-    public String getPackageCount() {
-        return packageCount;
-    }
-
-    public void setPackageCount(String packageCount) {
-        this.packageCount = packageCount;
-    }
-
-    public String getByFlag() {
-        return byFlag;
-    }
-
-    public void setByFlag(String byFlag) {
-        this.byFlag = byFlag;
-    }
-
-    public String getNormalProductFlag() {
-        return normalProductFlag;
-    }
-
-    public void setNormalProductFlag(String normalProductFlag) {
-        this.normalProductFlag = normalProductFlag;
-    }
-
-    public String getStep() {
-        return step;
-    }
-
-    public void setStep(String step) {
-        this.step = step;
-    }
-
-    public String getActFlag() {
-        return actFlag;
-    }
-
-    public void setActFlag(String actFlag) {
-        this.actFlag = actFlag;
-    }
-
-    public String getActType() {
-        return actType;
-    }
-
-    public void setActType(String actType) {
-        this.actType = actType;
-    }
-
-    public Date getOnlineTime() {
-        return onlineTime;
-    }
-
-    public void setOnlineTime(Date onlineTime) {
-        this.onlineTime = onlineTime;
-    }
-
-    public Date getDownlineTime() {
-        return downlineTime;
-    }
-
-    public void setDownlineTime(Date downlineTime) {
-        this.downlineTime = downlineTime;
-    }
-
-    public String getFreePostFlag() {
-        return freePostFlag;
-    }
-
-    public void setFreePostFlag(String freePostFlag) {
-        this.freePostFlag = freePostFlag;
-    }
-
-    public String getCostPrice() {
-        return costPrice;
-    }
-
-    public void setCostPrice(String costPrice) {
-        this.costPrice = costPrice;
-    }
-
-    public String getShopPercent() {
-        return shopPercent;
-    }
-
-    public void setShopPercent(String shopPercent) {
-        this.shopPercent = shopPercent;
-    }
-
-    public String getCostCheckFlag() {
-        return costCheckFlag;
-    }
-
-    public void setCostCheckFlag(String costCheckFlag) {
-        this.costCheckFlag = costCheckFlag;
-    }
-
-    public String getPrecisehKey() {
-        return precisehKey;
-    }
-
-    public void setPrecisehKey(String precisehKey) {
-        this.precisehKey = precisehKey;
-    }
-
-    public String getShopName() {
-        return shopName;
-    }
-
-    public void setShopName(String shopName) {
-        this.shopName = shopName;
-    }
-
-    public String getGiftFlag() {
-        return giftFlag;
-    }
-
-    public void setGiftFlag(String giftFlag) {
-        this.giftFlag = giftFlag;
-    }
-
-    public Double getNormalPrice() {
-        return normalPrice;
-    }
-
-    public void setNormalPrice(Double normalPrice) {
-        this.normalPrice = normalPrice;
-    }
-
-    public Double getPrice() {
-        return price;
-    }
-
-    public void setPrice(Double price) {
-        this.price = price;
-    }
-
-    public String getBeginTimeStr() {
-        return beginTimeStr;
-    }
-
-    public void setBeginTimeStr(String beginTimeStr) {
-        this.beginTimeStr = beginTimeStr;
-    }
-
-    public String getEndTimeStr() {
-        return endTimeStr;
-    }
-
-    public void setEndTimeStr(String endTimeStr) {
-        this.endTimeStr = endTimeStr;
-    }
-
-    public String getActStatus() {
-        return actStatus;
-    }
-
-    public void setActStatus(String actStatus) {
-        this.actStatus = actStatus;
-    }
-
-    @Transient
-    public boolean isCustomClass() {
-        return customClass;
-    }
-
-    public void setCustomClass(boolean customClass) {
-        this.customClass = customClass;
-    }
-
-    @Transient
-    public String getBrandName() {
-        return brandName;
-    }
-
-    public void setBrandName(String brandName) {
-        this.brandName = brandName;
-    }
-
-    public String getOtherBrandName() {
-        return otherBrandName;
-    }
-
-    public void setOtherBrandName(String otherBrandName) {
-        this.otherBrandName = otherBrandName;
-    }
-
-    @Transient
-    public String getDefaultType() {
-        return defaultType;
-    }
-
-    public void setDefaultType(String defaultType) {
-        this.defaultType = defaultType;
-    }
-
-    @Transient
-    public String getDefaultTypeName() {
-        return defaultTypeName;
-    }
-
-    public void setDefaultTypeName(String defaultTypeName) {
-        this.defaultTypeName = defaultTypeName;
-    }
-
-    public String getActSort() {
-        return actSort;
-    }
-
-    public void setActSort(String actSort) {
-        this.actSort = actSort;
-    }
-
-    public Integer getBigTypeID() {
-        return bigTypeID;
-    }
-
-    public void setBigTypeID(Integer bigTypeID) {
-        this.bigTypeID = bigTypeID;
-    }
-
-    public Integer getSmallTypeID() {
-        return smallTypeID;
-    }
-
-    public void setSmallTypeID(Integer smallTypeID) {
-        this.smallTypeID = smallTypeID;
-    }
-
-    public String getActTime() {
-        return actTime;
-    }
-
-    public void setActTime(String actTime) {
-        this.actTime = actTime;
-    }
-
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    public Date getActCreateTime() {
-        return actCreateTime;
-    }
-
-    public void setActCreateTime(Date actCreateTime) {
-        this.actCreateTime = actCreateTime;
-    }
-
-    public String getActCreateTimeStr() {
-        return actCreateTimeStr;
-    }
-
-    public void setActCreateTimeStr(String actCreateTimeStr) {
-        this.actCreateTimeStr = actCreateTimeStr;
-    }
-
-    public String getRecommendType() {
-        return recommendType;
-    }
-
-    public void setRecommendType(String recommendType) {
-        this.recommendType = recommendType;
-    }
-
-    public String getSort() {
-        return sort;
-    }
-
-    public void setSort(String sort) {
-        this.sort = sort;
-    }
-
-    public Integer getRecommendProductId() {
-        return recommendProductId;
-    }
-
-    public void setRecommendProductId(Integer recommendProductId) {
-        this.recommendProductId = recommendProductId;
-    }
-
-    public String getExistsFlag() {
-        return existsFlag;
-    }
-
-    public void setExistsFlag(String existsFlag) {
-        this.existsFlag = existsFlag;
-    }
-
-    public Integer getPreferredFlag() {
-        return preferredFlag;
-    }
-
-    public void setPreferredFlag(Integer preferredFlag) {
-        this.preferredFlag = preferredFlag;
-    }
-
-    public String getAliasName() {
-        return aliasName;
-    }
-
-    public void setAliasName(String aliasName) {
-        this.aliasName = aliasName;
-    }
-
-    public String getVisibility() {
-        return visibility;
-    }
-
-    public void setVisibility(String visibility) {
-        this.visibility = visibility;
-    }
-
-    public String getCommodityDetailsFlag() {
-        return commodityDetailsFlag;
-    }
-
-    public void setCommodityDetailsFlag(String commodityDetailsFlag) {
-        this.commodityDetailsFlag = commodityDetailsFlag;
-    }
-
-    public String getTags() {
-        return tags;
-    }
-
-    public void setTags(String tags) {
-        this.tags = tags;
-    }
-
-    public String getMachineType() {
-        return machineType;
-    }
-
-    public void setMachineType(String machineType) {
-        this.machineType = machineType;
-    }
-
-    public Integer getCombinationID() {
-        return combinationID;
-    }
-
-    public void setCombinationID(Integer combinationID) {
-        this.combinationID = combinationID;
-    }
-
-    public Integer getCombinationSort() {
-        return combinationSort;
-    }
-
-    public void setCombinationSort(Integer combinationSort) {
-        this.combinationSort = combinationSort;
-    }
-
-    public String getProductRemarks() {
-        return productRemarks;
-    }
-
-    public void setProductRemarks(String productRemarks) {
-        this.productRemarks = productRemarks;
-    }
-
-    public List<String> getSearchKeyList() {
-        return searchKeyList;
-    }
-
-    public void setSearchKeyList(List<String> searchKeyList) {
-        this.searchKeyList = searchKeyList;
-    }
-
-    public List<ProductParameters> getProductParametersList() {
-        return productParametersList;
-    }
-
-    public String getProductType() {
-        return productType;
-    }
-
-    public void setProductType(String productType) {
-        this.productType = productType;
-    }
-
-    public void setProductParametersList(List<ProductParameters> productParametersList) {
-        this.productParametersList = productParametersList;
-    }
-
-    public String getQualificationImg() {
-        return qualificationImg;
-    }
-
-    public void setQualificationImg(String qualificationImg) {
-        this.qualificationImg = qualificationImg;
-    }
-
-    public String getIncludedTax() {
-        return includedTax;
-    }
-
-    public void setIncludedTax(String includedTax) {
-        this.includedTax = includedTax;
-    }
-
-    public String getInvoiceType() {
-        return invoiceType;
-    }
-
-    public void setInvoiceType(String invoiceType) {
-        this.invoiceType = invoiceType;
-    }
-
-    public String getTaxPoint() {
-        return taxPoint;
-    }
-
-    public void setTaxPoint(String taxPoint) {
-        this.taxPoint = taxPoint;
-    }
-
-    public String getSupplierTaxPoint() {
-        return supplierTaxPoint;
-    }
-
-    public void setSupplierTaxPoint(String supplierTaxPoint) {
-        this.supplierTaxPoint = supplierTaxPoint;
-    }
-
-    public String getSearchName() {
-        return searchName;
-    }
-
-    public void setSearchName(String searchName) {
-        this.searchName = searchName;
-    }
-
-    public String getSearchShopName() {
-        return searchShopName;
-    }
-
-    public void setSearchShopName(String searchShopName) {
-        this.searchShopName = searchShopName;
-    }
-
-    public Integer getSearchShopID() {
-        return searchShopID;
-    }
-
-    public void setSearchShopID(Integer searchShopID) {
-        this.searchShopID = searchShopID;
-    }
-
-    public String getSearchCommodityType() {
-        return searchCommodityType;
-    }
-
-    public void setSearchCommodityType(String searchCommodityType) {
-        this.searchCommodityType = searchCommodityType;
-    }
-
-    public Integer getSearchBigTypeID() {
-        return searchBigTypeID;
-    }
-
-    public void setSearchBigTypeID(Integer searchBigTypeID) {
-        this.searchBigTypeID = searchBigTypeID;
-    }
-
-    public Integer getSearchSmallTypeID() {
-        return searchSmallTypeID;
-    }
-
-    public void setSearchSmallTypeID(Integer searchSmallTypeID) {
-        this.searchSmallTypeID = searchSmallTypeID;
-    }
-
-    public Integer getSearchTinyTypeID() {
-        return searchTinyTypeID;
-    }
-
-    public void setSearchTinyTypeID(Integer searchTinyTypeID) {
-        this.searchTinyTypeID = searchTinyTypeID;
-    }
-
-    public String getSearchValidFlag() {
-        return searchValidFlag;
-    }
-
-    public void setSearchValidFlag(String searchValidFlag) {
-        this.searchValidFlag = searchValidFlag;
-    }
-
-    public String getSearchActStatus() {
-        return searchActStatus;
-    }
-
-    public void setSearchActStatus(String searchActStatus) {
-        this.searchActStatus = searchActStatus;
-    }
-
-    public String getSearchProductType() {
-        return searchProductType;
-    }
-
-    public void setSearchProductType(String searchProductType) {
-        this.searchProductType = searchProductType;
-    }
-
-    public Integer getSearchBrandID() {
-        return searchBrandID;
-    }
-
-    public void setSearchBrandID(Integer searchBrandID) {
-        this.searchBrandID = searchBrandID;
-    }
-
-    public Integer getSearchPreferredFlag() {
-        return searchPreferredFlag;
-    }
-
-    public void setSearchPreferredFlag(Integer searchPreferredFlag) {
-        this.searchPreferredFlag = searchPreferredFlag;
-    }
-
-    public CmBrand getBrand() {
-        return brand;
-    }
-
-    public void setBrand(CmBrand brand) {
-        this.brand = brand;
-    }
-
-    public String getProductCategory() {
-        return productCategory;
-    }
-
-    public void setProductCategory(String productCategory) {
-        this.productCategory = productCategory;
-    }
-
-    public String getSecondHandType() {
-        return secondHandType;
-    }
-
-    public void setSecondHandType(String secondHandType) {
-        this.secondHandType = secondHandType;
-    }
-
-    public String getInstrumentType() {
-        return instrumentType;
-    }
-
-    public void setInstrumentType(String instrumentType) {
-        this.instrumentType = instrumentType;
-    }
-
-    public String getSearchProductCategory() {
-        return searchProductCategory;
-    }
-
-    public void setSearchProductCategory(String searchProductCategory) {
-        this.searchProductCategory = searchProductCategory;
-    }
-
-    public String getEditFlag() {
-        return editFlag;
-    }
-
-    public void setEditFlag(String editFlag) {
-        this.editFlag = editFlag;
-    }
-
-    public Integer getGiftNumber() {
-        return giftNumber;
-    }
-
-    public void setGiftNumber(Integer giftNumber) {
-        this.giftNumber = giftNumber;
-    }
-
-    public BigDecimal getReducedPrice() {
-        return reducedPrice;
-    }
-
-    public void setReducedPrice(BigDecimal reducedPrice) {
-        this.reducedPrice = reducedPrice;
-    }
-
-    public String getPromotionType() {
-        return promotionType;
-    }
-
-    public void setPromotionType(String promotionType) {
-        this.promotionType = promotionType;
-    }
-
-    public String getDelProductIds() {
-        return delProductIds;
-    }
-
-    public void setDelProductIds(String delProductIds) {
-        this.delProductIds = delProductIds;
-    }
-
-    public List<Integer> getDelIdList() {
-        return delIdList;
-    }
-
-    public void setDelIdList(List<Integer> delIdList) {
-        this.delIdList = delIdList;
-    }
-
-    public String getSold() {
-        return sold;
-    }
-
-    public void setSold(String sold) {
-        this.sold = sold;
-    }
-
-    public String getPayStatus() {
-        return payStatus;
-    }
-
-    public void setPayStatus(String payStatus) {
-        this.payStatus = payStatus;
-    }
-
-    public String getContactName() {
-        return contactName;
-    }
-
-    public void setContactName(String contactName) {
-        this.contactName = contactName;
-    }
-
-    public BigDecimal getOriginalPrice() {
-        return originalPrice;
-    }
-
-    public void setOriginalPrice(BigDecimal originalPrice) {
-        this.originalPrice = originalPrice;
-    }
-
-    public String getSubmitDate() {
-        return submitDate;
-    }
-
-    public void setSubmitDate(String submitDate) {
-        this.submitDate = submitDate;
-    }
-
-    public String getReviewedDate() {
-        return reviewedDate;
-    }
-
-    public void setReviewedDate(String reviewedDate) {
-        this.reviewedDate = reviewedDate;
-    }
-
-    public String getOnLineDate() {
-        return onLineDate;
-    }
-
-    public void setOnLineDate(String onLineDate) {
-        this.onLineDate = onLineDate;
-    }
-
-    public String getPublisher() {
-        return publisher;
-    }
-
-    public void setPublisher(String publisher) {
-        this.publisher = publisher;
-    }
-
-    public String getCommodityType() {
-        return commodityType;
-    }
-
-    public void setCommodityType(String commodityType) {
-        this.commodityType = commodityType;
-    }
-
-    public String getSource() {
-        return source;
-    }
-
-    public void setSource(String source) {
-        this.source = source;
-    }
-
-    public Integer getOrganizeId() {
-        return organizeId;
-    }
-
-    public void setOrganizeId(Integer organizeId) {
-        this.organizeId = organizeId;
-    }
-
-    public String getProductIdStr() {
-        return productIdStr;
-    }
-
-    public void setProductIdStr(String productIdStr) {
-        this.productIdStr = productIdStr;
-    }
-
-    public String getDockingPeopleName() {
-        return dockingPeopleName;
-    }
-
-    public void setDockingPeopleName(String dockingPeopleName) {
-        this.dockingPeopleName = dockingPeopleName;
-    }
-
-    public Integer getFloorId() {
-        return floorId;
-    }
-
-    public void setFloorId(Integer floorId) {
-        this.floorId = floorId;
-    }
-
-    public Integer getTrainingMethod() {
-        return trainingMethod;
-    }
-
-    public void setTrainingMethod(Integer trainingMethod) {
-        this.trainingMethod = trainingMethod;
-    }
-
-    public Integer getTrainingType() {
-        return trainingType;
-    }
-
-    public void setTrainingType(Integer trainingType) {
-        this.trainingType = trainingType;
-    }
-
-    public BigDecimal getTrainingFee() {
-        return trainingFee;
-    }
-
-    public void setTrainingFee(BigDecimal trainingFee) {
-        this.trainingFee = trainingFee;
-    }
-
-    public Integer getSvipFlag() {
-        return svipFlag;
-    }
-
-    public void setSvipFlag(Integer svipFlag) {
-        this.svipFlag = svipFlag;
-    }
-
-    public Integer getSearchType() {
-        return searchType;
-    }
-
-    public void setSearchType(Integer searchType) {
-        this.searchType = searchType;
-    }
-
-    public String getMobile() {
-        return mobile;
-    }
-
-    public void setMobile(String mobile) {
-        this.mobile = mobile;
-    }
-
-    public Integer getUserId() {
-        return userId;
-    }
-
-    public void setUserId(Integer userId) {
-        this.userId = userId;
-    }
-
-    public String getReceiptID() {
-        return receiptID;
-    }
-
-    public void setReceiptID(String receiptID) {
-        this.receiptID = receiptID;
-    }
-
-    public Integer getShopOrderID() {
-        return shopOrderID;
-    }
-
-    public void setShopOrderID(Integer shopOrderID) {
-        this.shopOrderID = shopOrderID;
-    }
-
-    public Integer getOrderProductID() {
-        return orderProductID;
-    }
-
-    public void setOrderProductID(Integer orderProductID) {
-        this.orderProductID = orderProductID;
-    }
-
-    public Double getTaxRate() {
-        return taxRate;
-    }
-
-    public void setTaxRate(Double taxRate) {
-        this.taxRate = taxRate;
-    }
-
-    public Integer getReturnGoodsStutas() {
-        return returnGoodsStutas;
-    }
-
-    public void setReturnGoodsStutas(Integer returnGoodsStutas) {
-        this.returnGoodsStutas = returnGoodsStutas;
-    }
-
-    public Integer getInsertStatus() {
-        return insertStatus;
-    }
-
-    public void setInsertStatus(Integer insertStatus) {
-        this.insertStatus = insertStatus;
-    }
-
-    public Integer getIsRelevance() {
-        return isRelevance;
-    }
-
-    public void setIsRelevance(Integer isRelevance) {
-        this.isRelevance = isRelevance;
-    }
-
-    public String getKeywords() {
-        return keywords;
-    }
 
-    public void setKeywords(String keywords) {
-        this.keywords = keywords;
-    }
 }

+ 3 - 1
src/main/java/com/caimei/modules/product/entity/Shop.java

@@ -82,6 +82,8 @@ public class Shop extends DataEntity<Shop> {
 	private String cooperateFlag; //
 	private String businessScope; //
 	private Integer bail; // 是否已缴纳保证金(0 没有,1 有)
+	private Integer AccountOwnership; // 账号归属 0采美 1 供应商
+	private String bankAccount;	//收款卡号
 	private List<ShopCert> shopCertList;//商品资质认证
 	private String shopIds;	//商店id,","隔开
 	private List<Integer> ids; //商店id列表
@@ -89,4 +91,4 @@ public class Shop extends DataEntity<Shop> {
 	private String delShopIds;//删除的商店id,以,隔开
 	private List<Integer> delShopIdList;//删除的商品id列表
 	private Integer shopType;
-}
+}

+ 21 - 1
src/main/java/com/caimei/modules/product/service/CmPromotionService.java

@@ -49,7 +49,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
         List<Shop> promotionShops = new ArrayList<>();
         if (CollectionUtils.isNotEmpty(promotionList)) {
             for (CmPromotion promotion : promotionList) {
-                if("1".equals(promotion.getMode())){
+                if ("1".equals(promotion.getMode())) {
                     promotion.setSkus(productDao.findSkuByPromotion(promotion.getId()));
                 }
                 if (StringUtils.isNotBlank(cmPromotion.getProductName())) {
@@ -192,6 +192,25 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
      * 查询促销可用商品
      */
     public Page findProductPage(Page<Product> productPage, Product product) {
+        /**
+         * 单品促销
+         * 满赠时,赠品只能选择和该促销单品相同供应商的商品
+         * 凑单促销
+         * 1.满赠时,凑单商品和赠品都只能选择[综合供应商]的商品
+         * 店铺促销
+         * 1.赠品只能在已选好的供应商的商品内选择
+         */
+        if ("1".equals(product.getPromotionType())) {
+            // 单品满赠
+            if (null != product.getPromotionMode() && 3 == product.getPromotionMode()) {
+                Integer shopId = null != product.getShopID() ? product.getShopID() : (cmPromotionDao.findShopId(product.getProductID()));
+                product.setShopID(shopId);
+                product.setProductID(null);
+            }
+        } else if ("2".equals(product.getPromotionType())) {
+            // 凑单
+            product.setShopID(1161);
+        }
         product.setPage(productPage);
         List<Integer> list = new ArrayList<>();
         //已添加的商品id不能被查询到
@@ -331,6 +350,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
                 //赠品改为skuId
                 String giftId = (String) map.get("skuId");
                 Integer number = Integer.parseInt(map.get("number").toString());
+                logger.info("giftId------------------" + giftId);
                 cmPromotionDao.insertGiftProduct(promotionId, giftId, number);
             }
         }

+ 23 - 9
src/main/java/com/caimei/modules/product/service/ProductService.java

@@ -97,10 +97,6 @@ public class ProductService extends CrudService<ProductDao, Product> {
         return productDao.getGiftProductInfo(giftProduct);
     }
 
-    public Sku getProductSku(Integer productId) {
-        return productDao.getProductSku(productId);
-    }
-
     /**
      * 更新赠送
      *
@@ -333,23 +329,39 @@ public class ProductService extends CrudService<ProductDao, Product> {
             listMall.sort(Comparator.naturalOrder());
             String strip = StringUtils.strip(listMall.toString(), "[]");
             product.setGroundMall(strip.replaceAll(",", "##").trim());
-            cmOrganizeProductInfoMapper.updateNotCmOrganizeProductInfos(listMall.toArray(new Integer[listMall.size()]),product.getProductID(),3);
             listMall.forEach(s -> {
                 CmOrganizeProductInfo cmOrganizeProductInfoOrganizeId = new CmOrganizeProductInfo();
                 cmOrganizeProductInfoOrganizeId.setOrganizeId(s);
                 cmOrganizeProductInfoOrganizeId.setProductId(product.getProductID());
+                // 调整商品信息表
+                CmOrganizeProductInfo cmOrganizeProductInfo = new CmOrganizeProductInfo();
+                if (0 == s) {
+                    cmOrganizeProductInfo.setCostCheckFlag(Integer.parseInt(product.getCostCheckFlag()));
+                } else if (4 == s){
+                    cmOrganizeProductInfo.setCostCheckFlag(Integer.parseInt(product.getMallCostCheckFlag()));
+                }
                 if ( null == cmOrganizeProductInfoMapper.getByCmOrganizeProductInfo(cmOrganizeProductInfoOrganizeId)){
-                    CmOrganizeProductInfo cmOrganizeProductInfo = new CmOrganizeProductInfo();
                     cmOrganizeProductInfo.setOrganizeId(s);
                     cmOrganizeProductInfo.setProductId(product.getProductID());
                     cmOrganizeProductInfo.setValidFlag(1);
                     cmOrganizeProductInfoMapper.addCmOrganizeProductInfo(cmOrganizeProductInfo);
+                } else {
+                    Integer validFlag = 0;
+                    if (!strip.contains(s.toString())) {
+                        validFlag = 3;
+                    } else {
+                        validFlag = 2;
+                    }
+                    cmOrganizeProductInfoMapper.updateNotCmOrganizeProductInfos(s, product.getProductID(), cmOrganizeProductInfo.getCostCheckFlag(), validFlag);
                 }
 
             });
         } else {
             product.setGroundMall("");
-            cmOrganizeProductInfoMapper.delCmOrganizeProductInfoByOrganizeIds(new Integer[]{0, 4},product.getProductID());
+            /**
+             * 即使不上架平台,商品状态也不能直接删除,将商品状态置为下架,删除状态
+             */
+            cmOrganizeProductInfoMapper.updateNotCmOrganizeProductInfos(999,product.getProductID(),999,10);
         }
         if (null != product.getShopType() && 2 == product.getShopType()) {
             product.setValidFlag("2");
@@ -671,8 +683,9 @@ public class ProductService extends CrudService<ProductDao, Product> {
 
     public List<CmSku> findSkuList(Integer productID) {
         List<CmSku> skus = productDao.findSkuListProduct(productID);
+        Integer costCheckFlag = productDao.getCostCheckFlag(productID, 0);
         skus.forEach(s -> {
-            s.setCostCheckFlag(2);
+            s.setCostCheckFlag(costCheckFlag);
             s.ladderPriceList(productDao.findLadderPriceBySku(s.skuId()));
         });
 
@@ -681,8 +694,9 @@ public class ProductService extends CrudService<ProductDao, Product> {
 
     public List<CmSku> findMallSkuList(Integer productID) {
         List<CmSku> skuOrganizeList = productDao.findSkuOrganizeList(productID);
+        Integer costCheckFlag = productDao.getCostCheckFlag(productID, 4);
         skuOrganizeList.forEach(o -> {
-            o.setCostCheckFlag(2);
+            o.setCostCheckFlag(costCheckFlag);
         });
         return skuOrganizeList;
     }

+ 21 - 24
src/main/java/com/caimei/modules/product/web/CmPromotionController.java

@@ -7,9 +7,7 @@ import com.caimei.modules.bulkpurchase.entity.PurchaseProduct;
 import com.caimei.modules.opensearch.CoreServiceUitls;
 import com.caimei.modules.opensearch.GenerateUtils;
 import com.caimei.modules.product.dao.CmPromotionDao;
-import com.caimei.modules.product.entity.CmPromotion;
-import com.caimei.modules.product.entity.Product;
-import com.caimei.modules.product.entity.Shop;
+import com.caimei.modules.product.entity.*;
 import com.caimei.modules.product.service.CmPromotionService;
 import com.caimei.modules.product.service.ProductService;
 import com.caimei.redis.RedisService;
@@ -122,10 +120,10 @@ public class CmPromotionController extends BaseController {
 
     @RequestMapping(value = "delPromotion")
     @ResponseBody
-    public Map<String, Object> delPromotion(@RequestParam("id") String id,@RequestParam("skuId")Integer skuId, HttpServletRequest request) {
+    public Map<String, Object> delPromotion(@RequestParam("id") String id, @RequestParam("skuId") Integer skuId, HttpServletRequest request) {
         Map<String, Object> map = new HashMap<>();
         try {
-            cmPromotionService.delPromotion(id,skuId);
+            cmPromotionService.delPromotion(id, skuId);
             map.put("success", "true");
             map.put("msg", "删除成功");
         } catch (Exception e) {
@@ -142,11 +140,11 @@ public class CmPromotionController extends BaseController {
     @RequestMapping(value = "form")
     public String form(CmPromotion cmPromotion, Model model) {
         if (cmPromotion != null) {
-            if("1".equals(cmPromotion.getType())&&"1".equals(cmPromotion.getMode())){
-                if(StringUtils.isNotBlank(cmPromotion.getId())){
+            if ("1".equals(cmPromotion.getType()) && "1".equals(cmPromotion.getMode())) {
+                if (StringUtils.isNotBlank(cmPromotion.getId())) {
                     //单品优惠价的时候给优惠商品的skus赋值
                     cmPromotion.setSkus(cmPromotionDao.getPromotionSkus(cmPromotion.getId()));
-                }else{
+                } else {
                     //新增单品促销的时候没有id
                     cmPromotion.setSkus(cmPromotionDao.getPromotionSkusByProduct(cmPromotion.getProductIds()));
                 }
@@ -185,18 +183,18 @@ public class CmPromotionController extends BaseController {
                     String[] split = cmPromotion.getProductIds().split(",");
                     for (String productId : split) {
                         if (StringUtil.isNotBlank(productId)) {
-                            if(StringUtils.isNotBlank(cmPromotion.getType()) && "2".equals(cmPromotion.getType())){
+                            if (StringUtils.isNotBlank(cmPromotion.getType()) && "2".equals(cmPromotion.getType())) {
                                 //凑单促销的时候取的是skuId
-                                productId=productService.getProductIdBySku(productId);
+                                productId = productService.getProductIdBySku(productId);
                             }
                             Product product = productService.get(productId);
                             promotionProducts.add(product);
                         }
                     }
                 } else {
-                    if(StringUtils.isNotBlank(cmPromotion.getType()) && "2".equals(cmPromotion.getType())){
+                    if (StringUtils.isNotBlank(cmPromotion.getType()) && "2".equals(cmPromotion.getType())) {
                         //凑单促销的时候取的是skuId
-                       String productId=productService.getProductIdBySku(cmPromotion.getProductIds());
+                        String productId = productService.getProductIdBySku(cmPromotion.getProductIds());
                         cmPromotion.setProductIds(productId);
                     }
                     Product product = productService.get(cmPromotion.getProductIds());
@@ -209,13 +207,13 @@ public class CmPromotionController extends BaseController {
                     String[] split = cmPromotion.getGiftIds().split(",");
                     for (String skuId : split) {
                         if (StringUtil.isNotBlank(skuId)) {
-                            Product product = productService.getBySku(skuId);
-                            giftProducts.add(product);
+                                Product product = productService.getBySku(skuId);
+                                giftProducts.add(product);
                         }
                     }
                 } else {
-                    Product product = productService.getBySku(cmPromotion.getGiftIds());
-                    giftProducts.add(product);
+                        Product product = productService.getBySku(cmPromotion.getGiftIds());
+                        giftProducts.add(product);
                 }
             }
             if (StringUtil.isNotBlank(cmPromotion.getShopIds())) {
@@ -337,11 +335,6 @@ public class CmPromotionController extends BaseController {
             cmPromotion.setGiftProducts(giftProducts);
             cmPromotion.setPromotionShops(promotionShops);
             model.addAttribute("cmPromotion", cmPromotion);
-            if (cmPromotion.getPromotionProducts().size() > 0) {
-                model.addAttribute("price1", cmPromotion.getPromotionProducts().get(0).getPrice());
-            } else {
-                model.addAttribute("price1", 0);
-            }
             if ("1".equals(cmPromotion.getType())) {
                 return "modules/product-new/singlePromotionForm";
             } else if ("2".equals(cmPromotion.getType())) {
@@ -352,7 +345,6 @@ public class CmPromotionController extends BaseController {
         } else {
             return null;
         }
-
     }
 
     /**
@@ -405,6 +397,7 @@ public class CmPromotionController extends BaseController {
         cleanRedisCache();
         return map;
     }
+
     //更新促销索引
     private void updateIndex(CmPromotion cmPromotion) {
         List<Integer> productIdsByPromotion = new ArrayList<>();
@@ -415,8 +408,8 @@ public class CmPromotionController extends BaseController {
             productIdByPromotion = cmPromotionDao.findProductIdByPromotion(cmPromotion.getId());
         }
         // 更新索引
-        productIdsByPromotion.forEach(p->coreServiceUitls.updateProductIndex(p));
-        productIdByPromotion.forEach(p->coreServiceUitls.updateProductIndex(p));
+        productIdsByPromotion.forEach(p -> coreServiceUitls.updateProductIndex(p));
+        productIdByPromotion.forEach(p -> coreServiceUitls.updateProductIndex(p));
     }
 
     /**
@@ -425,12 +418,16 @@ public class CmPromotionController extends BaseController {
     @RequiresPermissions("product:product:view")
     @RequestMapping(value = "findProductPage")
     public String findProductPage(Product product, Model model, HttpServletRequest request, HttpServletResponse response) {
+        //todo 非单品促销的时候当前版本限制死仅可选择综合供应商,赠品仅可选择和促销商品同一供应商
         Page page = cmPromotionService.findProductPage(new Page<Product>(request, response), product);
         model.addAttribute("page", page);
         model.addAttribute("promotionType", product.getPromotionType());
         model.addAttribute("ids", product.getIds());
         model.addAttribute("delProductIds", product.getDelProductIds());
         if ("1".equals(product.getPromotionType())) {
+            if (null != product.getPromotionMode() && 3 == product.getPromotionMode()) {
+                return "modules/product-new/promotionSelectProducts";
+            }
             return "modules/product-new/promotionSelectSingleProduct";
         } else {
             return "modules/product-new/promotionSelectProducts";

+ 0 - 5
src/main/java/com/caimei/modules/product/web/ProductController.java

@@ -269,12 +269,7 @@ public class ProductController extends BaseController{
                     if(null != productInfo){
                         gp.setProductImage(AppUtils.getImageURL("product", productInfo.getMainImage(), 0,""));
                         gp.setProductCode(productInfo.getProductCode());
-                        //获取购买最大库存
-                        Sku productSku = productService.getProductSku(gp.getGiftProductId());
                         Integer sku = 0;//默认库存
-                        if(null != productSku){
-                            sku = productSku.getStock();
-                        }
                         gp.setProductSku(sku);
                     }
                 }

+ 11 - 4
src/main/java/com/caimei/modules/product/web/ProductNewController.java

@@ -483,9 +483,16 @@ public class ProductNewController extends BaseController {
                 searchKeyStr += "##";
             }
         }
-        if (null != product.getSkuList()) {
+        /*if (null != product.getSkuList()) {
             for (CmSku s : product.getSkuList()) {
-                if (null != s.getCostCheckFlag() && s.getCostCheckFlag() == 2) {
+                if (StringUtils.isNotBlank(product.getCostCheckFlag()) && "1".equals(product.getCostCheckFlag())) {
+                    double v = MathUtil.add(MathUtil.add(s.getCostPrice(), s.getOrganizeCostPrice()), s.getCmCostPrice()).doubleValue();
+                    if (v != s.getPrice()) {
+                        addMessage(redirectAttributes, "保存商品失败,sku固定成本之和需要等于机构价!");
+                        return "redirect:" + Global.getAdminPath() + "/product/new/productEdit?id="+product.getId();
+                    }
+                }
+                if (StringUtils.isNotBlank(product.getCostCheckFlag()) && "2".equals(product.getCostCheckFlag())) {
                     if (s.getShopPercent()==0) {
                         addMessage(redirectAttributes, "保存商品失败,供应商比例必须大于0");
                         return "redirect:" + Global.getAdminPath() + "/product/new/productEdit?id="+product.getId();
@@ -497,7 +504,7 @@ public class ProductNewController extends BaseController {
                     }
                 }
             }
-        }
+        }*/
         product.setSearchKey(searchKeyStr);
         productDetailInfo.setProductID(product.getProductID());
         productService.saveProduct(product, productDetailInfo);
@@ -825,7 +832,7 @@ public class ProductNewController extends BaseController {
 
     @RequestMapping("auditProduct")
     @ResponseBody
-    public Map<String, Object> auditProduct(String validFlag, Integer newvalidFlag, String showtime, Integer productID, String remarks) {
+    public synchronized Map<String, Object> auditProduct(String validFlag, Integer newvalidFlag, String showtime, Integer productID, String remarks) {
         Map<String, Object> map = Maps.newLinkedHashMap();
         try {
             if (StringUtils.isBlank(validFlag) || null == productID) {

+ 27 - 0
src/main/java/com/caimei/modules/user/entity/NewCmShop.java

@@ -96,6 +96,33 @@ public class NewCmShop extends DataEntity<NewCmShop> {
     private String endTime;        //注册时间结束  查询条件
     private String editStatus;//1编辑,2审核
     private String source; //注册来源: 0网站 1小程序
+    private String cmBankAccount; //付采美银行账号
+    private String cmBankAccountName; //采美付款账号的户名
+    private String cmBankName; //采美付款账号的开户行
+
+    public String getCmBankAccount() {
+        return cmBankAccount;
+    }
+
+    public void setCmBankAccount(String cmBankAccount) {
+        this.cmBankAccount = cmBankAccount;
+    }
+
+    public String getCmBankAccountName() {
+        return cmBankAccountName;
+    }
+
+    public void setCmBankAccountName(String cmBankAccountName) {
+        this.cmBankAccountName = cmBankAccountName;
+    }
+
+    public String getCmBankName() {
+        return cmBankName;
+    }
+
+    public void setCmBankName(String cmBankName) {
+        this.cmBankName = cmBankName;
+    }
 
     public NewCmShop() {
         super();

+ 12 - 12
src/main/java/com/caimei/modules/user/service/ClubPortraitService.java

@@ -131,24 +131,24 @@ public class ClubPortraitService {
                     // 普通订单
                     if (("0".equals(order.getSecondHandOrderFlag()) || StringUtils.isEmpty(order.getSecondHandOrderFlag()))
                             && (!"1".equals(order.getRebateFlag()) || "".equals(order.getRebateFlag()) || StringUtils.isEmpty(order.getRebateFlag()))
-                            && ((!"1".equals(order.getRefundType()) && !"2".equals(order.getRefundType())) || "".equals(order.getRefundType()) || StringUtils.isEmpty(order.getRefundType()))
-                            && !"6".equals(order.getStatus())) {
+                            && (!"2".equals(order.getRefundType()) || "".equals(order.getRefundType()) || StringUtils.isEmpty(order.getRefundType()))
+                            && !"4".equals(order.getStatus())) {
                         ordinary++;
                     }
                     // 二手订单
                     if ("1".equals(order.getSecondHandOrderFlag()) && !"1".equals(order.getRebateFlag())
-                            && (!"1".equals(order.getRefundType()) && !"2".equals(order.getRefundType())) && !"6".equals(order.getStatus())) {
+                            && (!"2".equals(order.getRefundType())) && !"4".equals(order.getStatus())) {
                         secondHand++;
                     }
                     // 返佣订单
-                    if ("1".equals(order.getRebateFlag()) &&
-                            (!"1".equals(order.getRefundType()) && !"2".equals(order.getRefundType()) || StringUtils.isEmpty(order.getRefundType())) && !"6".equals(order.getStatus())) {
+                    /*if ("1".equals(order.getRebateFlag()) &&
+                            (!"2".equals(order.getRefundType()) || StringUtils.isEmpty(order.getRefundType())) && !"4".equals(order.getStatus())) {
                         rebate++;
-                    }
+                    }*/
                     // 部分退款
-                    if ("1".equals(order.getRefundType()) && !"6".equals(order.getStatus())) {
+                    /*if ("1".equals(order.getRefundType()) && !"4".equals(order.getStatus())) {
                         partialRefund++;
-                    }
+                    }*/
                     // 全部退款
                     /*if ("2".equals(order.getRefundType()) && !"6".equals(order.getStatus())) {
                         fullRefund++;
@@ -179,22 +179,22 @@ public class ClubPortraitService {
                     orderPortrait.setName("二手订单 【 0 %】 【" + secondHand + "个】");
                 }
                 orderPortraits.add(orderPortrait);
-                orderPortrait = new OrderPortrait();
+                /*orderPortrait = new OrderPortrait();
                 orderPortrait.setValue(rebate);
                 if (rebate != 0) {
                     orderPortrait.setName("返佣订单 【" + instance.format((float) rebate / (float) length * 100) + "%】 【" + rebate + "个】");
                 } else {
                     orderPortrait.setName("返佣订单 【 0 %】 【" + rebate + "个】");
                 }
-                orderPortraits.add(orderPortrait);
-                orderPortrait = new OrderPortrait();
+                orderPortraits.add(orderPortrait);*/
+                /*orderPortrait = new OrderPortrait();
                 orderPortrait.setValue(partialRefund);
                 if (partialRefund != 0) {
                     orderPortrait.setName("部分退款订单 【" + instance.format((float) partialRefund / (float) length * 100) + "%】 【" + partialRefund + "个】");
                 } else {
                     orderPortrait.setName("部分退款订单 【 0 %】 【" + partialRefund + "个】");
                 }
-                orderPortraits.add(orderPortrait);
+                orderPortraits.add(orderPortrait);*/
                 /*orderPortrait = new OrderPortrait();
                 orderPortrait.setValue(fullRefund);
                 if (fullRefund != 0) {

+ 4 - 0
src/main/java/com/caimei/modules/user/web/NewCmShopController.java

@@ -192,6 +192,10 @@ public class NewCmShopController extends BaseController {
     public String formShop(NewCmShop newCmShop, Model model) {
         //获取供应商证书信息
         newCmShop = newCmShopService.get(newCmShop.getShopID().toString());
+        //去除银行账号空格
+        if(newCmShop!=null&&newCmShop.getBankAccount()!=null){
+            newCmShop.setBankAccount(newCmShop.getBankAccount().replaceAll(" ",""));
+        }
         model.addAttribute("newCmShop", newCmShop);
         return "modules/user/newCmShopSetForm";
     }

+ 8 - 7
src/main/java/com/thinkgem/jeesite/common/persistence/DataEntity.java

@@ -5,6 +5,7 @@ package com.thinkgem.jeesite.common.persistence;
 
 import java.util.Date;
 
+import com.thinkgem.jeesite.common.utils.IdGen;
 import org.apache.commons.lang3.StringUtils;
 import org.hibernate.validator.constraints.Length;
 
@@ -21,7 +22,7 @@ import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
 public abstract class DataEntity<T> extends BaseEntity<T> {
 
 	private static final long serialVersionUID = 1L;
-	
+
 	protected String remarks;	// 备注
 	protected User createBy;	// 创建者
 	protected Date createDate;	// 创建日期
@@ -29,16 +30,16 @@ public abstract class DataEntity<T> extends BaseEntity<T> {
 	protected Date updateDate;	// 更新日期
 	protected String delFlag; 	// 删除标记(0:正常;1:删除;2:审核)
 	protected String enabledStatus;		// 启用/禁用状态
-	
+
 	public DataEntity() {
 		super();
 		this.delFlag = DEL_FLAG_NORMAL;
 	}
-	
+
 	public DataEntity(String id) {
 		super(id);
 	}
-	
+
 	/**
 	 * 插入之前执行方法,需要手动调用
 	 */
@@ -57,7 +58,7 @@ public abstract class DataEntity<T> extends BaseEntity<T> {
 		this.updateDate = new Date();
 		this.createDate = this.updateDate;
 	}
-	
+
 	/**
 	 * 更新之前执行方法,需要手动调用
 	 */
@@ -69,7 +70,7 @@ public abstract class DataEntity<T> extends BaseEntity<T> {
 		}
 		this.updateDate = new Date();
 	}
-	
+
 	@Length(min=0, max=255)
 	public String getRemarks() {
 		return remarks;
@@ -78,7 +79,7 @@ public abstract class DataEntity<T> extends BaseEntity<T> {
 	public void setRemarks(String remarks) {
 		this.remarks = remarks;
 	}
-	
+
 	@JsonIgnore
 	public User getCreateBy() {
 		return createBy;

+ 51 - 36
src/main/java/com/thinkgem/jeesite/common/persistence/Page.java

@@ -23,12 +23,12 @@ import com.thinkgem.jeesite.common.utils.CookieUtils;
  * @param <T>
  */
 public class Page<T> {
-	
+
 	private int pageNo = 1; // 当前页码
 	private int pageSize = Integer.valueOf(Global.getConfig("page.pageSize")); // 页面大小,设置为“-1”表示不进行分页(分页无效)
-	
+
 	private long count;// 总记录数,设置为“-1”表示不查询总数
-	
+
 	private int first;// 首页索引
 	private int last;// 尾页索引
 	private int prev;// 上一页索引
@@ -41,21 +41,21 @@ public class Page<T> {
 
 	private int length = 8;// 显示页面长度
 	private int slider = 1;// 前后显示页面长度
-	
+
 	private List<T> list = new ArrayList<T>();
-	
+
 	private String orderBy = ""; // 标准查询有效, 实例: updatedate desc, name asc
 
 	private String funcName = "page"; // 设置点击页码调用的js函数名称,默认为page,在一页有多个分页对象时使用。
-	
+
 	private String funcParam = ""; // 函数的附加参数,第三个参数值。
-	
+
 	private String message = ""; // 设置提示消息,显示在“共n条”之后
 
 	public Page() {
 		this.pageSize = -1;
 	}
-	
+
 	/**
 	 * 构造方法
 	 * @param request 传递 repage 参数,来记住页码
@@ -102,7 +102,7 @@ public class Page<T> {
 			this.setOrderBy(orderBy);
 		}
 	}
-	
+
 	/**
 	 * 构造方法
 	 * @param pageNo 当前页码
@@ -111,7 +111,7 @@ public class Page<T> {
 	public Page(int pageNo, int pageSize) {
 		this(pageNo, pageSize, 0);
 	}
-	
+
 	/**
 	 * 构造方法
 	 * @param pageNo 当前页码
@@ -121,7 +121,22 @@ public class Page<T> {
 	public Page(int pageNo, int pageSize, long count) {
 		this(pageNo, pageSize, count, new ArrayList<T>());
 	}
-	
+
+	/**
+	 * 构造方法
+	 * @param pageNo 当前页码
+	 * @param pageSize 分页大小
+	 * @param count 数据条数
+	 * @param list 本页数据对象列表
+	 */
+	public Page(HttpServletRequest request, HttpServletResponse response,int pageNo, int pageSize, long count, List<T> list) {
+		this(request, response, -2);
+		this.setCount(count);
+		this.setPageNo(pageNo);
+		this.pageSize = pageSize;
+		this.list = list;
+	}
+
 	/**
 	 * 构造方法
 	 * @param pageNo 当前页码
@@ -135,17 +150,17 @@ public class Page<T> {
 		this.pageSize = pageSize;
 		this.list = list;
 	}
-	
+
 	/**
 	 * 初始化参数
 	 */
 	public void initialize(){
-				
+
 		//1
 		this.first = 1;
-		
+
 		this.last = (int)(count / (this.pageSize < 1 ? 20 : this.pageSize) + first - 1);
-		
+
 		if (this.count % this.pageSize != 0 || this.last == 0) {
 			this.last++;
 		}
@@ -153,7 +168,7 @@ public class Page<T> {
 		if (this.last < this.first) {
 			this.last = this.first;
 		}
-		
+
 		if (this.pageNo <= 1) {
 			this.pageNo = this.first;
 			this.firstPage=true;
@@ -175,7 +190,7 @@ public class Page<T> {
 		} else {
 			this.prev = this.first;
 		}
-		
+
 		//2
 		if (this.pageNo < this.first) {// 如果当前页小于首页
 			this.pageNo = this.first;
@@ -184,18 +199,18 @@ public class Page<T> {
 		if (this.pageNo > this.last) {// 如果当前页大于尾页
 			this.pageNo = this.last;
 		}
-		
+
 	}
-	
+
 	/**
-	 * 默认输出当前分页标签 
+	 * 默认输出当前分页标签
 	 * <div class="page">${page}</div>
 	 */
 	@Override
 	public String toString() {
 
 		StringBuilder sb = new StringBuilder();
-		
+
 		if (pageNo == first) {// 如果是首页
 			sb.append("<li class=\"disabled\"><a href=\"javascript:\">&#171; 上一页</a></li>\n");
 		} else {
@@ -264,14 +279,14 @@ public class Page<T> {
 		sb.append("共 " + count + " 条"+(message!=null?message:"")+"</a></li>\n");
 
 		sb.insert(0,"<ul>\n").append("</ul>\n");
-		
+
 		sb.append("<div style=\"clear:both;\"></div>");
 
 //		sb.insert(0,"<div class=\"page\">\n").append("</div>\n");
-		
+
 		return sb.toString();
 	}
-	
+
 	/**
 	 * 获取分页HTML代码
 	 * @return
@@ -279,7 +294,7 @@ public class Page<T> {
 	public String getHtml(){
 		return toString();
 	}
-	
+
 //	public static void main(String[] args) {
 //		Page<String> p = new Page<String>(3, 3);
 //		System.out.println(p);
@@ -307,7 +322,7 @@ public class Page<T> {
 			pageNo = 1;
 		}
 	}
-	
+
 	/**
 	 * 获取当前页码
 	 * @return
@@ -315,7 +330,7 @@ public class Page<T> {
 	public int getPageNo() {
 		return pageNo;
 	}
-	
+
 	/**
 	 * 设置当前页码
 	 * @param pageNo
@@ -323,7 +338,7 @@ public class Page<T> {
 	public void setPageNo(int pageNo) {
 		this.pageNo = pageNo;
 	}
-	
+
 	/**
 	 * 获取页面大小
 	 * @return
@@ -357,7 +372,7 @@ public class Page<T> {
 	public int getLast() {
 		return last;
 	}
-	
+
 	/**
 	 * 获取页面总数
 	 * @return getLast();
@@ -384,7 +399,7 @@ public class Page<T> {
 	public boolean isLastPage() {
 		return lastPage;
 	}
-	
+
 	/**
 	 * 上一页索引值
 	 * @return
@@ -410,7 +425,7 @@ public class Page<T> {
 			return pageNo + 1;
 		}
 	}
-	
+
 	/**
 	 * 获取本页数据对象列表
 	 * @return List<T>
@@ -435,7 +450,7 @@ public class Page<T> {
 	 */
 	@JsonIgnore
 	public String getOrderBy() {
-		// SQL过滤,防止注入 
+		// SQL过滤,防止注入
 		String reg = "(?:')|(?:--)|(/\\*(?:.|[\\n\\r])*?\\*/)|"
 					+ "(\\b(select|update|and|or|delete|insert|trancate|char|into|substr|ascii|declare|exec|count|master|into|drop|execute)\\b)";
 		Pattern sqlPattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE);
@@ -494,7 +509,7 @@ public class Page<T> {
 	public void setMessage(String message) {
 		this.message = message;
 	}
-	
+
 	/**
 	 * 分页是否有效
 	 * @return this.pageSize==-1
@@ -503,7 +518,7 @@ public class Page<T> {
 	public boolean isDisabled() {
 		return this.pageSize==-1;
 	}
-	
+
 	/**
 	 * 是否进行总数统计
 	 * @return this.count==-1
@@ -512,7 +527,7 @@ public class Page<T> {
 	public boolean isNotCount() {
 		return this.count==-1;
 	}
-	
+
 	/**
 	 * 获取 Hibernate FirstResult
 	 */
@@ -551,7 +566,7 @@ public class Page<T> {
 //		}
 //		return new PageRequest(this.pageNo - 1, this.pageSize, new Sort(orders));
 //	}
-//	
+//
 //	/**
 //	 * 设置 Spring data JPA 分页对象,转换为本系统分页对象
 //	 */

+ 1 - 1
src/main/resources/config/dev/caimei.properties

@@ -16,7 +16,7 @@ jdbc.url=jdbc:mysql://120.79.25.27:3306/caimei?useUnicode=true&characterEncoding
 jdbc.username=developer
 jdbc.password=J5p3tgOVazNl4ydf
 
-
+#
 #jdbc.url=jdbc:mysql://192.168.2.100:3306/caimei?characterEncoding=UTF8&serverTimezone=Asia/Shanghai
 #jdbc.username=developer
 #jdbc.password=05bZ/OxTB:X+yd%1

+ 21 - 15
src/main/resources/mappings/modules/archive/CmProductArchiveContentMapper.xml

@@ -1,11 +1,13 @@
 <?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.modules.archive.dao.CmProductArchiveContentDao">
-    
+
 	<sql id="cmProductArchiveContentColumns">
 		a.id AS "id",
 		a.productArchiveId AS "productArchiveId",
 		a.title AS "title",
+		a.content AS "content",
+		IFNULL(c.pv, 0) AS "actualPv",
 		a.type AS "type",
 		a.addTime AS "addTime",
 		if(a.type=2,cf.ossName,ifnull(cf.waterOssName,cf.ossName)) as ossName,
@@ -13,28 +15,29 @@
 		cf.uploadTime,
 		if(a.type=2,cf.ossUrl,ifnull(cf.waterOssUrl,cf.ossUrl)) as ossUrl
 	</sql>
-	
+
 	<sql id="cmProductArchiveContentJoins">
 		left join cm_product_archive_file cf on a.id = cf.archiveContentId and a.type != 1
+		left join cm_praise_statistics c on a.id = c.authorId and c.type =1
 	</sql>
-    
+
 	<select id="get" resultType="CmProductArchiveContent">
-		SELECT 
+		SELECT
 			<include refid="cmProductArchiveContentColumns"/>
 		FROM cm_product_archive_content a
 		<include refid="cmProductArchiveContentJoins"/>
 		WHERE a.id = #{id}
 	</select>
-	
+
 	<select id="findList" resultType="CmProductArchiveContent">
-		SELECT 
+		SELECT
 			<include refid="cmProductArchiveContentColumns"/>
 		FROM cm_product_archive_content a
 		<include refid="cmProductArchiveContentJoins"/>
 		<where>
-			
+
 			<if test="title != null and title != ''">
-				AND a.title LIKE 
+				AND a.title LIKE
 					<if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
 					<if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
 					<if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
@@ -48,15 +51,15 @@
 		</where>
 		order by a.addTime desc
 	</select>
-	
+
 	<select id="findAllList" resultType="CmProductArchiveContent">
-		SELECT 
+		SELECT
 			<include refid="cmProductArchiveContentColumns"/>
 		FROM cm_product_archive_content a
 		<include refid="cmProductArchiveContentJoins"/>
 		<where>
-			
-		</where>		
+
+		</where>
 		<choose>
 			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
 				ORDER BY ${page.orderBy}
@@ -81,11 +84,13 @@
 		INSERT INTO cm_product_archive_content(
 			productArchiveId,
 			title,
+			content,
 			type,
 			addTime
 		) VALUES (
 			#{productArchiveId},
 			#{title},
+			#{content},
 			#{type},
 			now()
 		)
@@ -97,8 +102,9 @@
 	</insert>
 
 	<update id="update">
-		UPDATE cm_product_archive_content SET 	
-			title = #{title}
+		UPDATE cm_product_archive_content SET
+			title = #{title},
+			content = #{content}
 		WHERE id = #{id}
 	</update>
 	<update id="updateFile">
@@ -119,4 +125,4 @@
 		delete from cm_product_archive_file where archiveContentId = #{archiveContentId}
 	</delete>
 
-</mapper>
+</mapper>

+ 4 - 2
src/main/resources/mappings/modules/bulkpurchase/PurchaseProductMapper.xml

@@ -38,8 +38,10 @@
 
 	<select id="findSencondProductPage" resultType="com.caimei.modules.bulkpurchase.entity.PurchaseProduct">
 		SELECT b.name as shopName ,b.`shopID` as shopId,a.name purchaseProductName,
-		cs.price,a.`productID` as productId,a.productCode productNo,a.mainImage image
-		,cs.costCheckFlag,cs.costPrice,cs.shopPercent, cs.normalPrice
+		cs.price,a.`productID` as productId,a.productCode productNo,
+		a.mainImage image,
+		(SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) AS costCheckFlag,
+		cs.costPrice,cs.shopPercent, cs.normalPrice
 		,a.productCategory as "productCategory",cshd.secondHandType as "secondHandType",cs.ladderPriceFlag
 		,a.includedTax
 		,a.invoiceType

+ 2 - 1
src/main/resources/mappings/modules/cmpage/CmPageCentreMapper.xml

@@ -198,11 +198,12 @@
 		FROM
 		  new_page_floor_image a
 		  LEFT JOIN product p ON a.productId = p.productID
-		left join cm_organize_product_info copi on copi.productId = p.productID and copi.productId = p.productID  and copi.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=p.productId)
+		left join cm_organize_product_info copi on  copi.productId = p.productID
 		  LEFT JOIN shop s on p.shopID = s.shopID
 		  left join cm_hehe_product chp on a.productId = chp.productId
 		WHERE
 		  a.centreId = #{centreId}
+
           <if test="type != null and type == '8'">
               and chp.id is not null
           </if>

+ 12 - 2
src/main/resources/mappings/modules/hehe/CmHeheProductMapper.xml

@@ -157,9 +157,11 @@
         SELECT
         a.*,s.name AS "shopName"
         FROM product a
+        left join cm_organize_product_info copi on copi.productId = a.productID
         LEFT JOIN shop s on s.shopID = a.shopID
         <where>
-            a.splitCode is not null and a.splitCode != ''
+            a.splitCode is not null and a.splitCode != '' and  copi.validFlag=2
+            and s.shopID in(SELECT shopID FROM shop  WHERE name ='深圳市采美奥泰贸易有限公司')
             <if test="productID != null">
                 AND a.productID = #{productID}
             </if>
@@ -297,7 +299,9 @@
     <select id="findProductElement" resultType="com.caimei.modules.hehe.entity.CmHeheProduct">
         select ifnull(chs.price, 0)           as price,
                ifnull(cs.shopPercent, 0) as shopPercent,
-               ifnull(cs.costCheckFlag, 0)    as costType,
+               ifnull(cs.organizePercent, 0) as organizePercent,
+               ifnull(cs.cmPercent, 0) as cmPercent,
+               ifnull((SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ), 0)    as costType,
                ifnull(cs.costPrice, 0)        as costPrice
             ,cs.organizeId
         from cm_sku cs
@@ -314,6 +318,12 @@
         WHERE productId = #{productId}
     </update>
 
+
+    <update id="deleteCmHeHeSku">
+        delete from  cm_hehe_sku
+        WHERE productId = #{productId}
+    </update>
+
     <update id="updateProductId">
         update cm_hehe_product
         set oldProductId = #{oldProductId},

+ 30 - 20
src/main/resources/mappings/modules/hehe/CmHeheUserMapper.xml

@@ -1,7 +1,7 @@
 <?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.modules.hehe.dao.CmHeheUserDao">
-    
+
 	<sql id="cmHeheUserColumns">
 		a.id AS "id",
 		a.userId AS "userId",
@@ -12,26 +12,26 @@
 		a.openId AS "openId",
 		a.addTime AS "addTime"
 	</sql>
-	
+
 
 	<delete id="deleteUserActivity">
 		delete from cm_hehe_user_activity where userId = #{userId} and productId = #{productId}
 	</delete>
 
 	<select id="get" resultType="CmHeheUser">
-		SELECT 
+		SELECT
 			<include refid="cmHeheUserColumns"/>
 		FROM cm_hehe_user a
 		WHERE a.id = #{id}
 	</select>
-	
+
 	<select id="findList" resultType="CmHeheUser">
-		SELECT 
+		SELECT
 			<include refid="cmHeheUserColumns"/>
 		FROM cm_hehe_user a
 		<where>
 			<if test="name != null and name != ''">
-				AND a.name LIKE 
+				AND a.name LIKE
 					<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
 					<if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
 					<if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
@@ -55,14 +55,14 @@
 			</otherwise>
 		</choose>
 	</select>
-	
+
 	<select id="findAllList" resultType="CmHeheUser">
-		SELECT 
+		SELECT
 			<include refid="cmHeheUserColumns"/>
 		FROM cm_hehe_user a
 		<where>
-			
-		</where>		
+
+		</where>
 		<choose>
 			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
 				ORDER BY ${page.orderBy}
@@ -71,7 +71,7 @@
 			</otherwise>
 		</choose>
 	</select>
-	
+
 	<insert id="insert" parameterType="CmHeheUser"  keyProperty="id" useGeneratedKeys="true">
 		INSERT INTO cm_hehe_user(
 			userId,
@@ -91,9 +91,9 @@
 			#{addTime}
 		)
 	</insert>
-	
+
 	<update id="update">
-		UPDATE cm_hehe_user SET 	
+		UPDATE cm_hehe_user SET
 			name = #{name},
 			mobile = #{mobile},
 			userIdentity = #{userIdentity},
@@ -147,24 +147,29 @@
 		a.activityId AS "activityId",
 		a.productId AS "productId",
 		a.sort AS "sort",
-		chp.price AS "price",
+		chs.price AS "price",
 		p.name AS "name",
 		p.mainImage AS "mainImage",
-		p.unit AS "unit",
+		cs.unit AS "unit",
 		s.name AS "shopName"
 		FROM
 		cm_hehe_user_activity a
 		LEFT JOIN cm_hehe_product chp ON chp.productId = a.productID
+		LEFT JOIN cm_hehe_sku chs ON chp.productId = chs.productID
+		LEFT JOIN cm_sku cs ON cs.skuId = chs.skuId
 		LEFT JOIN product p ON a.productId = p.productID
+		left join cm_organize_product_info copi on copi.productId = a.productID
 		LEFT JOIN shop s ON s.shopID = p.shopID
 		WHERE
 		a.userId = #{userId}
+		and copi.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=a.productId)
 		<if test="name != null and name != ''">
 			AND p.name LIKE CONCAT('%',#{name},'%')
 		</if>
 		<if test="shopName != null and shopName != ''">
 			AND s.name LIKE CONCAT('%',#{shopName},'%')
 		</if>
+		group by a.productID
 		ORDER BY
 		- a.sort DESC
 	</select>
@@ -172,22 +177,26 @@
 	<select id="findUserActivityProduct" resultType="integer">
 		SELECT productId FROM cm_hehe_user_activity  WHERE userId = #{userId}
 	</select>
-	
+
 	<select id="findAllActivityProduct" resultType="com.caimei.modules.hehe.entity.CmHeheProduct">
 		SELECT
 		  a.id AS "id",
 		  a.productId AS "productId",
-		  chp.price AS "price",
+		  chs.price AS "price",
 		  p.name AS "name",
 		  p.mainImage AS "mainImage",
 		  s.name AS "shopName"
 		FROM
 		  cm_hehe_activity_product a
 		  LEFT JOIN cm_hehe_product chp ON a.productId = chp.productId
+		LEFT JOIN cm_hehe_sku chs ON chp.productId = chs.productID
+		LEFT JOIN cm_sku cs ON cs.skuId = chs.skuId
 		  LEFT JOIN product p ON a.productId = p.productID
-		  LEFT JOIN shop s ON s.shopID = p.shopID
+		left join cm_organize_product_info copi on copi.productId = a.productID
+		LEFT JOIN shop s ON s.shopID = p.shopID
 		WHERE
 		  a.delFlag = 0
+		and copi.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=a.productId)
 		<if test="ids != null and ids.size() > 0 ">
 			AND a.productId NOT IN
 			<foreach collection="ids" open="(" close=")" item="id" separator=",">
@@ -203,6 +212,7 @@
 		<if test="shopName != null and shopName != ''">
 			AND s.name LIKE CONCAT('%',#{shopName},'%')
 		</if>
+		group by  a.productID
 		ORDER BY productId DESC
 	</select>
 
@@ -221,5 +231,5 @@
 	<update id="updateSortById">
 		UPDATE cm_hehe_user_activity SET sort = #{sort} WHERE id =#{id}
 	</update>
-	
-</mapper>
+
+</mapper>

+ 443 - 0
src/main/resources/mappings/modules/info/CmRelatedMapper.xml

@@ -0,0 +1,443 @@
+<?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.modules.info.dao.CmRelatedMapper">
+
+    <resultMap type="CmRelated" id="CmRelatedResult">
+        <result property="id"    column="id"    />
+        <result property="type"    column="type"    />
+        <result property="authorId"    column="authorId"    />
+        <result property="relatedId"    column="relatedId"    />
+        <result property="delFlag"    column="delFlag"    />
+        <result property="updateTime"    column="updateTime"    />
+        <result property="createTime"    column="createTime"    />
+        <result property="sort"    column="sort"    />
+    </resultMap>
+
+    <sql id="selectCmRelatedVo">
+        select
+            cm_related.id,
+            cm_related.type,
+            cm_related.authorId,
+            cm_related.relatedId,
+            cm_related.delFlag,
+            cm_related.updateTime,
+            cm_related.createTime,
+            cm_related.sort
+    </sql>
+
+    <select id="getByCmRelated" parameterType="CmRelated" resultMap="CmRelatedResult">
+        <include refid="selectCmRelatedVo"/>
+        from cm_related AS cm_related
+        <where>  cm_related.delFlag = 0
+            <if test="id != null  and id != ''">
+                and cm_related.id
+                <if test="id.toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="type != null  and type != ''">
+                and cm_related.type
+                <if test="type.toUpperCase().indexOf('=')==-1">
+                    = #{type}
+                </if>
+                <if test="type.toUpperCase().indexOf('=')!=-1">
+                    <if test="type.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="type.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="typeIn" collection="type.substring(type.toUpperCase().indexOf('=')+1,type.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{typeIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="authorId != null  and authorId != ''"> and cm_related.authorId = #{authorId}</if>
+            <if test="relatedId != null  and relatedId != ''"> and cm_related.relatedId = #{relatedId}</if>
+            <if test="delFlag != null "> and cm_related.delFlag = #{delFlag}</if>
+            <if test="updateTime != null "> and cm_related.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_related.createTime = #{createTime}</if>
+            <if test="sort != null "> and cm_related.sort = #{sort}</if>
+        </where>
+        group by cm_related.id
+        order by cm_related.createTime desc
+        limit 0,1
+    </select>
+
+    <select id="findList" parameterType="CmRelated" resultMap="CmRelatedResult">
+        <include refid="selectCmRelatedVo"/>
+        from cm_related AS cm_related
+        <if test="info != null">
+            left join info AS info on cm_related.relatedId=info.id
+        </if>
+        <where>  cm_related.delFlag = 0
+            <if test="id != null  and id != ''">
+                and cm_related.id
+                <if test="id.toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="type != null  and type != ''">
+                and cm_related.type
+                <if test="type.toUpperCase().indexOf('=')==-1">
+                    = #{type}
+                </if>
+                <if test="type.toUpperCase().indexOf('=')!=-1">
+                    <if test="type.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="type.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="typeIn" collection="type.substring(type.toUpperCase().indexOf('=')+1,type.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{typeIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="authorId != null  and authorId != ''"> and cm_related.authorId = #{authorId}</if>
+            <if test="relatedId != null  and relatedId != ''"> and cm_related.relatedId = #{relatedId}</if>
+            <if test="delFlag != null "> and cm_related.delFlag = #{delFlag}</if>
+            <if test="updateTime != null "> and cm_related.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_related.createTime = #{createTime}</if>
+            <if test="sort != null "> and cm_related.sort = #{sort}</if>
+            --           info
+            <if test="info != null ">
+                <if test="info.id != null  and info.id != ''">
+                    and info.id
+                    = #{info.id}
+                </if>
+                <if test="info.typeId != null  and info.typeId != ''">
+                    and info.typeId
+                    = #{info.typeId}
+                </if>
+                <if test="info.title != null  and info.title != ''"> and info.title = #{info.title}</if>
+                <if test="info.label != null  and info.label != ''"> and info.label = #{info.label}</if>
+                <if test="info.publisher != null  and info.publisher != ''"> and info.publisher = #{info.publisher}</if>
+                <if test="info.source != null  and info.source != ''"> and info.source = #{info.source}</if>
+                <if test="info.publishSource != null "> and info.publishSource = #{info.publishSource}</if>
+                <if test="info.shopId != null "> and info.shopId = #{info.shopId}</if>
+                <if test="info.keyword != null  and info.keyword != ''"> and info.keyword = #{info.keyword}</if>
+                <if test="info.recommendContent != null  and info.recommendContent != ''"> and info.recommendContent = #{info.recommendContent}</if>
+                <if test="info.infoContent != null  and info.infoContent != ''"> and info.infoContent = #{info.infoContent}</if>
+                <if test="info.guidanceImage != null  and info.guidanceImage != ''"> and info.guidanceImage = #{info.guidanceImage}</if>
+                <if test="info.homePageImage != null  and info.homePageImage != ''"> and info.homePageImage = #{info.homePageImage}</if>
+                <if test="info.pubdate != null "> and info.pubdate = #{info.pubdate}</if>
+                <if test="info.recommendStatus != null  and info.recommendStatus != ''"> and info.recommendStatus = #{info.recommendStatus}</if>
+                <if test="info.enabledStatus != null  and info.enabledStatus != ''"> and info.enabledStatus = #{info.enabledStatus}</if>
+                <if test="info.basePraise != null "> and info.basePraise = #{info.basePraise}</if>
+                <if test="info.basePv != null "> and info.basePv = #{info.basePv}</if>
+                <if test="info.priorityIndex != null "> and info.priorityIndex = #{info.priorityIndex}</if>
+                <if test="info.auditStatus != null "> and info.auditStatus = #{info.auditStatus}</if>
+                <if test="info.onlineStatus != null "> and info.onlineStatus = #{info.onlineStatus}</if>
+                <if test="info.failReason != null  and info.failReason != ''"> and info.failReason = #{info.failReason}</if>
+                <if test="info.createBy != null  and info.createBy != ''"> and info.createBy = #{info.createBy}</if>
+                <if test="info.createDate != null "> and info.createDate = #{info.createDate}</if>
+                <if test="info.updateBy != null  and info.updateBy != ''"> and info.updateBy = #{info.updateBy}</if>
+                <if test="info.updateDate != null "> and info.updateDate = #{info.updateDate}</if>
+                <if test="info.topPosition != null "> and info.topPosition = #{info.topPosition}</if>
+                <if test="info.labelIds != null  and info.labelIds != ''"> and info.labelIds = #{info.labelIds}</if>
+                <if test="info.relatedLabels != null  and info.relatedLabels != ''"> and info.relatedLabels = #{info.relatedLabels}</if>
+                <if test="info.delFlag != null "> and info.delFlag = #{info.delFlag}</if>
+                <if test="info.autoStatus != null "> and info.autoStatus = #{info.autoStatus}</if>
+                <if test="info.startPubDate != null and info.startPubDate != ''">
+                    AND info.pubdate <![CDATA[  >=  ]]> #{info.startPubDate}
+                </if>
+                <if test="info.endPubDate != null and info.endPubDate != ''">
+                    AND info.pubdate <![CDATA[   <=  ]]> #{info.endPubDate}
+                </if>
+            </if>
+
+        </where>
+        group by cm_related.id
+        order by cm_related.sort asc,cm_related.createTime desc
+    </select>
+
+    <select id="getCmRelatedList" parameterType="CmRelated" resultMap="CmRelatedResult">
+        <include refid="selectCmRelatedVo"/>
+        from cm_related AS cm_related
+        <if test="info != null">
+            left join info AS info on cm_related.relatedId=info.id
+        </if>
+        <where>  cm_related.delFlag = 0
+            <if test="id != null  and id != ''">
+                and cm_related.id
+                <if test="id.toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="type != null  and type != ''">
+                and cm_related.type
+                <if test="type.toUpperCase().indexOf('=')==-1">
+                    = #{type}
+                </if>
+                <if test="type.toUpperCase().indexOf('=')!=-1">
+                    <if test="type.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="type.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="typeIn" collection="type.substring(type.toUpperCase().indexOf('=')+1,type.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{typeIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="authorId != null  and authorId != ''"> and cm_related.authorId = #{authorId}</if>
+            <if test="relatedId != null  and relatedId != ''"> and cm_related.relatedId = #{relatedId}</if>
+            <if test="delFlag != null "> and cm_related.delFlag = #{delFlag}</if>
+            <if test="updateTime != null "> and cm_related.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_related.createTime = #{createTime}</if>
+            <if test="sort != null "> and cm_related.sort = #{sort}</if>
+            --           info
+            <if test="info != null ">
+                <if test="info.id != null  and info.id != ''">
+                    and info.id
+                    = #{info.id}
+                </if>
+                <if test="info.typeId != null  and info.typeId != ''">
+                    and info.typeId
+                    = #{info.typeId}
+                </if>
+                <if test="info.title != null  and info.title != ''"> and info.title = #{info.title}</if>
+                <if test="info.label != null  and info.label != ''"> and info.label = #{info.label}</if>
+                <if test="info.publisher != null  and info.publisher != ''"> and info.publisher = #{info.publisher}</if>
+                <if test="info.source != null  and info.source != ''"> and info.source = #{info.source}</if>
+                <if test="info.publishSource != null "> and info.publishSource = #{info.publishSource}</if>
+                <if test="info.shopId != null "> and info.shopId = #{info.shopId}</if>
+                <if test="info.keyword != null  and info.keyword != ''"> and info.keyword = #{info.keyword}</if>
+                <if test="info.recommendContent != null  and info.recommendContent != ''"> and info.recommendContent = #{info.recommendContent}</if>
+                <if test="info.infoContent != null  and info.infoContent != ''"> and info.infoContent = #{info.infoContent}</if>
+                <if test="info.guidanceImage != null  and info.guidanceImage != ''"> and info.guidanceImage = #{info.guidanceImage}</if>
+                <if test="info.homePageImage != null  and info.homePageImage != ''"> and info.homePageImage = #{info.homePageImage}</if>
+                <if test="info.pubdate != null "> and info.pubdate = #{info.pubdate}</if>
+                <if test="info.recommendStatus != null  and info.recommendStatus != ''"> and info.recommendStatus = #{info.recommendStatus}</if>
+                <if test="info.enabledStatus != null  and info.enabledStatus != ''"> and info.enabledStatus = #{info.enabledStatus}</if>
+                <if test="info.basePraise != null "> and info.basePraise = #{info.basePraise}</if>
+                <if test="info.basePv != null "> and info.basePv = #{info.basePv}</if>
+                <if test="info.priorityIndex != null "> and info.priorityIndex = #{info.priorityIndex}</if>
+                <if test="info.auditStatus != null "> and info.auditStatus = #{info.auditStatus}</if>
+                <if test="info.onlineStatus != null "> and info.onlineStatus = #{info.onlineStatus}</if>
+                <if test="info.failReason != null  and info.failReason != ''"> and info.failReason = #{info.failReason}</if>
+                <if test="info.createBy != null  and info.createBy != ''"> and info.createBy = #{info.createBy}</if>
+                <if test="info.createDate != null "> and info.createDate = #{info.createDate}</if>
+                <if test="info.updateBy != null  and info.updateBy != ''"> and info.updateBy = #{info.updateBy}</if>
+                <if test="info.updateDate != null "> and info.updateDate = #{info.updateDate}</if>
+                <if test="info.topPosition != null "> and info.topPosition = #{info.topPosition}</if>
+                <if test="info.labelIds != null  and info.labelIds != ''"> and info.labelIds = #{info.labelIds}</if>
+                <if test="info.relatedLabels != null  and info.relatedLabels != ''"> and info.relatedLabels = #{info.relatedLabels}</if>
+                <if test="info.delFlag != null "> and info.delFlag = #{info.delFlag}</if>
+                <if test="info.autoStatus != null "> and info.autoStatus = #{info.autoStatus}</if>
+                <if test="info.startPubDate != null and info.startPubDate != ''">
+                    AND info.pubdate <![CDATA[  >=  ]]> #{info.startPubDate}
+                </if>
+                <if test="info.endPubDate != null and info.endPubDate != ''">
+                    AND info.pubdate <![CDATA[   <=  ]]> #{info.endPubDate}
+                </if>
+            </if>
+
+        </where>
+        group by cm_related.id
+        order by cm_related.sort asc,cm_related.createTime desc
+    </select>
+
+    <select id="getCmRelatedCount" parameterType="CmRelated" resultType="String">
+        select count(1)
+        from cm_related AS cm_related
+        <where>  cm_related.delFlag = 0
+            <if test="id != null  and  id != ''">
+                and cm_related.id
+                <if test="id.toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="type != null  and type != ''">
+                and cm_related.type
+                <if test="type.toUpperCase().indexOf('=')==-1">
+                    = #{type}
+                </if>
+                <if test="type.toUpperCase().indexOf('=')!=-1">
+                    <if test="type.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="type.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="typeIn" collection="type.substring(type.toUpperCase().indexOf('=')+1,type.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{typeIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="authorId != null  and authorId != ''"> and cm_related.authorId = #{authorId}</if>
+            <if test="relatedId != null  and relatedId != ''"> and cm_related.relatedId = #{relatedId}</if>
+            <if test="delFlag != null "> and cm_related.delFlag = #{delFlag}</if>
+            <if test="updateTime != null "> and cm_related.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_related.createTime = #{createTime}</if>
+            <if test="sort != null "> and cm_related.sort = #{sort}</if>
+        </where>
+        group by cm_related.id
+    </select>
+
+    <select id="getCmRelatedById" parameterType="String" resultMap="CmRelatedResult">
+        <include refid="selectCmRelatedVo"/>
+        from cm_related AS cm_related
+        where  cm_related.delFlag = 0 and cm_related.id = #{id}
+    </select>
+
+    <select id="getByIds" parameterType="CmRelated" resultType="String">
+        select id
+        from cm_related AS cm_related
+        <where>  cm_related.delFlag = 0
+            <if test="id != null  and id != ''">
+                and cm_related.id
+                <if test="id.toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="type != null  and type != ''">
+                and cm_related.type
+                <if test="type.toUpperCase().indexOf('=')==-1">
+                    = #{type}
+                </if>
+                <if test="type.toUpperCase().indexOf('=')!=-1">
+                    <if test="type.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="type.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="typeIn" collection="type.substring(type.toUpperCase().indexOf('=')+1,type.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{typeIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="authorId != null  and authorId != ''"> and cm_related.authorId = #{authorId}</if>
+            <if test="relatedId != null  and relatedId != ''"> and cm_related.relatedId = #{relatedId}</if>
+            <if test="delFlag != null "> and cm_related.delFlag = #{delFlag}</if>
+            <if test="updateTime != null "> and cm_related.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_related.createTime = #{createTime}</if>
+            <if test="sort != null "> and cm_related.sort = #{sort}</if>
+        </where>
+        group by cm_related.id
+    </select>
+
+    <select id="getById" parameterType="CmRelated" resultType="String">
+        select id
+        from cm_related AS cm_related
+        <where>  cm_related.delFlag = 0
+            <if test="id != null  and id != ''">
+                and cm_related.id
+                <if test="id.toString().toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toString().toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toString().toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toString().toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.toString().substring(id.toString().toUpperCase().indexOf('=')+1,id.toString().length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="type != null  and type != ''">
+                and cm_related.type
+                <if test="type.toUpperCase().indexOf('=')==-1">
+                    = #{type}
+                </if>
+                <if test="type.toUpperCase().indexOf('=')!=-1">
+                    <if test="type.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="type.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="typeIn" collection="type.substring(type.toUpperCase().indexOf('=')+1,type.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{typeIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="authorId != null  and authorId != ''"> and cm_related.authorId = #{authorId}</if>
+            <if test="relatedId != null  and relatedId != ''"> and cm_related.relatedId = #{relatedId}</if>
+            <if test="delFlag != null "> and cm_related.delFlag = #{delFlag}</if>
+            <if test="updateTime != null "> and cm_related.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_related.createTime = #{createTime}</if>
+            <if test="sort != null "> and cm_related.sort = #{sort}</if>
+        </where>
+        group by cm_related.id
+        limit 0,1
+    </select>
+
+    <insert id="addCmRelated" parameterType="CmRelated" useGeneratedKeys="true" keyProperty="id">
+        insert into cm_related
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null and id != ''">id,</if>
+            <if test="type != null and type != ''">type,</if>
+            <if test="authorId != null and authorId != ''">authorId,</if>
+            <if test="relatedId != null and relatedId != ''">relatedId,</if>
+            <if test="delFlag != null">delFlag,</if>
+            <if test="updateTime != null">updateTime,</if>
+            <if test="createTime != null">createTime,</if>
+            <if test="sort != null">sort,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null and id != ''">#{id},</if>
+            <if test="type != null and type != ''">#{type},</if>
+            <if test="authorId != null and authorId != ''">#{authorId},</if>
+            <if test="relatedId != null and relatedId != ''">#{relatedId},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="sort != null">#{sort},</if>
+        </trim>
+    </insert>
+
+    <update id="updateCmRelated" parameterType="CmRelated">
+        update cm_related
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="type != null and type != ''">type = #{type},</if>
+            <if test="authorId != null and authorId != ''">authorId = #{authorId},</if>
+            <if test="relatedId != null and relatedId != ''">relatedId = #{relatedId},</if>
+            <if test="delFlag != null">delFlag = #{delFlag},</if>
+            <if test="updateTime != null">updateTime = #{updateTime},</if>
+            <if test="createTime != null">createTime = #{createTime},</if>
+            <if test="sort != null">sort = #{sort},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <update id="updateDelCmRelatedByIds" parameterType="String">
+        update cm_related set delFlag=#{delFlag} where id in
+        <foreach item="id" collection="ids" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+
+    <delete id="delCmRelatedById" parameterType="String">
+        delete
+        from cm_related where id = #{id}
+    </delete>
+
+    <delete id="delCmRelatedByAuthorId" parameterType="String">
+        delete
+        from cm_related where type = #{type} and authorId = #{authorId}
+    </delete>
+
+    <delete id="delCmRelatedByIds" parameterType="String">
+        delete from cm_related where id in
+        <foreach item="id" collection="ids" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+
+</mapper>

+ 243 - 4
src/main/resources/mappings/modules/info/InfoMapper.xml

@@ -6,6 +6,8 @@
         a.id AS "id",
 		a.shopId AS "shopId",
 		a.typeId AS "infoType.id",
+		a.typeId ,
+        b.name as typeName,
 		a.title AS "title",
 		a.label AS "label",
 		a.publisher AS "publisher",
@@ -24,6 +26,7 @@
 		a.basePv AS "basePv",
 		a.priorityIndex AS "priorityIndex",
 		a.auditStatus,
+		a.autoStatus,
         a.onlineStatus,
 		a.failReason,
 		c.num AS "realPraise",
@@ -43,6 +46,226 @@
 		LEFT JOIN info_praise c ON a.id=c.infoId
 		left join shop s on a.shopId = s.shopID
     </sql>
+    <resultMap type="com.caimei.modules.info.entity.Info" id="InfoResult">
+        <result property="id"    column="id"    />
+        <result property="typeId"    column="typeId"    />
+        <result property="typeName"    column="typeName"    />
+        <result property="title"    column="title"    />
+        <result property="label"    column="label"    />
+        <result property="publisher"    column="publisher"    />
+        <result property="source"    column="source"    />
+        <result property="publishSource"    column="publishSource"    />
+        <result property="shopId"    column="shopId"    />
+        <result property="keyword"    column="keyword"    />
+        <result property="recommendContent"    column="recommendContent"    />
+        <result property="infoContent"    column="infoContent"    />
+        <result property="guidanceImage"    column="guidanceImage"    />
+        <result property="homePageImage"    column="homePageImage"    />
+        <result property="pubdate"    column="pubdate"    />
+        <result property="recommendStatus"    column="recommendStatus"    />
+        <result property="enabledStatus"    column="enabledStatus"    />
+        <result property="basePraise"    column="basePraise"    />
+        <result property="basePv"    column="basePv"    />
+        <result property="priorityIndex"    column="priorityIndex"    />
+        <result property="auditStatus"    column="auditStatus"    />
+        <result property="onlineStatus"    column="onlineStatus"    />
+        <result property="failReason"    column="failReason"    />
+        <result property="createBy.id"    column="createBy"    />
+        <result property="createDate"    column="createDate"    />
+        <result property="updateBy.id"    column="updateBy"    />
+        <result property="updateDate"    column="updateDate"    />
+        <result property="topPosition"    column="topPosition"    />
+        <result property="labelIds"    column="labelIds"    />
+        <result property="relatedLabels"    column="relatedLabels"    />
+        <result property="delFlag"    column="delFlag"    />
+        <result property="autoStatus"    column="autoStatus"    />
+    </resultMap>
+
+    <sql id="selectInfoVo">
+        select
+            info.id,
+            info.typeId,
+            info.title,
+            info.label,
+            info.publisher,
+            info.source,
+            info.publishSource,
+            info.shopId,
+            info.keyword,
+            info.recommendContent,
+            info.infoContent,
+            info.guidanceImage,
+            info.homePageImage,
+            info.pubdate,
+            info.recommendStatus,
+            info.enabledStatus,
+            info.basePraise,
+            info.basePv,
+            info.priorityIndex,
+            info.auditStatus,
+            info.onlineStatus,
+            info.failReason,
+            info.createBy,
+            info.createDate,
+            info.updateBy,
+            info.updateDate,
+            info.topPosition,
+            info.labelIds,
+            info.relatedLabels,
+            info.delFlag,
+            info.autoStatus
+    </sql>
+
+    <select id="getByInfo" parameterType="com.caimei.modules.info.entity.Info" resultMap="InfoResult">
+        <include refid="selectInfoVo"/>
+        from info AS info
+        LEFT JOIN info_type b ON info.typeId=b.id
+        <where>  info.delFlag = 0
+            <if test="id != null  and id != ''">
+                and info.id
+                <if test="id.toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="typeId != null  and typeId != ''">
+                and info.typeId
+                    = #{typeId}
+            </if>
+            <if test="title != null  and title != ''"> and info.title = #{title}</if>
+            <if test="label != null  and label != ''"> and info.label = #{label}</if>
+            <if test="publisher != null  and publisher != ''"> and info.publisher = #{publisher}</if>
+            <if test="source != null  and source != ''"> and info.source = #{source}</if>
+            <if test="publishSource != null "> and info.publishSource = #{publishSource}</if>
+            <if test="shopId != null "> and info.shopId = #{shopId}</if>
+            <if test="keyword != null  and keyword != ''"> and info.keyword = #{keyword}</if>
+            <if test="recommendContent != null  and recommendContent != ''"> and info.recommendContent = #{recommendContent}</if>
+            <if test="infoContent != null  and infoContent != ''"> and info.infoContent = #{infoContent}</if>
+            <if test="guidanceImage != null  and guidanceImage != ''"> and info.guidanceImage = #{guidanceImage}</if>
+            <if test="homePageImage != null  and homePageImage != ''"> and info.homePageImage = #{homePageImage}</if>
+            <if test="pubdate != null "> and info.pubdate = #{pubdate}</if>
+            <if test="recommendStatus != null  and recommendStatus != ''"> and info.recommendStatus = #{recommendStatus}</if>
+            <if test="enabledStatus != null  and enabledStatus != ''"> and info.enabledStatus = #{enabledStatus}</if>
+            <if test="basePraise != null "> and info.basePraise = #{basePraise}</if>
+            <if test="basePv != null "> and info.basePv = #{basePv}</if>
+            <if test="priorityIndex != null "> and info.priorityIndex = #{priorityIndex}</if>
+            <if test="auditStatus != null "> and info.auditStatus = #{auditStatus}</if>
+            <if test="onlineStatus != null "> and info.onlineStatus = #{onlineStatus}</if>
+            <if test="failReason != null  and failReason != ''"> and info.failReason = #{failReason}</if>
+            <if test="createBy != null  and createBy != ''"> and info.createBy = #{createBy}</if>
+            <if test="createDate != null "> and info.createDate = #{createDate}</if>
+            <if test="updateBy != null  and updateBy != ''"> and info.updateBy = #{updateBy}</if>
+            <if test="updateDate != null "> and info.updateDate = #{updateDate}</if>
+            <if test="topPosition != null "> and info.topPosition = #{topPosition}</if>
+            <if test="labelIds != null  and labelIds != ''"> and info.labelIds = #{labelIds}</if>
+            <if test="relatedLabels != null  and relatedLabels != ''"> and info.relatedLabels = #{relatedLabels}</if>
+            <if test="delFlag != null "> and info.delFlag = #{delFlag}</if>
+            <if test="autoStatus != null "> and info.autoStatus = #{autoStatus}</if>
+        </where>
+        group by info.id
+        order by info.createDate desc
+        limit 0,1
+    </select>
+
+    <update id="updateInfo" parameterType="Info">
+        update info
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="typeId != null and typeId != ''">typeId = #{typeId},</if>
+            <if test="title != null and title != ''">title = #{title},</if>
+            <if test="label != null and label != ''">label = #{label},</if>
+            <if test="publisher != null and publisher != ''">publisher = #{publisher},</if>
+            <if test="source != null and source != ''">source = #{source},</if>
+            <if test="publishSource != null">publishSource = #{publishSource},</if>
+            <if test="shopId != null">shopId = #{shopId},</if>
+            <if test="keyword != null and keyword != ''">keyword = #{keyword},</if>
+            <if test="recommendContent != null and recommendContent != ''">recommendContent = #{recommendContent},</if>
+            <if test="infoContent != null and infoContent != ''">infoContent = #{infoContent},</if>
+            <if test="guidanceImage != null and guidanceImage != ''">guidanceImage = #{guidanceImage},</if>
+            <if test="homePageImage != null and homePageImage != ''">homePageImage = #{homePageImage},</if>
+            <if test="pubdate != null">pubdate = #{pubdate},</if>
+            <if test="recommendStatus != null and recommendStatus != ''">recommendStatus = #{recommendStatus},</if>
+            <if test="enabledStatus != null and enabledStatus != ''">enabledStatus = #{enabledStatus},</if>
+            <if test="basePraise != null">basePraise = #{basePraise},</if>
+            <if test="basePv != null">basePv = #{basePv},</if>
+            <if test="priorityIndex != null">priorityIndex = #{priorityIndex},</if>
+            <if test="auditStatus != null">auditStatus = #{auditStatus},</if>
+            <if test="onlineStatus != null">onlineStatus = #{onlineStatus},</if>
+            <if test="failReason != null and failReason != ''">failReason = #{failReason},</if>
+            <if test="createBy != null and createBy != ''">createBy = #{createBy},</if>
+            <if test="createDate != null">createDate = #{createDate},</if>
+            <if test="updateBy != null and updateBy != ''">updateBy = #{updateBy},</if>
+            <if test="updateDate != null">updateDate = #{updateDate},</if>
+            <if test="topPosition != null">topPosition = #{topPosition},</if>
+            <if test="labelIds != null and labelIds != ''">labelIds = #{labelIds},</if>
+            <if test="relatedLabels != null and relatedLabels != ''">relatedLabels = #{relatedLabels},</if>
+            <if test="delFlag != null">delFlag = #{delFlag},</if>
+            <if test="autoStatus != null">autoStatus = #{autoStatus},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <select id="getInfoList" parameterType="com.caimei.modules.info.entity.Info" resultMap="InfoResult">
+        <include refid="selectInfoVo"/>
+        ,b.name as typeName
+        from info AS info
+        LEFT JOIN info_type b ON info.typeId=b.id
+        <where>  info.delFlag = 0
+            <if test="id != null  and id != ''">
+                and info.id
+                <if test="id.toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
+            </if>
+            <if test="typeId != null  and typeId != ''">
+                and info.typeId
+                    = #{typeId}
+            </if>
+            <if test="title != null  and title != ''"> and info.title = #{title}</if>
+            <if test="label != null  and label != ''"> and info.label = #{label}</if>
+            <if test="publisher != null  and publisher != ''"> and info.publisher = #{publisher}</if>
+            <if test="source != null  and source != ''"> and info.source = #{source}</if>
+            <if test="publishSource != null "> and info.publishSource = #{publishSource}</if>
+            <if test="shopId != null "> and info.shopId = #{shopId}</if>
+            <if test="keyword != null  and keyword != ''"> and info.keyword = #{keyword}</if>
+            <if test="recommendContent != null  and recommendContent != ''"> and info.recommendContent = #{recommendContent}</if>
+            <if test="infoContent != null  and infoContent != ''"> and info.infoContent = #{infoContent}</if>
+            <if test="guidanceImage != null  and guidanceImage != ''"> and info.guidanceImage = #{guidanceImage}</if>
+            <if test="homePageImage != null  and homePageImage != ''"> and info.homePageImage = #{homePageImage}</if>
+            <if test="pubdate != null "> and info.pubdate = #{pubdate}</if>
+            <if test="recommendStatus != null  and recommendStatus != ''"> and info.recommendStatus = #{recommendStatus}</if>
+            <if test="enabledStatus != null  and enabledStatus != ''"> and info.enabledStatus = #{enabledStatus}</if>
+            <if test="basePraise != null "> and info.basePraise = #{basePraise}</if>
+            <if test="basePv != null "> and info.basePv = #{basePv}</if>
+            <if test="priorityIndex != null "> and info.priorityIndex = #{priorityIndex}</if>
+            <if test="auditStatus != null "> and info.auditStatus = #{auditStatus}</if>
+            <if test="onlineStatus != null "> and info.onlineStatus = #{onlineStatus}</if>
+            <if test="failReason != null  and failReason != ''"> and info.failReason = #{failReason}</if>
+            <if test="createBy != null  and createBy != ''"> and info.createBy = #{createBy}</if>
+            <if test="createDate != null "> and info.createDate = #{createDate}</if>
+            <if test="updateBy != null  and updateBy != ''"> and info.updateBy = #{updateBy}</if>
+            <if test="updateDate != null "> and info.updateDate = #{updateDate}</if>
+            <if test="topPosition != null "> and info.topPosition = #{topPosition}</if>
+            <if test="labelIds != null  and labelIds != ''"> and info.labelIds = #{labelIds}</if>
+            <if test="relatedLabels != null  and relatedLabels != ''"> and info.relatedLabels = #{relatedLabels}</if>
+            <if test="delFlag != null "> and info.delFlag = #{delFlag}</if>
+            <if test="autoStatus != null "> and info.autoStatus = #{autoStatus}</if>
+        </where>
+        group by info.id
+        order by info.createDate desc
+    </select>
 
     <select id="get" resultType="Info">
         SELECT
@@ -56,17 +279,33 @@
         SELECT
         <include refid="infoColumns"/>
         FROM info a
+        <if test="null !=cmRelatedType and cmRelatedType != ''">
+            left join cm_related AS cm_related on  cm_related.relatedId=a.id and cm_related.delFlag = 0 AND cm_related.type = #{cmRelatedType}
+        </if>
         <include refid="infoJoins"/>
         <where>
-            delFlag = 0
-            <if test="id != null and id != ''">
-                AND a.id = #{id}
+            a.delFlag = 0
+            <if test="id != null  and id != ''">
+                and a.id
+                <if test="id.toUpperCase().indexOf('=')==-1">
+                    = #{id}
+                </if>
+                <if test="id.toUpperCase().indexOf('=')!=-1">
+                    <if test="id.toUpperCase().indexOf('NOT')!=-1"> not </if>
+                    <if test="id.toUpperCase().indexOf('IN')!=-1"> in </if>
+                    <foreach item="idIn" collection="id.substring(id.toUpperCase().indexOf('=')+1,id.length()).trim().split(',')" open="(" separator="," close=")">
+                        #{idIn}
+                    </foreach>
+                </if>
             </if>
             <if test="null !=infoType">
                 <if test="infoType.id != null and infoType.id != ''">
-                    AND a.typeId = #{infoType.id}
+                    AND (a.typeId = #{infoType.id}  or b.parentId=#{infoType.id})
                 </if>
             </if>
+            <if test="null !=cmRelatedType and cmRelatedType != ''">
+                  and cm_related.relatedId is null
+            </if>
             <if test="title != null and title != ''">
                 AND a.title LIKE concat('%',#{title},'%')
             </if>

+ 116 - 22
src/main/resources/mappings/modules/info/InfoTypeMapper.xml

@@ -1,7 +1,7 @@
 <?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.modules.info.dao.InfoTypeDao">
-    
+
 	<sql id="infoTypeColumns">
 		a.id AS "id",
 		a.name AS "name",
@@ -11,24 +11,49 @@
 		a.createBy AS "createBy.id",
 		a.createDate AS "createDate",
 		a.updateBy AS "updateBy.id",
-		a.updateDate AS "updateDate"
+		a.updateDate AS "updateDate",
+		a.delFlag AS "delFlag",
+		a.type AS "type",
+		a.parentId AS "parentId",
+		a.parentIds AS "parentIds"
+	</sql>
+	<sql id="selectInfoTypeVo">
+		select
+			info_type.id,
+			info_type.name,
+			info_type.sort,
+			info_type.shopUseFlag,
+			info_type.enabledStatus,
+			info_type.createBy,
+			info_type.createDate,
+			info_type.updateBy,
+			info_type.updateDate,
+			info_type.delFlag,
+			info_type.type,
+			info_type.parentId,
+			info_type.parentIds
 	</sql>
-
 	<select id="get" resultType="InfoType">
-		SELECT 
+		SELECT
 			<include refid="infoTypeColumns"/>
 		FROM info_type a
 		WHERE a.id = #{id}
 	</select>
-	
+
 	<select id="findList" resultType="InfoType">
-		SELECT 
+		SELECT
 			<include refid="infoTypeColumns"/>
 		FROM info_type a
 		<where>
 			<if test="id != null and id != ''">
 				AND a.id = #{id}
 			</if>
+			<if test="type != null and type != ''">
+				AND a.type = #{type}
+			</if>
+			<if test="parentId != null and parentId != ''">
+				AND a.parentId = #{parentId}
+			</if>
 			<if test="enabledStatus != null and enabledStatus != ''">
 				AND a.enabledStatus = #{enabledStatus}
 			</if>
@@ -42,14 +67,14 @@
 			</otherwise>
 		</choose>
 	</select>
-	
+
 	<select id="findAllList" resultType="InfoType">
-		SELECT 
+		SELECT
 			<include refid="infoTypeColumns"/>
 		FROM info_type a
 		<where>
-			
-		</where>		
+
+		</where>
 		<choose>
 			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
 				ORDER BY ${page.orderBy}
@@ -59,52 +84,121 @@
 			</otherwise>
 		</choose>
 	</select>
-	
+
 	<insert id="insert" parameterType="InfoType"  keyProperty="id" useGeneratedKeys="true">
 		INSERT INTO info_type(
 			name,
 			sort,
 			shopUseFlag,
+			enabledStatus,
 			createBy,
 			createDate,
 			updateBy,
-			updateDate
+			updateDate,
+			delFlag,
+			type,
+			parentId,
+			parentIds
 		) VALUES (
 			#{name},
 			#{sort},
 			#{shopUseFlag},
+			#{enabledStatus},
 			#{createBy.id},
 			#{createDate},
 			#{updateBy.id},
-			#{updateDate}
+			#{updateDate},
+			#{delFlag},
+			#{type},
+			#{parentId},
+			#{parentIds}
 		)
 	</insert>
-	
+
 	<update id="update">
-		UPDATE info_type SET 	
+		UPDATE info_type SET
 			name = #{name},
 			sort = #{sort},
 			shopUseFlag = #{shopUseFlag},
 			enabledStatus = #{enabledStatus},
 			updateBy = #{updateBy.id},
-			updateDate = #{updateDate}
+			updateDate = #{updateDate},
+			delFlag =#{delFlag},
+			type =#{type},
+			parentId =#{parentId},
+			parentIds =#{parentIds}
 		WHERE id = #{id}
 	</update>
-	
+
 	<delete id="delete">
 		DELETE FROM info_type
 		WHERE id = #{id}
 	</delete>
-	
+
 	<update id="updateEnabledStatusByIds">
-		UPDATE info_type a SET a.enabledStatus = #{param1} 
+		UPDATE info_type a SET a.enabledStatus = #{param1}
 		WHERE  a.id IN
 	 	<foreach collection="param2" item="id" index="index" open="(" separator="," close=")" >
 	       #{id}
 	 	</foreach>
 	</update>
-	
+
 	<select id="countEnabledStatus" resultType="java.lang.Integer">
-		SELECT count(1) FROM  info_type a WHERE a.enabledStatus = #{param1}
+		SELECT count(1) FROM  info_type a WHERE a.enabledStatus = #{param1} and a.parentId=0
+	</select>
+
+	<select id="getByInfoType" parameterType="InfoType" resultType="InfoType">
+		<include refid="selectInfoTypeVo"/>
+		from info_type AS info_type
+		<where>  info_type.delFlag = 0
+			<if test="id != null  and id != ''">
+				and info_type.id= #{id}
+			</if>
+			<if test="name != null  and name != ''"> and info_type.name like concat('%', #{name}, '%')</if>
+			<if test="sort != null "> and info_type.sort = #{sort}</if>
+			<if test="shopUseFlag != null "> and info_type.shopUseFlag = #{shopUseFlag}</if>
+			<if test="enabledStatus != null  and enabledStatus != ''"> and info_type.enabledStatus = #{enabledStatus}</if>
+<!--			<if test="createBy != null "> and info_type.createBy = #{createBy}</if>-->
+			<if test="createDate != null "> and info_type.createDate = #{createDate}</if>
+<!--			<if test="updateBy != null "> and info_type.updateBy = #{updateBy}</if>-->
+			<if test="updateDate != null "> and info_type.updateDate = #{updateDate}</if>
+			<if test="delFlag != null "> and info_type.delFlag = #{delFlag}</if>
+			<if test="type != null  and type != ''">
+				and info_type.type
+					= #{type}
+			</if>
+			<if test="parentId != null  and parentId != ''"> and info_type.parentId = #{parentId}</if>
+			<if test="parentIds != null  and parentIds != ''"> and info_type.parentIds = #{parentIds}</if>
+		</where>
+		group by info_type.id
+		order by info_type.createDate desc
+		limit 0,1
+	</select>
+
+	<select id="getByInfoTypeList" parameterType="InfoType" resultType="InfoType">
+		<include refid="selectInfoTypeVo"/>
+		from info_type AS info_type
+		<where>  info_type.delFlag = 0
+			<if test="id != null  and id != ''">
+				and info_type.id= #{id}
+			</if>
+			<if test="name != null  and name != ''"> and info_type.name like concat('%', #{name}, '%')</if>
+			<if test="sort != null "> and info_type.sort = #{sort}</if>
+			<if test="shopUseFlag != null "> and info_type.shopUseFlag = #{shopUseFlag}</if>
+			<if test="enabledStatus != null  and enabledStatus != ''"> and info_type.enabledStatus = #{enabledStatus}</if>
+<!--			<if test="createBy != null "> and info_type.createBy = #{createBy}</if>-->
+			<if test="createDate != null "> and info_type.createDate = #{createDate}</if>
+<!--			<if test="updateBy != null "> and info_type.updateBy = #{updateBy}</if>-->
+			<if test="updateDate != null "> and info_type.updateDate = #{updateDate}</if>
+			<if test="delFlag != null "> and info_type.delFlag = #{delFlag}</if>
+			<if test="type != null  and type != ''">
+				and info_type.type
+					= #{type}
+			</if>
+			<if test="parentId != null  and parentId != ''"> and info_type.parentId = #{parentId}</if>
+			<if test="parentIds != null  and parentIds != ''"> and info_type.parentIds LIKE CONCAT('%',#{parentIds},'%')</if>
+		</where>
+		group by info_type.id
+		order by info_type.createDate desc
 	</select>
-</mapper>
+</mapper>

+ 76 - 1
src/main/resources/mappings/modules/landing/CmBrandLandingMapper.xml

@@ -8,6 +8,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="id"    column="id"    />
         <result property="authUserId"    column="authUserId"    />
         <result property="type"    column="type"    />
+        <result property="levelType"    column="levelType"    />
+        <result property="authorId"    column="authorId"    />
         <result property="headPcBanner"    column="headPcBanner"    />
         <result property="headAppBanner"    column="headAppBanner"    />
         <result property="jumpStatus"    column="jumpStatus"    />
@@ -27,7 +29,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <sql id="selectCmBrandLandingVo">
-        select id, authUserId, type, headPcBanner, headAppBanner, jumpStatus, jumpPcPicture, jumpAppPicture, jumpLink, title, content, video, sort, pcStatus, appStatus, delFlag, updateTime, addTime from cm_brand_landing
+        select id,
+               authUserId,
+               type,
+               levelType,
+               authorId,
+               headPcBanner,
+               headAppBanner,
+               jumpStatus,
+               jumpPcPicture,
+               jumpAppPicture,
+               jumpLink,
+               title,
+               content,
+               video,
+               sort,
+               pcStatus,
+               appStatus,
+               delFlag,
+               updateTime,
+               addTime
+        from cm_brand_landing
     </sql>
 
     <select id="selectCmBrandLandingList" parameterType="CmBrandLanding" resultMap="CmBrandLandingResult">
@@ -36,6 +58,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="id != null  and id != ''"> and id = #{id}</if>
             <if test="authUserId != null "> and authUserId = #{authUserId}</if>
             <if test="type != null "> and type = #{type}</if>
+            <if test="levelType != null "> and levelType = #{levelType}</if>
+            <if test="authorId != null "> and authorId = #{authorId}</if>
             <if test="headPcBanner != null  and headPcBanner != ''"> and headPcBanner = #{headPcBanner}</if>
             <if test="headAppBanner != null  and headAppBanner != ''"> and headAppBanner = #{headAppBanner}</if>
             <if test="jumpStatus != null "> and jumpStatus = #{jumpStatus}</if>
@@ -60,6 +84,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="id != null  and id != ''"> and id = #{id}</if>
             <if test="authUserId != null "> and authUserId = #{authUserId}</if>
             <if test="type != null "> and type = #{type}</if>
+            <if test="levelType != null "> and levelType = #{levelType}</if>
+            <if test="authorId != null "> and authorId = #{authorId}</if>
             <if test="headPcBanner != null  and headPcBanner != ''"> and headPcBanner = #{headPcBanner}</if>
             <if test="headAppBanner != null  and headAppBanner != ''"> and headAppBanner = #{headAppBanner}</if>
             <if test="jumpStatus != null "> and jumpStatus = #{jumpStatus}</if>
@@ -84,6 +110,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </select>
 
+    <select id="getById" parameterType="CmBrandLanding" resultType="String">
+        select id
+        from cm_brand_landing AS cm_brand_landing
+        <where>  cm_brand_landing.delFlag = 0
+            <if test="id != null  and id != ''">
+                and cm_brand_landing.id
+                    = #{id}
+            </if>
+            <if test="type != null  and type != ''">
+                and cm_brand_landing.type
+                    = #{type}
+            </if>
+            <if test="authUserId != null "> and cm_brand_landing.authUserId = #{authUserId}</if>
+            <if test="levelType != null  and levelType != ''">
+                and cm_brand_landing.levelType = #{levelType}
+            </if>
+            <if test="authorId != null  and authorId != ''"> and cm_brand_landing.authorId = #{authorId}</if>
+            <if test="headPcBanner != null  and headPcBanner != ''"> and cm_brand_landing.headPcBanner = #{headPcBanner}</if>
+            <if test="headAppBanner != null  and headAppBanner != ''"> and cm_brand_landing.headAppBanner = #{headAppBanner}</if>
+            <if test="jumpStatus != null "> and cm_brand_landing.jumpStatus = #{jumpStatus}</if>
+            <if test="jumpPcPicture != null  and jumpPcPicture != ''"> and cm_brand_landing.jumpPcPicture = #{jumpPcPicture}</if>
+            <if test="jumpAppPicture != null  and jumpAppPicture != ''"> and cm_brand_landing.jumpAppPicture = #{jumpAppPicture}</if>
+            <if test="jumpLink != null  and jumpLink != ''"> and cm_brand_landing.jumpLink = #{jumpLink}</if>
+            <if test="title != null  and title != ''"> and cm_brand_landing.title = #{title}</if>
+            <if test="content != null  and content != ''"> and cm_brand_landing.content = #{content}</if>
+            <if test="video != null  and video != ''"> and cm_brand_landing.video = #{video}</if>
+            <if test="sort != null "> and cm_brand_landing.sort = #{sort}</if>
+            <if test="pcStatus != null "> and cm_brand_landing.pcStatus = #{pcStatus}</if>
+            <if test="appStatus != null "> and cm_brand_landing.appStatus = #{appStatus}</if>
+            <if test="delFlag != null "> and cm_brand_landing.delFlag = #{delFlag}</if>
+            <if test="updateTime != null "> and cm_brand_landing.updateTime = #{updateTime}</if>
+            <if test="addTime != null "> and cm_brand_landing.addTime = #{addTime}</if>
+        </where>
+        group by cm_brand_landing.id
+        order by cm_brand_landing.addTime desc
+        limit 0,1
+    </select>
+
     <select id="findBigSort" resultType="java.lang.String">
         SELECT sort FROM cm_brand_landing ORDER BY sort DESC LIMIT 1
     </select>
@@ -96,6 +160,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="authUserId != null">authUserId,</if>
             <if test="type != null">type,</if>
+            <if test="levelType != null ">  levelType,</if>
+            <if test="authorId != null ">  authorId,</if>
             <if test="headPcBanner != null">headPcBanner,</if>
             <if test="headAppBanner != null">headAppBanner,</if>
             <if test="jumpStatus != null">jumpStatus,</if>
@@ -115,6 +181,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="authUserId != null">#{authUserId},</if>
             <if test="type != null">#{type},</if>
+            <if test="levelType != null ">  #{levelType},</if>
+            <if test="authorId != null "> #{authorId},</if>
             <if test="headPcBanner != null">#{headPcBanner},</if>
             <if test="headAppBanner != null">#{headAppBanner},</if>
             <if test="jumpStatus != null">#{jumpStatus},</if>
@@ -138,6 +206,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="SET" suffixOverrides=",">
             <if test="authUserId != null">authUserId = #{authUserId},</if>
             <if test="type != null">type = #{type},</if>
+            <if test="levelType != null ">  levelType = #{levelType},</if>
+            <if test="authorId != null ">  authorId = #{authorId},</if>
             <if test="headPcBanner != null">headPcBanner = #{headPcBanner},</if>
             <if test="headAppBanner != null">headAppBanner = #{headAppBanner},</if>
             <if test="jumpStatus != null">jumpStatus = #{jumpStatus},</if>
@@ -161,6 +231,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         delete from cm_brand_landing where id = #{id}
     </delete>
 
+
+    <delete id="delCmBrandLandingByAuthorId" parameterType="String">
+        delete from cm_brand_landing where authorId = #{authorId}
+    </delete>
+
     <delete id="deleteCmBrandLandingByIds" parameterType="String">
         delete from cm_brand_landing where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">

+ 3 - 0
src/main/resources/mappings/modules/order/CmDiscernReceiptMapper.xml

@@ -168,6 +168,9 @@
             <if test="shopOrderId != null and shopOrderId != ''">
                 AND (cso.shopOrderId = #{shopOrderId} )
             </if>
+            <if test="shopOrderNo != null and shopOrderNo != ''">
+                AND (cso.shopOrderNo = #{shopOrderNo} )
+            </if>
             <if test="userName != null and userName != ''">
                 AND (u.userName LIKE concat('%',#{userName},'%') or u.name LIKE concat('%',#{userName},'%'))
             </if>

+ 85 - 3
src/main/resources/mappings/modules/order/CmPayShopMapper.xml

@@ -70,6 +70,10 @@
 		LEFT JOIN cm_pay_shop_record psr ON psr.payShopID = a.id
 		LEFT JOIN cm_shop_order so ON so.shopOrderID = psr.shopOrderID
 		<where>
+			(a.shopId = 1161 OR s.AccountOwnership = 0 OR so.splitCode = 'E1807059160' or so.ordertype = 2)
+			and a.delFlag = '0'
+			and (so.organizeID!=4 or so.organizeID is null)
+			and a.shopID != 998
 			<if test="id != null and id != ''">
 				and a.id = #{id}
 			</if>
@@ -118,9 +122,6 @@
 			<if test="paymentType != null">
 				AND a.id IN(SELECT payShopID FROM cm_pay_shop_record WHERE paymentType = #{paymentType} AND delFlag = 0)
 			</if>
-			and a.delFlag = '0'
-			and (so.organizeID!=4 or so.organizeID is null)
-			and a.shopID != 998
 		</where>
 		GROUP BY a.id
 		<choose>
@@ -131,6 +132,87 @@
 				ORDER BY a.id desc
 			</otherwise>
 		</choose>
+
+	</select>
+	<select id="payThirdParties" resultType="CmPayShop">
+		SELECT
+		<include refid="cmPayShopColumns"/>,
+		u1.name AS applicantName,
+		u2.name AS reviewerName,
+		s.name AS shopName,
+		(SELECT paymentType FROM cm_pay_shop_record WHERE payShopID = a.id LIMIT 1) AS paymentType
+		FROM cm_pay_shop a
+		left join sys_user u1 on u1.id = a.applicant
+		left join sys_user u2 on u2.id = a.reviewer
+		left join shop s on s.shopID = a.shopID
+		LEFT JOIN cm_pay_shop_record psr ON psr.payShopID = a.id
+		LEFT JOIN cm_shop_order so ON so.shopOrderID = psr.shopOrderID
+		LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = so.orderId
+		LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
+		<where>
+			s.name NOT LIKE '%综合供应商%'
+			AND s.AccountOwnership = 1
+			AND cdr.payWay = 2
+			AND so.receiptStatus != 1
+			<if test="id != null and id != ''">
+				and a.id = #{id}
+			</if>
+			<if test="shopName != null and shopName != ''">
+				and s.name like concat('%', #{shopName}, '%')
+			</if>
+			<if test="name != null and name != ''">
+				AND a.name LIKE
+				<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
+				<if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
+				<if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
+			</if>
+			<if test="startTime != null and startTime != ''">
+				AND a.applyTime <![CDATA[  >=  ]]> #{startTime}
+			</if>
+			<if test="endTime != null and endTime != ''">
+				AND a.applyTime <![CDATA[   <=  ]]> #{endTime}
+			</if>
+			<if test="startTime2 != null and startTime2 != ''">
+				AND a.payTime <![CDATA[  >=  ]]> #{startTime2}
+			</if>
+			<if test="endTime2 != null and endTime2 != ''">
+				AND a.payTime <![CDATA[   <=  ]]> #{endTime2}
+			</if>
+			<if test="status != null and status != ''">
+				AND a.status = #{status}
+			</if>
+			<if test="shopOrderNo != null and shopOrderNo != ''">
+				AND a.id in (select cpsr.payShopID from cm_pay_shop_record cpsr where cpsr.shopOrderNo like concat('%',#{shopOrderNo},'%'))
+			</if>
+			<if test="shopOrderID != null and shopOrderID != ''">
+				AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record cpsr WHERE cpsr.shopOrderID=#{shopOrderID})
+			</if>
+			<if test="orderID != null and orderID != ''">
+				AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record  cpsr LEFT JOIN cm_shop_order so ON so.shopOrderID=cpsr.shopOrderID WHERE so.orderID=#{orderID})
+			</if>
+			<if test='organizeID != null and organizeID != "" and organizeID != "9999"'>
+				AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record  cpsr LEFT JOIN cm_shop_order so ON so.shopOrderID=cpsr.shopOrderID WHERE so.organizeID = #{organizeID})
+			</if>
+			<if test='organizeID == "9999"'>
+				AND a.id IN (SELECT cpsr.payShopID FROM cm_pay_shop_record  cpsr LEFT JOIN cm_shop_order so ON so.shopOrderID=cpsr.shopOrderID WHERE so.orderType = 2)
+			</if>
+			<if test="orderNo != null and orderNo != ''">
+				AND a.id in (SELECT cpsr.payShopID FROM cm_pay_shop_record  cpsr LEFT JOIN cm_shop_order so ON so.shopOrderID=cpsr.shopOrderID WHERE so.orderNo LIKE CONCAT('%',#{orderNo},'%'))
+			</if>
+			<if test="paymentType != null">
+				AND a.id IN(SELECT payShopID FROM cm_pay_shop_record WHERE paymentType = #{paymentType} AND delFlag = 0)
+			</if>
+		</where>
+		GROUP BY a.id
+		<choose>
+			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
+				ORDER BY ${page.orderBy}
+			</when>
+			<otherwise>
+				ORDER BY a.id desc
+			</otherwise>
+		</choose>
+
 	</select>
 
 	<select id="findAllList" resultType="CmPayShop">

+ 20 - 1
src/main/resources/mappings/modules/order/CmReceiptOrderRelationMapper.xml

@@ -157,6 +157,16 @@
           AND b.delFlag = '0'
     </select>
 
+    <select id="findReceiptByShopOrderId" resultType="java.lang.Double">
+        select IFNULL(sum(associateAmount), 0)
+        from cm_receipt_order_relation a
+                 left join cm_discern_receipt b on a.receiptID = b.id
+        where a.shopOrderId = #{shopOrderId}
+          AND b.receiptStatus = '3'
+          AND a.delFlag = '0'
+          AND b.delFlag = '0'
+    </select>
+
     <select id="toAudit" resultType="java.lang.Integer">
         SELECT cdr.id
         FROM `cm_receipt_order_relation` cror
@@ -170,11 +180,20 @@
     <select id="findOrderRelation" resultType="CmReceiptOrderRelation">
         SELECT *
         FROM cm_receipt_order_relation
-        WHERE orderID = #{orderID}
+        WHERE (orderID = #{orderId} or shopOrderId = #{shopOrderId})
           AND delFlag = '0'
         GROUP BY orderID
     </select>
 
+    <select id="getDiscernPayWay" resultType="java.lang.Integer">
+        SELECT cdr.payWay
+        FROM cm_receipt_order_relation cror
+                 LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
+        WHERE cror.orderID = #{orderID} and cror.delFlag = 0
+        ORDER BY cdr.payWay
+        LIMIT 1
+    </select>
+
     <select id="findOnlinePayment" resultType="date">
         SELECT cdr.receiptDate
         FROM cm_receipt_order_relation cror

+ 848 - 21
src/main/resources/mappings/modules/order/OrderMapper.xml

@@ -173,6 +173,12 @@
             <if test="orderNo != null and orderNo != ''">
                 AND co.orderNo = #{orderNo}
             </if>
+            <if test="shopOrderID != null and shopOrderID != ''">
+                AND cso.shopOrderID = #{shopOrderID}
+            </if>
+            <if test="shopOrderNo != null and shopOrderNo != ''">
+                AND cso.shopOrderNo = #{shopOrderNo}
+            </if>
             <if test="organizeID != null">
                 AND co.organizeID = #{organizeID}
             </if>
@@ -1132,14 +1138,6 @@
         ORDER BY cop.discountPrice DESC
     </select>
 
-    <select id="getOrderProductPaidAmount" resultType="java.lang.Double">
-        SELECT SUM(splitAccount)
-        FROM cm_split_account
-        WHERE orderProductId = #{orderProductId}
-          AND payStatus = 1
-          AND productType = 1
-    </select>
-
     <select id="getShopOrderListByOrderId" resultType="com.caimei.modules.order.entity.ShopOrderVo">
         SELECT shopOrderID AS shopOrderId,
                shopOrderNo,
@@ -1159,7 +1157,7 @@
                productAmount,
                needPayAmount,
                shopProductAmount,
-               shopPostFee,
+               ifnull(shopPostFee, 0) as shopPostFee,
                shopTaxFee,
                shouldPayShopAmount,
                orderTime,
@@ -1167,7 +1165,10 @@
                payStatus,
                sendOutStatus,
                splitFlag,
-               splitCode
+               splitCode,
+               organizeId,
+               ifnull(promotionFullReduction,0) as promotionFullReduction,
+               ifnull(couponAmount,0) as couponAmount
         FROM cm_shop_order
         WHERE delFlag = 0
           AND shopOrderID = #{shopOrderId}
@@ -1265,7 +1266,6 @@
                cop.productImage                                                   AS image,
                cop.price,
                cop.shopName,
-               IF(cop.shopid = 998 AND co.freight > 0, co.freight, cop.costPrice) AS costPrice,
                cop.normalPrice,
                cop.ladderPriceFlag,
                cop.discountPrice,
@@ -1296,17 +1296,19 @@
                cop.notOutStore,
                cop.isActProduct                                                   AS actProduct,
                cop.productType,
-               p.productCategory                                                  as productCategory,
-               p.splitCode,
-               cs.shopPercent,
-               cs.cmPercent,
-               cs.organizePercent
+               p.productCategory                                                  AS productCategory,
+               cop.organizeId,
+#                当前版本采美豆抵运费未实装,且运费子订单已取消,运费金额并入子订单,取值不做操作
+#                IF(cop.shopid = 998 AND co.freight > 0, co.freight, cop.costPrice) AS costPrice,
+               IFNULL(cop.costPrice,0)                                            AS costPrice,
+               IFNULL(cop.organizeCostPrice,0)                                    AS organizeCostPrice,
+               IFNULL(cop.cmCostPrice,0)                                          AS cmCostPrice,
+               p.splitCode
         FROM cm_order_product cop
-                 LEFT JOIN product p ON cop.productID = p.productID
-                 left join cm_order co on co.orderID = cop.orderID
-                 left join cm_sku cs on cop.skuId = cs.skuId and cop.organizeID=cs.organizeID
+        LEFT JOIN product p ON cop.productID = p.productID
+        left join cm_order co on co.orderID = cop.orderID
         WHERE cop.shopOrderID = #{shopOrderId}
-          AND IF(co.userBeans = 0, 1 = 1, cop.shopid != 998)
+#           AND IF(co.userBeans = 0, 1 = 1, cop.shopid != 998)
         group by p.productID
         ORDER BY cop.discountPrice DESC
     </select>
@@ -1329,7 +1331,7 @@
                productAmount,
                needPayAmount,
                shopProductAmount,
-               shopPostFee,
+               ifnull(shopPostFee, 0) as shopPostFee,
                shopTaxFee,
                shouldPayShopAmount,
                orderTime,
@@ -1455,6 +1457,13 @@
         from cm_voucher_image
         where voucherId = #{id}
     </select>
+    <select id="getPaidOrganizePrice" resultType="java.lang.Double">
+        SELECT ifnull(SUM(splitAccount),0)
+        FROM cm_split_account
+        WHERE shopOrderId = #{shopOrderId}
+          AND payStatus = 1
+          AND productType = 5
+    </select>
     <insert id="insertSplitAccount">
         INSERT INTO cm_split_account (orderId, productId, orderProductId, shopId, couponRecordId, vipRecordId,
                                       authVipRecordId, type, subUserNo, splitAccount,
@@ -1491,4 +1500,822 @@
         WHERE shopOrderID = #{shopOrderID}
     </update>
 
+    <resultMap type="com.caimei.modules.order.entity.NewOrder" id="CmOrderResult">
+        <result property="orderID"    column="orderID"    />
+        <result property="orderNo"    column="orderNo"    />
+        <result property="organizeID"    column="organizeID"    />
+        <result property="userID"    column="userID"    />
+        <result property="buyUserID"    column="buyUserID"    />
+        <result property="organizeStoreId"    column="organizeStoreId"    />
+        <result property="shopOrderIDs"    column="shopOrderIDs"    />
+        <result property="orderSubmitType"    column="orderSubmitType"    />
+        <result property="orderType"    column="orderType"    />
+        <result property="hasActProduct"    column="hasActProduct"    />
+        <result property="status"    column="status"    />
+        <result property="receiptStatus"    column="receiptStatus"    />
+        <result property="payStatus"    column="payStatus"    />
+        <result property="sendOutStatus"    column="sendOutStatus"    />
+        <result property="refundType"    column="refundType"    />
+        <result property="paySuccessCounter"    column="paySuccessCounter"    />
+        <result property="payFlag"    column="payFlag"    />
+        <result property="onlinePayFlag"    column="onlinePayFlag"    />
+        <result property="productTotalFee"    column="productTotalFee"    />
+        <result property="orderTotalFee"    column="orderTotalFee"    />
+        <result property="payTotalFee"    column="payTotalFee"    />
+        <result property="payableAmount"    column="payableAmount"    />
+        <result property="balancePayFee"    column="balancePayFee"    />
+        <result property="preferential"    column="preferential"    />
+        <result property="discountFee"    column="discountFee"    />
+        <result property="promotionFullReduction"    column="promotionFullReduction"    />
+        <result property="spID"    column="spID"    />
+        <result property="mainSpID"    column="mainSpID"    />
+        <result property="note"    column="note"    />
+        <result property="clubID"    column="clubID"    />
+        <result property="clubScanTime"    column="clubScanTime"    />
+        <result property="orderSource"    column="orderSource"    />
+        <result property="closeTime"    column="closeTime"    />
+        <result property="confirmTime"    column="confirmTime"    />
+        <result property="payTime"    column="payTime"    />
+        <result property="orderTime"    column="orderTime"    />
+        <result property="productCount"    column="productCount"    />
+        <result property="presentCount"    column="presentCount"    />
+        <result property="promotionalGiftsCount"    column="promotionalGiftsCount"    />
+        <result property="invoiceFlag"    column="invoiceFlag"    />
+        <result property="confirmFlag"    column="confirmFlag"    />
+        <result property="clauseID"    column="clauseID"    />
+        <result property="clauseContent"    column="clauseContent"    />
+        <result property="clauseName"    column="clauseName"    />
+        <result property="updateDate"    column="updateDate"    />
+        <result property="freePostFlag"    column="freePostFlag"    />
+        <result property="freight"    column="freight"    />
+        <result property="userBeans"    column="userBeans"    />
+        <result property="delFlag"    column="delFlag"    />
+        <result property="freePostageTicketID"    column="freePostageTicketID"    />
+        <result property="splitFlag"    column="splitFlag"    />
+        <result property="closeReason"    column="closeReason"    />
+        <result property="postageOrderFlag"    column="postageOrderFlag"    />
+        <result property="thirdPartyOrderNo"    column="thirdPartyOrderNo"    />
+        <result property="synchronizeFlag"    column="synchronizeFlag"    />
+        <result property="secondHandOrderFlag"    column="secondHandOrderFlag"    />
+        <result property="affirmPaymentFlag"    column="affirmPaymentFlag"    />
+        <result property="rebateFlag"    column="rebateFlag"    />
+        <result property="rebateFee"    column="rebateFee"    />
+        <result property="zeroCostFlag"    column="zeroCostFlag"    />
+        <result property="couponAmount"    column="couponAmount"    />
+        <result property="svipFullReduction"    column="svipFullReduction"    />
+        <result property="orderSeen"    column="orderSeen"    />
+        <result property="reductionAmount"    column="reductionAmount"    />
+        <result property="unionID"    column="unionID"    />
+    </resultMap>
+
+    <sql id="selectCmOrderVo">
+        select
+            cm_order.orderID,
+            cm_order.orderNo,
+            cm_order.apiOrganizeOrderId,
+            cm_order.organizeID,
+            cm_order.userID,
+            cm_order.buyUserID,
+            cm_order.organizeStoreId,
+            cm_order.shopOrderIDs,
+            cm_order.orderSubmitType,
+            cm_order.orderType,
+            cm_order.hasActProduct,
+            cm_order.status,
+            cm_order.receiptStatus,
+            cm_order.payStatus,
+            cm_order.sendOutStatus,
+            cm_order.refundType,
+            cm_order.paySuccessCounter,
+            cm_order.payFlag,
+            cm_order.onlinePayFlag,
+            cm_order.productTotalFee,
+            cm_order.orderTotalFee,
+            cm_order.payTotalFee,
+            cm_order.payableAmount,
+            cm_order.balancePayFee,
+            cm_order.preferential,
+            cm_order.discountFee,
+            cm_order.promotionFullReduction,
+            cm_order.spID,
+            cm_order.mainSpID,
+            cm_order.note,
+            cm_order.clubID,
+            cm_order.clubScanTime,
+            cm_order.orderSource,
+            cm_order.closeTime,
+            cm_order.confirmTime,
+            cm_order.payTime,
+            cm_order.orderTime,
+            cm_order.productCount,
+            cm_order.presentCount,
+            cm_order.promotionalGiftsCount,
+            cm_order.invoiceFlag,
+            cm_order.confirmFlag,
+            cm_order.clauseID,
+            cm_order.clauseContent,
+            cm_order.clauseName,
+            cm_order.updateDate,
+            cm_order.freePostFlag,
+            cm_order.freight,
+            cm_order.userBeans,
+            cm_order.delFlag,
+            cm_order.freePostageTicketID,
+            cm_order.splitFlag,
+            cm_order.closeReason,
+            cm_order.postageOrderFlag,
+            cm_order.thirdPartyOrderNo,
+            cm_order.synchronizeFlag,
+            cm_order.secondHandOrderFlag,
+            cm_order.affirmPaymentFlag,
+            cm_order.rebateFlag,
+            cm_order.rebateFee,
+            cm_order.zeroCostFlag,
+            cm_order.couponAmount,
+            cm_order.svipFullReduction,
+            cm_order.orderSeen,
+            cm_order.reductionAmount,
+            cm_order.unionID
+    </sql>
+
+    <select id="getByCmOrder" parameterType="com.caimei.modules.order.entity.NewOrder" resultMap="CmOrderResult">
+        <include refid="selectCmOrderVo"/>
+        from cm_order AS cm_order
+        <where>  cm_order.delFlag = 0
+            <if test="orderID != null  and orderID != ''">
+                and cm_order.orderID
+                    = #{orderID}
+            </if>
+            <if test="orderNo != null  and orderNo != ''"> and cm_order.orderNo = #{orderNo}</if>
+            <if test="apiOrganizeOrderId != null  and apiOrganizeOrderId != ''"> and cm_order.apiOrganizeOrderId = #{apiOrganizeOrderId}</if>
+            <if test="organizeID != null "> and cm_order.organizeID = #{organizeID}</if>
+            <if test="userID != null "> and cm_order.userID = #{userID}</if>
+            <if test="buyUserID != null "> and cm_order.buyUserID = #{buyUserID}</if>
+            <if test="organizeStoreId != null "> and cm_order.organizeStoreId = #{organizeStoreId}</if>
+            <if test="shopOrderIDs != null  and shopOrderIDs != ''"> and cm_order.shopOrderIDs = #{shopOrderIDs}</if>
+            <if test="orderSubmitType != null "> and cm_order.orderSubmitType = #{orderSubmitType}</if>
+            <if test="orderType != null "> and cm_order.orderType = #{orderType}</if>
+            <if test="hasActProduct != null  and hasActProduct != ''"> and cm_order.hasActProduct = #{hasActProduct}</if>
+            <if test="status != null  and status != ''"> and cm_order.status = #{status}</if>
+            <if test="receiptStatus != null  and receiptStatus != ''"> and cm_order.receiptStatus = #{receiptStatus}</if>
+            <if test="payStatus != null  and payStatus != ''"> and cm_order.payStatus = #{payStatus}</if>
+            <if test="sendOutStatus != null  and sendOutStatus != ''"> and cm_order.sendOutStatus = #{sendOutStatus}</if>
+            <if test="refundType != null  and refundType != ''"> and cm_order.refundType = #{refundType}</if>
+            <if test="paySuccessCounter != null "> and cm_order.paySuccessCounter = #{paySuccessCounter}</if>
+            <if test="payFlag != null  and payFlag != ''"> and cm_order.payFlag = #{payFlag}</if>
+            <if test="onlinePayFlag != null  and onlinePayFlag != ''"> and cm_order.onlinePayFlag = #{onlinePayFlag}</if>
+            <if test="productTotalFee != null "> and cm_order.productTotalFee = #{productTotalFee}</if>
+            <if test="orderTotalFee != null "> and cm_order.orderTotalFee = #{orderTotalFee}</if>
+            <if test="payTotalFee != null "> and cm_order.payTotalFee = #{payTotalFee}</if>
+            <if test="payableAmount != null "> and cm_order.payableAmount = #{payableAmount}</if>
+            <if test="balancePayFee != null "> and cm_order.balancePayFee = #{balancePayFee}</if>
+            <if test="preferential != null "> and cm_order.preferential = #{preferential}</if>
+            <if test="discountFee != null "> and cm_order.discountFee = #{discountFee}</if>
+            <if test="promotionFullReduction != null "> and cm_order.promotionFullReduction = #{promotionFullReduction}</if>
+            <if test="spID != null "> and cm_order.spID = #{spID}</if>
+            <if test="mainSpID != null "> and cm_order.mainSpID = #{mainSpID}</if>
+            <if test="note != null  and note != ''"> and cm_order.note = #{note}</if>
+            <if test="clubID != null "> and cm_order.clubID = #{clubID}</if>
+            <if test="clubScanTime != null  and clubScanTime != ''"> and cm_order.clubScanTime = #{clubScanTime}</if>
+            <if test="orderSource != null  and orderSource != ''"> and cm_order.orderSource = #{orderSource}</if>
+            <if test="closeTime != null  and closeTime != ''"> and cm_order.closeTime = #{closeTime}</if>
+            <if test="confirmTime != null  and confirmTime != ''"> and cm_order.confirmTime = #{confirmTime}</if>
+            <if test="payTime != null  and payTime != ''"> and cm_order.payTime = #{payTime}</if>
+            <if test="orderTime != null  and orderTime != ''"> and cm_order.orderTime = #{orderTime}</if>
+            <if test="productCount != null "> and cm_order.productCount = #{productCount}</if>
+            <if test="presentCount != null "> and cm_order.presentCount = #{presentCount}</if>
+            <if test="promotionalGiftsCount != null "> and cm_order.promotionalGiftsCount = #{promotionalGiftsCount}</if>
+            <if test="invoiceFlag != null  and invoiceFlag != ''"> and cm_order.invoiceFlag = #{invoiceFlag}</if>
+            <if test="confirmFlag != null  and confirmFlag != ''"> and cm_order.confirmFlag = #{confirmFlag}</if>
+            <if test="clauseID != null "> and cm_order.clauseID = #{clauseID}</if>
+            <if test="clauseContent != null  and clauseContent != ''"> and cm_order.clauseContent = #{clauseContent}</if>
+            <if test="clauseName != null  and clauseName != ''"> and cm_order.clauseName like concat('%', #{clauseName}, '%')</if>
+            <if test="updateDate != null  and updateDate != ''"> and cm_order.updateDate = #{updateDate}</if>
+            <if test="freePostFlag != null  and freePostFlag != ''"> and cm_order.freePostFlag = #{freePostFlag}</if>
+            <if test="freight != null "> and cm_order.freight = #{freight}</if>
+            <if test="userBeans != null "> and cm_order.userBeans = #{userBeans}</if>
+            <if test="delFlag != null  and delFlag != ''"> and cm_order.delFlag = #{delFlag}</if>
+            <if test="freePostageTicketID != null "> and cm_order.freePostageTicketID = #{freePostageTicketID}</if>
+            <if test="splitFlag != null  and splitFlag != ''"> and cm_order.splitFlag = #{splitFlag}</if>
+            <if test="closeReason != null  and closeReason != ''"> and cm_order.closeReason = #{closeReason}</if>
+            <if test="postageOrderFlag != null  and postageOrderFlag != ''"> and cm_order.postageOrderFlag = #{postageOrderFlag}</if>
+            <if test="thirdPartyOrderNo != null  and thirdPartyOrderNo != ''"> and cm_order.thirdPartyOrderNo = #{thirdPartyOrderNo}</if>
+            <if test="synchronizeFlag != null  and synchronizeFlag != ''"> and cm_order.synchronizeFlag = #{synchronizeFlag}</if>
+            <if test="secondHandOrderFlag != null  and secondHandOrderFlag != ''"> and cm_order.secondHandOrderFlag = #{secondHandOrderFlag}</if>
+            <if test="affirmPaymentFlag != null  and affirmPaymentFlag != ''"> and cm_order.affirmPaymentFlag = #{affirmPaymentFlag}</if>
+            <if test="rebateFlag != null  and rebateFlag != ''"> and cm_order.rebateFlag = #{rebateFlag}</if>
+            <if test="rebateFee != null  and rebateFee != ''"> and cm_order.rebateFee = #{rebateFee}</if>
+            <if test="zeroCostFlag != null "> and cm_order.zeroCostFlag = #{zeroCostFlag}</if>
+            <if test="couponAmount != null "> and cm_order.couponAmount = #{couponAmount}</if>
+            <if test="svipFullReduction != null "> and cm_order.svipFullReduction = #{svipFullReduction}</if>
+            <if test="orderSeen != null  and orderSeen != ''"> and cm_order.orderSeen = #{orderSeen}</if>
+            <if test="reductionAmount != null "> and cm_order.reductionAmount = #{reductionAmount}</if>
+            <if test="unionID != null  and unionID != ''"> and cm_order.unionID = #{unionID}</if>
+        </where>
+        group by cm_order.orderID
+        order by cm_order.orderTime desc
+        limit 0,1
+    </select>
+
+    <select id="getCmOrderList" parameterType="com.caimei.modules.order.entity.NewOrder" resultMap="CmOrderResult">
+        <include refid="selectCmOrderVo"/>
+        from cm_order AS cm_order
+        <where>  cm_order.delFlag = 0
+            <if test="orderID != null  and orderID != ''">
+                and cm_order.orderID
+                    = #{orderID}
+            </if>
+            <if test="orderNo != null  and orderNo != ''"> and cm_order.orderNo = #{orderNo}</if>
+            <if test="apiOrganizeOrderId != null  and apiOrganizeOrderId != ''"> and cm_order.apiOrganizeOrderId = #{apiOrganizeOrderId}</if>
+            <if test="organizeID != null "> and cm_order.organizeID = #{organizeID}</if>
+            <if test="userID != null "> and cm_order.userID = #{userID}</if>
+            <if test="buyUserID != null "> and cm_order.buyUserID = #{buyUserID}</if>
+            <if test="organizeStoreId != null "> and cm_order.organizeStoreId = #{organizeStoreId}</if>
+            <if test="shopOrderIDs != null  and shopOrderIDs != ''"> and cm_order.shopOrderIDs = #{shopOrderIDs}</if>
+            <if test="orderSubmitType != null "> and cm_order.orderSubmitType = #{orderSubmitType}</if>
+            <if test="orderType != null "> and cm_order.orderType = #{orderType}</if>
+            <if test="hasActProduct != null  and hasActProduct != ''"> and cm_order.hasActProduct = #{hasActProduct}</if>
+            <if test="status != null  and status != ''"> and cm_order.status = #{status}</if>
+            <if test="receiptStatus != null  and receiptStatus != ''"> and cm_order.receiptStatus = #{receiptStatus}</if>
+            <if test="payStatus != null  and payStatus != ''"> and cm_order.payStatus = #{payStatus}</if>
+            <if test="sendOutStatus != null  and sendOutStatus != ''"> and cm_order.sendOutStatus = #{sendOutStatus}</if>
+            <if test="refundType != null  and refundType != ''"> and cm_order.refundType = #{refundType}</if>
+            <if test="paySuccessCounter != null "> and cm_order.paySuccessCounter = #{paySuccessCounter}</if>
+            <if test="payFlag != null  and payFlag != ''"> and cm_order.payFlag = #{payFlag}</if>
+            <if test="onlinePayFlag != null  and onlinePayFlag != ''"> and cm_order.onlinePayFlag = #{onlinePayFlag}</if>
+            <if test="productTotalFee != null "> and cm_order.productTotalFee = #{productTotalFee}</if>
+            <if test="orderTotalFee != null "> and cm_order.orderTotalFee = #{orderTotalFee}</if>
+            <if test="payTotalFee != null "> and cm_order.payTotalFee = #{payTotalFee}</if>
+            <if test="payableAmount != null "> and cm_order.payableAmount = #{payableAmount}</if>
+            <if test="balancePayFee != null "> and cm_order.balancePayFee = #{balancePayFee}</if>
+            <if test="preferential != null "> and cm_order.preferential = #{preferential}</if>
+            <if test="discountFee != null "> and cm_order.discountFee = #{discountFee}</if>
+            <if test="promotionFullReduction != null "> and cm_order.promotionFullReduction = #{promotionFullReduction}</if>
+            <if test="spID != null "> and cm_order.spID = #{spID}</if>
+            <if test="mainSpID != null "> and cm_order.mainSpID = #{mainSpID}</if>
+            <if test="note != null  and note != ''"> and cm_order.note = #{note}</if>
+            <if test="clubID != null "> and cm_order.clubID = #{clubID}</if>
+            <if test="clubScanTime != null  and clubScanTime != ''"> and cm_order.clubScanTime = #{clubScanTime}</if>
+            <if test="orderSource != null  and orderSource != ''"> and cm_order.orderSource = #{orderSource}</if>
+            <if test="closeTime != null  and closeTime != ''"> and cm_order.closeTime = #{closeTime}</if>
+            <if test="confirmTime != null  and confirmTime != ''"> and cm_order.confirmTime = #{confirmTime}</if>
+            <if test="payTime != null  and payTime != ''"> and cm_order.payTime = #{payTime}</if>
+            <if test="orderTime != null  and orderTime != ''"> and cm_order.orderTime = #{orderTime}</if>
+            <if test="productCount != null "> and cm_order.productCount = #{productCount}</if>
+            <if test="presentCount != null "> and cm_order.presentCount = #{presentCount}</if>
+            <if test="promotionalGiftsCount != null "> and cm_order.promotionalGiftsCount = #{promotionalGiftsCount}</if>
+            <if test="invoiceFlag != null  and invoiceFlag != ''"> and cm_order.invoiceFlag = #{invoiceFlag}</if>
+            <if test="confirmFlag != null  and confirmFlag != ''"> and cm_order.confirmFlag = #{confirmFlag}</if>
+            <if test="clauseID != null "> and cm_order.clauseID = #{clauseID}</if>
+            <if test="clauseContent != null  and clauseContent != ''"> and cm_order.clauseContent = #{clauseContent}</if>
+            <if test="clauseName != null  and clauseName != ''"> and cm_order.clauseName like concat('%', #{clauseName}, '%')</if>
+            <if test="updateDate != null  and updateDate != ''"> and cm_order.updateDate = #{updateDate}</if>
+            <if test="freePostFlag != null  and freePostFlag != ''"> and cm_order.freePostFlag = #{freePostFlag}</if>
+            <if test="freight != null "> and cm_order.freight = #{freight}</if>
+            <if test="userBeans != null "> and cm_order.userBeans = #{userBeans}</if>
+            <if test="delFlag != null  and delFlag != ''"> and cm_order.delFlag = #{delFlag}</if>
+            <if test="freePostageTicketID != null "> and cm_order.freePostageTicketID = #{freePostageTicketID}</if>
+            <if test="splitFlag != null  and splitFlag != ''"> and cm_order.splitFlag = #{splitFlag}</if>
+            <if test="closeReason != null  and closeReason != ''"> and cm_order.closeReason = #{closeReason}</if>
+            <if test="postageOrderFlag != null  and postageOrderFlag != ''"> and cm_order.postageOrderFlag = #{postageOrderFlag}</if>
+            <if test="thirdPartyOrderNo != null  and thirdPartyOrderNo != ''"> and cm_order.thirdPartyOrderNo = #{thirdPartyOrderNo}</if>
+            <if test="synchronizeFlag != null  and synchronizeFlag != ''"> and cm_order.synchronizeFlag = #{synchronizeFlag}</if>
+            <if test="secondHandOrderFlag != null  and secondHandOrderFlag != ''"> and cm_order.secondHandOrderFlag = #{secondHandOrderFlag}</if>
+            <if test="affirmPaymentFlag != null  and affirmPaymentFlag != ''"> and cm_order.affirmPaymentFlag = #{affirmPaymentFlag}</if>
+            <if test="rebateFlag != null  and rebateFlag != ''"> and cm_order.rebateFlag = #{rebateFlag}</if>
+            <if test="rebateFee != null  and rebateFee != ''"> and cm_order.rebateFee = #{rebateFee}</if>
+            <if test="zeroCostFlag != null "> and cm_order.zeroCostFlag = #{zeroCostFlag}</if>
+            <if test="couponAmount != null "> and cm_order.couponAmount = #{couponAmount}</if>
+            <if test="svipFullReduction != null "> and cm_order.svipFullReduction = #{svipFullReduction}</if>
+            <if test="orderSeen != null  and orderSeen != ''"> and cm_order.orderSeen = #{orderSeen}</if>
+            <if test="reductionAmount != null "> and cm_order.reductionAmount = #{reductionAmount}</if>
+            <if test="unionID != null  and unionID != ''"> and cm_order.unionID = #{unionID}</if>
+        </where>
+        group by cm_order.orderID
+        order by cm_order.orderTime desc
+    </select>
+    <select id="getCmOrderCount" parameterType="com.caimei.modules.order.entity.NewOrder" resultType="String">
+        select count(1)
+        from cm_order AS cm_order
+        <where>  cm_order.delFlag = 0
+            <if test="orderID != null  and  orderID != ''">
+                and cm_order.orderID
+                    = #{orderID}
+            </if>
+            <if test="orderNo != null  and orderNo != ''"> and cm_order.orderNo = #{orderNo}</if>
+            <if test="apiOrganizeOrderId != null  and apiOrganizeOrderId != ''"> and cm_order.apiOrganizeOrderId = #{apiOrganizeOrderId}</if>
+            <if test="organizeID != null "> and cm_order.organizeID = #{organizeID}</if>
+            <if test="userID != null "> and cm_order.userID = #{userID}</if>
+            <if test="buyUserID != null "> and cm_order.buyUserID = #{buyUserID}</if>
+            <if test="organizeStoreId != null "> and cm_order.organizeStoreId = #{organizeStoreId}</if>
+            <if test="shopOrderIDs != null  and shopOrderIDs != ''"> and cm_order.shopOrderIDs = #{shopOrderIDs}</if>
+            <if test="orderSubmitType != null "> and cm_order.orderSubmitType = #{orderSubmitType}</if>
+            <if test="orderType != null "> and cm_order.orderType = #{orderType}</if>
+            <if test="hasActProduct != null  and hasActProduct != ''"> and cm_order.hasActProduct = #{hasActProduct}</if>
+            <if test="status != null  and status != ''"> and cm_order.status = #{status}</if>
+            <if test="receiptStatus != null  and receiptStatus != ''"> and cm_order.receiptStatus = #{receiptStatus}</if>
+            <if test="payStatus != null  and payStatus != ''"> and cm_order.payStatus = #{payStatus}</if>
+            <if test="sendOutStatus != null  and sendOutStatus != ''"> and cm_order.sendOutStatus = #{sendOutStatus}</if>
+            <if test="refundType != null  and refundType != ''"> and cm_order.refundType = #{refundType}</if>
+            <if test="paySuccessCounter != null "> and cm_order.paySuccessCounter = #{paySuccessCounter}</if>
+            <if test="payFlag != null  and payFlag != ''"> and cm_order.payFlag = #{payFlag}</if>
+            <if test="onlinePayFlag != null  and onlinePayFlag != ''"> and cm_order.onlinePayFlag = #{onlinePayFlag}</if>
+            <if test="productTotalFee != null "> and cm_order.productTotalFee = #{productTotalFee}</if>
+            <if test="orderTotalFee != null "> and cm_order.orderTotalFee = #{orderTotalFee}</if>
+            <if test="payTotalFee != null "> and cm_order.payTotalFee = #{payTotalFee}</if>
+            <if test="payableAmount != null "> and cm_order.payableAmount = #{payableAmount}</if>
+            <if test="balancePayFee != null "> and cm_order.balancePayFee = #{balancePayFee}</if>
+            <if test="preferential != null "> and cm_order.preferential = #{preferential}</if>
+            <if test="discountFee != null "> and cm_order.discountFee = #{discountFee}</if>
+            <if test="promotionFullReduction != null "> and cm_order.promotionFullReduction = #{promotionFullReduction}</if>
+            <if test="spID != null "> and cm_order.spID = #{spID}</if>
+            <if test="mainSpID != null "> and cm_order.mainSpID = #{mainSpID}</if>
+            <if test="note != null  and note != ''"> and cm_order.note = #{note}</if>
+            <if test="clubID != null "> and cm_order.clubID = #{clubID}</if>
+            <if test="clubScanTime != null  and clubScanTime != ''"> and cm_order.clubScanTime = #{clubScanTime}</if>
+            <if test="orderSource != null  and orderSource != ''"> and cm_order.orderSource = #{orderSource}</if>
+            <if test="closeTime != null  and closeTime != ''"> and cm_order.closeTime = #{closeTime}</if>
+            <if test="confirmTime != null  and confirmTime != ''"> and cm_order.confirmTime = #{confirmTime}</if>
+            <if test="payTime != null  and payTime != ''"> and cm_order.payTime = #{payTime}</if>
+            <if test="orderTime != null  and orderTime != ''"> and cm_order.orderTime = #{orderTime}</if>
+            <if test="productCount != null "> and cm_order.productCount = #{productCount}</if>
+            <if test="presentCount != null "> and cm_order.presentCount = #{presentCount}</if>
+            <if test="promotionalGiftsCount != null "> and cm_order.promotionalGiftsCount = #{promotionalGiftsCount}</if>
+            <if test="invoiceFlag != null  and invoiceFlag != ''"> and cm_order.invoiceFlag = #{invoiceFlag}</if>
+            <if test="confirmFlag != null  and confirmFlag != ''"> and cm_order.confirmFlag = #{confirmFlag}</if>
+            <if test="clauseID != null "> and cm_order.clauseID = #{clauseID}</if>
+            <if test="clauseContent != null  and clauseContent != ''"> and cm_order.clauseContent = #{clauseContent}</if>
+            <if test="clauseName != null  and clauseName != ''"> and cm_order.clauseName like concat('%', #{clauseName}, '%')</if>
+            <if test="updateDate != null  and updateDate != ''"> and cm_order.updateDate = #{updateDate}</if>
+            <if test="freePostFlag != null  and freePostFlag != ''"> and cm_order.freePostFlag = #{freePostFlag}</if>
+            <if test="freight != null "> and cm_order.freight = #{freight}</if>
+            <if test="userBeans != null "> and cm_order.userBeans = #{userBeans}</if>
+            <if test="delFlag != null  and delFlag != ''"> and cm_order.delFlag = #{delFlag}</if>
+            <if test="freePostageTicketID != null "> and cm_order.freePostageTicketID = #{freePostageTicketID}</if>
+            <if test="splitFlag != null  and splitFlag != ''"> and cm_order.splitFlag = #{splitFlag}</if>
+            <if test="closeReason != null  and closeReason != ''"> and cm_order.closeReason = #{closeReason}</if>
+            <if test="postageOrderFlag != null  and postageOrderFlag != ''"> and cm_order.postageOrderFlag = #{postageOrderFlag}</if>
+            <if test="thirdPartyOrderNo != null  and thirdPartyOrderNo != ''"> and cm_order.thirdPartyOrderNo = #{thirdPartyOrderNo}</if>
+            <if test="synchronizeFlag != null  and synchronizeFlag != ''"> and cm_order.synchronizeFlag = #{synchronizeFlag}</if>
+            <if test="secondHandOrderFlag != null  and secondHandOrderFlag != ''"> and cm_order.secondHandOrderFlag = #{secondHandOrderFlag}</if>
+            <if test="affirmPaymentFlag != null  and affirmPaymentFlag != ''"> and cm_order.affirmPaymentFlag = #{affirmPaymentFlag}</if>
+            <if test="rebateFlag != null  and rebateFlag != ''"> and cm_order.rebateFlag = #{rebateFlag}</if>
+            <if test="rebateFee != null  and rebateFee != ''"> and cm_order.rebateFee = #{rebateFee}</if>
+            <if test="zeroCostFlag != null "> and cm_order.zeroCostFlag = #{zeroCostFlag}</if>
+            <if test="couponAmount != null "> and cm_order.couponAmount = #{couponAmount}</if>
+            <if test="svipFullReduction != null "> and cm_order.svipFullReduction = #{svipFullReduction}</if>
+            <if test="orderSeen != null  and orderSeen != ''"> and cm_order.orderSeen = #{orderSeen}</if>
+            <if test="reductionAmount != null "> and cm_order.reductionAmount = #{reductionAmount}</if>
+            <if test="unionID != null  and unionID != ''"> and cm_order.unionID = #{unionID}</if>
+        </where>
+        group by cm_order.orderID
+    </select>
+
+    <select id="getCmOrderByOrderID" parameterType="String" resultMap="CmOrderResult">
+        <include refid="selectCmOrderVo"/>
+        from cm_order AS cm_order
+        where  cm_order.delFlag = 0 and cm_order.orderID = #{orderID}
+    </select>
+
+    <select id="getByIds" parameterType="com.caimei.modules.order.entity.NewOrder" resultType="String">
+        select orderID
+        from cm_order AS cm_order
+        <where>  cm_order.delFlag = 0
+            <if test="orderID != null  and orderID != ''">
+                and cm_order.orderID
+                    = #{orderID}
+            </if>
+            <if test="orderNo != null  and orderNo != ''"> and cm_order.orderNo = #{orderNo}</if>
+            <if test="apiOrganizeOrderId != null  and apiOrganizeOrderId != ''"> and cm_order.apiOrganizeOrderId = #{apiOrganizeOrderId}</if>
+            <if test="organizeID != null "> and cm_order.organizeID = #{organizeID}</if>
+            <if test="userID != null "> and cm_order.userID = #{userID}</if>
+            <if test="buyUserID != null "> and cm_order.buyUserID = #{buyUserID}</if>
+            <if test="organizeStoreId != null "> and cm_order.organizeStoreId = #{organizeStoreId}</if>
+            <if test="shopOrderIDs != null  and shopOrderIDs != ''"> and cm_order.shopOrderIDs = #{shopOrderIDs}</if>
+            <if test="orderSubmitType != null "> and cm_order.orderSubmitType = #{orderSubmitType}</if>
+            <if test="orderType != null "> and cm_order.orderType = #{orderType}</if>
+            <if test="hasActProduct != null  and hasActProduct != ''"> and cm_order.hasActProduct = #{hasActProduct}</if>
+            <if test="status != null  and status != ''"> and cm_order.status = #{status}</if>
+            <if test="receiptStatus != null  and receiptStatus != ''"> and cm_order.receiptStatus = #{receiptStatus}</if>
+            <if test="payStatus != null  and payStatus != ''"> and cm_order.payStatus = #{payStatus}</if>
+            <if test="sendOutStatus != null  and sendOutStatus != ''"> and cm_order.sendOutStatus = #{sendOutStatus}</if>
+            <if test="refundType != null  and refundType != ''"> and cm_order.refundType = #{refundType}</if>
+            <if test="paySuccessCounter != null "> and cm_order.paySuccessCounter = #{paySuccessCounter}</if>
+            <if test="payFlag != null  and payFlag != ''"> and cm_order.payFlag = #{payFlag}</if>
+            <if test="onlinePayFlag != null  and onlinePayFlag != ''"> and cm_order.onlinePayFlag = #{onlinePayFlag}</if>
+            <if test="productTotalFee != null "> and cm_order.productTotalFee = #{productTotalFee}</if>
+            <if test="orderTotalFee != null "> and cm_order.orderTotalFee = #{orderTotalFee}</if>
+            <if test="payTotalFee != null "> and cm_order.payTotalFee = #{payTotalFee}</if>
+            <if test="payableAmount != null "> and cm_order.payableAmount = #{payableAmount}</if>
+            <if test="balancePayFee != null "> and cm_order.balancePayFee = #{balancePayFee}</if>
+            <if test="preferential != null "> and cm_order.preferential = #{preferential}</if>
+            <if test="discountFee != null "> and cm_order.discountFee = #{discountFee}</if>
+            <if test="promotionFullReduction != null "> and cm_order.promotionFullReduction = #{promotionFullReduction}</if>
+            <if test="spID != null "> and cm_order.spID = #{spID}</if>
+            <if test="mainSpID != null "> and cm_order.mainSpID = #{mainSpID}</if>
+            <if test="note != null  and note != ''"> and cm_order.note = #{note}</if>
+            <if test="clubID != null "> and cm_order.clubID = #{clubID}</if>
+            <if test="clubScanTime != null  and clubScanTime != ''"> and cm_order.clubScanTime = #{clubScanTime}</if>
+            <if test="orderSource != null  and orderSource != ''"> and cm_order.orderSource = #{orderSource}</if>
+            <if test="closeTime != null  and closeTime != ''"> and cm_order.closeTime = #{closeTime}</if>
+            <if test="confirmTime != null  and confirmTime != ''"> and cm_order.confirmTime = #{confirmTime}</if>
+            <if test="payTime != null  and payTime != ''"> and cm_order.payTime = #{payTime}</if>
+            <if test="orderTime != null  and orderTime != ''"> and cm_order.orderTime = #{orderTime}</if>
+            <if test="productCount != null "> and cm_order.productCount = #{productCount}</if>
+            <if test="presentCount != null "> and cm_order.presentCount = #{presentCount}</if>
+            <if test="promotionalGiftsCount != null "> and cm_order.promotionalGiftsCount = #{promotionalGiftsCount}</if>
+            <if test="invoiceFlag != null  and invoiceFlag != ''"> and cm_order.invoiceFlag = #{invoiceFlag}</if>
+            <if test="confirmFlag != null  and confirmFlag != ''"> and cm_order.confirmFlag = #{confirmFlag}</if>
+            <if test="clauseID != null "> and cm_order.clauseID = #{clauseID}</if>
+            <if test="clauseContent != null  and clauseContent != ''"> and cm_order.clauseContent = #{clauseContent}</if>
+            <if test="clauseName != null  and clauseName != ''"> and cm_order.clauseName like concat('%', #{clauseName}, '%')</if>
+            <if test="updateDate != null  and updateDate != ''"> and cm_order.updateDate = #{updateDate}</if>
+            <if test="freePostFlag != null  and freePostFlag != ''"> and cm_order.freePostFlag = #{freePostFlag}</if>
+            <if test="freight != null "> and cm_order.freight = #{freight}</if>
+            <if test="userBeans != null "> and cm_order.userBeans = #{userBeans}</if>
+            <if test="delFlag != null  and delFlag != ''"> and cm_order.delFlag = #{delFlag}</if>
+            <if test="freePostageTicketID != null "> and cm_order.freePostageTicketID = #{freePostageTicketID}</if>
+            <if test="splitFlag != null  and splitFlag != ''"> and cm_order.splitFlag = #{splitFlag}</if>
+            <if test="closeReason != null  and closeReason != ''"> and cm_order.closeReason = #{closeReason}</if>
+            <if test="postageOrderFlag != null  and postageOrderFlag != ''"> and cm_order.postageOrderFlag = #{postageOrderFlag}</if>
+            <if test="thirdPartyOrderNo != null  and thirdPartyOrderNo != ''"> and cm_order.thirdPartyOrderNo = #{thirdPartyOrderNo}</if>
+            <if test="synchronizeFlag != null  and synchronizeFlag != ''"> and cm_order.synchronizeFlag = #{synchronizeFlag}</if>
+            <if test="secondHandOrderFlag != null  and secondHandOrderFlag != ''"> and cm_order.secondHandOrderFlag = #{secondHandOrderFlag}</if>
+            <if test="affirmPaymentFlag != null  and affirmPaymentFlag != ''"> and cm_order.affirmPaymentFlag = #{affirmPaymentFlag}</if>
+            <if test="rebateFlag != null  and rebateFlag != ''"> and cm_order.rebateFlag = #{rebateFlag}</if>
+            <if test="rebateFee != null  and rebateFee != ''"> and cm_order.rebateFee = #{rebateFee}</if>
+            <if test="zeroCostFlag != null "> and cm_order.zeroCostFlag = #{zeroCostFlag}</if>
+            <if test="couponAmount != null "> and cm_order.couponAmount = #{couponAmount}</if>
+            <if test="svipFullReduction != null "> and cm_order.svipFullReduction = #{svipFullReduction}</if>
+            <if test="orderSeen != null  and orderSeen != ''"> and cm_order.orderSeen = #{orderSeen}</if>
+            <if test="reductionAmount != null "> and cm_order.reductionAmount = #{reductionAmount}</if>
+            <if test="unionID != null  and unionID != ''"> and cm_order.unionID = #{unionID}</if>
+        </where>
+        group by cm_order.orderID
+    </select>
+    <select id="getById" parameterType="com.caimei.modules.order.entity.NewOrder" resultType="String">
+        select orderID
+        from cm_order AS cm_order
+        <where>  cm_order.delFlag = 0
+            <if test="orderID != null  and orderID != ''">
+                and cm_order.orderID
+                    = #{orderID}
+            </if>
+            <if test="orderNo != null  and orderNo != ''"> and cm_order.orderNo = #{orderNo}</if>
+            <if test="apiOrganizeOrderId != null  and apiOrganizeOrderId != ''"> and cm_order.apiOrganizeOrderId = #{apiOrganizeOrderId}</if>
+            <if test="organizeID != null "> and cm_order.organizeID = #{organizeID}</if>
+            <if test="userID != null "> and cm_order.userID = #{userID}</if>
+            <if test="buyUserID != null "> and cm_order.buyUserID = #{buyUserID}</if>
+            <if test="organizeStoreId != null "> and cm_order.organizeStoreId = #{organizeStoreId}</if>
+            <if test="shopOrderIDs != null  and shopOrderIDs != ''"> and cm_order.shopOrderIDs = #{shopOrderIDs}</if>
+            <if test="orderSubmitType != null "> and cm_order.orderSubmitType = #{orderSubmitType}</if>
+            <if test="orderType != null "> and cm_order.orderType = #{orderType}</if>
+            <if test="hasActProduct != null  and hasActProduct != ''"> and cm_order.hasActProduct = #{hasActProduct}</if>
+            <if test="status != null  and status != ''"> and cm_order.status = #{status}</if>
+            <if test="receiptStatus != null  and receiptStatus != ''"> and cm_order.receiptStatus = #{receiptStatus}</if>
+            <if test="payStatus != null  and payStatus != ''"> and cm_order.payStatus = #{payStatus}</if>
+            <if test="sendOutStatus != null  and sendOutStatus != ''"> and cm_order.sendOutStatus = #{sendOutStatus}</if>
+            <if test="refundType != null  and refundType != ''"> and cm_order.refundType = #{refundType}</if>
+            <if test="paySuccessCounter != null "> and cm_order.paySuccessCounter = #{paySuccessCounter}</if>
+            <if test="payFlag != null  and payFlag != ''"> and cm_order.payFlag = #{payFlag}</if>
+            <if test="onlinePayFlag != null  and onlinePayFlag != ''"> and cm_order.onlinePayFlag = #{onlinePayFlag}</if>
+            <if test="productTotalFee != null "> and cm_order.productTotalFee = #{productTotalFee}</if>
+            <if test="orderTotalFee != null "> and cm_order.orderTotalFee = #{orderTotalFee}</if>
+            <if test="payTotalFee != null "> and cm_order.payTotalFee = #{payTotalFee}</if>
+            <if test="payableAmount != null "> and cm_order.payableAmount = #{payableAmount}</if>
+            <if test="balancePayFee != null "> and cm_order.balancePayFee = #{balancePayFee}</if>
+            <if test="preferential != null "> and cm_order.preferential = #{preferential}</if>
+            <if test="discountFee != null "> and cm_order.discountFee = #{discountFee}</if>
+            <if test="promotionFullReduction != null "> and cm_order.promotionFullReduction = #{promotionFullReduction}</if>
+            <if test="spID != null "> and cm_order.spID = #{spID}</if>
+            <if test="mainSpID != null "> and cm_order.mainSpID = #{mainSpID}</if>
+            <if test="note != null  and note != ''"> and cm_order.note = #{note}</if>
+            <if test="clubID != null "> and cm_order.clubID = #{clubID}</if>
+            <if test="clubScanTime != null  and clubScanTime != ''"> and cm_order.clubScanTime = #{clubScanTime}</if>
+            <if test="orderSource != null  and orderSource != ''"> and cm_order.orderSource = #{orderSource}</if>
+            <if test="closeTime != null  and closeTime != ''"> and cm_order.closeTime = #{closeTime}</if>
+            <if test="confirmTime != null  and confirmTime != ''"> and cm_order.confirmTime = #{confirmTime}</if>
+            <if test="payTime != null  and payTime != ''"> and cm_order.payTime = #{payTime}</if>
+            <if test="orderTime != null  and orderTime != ''"> and cm_order.orderTime = #{orderTime}</if>
+            <if test="productCount != null "> and cm_order.productCount = #{productCount}</if>
+            <if test="presentCount != null "> and cm_order.presentCount = #{presentCount}</if>
+            <if test="promotionalGiftsCount != null "> and cm_order.promotionalGiftsCount = #{promotionalGiftsCount}</if>
+            <if test="invoiceFlag != null  and invoiceFlag != ''"> and cm_order.invoiceFlag = #{invoiceFlag}</if>
+            <if test="confirmFlag != null  and confirmFlag != ''"> and cm_order.confirmFlag = #{confirmFlag}</if>
+            <if test="clauseID != null "> and cm_order.clauseID = #{clauseID}</if>
+            <if test="clauseContent != null  and clauseContent != ''"> and cm_order.clauseContent = #{clauseContent}</if>
+            <if test="clauseName != null  and clauseName != ''"> and cm_order.clauseName like concat('%', #{clauseName}, '%')</if>
+            <if test="updateDate != null  and updateDate != ''"> and cm_order.updateDate = #{updateDate}</if>
+            <if test="freePostFlag != null  and freePostFlag != ''"> and cm_order.freePostFlag = #{freePostFlag}</if>
+            <if test="freight != null "> and cm_order.freight = #{freight}</if>
+            <if test="userBeans != null "> and cm_order.userBeans = #{userBeans}</if>
+            <if test="delFlag != null  and delFlag != ''"> and cm_order.delFlag = #{delFlag}</if>
+            <if test="freePostageTicketID != null "> and cm_order.freePostageTicketID = #{freePostageTicketID}</if>
+            <if test="splitFlag != null  and splitFlag != ''"> and cm_order.splitFlag = #{splitFlag}</if>
+            <if test="closeReason != null  and closeReason != ''"> and cm_order.closeReason = #{closeReason}</if>
+            <if test="postageOrderFlag != null  and postageOrderFlag != ''"> and cm_order.postageOrderFlag = #{postageOrderFlag}</if>
+            <if test="thirdPartyOrderNo != null  and thirdPartyOrderNo != ''"> and cm_order.thirdPartyOrderNo = #{thirdPartyOrderNo}</if>
+            <if test="synchronizeFlag != null  and synchronizeFlag != ''"> and cm_order.synchronizeFlag = #{synchronizeFlag}</if>
+            <if test="secondHandOrderFlag != null  and secondHandOrderFlag != ''"> and cm_order.secondHandOrderFlag = #{secondHandOrderFlag}</if>
+            <if test="affirmPaymentFlag != null  and affirmPaymentFlag != ''"> and cm_order.affirmPaymentFlag = #{affirmPaymentFlag}</if>
+            <if test="rebateFlag != null  and rebateFlag != ''"> and cm_order.rebateFlag = #{rebateFlag}</if>
+            <if test="rebateFee != null  and rebateFee != ''"> and cm_order.rebateFee = #{rebateFee}</if>
+            <if test="zeroCostFlag != null "> and cm_order.zeroCostFlag = #{zeroCostFlag}</if>
+            <if test="couponAmount != null "> and cm_order.couponAmount = #{couponAmount}</if>
+            <if test="svipFullReduction != null "> and cm_order.svipFullReduction = #{svipFullReduction}</if>
+            <if test="orderSeen != null  and orderSeen != ''"> and cm_order.orderSeen = #{orderSeen}</if>
+            <if test="reductionAmount != null "> and cm_order.reductionAmount = #{reductionAmount}</if>
+            <if test="unionID != null  and unionID != ''"> and cm_order.unionID = #{unionID}</if>
+        </where>
+        group by cm_order.orderID
+        limit 0,1
+    </select>
+
+    <select id="findSplitCodeByOrganize" resultType="java.lang.String">
+        select splitCode from cm_mall_organize where id = #{organizeId}
+    </select>
+
+    <select id="findPayOther" resultType="java.lang.Double">
+        SELECT IFNULL(SUM(payAmount),0)
+        FROM cm_pay_shop_record cpsr
+        LEFT JOIN cm_pay_shop cps ON cpsr.payShopID = cps.id
+        WHERE cpsr.delFLag = 0
+          AND cps.delFlag = 0
+          AND cpsr.paymentType = 3
+          AND cps.status = 1
+          AND cpsr.status = 1
+          AND cpsr.shopOrderId = #{shopOrderId}
+    </select>
+
+    <select id="getShopOrderPaidAmount" resultType="java.lang.Double">
+        SELECT ifnull(SUM(splitAccount),0)
+        FROM cm_split_account
+        WHERE shopOrderId = #{shopOrderId}
+          AND payStatus = 1
+          AND productType = 1
+    </select>
+
+    <select id="getOtherPaid" resultType="java.lang.Double">
+        SELECT ifnull(SUM(splitAccount),0)
+        FROM cm_split_account
+        WHERE shopOrderId = #{shopOrderId}
+          AND payStatus = 1
+          AND productType = 6
+          AND type = 6
+    </select>
+
+    <select id="findShopCost" resultType="java.lang.Double">
+        SELECT ifnull(SUM(splitAccount),0)
+        FROM cm_split_account
+        WHERE shopOrderId = #{shopOrderId}
+          AND payStatus = 1
+          AND productType = 1
+    </select>
+
+    <select id="findPayOrganize" resultType="java.lang.Double">
+        SELECT ifnull(SUM(splitAccount),0)
+        FROM cm_split_account
+        WHERE shopOrderId = #{shopOrderId}
+          AND payStatus = 1
+          AND productType = 5
+    </select>
+
+    <select id="findOrganizeSplitByShopOrder" resultType="java.lang.String">
+        select cmo.splitCode
+        from cm_mall_organize cmo
+        left join cm_shop_order cso on cmo.id = cso.organizeID
+        where cso.shopOrderID = #{shopOrderId}
+    </select>
+
+    <insert id="addCmOrder" parameterType="com.caimei.modules.order.entity.NewOrder" useGeneratedKeys="true" keyProperty="orderID">
+        insert into cm_order
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="orderID != null and orderID != ''">orderID,</if>
+            <if test="orderNo != null and orderNo != ''">orderNo,</if>
+            <if test="apiOrganizeOrderId != null and apiOrganizeOrderId != ''">apiOrganizeOrderId,</if>
+            <if test="organizeID != null">organizeID,</if>
+            <if test="userID != null">userID,</if>
+            <if test="buyUserID != null">buyUserID,</if>
+            <if test="organizeStoreId != null">organizeStoreId,</if>
+            <if test="shopOrderIDs != null and shopOrderIDs != ''">shopOrderIDs,</if>
+            <if test="orderSubmitType != null">orderSubmitType,</if>
+            <if test="orderType != null">orderType,</if>
+            <if test="hasActProduct != null and hasActProduct != ''">hasActProduct,</if>
+            <if test="status != null and status != ''">status,</if>
+            <if test="receiptStatus != null and receiptStatus != ''">receiptStatus,</if>
+            <if test="payStatus != null and payStatus != ''">payStatus,</if>
+            <if test="sendOutStatus != null and sendOutStatus != ''">sendOutStatus,</if>
+            <if test="refundType != null and refundType != ''">refundType,</if>
+            <if test="paySuccessCounter != null">paySuccessCounter,</if>
+            <if test="payFlag != null and payFlag != ''">payFlag,</if>
+            <if test="onlinePayFlag != null and onlinePayFlag != ''">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 and note != ''">note,</if>
+            <if test="clubID != null">clubID,</if>
+            <if test="clubScanTime != null and clubScanTime != ''">clubScanTime,</if>
+            <if test="orderSource != null and orderSource != ''">orderSource,</if>
+            <if test="closeTime != null and closeTime != ''">closeTime,</if>
+            <if test="confirmTime != null and confirmTime != ''">confirmTime,</if>
+            <if test="payTime != null and payTime != ''">payTime,</if>
+            <if test="orderTime != null and orderTime != ''">orderTime,</if>
+            <if test="productCount != null">productCount,</if>
+            <if test="presentCount != null">presentCount,</if>
+            <if test="promotionalGiftsCount != null">promotionalGiftsCount,</if>
+            <if test="invoiceFlag != null and invoiceFlag != ''">invoiceFlag,</if>
+            <if test="confirmFlag != null and confirmFlag != ''">confirmFlag,</if>
+            <if test="clauseID != null">clauseID,</if>
+            <if test="clauseContent != null and clauseContent != ''">clauseContent,</if>
+            <if test="clauseName != null and clauseName != ''">clauseName,</if>
+            <if test="updateDate != null and updateDate != ''">updateDate,</if>
+            <if test="freePostFlag != null and freePostFlag != ''">freePostFlag,</if>
+            <if test="freight != null">freight,</if>
+            <if test="userBeans != null">userBeans,</if>
+            <if test="delFlag != null and delFlag != ''">delFlag,</if>
+            <if test="freePostageTicketID != null">freePostageTicketID,</if>
+            <if test="splitFlag != null and splitFlag != ''">splitFlag,</if>
+            <if test="closeReason != null and closeReason != ''">closeReason,</if>
+            <if test="postageOrderFlag != null and postageOrderFlag != ''">postageOrderFlag,</if>
+            <if test="thirdPartyOrderNo != null and thirdPartyOrderNo != ''">thirdPartyOrderNo,</if>
+            <if test="synchronizeFlag != null and synchronizeFlag != ''">synchronizeFlag,</if>
+            <if test="secondHandOrderFlag != null and secondHandOrderFlag != ''">secondHandOrderFlag,</if>
+            <if test="affirmPaymentFlag != null and affirmPaymentFlag != ''">affirmPaymentFlag,</if>
+            <if test="rebateFlag != null and rebateFlag != ''">rebateFlag,</if>
+            <if test="rebateFee != null and rebateFee != ''">rebateFee,</if>
+            <if test="zeroCostFlag != null">zeroCostFlag,</if>
+            <if test="couponAmount != null">couponAmount,</if>
+            <if test="svipFullReduction != null">svipFullReduction,</if>
+            <if test="orderSeen != null and orderSeen != ''">orderSeen,</if>
+            <if test="reductionAmount != null">reductionAmount,</if>
+            <if test="unionID != null and unionID != ''">unionID,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="orderID != null and orderID != ''">#{orderID},</if>
+            <if test="orderNo != null and orderNo != ''">#{orderNo},</if>
+            <if test="apiOrganizeOrderId != null and apiOrganizeOrderId != ''">#{apiOrganizeOrderId},</if>
+            <if test="organizeID != null">#{organizeID},</if>
+            <if test="userID != null">#{userID},</if>
+            <if test="buyUserID != null">#{buyUserID},</if>
+            <if test="organizeStoreId != null">#{organizeStoreId},</if>
+            <if test="shopOrderIDs != null and shopOrderIDs != ''">#{shopOrderIDs},</if>
+            <if test="orderSubmitType != null">#{orderSubmitType},</if>
+            <if test="orderType != null">#{orderType},</if>
+            <if test="hasActProduct != null and hasActProduct != ''">#{hasActProduct},</if>
+            <if test="status != null and status != ''">#{status},</if>
+            <if test="receiptStatus != null and receiptStatus != ''">#{receiptStatus},</if>
+            <if test="payStatus != null and payStatus != ''">#{payStatus},</if>
+            <if test="sendOutStatus != null and sendOutStatus != ''">#{sendOutStatus},</if>
+            <if test="refundType != null and refundType != ''">#{refundType},</if>
+            <if test="paySuccessCounter != null">#{paySuccessCounter},</if>
+            <if test="payFlag != null and payFlag != ''">#{payFlag},</if>
+            <if test="onlinePayFlag != null and onlinePayFlag != ''">#{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 and note != ''">#{note},</if>
+            <if test="clubID != null">#{clubID},</if>
+            <if test="clubScanTime != null and clubScanTime != ''">#{clubScanTime},</if>
+            <if test="orderSource != null and orderSource != ''">#{orderSource},</if>
+            <if test="closeTime != null and closeTime != ''">#{closeTime},</if>
+            <if test="confirmTime != null and confirmTime != ''">#{confirmTime},</if>
+            <if test="payTime != null and payTime != ''">#{payTime},</if>
+            <if test="orderTime != null and orderTime != ''">#{orderTime},</if>
+            <if test="productCount != null">#{productCount},</if>
+            <if test="presentCount != null">#{presentCount},</if>
+            <if test="promotionalGiftsCount != null">#{promotionalGiftsCount},</if>
+            <if test="invoiceFlag != null and invoiceFlag != ''">#{invoiceFlag},</if>
+            <if test="confirmFlag != null and confirmFlag != ''">#{confirmFlag},</if>
+            <if test="clauseID != null">#{clauseID},</if>
+            <if test="clauseContent != null and clauseContent != ''">#{clauseContent},</if>
+            <if test="clauseName != null and clauseName != ''">#{clauseName},</if>
+            <if test="updateDate != null and updateDate != ''">#{updateDate},</if>
+            <if test="freePostFlag != null and freePostFlag != ''">#{freePostFlag},</if>
+            <if test="freight != null">#{freight},</if>
+            <if test="userBeans != null">#{userBeans},</if>
+            <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
+            <if test="freePostageTicketID != null">#{freePostageTicketID},</if>
+            <if test="splitFlag != null and splitFlag != ''">#{splitFlag},</if>
+            <if test="closeReason != null and closeReason != ''">#{closeReason},</if>
+            <if test="postageOrderFlag != null and postageOrderFlag != ''">#{postageOrderFlag},</if>
+            <if test="thirdPartyOrderNo != null and thirdPartyOrderNo != ''">#{thirdPartyOrderNo},</if>
+            <if test="synchronizeFlag != null and synchronizeFlag != ''">#{synchronizeFlag},</if>
+            <if test="secondHandOrderFlag != null and secondHandOrderFlag != ''">#{secondHandOrderFlag},</if>
+            <if test="affirmPaymentFlag != null and affirmPaymentFlag != ''">#{affirmPaymentFlag},</if>
+            <if test="rebateFlag != null and rebateFlag != ''">#{rebateFlag},</if>
+            <if test="rebateFee != null and rebateFee != ''">#{rebateFee},</if>
+            <if test="zeroCostFlag != null">#{zeroCostFlag},</if>
+            <if test="couponAmount != null">#{couponAmount},</if>
+            <if test="svipFullReduction != null">#{svipFullReduction},</if>
+            <if test="orderSeen != null and orderSeen != ''">#{orderSeen},</if>
+            <if test="reductionAmount != null">#{reductionAmount},</if>
+            <if test="unionID != null and unionID != ''">#{unionID},</if>
+        </trim>
+    </insert>
+
+    <update id="updateCmOrder" parameterType="com.caimei.modules.order.entity.NewOrder">
+        update cm_order
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="orderNo != null and orderNo != ''">orderNo = #{orderNo},</if>
+            <if test="apiOrganizeOrderId != null and apiOrganizeOrderId != ''">apiOrganizeOrderId = #{apiOrganizeOrderId},</if>
+            <if test="organizeID != null">organizeID = #{organizeID},</if>
+            <if test="userID != null">userID = #{userID},</if>
+            <if test="buyUserID != null">buyUserID = #{buyUserID},</if>
+            <if test="organizeStoreId != null">organizeStoreId = #{organizeStoreId},</if>
+            <if test="shopOrderIDs != null and shopOrderIDs != ''">shopOrderIDs = #{shopOrderIDs},</if>
+            <if test="orderSubmitType != null">orderSubmitType = #{orderSubmitType},</if>
+            <if test="orderType != null">orderType = #{orderType},</if>
+            <if test="hasActProduct != null and hasActProduct != ''">hasActProduct = #{hasActProduct},</if>
+            <if test="status != null and status != ''">status = #{status},</if>
+            <if test="receiptStatus != null and receiptStatus != ''">receiptStatus = #{receiptStatus},</if>
+            <if test="payStatus != null and payStatus != ''">payStatus = #{payStatus},</if>
+            <if test="sendOutStatus != null and sendOutStatus != ''">sendOutStatus = #{sendOutStatus},</if>
+            <if test="refundType != null and refundType != ''">refundType = #{refundType},</if>
+            <if test="paySuccessCounter != null">paySuccessCounter = #{paySuccessCounter},</if>
+            <if test="payFlag != null and payFlag != ''">payFlag = #{payFlag},</if>
+            <if test="onlinePayFlag != null and onlinePayFlag != ''">onlinePayFlag = #{onlinePayFlag},</if>
+            <if test="productTotalFee != null">productTotalFee = #{productTotalFee},</if>
+            <if test="orderTotalFee != null">orderTotalFee = #{orderTotalFee},</if>
+            <if test="payTotalFee != null">payTotalFee = #{payTotalFee},</if>
+            <if test="payableAmount != null">payableAmount = #{payableAmount},</if>
+            <if test="balancePayFee != null">balancePayFee = #{balancePayFee},</if>
+            <if test="preferential != null">preferential = #{preferential},</if>
+            <if test="discountFee != null">discountFee = #{discountFee},</if>
+            <if test="promotionFullReduction != null">promotionFullReduction = #{promotionFullReduction},</if>
+            <if test="spID != null">spID = #{spID},</if>
+            <if test="mainSpID != null">mainSpID = #{mainSpID},</if>
+            <if test="note != null and note != ''">note = #{note},</if>
+            <if test="clubID != null">clubID = #{clubID},</if>
+            <if test="clubScanTime != null and clubScanTime != ''">clubScanTime = #{clubScanTime},</if>
+            <if test="orderSource != null and orderSource != ''">orderSource = #{orderSource},</if>
+            <if test="closeTime != null and closeTime != ''">closeTime = #{closeTime},</if>
+            <if test="confirmTime != null and confirmTime != ''">confirmTime = #{confirmTime},</if>
+            <if test="payTime != null and payTime != ''">payTime = #{payTime},</if>
+            <if test="orderTime != null and orderTime != ''">orderTime = #{orderTime},</if>
+            <if test="productCount != null">productCount = #{productCount},</if>
+            <if test="presentCount != null">presentCount = #{presentCount},</if>
+            <if test="promotionalGiftsCount != null">promotionalGiftsCount = #{promotionalGiftsCount},</if>
+            <if test="invoiceFlag != null and invoiceFlag != ''">invoiceFlag = #{invoiceFlag},</if>
+            <if test="confirmFlag != null and confirmFlag != ''">confirmFlag = #{confirmFlag},</if>
+            <if test="clauseID != null">clauseID = #{clauseID},</if>
+            <if test="clauseContent != null and clauseContent != ''">clauseContent = #{clauseContent},</if>
+            <if test="clauseName != null and clauseName != ''">clauseName = #{clauseName},</if>
+            <if test="updateDate != null and updateDate != ''">updateDate = #{updateDate},</if>
+            <if test="freePostFlag != null and freePostFlag != ''">freePostFlag = #{freePostFlag},</if>
+            <if test="freight != null">freight = #{freight},</if>
+            <if test="userBeans != null">userBeans = #{userBeans},</if>
+            <if test="delFlag != null and delFlag != ''">delFlag = #{delFlag},</if>
+            <if test="freePostageTicketID != null">freePostageTicketID = #{freePostageTicketID},</if>
+            <if test="splitFlag != null and splitFlag != ''">splitFlag = #{splitFlag},</if>
+            <if test="closeReason != null and closeReason != ''">closeReason = #{closeReason},</if>
+            <if test="postageOrderFlag != null and postageOrderFlag != ''">postageOrderFlag = #{postageOrderFlag},</if>
+            <if test="thirdPartyOrderNo != null and thirdPartyOrderNo != ''">thirdPartyOrderNo = #{thirdPartyOrderNo},</if>
+            <if test="synchronizeFlag != null and synchronizeFlag != ''">synchronizeFlag = #{synchronizeFlag},</if>
+            <if test="secondHandOrderFlag != null and secondHandOrderFlag != ''">secondHandOrderFlag = #{secondHandOrderFlag},</if>
+            <if test="affirmPaymentFlag != null and affirmPaymentFlag != ''">affirmPaymentFlag = #{affirmPaymentFlag},</if>
+            <if test="rebateFlag != null and rebateFlag != ''">rebateFlag = #{rebateFlag},</if>
+            <if test="rebateFee != null and rebateFee != ''">rebateFee = #{rebateFee},</if>
+            <if test="zeroCostFlag != null">zeroCostFlag = #{zeroCostFlag},</if>
+            <if test="couponAmount != null">couponAmount = #{couponAmount},</if>
+            <if test="svipFullReduction != null">svipFullReduction = #{svipFullReduction},</if>
+            <if test="orderSeen != null and orderSeen != ''">orderSeen = #{orderSeen},</if>
+            <if test="reductionAmount != null">reductionAmount = #{reductionAmount},</if>
+            <if test="unionID != null and unionID != ''">unionID = #{unionID},</if>
+        </trim>
+        where orderID = #{orderID}
+    </update>
+
+    <update id="updateDelCmOrderByOrderIDs" parameterType="String">
+        update cm_order set delFlag=#{delFlag} where orderID in
+        <foreach item="orderID" collection="orderIDs" open="(" separator="," close=")">
+            #{orderID}
+        </foreach>
+    </update>
+
+    <delete id="delCmOrderByOrderID" parameterType="String">
+        delete
+        from cm_order where orderID = #{orderID}
+    </delete>
+
+    <delete id="delCmOrderByOrderIDs" parameterType="String">
+        delete from cm_order where orderID in
+        <foreach item="orderID" collection="orderIDs" open="(" separator="," close=")">
+            #{orderID}
+        </foreach>
+    </delete>
+
 </mapper>

+ 15 - 2
src/main/resources/mappings/modules/order/OrderProductMapper.xml

@@ -81,7 +81,7 @@
 		a.`productImage` AS `productImage`,
 		a.`shopName` AS `shopName`,
 		cs.stock AS stock,
-		cs.costCheckFlag AS costCheckFlag,
+		(SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) AS costCheckFlag,
 		cs.costPrice AS costPrice,
 		cs.organizeId AS organizeId,
 		cs.unit AS unit,
@@ -477,7 +477,13 @@
     <update id="updateProductFee">
         UPDATE cm_order_product
         SET costPrice               = #{costPrice},
+            organizeCostPrice       = #{organizeCostPrice},
+            cmCostPrice             = #{cmCostPrice},
+            shopPercent             = #{shopPercent},
+            organizePercent         = #{organizePercent},
+            cmPercent               = #{cmPercent},
             supplierTaxRate         = #{supplierTaxRate},
+            taxRate                 = #{taxRate},
             shouldPayTotalTax       = #{shouldPayTotalTax},
             singleShouldPayTotalTax = #{singleShouldPayTotalTax}
         WHERE orderProductID = #{orderProductID}
@@ -544,7 +550,6 @@
                cop.totalFee                AS totalFee,
                cop.shouldPayTotalTax       AS shouldPayTotalTax,
                cop.shopProductAmount       AS shopProductAmount,
-               cop.costPrice               AS costPrice,
                cop.singleShouldPayTotalTax AS singleShouldPayTotalTax,
                cop.taxRate                 AS taxRate,
                cop.supplierTaxRate         AS supplierTaxRate,
@@ -554,6 +559,14 @@
                cop.productType             AS productType,
                cop.totalAddedValueTax      AS totalAddedValueTax,
                cs.organizeId      AS organizeId,
+               cs.unit as productUnit,
+               (cop.discountPrice - cop.costPrice - cop.cmCostPrice) as brokerage,
+               cop.costPrice               AS costPrice,
+               ifnull(cop.organizeCostPrice, 0)       AS organizeCostPrice,
+               ifnull(cop.cmCostPrice, 0)             AS cmCostPrice,
+               cop.shopPercent,
+               cop.organizePercent,
+               cop.cmPercent,
                cpo.touchPrice              AS touchPrice
         from cm_order_product cop
                  left join cm_sku cs on cop.skuId = cs.skuId and cs.organizeId=cop.organizeId

+ 1511 - 136
src/main/resources/mappings/modules/order/ShopOrderMapper.xml

@@ -4,7 +4,6 @@
 
     <sql id="shopOrderColumns">
         co.rebateFee as rebateFee,
-        co.couponAmount as couponAmount,
 			co.userBeans as userBeans,
 			a.shopOrderID AS shopOrderID,
 			a.shopStatus AS status,
@@ -69,7 +68,7 @@
     		a.payStatus AS payStatus,
     		a.sendOutStatus AS sendOutStatus,
     		a.shopProductAmount AS shopProductAmount,
-    		a.shopPostFee AS shopPostFee,
+    		ifnull(a.shopPostFee, 0) AS shopPostFee,
     		a.shopTaxFee AS shopTaxFee,
     		a.shouldPayShopAmount AS shouldPayShopAmount,
     		a.payedShopAmount AS payedShopAmount,
@@ -82,7 +81,8 @@
     		a.differenceType AS differenceType,
     		a.differencePrice AS differencePrice,
     		a.proportional AS proportional,
-    		a.promotionFullReduction As promotionFullReduction,
+    		ifnull(a.promotionFullReduction, 0) As promotionFullReduction,
+    		ifnull(a.couponAmount, 0) As couponAmount,
     		a.zeroCostFlag AS zeroCostFlag
     </sql>
 
@@ -225,6 +225,14 @@
         where a.shopOrderID = #{shopOrderID}
     </select>
 
+    <select id="findByPayShopID" resultType="java.lang.Double">
+        SELECT SUM(cpsr.payAmount)
+        FROM cm_pay_shop cps
+        LEFT JOIN cm_pay_shop_record cpsr ON cpsr.payShopID = cps.id
+        WHERE cpsr.delFlag = 0
+          AND cps.delFlag = 0
+          AND cpsr.shopOrderId = #{shopOrderID}
+    </select>
     <select id="findList" resultType="newShopOrder">
         SELECT
         <include refid="shopOrderColumns"/>
@@ -263,7 +271,8 @@
         SELECT<include refid="shopOrderColumns"/>,
         b.name as shopName,
         oa.id as orderArchiveId,
-        co.receiptStatus
+        co.receiptStatus,
+        (SELECT SUM(num) FROM cm_order_product WHERE shoporderid=29760 AND productType = 2) as presentNum
         FROM cm_shop_order a
         left join shop b on a.shopID = b.shopID
         left join cm_order_archive oa on a.shopOrderID = oa.shopOrderId
@@ -271,8 +280,23 @@
         WHERE a.orderID = #{orderID} ORDER BY a.shopOrderNo DESC
     </select>
 
+    <select id="getFreightAmount" resultType="java.lang.Double">
+        SELECT ifnull(SUM(cfr.freightAmount), 0)
+        FROM cm_freight_rule cfr
+                 LEFT JOIN cm_freight_template cft ON cft.id = cfr.freightId
+                 LEFT JOIN product p ON p.freightTemplateId = cft.id
+        WHERE productId = #{productId} and cft.delFlag = 0
+    </select>
+
+    <select id="getShopOrderId" resultType="com.caimei.modules.product.entity.Shop">
+        select shopId, AccountOwnership, bankAccount from shop where shopId = #{shopId}
+    </select>
+
     <select id="findCommercialCode" resultType="String">
-        select commercialCode FROM cm_shop_order a left join cm_shop_splitcode css on a.shopID = css.shopId WHERE a.orderID = #{orderID}
+        select commercialCode
+        FROM cm_shop_order a
+                 left join cm_shop_splitcode css on a.shopID = css.shopId
+        WHERE a.orderID = #{orderID}
     </select>
 
     <update id="update" parameterType="newShopOrder">
@@ -284,6 +308,9 @@
             <if test="status != null and status != ''">
                 shopStatus = #{status},
             </if>
+            <if test="confirmTime != null and confirmTime != ''">
+                confirmTime = #{confirmTime},
+            </if>
             <if test="shopOrderNo != null and shopOrderNo != ''">
                 orderID = #{orderID},
             </if>
@@ -703,6 +730,91 @@
         left join shop s on s.shopID = a.shopID
         LEFT JOIN club c ON c.userID = a.userID
         <where>
+            (s.shopId = 1161 OR s.AccountOwnership = 0 OR a.splitCode = 'E1807059160' or a.ordertype = 2)
+            and a.shopStatus not in (4, 5)
+            <if test="startTime != null and startTime != ''">
+                AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
+            </if>
+            <if test="endTime != null and endTime != ''">
+                AND (a.orderTime &lt; #{endTime} OR a.orderTime = #{endTime})
+            </if>
+            <if test="orderID != null and orderID != ''">
+                AND a.orderID = #{orderID}
+            </if>
+            <if test="organizeID != null and organizeID != 9999">
+                AND co.organizeID = #{organizeID}
+            </if>
+            <if test="organizeID == 9999 ">
+                AND co.orderType = 2
+            </if>
+            <if test="orderNo != null and orderNo != ''">
+                AND a.orderNo like concat('%', #{orderNo} ,'%')
+            </if>
+            <if test="ps != null and ps.length>0 ">
+                AND a.payStatus in
+                <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND s.name like concat('%', #{shopName} ,'%')
+            </if>
+            <if test="buyer != null and buyer != ''">
+                AND bou.name like concat('%', #{buyer} ,'%')
+            </if>
+            <if test="clubName != null and clubName != ''">
+                AND c.name like concat('%', #{clubName} ,'%')
+            </if>
+            <if test="shopOrderID != null and shopOrderID != ''">
+                AND a.shopOrderID = #{shopOrderID}
+            </if>
+            <if test="shopOrderNo != null and shopOrderNo != ''">
+                AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
+            </if>
+            <if test="operatingMode != null and operatingMode == '1'.toString()">
+                and a.payStatus != 3 and co.status NOT IN (6,7)
+            </if>
+            <if test="operatingMode != null and operatingMode == '2'.toString()">
+                and a.payStatus != 1 and co.status != 6
+            </if>
+            <if test="operatingMode != null and operatingMode == '3'.toString()">
+                and a.payStatus = 3 and co.status NOT IN (6,7)
+            </if>
+            and a.shopStatus != 0
+            and co.delFlag = 0
+            -- and not (co.secondHandOrderFlag=1 AND co.rebateFlag=1)
+            and a.delFlag = 0
+            and (a.organizeID!=4 or a.organizeID is null)
+            and a.shopID != 998
+            and co.orderID not in (
+            SELECT orderID FROM cm_order_product WHERE productID IN
+            (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069) GROUP BY orderID
+            )
+        </where>
+        group by a.shopOrderID
+        ORDER BY a.shopOrderID DESC
+    </select>
+
+    <select id="payThirdParties" resultType="newShopOrder">
+        select<include refid="shopOrderColumns"/>,
+        co.payTotalFee AS payTotalFee,
+        bou.name AS buyer,
+        s.name AS shopName,
+        c.name AS clubName,
+        cdr.payWay AS payWay
+        from cm_shop_order a
+        left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
+        left join bp_order_userinfo bou on bou.orderId = a.orderID
+        left join cm_order co on co.orderID = a.orderID
+        LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
+        LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
+        left join shop s on s.shopID = a.shopID
+        LEFT JOIN club c ON c.userID = a.userID
+        <where>
+            s.name NOT LIKE '%综合供应商%'
+            AND s.AccountOwnership = 1
+            AND cdr.payWay = 2
+            AND a.receiptStatus != 1
             <if test="startTime != null and startTime != ''">
                 AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
             </if>
@@ -753,7 +865,87 @@
                 and a.payStatus = 3 and co.status NOT IN (6,7)
             </if>
             and co.delFlag = 0
---              and not (co.secondHandOrderFlag=1 AND co.rebateFlag=1)
+            --              and not (co.secondHandOrderFlag=1 AND co.rebateFlag=1)
+            and a.delFlag = 0
+            and (a.organizeID!=4 or a.organizeID is null)
+            and a.shopID != 998
+            and co.orderID not in (
+            SELECT orderID FROM cm_order_product WHERE productID IN
+            (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069) GROUP BY orderID
+            )
+        </where>
+        group by a.shopOrderID
+        ORDER BY a.shopOrderID DESC
+    </select>
+
+    <select id="findShopOrderList" resultType="newShopOrder">
+        select<include refid="shopOrderColumns"/>,
+        co.payTotalFee AS payTotalFee,
+        bou.name AS buyer,
+        s.name AS shopName,
+        c.name AS clubName,
+        cdr.payWay AS payWay
+        from cm_shop_order a
+        left join cm_pay_shop_record cpsr on a.shopOrderID = cpsr.shopOrderID
+        left join bp_order_userinfo bou on bou.orderId = a.orderID
+        left join cm_order co on co.orderID = a.orderID
+        LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
+        LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
+        left join shop s on s.shopID = a.shopID
+        LEFT JOIN club c ON c.userID = a.userID
+        <where>
+            (s.shopId = 1161 OR s.AccountOwnership = 0 OR a.splitCode = 'E1807059160' or a.ordertype = 2)
+            and a.shopStatus not in (4, 5)
+            <if test="startTime != null and startTime != ''">
+                AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
+            </if>
+            <if test="endTime != null and endTime != ''">
+                AND (a.orderTime &lt; #{endTime} OR a.orderTime = #{endTime})
+            </if>
+            <if test="orderID != null and orderID != ''">
+                AND a.orderID = #{orderID}
+            </if>
+            <if test="organizeID != null and organizeID != 9999">
+                AND co.organizeID = #{organizeID}
+            </if>
+            <if test="organizeID == 9999 ">
+                AND co.orderType = 2
+            </if>
+            <if test="orderNo != null and orderNo != ''">
+                AND a.orderNo like concat('%', #{orderNo} ,'%')
+            </if>
+            <if test="ps != null and ps.length>0 ">
+                AND a.payStatus in
+                <foreach item="item" index="index" collection="ps" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="receiptStatus != null and receiptStatus!= ''">
+                AND a.receiptStatus = #{receiptStatus}
+            </if>
+            <if test="refundStatus !=null and refundStatus != ''">
+                AND a.refundStatus = #{refundStatus}
+            </if>
+            <if test="settleStatus != null and settleStatus!= ''">
+                AND a.settleStatus = #{settleStatus}
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND s.name like concat('%', #{shopName} ,'%')
+            </if>
+            <if test="buyer != null and buyer != ''">
+                AND bou.name like concat('%', #{buyer} ,'%')
+            </if>
+            <if test="clubName != null and clubName != ''">
+                AND c.name like concat('%', #{clubName} ,'%')
+            </if>
+            <if test="shopOrderID != null and shopOrderID != ''">
+                AND a.shopOrderID = #{shopOrderID}
+            </if>
+            <if test="shopOrderNo != null and shopOrderNo != ''">
+                AND a.shopOrderNo like concat('%', #{shopOrderNo} ,'%')
+            </if>
+            and co.delFlag = 0
+            --              and not (co.secondHandOrderFlag=1 AND co.rebateFlag=1)
             and a.delFlag = 0
             and (a.organizeID!=4 or a.organizeID is null)
             and a.shopID != 998
@@ -766,6 +958,40 @@
         ORDER BY a.shopOrderID DESC
     </select>
 
+    <select id="payAmountByShopOrderId" resultType="java.lang.Double">
+        SELECT IFNULL(SUM(cpsr.payAmount), 0)
+        FROM cm_pay_shop cps
+                 LEFT JOIN cm_pay_shop_record cpsr ON cps.id = cpsr.payShopID
+        WHERE cps.delFlag = 0 AND cpsr.delFlag = 0
+          AND cpsr.shopOrderID = #{shopOrderId}
+    </select>
+
+    <select id="settleAmountByShopOrderId" resultType="java.lang.Double">
+        SELECT IFNULL(SUM(settleAmount), 0)
+        FROM cm_settle_record
+        WHERE shopOrderId = #{shopOrderId}
+    </select>
+
+    <select id="payShopAmountShopOrderId" resultType="java.lang.Double">
+        SELECT IFNULL(SUM(cpsr.payCmAmount), 0)
+        FROM cm_pay_shop cps
+                 LEFT JOIN cm_pay_shop_record cpsr ON cps.id = cpsr.payShopID
+        WHERE cpsr.delFlag = 0 AND cpsr.shopOrderID = 29478
+    </select>
+
+    <select id="returnedPurchaseFeeByShopOrderId" resultType="java.lang.Double">
+        SELECT
+            IFNULL(SUM(crp.returnedPurchaseFee), 0)
+        FROM cm_returned_purchase crp
+                 LEFT JOIN cm_returned_purchase_product crpp ON crp.id = crpp.returnedID
+        WHERE crp.delFlag = 0 AND crp.status = 2
+          AND crp.shopOrderId = #{shopOrderId}
+    </select>
+    <select id="findSplitCount" resultType="java.lang.Integer">
+        SELECT COUNT(*)
+        FROM cm_split_account
+        WHERE shopOrderId = #{shopOrderId}
+    </select>
     <select id="findPayOrderListByIDs" resultType="newShopOrder">
         select distinct<include refid="shopOrderColumns"/>,
         co.payTotalFee AS payTotalFee,
@@ -934,17 +1160,15 @@
 
     <select id="findIncome" resultType="java.lang.Double">
         SELECT ROUND(IFNULL((
-                                        co.payTotalFee - (IFNULL((
-                                                                     SELECT ROUND(SUM((IFNULL(op.costPrice, 0) *
-                                                                                       (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0))) +
-                                                                                      IFNULL(op.shouldPayTotalTax, 0)),
-                                                                                  2)
-                                                                     FROM cm_order_product op
-                                                                              LEFT JOIN cm_shop_order cso ON cso.shopOrderID = op.shopOrderID
-                                                                     WHERE cso.orderID = co.orderID
-                                                                       AND op.productID != 999
-                                                                     GROUP BY cso.orderID
-                                                                 ), 0))
+                                        co.payTotalFee - (IFNULL((SELECT ROUND(SUM((IFNULL(op.costPrice, 0) *
+                                                                                    (IFNULL(op.num, 0) + IFNULL(op.presentNum, 0))) +
+                                                                                   IFNULL(op.shouldPayTotalTax, 0)),
+                                                                               2)
+                                                                  FROM cm_order_product op
+                                                                           LEFT JOIN cm_shop_order cso ON cso.shopOrderID = op.shopOrderID
+                                                                  WHERE cso.orderID = co.orderID
+                                                                    AND op.productID != 999
+                                                                  GROUP BY cso.orderID), 0))
                                         - (SELECT IFNULL(SUM(cso.shopOtherFee), 0)
                                            FROM cm_shop_order cso
                                            WHERE cso.orderID = co.orderID)
@@ -959,7 +1183,7 @@
                                                                          WHERE cso.orderID = co.orderID)
                                                 AND cpsr.delFlag = 0
                                                 AND (cpsr.`status` = 1 OR cpsr.`status` = 0)), 0)
-                                    +IFNULL(co.rebateFee,0)
+                                    + IFNULL(co.rebateFee, 0)
                                 ), 0), 2) AS "采美总佣金"
         FROM cm_order co
         WHERE co.orderID = #{orderID}
@@ -1054,38 +1278,33 @@
                s.name                     AS shopName,
                c.name                     AS clubName
         FROM cm_shop_order a
-                 LEFT JOIN cm_pay_shop_record cpsr ON a.shopOrderID = cpsr.shopOrderID
-                 LEFT JOIN bp_order_userinfo bou ON bou.orderId = a.orderID
-                 LEFT JOIN cm_order co ON co.orderID = a.orderID
-                 LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
-                 LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
-                 LEFT JOIN shop s ON s.shopID = a.shopID
-                 LEFT JOIN club c ON c.userID = a.userID
-                 LEFT JOIN cm_order_product cop ON a.shopOrderID = cop.shopOrderID
-                 LEFT JOIN product p ON cop.productID = p.productID
+        LEFT JOIN cm_pay_shop_record cpsr ON a.shopOrderID = cpsr.shopOrderID
+        LEFT JOIN bp_order_userinfo bou ON bou.orderId = a.orderID
+        LEFT JOIN cm_order co ON co.orderID = a.orderID
+        LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
+        LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
+        LEFT JOIN shop s ON s.shopID = a.shopID
+        LEFT JOIN club c ON c.userID = a.userID
         WHERE co.organizeID = 0
           AND a.refundStatus = 1
           AND co.delFlag = 0
           AND co.orderType != 2
           AND a.delFlag = 0
           AND a.shopID != 998
-          AND (a.organizeID!=4 or a.organizeID is null)
+          AND (a.organizeID != 4 or a.organizeID is null)
           AND cdr.payWay = 1
           AND cdr.receiptDate <![CDATA[ <= ]]> NOW()
           AND cror.relationType = 2
           AND cror.delFlag = 0
           AND cror.mbOrderId IS NOT NULL
           AND cror.splitStatus = 0
-          AND a.receiptStatus=3
-          -- AND p.splitCode != 'E1807059160'
-          AND co.orderID NOT IN (SELECT orderID FROM cm_order_product cops LEFT JOIN product ps ON cops.productID = ps.productID WHERE ps.splitCode = 'E1807059160' AND cops.orderID = cop.orderID)
-          AND co.orderID NOT IN (
-            SELECT orderID
-            FROM cm_order_product
-            WHERE productID IN
-                  (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069)
-            GROUP BY orderID
-        )
+          AND a.receiptStatus = 3
+          AND a.splitCode != 'E1807059160'
+          AND co.orderID NOT IN (SELECT orderID
+                                 FROM cm_order_product
+                                 WHERE productID IN
+                                       (6060, 6061, 6062, 6063, 6064, 6065, 6066, 6067, 6068, 6069)
+                                 GROUP BY orderID)
         GROUP BY a.shopOrderID
         ORDER BY a.shopOrderID DESC
     </select>
@@ -1097,11 +1316,15 @@
     </select>
 
     <select id="FromUnionId" resultType="java.lang.String">
-        SELECT unionID FROM `cm_order` WHERE orderID=#{orderId}
+        SELECT unionID
+        FROM `cm_order`
+        WHERE orderID = #{orderId}
     </select>
 
     <select id="UnionId" resultType="java.lang.String">
-        SELECT unionID FROM `cm_order` WHERE userID=#{userID}
+        SELECT unionID
+        FROM `cm_order`
+        WHERE userID = #{userID}
         ORDER BY orderID DESC
         LIMIT 1
     </select>
@@ -1113,90 +1336,90 @@
     </select>
 
     <select id="payWay" resultType="java.lang.Integer">
-        SELECT  cdr.payWay
+        SELECT cdr.payWay
         FROM cm_shop_order a
                  LEFT JOIN cm_order co ON co.orderID = a.orderID
                  LEFT JOIN cm_receipt_order_relation cror ON cror.orderId = co.orderId
                  LEFT JOIN cm_discern_receipt cdr ON cror.receiptID = cdr.id
-        WHERE a.shopOrderID =  #{shopOrderID}
+        WHERE a.shopOrderID = #{shopOrderID}
     </select>
 
     <select id="findSettlementList" resultType="com.caimei.modules.order.entity.NewShopOrder">
-        SELECT co.couponAmount            AS couponAmount,
-               co.userBeans               AS userBeans,
-               a.shopOrderID              AS shopOrderID,
-               a.orderID                  AS orderID,
-               a.organizeID               AS organizeID,
-               a.shopOrderNo              AS shopOrderNo,
-               a.orderNo                  AS orderNo,
-               a.userID                   AS userID,
-               a.shopID                   AS shopID,
-               a.itemCount                AS itemCount,
-               a.townID                   AS townID,
-               a.productAmount            AS productAmount,
-               a.discountAmount           AS discountAmount,
-               a.accountAmount            AS accountAmount,
-               a.totalAmount              AS totalAmount,
-               a.payFlag                  AS payFlag,
-               a.payTime                  AS payTime,
-               a.finishTime               AS finishTime,
-               a.refundStatus             AS refundStatus,
-               a.needPayAmount            AS needPayAmount,
-               a.canRefundAmount          AS canRefundAmount,
-               a.refundAmount             AS refundAmount,
-               a.clubID                   AS clubID,
-               a.spID                     AS spID,
-               a.mainSpID                 AS mainSpID,
-               a.orderBeanAmount          AS orderBeanAmount,
-               a.useBeanAmount            AS useBeanAmount,
-               a.useBeanFlag              AS useBeanFlag,
-               a.canRefundFlag            AS canRefundFlag,
-               a.useBalanceFlag           AS useBalanceFlag,
-               a.canRefundBeans           AS canRefundBeans,
-               a.freePostageFee           AS freePostageFee,
-               a.freePostageTicketID      AS freePostageTicketID,
-               a.brokerage                AS brokerage,
-               a.delFlag                  AS delFlag,
-               a.refundsAmount            AS refundsAmount,
-               a.orderStatusFlag          AS orderStatusFlag,
-               a.buyStatus                AS buyStatus,
-               a.orderSubmitType          AS orderSubmitType,
-               a.orderType                AS orderType,
-               a.orderTime                AS orderTime,
-               a.deliveryTimeMills        AS deliveryTimeMills,
-               a.presentNum               AS presentNum,
-               a.preferential             AS preferential,
-               a.outStoreNum              AS outStoreNum,
-               IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
-               a.splitFlag                AS splitFlag,
-               a.autoReceiveTimeMills     AS autoReceiveTimeMills,
-               a.autoOverTimeMills        AS autoOverTimeMills,
-               a.receiveGoodsTime         AS receiveGoodsTime,
-               a.totalAddedValueTax       AS totalAddedValueTax,
-               a.note                     AS note,
-               a.payStatus                AS payStatus,
-               a.sendOutStatus            AS sendOutStatus,
-               a.shopProductAmount        AS shopProductAmount,
-               a.shopPostFee              AS shopPostFee,
-               a.shopTaxFee               AS shopTaxFee,
-               a.shouldPayShopAmount      AS shouldPayShopAmount,
-               a.payedShopAmount          AS payedShopAmount,
-               a.shopOtherFee             AS shopOtherFee,
-               a.paying                   AS paying,
-               a.costType                 AS costType,
-               a.modifyShouldPayNote      AS modifyShouldPayNote,
-               a.orderPromotionsId        AS orderPromotionsId,
-               a.differenceType           AS differenceType,
-               a.differencePrice          AS differencePrice,
-               a.proportional             AS proportional,
-               a.promotionFullReduction   AS promotionFullReduction,
-               a.zeroCostFlag             AS zeroCostFlag,
-               a.settleStatus             AS settleStatus,
-               co.payTotalFee             AS payTotalFee,
-               co.status                  AS STATUS,
-               bou.name                   AS buyer,
-               s.name                     AS shopName,
-               c.name                     AS clubName
+        SELECT co.couponAmount AS couponAmount,
+        co.userBeans AS userBeans,
+        a.shopOrderID AS shopOrderID,
+        a.orderID AS orderID,
+        a.organizeID AS organizeID,
+        a.shopOrderNo AS shopOrderNo,
+        a.orderNo AS orderNo,
+        a.userID AS userID,
+        a.shopID AS shopID,
+        a.itemCount AS itemCount,
+        a.townID AS townID,
+        a.productAmount AS productAmount,
+        a.discountAmount AS discountAmount,
+        a.accountAmount AS accountAmount,
+        a.totalAmount AS totalAmount,
+        a.payFlag AS payFlag,
+        a.payTime AS payTime,
+        a.finishTime AS finishTime,
+        a.refundStatus AS refundStatus,
+        a.needPayAmount AS needPayAmount,
+        a.canRefundAmount AS canRefundAmount,
+        a.refundAmount AS refundAmount,
+        a.clubID AS clubID,
+        a.spID AS spID,
+        a.mainSpID AS mainSpID,
+        a.orderBeanAmount AS orderBeanAmount,
+        a.useBeanAmount AS useBeanAmount,
+        a.useBeanFlag AS useBeanFlag,
+        a.canRefundFlag AS canRefundFlag,
+        a.useBalanceFlag AS useBalanceFlag,
+        a.canRefundBeans AS canRefundBeans,
+        a.freePostageFee AS freePostageFee,
+        a.freePostageTicketID AS freePostageTicketID,
+        a.brokerage AS brokerage,
+        a.delFlag AS delFlag,
+        a.refundsAmount AS refundsAmount,
+        a.orderStatusFlag AS orderStatusFlag,
+        a.buyStatus AS buyStatus,
+        a.orderSubmitType AS orderSubmitType,
+        a.orderType AS orderType,
+        a.orderTime AS orderTime,
+        a.deliveryTimeMills AS deliveryTimeMills,
+        a.presentNum AS presentNum,
+        a.preferential AS preferential,
+        a.outStoreNum AS outStoreNum,
+        IFNULL(a.outStoreTimes, 0) AS outStoreTimes,
+        a.splitFlag AS splitFlag,
+        a.autoReceiveTimeMills AS autoReceiveTimeMills,
+        a.autoOverTimeMills AS autoOverTimeMills,
+        a.receiveGoodsTime AS receiveGoodsTime,
+        a.totalAddedValueTax AS totalAddedValueTax,
+        a.note AS note,
+        a.payStatus AS payStatus,
+        a.sendOutStatus AS sendOutStatus,
+        a.shopProductAmount AS shopProductAmount,
+        a.shopPostFee AS shopPostFee,
+        a.shopTaxFee AS shopTaxFee,
+        a.shouldPayShopAmount AS shouldPayShopAmount,
+        a.payedShopAmount AS payedShopAmount,
+        a.shopOtherFee AS shopOtherFee,
+        a.paying AS paying,
+        a.costType AS costType,
+        a.modifyShouldPayNote AS modifyShouldPayNote,
+        a.orderPromotionsId AS orderPromotionsId,
+        a.differenceType AS differenceType,
+        a.differencePrice AS differencePrice,
+        a.proportional AS proportional,
+        a.promotionFullReduction AS promotionFullReduction,
+        a.zeroCostFlag AS zeroCostFlag,
+        a.settleStatus AS settleStatus,
+        co.payTotalFee AS payTotalFee,
+        co.status AS STATUS,
+        bou.name AS buyer,
+        s.name AS shopName,
+        c.name AS clubName
         FROM cm_shop_order a
         LEFT JOIN cm_pay_shop_record cpsr ON a.shopOrderID = cpsr.shopOrderID
         LEFT JOIN bp_order_userinfo bou ON bou.orderId = a.orderID
@@ -1206,25 +1429,23 @@
         LEFT JOIN cm_split_account csa on csa.shopOrderId = a.shopOrderID
         LEFT JOIN shop s ON s.shopID = a.shopID
         LEFT JOIN club c ON c.userID = a.userID
-        LEFT JOIN cm_order_product cop ON a.shopOrderID = cop.shopOrderID
-        LEFT JOIN product p ON cop.productID = p.productID
         WHERE co.organizeID = 0
-          AND co.refundType != 2
-          AND co.delFlag = 0
-          AND co.orderType != 2
-          AND co.receiptStatus = 3
-          AND a.delFlag = 0
-          AND a.shopID != 998
-          AND (a.organizeID!=4 or a.organizeID is null)
-          AND cdr.payWay = 1
-          AND cror.relationType = 2
-          AND a.settleStatus in (1,2)
-          AND csa.settleStatus = 0
-          AND cror.delFlag = 0
-          AND cror.mbOrderId IS NOT NULL
-          AND cror.splitStatus = 1
-          -- AND p.splitCode != 'E1807059160'
-          AND co.orderID NOT IN (SELECT orderID FROM cm_order_product cops LEFT JOIN product ps ON cops.productID = ps.productID WHERE ps.splitCode = 'E1807059160' AND cops.orderID = cop.orderID)
+        AND co.refundType != 2
+        AND co.delFlag = 0
+        AND co.orderType != 2
+        AND co.receiptStatus = 3
+        AND a.delFlag = 0
+        AND a.refundStatus = 1
+        AND a.shopID != 998
+        AND (a.organizeID!=4 or a.organizeID is null)
+        AND cdr.payWay = 1
+        AND cror.relationType = 2
+        AND a.settleStatus in (1,2)
+        AND csa.settleStatus = 0
+        AND cror.delFlag = 0
+        AND cror.mbOrderId IS NOT NULL
+        AND cror.splitStatus = 1
+        AND a.splitCode != 'E1807059160'
         <if test="startTime != null and startTime != ''">
             AND (a.orderTime &gt; #{startTime} OR a.orderTime = #{startTime})
         </if>
@@ -1260,7 +1481,7 @@
     </select>
 
     <select id="findSettleRecord" resultType="com.caimei.modules.order.entity.SettleRecord">
-        select settleAmount,settleType,settleTime
+        select settleAmount, settleType, settleTime
         from cm_settle_record
         where shopOrderId = #{shopOrderID}
     </select>
@@ -1277,4 +1498,1158 @@
         WHERE a.shopOrderId = #{onlineShopOrderId}
         ORDER BY a.shopOrderNo DESC
     </select>
+
+    <resultMap type="com.caimei.modules.order.entity.NewShopOrder" id="CmShopOrderResult">
+        <result property="shopOrderID" column="shopOrderID"/>
+        <result property="shopOrderNo" column="shopOrderNo"/>
+        <result property="orderNo" column="orderNo"/>
+        <result property="orderID" column="orderID"/>
+        <result property="organizeID" column="organizeID"/>
+        <result property="isColdChina" column="isColdChina"/>
+        <result property="userID" column="userID"/>
+        <result property="shopID" column="shopID"/>
+        <result property="orderPromotionsId" column="orderPromotionsId"/>
+        <result property="orderType" column="orderType"/>
+        <result property="orderSubmitType" column="orderSubmitType"/>
+        <result property="presentNum" column="presentNum"/>
+        <result property="itemCount" column="itemCount"/>
+        <result property="outStoreNum" column="outStoreNum"/>
+        <result property="outStoreTimes" column="outStoreTimes"/>
+        <result property="townID" column="townID"/>
+        <result property="note" column="note"/>
+        <result property="eachDiscount" column="eachDiscount"/>
+        <result property="realPay" column="realPay"/>
+        <result property="receiptAmount" column="receiptAmount"/>
+        <result property="accountAmount" column="accountAmount"/>
+        <result property="productAmount" column="productAmount"/>
+        <result property="totalAmount" column="totalAmount"/>
+        <result property="needPayAmount" column="needPayAmount"/>
+        <result property="discountAmount" column="discountAmount"/>
+        <result property="preferential" column="preferential"/>
+        <result property="promotionFullReduction" column="promotionFullReduction"/>
+        <result property="payFlag" column="payFlag"/>
+        <result property="orderTime" column="orderTime"/>
+        <result property="payTime" column="payTime"/>
+        <result property="finishTime" column="finishTime"/>
+        <result property="autoOverTimeMills" column="autoOverTimeMills"/>
+        <result property="settleStatus" column="settleStatus"/>
+        <result property="payStatus" column="payStatus"/>
+        <result property="receiptStatus" column="receiptStatus"/>
+        <result property="sendOutStatus" column="sendOutStatus"/>
+        <result property="refundStatus" column="refundStatus"/>
+        <result property="returnGoodsStatus" column="returnGoodsStatus"/>
+        <result property="receiveGoodsTime" column="receiveGoodsTime"/>
+        <result property="autoReceiveTimeMills" column="autoReceiveTimeMills"/>
+        <result property="totalAddedValueTax" column="totalAddedValueTax"/>
+        <result property="canRefundAmount" column="canRefundAmount"/>
+        <result property="refundAmount" column="refundAmount"/>
+        <result property="clubID" column="clubID"/>
+        <result property="spID" column="spID"/>
+        <result property="mainSpID" column="mainSpID"/>
+        <result property="orderBeanAmount" column="orderBeanAmount"/>
+        <result property="useBeanAmount" column="useBeanAmount"/>
+        <result property="useBeanFlag" column="useBeanFlag"/>
+        <result property="canRefundFlag" column="canRefundFlag"/>
+        <result property="useBalanceFlag" column="useBalanceFlag"/>
+        <result property="canRefundBeans" column="canRefundBeans"/>
+        <result property="freePostageFee" column="freePostageFee"/>
+        <result property="freePostageTicketID" column="freePostageTicketID"/>
+        <result property="brokerage" column="brokerage"/>
+        <result property="delFlag" column="delFlag"/>
+        <result property="refundsAmount" column="refundsAmount"/>
+        <result property="orderStatusFlag" column="orderStatusFlag"/>
+        <result property="buyStatus" column="buyStatus"/>
+        <result property="deliveryTimeMills" column="deliveryTimeMills"/>
+        <result property="orderDeliveryID" column="orderDeliveryID"/>
+        <result property="splitFlag" column="splitFlag"/>
+        <result property="paying" column="paying"/>
+        <result property="shopProductAmount" column="shopProductAmount"/>
+        <result property="shopPostFee" column="shopPostFee"/>
+        <result property="shopPostFlag" column="shopPostFlag"/>
+        <result property="shopTaxFee" column="shopTaxFee"/>
+        <result property="payCmAmount" column="payCmAmount"/>
+        <result property="shouldPayShopAmount" column="shouldPayShopAmount"/>
+        <result property="payedShopAmount" column="payedShopAmount"/>
+        <result property="shopOtherFee" column="shopOtherFee"/>
+        <result property="receiptedFlag" column="receiptedFlag"/>
+        <result property="receiptedType" column="receiptedType"/>
+        <result property="costType" column="costType"/>
+        <result property="proportional" column="proportional"/>
+        <result property="modifyShouldPayNote" column="modifyShouldPayNote"/>
+        <result property="modifyShouldPayUserID" column="modifyShouldPayUserID"/>
+        <result property="modifyShouldPayDate" column="modifyShouldPayDate"/>
+        <result property="zeroCostFlag" column="zeroCostFlag"/>
+        <result property="differenceType" column="differenceType"/>
+        <result property="differencePrice" column="differencePrice"/>
+        <result property="svipShopReduction" column="svipShopReduction"/>
+        <result property="splitCode" column="splitCode"/>
+        <result property="paySuccessCounter" column="paySuccessCounter"/>
+        <result property="onlinePayWays" column="onlinePayWays"/>
+        <result property="status" column="shopStatus"/>
+    </resultMap>
+
+    <sql id="selectCmShopOrderVo">
+        select cm_shop_order.shopOrderID,
+               cm_shop_order.shopOrderNo,
+               cm_shop_order.orderNo,
+               cm_shop_order.orderID,
+               cm_shop_order.organizeID,
+               cm_shop_order.isColdChina,
+               cm_shop_order.userID,
+               cm_shop_order.shopID,
+               cm_shop_order.orderPromotionsId,
+               cm_shop_order.orderType,
+               cm_shop_order.orderSubmitType,
+               cm_shop_order.presentNum,
+               cm_shop_order.itemCount,
+               cm_shop_order.outStoreNum,
+               cm_shop_order.outStoreTimes,
+               cm_shop_order.townID,
+               cm_shop_order.note,
+               ifnull(cm_shop_order.accountAmount, 0)          AS accountAmount,
+               ifnull(cm_shop_order.productAmount, 0)          AS productAmount,
+               ifnull(cm_shop_order.totalAmount, 0)            AS totalAmount,
+               ifnull(cm_shop_order.needPayAmount, 0)          AS needPayAmount,
+               ifnull(cm_shop_order.discountAmount, 0)         AS discountAmount,
+               ifnull(cm_shop_order.preferential, 0)           AS preferential,
+               ifnull(cm_shop_order.promotionFullReduction, 0) AS promotionFullReduction,
+               cm_shop_order.payFlag,
+               cm_shop_order.orderTime,
+               cm_shop_order.payTime,
+               cm_shop_order.finishTime,
+               cm_shop_order.autoOverTimeMills,
+               cm_shop_order.settleStatus,
+               cm_shop_order.payStatus,
+               cm_shop_order.sendOutStatus,
+               cm_shop_order.refundStatus,
+               cm_shop_order.shopStatus,
+               cm_shop_order.returnGoodsStatus,
+               cm_shop_order.receiveGoodsTime,
+               cm_shop_order.autoReceiveTimeMills,
+               ifnull(cm_shop_order.totalAddedValueTax, 0)     AS totalAddedValueTax,
+               cm_shop_order.canRefundAmount,
+               cm_shop_order.refundAmount,
+               cm_shop_order.clubID,
+               cm_shop_order.spID,
+               cm_shop_order.mainSpID,
+               cm_shop_order.orderBeanAmount,
+               cm_shop_order.useBeanAmount,
+               cm_shop_order.useBeanFlag,
+               cm_shop_order.canRefundFlag,
+               cm_shop_order.useBalanceFlag,
+               cm_shop_order.canRefundBeans,
+               ifnull(cm_shop_order.freePostageFee, 0)         AS freePostageFee,
+               cm_shop_order.freePostageTicketID,
+               ifnull(cm_shop_order.brokerage, 0)              AS brokerage,
+               cm_shop_order.delFlag,
+               ifnull(cm_shop_order.refundsAmount, 0)          AS refundsAmount,
+               cm_shop_order.orderStatusFlag,
+               cm_shop_order.buyStatus,
+               cm_shop_order.deliveryTimeMills,
+               cm_shop_order.confirmTime,
+               cm_shop_order.updateTime,
+               cm_shop_order.orderDeliveryID,
+               cm_shop_order.splitFlag,
+               cm_shop_order.receiptedFlag,
+               cm_shop_order.receiptedType,
+               cm_shop_order.paying,
+               ifnull(cm_shop_order.shopProductAmount, 0)      AS shopProductAmount,
+               ifnull(cm_shop_order.shopPostFee, 0)            AS shopPostFee,
+               cm_shop_order.shopPostFlag,
+               ifnull(cm_shop_order.shopTaxFee, 0)             AS shopTaxFee,
+               ifnull(cm_shop_order.payCmAmount, 0)            AS payCmAmount,
+               ifnull(cm_shop_order.shouldPayShopAmount, 0)    AS shouldPayShopAmount,
+               ifnull(cm_shop_order.payedShopAmount, 0)        AS payedShopAmount,
+               ifnull(cm_shop_order.shopOtherFee, 0)           AS shopOtherFee,
+               cm_shop_order.costType,
+               ifnull(cm_shop_order.proportional, 0)           AS proportional,
+               cm_shop_order.modifyShouldPayNote,
+               cm_shop_order.modifyShouldPayUserID,
+               cm_shop_order.modifyShouldPayDate,
+               cm_shop_order.zeroCostFlag,
+               cm_shop_order.differenceType,
+               ifnull(cm_shop_order.differencePrice, 0)        AS differencePrice,
+               ifnull(cm_shop_order.svipShopReduction, 0)      AS svipShopReduction,
+               ifnull(cm_shop_order.shopRefundAmount, 0)       AS shopRefundAmount,
+               cm_shop_order.splitCode,
+               cm_shop_order.paySuccessCounter,
+               cm_shop_order.onlinePayWays,
+               cm_shop_order.receiptStatus,
+               ifnull(cm_shop_order.receiptAmount, 0)          AS receiptAmount,
+               ifnull(cm_shop_order.eachDiscount, 0)           AS eachDiscount,
+               ifnull(cm_shop_order.realPay, 0)                AS realPay,
+               cm_shop_order.discountFee,
+               cm_shop_order.fee
+    </sql>
+
+    <select id="getByCmShopOrder" parameterType="com.caimei.modules.order.entity.NewShopOrder"
+            resultMap="CmShopOrderResult">
+        <include refid="selectCmShopOrderVo"/>
+        from cm_shop_order AS cm_shop_order
+        <where>cm_shop_order.delFlag = 0
+            <if test="shopOrderID != null  and  shopOrderID != ''">
+                and cm_shop_order.shopOrderID
+                = #{shopOrderID}
+            </if>
+            <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
+                <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
+                <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
+                <foreach item="shopOrderIDIn"
+                         collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
+                         open="(" separator="," close=")">
+                    #{shopOrderIDIn}
+                </foreach>
+            </if>
+            <if test="shopOrderNo != null  and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
+            <if test="orderNo != null  and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
+            <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
+            <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
+            <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
+            <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
+            <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
+            <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
+            <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
+            <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
+            <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
+            <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
+            <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
+            <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
+            <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
+            <if test="note != null  and note != ''">and cm_shop_order.note = #{note}</if>
+            <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
+            <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
+            <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
+            <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
+            <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
+            <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
+            <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
+            <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
+            <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
+            <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
+                #{promotionFullReduction}
+            </if>
+            <if test="payFlag != null  and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
+            <if test="orderTime != null  and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
+            <if test="payTime != null  and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
+            <if test="finishTime != null  and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
+            <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
+            <if test="settleStatus != null  and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
+            </if>
+            <if test="payStatus != null  and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
+            <if test="receiptStatus != null  and receiptStatus != ''">and cm_shop_order.receiptStatus =
+                #{receiptStatus}
+            </if>
+            <if test="sendOutStatus != null  and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
+                #{sendOutStatus}
+            </if>
+            <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
+            <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
+            <if test="receiveGoodsTime != null  and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
+                #{receiveGoodsTime}
+            </if>
+            <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
+            </if>
+            <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
+            <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
+            <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
+            <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
+            <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
+            <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
+            <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
+            <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
+            <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
+            <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
+            <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
+            <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
+            <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
+            <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
+            <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
+            <if test="delFlag != null  and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
+            <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
+            <if test="orderStatusFlag != null  and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
+                #{orderStatusFlag}
+            </if>
+            <if test="buyStatus != null  and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
+            <if test="deliveryTimeMills != null  and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
+                #{deliveryTimeMills}
+            </if>
+            <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
+            <if test="splitFlag != null  and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
+            <if test="paying != null  and paying != ''">and cm_shop_order.paying = #{paying}</if>
+            <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
+            <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
+            <if test="shopPostFlag != null  and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
+            </if>
+            <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
+            <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
+            <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
+            <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
+            <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
+            <if test="receiptedFlag != null  and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
+                #{receiptedFlag}
+            </if>
+            <if test="receiptedType != null  and receiptedType != ''">and cm_shop_order.receiptedType =
+                #{receiptedType}
+            </if>
+            <if test="costType != null  and costType != ''">and cm_shop_order.costType = #{costType}</if>
+            <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
+            <if test="modifyShouldPayNote != null  and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
+                = #{modifyShouldPayNote}
+            </if>
+            <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
+                #{modifyShouldPayUserID}
+            </if>
+            <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
+            <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
+            <if test="differenceType != null  and differenceType != ''">and cm_shop_order.differenceType =
+                #{differenceType}
+            </if>
+            <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
+            <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
+            <if test="splitCode != null  and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
+            <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
+            <if test="onlinePayWays != null  and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
+                #{onlinePayWays}
+            </if>
+            <if test="status != null  and status != ''">and cm_shop_order.shopStatus = #{status}</if>
+        </where>
+        group by cm_shop_order.shopOrderID
+        order by cm_shop_order.orderTime desc
+        limit 0,1
+    </select>
+
+    <select id="getCmShopOrderList" parameterType="com.caimei.modules.order.entity.NewShopOrder"
+            resultMap="CmShopOrderResult">
+        <include refid="selectCmShopOrderVo"/>
+        from cm_shop_order AS cm_shop_order
+        <where>cm_shop_order.delFlag = 0
+            <if test="shopOrderID != null  and  shopOrderID != ''">
+                and cm_shop_order.shopOrderID
+                = #{shopOrderID}
+            </if>
+            <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
+                <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
+                <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
+                <foreach item="shopOrderIDIn"
+                         collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
+                         open="(" separator="," close=")">
+                    #{shopOrderIDIn}
+                </foreach>
+            </if>
+            <if test="shopOrderNo != null  and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
+            <if test="orderNo != null  and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
+            <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
+            <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
+            <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
+            <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
+            <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
+            <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
+            <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
+            <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
+            <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
+            <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
+            <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
+            <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
+            <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
+            <if test="note != null  and note != ''">and cm_shop_order.note = #{note}</if>
+            <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
+            <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
+            <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
+            <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
+            <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
+            <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
+            <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
+            <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
+            <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
+            <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
+                #{promotionFullReduction}
+            </if>
+            <if test="payFlag != null  and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
+            <if test="orderTime != null  and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
+            <if test="payTime != null  and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
+            <if test="finishTime != null  and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
+            <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
+            <if test="settleStatus != null  and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
+            </if>
+            <if test="payStatus != null  and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
+            <if test="receiptStatus != null  and receiptStatus != ''">and cm_shop_order.receiptStatus =
+                #{receiptStatus}
+            </if>
+            <if test="sendOutStatus != null  and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
+                #{sendOutStatus}
+            </if>
+            <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
+            <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
+            <if test="receiveGoodsTime != null  and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
+                #{receiveGoodsTime}
+            </if>
+            <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
+            </if>
+            <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
+            <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
+            <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
+            <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
+            <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
+            <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
+            <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
+            <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
+            <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
+            <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
+            <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
+            <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
+            <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
+            <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
+            <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
+            <if test="delFlag != null  and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
+            <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
+            <if test="orderStatusFlag != null  and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
+                #{orderStatusFlag}
+            </if>
+            <if test="buyStatus != null  and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
+            <if test="deliveryTimeMills != null  and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
+                #{deliveryTimeMills}
+            </if>
+            <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
+            <if test="splitFlag != null  and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
+            <if test="paying != null  and paying != ''">and cm_shop_order.paying = #{paying}</if>
+            <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
+            <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
+            <if test="shopPostFlag != null  and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
+            </if>
+            <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
+            <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
+            <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
+            <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
+            <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
+            <if test="receiptedFlag != null  and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
+                #{receiptedFlag}
+            </if>
+            <if test="receiptedType != null  and receiptedType != ''">and cm_shop_order.receiptedType =
+                #{receiptedType}
+            </if>
+            <if test="costType != null  and costType != ''">and cm_shop_order.costType = #{costType}</if>
+            <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
+            <if test="modifyShouldPayNote != null  and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
+                = #{modifyShouldPayNote}
+            </if>
+            <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
+                #{modifyShouldPayUserID}
+            </if>
+            <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
+            <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
+            <if test="differenceType != null  and differenceType != ''">and cm_shop_order.differenceType =
+                #{differenceType}
+            </if>
+            <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
+            <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
+            <if test="splitCode != null  and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
+            <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
+            <if test="onlinePayWays != null  and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
+                #{onlinePayWays}
+            </if>
+            <if test="status != null  and status != ''">and cm_shop_order.shopStatus = #{status}</if>
+        </where>
+        group by cm_shop_order.shopOrderID
+        order by cm_shop_order.orderTime desc
+    </select>
+    <select id="getCmShopOrderCount" parameterType="com.caimei.modules.order.entity.NewShopOrder" resultType="String">
+        select count(1)
+        from cm_shop_order AS cm_shop_order
+        <where>cm_shop_order.delFlag = 0
+            <if test="shopOrderID != null  and  shopOrderID != ''">
+                and cm_shop_order.shopOrderID
+                = #{shopOrderID}
+            </if>
+            <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
+                <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
+                <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
+                <foreach item="shopOrderIDIn"
+                         collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
+                         open="(" separator="," close=")">
+                    #{shopOrderIDIn}
+                </foreach>
+            </if>
+            <if test="shopOrderNo != null  and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
+            <if test="orderNo != null  and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
+            <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
+            <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
+            <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
+            <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
+            <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
+            <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
+            <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
+            <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
+            <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
+            <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
+            <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
+            <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
+            <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
+            <if test="note != null  and note != ''">and cm_shop_order.note = #{note}</if>
+            <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
+            <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
+            <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
+            <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
+            <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
+            <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
+            <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
+            <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
+            <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
+            <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
+                #{promotionFullReduction}
+            </if>
+            <if test="payFlag != null  and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
+            <if test="orderTime != null  and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
+            <if test="payTime != null  and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
+            <if test="finishTime != null  and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
+            <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
+            <if test="settleStatus != null  and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
+            </if>
+            <if test="payStatus != null  and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
+            <if test="receiptStatus != null  and receiptStatus != ''">and cm_shop_order.receiptStatus =
+                #{receiptStatus}
+            </if>
+            <if test="sendOutStatus != null  and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
+                #{sendOutStatus}
+            </if>
+            <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
+            <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
+            <if test="receiveGoodsTime != null  and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
+                #{receiveGoodsTime}
+            </if>
+            <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
+            </if>
+            <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
+            <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
+            <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
+            <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
+            <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
+            <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
+            <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
+            <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
+            <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
+            <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
+            <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
+            <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
+            <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
+            <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
+            <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
+            <if test="delFlag != null  and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
+            <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
+            <if test="orderStatusFlag != null  and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
+                #{orderStatusFlag}
+            </if>
+            <if test="buyStatus != null  and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
+            <if test="deliveryTimeMills != null  and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
+                #{deliveryTimeMills}
+            </if>
+            <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
+            <if test="splitFlag != null  and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
+            <if test="paying != null  and paying != ''">and cm_shop_order.paying = #{paying}</if>
+            <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
+            <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
+            <if test="shopPostFlag != null  and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
+            </if>
+            <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
+            <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
+            <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
+            <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
+            <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
+            <if test="receiptedFlag != null  and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
+                #{receiptedFlag}
+            </if>
+            <if test="receiptedType != null  and receiptedType != ''">and cm_shop_order.receiptedType =
+                #{receiptedType}
+            </if>
+            <if test="costType != null  and costType != ''">and cm_shop_order.costType = #{costType}</if>
+            <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
+            <if test="modifyShouldPayNote != null  and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
+                = #{modifyShouldPayNote}
+            </if>
+            <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
+                #{modifyShouldPayUserID}
+            </if>
+            <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
+            <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
+            <if test="differenceType != null  and differenceType != ''">and cm_shop_order.differenceType =
+                #{differenceType}
+            </if>
+            <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
+            <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
+            <if test="splitCode != null  and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
+            <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
+            <if test="onlinePayWays != null  and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
+                #{onlinePayWays}
+            </if>
+            <if test="status != null  and status != ''">and cm_shop_order.shopStatus = #{status}</if>
+        </where>
+        group by cm_shop_order.shopOrderID
+    </select>
+
+    <select id="getCmShopOrderByShopOrderID" parameterType="String" resultMap="CmShopOrderResult">
+        <include refid="selectCmShopOrderVo"/>
+        from cm_shop_order AS cm_shop_order
+        where cm_shop_order.delFlag = 0 and cm_shop_order.shopOrderID = #{shopOrderID}
+    </select>
+
+    <select id="getByIds" parameterType="com.caimei.modules.order.entity.NewShopOrder" resultType="String">
+        select shopOrderID
+        from cm_shop_order AS cm_shop_order
+        <where>cm_shop_order.delFlag = 0
+            <if test="shopOrderID != null  and  shopOrderID != ''">
+                and cm_shop_order.shopOrderID
+                = #{shopOrderID}
+            </if>
+            <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
+                <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
+                <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
+                <foreach item="shopOrderIDIn"
+                         collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
+                         open="(" separator="," close=")">
+                    #{shopOrderIDIn}
+                </foreach>
+            </if>
+            <if test="shopOrderNo != null  and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
+            <if test="orderNo != null  and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
+            <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
+            <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
+            <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
+            <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
+            <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
+            <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
+            <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
+            <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
+            <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
+            <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
+            <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
+            <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
+            <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
+            <if test="note != null  and note != ''">and cm_shop_order.note = #{note}</if>
+            <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
+            <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
+            <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
+            <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
+            <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
+            <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
+            <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
+            <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
+            <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
+            <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
+                #{promotionFullReduction}
+            </if>
+            <if test="payFlag != null  and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
+            <if test="orderTime != null  and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
+            <if test="payTime != null  and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
+            <if test="finishTime != null  and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
+            <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
+            <if test="settleStatus != null  and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
+            </if>
+            <if test="payStatus != null  and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
+            <if test="receiptStatus != null  and receiptStatus != ''">and cm_shop_order.receiptStatus =
+                #{receiptStatus}
+            </if>
+            <if test="sendOutStatus != null  and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
+                #{sendOutStatus}
+            </if>
+            <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
+            <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
+            <if test="receiveGoodsTime != null  and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
+                #{receiveGoodsTime}
+            </if>
+            <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
+            </if>
+            <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
+            <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
+            <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
+            <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
+            <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
+            <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
+            <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
+            <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
+            <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
+            <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
+            <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
+            <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
+            <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
+            <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
+            <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
+            <if test="delFlag != null  and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
+            <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
+            <if test="orderStatusFlag != null  and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
+                #{orderStatusFlag}
+            </if>
+            <if test="buyStatus != null  and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
+            <if test="deliveryTimeMills != null  and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
+                #{deliveryTimeMills}
+            </if>
+            <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
+            <if test="splitFlag != null  and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
+            <if test="paying != null  and paying != ''">and cm_shop_order.paying = #{paying}</if>
+            <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
+            <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
+            <if test="shopPostFlag != null  and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
+            </if>
+            <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
+            <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
+            <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
+            <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
+            <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
+            <if test="receiptedFlag != null  and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
+                #{receiptedFlag}
+            </if>
+            <if test="receiptedType != null  and receiptedType != ''">and cm_shop_order.receiptedType =
+                #{receiptedType}
+            </if>
+            <if test="costType != null  and costType != ''">and cm_shop_order.costType = #{costType}</if>
+            <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
+            <if test="modifyShouldPayNote != null  and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
+                = #{modifyShouldPayNote}
+            </if>
+            <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
+                #{modifyShouldPayUserID}
+            </if>
+            <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
+            <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
+            <if test="differenceType != null  and differenceType != ''">and cm_shop_order.differenceType =
+                #{differenceType}
+            </if>
+            <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
+            <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
+            <if test="splitCode != null  and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
+            <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
+            <if test="onlinePayWays != null  and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
+                #{onlinePayWays}
+            </if>
+            <if test="status != null  and status != ''">and cm_shop_order.shopStatus = #{status}</if>
+        </where>
+        group by cm_shop_order.shopOrderID
+    </select>
+    <select id="getById" parameterType="com.caimei.modules.order.entity.NewShopOrder" resultType="String">
+        select shopOrderID
+        from cm_shop_order AS cm_shop_order
+        <where>cm_shop_order.delFlag = 0
+            <if test="shopOrderID != null  and  shopOrderID != ''">
+                and cm_shop_order.shopOrderID
+                = #{shopOrderID}
+            </if>
+            <if test="shopOrderID.toString().toUpperCase().indexOf('=')!=-1">
+                <if test="shopOrderID.toString().toUpperCase().indexOf('NOT')!=-1">not</if>
+                <if test="shopOrderID.toString().toUpperCase().indexOf('IN')!=-1">in</if>
+                <foreach item="shopOrderIDIn"
+                         collection="shopOrderID.toString().substring(shopOrderID.toUpperCase().toString().indexOf('=')+1,shopOrderID.toString().length()).trim().split(',')"
+                         open="(" separator="," close=")">
+                    #{shopOrderIDIn}
+                </foreach>
+            </if>
+            <if test="shopOrderNo != null  and shopOrderNo != ''">and cm_shop_order.shopOrderNo = #{shopOrderNo}</if>
+            <if test="orderNo != null  and orderNo != ''">and cm_shop_order.orderNo = #{orderNo}</if>
+            <if test="orderID != null ">and cm_shop_order.orderID = #{orderID}</if>
+            <if test="organizeID != null ">and cm_shop_order.organizeID = #{organizeID}</if>
+            <if test="isColdChina != null ">and cm_shop_order.isColdChina = #{isColdChina}</if>
+            <if test="userID != null ">and cm_shop_order.userID = #{userID}</if>
+            <if test="shopID != null ">and cm_shop_order.shopID = #{shopID}</if>
+            <if test="orderPromotionsId != null ">and cm_shop_order.orderPromotionsId = #{orderPromotionsId}</if>
+            <if test="orderType != null ">and cm_shop_order.orderType = #{orderType}</if>
+            <if test="orderSubmitType != null ">and cm_shop_order.orderSubmitType = #{orderSubmitType}</if>
+            <if test="presentNum != null ">and cm_shop_order.presentNum = #{presentNum}</if>
+            <if test="itemCount != null ">and cm_shop_order.itemCount = #{itemCount}</if>
+            <if test="outStoreNum != null ">and cm_shop_order.outStoreNum = #{outStoreNum}</if>
+            <if test="outStoreTimes != null ">and cm_shop_order.outStoreTimes = #{outStoreTimes}</if>
+            <if test="townID != null ">and cm_shop_order.townID = #{townID}</if>
+            <if test="note != null  and note != ''">and cm_shop_order.note = #{note}</if>
+            <if test="eachDiscount != null ">and cm_shop_order.eachDiscount = #{eachDiscount}</if>
+            <if test="realPay != null ">and cm_shop_order.realPay = #{realPay}</if>
+            <if test="receiptAmount != null ">and cm_shop_order.receiptAmount = #{receiptAmount}</if>
+            <if test="accountAmount != null ">and cm_shop_order.accountAmount = #{accountAmount}</if>
+            <if test="productAmount != null ">and cm_shop_order.productAmount = #{productAmount}</if>
+            <if test="totalAmount != null ">and cm_shop_order.totalAmount = #{totalAmount}</if>
+            <if test="needPayAmount != null ">and cm_shop_order.needPayAmount = #{needPayAmount}</if>
+            <if test="discountAmount != null ">and cm_shop_order.discountAmount = #{discountAmount}</if>
+            <if test="preferential != null ">and cm_shop_order.preferential = #{preferential}</if>
+            <if test="promotionFullReduction != null ">and cm_shop_order.promotionFullReduction =
+                #{promotionFullReduction}
+            </if>
+            <if test="payFlag != null  and payFlag != ''">and cm_shop_order.payFlag = #{payFlag}</if>
+            <if test="orderTime != null  and orderTime != ''">and cm_shop_order.orderTime = #{orderTime}</if>
+            <if test="payTime != null  and payTime != ''">and cm_shop_order.payTime = #{payTime}</if>
+            <if test="finishTime != null  and finishTime != ''">and cm_shop_order.finishTime = #{finishTime}</if>
+            <if test="autoOverTimeMills != null ">and cm_shop_order.autoOverTimeMills = #{autoOverTimeMills}</if>
+            <if test="settleStatus != null  and settleStatus != ''">and cm_shop_order.settleStatus = #{settleStatus}
+            </if>
+            <if test="payStatus != null  and payStatus != ''">and cm_shop_order.payStatus = #{payStatus}</if>
+            <if test="receiptStatus != null  and receiptStatus != ''">and cm_shop_order.receiptStatus =
+                #{receiptStatus}
+            </if>
+            <if test="sendOutStatus != null  and sendOutStatus != ''">and cm_shop_order.sendOutStatus =
+                #{sendOutStatus}
+            </if>
+            <if test="refundStatus != null ">and cm_shop_order.refundStatus = #{refundStatus}</if>
+            <if test="returnGoodsStatus != null ">and cm_shop_order.returnGoodsStatus = #{returnGoodsStatus}</if>
+            <if test="receiveGoodsTime != null  and receiveGoodsTime != ''">and cm_shop_order.receiveGoodsTime =
+                #{receiveGoodsTime}
+            </if>
+            <if test="autoReceiveTimeMills != null ">and cm_shop_order.autoReceiveTimeMills = #{autoReceiveTimeMills}
+            </if>
+            <if test="totalAddedValueTax != null ">and cm_shop_order.totalAddedValueTax = #{totalAddedValueTax}</if>
+            <if test="canRefundAmount != null ">and cm_shop_order.canRefundAmount = #{canRefundAmount}</if>
+            <if test="refundAmount != null ">and cm_shop_order.refundAmount = #{refundAmount}</if>
+            <if test="clubID != null ">and cm_shop_order.clubID = #{clubID}</if>
+            <if test="spID != null ">and cm_shop_order.spID = #{spID}</if>
+            <if test="mainSpID != null ">and cm_shop_order.mainSpID = #{mainSpID}</if>
+            <if test="orderBeanAmount != null ">and cm_shop_order.orderBeanAmount = #{orderBeanAmount}</if>
+            <if test="useBeanAmount != null ">and cm_shop_order.useBeanAmount = #{useBeanAmount}</if>
+            <if test="useBeanFlag != null ">and cm_shop_order.useBeanFlag = #{useBeanFlag}</if>
+            <if test="canRefundFlag != null ">and cm_shop_order.canRefundFlag = #{canRefundFlag}</if>
+            <if test="useBalanceFlag != null ">and cm_shop_order.useBalanceFlag = #{useBalanceFlag}</if>
+            <if test="canRefundBeans != null ">and cm_shop_order.canRefundBeans = #{canRefundBeans}</if>
+            <if test="freePostageFee != null ">and cm_shop_order.freePostageFee = #{freePostageFee}</if>
+            <if test="freePostageTicketID != null ">and cm_shop_order.freePostageTicketID = #{freePostageTicketID}</if>
+            <if test="brokerage != null ">and cm_shop_order.brokerage = #{brokerage}</if>
+            <if test="delFlag != null  and delFlag != ''">and cm_shop_order.delFlag = #{delFlag}</if>
+            <if test="refundsAmount != null ">and cm_shop_order.refundsAmount = #{refundsAmount}</if>
+            <if test="orderStatusFlag != null  and orderStatusFlag != ''">and cm_shop_order.orderStatusFlag =
+                #{orderStatusFlag}
+            </if>
+            <if test="buyStatus != null  and buyStatus != ''">and cm_shop_order.buyStatus = #{buyStatus}</if>
+            <if test="deliveryTimeMills != null  and deliveryTimeMills != ''">and cm_shop_order.deliveryTimeMills =
+                #{deliveryTimeMills}
+            </if>
+            <if test="orderDeliveryID != null ">and cm_shop_order.orderDeliveryID = #{orderDeliveryID}</if>
+            <if test="splitFlag != null  and splitFlag != ''">and cm_shop_order.splitFlag = #{splitFlag}</if>
+            <if test="paying != null  and paying != ''">and cm_shop_order.paying = #{paying}</if>
+            <if test="shopProductAmount != null ">and cm_shop_order.shopProductAmount = #{shopProductAmount}</if>
+            <if test="shopPostFee != null ">and cm_shop_order.shopPostFee = #{shopPostFee}</if>
+            <if test="shopPostFlag != null  and shopPostFlag != ''">and cm_shop_order.shopPostFlag = #{shopPostFlag}
+            </if>
+            <if test="shopTaxFee != null ">and cm_shop_order.shopTaxFee = #{shopTaxFee}</if>
+            <if test="payCmAmount != null ">and cm_shop_order.payCmAmount = #{payCmAmount}</if>
+            <if test="shouldPayShopAmount != null ">and cm_shop_order.shouldPayShopAmount = #{shouldPayShopAmount}</if>
+            <if test="payedShopAmount != null ">and cm_shop_order.payedShopAmount = #{payedShopAmount}</if>
+            <if test="shopOtherFee != null ">and cm_shop_order.shopOtherFee = #{shopOtherFee}</if>
+            <if test="receiptedFlag != null  and receiptedFlag != ''">and cm_shop_order.receiptedFlag =
+                #{receiptedFlag}
+            </if>
+            <if test="receiptedType != null  and receiptedType != ''">and cm_shop_order.receiptedType =
+                #{receiptedType}
+            </if>
+            <if test="costType != null  and costType != ''">and cm_shop_order.costType = #{costType}</if>
+            <if test="proportional != null ">and cm_shop_order.proportional = #{proportional}</if>
+            <if test="modifyShouldPayNote != null  and modifyShouldPayNote != ''">and cm_shop_order.modifyShouldPayNote
+                = #{modifyShouldPayNote}
+            </if>
+            <if test="modifyShouldPayUserID != null ">and cm_shop_order.modifyShouldPayUserID =
+                #{modifyShouldPayUserID}
+            </if>
+            <if test="modifyShouldPayDate != null ">and cm_shop_order.modifyShouldPayDate = #{modifyShouldPayDate}</if>
+            <if test="zeroCostFlag != null ">and cm_shop_order.zeroCostFlag = #{zeroCostFlag}</if>
+            <if test="differenceType != null  and differenceType != ''">and cm_shop_order.differenceType =
+                #{differenceType}
+            </if>
+            <if test="differencePrice != null ">and cm_shop_order.differencePrice = #{differencePrice}</if>
+            <if test="svipShopReduction != null ">and cm_shop_order.svipShopReduction = #{svipShopReduction}</if>
+            <if test="splitCode != null  and splitCode != ''">and cm_shop_order.splitCode = #{splitCode}</if>
+            <if test="paySuccessCounter != null ">and cm_shop_order.paySuccessCounter = #{paySuccessCounter}</if>
+            <if test="onlinePayWays != null  and onlinePayWays != ''">and cm_shop_order.onlinePayWays =
+                #{onlinePayWays}
+            </if>
+            <if test="status != null  and status != ''">and cm_shop_order.shopStatus = #{status}</if>
+        </where>
+        group by cm_shop_order.shopOrderID
+        limit 0,1
+    </select>
+
+    <insert id="addCmShopOrder" parameterType="com.caimei.modules.order.entity.NewShopOrder" useGeneratedKeys="true"
+            keyProperty="shopOrderID">
+        insert into cm_shop_order
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="shopOrderID != null and shopOrderID != ''">shopOrderID,</if>
+            <if test="shopOrderNo != null and shopOrderNo != ''">shopOrderNo,</if>
+            <if test="orderNo != null and orderNo != ''">orderNo,</if>
+            <if test="orderID != null">orderID,</if>
+            <if test="organizeID != null">organizeID,</if>
+            <if test="isColdChina != null">isColdChina,</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 and note != ''">note,</if>
+            <if test="eachDiscount != null">eachDiscount,</if>
+            <if test="realPay != null">realPay,</if>
+            <if test="receiptAmount != null">receiptAmount,</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="preferential != null">preferential,</if>
+            <if test="promotionFullReduction != null">promotionFullReduction,</if>
+            <if test="payFlag != null and payFlag != ''">payFlag,</if>
+            <if test="orderTime != null and orderTime != ''">orderTime,</if>
+            <if test="payTime != null and payTime != ''">payTime,</if>
+            <if test="finishTime != null and finishTime != ''">finishTime,</if>
+            <if test="autoOverTimeMills != null">autoOverTimeMills,</if>
+            <if test="settleStatus != null and settleStatus != ''">settleStatus,</if>
+            <if test="payStatus != null and payStatus != ''">payStatus,</if>
+            <if test="receiptStatus != null and receiptStatus != ''">receiptStatus,</if>
+            <if test="sendOutStatus != null and sendOutStatus != ''">sendOutStatus,</if>
+            <if test="refundStatus != null">refundStatus,</if>
+            <if test="returnGoodsStatus != null">returnGoodsStatus,</if>
+            <if test="receiveGoodsTime != null and receiveGoodsTime != ''">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 and delFlag != ''">delFlag,</if>
+            <if test="refundsAmount != null">refundsAmount,</if>
+            <if test="orderStatusFlag != null and orderStatusFlag != ''">orderStatusFlag,</if>
+            <if test="buyStatus != null and buyStatus != ''">buyStatus,</if>
+            <if test="deliveryTimeMills != null and deliveryTimeMills != ''">deliveryTimeMills,</if>
+            <if test="orderDeliveryID != null">orderDeliveryID,</if>
+            <if test="splitFlag != null and splitFlag != ''">splitFlag,</if>
+            <if test="paying != null and paying != ''">paying,</if>
+            <if test="shopProductAmount != null">shopProductAmount,</if>
+            <if test="shopPostFee != null">shopPostFee,</if>
+            <if test="shopPostFlag != null and shopPostFlag != ''">shopPostFlag,</if>
+            <if test="shopTaxFee != null">shopTaxFee,</if>
+            <if test="payCmAmount != null">payCmAmount,</if>
+            <if test="shouldPayShopAmount != null">shouldPayShopAmount,</if>
+            <if test="payedShopAmount != null">payedShopAmount,</if>
+            <if test="shopOtherFee != null">shopOtherFee,</if>
+            <if test="receiptedFlag != null and receiptedFlag != ''">receiptedFlag,</if>
+            <if test="receiptedType != null and receiptedType != ''">receiptedType,</if>
+            <if test="costType != null and costType != ''">costType,</if>
+            <if test="proportional != null">proportional,</if>
+            <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">modifyShouldPayNote,</if>
+            <if test="modifyShouldPayUserID != null">modifyShouldPayUserID,</if>
+            <if test="modifyShouldPayDate != null">modifyShouldPayDate,</if>
+            <if test="zeroCostFlag != null">zeroCostFlag,</if>
+            <if test="differenceType != null and differenceType != ''">differenceType,</if>
+            <if test="differencePrice != null">differencePrice,</if>
+            <if test="svipShopReduction != null">svipShopReduction,</if>
+            <if test="splitCode != null and splitCode != ''">splitCode,</if>
+            <if test="paySuccessCounter != null">paySuccessCounter,</if>
+            <if test="onlinePayWays != null and onlinePayWays != ''">onlinePayWays,</if>
+            <if test="status != null and status != ''">shopStatus,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="shopOrderID != null and shopOrderID != ''">#{shopOrderID},</if>
+            <if test="shopOrderNo != null and shopOrderNo != ''">#{shopOrderNo},</if>
+            <if test="orderNo != null and orderNo != ''">#{orderNo},</if>
+            <if test="orderID != null">#{orderID},</if>
+            <if test="organizeID != null">#{organizeID},</if>
+            <if test="isColdChina != null">#{isColdChina},</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 and note != ''">#{note},</if>
+            <if test="eachDiscount != null">#{eachDiscount},</if>
+            <if test="realPay != null">#{realPay},</if>
+            <if test="receiptAmount != null">#{receiptAmount},</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="preferential != null">#{preferential},</if>
+            <if test="promotionFullReduction != null">#{promotionFullReduction},</if>
+            <if test="payFlag != null and payFlag != ''">#{payFlag},</if>
+            <if test="orderTime != null and orderTime != ''">#{orderTime},</if>
+            <if test="payTime != null and payTime != ''">#{payTime},</if>
+            <if test="finishTime != null and finishTime != ''">#{finishTime},</if>
+            <if test="autoOverTimeMills != null">#{autoOverTimeMills},</if>
+            <if test="settleStatus != null and settleStatus != ''">#{settleStatus},</if>
+            <if test="payStatus != null and payStatus != ''">#{payStatus},</if>
+            <if test="receiptStatus != null and receiptStatus != ''">#{receiptStatus},</if>
+            <if test="sendOutStatus != null and sendOutStatus != ''">#{sendOutStatus},</if>
+            <if test="refundStatus != null">#{refundStatus},</if>
+            <if test="returnGoodsStatus != null">#{returnGoodsStatus},</if>
+            <if test="receiveGoodsTime != null and receiveGoodsTime != ''">#{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 and delFlag != ''">#{delFlag},</if>
+            <if test="refundsAmount != null">#{refundsAmount},</if>
+            <if test="orderStatusFlag != null and orderStatusFlag != ''">#{orderStatusFlag},</if>
+            <if test="buyStatus != null and buyStatus != ''">#{buyStatus},</if>
+            <if test="deliveryTimeMills != null and deliveryTimeMills != ''">#{deliveryTimeMills},</if>
+            <if test="orderDeliveryID != null">#{orderDeliveryID},</if>
+            <if test="splitFlag != null and splitFlag != ''">#{splitFlag},</if>
+            <if test="paying != null and paying != ''">#{paying},</if>
+            <if test="shopProductAmount != null">#{shopProductAmount},</if>
+            <if test="shopPostFee != null">#{shopPostFee},</if>
+            <if test="shopPostFlag != null and shopPostFlag != ''">#{shopPostFlag},</if>
+            <if test="shopTaxFee != null">#{shopTaxFee},</if>
+            <if test="payCmAmount != null">#{payCmAmount},</if>
+            <if test="shouldPayShopAmount != null">#{shouldPayShopAmount},</if>
+            <if test="payedShopAmount != null">#{payedShopAmount},</if>
+            <if test="shopOtherFee != null">#{shopOtherFee},</if>
+            <if test="receiptedFlag != null and receiptedFlag != ''">#{receiptedFlag},</if>
+            <if test="receiptedType != null and receiptedType != ''">#{receiptedType},</if>
+            <if test="costType != null and costType != ''">#{costType},</if>
+            <if test="proportional != null">#{proportional},</if>
+            <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">#{modifyShouldPayNote},</if>
+            <if test="modifyShouldPayUserID != null">#{modifyShouldPayUserID},</if>
+            <if test="modifyShouldPayDate != null">#{modifyShouldPayDate},</if>
+            <if test="zeroCostFlag != null">#{zeroCostFlag},</if>
+            <if test="differenceType != null and differenceType != ''">#{differenceType},</if>
+            <if test="differencePrice != null">#{differencePrice},</if>
+            <if test="svipShopReduction != null">#{svipShopReduction},</if>
+            <if test="splitCode != null and splitCode != ''">#{splitCode},</if>
+            <if test="paySuccessCounter != null">#{paySuccessCounter},</if>
+            <if test="onlinePayWays != null and onlinePayWays != ''">#{onlinePayWays},</if>
+            <if test="status != null and status != ''">#{status},</if>
+        </trim>
+    </insert>
+
+    <update id="updateCmShopOrder" parameterType="com.caimei.modules.order.entity.NewShopOrder">
+        update cm_shop_order
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="shopOrderNo != null and shopOrderNo != ''">shopOrderNo = #{shopOrderNo},</if>
+            <if test="orderNo != null and orderNo != ''">orderNo = #{orderNo},</if>
+            <if test="orderID != null">orderID = #{orderID},</if>
+            <if test="organizeID != null">organizeID = #{organizeID},</if>
+            <if test="isColdChina != null">isColdChina = #{isColdChina},</if>
+            <if test="userID != null">userID = #{userID},</if>
+            <if test="shopID != null">shopID = #{shopID},</if>
+            <if test="orderPromotionsId != null">orderPromotionsId = #{orderPromotionsId},</if>
+            <if test="orderType != null">orderType = #{orderType},</if>
+            <if test="orderSubmitType != null">orderSubmitType = #{orderSubmitType},</if>
+            <if test="presentNum != null">presentNum = #{presentNum},</if>
+            <if test="itemCount != null">itemCount = #{itemCount},</if>
+            <if test="outStoreNum != null">outStoreNum = #{outStoreNum},</if>
+            <if test="outStoreTimes != null">outStoreTimes = #{outStoreTimes},</if>
+            <if test="townID != null">townID = #{townID},</if>
+            <if test="note != null and note != ''">note = #{note},</if>
+            <if test="eachDiscount != null">eachDiscount = #{eachDiscount},</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="discountAmount != null">discountAmount = #{discountAmount},</if>
+            <if test="preferential != null">preferential = #{preferential},</if>
+            <if test="promotionFullReduction != null">promotionFullReduction = #{promotionFullReduction},</if>
+            <if test="payFlag != null and payFlag != ''">payFlag = #{payFlag},</if>
+            <if test="orderTime != null and orderTime != ''">orderTime = #{orderTime},</if>
+            <if test="payTime != null and payTime != ''">payTime = #{payTime},</if>
+            <if test="finishTime != null and finishTime != ''">finishTime = #{finishTime},</if>
+            <if test="autoOverTimeMills != null">autoOverTimeMills = #{autoOverTimeMills},</if>
+            <if test="settleStatus != null and settleStatus != ''">settleStatus = #{settleStatus},</if>
+            <if test="payStatus != null and payStatus != ''">payStatus = #{payStatus},</if>
+            <if test="receiptStatus != null and receiptStatus != ''">receiptStatus = #{receiptStatus},</if>
+            <if test="sendOutStatus != null and sendOutStatus != ''">sendOutStatus = #{sendOutStatus},</if>
+            <if test="refundStatus != null">refundStatus = #{refundStatus},</if>
+            <if test="returnGoodsStatus != null">returnGoodsStatus = #{returnGoodsStatus},</if>
+            <if test="receiveGoodsTime != null and receiveGoodsTime != ''">receiveGoodsTime = #{receiveGoodsTime},</if>
+            <if test="autoReceiveTimeMills != null">autoReceiveTimeMills = #{autoReceiveTimeMills},</if>
+            <if test="totalAddedValueTax != null">totalAddedValueTax = #{totalAddedValueTax},</if>
+            <if test="canRefundAmount != null">canRefundAmount = #{canRefundAmount},</if>
+            <if test="refundAmount != null">refundAmount = #{refundAmount},</if>
+            <if test="clubID != null">clubID = #{clubID},</if>
+            <if test="spID != null">spID = #{spID},</if>
+            <if test="mainSpID != null">mainSpID = #{mainSpID},</if>
+            <if test="orderBeanAmount != null">orderBeanAmount = #{orderBeanAmount},</if>
+            <if test="useBeanAmount != null">useBeanAmount = #{useBeanAmount},</if>
+            <if test="useBeanFlag != null">useBeanFlag = #{useBeanFlag},</if>
+            <if test="canRefundFlag != null">canRefundFlag = #{canRefundFlag},</if>
+            <if test="useBalanceFlag != null">useBalanceFlag = #{useBalanceFlag},</if>
+            <if test="canRefundBeans != null">canRefundBeans = #{canRefundBeans},</if>
+            <if test="freePostageFee != null">freePostageFee = #{freePostageFee},</if>
+            <if test="freePostageTicketID != null">freePostageTicketID = #{freePostageTicketID},</if>
+            <if test="brokerage != null">brokerage = #{brokerage},</if>
+            <if test="delFlag != null and delFlag != ''">delFlag = #{delFlag},</if>
+            <if test="refundsAmount != null">refundsAmount = #{refundsAmount},</if>
+            <if test="orderStatusFlag != null and orderStatusFlag != ''">orderStatusFlag = #{orderStatusFlag},</if>
+            <if test="buyStatus != null and buyStatus != ''">buyStatus = #{buyStatus},</if>
+            <if test="deliveryTimeMills != null and deliveryTimeMills != ''">deliveryTimeMills = #{deliveryTimeMills},
+            </if>
+            <if test="orderDeliveryID != null">orderDeliveryID = #{orderDeliveryID},</if>
+            <if test="splitFlag != null and splitFlag != ''">splitFlag = #{splitFlag},</if>
+            <if test="paying != null and paying != ''">paying = #{paying},</if>
+            <if test="shopProductAmount != null">shopProductAmount = #{shopProductAmount},</if>
+            <if test="shopPostFee != null">shopPostFee = #{shopPostFee},</if>
+            <if test="shopPostFlag != null and shopPostFlag != ''">shopPostFlag = #{shopPostFlag},</if>
+            <if test="shopTaxFee != null">shopTaxFee = #{shopTaxFee},</if>
+            <if test="payCmAmount != null">payCmAmount = #{payCmAmount},</if>
+            <if test="shouldPayShopAmount != null">shouldPayShopAmount = #{shouldPayShopAmount},</if>
+            <if test="payedShopAmount != null">payedShopAmount = #{payedShopAmount},</if>
+            <if test="shopOtherFee != null">shopOtherFee = #{shopOtherFee},</if>
+            <if test="receiptedFlag != null and receiptedFlag != ''">receiptedFlag = #{receiptedFlag},</if>
+            <if test="receiptedType != null and receiptedType != ''">receiptedType = #{receiptedType},</if>
+            <if test="costType != null and costType != ''">costType = #{costType},</if>
+            <if test="proportional != null">proportional = #{proportional},</if>
+            <if test="modifyShouldPayNote != null and modifyShouldPayNote != ''">modifyShouldPayNote =
+                #{modifyShouldPayNote},
+            </if>
+            <if test="modifyShouldPayUserID != null">modifyShouldPayUserID = #{modifyShouldPayUserID},</if>
+            <if test="modifyShouldPayDate != null">modifyShouldPayDate = #{modifyShouldPayDate},</if>
+            <if test="zeroCostFlag != null">zeroCostFlag = #{zeroCostFlag},</if>
+            <if test="differenceType != null and differenceType != ''">differenceType = #{differenceType},</if>
+            <if test="differencePrice != null">differencePrice = #{differencePrice},</if>
+            <if test="svipShopReduction != null">svipShopReduction = #{svipShopReduction},</if>
+            <if test="splitCode != null and splitCode != ''">splitCode = #{splitCode},</if>
+            <if test="paySuccessCounter != null">paySuccessCounter = #{paySuccessCounter},</if>
+            <if test="onlinePayWays != null and onlinePayWays != ''">onlinePayWays = #{onlinePayWays},</if>
+            <if test="status != null and status != ''">shopStatus = #{status},</if>
+        </trim>
+        where shopOrderID = #{shopOrderID}
+    </update>
+
+    <update id="updateDelCmShopOrderByShopOrderIDs" parameterType="String">
+        update cm_shop_order set delFlag=#{delFlag} where shopOrderID in
+        <foreach item="shopOrderID" collection="shopOrderIDs" open="(" separator="," close=")">
+            #{shopOrderID}
+        </foreach>
+    </update>
+
+    <delete id="delCmShopOrderByShopOrderID" parameterType="String">
+        delete
+        from cm_shop_order
+        where shopOrderID = #{shopOrderID}
+    </delete>
+
+    <delete id="delCmShopOrderByShopOrderIDs" parameterType="String">
+        delete from cm_shop_order where shopOrderID in
+        <foreach item="shopOrderID" collection="shopOrderIDs" open="(" separator="," close=")">
+            #{shopOrderID}
+        </foreach>
+    </delete>
 </mapper>

+ 7 - 4
src/main/resources/mappings/modules/product/CmOrganizeProductInfoMapper.xml

@@ -48,11 +48,13 @@
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="organizeId != null">organizeId,</if>
             <if test="productId != null">productId,</if>
+            <if test="costCheckFlag != null">costCheckFlag,</if>
             <if test="validFlag != null">validFlag,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="organizeId != null">#{organizeId},</if>
             <if test="productId != null">#{productId},</if>
+            <if test="costCheckFlag != null">#{costCheckFlag},</if>
             <if test="validFlag != null">#{validFlag},</if>
         </trim>
     </insert>
@@ -88,11 +90,12 @@
         update cm_organize_product_info
         <trim prefix="SET" suffixOverrides=",">
             <if test="validFlag != null">validFlag = #{validFlag},</if>
+            <if test="costCheckFlag != null and costCheckFlag != 999">costCheckFlag = #{costCheckFlag},</if>
         </trim>
-        where productId = #{productId} and organizeId not in
-        <foreach item="organizeId" collection="organizeIds" open="(" separator="," close=")">
-            #{organizeId}
-        </foreach>
+        where productId = #{productId}
+            <if test="organizeId != null and organizeId != 999">
+                and organizeId = #{organizeId}
+            </if>
     </update>
 
 </mapper>

+ 1 - 3
src/main/resources/mappings/modules/product/CmProductCombinationMapper.xml

@@ -130,7 +130,7 @@
 		left join cm_organize_product_info copi on copi.productId = a.productID
 		left join shop s on a.shopId = s.shopID
 		<where>
-
+			copi.validFlag in (2,3,9)
 			<if test="productID !=null and productID !=''">
 				AND a.productID=#{productID}
 			</if>
@@ -146,8 +146,6 @@
 				<if test="dbName == 'mssql'">'%'+#{shopName}+'%'</if>
 				<if test="dbName == 'mysql'">concat('%',#{shopName},'%')</if>
 			</if>
--- 			AND a.validFlag in (2,3,9)
-			 copi.validFlag in (2,3,9)
 			and a.combinationID is null
 			and a.productCategory = 1
 		</where>

+ 25 - 9
src/main/resources/mappings/modules/product/CmPromotionMapper.xml

@@ -128,7 +128,7 @@
                  LEFT JOIN shop s ON s.shopID = p.shopID
         WHERE cp.id = #{id} and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
           and p.productCategory = 1
-        group by p.productID
+        group by cpg.skuId
     </select>
 
     <select id="findGiftPurchaseProduct" resultType="com.caimei.modules.bulkpurchase.entity.PurchaseProduct">
@@ -140,7 +140,7 @@
                p.`productID`       productId,
                p.productCode       productNo,
                p.mainImage         image,
-               cs.costCheckFlag    costCheckFlag,
+               (SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) AS costCheckFlag,
                cs.costPrice        costPrice,
                cs.organizeId        organizeId,
                cs.shopPercent shopPercent,
@@ -165,7 +165,7 @@
     </select>
 
     <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
-        SELECT
+        SELECT distinct
         p.productId as productID,
         p.mainImage as mainImage,
         p.name as name,
@@ -187,6 +187,9 @@
             <if test="shopName != null and shopName != ''">
                 AND s.name LIKE concat('%',#{shopName},'%')
             </if>
+            <if test="shopID !=null and shopID != ''">
+                AND s.shopID = #{shopID}
+            </if>
             <if test="ids != null and ids.size > 0">
                 AND p.productID NOT IN
                 <foreach collection="ids" open="(" close=")" item="id" separator=",">
@@ -461,24 +464,37 @@
     </select>
 
     <select id="getPromotionSkus" resultType="com.caimei.modules.product.entity.CmSku">
-        SELECT DISTINCT cs.unit, cs.costCheckFlag, cs.costPrice, cs.shopPercent, cps.touchPrice
-                               , cs.skuId
-                               , cs.organizeId
+        SELECT DISTINCT cs.unit,
+                        (SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) AS costCheckFlag,
+                        cs.costPrice,
+                        cs.shopPercent,
+                        cps.touchPrice,
+                        cs.skuId,
+                        cs.organizeId
         FROM cm_promotions cp
                  LEFT JOIN cm_promotions_product cpp ON cp.id = cpp.promotionsId
                  LEFT JOIN cm_sku cs ON cpp.productId = cs.productId
                  LEFT JOIN cm_promotion_sku cps ON cs.skuId = cps.skuId
-        WHERE cp.id = #{id} and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
+        WHERE cp.id = #{id} and cps.promotionId = #{id}
+          and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
     </select>
 
     <select id="getPromotionSkusByProduct" resultType="com.caimei.modules.product.entity.CmSku">
-        SELECT cs.skuId,cs.unit, cs.costCheckFlag, cs.costPrice, cs.shopPercent, cps.touchPrice
-                      , cs.organizeId
+        SELECT cs.skuId,cs.unit,
+               (SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) AS costCheckFlag,
+               cs.costPrice,
+               cs.shopPercent,
+               cps.touchPrice,
+               cs.organizeId
         FROM cm_sku cs
                  LEFT JOIN cm_promotion_sku cps ON cs.skuId = cps.skuId
         WHERE cs.productId = #{productIds} and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
     </select>
 
+    <select id="findShopId" resultType="java.lang.Integer">
+        select shopId from product where productId = #{productID}
+    </select>
+
     <delete id="deletePromotion">
         delete
         from cm_promotions_gift

+ 1 - 1
src/main/resources/mappings/modules/product/CmSecondHandDetailMapper.xml

@@ -47,7 +47,7 @@
 		cs.stock AS "stock",
 		p.brandID AS "brandID",
 		cs.costPrice as "costPrice",
-		cs.costCheckFlag AS "costCheckFlag",
+		(SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId ) AS costCheckFlag,
 		cs.shopPercent AS "shopPercent",
 		cs.organizeId AS "organizeId",
 		p.visibility AS "visibility",

+ 275 - 193
src/main/resources/mappings/modules/product/ProductMapper.xml

@@ -99,10 +99,13 @@
     <sql id="ActivityJoins">
         LEFT JOIN shop s on s.shopID = a.shopID
     </sql>
-    <insert id="insertMallProduct" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
-        INSERT INTO cm_mall_organize_products (organizeID, productID, shopId, normalPrice, costPrice, ladderPriceFlag, minBuyNumber,
+    <insert id="insertMallProduct" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
+            parameterType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
+        INSERT INTO cm_mall_organize_products (organizeID, productID, shopId, normalPrice, costPrice, ladderPriceFlag,
+                                               minBuyNumber,
                                                validFlag, addTime, updateTime, delFlag)
-        VALUES (#{organizeId}, #{productId}, #{shopId}, #{normalPrice}, #{costPrice}, #{ladderPriceFlag}, #{minBuyNumber},
+        VALUES (#{organizeId}, #{productId}, #{shopId}, #{normalPrice}, #{costPrice}, #{ladderPriceFlag},
+                #{minBuyNumber},
                 #{validFlag}, #{addTime}, #{updateTime}, #{delFlag})
     </insert>
     <update id="saveSort">
@@ -122,7 +125,11 @@
 
     <select id="get" resultType="Product">
         SELECT
-        <include refid="productColumns"/>
+        <include refid="productColumns"/>,
+        (select costCheckFlag from cm_organize_product_info where productId = #{id} and organizeId = 0 ) as
+        costCheckFlag,
+        (select costCheckFlag from cm_organize_product_info where productId = #{id} and organizeId = 4 ) as
+        mallCostCheckFlag
         FROM product a
         <include refid="productJoins"/>
         WHERE a.productID = #{id}
@@ -354,7 +361,7 @@
         bigTypeID,
         smallTypeID,
         tinyTypeID,
---         selfTypeID,
+        -- selfTypeID,
         shopID,
         aliasName,
         name,
@@ -366,28 +373,28 @@
         propertiesInfo,
         addTime,
         updateTime,
---         weekSellNumber,
+        -- weekSellNumber,
         beforeValidFlag,
         validFlag,
         favoriteTimes,
         commentScore,
         commentTimes,
---         selfRecommendFlag,
---         sysRecommendFlag,
+        -- selfRecommendFlag,
+        -- sysRecommendFlag,
         sortIndex,
         featuredFlag,
         featuredSortIndex,
         productCode,
---         synToERPFlag,
+        -- synToERPFlag,
         allAreaFlag,
         provinceIDs,
         serviceNumber,
         packageCount,
         byFlag,
         normalProductFlag,
---         wholeSaleProductFlag,
---         promotionProductFlag,
---         groupBuyProductFlag,
+        -- wholeSaleProductFlag,
+        -- promotionProductFlag,
+        -- groupBuyProductFlag,
         step,
         actFlag,
         actType,
@@ -395,7 +402,7 @@
         onlineTime,
         downlineTime,
         freePostFlag,
---         precisehKey,
+        -- precisehKey,
         visibility,
         commodityDetailsFlag,
         productType,
@@ -434,7 +441,7 @@
         #{bigTypeID},
         #{smallTypeID},
         #{tinyTypeID},
---         #{selfTypeID},
+        -- #{selfTypeID},
         #{shopID},
         #{aliasName},
         #{name},
@@ -446,28 +453,28 @@
         #{propertiesInfo},
         #{addTime},
         #{updateTime},
---         #{weekSellNumber},
+        -- #{weekSellNumber},
         #{beforeValidFlag},
         #{validFlag},
         #{favoriteTimes},
         #{commentScore},
         #{commentTimes},
---         #{selfRecommendFlag},
---         #{sysRecommendFlag},
+        -- #{selfRecommendFlag},
+        -- #{sysRecommendFlag},
         #{sortIndex},
         #{featuredFlag},
         #{featuredSortIndex},
         #{productCode},
---         #{synToERPFlag},
+        -- #{synToERPFlag},
         #{allAreaFlag},
         #{provinceIDs},
         #{serviceNumber},
         #{packageCount},
         #{byFlag},
         #{normalProductFlag},
---         #{wholeSaleProductFlag},
---         #{promotionProductFlag},
---         #{groupBuyProductFlag},
+        -- #{wholeSaleProductFlag},
+        -- #{promotionProductFlag},
+        -- #{groupBuyProductFlag},
         #{step},
         #{actFlag},
         #{actType},
@@ -475,7 +482,7 @@
         #{onlineTime},
         #{downlineTime},
         #{freePostFlag},
---         #{precisehKey},
+        -- #{precisehKey},
         #{visibility},
         #{commodityDetailsFlag},
         #{productType},
@@ -513,51 +520,51 @@
 
     <update id="update">
         UPDATE product
-        SET productID            = #{id},
-            brandID              = #{brandID},
-            tinyTypeID           = #{tinyTypeID},
+        SET productID         = #{id},
+            brandID           = #{brandID},
+            tinyTypeID        = #{tinyTypeID},
 --             selfTypeID           = #{selfTypeID},
-            shopID               = #{shopID},
-            name                 = #{name},
-            searchKey            = #{searchKey},
-            priceFlag            = #{priceFlag},
-            beautyActFlag        = #{beautyActFlag},
-            hasSkuFlag           = #{hasSkuFlag},
-            mainImage            = #{mainImage},
-            propertiesInfo       = #{propertiesInfo},
-            addTime              = #{addTime},
-            updateTime           = #{updateTime},
-            sellNumber           = #{sellNumber},
+            shopID            = #{shopID},
+            name              = #{name},
+            searchKey         = #{searchKey},
+            priceFlag         = #{priceFlag},
+            beautyActFlag     = #{beautyActFlag},
+            hasSkuFlag        = #{hasSkuFlag},
+            mainImage         = #{mainImage},
+            propertiesInfo    = #{propertiesInfo},
+            addTime           = #{addTime},
+            updateTime        = #{updateTime},
+            sellNumber        = #{sellNumber},
 --             weekSellNumber       = #{weekSellNumber},
-            beforeValidFlag      = #{beforeValidFlag},
-            validFlag            = #{validFlag},
-            favoriteTimes        = #{favoriteTimes},
-            commentScore         = #{commentScore},
-            commentTimes         = #{commentTimes},
+            beforeValidFlag   = #{beforeValidFlag},
+            validFlag         = #{validFlag},
+            favoriteTimes     = #{favoriteTimes},
+            commentScore      = #{commentScore},
+            commentTimes      = #{commentTimes},
 --             selfRecommendFlag    = #{selfRecommendFlag},
 --             sysRecommendFlag     = #{sysRecommendFlag},
-            sortIndex            = #{sortIndex},
-            featuredFlag         = #{featuredFlag},
-            featuredSortIndex    = #{featuredSortIndex},
-            productCode          = #{productCode},
+            sortIndex         = #{sortIndex},
+            featuredFlag      = #{featuredFlag},
+            featuredSortIndex = #{featuredSortIndex},
+            productCode       = #{productCode},
 --             synToERPFlag         = #{synToERPFlag},
-            allAreaFlag          = #{allAreaFlag},
-            provinceIDs          = #{provinceIDs},
-            serviceNumber        = #{serviceNumber},
-            packageCount         = #{packageCount},
-            byFlag               = #{byFlag},
-            normalProductFlag    = #{normalProductFlag},
+            allAreaFlag       = #{allAreaFlag},
+            provinceIDs       = #{provinceIDs},
+            serviceNumber     = #{serviceNumber},
+            packageCount      = #{packageCount},
+            byFlag            = #{byFlag},
+            normalProductFlag = #{normalProductFlag},
 --             wholeSaleProductFlag = #{wholeSaleProductFlag},
 --             promotionProductFlag = #{promotionProductFlag},
 --             groupBuyProductFlag  = #{groupBuyProductFlag},
-            step                 = #{step},
-            actFlag              = #{actFlag},
-            actType              = #{actType},
-            onlineTime           = #{onlineTime},
-            downlineTime         = #{downlineTime},
-            freePostFlag         = #{freePostFlag},
+            step              = #{step},
+            actFlag           = #{actFlag},
+            actType           = #{actType},
+            onlineTime        = #{onlineTime},
+            downlineTime      = #{downlineTime},
+            freePostFlag      = #{freePostFlag},
 --             precisehKey          = #{precisehKey},
-            actSort              = #{actSort},
+            actSort           = #{actSort},
             newProductType=#{newProductType}
 
         WHERE productID = #{id}
@@ -686,17 +693,6 @@
         </where>
     </select>
 
-    <select id="getProductSku" resultType="com.caimei.modules.product.entity.Sku">
-        SELECT
-        *
-        FROM
-        sku
-        <where>
-            productID = #{productId}
-            AND validFlag = 1
-        </where>
-    </select>
-
     <select id="findProductBigTypeByProductID" parameterType="java.lang.Integer" resultType="java.lang.String">
         SELECT
         tb.name
@@ -889,7 +885,7 @@
             `productCategory`,
         </if>
         `preferredFlag`,
---         `selfTypeID`,
+        -- `selfTypeID`,
         `shopID`,
         `name`,
         `aliasName`,
@@ -902,28 +898,28 @@
         `propertiesInfo`,
         `addTime`,
         `updateTime`,
---         `weekSellNumber`,
+        -- `weekSellNumber`,
         `beforeValidFlag`,
         `validFlag`,
         `favoriteTimes`,
         `commentScore`,
         `commentTimes`,
---         `selfRecommendFlag`,
---         `sysRecommendFlag`,
+        -- `selfRecommendFlag`,
+        -- `sysRecommendFlag`,
         `sortIndex`,
         `featuredFlag`,
         `featuredSortIndex`,
         `productCode`,
---         `synToERPFlag`,
+        -- `synToERPFlag`,
         `allAreaFlag`,
         `provinceIDs`,
         `serviceNumber`,
         `packageCount`,
         `byFlag`,
         `normalProductFlag`,
---         `wholeSaleProductFlag`,
---         `promotionProductFlag`,
---         `groupBuyProductFlag`,
+        -- `wholeSaleProductFlag`,
+        -- `promotionProductFlag`,
+        -- `groupBuyProductFlag`,
         `step`,
         `actFlag`,
         `actStatus`,
@@ -933,7 +929,7 @@
         `onlineTime`,
         `downlineTime`,
         `freePostFlag`,
---         `precisehKey`,
+        -- `precisehKey`,
         `tags`,
         `productType`,
         `machineType`,
@@ -954,7 +950,7 @@
             #{productCategory},
         </if>
         #{preferredFlag},
---         #{selfTypeID},
+        -- #{selfTypeID},
         #{shopID},
         #{name},
         #{aliasName},
@@ -967,28 +963,28 @@
         #{propertiesInfo},
         #{addTime},
         #{updateTime},
---         #{weekSellNumber},
+        -- #{weekSellNumber},
         #{beforeValidFlag},
         #{validFlag},
         #{favoriteTimes},
         #{commentScore},
         #{commentTimes},
---         #{selfRecommendFlag},
---         #{sysRecommendFlag},
+        -- #{selfRecommendFlag},
+        -- #{sysRecommendFlag},
         #{sortIndex},
         #{featuredFlag},
         #{featuredSortIndex},
         #{productCode},
---         #{synToERPFlag},
+        -- #{synToERPFlag},
         #{allAreaFlag},
         #{provinceIDs},
         #{serviceNumber},
         #{packageCount},
         #{byFlag},
         #{normalProductFlag},
---         #{wholeSaleProductFlag},
---         #{promotionProductFlag},
---         #{groupBuyProductFlag},
+        -- #{wholeSaleProductFlag},
+        -- #{promotionProductFlag},
+        -- #{groupBuyProductFlag},
         #{step},
         #{actFlag},
         #{actStatus},
@@ -998,7 +994,7 @@
         #{onlineTime},
         #{downlineTime},
         #{freePostFlag},
---         #{precisehKey},
+        -- #{precisehKey},
         #{tags},
         #{productType},
         #{machineType},
@@ -1048,33 +1044,60 @@
             useGeneratedKeys="true">
         insert into cm_sku
         (productId,
-         normalPrice,
-         price,
-         ladderPriceFlag,
-         costCheckFlag,
-         costprice,
-         stock,
-         shopPercent,
-         organizePercent,
-         cmPercent,
-         organizeId,
-         minBuyNumber,
-         unit)
+        normalPrice,
+        price,
+        ladderPriceFlag,
+        <if test="costPrice != null">
+            costprice,
+        </if>
+        <if test="organizeCostPrice != null">
+            organizeCostPrice,
+        </if>
+        <if test="cmCostPrice != null">
+            cmCostPrice,
+        </if>
+        stock,
+        <if test="shopPercent != null">
+            shopPercent,
+        </if>
+        <if test="organizePercent != null">
+            organizePercent,
+        </if>
+        <if test="cmPercent != null">
+            cmPercent,
+        </if>
+        organizeId,
+        minBuyNumber,
+        unit)
         values (#{productId},
-                #{normalPrice},
-                #{price},
-                #{ladderPriceFlag},
-                #{costCheckFlag},
-                #{costPrice},
-                #{stock},
-                #{shopPercent},
-                #{organizePercent},
-                #{cmPercent},
-                #{organizeId},
-                #{minBuyNumber},
-                #{unit})
+        #{normalPrice},
+        #{price},
+        #{ladderPriceFlag},
+        <if test="costPrice != null">
+            #{costPrice},
+        </if>
+        <if test="organizeCostPrice != null">
+            #{organizeCostPrice},
+        </if>
+        <if test="cmCostPrice != null">
+            #{cmCostPrice},
+        </if>
+        #{stock},
+        <if test="shopPercent != null">
+            #{shopPercent},
+        </if>
+        <if test="organizePercent != null">
+            #{organizePercent},
+        </if>
+        <if test="cmPercent != null">
+            #{cmPercent},
+        </if>
+        #{organizeId},
+        #{minBuyNumber},
+        #{unit})
     </insert>
-    <insert id="insertOrganizeSku" keyColumn="id" keyProperty="id" parameterType="com.caimei.modules.product.entity.CmSku"
+    <insert id="insertOrganizeSku" keyColumn="id" keyProperty="id"
+            parameterType="com.caimei.modules.product.entity.CmSku"
             useGeneratedKeys="true">
         insert into cm_mall_product_sku
         (productId,
@@ -1094,6 +1117,8 @@
                 #{stock},
                 #{minBuyNumber},
                 #{unit},
+                #{organizeCostPrice},
+                #{cmCostPrice},
                 #{organizePercent},
                 #{shopPercent},
                 #{cmPercent})
@@ -1190,7 +1215,8 @@
         select productId
         from cm_sku cs
         where skuId = #{productId}
-        and  cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=#{productId})
+        #暂时写死0
+        and  cs.organizeId = 0 limit 1
     </select>
 
     <select id="toAddProductList" resultType="product">
@@ -1483,15 +1509,15 @@
             <if test="updateTime != null and updateTime !=''">
                 updateTime = #{updateTime},
             </if>
-<!--            <if test="weekSellNumber != null and weekSellNumber !=''">-->
-<!--                weekSellNumber = #{weekSellNumber},-->
-<!--            </if>-->
+            <!--            <if test="weekSellNumber != null and weekSellNumber !=''">-->
+            <!--                weekSellNumber = #{weekSellNumber},-->
+            <!--            </if>-->
             <if test="beforeValidFlag != null and beforeValidFlag !=''">
                 beforeValidFlag = #{beforeValidFlag},
             </if>
-<!--            <if test="validFlag != null and validFlag !=''">-->
-<!--                validFlag = #{validFlag},-->
-<!--            </if>-->
+            <!--            <if test="validFlag != null and validFlag !=''">-->
+            <!--                validFlag = #{validFlag},-->
+            <!--            </if>-->
             <if test="favoriteTimes != null and favoriteTimes !=''">
                 favoriteTimes = #{favoriteTimes},
             </if>
@@ -1501,12 +1527,12 @@
             <if test="commentTimes != null and commentTimes !=''">
                 commentTimes = #{commentTimes},
             </if>
-<!--            <if test="selfRecommendFlag != null and selfRecommendFlag !=''">-->
-<!--                selfRecommendFlag = #{selfRecommendFlag},-->
-<!--            </if>-->
-<!--            <if test="sysRecommendFlag != null and sysRecommendFlag !=''">-->
-<!--                sysRecommendFlag = #{sysRecommendFlag},-->
-<!--            </if>-->
+            <!--            <if test="selfRecommendFlag != null and selfRecommendFlag !=''">-->
+            <!--                selfRecommendFlag = #{selfRecommendFlag},-->
+            <!--            </if>-->
+            <!--            <if test="sysRecommendFlag != null and sysRecommendFlag !=''">-->
+            <!--                sysRecommendFlag = #{sysRecommendFlag},-->
+            <!--            </if>-->
             <if test="sortIndex != null and sortIndex != ''">
                 sortIndex = #{sortIndex},
             </if>
@@ -1519,9 +1545,9 @@
             <if test="productCode != null and productCode !=''">
                 productCode = #{productCode},
             </if>
-<!--            <if test="synToERPFlag != null and synToERPFlag !=''">-->
-<!--                synToERPFlag = #{synToERPFlag},-->
-<!--            </if>-->
+            <!--            <if test="synToERPFlag != null and synToERPFlag !=''">-->
+            <!--                synToERPFlag = #{synToERPFlag},-->
+            <!--            </if>-->
             <if test="allAreaFlag != null and allAreaFlag !=''">
                 allAreaFlag = #{allAreaFlag},
             </if>
@@ -1540,15 +1566,15 @@
             <if test="normalProductFlag != null and normalProductFlag !=''">
                 normalProductFlag = #{normalProductFlag},
             </if>
-<!--            <if test="wholeSaleProductFlag != null and wholeSaleProductFlag !=''">-->
-<!--                wholeSaleProductFlag = #{wholeSaleProductFlag},-->
-<!--            </if>-->
-<!--            <if test="promotionProductFlag != null and promotionProductFlag !=''">-->
-<!--                promotionProductFlag = #{promotionProductFlag},-->
-<!--            </if>-->
-<!--            <if test="groupBuyProductFlag != null and groupBuyProductFlag !=''">-->
-<!--                groupBuyProductFlag = #{groupBuyProductFlag},-->
-<!--            </if>-->
+            <!--            <if test="wholeSaleProductFlag != null and wholeSaleProductFlag !=''">-->
+            <!--                wholeSaleProductFlag = #{wholeSaleProductFlag},-->
+            <!--            </if>-->
+            <!--            <if test="promotionProductFlag != null and promotionProductFlag !=''">-->
+            <!--                promotionProductFlag = #{promotionProductFlag},-->
+            <!--            </if>-->
+            <!--            <if test="groupBuyProductFlag != null and groupBuyProductFlag !=''">-->
+            <!--                groupBuyProductFlag = #{groupBuyProductFlag},-->
+            <!--            </if>-->
             <if test="step != null and step !=''">
                 step = #{step},
             </if>
@@ -1570,9 +1596,9 @@
             <if test="freePostFlag != null and freePostFlag !=''">
                 freePostFlag = #{freePostFlag},
             </if>
-<!--            <if test="precisehKey != null and precisehKey !=''">-->
-<!--                precisehKey = #{precisehKey},-->
-<!--            </if>-->
+            <!--            <if test="precisehKey != null and precisehKey !=''">-->
+            <!--                precisehKey = #{precisehKey},-->
+            <!--            </if>-->
             <if test="visibility != null and visibility !=''">
                 visibility = #{visibility},
             </if>
@@ -1706,18 +1732,31 @@
     <update id="updateCmSku">
         update cm_sku
         set productId=#{productId},
-            ladderPriceFlag=#{ladderPriceFlag},
-            normalPrice=#{normalPrice},
-            price=#{price},
-            organizeId=#{organizeId},
+        ladderPriceFlag=#{ladderPriceFlag},
+        normalPrice=#{normalPrice},
+        price=#{price},
+        organizeId=#{organizeId},
+        <if test="shopPercent != null">
             shopPercent=#{shopPercent},
+        </if>
+        <if test="organizePercent != null">
             organizePercent=#{organizePercent},
+        </if>
+        <if test="cmPercent != null">
             cmPercent=#{cmPercent},
+        </if>
+        <if test="costPrice != null">
             costPrice=#{costPrice},
-            costCheckFlag=#{costCheckFlag},
-            stock=#{stock},
-            unit=#{unit},
-            minBuyNumber=#{minBuyNumber}
+        </if>
+        <if test="organizeCostPrice != null">
+            organizeCostPrice = #{organizeCostPrice},
+        </if>
+        <if test="cmCostPrice != null">
+            cmCostPrice = #{cmCostPrice},
+        </if>
+        stock=#{stock},
+        unit=#{unit},
+        minBuyNumber=#{minBuyNumber}
         where skuId = #{skuId}
     </update>
     <update id="updateOrganizeSku">
@@ -1978,7 +2017,9 @@
                unit,
                normalPrice,
                stock,
-               costCheckFlag,
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
                shopPercent,
                costPrice,
                price,
@@ -1992,7 +2033,13 @@
                  left join cm_promotion_sku cps on cs.skuId = cps.skuId
                  left join cm_svip_product_sku csps on cs.skuId = csps.skuId
         where cs.productId = #{productID}
-          and  cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=#{productID})
+          and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = #{productID})
+    </select>
+    <select id="getCostCheckFlag" resultType="java.lang.Integer">
+        select costCheckFlag
+        from cm_organize_product_info
+        where productId = #{productId}
+          and organizeId = #{organizeId}
     </select>
     <select id="findSkuListProduct" resultType="com.caimei.modules.product.entity.CmSku">
         select cs.skuId,
@@ -2001,11 +2048,15 @@
                unit,
                normalPrice,
                stock,
-               costCheckFlag,
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
                shopPercent,
                organizePercent,
                cmPercent,
                costPrice,
+               organizeCostPrice,
+               cmCostPrice,
                price,
                ladderPriceFlag,
                minBuyNumber,
@@ -2014,25 +2065,32 @@
                csps.priceType
         from cm_sku cs
                  left join cm_svip_product_sku csps on cs.skuId = csps.skuId
-        where cs.organizeId=0 and  cs.productId = #{productID}
+        where cs.organizeId = 0
+          and cs.productId = #{productID}
+        order by cs.price asc
     </select>
     <select id="findSkuOrganizeList" resultType="com.caimei.modules.product.entity.CmSku">
-        select skuId,
-               productId,
-               organizeId,
-               unit,
-               normalPrice,
-               stock,
-               "2" as costCheckFlag,
-               shopPercent as shopPercent,
-               costPrice,
-               price,
-               minBuyNumber,
-               organizePercent,
-               shopPercent,
-               cmPercent
-        from cm_sku
-        where organizeId=4  and productId = #{productID}
+        select cs.skuId,
+               cs.productId,
+               cs.organizeId,
+               cs.unit,
+               cs.normalPrice,
+               cs.stock,
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
+               cs.shopPercent                                                  as shopPercent,
+               cs.costPrice,
+               cs.organizeCostPrice,
+               cs.cmCostPrice,
+               cs.price,
+               cs.minBuyNumber,
+               cs.organizePercent,
+               cs.shopPercent,
+               cs.cmPercent
+        from cm_sku cs
+        where cs.organizeId = 4
+          and cs.productId = #{productID}
     </select>
     <select id="findLadderPriceBySku" resultType="com.caimei.modules.product.entity.CmLadderPrice">
         select skuId, productId, userType, ladderNum, buyNum, buyPrice, delFlag
@@ -2063,7 +2121,8 @@
         FROM product a
         <include refid="productJoins"/>
         left join cm_sku cs on cs.productId=a.productID and copi.organizeId= cs.organizeId
-        WHERE cs.skuId = #{skuId} and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
+        WHERE cs.skuId = #{skuId} and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE
+        productID=cs.productId)
     </select>
     <select id="findHeHeSku" resultType="com.caimei.modules.product.entity.CmSku">
         select cs.skuId,
@@ -2071,14 +2130,18 @@
                cs.organizeId,
                cs.unit,
                cs.stock,
-               cs.costCheckFlag,
-               cs.shopPercent,
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
                cs.costPrice,
+               ifnull(cs.shopPercent, 0)                                       as shopPercent,
+               ifnull(cs.organizePercent, 0)                                   as organizePercent,
+               ifnull(cs.cmPercent, 0)                                         as cmPercent,
                chs.price
         from cm_sku cs
                  left join cm_hehe_sku chs on cs.skuId = chs.skuId
         where cs.productId = #{productID}
-          and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
+          and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = cs.productId)
     </select>
     <select id="findSkuId" resultType="java.lang.Integer">
         select skuId
@@ -2086,30 +2149,47 @@
         where productId = #{productId}
     </select>
     <select id="findSku" resultType="com.caimei.modules.product.entity.CmSku">
-        select price, ifnull(costPrice, 0) as costPrice, costCheckFlag, shopPercent, normalPrice
+        select cs.price,
+               ifnull(cs.costPrice, 0)                                         as costPrice,
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
+               cs.shopPercent,
+               cs.normalPrice
         from cm_sku cs
-        where productId = #{productId}
-          and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
-        order by price asc
+        where cs.productId = #{productId}
+          and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = cs.productId)
+        order by cs.price asc
         limit 1
     </select>
     <select id="findOrganizeSku" resultType="com.caimei.modules.product.entity.CmSku">
-        SELECT price, ifnull(costPrice, 0),"1" AS costCheckFlag, shopPercent AS shopPercent
-                    , normalPrice
-                    , organizeId
+        SELECT cs.price,
+               ifnull(cs.costPrice, 0),
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
+               cs.shopPercent                                                  AS shopPercent,
+               cs.normalPrice,
+               cs.organizeId
         FROM cm_sku cs
-        WHERE productId = #{productId}
-          and cs.organizeId=4
-        ORDER BY price ASC
+        WHERE cs.productId = #{productId}
+          and cs.organizeId = 4
+        ORDER BY cs.price ASC
         LIMIT 1
     </select>
     <select id="findSkuById" resultType="com.caimei.modules.product.entity.CmSku">
-        select skuId, price, costPrice, costCheckFlag, shopPercent
-                    , unit
-                    , organizeId
-        from cm_sku
-        where skuId = #{skuId}
-          and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
+        select cs.skuId,
+               cs.price,
+               cs.costPrice,
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
+               cs.shopPercent,
+               cs.unit,
+               cs.organizeId
+        from cm_sku cs
+        where cs.skuId = #{skuId}
+          and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = cs.productId)
     </select>
     <select id="findSkuIdByPromotionsId" resultType="java.lang.Integer">
         select skuId
@@ -2122,19 +2202,21 @@
         where skuId = #{skuId}
     </select>
     <select id="findSkuByPromotion" resultType="com.caimei.modules.product.entity.CmSku">
-        SELECT cs.price, cps.skuId, cps.touchPrice
-                       , cs.unit
-                       , cs.organizeId
+        SELECT cs.price
+             , cps.skuId
+             , cps.touchPrice
+             , cs.unit
+             , cs.organizeId
         FROM cm_promotion_sku cps
                  LEFT JOIN cm_sku cs ON cps.skuId = cs.skuId
         WHERE promotionId = #{id}
-          and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
+          and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = cs.productId)
     </select>
     <select id="getSkuByPromotionId" resultType="com.caimei.modules.product.entity.CmSku">
         SELECT cs.price, cpp.productId, cs.skuId, cs.unit
         FROM cm_promotions_product cpp
                  LEFT JOIN cm_sku cs ON cpp.productId = cs.productId
         WHERE promotionsId = #{id}
-          and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
+          and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = cs.productId)
     </select>
 </mapper>

+ 14 - 4
src/main/resources/mappings/modules/product/ProductNewMapper.xml

@@ -121,10 +121,12 @@
     </sql>
     <select id="get" resultType="Product">
         SELECT
-        <include refid="productColumns"/>
+        <include refid="productColumns"/>,
+        (select costCheckFlag from cm_organize_product_info where productId = #{id} and organizeId = 0 ) as costCheckFlag,
+        (select costCheckFlag from cm_organize_product_info where productId = #{id} and organizeId = 4 ) as mallCostCheckFlag
         FROM product a
         <include refid="productJoins"/>
-        WHERE a.productID = #{id} and  copi.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=#{id})
+        WHERE a.productID = #{id}
         group by a.productID
     </select>
 
@@ -140,9 +142,13 @@
         SELECT
         <include refid="productColumns"/>
         FROM product a
-        <include refid="productJoins"/>
+        LEFT JOIN shop s ON s.shopID = a.shopID
+        LEFT JOIN cm_second_hand_detail cshd ON cshd.productID = a.productID
+        LEFT JOIN cm_brand cb ON a.brandID = cb.id
+        LEFT JOIN cm_svip_product csp on a.productID = csp.productId
+        left join (select * from cm_organize_product_info ) copi on copi.productId = a.productID
         <where>
-              copi.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=a.productID)
+
             <if test="id !=null and id !=''">
                 AND a.productID=#{id}
             </if>
@@ -160,6 +166,10 @@
             </if>
             <if test="groundMall != null and groundMall != ''">
                 AND a.groundMall like concat('%',#{groundMall},'%')
+                and copi.organizeId = #{groundMall}
+            </if>
+            <if test="groundMall == null">
+                copi.organizeId = 0
             </if>
             <if test="productCategory != null and productCategory != ''">
                 AND a.productCategory = #{productCategory}

+ 1 - 1
src/main/resources/mappings/modules/product/RepeatPurchasePriceMapper.xml

@@ -64,7 +64,7 @@
 			IFNULL(c.registerUserTypeID,3) As "type",
 			b.name AS "productName",
 		  	cs.unit,
-            CASE   cs.costCheckFlag
+            CASE   (SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cs.productId AND organizeId = cs.organizeId )
             WHEN  1 THEN cs.`costPrice`
             WHEN  2 THEN cs.`shopPercent` * cs.`price` / 100
             END   AS "costPrice"

+ 17 - 14
src/main/resources/mappings/modules/user/CmPortraitMapper.xml

@@ -4,8 +4,8 @@
 
     <select id="selTotal" resultType="com.caimei.modules.user.entity.CmPortrait">
         SELECT
-                (SELECT COUNT(orderID) FROM cm_order WHERE clubID = #{clubID} AND STATUS != 6 AND STATUS != 7 AND refundType != 2 AND orderTime <![CDATA[ < ]]> now()) AS orderTotal,
-                (SELECT SUM(payTotalFee) FROM cm_order WHERE clubID = #{clubID} AND STATUS != 6 AND STATUS != 7 AND refundType != 2 AND orderTime <![CDATA[ < ]]> now()) AS orderTotalAmount,
+                (SELECT COUNT(shopOrderId) FROM cm_shop_order WHERE clubID = #{clubID} AND shopStatus != 4 AND shopStatus != 5 AND refundStatus != 2 AND orderTime <![CDATA[ < ]]> NOW()) AS orderTotal,
+                (SELECT IFNULL(SUM(totalAmount), 0) FROM cm_shop_order WHERE clubID = #{clubID} AND shopStatus != 4 AND shopStatus != 5 AND refundStatus != 2 AND orderTime <![CDATA[ < ]]> NOW()) AS orderTotalAmount,
                 (SELECT COUNT(cbr.recordID) FROM cm_behavior_record cbr LEFT JOIN club c ON cbr.userID = c.userID WHERE cbr.pageType IN (8, 9) AND c.clubID = #{clubID} AND cbr.accessDate <![CDATA[ < ]]> now()) AS totalkeywords ,
                 (SELECT COUNT(remarks) FROM cm_club_remarks WHERE clubID = #{clubID} AND addTime <![CDATA[ < ]]> now()) AS remarksTotal
     </select>
@@ -47,20 +47,23 @@
 
     <select id="selOrderList" resultType="com.caimei.modules.order.entity.NewOrder">
         SELECT
-               (SELECT COUNT(orderID) FROM cm_order WHERE clubID = #{clubID} AND STATUS != 6 AND STATUS != 7 AND refundType != 2) as numbers,
-                (SELECT SUM(payTotalFee) FROM cm_order WHERE clubID = #{clubID} AND STATUS != 6 AND STATUS != 7 AND refundType != 2) as totalMoney,
-               clubID,
-               secondHandOrderFlag,
-               rebateFlag,
-               refundType,
-               payTotalFee,
-               STATUS,
-               orderTime
-        FROM cm_order
+        DISTINCT cso.shopOrderId as shopOrderID,
+        (SELECT COUNT(shopOrderId) FROM cm_shop_order WHERE clubID = #{clubID} AND shopStatus != 4 AND shopStatus != 5 AND refundStatus != 2 AND orderTime <![CDATA[ < ]]> NOW()) AS orderTotal,
+        (SELECT IFNULL(SUM(totalAmount), 0) FROM cm_shop_order WHERE clubID = #{clubID} AND shopStatus != 4 AND shopStatus != 5 AND refundStatus != 2 AND orderTime <![CDATA[ < ]]> NOW()) AS orderTotalAmount,
+        cso.clubID,
+        co.secondHandOrderFlag,
+        co.rebateFlag,
+        cso.totalAmount AS payTotalFee,
+        ifnull(cso.refundStatus,1) as refundType,
+        cso.shopStatus AS STATUS,
+        cso.orderTime
+        FROM cm_shop_order cso
+        LEFT JOIN cm_order co ON cso.orderId = co.orderId
+        LEFT JOIN cm_order_product cop ON cso.shopOrderId = cop.shopOrderId
         <where>
-             clubID = #{clubID} AND STATUS != 6 AND STATUS != 7 AND refundType != 2
+            cso.clubID = #{clubID} AND cso.shopStatus != 4 AND cso.shopStatus != 5 AND cso.refundStatus != 2 AND cop.productId != 999
              <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
-                 AND orderTime <![CDATA[ >= ]]> #{startTime} AND orderTime <![CDATA[ <= ]]> #{endTime}
+                 AND cso.orderTime <![CDATA[ >= ]]> #{startTime} AND cso.orderTime <![CDATA[ <= ]]> #{endTime}
              </if>
         </where>
     </select>

+ 21 - 0
src/main/resources/mappings/modules/user/NewCmShopMapper.xml

@@ -54,6 +54,9 @@
 		a.rebateAmount AS "rebateAmount",
 		a.bankAccountName AS "bankAccountName",
 		a.bankName AS "bankName",
+        a.cmBankAccount AS "cmBankAccount",
+		a.cmBankAccountName AS "cmBankAccountName",
+		a.cmBankName AS "cmBankName",
         a.AccountOwnership as AccountOwnership,
 		a.socialCreditCode AS "socialCreditCode",
 		u.email,
@@ -389,6 +392,16 @@
             <if test="bankName != null">
                 bankName=#{bankName},
             </if>
+            <if test="cmBankName != null">
+                cmBankName=#{cmBankName},
+            </if>
+            <if test="cmBankAccountName != null">
+                cmBankAccountName=#{cmBankAccountName},
+            </if>
+            <if test="cmBankAccount != null">
+                cmBankAccount=#{cmBankAccount},
+            </if>
+
             <if test="socialCreditCode != null">
                 socialCreditCode = #{socialCreditCode}
             </if>
@@ -575,6 +588,10 @@
         <result property="bankAccount"    column="bankAccount"    />
         <result property="bankAccountName"    column="bankAccountName"    />
         <result property="bankName"    column="bankName"    />
+        <result property="cmBankName"    column="cmBankName"    />
+        <result property="cmBankAccountName"    column="cmBankAccountName"    />
+        <result property="cmBankAccount"    column="cmBankAccount"    />
+
         <result property="checkMan"    column="checkMan"    />
         <result property="ableRebateAmount"    column="ableRebateAmount"    />
         <result property="website"    column="website"    />
@@ -635,7 +652,11 @@
             <if test="medicalPracticeLicenseImg3 != null and medicalPracticeLicenseImg3 != ''">medicalPracticeLicenseImg3 = #{medicalPracticeLicenseImg3},</if>
             <if test="bankAccount != null and bankAccount != ''">bankAccount = #{bankAccount},</if>
             <if test="bankAccountName != null and bankAccountName != ''">bankAccountName = #{bankAccountName},</if>
+            <if test="cmBankName != null and cmBankName != ''">cmBankName = #{cmBankName},</if>
+            <if test="cmBankAccountName != null and cmBankAccountName != ''">cmBankAccountName = #{cmBankAccountName},</if>
+            <if test="cmBankAccount != null and cmBankAccount != ''">cmBankAccount = #{cmBankAccount},</if>
             <if test="bankName != null and bankName != ''">bankName = #{bankName},</if>
+
             <if test="checkMan != null and checkMan != ''">checkMan = #{checkMan},</if>
             <if test="ableRebateAmount != null">ableRebateAmount = #{ableRebateAmount},</if>
             <if test="website != null and website != ''">website = #{website},</if>

+ 1 - 1
src/main/resources/mappings/modules/weisha/CmOrganizeProductMapper.xml

@@ -80,7 +80,7 @@
         cmps.price,
         cmps.stock,
         cmps.unit,
-        "2" as costCheckFlag,
+        (SELECT costCheckFlag FROM cm_organize_product_info WHERE productId = cmps.productId AND organizeId = cmps.organizeId ) AS costCheckFlag,
         cmps.organizePercent,
         cmps.shopPercent,
         cmps.cmPercent

+ 11 - 0
src/main/webapp/WEB-INF/views/modules/archive/addFileForm.jsp

@@ -182,6 +182,16 @@
             <font color="red">标题输入不超过50个字</font>
         </div>
     </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>文件内容:</label>
+        <div class="controls">
+            <form:textarea path="content" rows="5"  htmlEscape="false" class="input-xlarge required"/>
+        </div>
+        <div style="margin:5px 0 0 180px">
+            <font color="red">注:提供给不满条件预览文件的用户。
+            </font>
+        </div>
+    </div>
     <div class="control-group">
         <label class="control-label"><font color="red">*</font>文件路径:</label>
         <input id="uploadFileName" type="text" style="display: inline;margin-left:20px" disabled="true" class="input-xlarge required" />
@@ -208,6 +218,7 @@
         items.push({
             id: $("#id").val(),
             title: $("#title").val(),
+            content: $("#content").val(),
             fileId: fileId
         })
         return items;

+ 2 - 0
src/main/webapp/WEB-INF/views/modules/archive/addVideoForm.jsp

@@ -172,6 +172,7 @@
 <form:form id="inputForm" modelAttribute="cmProductArchiveContent" action="${ctx}/archive/cmOrderArchiveContent/save" method="post" class="form-horizontal">
     <form:hidden path="id"/>
     <form:hidden path="type" value="2"/>
+    <form:hidden path="content"/>
     <sys:message content="${message}"/>
     <div class="control-group">
         <label class="control-label"><font color="red">*</font>标题:</label>
@@ -208,6 +209,7 @@
         items.push({
             id: $("#id").val(),
             title: $("#title").val(),
+            content: $("#content").val(),
             fileId: fileId
         })
         return items;

+ 11 - 2
src/main/webapp/WEB-INF/views/modules/archive/cmProductArchiveContentList.jsp

@@ -45,6 +45,7 @@
 			<tr>
 				<th>序号</th>
 				<th>标题</th>
+				<th>浏览量</th>
 				<th>添加时间</th>
 				<th>操作</th>
 			</tr>
@@ -56,6 +57,9 @@
 				<td>
 					${cmProductArchiveContent.title}
 				</td>
+				<td>
+					${cmProductArchiveContent.actualPv}
+				</td>
 				<td>
 					<fmt:formatDate value="${cmProductArchiveContent.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
 				</td>
@@ -88,7 +92,7 @@
 			top.$.jBox("iframe:" + url, {
 				iframeScrolling: 'yes',
 				width: 800,
-				height: 300,
+				height: type == 2?300:500,
 				persistent: true,
 				title: title,
 				buttons: {"保存": '1', "取消": '-1'},
@@ -102,16 +106,21 @@
 							console.log(items)
 							var archiveContentId = items[0].id;
 							var title = items[0].title;
+							var content = items[0].content;
 							var fileId = items[0].fileId;
 							if (title == '') {
 								top.$.jBox.tip("标题不能为空");
 								return false;
 							}
+							if (type==3&&content == '') {
+								top.$.jBox.tip("文件内容不能为空");
+								return false;
+							}
 							if (fileId == '') {
 								top.$.jBox.tip("请先上传文件");
 								return false;
 							}
-							$.post("${ctx}/archive/cmProductArchiveContent/save?type="+type+"&id=" + archiveContentId + "&title=" + title + "&fileId=" + fileId+"&productArchiveId=" + productArchiveId, function (data) {
+							$.post("${ctx}/archive/cmProductArchiveContent/save?type="+type+"&id=" + archiveContentId + "&title=" + title +"&content=" + content + "&fileId=" + fileId+"&productArchiveId=" + productArchiveId, function (data) {
 								top.$.jBox.tip("保存资料成功");
 								setTimeout(function () {
 									window.location.href = "${ctx}/archive/cmProductArchiveContent/?type="+type+"&productArchiveId=" + productArchiveId;

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderConfirmReturnRecord.jsp

@@ -125,7 +125,7 @@
 </ul>
 <br/>
 <div class="refund-btn-top">
-    <input type="button" class="btn btn-primary" onclick="window.location.href='${ctx}/order/cmReturnedPurchase/'"
+    <input type="button" class="btn btn-primary" onclick="window.history.go(-1)"
            value="返回">
     <input type="button" class="btn btn-primary print-now" value="打印">
 </div>

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/bulkpurchase/refundRecord.jsp

@@ -104,7 +104,7 @@
         </c:if>
     </c:if>
     <c:if test="${from eq '2'}">
-        <li><a href="${ctx}/order/detail?id=${orderID}">订单详情</a></li>
+        <li><a href="${ctx}${orderType == 2 ?'/hehe/new':''}/order/detail?id=${orderID}">订单详情</a></li>
     </c:if>
     <c:if test="${from eq '3'}">
         <li><a href="${ctx}/shopOrder/checkPaymentOrder">订单财务信息</a></li>

+ 9 - 9
src/main/webapp/WEB-INF/views/modules/coupon/MoneyCouponForm.jsp

@@ -247,12 +247,12 @@
         <div class="controls">
             <form:radiobutton name="hdq" path="couponType" value="0" label="活动券" class="required"
                               onclick="couponShow()"/>
-            <form:radiobutton id="plq" path="couponType" value="1"
-                              style="display:${cmCoupon.moneyCouponType eq 2 ? 'none':''}" label="品类券" class="required"
-                              onclick="couponShow()"/>
-            <form:radiobutton id="zxq" path="couponType" value="2"
-                              style="display:${cmCoupon.moneyCouponType eq 2 ? 'none':''}" label="用户专享券"
-                              class="required" onclick="couponShow()"/>
+<%--            <form:radiobutton id="plq" path="couponType" value="1"--%>
+<%--                              style="display:${cmCoupon.moneyCouponType eq 2 ? 'none':''}" label="品类券" class="required"--%>
+<%--                              onclick="couponShow()"/>--%>
+<%--            <form:radiobutton id="zxq" path="couponType" value="2"--%>
+<%--                              style="display:${cmCoupon.moneyCouponType eq 2 ? 'none':''}" label="用户专享券"--%>
+<%--                              class="required" onclick="couponShow()"/>--%>
             <form:radiobutton id="dpq" path="couponType" value="3"
                               style="display:${cmCoupon.moneyCouponType eq 2 ? 'none':''}" label="店铺券" class="required"
                               onclick="couponShow()"/>
@@ -262,9 +262,9 @@
         <div class="control-group">
             <label class="control-label"><font color="red">*</font>优惠商品:</label>
             <div class="controls">
-                <form:radiobutton id="qsc" path="productType" value="1" label="全商城商品"
-                                  style="display: ${cmCoupon.moneyCouponType eq 2 ? 'none':''}" onclick="productShow()"
-                                  checked="${empty cmCoupon.productType ? true:false}"/>
+<%--                <form:radiobutton id="qsc" path="productType" value="1" label="全商城商品"--%>
+<%--                                  style="display: ${cmCoupon.moneyCouponType eq 2 ? 'none':''}" onclick="productShow()"--%>
+<%--                                  checked="${empty cmCoupon.productType ? true:false}"/>--%>
                 <form:radiobutton path="productType" value="2" label="指定商品" onclick="productShow()"/>
             </div>
         </div>

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/coupon/cmCouponForm.jsp

@@ -194,7 +194,7 @@
 		<div class="control-group">
 			<label class="control-label"><font color="red">*</font>优惠商品:</label>
 			<div class="controls">
-				<form:radiobutton path="productType" value="1" label="全商城商品" onclick="productShow()" checked ="${empty cmCoupon.productType ? true:false}"/>
+<%--				<form:radiobutton path="productType" value="1" label="全商城商品" onclick="productShow()" checked ="${empty cmCoupon.productType ? true:false}"/>--%>
 				<form:radiobutton path="productType" value="2" label="指定商品" onclick="productShow()"/>
 			</div>
 		</div>

+ 3 - 3
src/main/webapp/WEB-INF/views/modules/coupon/cmCouponList.jsp

@@ -23,10 +23,10 @@
 <body>
 	<ul class="nav nav-tabs">
 		<li class="active"><a href="${ctx}/coupon/cmCoupon/list?couponType=0&&moneyCouponFlag=2">活动券</a></li>
-		<li><a href="${ctx}/coupon/cmCoupon/list?couponType=1&&moneyCouponFlag=2">品类券</a></li>
-		<li><a href="${ctx}/coupon/cmCoupon/list?couponType=2&&moneyCouponFlag=2">用户专享券</a></li>
+<%--		<li><a href="${ctx}/coupon/cmCoupon/list?couponType=1&&moneyCouponFlag=2">品类券</a></li>--%>
+<%--		<li><a href="${ctx}/coupon/cmCoupon/list?couponType=2&&moneyCouponFlag=2">用户专享券</a></li>--%>
 		<li><a href="${ctx}/coupon/cmCoupon/list?couponType=3&&moneyCouponFlag=2">店铺券</a></li>
-		<li><a href="${ctx}/coupon/cmCoupon/list?couponType=4&&moneyCouponFlag=2">新用户券</a></li>
+<%--		<li><a href="${ctx}/coupon/cmCoupon/list?couponType=4&&moneyCouponFlag=2">新用户券</a></li>--%>
 	</ul>
 	<form:form id="searchForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/" method="post" class="breadcrumb form-search">
 		<input type="hidden" name="couponType" value="0"/>

+ 3 - 3
src/main/webapp/WEB-INF/views/modules/coupon/couponShopList.jsp

@@ -23,10 +23,10 @@
 <body>
 <ul class="nav nav-tabs">
     <li><a href="${ctx}/coupon/cmCoupon/list?couponType=0&&moneyCouponFlag=2">活动券</a></li>
-    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=1&&moneyCouponFlag=2">品类券</a></li>
-    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=2&&moneyCouponFlag=2">用户专享券</a></li>
+<%--    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=1&&moneyCouponFlag=2">品类券</a></li>--%>
+<%--    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=2&&moneyCouponFlag=2">用户专享券</a></li>--%>
     <li class="active"><a href="${ctx}/coupon/cmCoupon/list?couponType=3&&moneyCouponFlag=2">店铺券</a></li>
-    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=4&&moneyCouponFlag=2">新用户券</a></li>
+<%--    <li><a href="${ctx}/coupon/cmCoupon/list?couponType=4&&moneyCouponFlag=2">新用户券</a></li>--%>
 </ul>
 <form:form id="searchForm" modelAttribute="cmCoupon" action="${ctx}/coupon/cmCoupon/" method="post" class="breadcrumb form-search">
     <input type="hidden" name="couponType" value="3"/>

+ 4 - 4
src/main/webapp/WEB-INF/views/modules/coupon/redemptionCodeCouponForm.jsp

@@ -185,17 +185,17 @@
         <label class="control-label"><font color="red">*</font>优惠券类型:</label>
         <div class="controls">
             <form:radiobutton path="couponType" value="0" label="活动券" class="required" onclick="couponShow()"/>
-            <form:radiobutton path="couponType" value="1" label="品类券" class="required" onclick="couponShow()"/>
-            <form:radiobutton path="couponType" value="2" label="用户专享券" class="required" onclick="couponShow()"/>
+<%--            <form:radiobutton path="couponType" value="1" label="品类券" class="required" onclick="couponShow()"/>--%>
+<%--            <form:radiobutton path="couponType" value="2" label="用户专享券" class="required" onclick="couponShow()"/>--%>
             <form:radiobutton path="couponType" value="3" label="店铺券" class="required" onclick="couponShow()"/>
-            <form:radiobutton path="couponType" value="4" label="新用户券" class="required" onclick="couponShow()"/>
+<%--            <form:radiobutton disabled="true" path="couponType" value="4" label="新用户券" class="required" onclick="couponShow()"/>--%>
         </div>
     </div>
     <div id="eventVoucher" hidden="hidden">
         <div class="control-group">
             <label class="control-label"><font color="red">*</font>优惠商品:</label>
             <div class="controls">
-                <form:radiobutton path="productType" value="1" label="全商城商品" onclick="productShow()" checked ="${empty cmCoupon.productType ? true:false}"/>
+<%--                <form:radiobutton path="productType" value="1" label="全商城商品" onclick="productShow()" checked ="${empty cmCoupon.productType ? true:false}"/>--%>
                 <form:radiobutton path="productType" value="2" label="指定商品" onclick="productShow()"/>
             </div>
         </div>

+ 9 - 9
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheProductForm.jsp

@@ -297,17 +297,18 @@
            class="form-horizontal">
 <form:hidden path="id"/>
 <form:hidden path="productId" id="productId"/>
+<form:hidden path="isNewRecord" id="isNewRecord"/>
 <sys:message content="${message}"/>
     <%--        <form:hidden path="floorIds"/>--%>
 <div class="control-group">
     <label class="control-label"><font color="red">*</font>商品:</label>
     <div class="controls" id="addProduct">
-        <a href="JavaScript:;" onclick="showSelect()">请选择加入呵呵商城的商品</a>
+        <a href="JavaScript:;" onclick="showSelect()">请选择加入颜选美学商城的商品</a>
     </div>
     <table id="contentTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
         <thead>
         <tr>
-            <th>图片</th>
+            <th style="text-align:right">图片</th>
             <th>商品名称</th>
             <th>供应商</th>
             <th>操作</th>
@@ -315,7 +316,7 @@
         </thead>
         <tbody>
         <tr>
-            <td><img id="mainImage" src="${cmHeheProduct.mainImage}" width="50px" height="50px"></td>
+            <td style="text-align:right"><img id="mainImage" src="${cmHeheProduct.mainImage}" width="50px" height="50px"></td>
             <td style="text-align: center" id="name">${cmHeheProduct.name}</td>
             <td id="shopName">${cmHeheProduct.shopName}</td>
             <td><a href="javascript:void(0);" onclick="deleteProduct()">删除</a></td>
@@ -333,7 +334,7 @@
             <c:forEach items="${cmHeheProduct.skus}" var="sku" varStatus="index">
                 <div>
                     <input type="number" style="display:none" value="${sku.skuId}" name="skus[${index.index}].skuId">
-                    <label class="control-label" style="text-align:left">
+                    <label class="control-label" style="text-align:right">
                         <font color="red">*</font>规格:${sku.unit}
                     </label>
                     <div class="controls">
@@ -347,7 +348,7 @@
                             <label><font color="red">*</font>成本价:${sku.costPrice}</label>
                         </c:if>
                         <c:if test="${sku.costCheckFlag eq 2}">
-                            <label><font color="red">*</font>成本比例百分比:${sku.shopPercent}%</label>
+                            <label><font color="red">*</font>比例:供应商${sku.shopPercent}%,集团${sku.organizePercent}%,采美${sku.cmPercent}%</label>
                         </c:if>
                     </div>
                 </div>
@@ -501,11 +502,10 @@
 
                             for (let i = 0; i < skus.length; i++) {
                                 var unit=i+1;
-                                var cost = skus[i].costCheckFlag == 1 ? '固定成本' : '比例成本';
-                                var costShow = skus[i].costCheckFlag == 1 ? '<label><font color="red">*</font>成本价:' + skus[i].costPrice + '</label>' : '<label><font color="red">*</font>成本比例百分比:' + skus[i].shopPercent + '%</label>';
+                                var cost = skus[i].costCheckFlag == 1 ? '固定成本' : '比例成本' ;
+                                var costShow = skus[i].costCheckFlag == 1 ? '<label><font color="red">*</font>成本价:' + skus[i].costPrice + '</label>' : '<label><font color="red">*</font>比例:供应商' + skus[i].shopPercent + '%,集团' + skus[i].organizePercent + '%,采美' + skus[i].cmPercent + '%</label>';
                                 html += '<div><input type="number" style="display:none" value="' + skus[i].skuId + '" name="skus[' + i + '].skuId">';
-                                html += '<label class="control-label"><font color="red">*</font>规格:规格' + unit;
-                                html += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>';
+                                html += '<label class="control-label" style="text-align:right"><font color="red">*</font>规格:' + skus[i].unit+'</label>';
                                 html += '<div class="controls"><font color="red">*</font>售价:';
                                 html += '<input type="number" style="width:100px;" min="0" id="price" name="skus[' + i + '].price" value="' + skus[i].price + '" required onblur="checkPrice(this)">';
                                 html += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';

+ 4 - 4
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheProductList.jsp

@@ -10,7 +10,7 @@
 	</style>
 	<script type="text/javascript">
 		$(document).ready(function() {
-			
+
 		});
 		function page(n,s){
 			$("#pageNo").val(n);
@@ -70,7 +70,7 @@
 				<th>商品名称</th>
 				<th>供应商名称</th>
 				<th>售价</th>
-				<th>成本价</th>
+				<th>成本价/比例</th>
 				<th>是否含税</th>
 				<th>商品状态</th>
 				<th>添加时间</th>
@@ -96,7 +96,7 @@
 						${cmHeheProduct.price}
 				</td>
 				<td>
-						${cmHeheProduct.costPrice}
+						${cmHeheProduct.costType eq 1?cmHeheProduct.costPrice:cmHeheProduct.shopPercent}${cmHeheProduct.costType eq 1?'':'%'}
 				</td>
 				<td>
 					${cmHeheProduct.includedTax eq 0 ? "不含税" : "含税"}-
@@ -158,4 +158,4 @@
 	}
 </script>
 </body>
-</html>
+</html>

+ 253 - 220
src/main/webapp/WEB-INF/views/modules/hehe/heheNewOrderDetail.jsp

@@ -250,14 +250,14 @@
             background: #fff;
             width: 125px;
             position: absolute;
-            left: 35px;
-            top: 30px;
+            left: 826px;
+            top: 5px;
             padding: 10px;
             border: 1px solid #666;
             -webkit-border-radius: 5px;
             -moz-border-radius: 5px;
             border-radius: 5px;
-            z-index: 999;
+            z-index: 100001;
             display: none
         }
 
@@ -391,7 +391,7 @@
     <tr>
         <td>下单时间: ${order.orderTime}</td>
         <td>订单号(ID): ${order.orderNo}(${order.orderID})</td>
-        <td>返佣订单: ${(order.rebateOrder ne '0' || order.rebateFlag eq '1')?'是':'否'}</td>
+<%--        <td>返佣订单: ${(order.rebateOrder ne '0' || order.rebateFlag eq '1')?'是':'否'}</td>--%>
     </tr>
     <tr>
         <td>订单类型: ${order.collageFlag eq 1?'拼团订单':'独立订单'}</td>
@@ -526,15 +526,15 @@
         <td>
             应收金额:<fmt:formatNumber value="${order.payableAmount}" type="currency"/>
             <span style="color: red">
-                <c:if test="${order.balancePayFee gt 0}">
-                    <a href="${ctx}/user/cmUserBalanceRecord/userBalanceRecord?userId=${order.userID}"
-                       style="color: red;text-decoration: underline">
-                        (账户余额抵扣: <fmt:formatNumber value="${order.balancePayFee}" type="currency"/>)
-                    </a>
-                </c:if>
-                <c:if test="${order.balancePayFee le 0}">
-                    (账户余额抵扣: <fmt:formatNumber value="${order.balancePayFee}" type="currency"/>)
-                </c:if>
+<%--                <c:if test="${order.balancePayFee gt 0}">--%>
+<%--                    <a href="${ctx}/user/cmUserBalanceRecord/userBalanceRecord?userId=${order.userID}"--%>
+<%--                       style="color: red;text-decoration: underline">--%>
+<%--                        (账户余额抵扣: <fmt:formatNumber value="${order.balancePayFee}" type="currency"/>)--%>
+<%--                    </a>--%>
+<%--                </c:if>--%>
+<%--                <c:if test="${order.balancePayFee le 0}">--%>
+<%--                    (账户余额抵扣: <fmt:formatNumber value="${order.balancePayFee}" type="currency"/>)--%>
+<%--                </c:if>--%>
 
 
             </span>
@@ -552,68 +552,68 @@
         </td>
         <td>
             退款金额(已完成):<fmt:formatNumber value="${returnValue}" type="currency"/>
-            <span style="color: red">
-                    (原<fmt:formatNumber value="${returnedPurchaseFee}" type="currency"/>,折扣取消
-                    <c:if test="${order.discountFee gt returnedPurchaseFee}"><fmt:formatNumber
-                            value="${returnedPurchaseFee}" type="currency"/></c:if>
-                    <c:if test="${order.discountFee le returnedPurchaseFee}"><fmt:formatNumber
-                            value="${order.discountFee}" type="currency"/></c:if>)
-                </span>
+<%--            <span style="color: red">--%>
+<%--                    (原<fmt:formatNumber value="${returnedPurchaseFee}" type="currency"/>,折扣取消--%>
+<%--                    <c:if test="${order.discountFee gt returnedPurchaseFee}"><fmt:formatNumber--%>
+<%--                            value="${returnedPurchaseFee}" type="currency"/></c:if>--%>
+<%--                    <c:if test="${order.discountFee le returnedPurchaseFee}"><fmt:formatNumber--%>
+<%--                            value="${order.discountFee}" type="currency"/></c:if>)--%>
+<%--                </span>--%>
         </td>
     </tr>
     <tr>
-        <td>
-            经理折扣:
-            <c:if test="${order.discountFee gt 0}">
-                <c:if test="${order.discountFee gt returnedPurchaseFee}">
-                    <fmt:formatNumber value="${order.discountFee - returnedPurchaseFee}" type="currency"/>
-                </c:if>
-                <c:if test="${order.discountFee le returnedPurchaseFee}">
-                    ¥0.00
-                </c:if>
-                <span style="color: red">
-                        (原<fmt:formatNumber value="${order.discountFee}" type="currency"/>,折扣取消
-                        <c:if test="${order.discountFee gt returnedPurchaseFee}">
-                            <fmt:formatNumber value="${returnedPurchaseFee}" type="currency"/>
-                        </c:if>
-                        <c:if test="${order.discountFee le returnedPurchaseFee}">
-                            <fmt:formatNumber value="${order.discountFee}" type="currency"/>
-                        </c:if>)
-                    </span>
-            </c:if>
-            <c:if test="${order.discountFee le 0}">¥0.00</c:if>
-        </td>
-        <td>运费:
-            <c:if test="${order.freight == 0}">
-                包邮
-            </c:if>
-            <c:if test="${order.freight == -1}">
-                到付
-            </c:if>
-            <c:if test="${order.freight == -2}">
-                仪器到付-产品包邮
-            </c:if>
-            <c:if test="${order.freight != -1 && order.freight != 0 && order.freight != -2}">
-                <fmt:formatNumber value="${order.freight}" type="currency"/>
-            </c:if>
-        </td>
-        <td style="position: relative;"><a class="operation-btn btn">功能</a>
-            <div class="operation-block">
-                <shiro:hasPermission name="order:order:edit">
-                    <%--包含订单充值商品就不显示--%>
-                    <c:if test="${order.rechargeGoods ne 1 and order.rechargeGoods ne 2}">
-                        <c:if test="${order.status == 11 || order.status == 12 || order.status == 21 || order.status == 22 || order.status == 31 || order.status == 32}">
-                            <a href="${ctx}/order/toDeliveryPage?id=${order.orderID}">发货</a>
-                        </c:if>
-                        <c:if test="${order.receiptStatus == 2 && order.status != 6 && order.status != 7}">
-                            <a href="javascript:void(0);" onclick="collection(${order.orderID})">抹平收款</a>
-                        </c:if>
-                    </c:if>
-                    <c:if test="${(order.organizeID == 0 or order.organizeID > 2) && order.status == 11 && order.payStatus == 1}">
-                        <a href="javascript:void(0);"
-                           onclick="modelShow('${order.orderID}')">编辑经理折扣</a>
-                    </c:if>
-                </shiro:hasPermission>
+<%--        <td>--%>
+<%--            经理折扣:--%>
+<%--            <c:if test="${order.discountFee gt 0}">--%>
+<%--                <c:if test="${order.discountFee gt returnedPurchaseFee}">--%>
+<%--                    <fmt:formatNumber value="${order.discountFee - returnedPurchaseFee}" type="currency"/>--%>
+<%--                </c:if>--%>
+<%--                <c:if test="${order.discountFee le returnedPurchaseFee}">--%>
+<%--                    ¥0.00--%>
+<%--                </c:if>--%>
+<%--                <span style="color: red">--%>
+<%--                        (原<fmt:formatNumber value="${order.discountFee}" type="currency"/>,折扣取消--%>
+<%--                        <c:if test="${order.discountFee gt returnedPurchaseFee}">--%>
+<%--                            <fmt:formatNumber value="${returnedPurchaseFee}" type="currency"/>--%>
+<%--                        </c:if>--%>
+<%--                        <c:if test="${order.discountFee le returnedPurchaseFee}">--%>
+<%--                            <fmt:formatNumber value="${order.discountFee}" type="currency"/>--%>
+<%--                        </c:if>)--%>
+<%--                    </span>--%>
+<%--            </c:if>--%>
+<%--            <c:if test="${order.discountFee le 0}">¥0.00</c:if>--%>
+<%--        </td>--%>
+<%--        <td>运费:--%>
+<%--            <c:if test="${order.freight == 0}">--%>
+<%--                包邮--%>
+<%--            </c:if>--%>
+<%--            <c:if test="${order.freight == -1}">--%>
+<%--                到付--%>
+<%--            </c:if>--%>
+<%--            <c:if test="${order.freight == -2}">--%>
+<%--                仪器到付-产品包邮--%>
+<%--            </c:if>--%>
+<%--            <c:if test="${order.freight != -1 && order.freight != 0 && order.freight != -2}">--%>
+<%--                <fmt:formatNumber value="${order.freight}" type="currency"/>--%>
+<%--            </c:if>--%>
+<%--        </td>--%>
+<%--        <td style="position: relative;"><a class="operation-btn btn">功能</a>--%>
+<%--            <div class="operation-block">--%>
+<%--                <shiro:hasPermission name="order:order:edit">--%>
+<%--                    &lt;%&ndash;包含订单充值商品就不显示&ndash;%&gt;--%>
+<%--                    <c:if test="${order.rechargeGoods ne 1 and order.rechargeGoods ne 2}">--%>
+<%--                        <c:if test="${order.status == 11 || order.status == 12 || order.status == 21 || order.status == 22 || order.status == 31 || order.status == 32}">--%>
+<%--                            <a href="${ctx}/order/toDeliveryPage?id=${order.orderID}">发货</a>--%>
+<%--                        </c:if>--%>
+<%--                        <c:if test="${order.receiptStatus == 2 && order.status != 6 && order.status != 7}">--%>
+<%--                            <a href="javascript:void(0);" onclick="collection(${order.orderID})">抹平收款</a>--%>
+<%--                        </c:if>--%>
+<%--                    </c:if>--%>
+<%--                    <c:if test="${(order.organizeID == 0 or order.organizeID > 2) && order.status == 11 && order.payStatus == 1}">--%>
+<%--                        <a href="javascript:void(0);"--%>
+<%--                           onclick="modelShow('${order.orderID}')">编辑经理折扣</a>--%>
+<%--                    </c:if>--%>
+<%--                </shiro:hasPermission>--%>
 <%--                <shiro:hasPermission name="order:order:applyrefound">--%>
 <%--                    <c:if test="${order.status == 12 || order.status == 13 || order.status == 21 || order.status == 22 || order.status == 23 || order.status == 31 || order.status == 32 || order.status == 33 || order.status == 4 || order.status == 5}">--%>
 <%--                        &lt;%&ndash;  返佣订单不能申请退款(退货) &ndash;%&gt;--%>
@@ -640,29 +640,29 @@
 <%--                    </c:if>--%>
 <%--                </shiro:hasPermission>--%>
 
-                <shiro:hasPermission name="order:order:edit">
-                    <c:if test="${order.status ne 0}">
-                        <a href="${ctx}/order/printOrder?orderID=${order.orderID}">打印发货单</a>
-                    </c:if>
-                    <a href="${ctx}/order/exportOrder?id=${order.orderID}">订单导出</a>
-                    <a href="${ctx}/order/cmOrderRemark/remarksViewNew.rpc?orderID=${order.orderID}&source=2&orderType=2">订单备注</a>
-                    <%--包含订单充值商品就不显示--%>
-                    <c:if test="${empty order.rechargeGoods}">
-                        <c:if test="${order.status ne 0 && order.status ne 11 && order.status ne 21 && order.status ne 6 && order.status ne 4}">
-                            <a href="${ctx}/order/logisticsDetails?orderID=${order.orderID}">发货记录</a>
-                        </c:if>
-                        <c:if test="${order.status ne 0 && order.status ne 11 && order.status ne 6}">
-                            <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${order.orderID}&from=2">收退款记录
-                            </a>
-                        </c:if>
-                        <c:if test="${order.status ne 0 && order.status ne 11 && order.status ne 6}">
-                            <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRecturnRecordByOrderID.rpc?orderID=${order.orderID}">退款(退货)记录
-                            </a>
-                        </c:if>
-                    </c:if>
-                </shiro:hasPermission>
-            </div>
-        </td>
+<%--                <shiro:hasPermission name="order:order:edit">--%>
+<%--                    <c:if test="${order.status ne 0}">--%>
+<%--                        <a href="${ctx}/order/printOrder?orderID=${order.orderID}">打印发货单</a>--%>
+<%--                    </c:if>--%>
+<%--                    <a href="${ctx}/order/exportOrder?id=${order.orderID}">订单导出</a>--%>
+<%--                    <a href="${ctx}/order/cmOrderRemark/remarksViewNew.rpc?orderID=${order.orderID}&source=2&orderType=2">订单备注</a>--%>
+<%--                    &lt;%&ndash;包含订单充值商品就不显示&ndash;%&gt;--%>
+<%--                    <c:if test="${empty order.rechargeGoods}">--%>
+<%--                        <c:if test="${order.status ne 0 && order.status ne 11 && order.status ne 21 && order.status ne 6 && order.status ne 4}">--%>
+<%--                            <a href="${ctx}/order/logisticsDetails?orderID=${order.orderID}">发货记录</a>--%>
+<%--                        </c:if>--%>
+<%--                        <c:if test="${order.status ne 0 && order.status ne 11 && order.status ne 6}">--%>
+<%--                            <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${order.orderID}&from=2">收退款记录--%>
+<%--                            </a>--%>
+<%--                        </c:if>--%>
+<%--                        <c:if test="${order.status ne 0 && order.status ne 11 && order.status ne 6}">--%>
+<%--                            <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRecturnRecordByOrderID.rpc?orderID=${order.orderID}">退款(退货)记录--%>
+<%--                            </a>--%>
+<%--                        </c:if>--%>
+<%--                    </c:if>--%>
+<%--                </shiro:hasPermission>--%>
+<%--            </div>--%>
+<%--        </td>--%>
     </tr>
     <tr>
         <td>拼团状态:
@@ -699,124 +699,149 @@
     <div class="order-rows">
         <span><label>下单时间:</label>${order.orderTime}</span>
         <span><label>子订单号(ID):</label>${shopOrder.shopOrderNo}(${shopOrder.shopOrderID})</span>
-        <span><label>子订单金额:</label><fmt:formatNumber value="${shopOrder.realPay}" type="currency"/></span>
-        <c:if test="${shopOrder.postFeeCos eq '0'}">
-            <div class="print-wrapper">
-                <a href="${ctx}/order/printOrder?shopOrderID=${shopOrder.shopOrderID}">打印</a>
-                <a href="${ctx}/order/exportSubOrder?shopOrderID=${shopOrder.shopOrderID}">导出</a>
-                <c:if test="${order.status ne '0'}">
-                    <a onclick="copyText('${shopOrder.shopOrderID}')" style="cursor:pointer;">供应商订单二维码</a>
-                </c:if>
-                <c:if test="${shopOrder.orderArchiveId ne null}">
-                    <a href="${ctx}/archive/cmOrderArchive/form?id=${shopOrder.orderArchiveId}">查看订单资料</a>
-                </c:if>
-                <c:if test="${order.onlinePayFlag eq 0}">
-                    <c:if test="${order.status == 12 || order.status == 13 || order.status == 21 || order.status == 22 || order.status == 23 || order.status == 31 || order.status == 32 || order.status == 33 || order.status == 4 || order.status == 5}">
-                        <%--  返佣订单不能申请退款(退货) --%>
-                        <c:if test="${order.rebateOrder == '0'}">
-                            <c:if test="${order.toAudit eq 1}">
-                                <%--如果存在审核收款则不允许申请:1不能申请,其它可以申请--%>
-                                <c:if test="${order.toAudit eq 1}">
-                                    <%--弹窗提示--%>
-                                    <a href="#" onclick="return alertx('订单存在未审核的收款,暂不能退款。请将收款审核通过后再操作退款。')">申请退款</a>
-                                </c:if>
-                            </c:if>
-                            <c:if test="${order.toAudit ne 1}">
-                                <c:if test="${order.applyReturnedPurchaseFlag eq 1}">
-                                    <a href="${ctx}/bulkpurchase/cmRefundsProduct/applyRefound.rpc?orderID=${order.orderID}&onlineShopOrderId=${shopOrder.shopOrderID}&refundType=1"
-                                       <c:if test="${order.status == 21 || order.status == 22 || order.status == 23}">onclick="return confirmx('部分收款的订单、申请退款只能申请全部退款!', this.href)"
-                                    </c:if>
-                                    >申请退款</a>
-                                </c:if>
-                                <c:if test="${order.applyReturnedPurchaseFlag ne 1}">
-                                    <font title="存在未处理完的申请,请前往退款列表处理!">申请退款</font>
-                                </c:if>
-                            </c:if>
+        <span><label>子订单金额:</label><fmt:formatNumber
+                value="${order.onlinePayFlag eq 0?shopOrder.realPay:shopOrder.needPayAmount}" type="currency"/></span>
+        <td style="position: relative;"><a class="operation-btn btn"
+                                           onclick="operation(${shopOrder.shopOrderID})">功能</a>
+            <div style="position: relative;">
+                <div class="operation-block ${shopOrder.shopOrderID}">
+                    <shiro:hasPermission name="order:order:edit">
+                        <%--包含订单充值商品就不显示--%>
+                        <c:if test="${shopOrder.status == 0}">
+                            <a href="${ctx}/order/confirmOrder?orderID=${order.orderID}&shopOrderID=${shopOrder.shopOrderID}&orderType=2"
+                               onclick="return confirmx('是否确认订单?', this.href)">确认订单</a>
                         </c:if>
-                    </c:if>
-                </c:if>
+                    </shiro:hasPermission>
+
+
+                    <shiro:hasPermission name="order:order:edit">
+                        <%--包含订单充值商品就不显示--%>
+                        <a href="${ctx}/order/logisticsDetails?orderID=${order.orderID}&shopOrderID=${shopOrder.shopOrderID}&orderType=2">发货记录</a>
+                        <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${order.orderID}&shopOrderID=${shopOrder.shopOrderID}&from=2&orderType=2">收付款记录</a>
+                        <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRecturnRecordByOrderID.rpc?orderID=${order.orderID}&shopOrderID=${shopOrder.shopOrderID}&orderType=2">退款(退货)记录</a>
+                        <a href="${ctx}/order/cmOrderRemark/remarksViewNew.rpc?orderID=${order.orderID}&source=2&shopOrderID=${shopOrder.shopOrderID}&orderType=2">订单备注</a>
+                    </shiro:hasPermission>
+                </div>
             </div>
-        </c:if>
-        <c:if test="${order.onlinePayFlag eq 0}">
-            <br/>
-            <span><label>商品总额:</label><fmt:formatNumber value="${shopOrder.needPayAmount}" type="currency"/></span>
-            <span><label>优惠:</label><fmt:formatNumber value="${shopOrder.eachDiscount}" type="currency"/></span>
-            <span><label>应付金额:</label><fmt:formatNumber value="${shopOrder.realPay}" type="currency"/></span>
-            <span><label>已付金额:</label><fmt:formatNumber value="${shopOrder.receiptAmount}" type="currency"/></span>
-            <span><label>待付金额:</label><fmt:formatNumber value="${shopOrder.restAmount}" type="currency"/></span>
-            <br/>
-            <span><label>收款状态:</label>
-                    <c:if test="${shopOrder.shopReceiptStatus == 1}">
-                        <font color="red">待收款</font>
-                    </c:if>
-                    <c:if test="${shopOrder.shopReceiptStatus == 2}">
-                        <font color="#ff8c00">部分收款</font>
-                    </c:if>
-                    <c:if test="${shopOrder.shopReceiptStatus == 3}">
-                        <font color="green">已收款</font>
-                    </c:if>
-            </span>
-            <span><label>付款状态:</label>
-                    <c:if test="${shopOrder.payStatus == 1}">
-                        <font color="red">待付款</font>
-                    </c:if>
-                    <c:if test="${shopOrder.payStatus == 2}">
-                        <font color="#ff8c00">部分付款</font>
-                    </c:if>
-                    <c:if test="${shopOrder.payStatus == 3}">
-                        <font color="green">已付款</font>
-                    </c:if>
+        </td>
+        </tr>
+        <span>商品总额:<fmt:formatNumber value="${shopOrder.needPayAmount}" type="currency"/></span>
+        <span>运费:
+                    ${shopOrder.postageInfo}
             </span>
-            <span><label>发货状态:</label>
-                    <c:if test="${shopOrder.sendOutStatus == 1}">
-                        <font color="red">待发货</font>
-                    </c:if>
-                    <c:if test="${shopOrder.sendOutStatus == 2}">
-                        <font color="#ff8c00">部分发货</font>
-                    </c:if>
-                    <c:if test="${shopOrder.sendOutStatus == 3}">
-                        <font color="green">已发货</font>
-                    </c:if>
+        <span>子订单总额:<fmt:formatNumber value="${shopOrder.totalAmount}" type="currency"/></span>
+            <%--        <span>优惠:<fmt:formatNumber value="${shopOrder.eachDiscount}" type="currency"/></span>--%>
+        <span>应收金额:
+            <c:if test="${shopOrder.realPay!=null}"><fmt:formatNumber value="${shopOrder.realPay}"
+                                                                      type="currency"/></c:if>
+            <c:if test="${shopOrder.realPay==null}"><fmt:formatNumber value="${shopOrder.needPayAmount}"
+                                                                      type="currency"/></c:if>
+        </span>
+        <span>
+                已收金额:<fmt:formatNumber value="${shopOrder.receiptAmount}" type="currency"/>
+                <c:if test="${shopOrder.useBalanceFlag eq 1 and shopOrder.accountAmount ne null}">(余额抵扣¥${shopOrder.accountAmount})</c:if>
+<%--                <c:if test="${order.organizeID != 4&&shopOrder.commercialCode eq 'E1807059160' && (order.receiptStatus == 2 || order.receiptStatus == 3)}">--%>
+<%--                    <font color="red">(采美信息线上收款)</font>--%>
+<%--                </c:if>--%>
+
             </span>
-            <c:if test="${not empty shopOrder.note}">
-                <span>留言:${shopOrder.note}</span>
-            </c:if>
-        </c:if>
-        <c:if test="${order.onlinePayFlag eq 1}">
-            <c:if test="${shopOrder.postFeeCos eq '0'}">
-                <c:if test="${order.status ne 0 && order.status ne 11}">
-                    <div class="delivery-wrapper">
-                            <span>发货状态:
-                                <c:if test="${shopOrder.sendOutStatus == 1}">
-                                    <font color="red">待发货</font>
-                                </c:if>
-                                <c:if test="${shopOrder.sendOutStatus == 2}">
-                                    <font color="#ff8c00">部分发货</font>
+        <span>待收金额:<fmt:formatNumber value="${shopOrder.restAmount}" type="currency"/></span>
+        <br/>
+        <span>子订单状态:
+ <c:if test="${shopOrder.status eq 11 || shopOrder.status eq 12 || shopOrder.status eq 13 ||shopOrder.status eq 21 ||shopOrder.status eq 22 ||
+				shopOrder.status eq 23 || shopOrder.status eq 31 ||shopOrder.status eq 32 ||shopOrder.status eq 33}">
+     交易中
+ </c:if>
+<%--            <c:if test="${shopOrder.status eq 0 || shopOrder.status eq 4 || shopOrder.status eq 5 || shopOrder.status eq 6 || shopOrder.status eq 7}">--%>
+<%--                ${fns:getDictLabel(shopOrder.status,"order_status","" )}--%>
+<%--                <c:if test="${shopOrder.status eq 0}">--%>
+<%--                    <span id="time" style="color: red"></span>--%>
+<%--                </c:if>--%>
+<%--                <c:if test="${shopOrder.status eq 6}">--%>
+<%--                    <font color="red">(--%>
+<%--                            <c:if test="${shopOrder.closeTime ne null}">--%>
+<%--                                ${shopOrder.closeTime}--%>
+<%--                            </c:if>--%>
+<%--                            <c:if test="${shopOrder.closeReason ne null}">--%>
+<%--                                , ${shopOrder.closeReason}--%>
+<%--                            </c:if>--%>
+<%--                    )</font>--%>
+<%--                </c:if>--%>
+<%--            </c:if>--%>
+<%--            订单状态 0:待确认 1:已确认 2:交易完成 3:订单完成 4:已关闭 5:交易全退--%>
+                            <c:if test="${shopOrder.status == 0}">
+                                <font color="red">待确认</font>
+                            </c:if>
+                            <c:if test="${shopOrder.status == 1}">
+                                <font color="red">已确认</font>
+                            </c:if>
+                            <c:if test="${shopOrder.status == 2}">
+                                <font color="red">交易完成</font>
+                            </c:if>
+                            <c:if test="${shopOrder.status == 3}">
+                                <font color="red">订单完成</font>
+                            </c:if>
+                            <c:if test="${shopOrder.status == 4}">
+                                <font color="red">已关闭</font>
+                            </c:if>
+                            <c:if test="${shopOrder.status == 5}">
+                                <font color="red">交易全退</font>
+                            </c:if>
+
+                        </span>
+        <span>收款状态:
+                            <c:if test="${shopOrder.shopReceiptStatus == 1}">
+                                <font color="red">待收款</font>
+                            </c:if>
+                            <c:if test="${shopOrder.shopReceiptStatus == 2}">
+                                <font color="#ff8c00">部分收款</font>
+                            </c:if>
+                            <c:if test="${shopOrder.shopReceiptStatus == 3}">
+                                <font color="green">已收款</font>
+                            </c:if>
+                        </span>
+
+        <span>发货状态:
+                            <c:if test="${shopOrder.sendOutStatus == 1}">
+                                <font color="red">待发货</font>
+                            </c:if>
+                            <c:if test="${shopOrder.sendOutStatus == 2}">
+                                <font color="#ff8c00">部分发货</font>
+                            </c:if>
+                            <c:if test="${shopOrder.sendOutStatus == 3}">
+                                <font color="green">已发货</font>
+                            </c:if>
+                        </span>
+        <span>付款状态:
+                            <c:if test="${shopOrder.payStatus == 1}">
+                                <font color="red">待付款</font>
+                            </c:if>
+                            <c:if test="${shopOrder.payStatus == 2}">
+                                <font color="#ff8c00">部分付款</font>
+                            </c:if>
+                            <c:if test="${shopOrder.payStatus == 3}">
+                                <font color="green">已付款</font>
+                            </c:if>
+                        </span>
+        <span>
+                                退款状态:
+                                <c:if test="${shopOrder.refundStatus == 1}">
+                                    <font>无退款</font>
                                 </c:if>
-                                <c:if test="${shopOrder.sendOutStatus == 3}">
-                                    <font color="green">已发货</font>
+<%--                                <c:if test="${shopOrder.refundStatus == 2}">--%>
+<%--                                    <font>退款中</font>--%>
+<%--                                </c:if>--%>
+<%--                                <c:if test="${shopOrder.orderStatusFlag == 2}">--%>
+<%--                                    <font>部分退款</font>--%>
+<%--                                </c:if>--%>
+                                <c:if test="${shopOrder.refundStatus == 3}">
+                                    <font>已退款</font>
                                 </c:if>
                             </span>
-                        <span>付款状态:<c:if test="${shopOrder.payStatus == 1}">
-                            <font color="red">待付款</font>
-                        </c:if>
-                                            <c:if test="${shopOrder.payStatus == 2}">
-                                                <font color="#ff8c00">部分付款</font>
-                                            </c:if>
-                                            <c:if test="${shopOrder.payStatus == 3}">
-                                                <font color="green">已付款</font>
-                                            </c:if></span>
-                        <c:if test="${shopOrder.payStatus == 3 or shopOrder.payStatus == 2}">
-                                    <span>已付金额: <fmt:formatNumber value="${shopOrder.payed}" type="currency"/>
-                                    </span>
-                        </c:if>
-                    </div>
-                </c:if>
-                <c:if test="${not empty shopOrder.note}">
-                    <div><label>留言:</label>${shopOrder.note}</div>
-                </c:if>
-            </c:if>
+        <c:if test="${not empty shopOrder.note}">
+            <span>留言:${shopOrder.note}</span>
         </c:if>
+            <%--        </c:if>--%>
     </div>
 
     <div class="order-rows">
@@ -1010,20 +1035,20 @@
 </c:forEach>
 <script type="text/javascript">
     (function () {
-        $('body').click(function (e) {
-            var target = $(e.target),
-                $block = $('.operation-block');
-            if (target.is('.operation-btn')) {
-                if ($block.css('display') === 'none') {
-                    $block.show();
-                } else {
-                    $block.hide();
-                }
-            }
-            if (!target.is('.operation-block') && !target.is('.operation-btn')) {
-                $block.hide();
-            }
-        });
+        // $('body').click(function (e) {
+        //     var target = $(e.target),
+        //         $block = $('.operation-block');
+        //     if (target.is('.operation-btn')) {
+        //         if ($block.css('display') === 'none') {
+        //             $block.show();
+        //         } else {
+        //             $block.hide();
+        //         }
+        //     }
+        //     if (!target.is('.operation-block') && !target.is('.operation-btn')) {
+        //         $block.hide();
+        //     }
+        // });
 
         $('.clauseId').each(function () {
             var self = $(this);
@@ -1044,7 +1069,15 @@
             }
         })
     })();
-
+    function operation(shopOrderID) {
+        var operationBlok = $('.' + shopOrderID)
+        if (operationBlok.css('display') == 'none') {
+            $('.operation-block').hide()
+            operationBlok.show()
+        } else {
+            operationBlok.hide()
+        }
+    }
     function openClauseInfo(index) {
         var content = $("#clauseContent" + index).val();
         if (content == '') {

+ 44 - 44
src/main/webapp/WEB-INF/views/modules/hehe/heheNewOrderList.jsp

@@ -943,23 +943,23 @@
             <li>${order.orderTime}</li>
             <li class="operation-wrap">
                 <a href="${ctx}/hehe/new/order/detail?id=${order.orderID}">查看详情</a>
-                <a class="operation-btn">功能</a>
-                <div class="operation-block">
-                    <shiro:hasPermission name="order:order:edit">
-                        <%--包含订单充值商品就不显示--%>
-                        <c:if test="${empty order.rechargeGoods}">
-                            <c:if test="${order.status == 11 || order.status == 12 || order.status == 21 || order.status == 22 || order.status == 31 || order.status == 32}">
-                                <a href="${ctx}/order/toDeliveryPage?id=${order.orderID}">发货</a>
-                            </c:if>
-                            <c:if test="${order.receiptStatus == 2 && order.status != 6 && order.status != 7}">
-                                <a href="javascript:void(0);" onclick="collection(${order.orderID})">抹平收款</a>
-                            </c:if>
-                        </c:if>
-                        <c:if test="${(order.organizeID == 0 or order.organizeID > 2) && order.status == 11 && order.payStatus == 1}">
-                            <a href="javascript:void(0);"
-                               onclick="modelShow('${order.orderID}')">编辑经理折扣</a>
-                        </c:if>
-                    </shiro:hasPermission>
+<%--                <a class="operation-btn">功能</a>--%>
+<%--                <div class="operation-block">--%>
+<%--                    <shiro:hasPermission name="order:order:edit">--%>
+<%--                        &lt;%&ndash;包含订单充值商品就不显示&ndash;%&gt;--%>
+<%--                        <c:if test="${empty order.rechargeGoods}">--%>
+<%--                            <c:if test="${order.status == 11 || order.status == 12 || order.status == 21 || order.status == 22 || order.status == 31 || order.status == 32}">--%>
+<%--                                <a href="${ctx}/order/toDeliveryPage?id=${order.orderID}">发货</a>--%>
+<%--                            </c:if>--%>
+<%--                            <c:if test="${order.receiptStatus == 2 && order.status != 6 && order.status != 7}">--%>
+<%--                                <a href="javascript:void(0);" onclick="collection(${order.orderID})">抹平收款</a>--%>
+<%--                            </c:if>--%>
+<%--                        </c:if>--%>
+<%--                        <c:if test="${(order.organizeID == 0 or order.organizeID > 2) && order.status == 11 && order.payStatus == 1}">--%>
+<%--                            <a href="javascript:void(0);"--%>
+<%--                               onclick="modelShow('${order.orderID}')">编辑经理折扣</a>--%>
+<%--                        </c:if>--%>
+<%--                    </shiro:hasPermission>--%>
 
 <%--                    <shiro:hasPermission name="order:order:applyrefound">--%>
 <%--                        <c:if test="${order.status == 12 || order.status == 13 || order.status == 21 || order.status == 22 || order.status == 23 || order.status == 31 || order.status == 32 || order.status == 33 || order.status == 4 || order.status == 5}">--%>
@@ -988,33 +988,33 @@
 <%--                        </c:if>--%>
 <%--                    </shiro:hasPermission>--%>
 
-                    <shiro:hasPermission name="order:order:edit">
-                        <c:if test="${order.status == 0 || order.status == 11}">
-                            <a href="${ctx}/hehe/new/order/cancelOrder?orderID=${order.orderID}"
-                               onclick="return confirmx('是否取消订单?', this.href)">取消订单</a>
-                        </c:if>
-                        <c:if test="${order.status ne 0}">
-                            <a href="${ctx}/order/printOrder?orderID=${order.orderID}">打印发货单</a>
-                        </c:if>
-                        <%--<a href="/">供应商链接</a>--%>
-                        <a href="${ctx}/order/exportOrder?id=${order.orderID}">订单导出</a>
-                        <a href="${ctx}/order/cmOrderRemark/remarksViewNew.rpc?orderID=${order.orderID}&source=1&orderType=2">订单备注</a>
-                        <%--包含订单充值商品就不显示--%>
-                        <c:if test="${empty order.rechargeGoods}">
-                            <c:if test="${order.status ne 0 && order.status ne 11 && order.status ne 21 && order.status ne 6 && order.status ne 4}">
-                                <a href="${ctx}/order/logisticsDetails?orderID=${order.orderID}&orderType=2">发货记录</a>
-                            </c:if>
-                            <c:if test="${order.status ne 0 && order.status ne 11 && order.status ne 6}">
-                                <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${order.orderID}&from=1">收退款记录
-                                </a>
-                            </c:if>
-                            <c:if test="${order.status ne 0 && order.status ne 11 && order.status ne 6}">
-                                <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRecturnRecordByOrderID.rpc?orderID=${order.orderID}">退款(退货)记录
-                                </a>
-                            </c:if>
-                        </c:if>
-                    </shiro:hasPermission>
-                </div>
+<%--                    <shiro:hasPermission name="order:order:edit">--%>
+<%--                        <c:if test="${order.status == 0 || order.status == 11}">--%>
+<%--                            <a href="${ctx}/hehe/new/order/cancelOrder?orderID=${order.orderID}"--%>
+<%--                               onclick="return confirmx('是否取消订单?', this.href)">取消订单</a>--%>
+<%--                        </c:if>--%>
+<%--                        <c:if test="${order.status ne 0}">--%>
+<%--                            <a href="${ctx}/order/printOrder?orderID=${order.orderID}">打印发货单</a>--%>
+<%--                        </c:if>--%>
+<%--                        &lt;%&ndash;<a href="/">供应商链接</a>&ndash;%&gt;--%>
+<%--                        <a href="${ctx}/order/exportOrder?id=${order.orderID}">订单导出</a>--%>
+<%--                        <a href="${ctx}/order/cmOrderRemark/remarksViewNew.rpc?orderID=${order.orderID}&source=1&orderType=2">订单备注</a>--%>
+<%--                        &lt;%&ndash;包含订单充值商品就不显示&ndash;%&gt;--%>
+<%--                        <c:if test="${empty order.rechargeGoods}">--%>
+<%--                            <c:if test="${order.status ne 0 && order.status ne 11 && order.status ne 21 && order.status ne 6 && order.status ne 4}">--%>
+<%--                                <a href="${ctx}/order/logisticsDetails?orderID=${order.orderID}&orderType=2">发货记录</a>--%>
+<%--                            </c:if>--%>
+<%--                            <c:if test="${order.status ne 0 && order.status ne 11 && order.status ne 6}">--%>
+<%--                                <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRefundRecord.rpc?orderID=${order.orderID}&from=1">收退款记录--%>
+<%--                                </a>--%>
+<%--                            </c:if>--%>
+<%--                            <c:if test="${order.status ne 0 && order.status ne 11 && order.status ne 6}">--%>
+<%--                                <a href="${ctx}/bulkpurchase/cmRefundsProduct/toRecturnRecordByOrderID.rpc?orderID=${order.orderID}">退款(退货)记录--%>
+<%--                                </a>--%>
+<%--                            </c:if>--%>
+<%--                        </c:if>--%>
+<%--                    </shiro:hasPermission>--%>
+<%--                </div>--%>
             </li>
         </ul>
     </c:forEach>

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/hehe/userActivityProductList.jsp

@@ -183,4 +183,4 @@
     }
 </script>
 </body>
-</html>
+</html>

+ 199 - 0
src/main/webapp/WEB-INF/views/modules/info/addInfoForm.jsp

@@ -0,0 +1,199 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+	<title>选择文章</title>
+	<meta name="decorator" content="default"/>
+	<style type="text/css">
+		.table td i {
+			margin: 0 2px;
+		}
+	</style>
+	<script type="text/javascript">
+		$(document).ready(function () {
+			//弹出框去滚动条
+			top.$('#jbox-content').css("overflow-y", "hidden");
+			show_title(30);
+
+			//			反选
+			$('body').on('click', 'input[name="info"]', function () {
+				var allInputLength = $('input[name="info"]').length - $('input[name="info"]:disabled').length,
+						allInputCheckedLength = $('input[name="info"]:checked').length,
+						checkAllEle = $('.check-all');
+//			    判断选中长度和总长度,如果相等就是全选否则取消全选
+				if (allInputLength === allInputCheckedLength) {
+					checkAllEle.attr('checked', true);
+				} else {
+					checkAllEle.attr('checked', false);
+				}
+			})
+		});
+
+		function page(n, s) {
+			$("#pageNo").val(n);
+			$("#pageSize").val(s);
+			$("#searchForm").submit();
+			return false;
+		}
+
+		function getCheckedItems() {
+			var items = new Array();
+			var $items = $('.check-item:checked');
+			$items.each(function () {
+				//通过拿到的商品ID组合键获取其它值
+				var productId = $(this).val();
+				items.push(productId);
+			});
+			return items;
+		}
+
+		function allCkbfun(ckb) {
+			var isChecked = ckb.checked;
+			$(".check-item").attr('checked', isChecked);
+		}
+
+		/**
+		 * @param obj
+		 * jquery控制input只能输入数字
+		 */
+		function onlynum(obj) {
+			obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+		}
+
+		/**
+		 * @param obj
+		 * jquery控制input只能输入数字和两位小数(金额)
+		 */
+		function num(obj) {
+			obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
+			obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
+			obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个, 清除多余的
+			obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
+			obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
+		}
+		var ontypeId = null;
+		var typeId = null;
+		function ischangeType() {
+			if (null != typeId) {
+				$("#typeListId option[value=" + typeId + "]").val(ontypeId);
+			}
+			$("#optionType").find("option").eq(0).prop("selected", true)
+			optionTypeParent()
+		}
+
+		function optionTypeParent() {
+			$("#optionType [parent]").each(function (item) {
+				if ($("#typeListId option:selected").val() == $(this).attr("parent")) {
+					$(this).show()
+				} else {
+					$(this).hide()
+				}
+			})
+		}
+
+		function isoptionType() {
+			if ("" != $("#optionType option:selected").val()) {
+			ontypeId =  $("#optionType option:selected").attr("parent")
+			typeId = $("#optionType option:selected").val()
+			$("#typeListId option:selected").val($("#optionType option:selected").val())
+			}else {
+				ischangeType()
+			}
+		}
+
+		$(document).ready(function () {
+			$("#typeListId option[value=" + $("#optionType option:selected").attr("parent") + "]").prop("selected", true);
+			optionTypeParent()
+			isoptionType()
+			$("input[type='radio'][name='publishSource']").change(function (obj) {
+				$("#searchForm").submit();
+			})
+		})
+
+	</script>
+</head>
+<body>
+<form:form id="searchForm" modelAttribute="info" action="${ctx}/info/info/findInfoPage" method="post"
+		   class="breadcrumb form-search">
+	<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+	<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+	<div class="ul-form">
+		<br>
+		<input type="radio" name="publishSource"
+			   value="1" ${empty info.publishSource?'checked=checked':info.publishSource eq 1?'checked=checked':''} >采美文章
+		<input type="radio" name="publishSource" value="2" ${info.publishSource eq 2?'checked=checked':''}>供应商文章
+		<br>
+		<br>
+		<label>ID:</label>
+		<form:hidden path="cmRelatedType"/>
+		<form:input path="id" htmlEscape="false" maxlength="11" class="input-mini"/>
+		<label>标题:</label>
+		<form:input path="title" htmlEscape="false" maxlength="100" class="input-medium"/>
+		<label>发布人:</label>
+		<form:input path="publisher" htmlEscape="false" maxlength="50" class="input-medium"/>
+		<label>发布时间:</label>
+		<form:input path="startPubDate" type="text" maxlength="10" class="input-medium Wdate"
+					value="${startPubDate}"
+					onclick="WdatePicker({dateFmt:'yyyy-MM-dd ',isShowClear:false});"/>
+		至
+		<form:input path="endPubDate" type="text" maxlength="10" class="input-medium Wdate"
+					value="${startPubDate}"
+					onclick="WdatePicker({dateFmt:'yyyy-MM-dd ',isShowClear:false});"/>
+		<br> <br>
+		<label>文章分类:</label>
+		<form:select id="typeListId" path="infoType.id" class="input-small" onchange="ischangeType()">
+			<form:option value="" label=" "/>
+			<c:forEach items="${typeList}" var="type" varStatus="index">
+				<c:if test="${type.parentId eq 0}">
+					<form:option value="${type.id}" label="${type.name}"/>
+				</c:if>
+			</c:forEach>
+		</form:select>
+		<form:select id="optionType" path="typeId" class="input-small" onchange="isoptionType()">
+			<form:option value="" label=" "/>
+			<c:forEach items="${typeList}" var="type" varStatus="index">
+				<c:if test="${type.parentId ne 0}">
+					<form:option value="${type.id}" label="${type.name}" parent="${type.parentId}"
+								 cssStyle="display: none"/>
+				</c:if>
+			</c:forEach>
+		</form:select>
+		&nbsp;&nbsp<input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
+		<div class="clearfix"></div>
+	</div>
+</form:form>
+<sys:message content="${message}"/>
+<table class="table table-striped table-bordered table-condensed table-hover">
+	<tr>
+		<th style="width:20px;"><input class="check-all" type="checkbox" onclick="allCkbfun(this);"/></th>
+		<th>文章ID</th>
+		<th>文章分类</th>
+		<th>引导图</th>
+		<th>发布人</th>
+		<th>文章标题</th>
+		<th>发布时间</th>
+	</tr>
+	<tbody>
+	<c:if test="${not empty page.list}">
+		<c:forEach items="${page.list}" var="item">
+			<tr id="${item.id}" class="itemtr">
+				<th>
+					<input class="check-item" type="checkbox" name="info" value='${item.id}'/>
+				</th>
+				<td>${item.id}</td>
+				<td>${item.infoType.name}</td>
+				<td><img src="${item.guidanceImage}" width="50px" height="50px"></td>
+				<td>${item.publisher}</td>
+				<td>${item.title}</td>
+				<td><fmt:formatDate value="${item.pubdate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
+			</tr>
+		</c:forEach>
+	</c:if>
+	</tbody>
+</table>
+<c:if test="${empty  page.list}">
+	<p style="text-align: center;"><font color="#1e90ff">暂无数据……</font></p>
+</c:if>
+<div class="pagination">${page}</div>
+</body>
+</html>

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott