Procházet zdrojové kódy

分销系统V.1.0.0

kaick před 1 rokem
rodič
revize
db08d45bb1
34 změnil soubory, kde provedl 1889 přidání a 69 odebrání
  1. 30 4
      src/main/java/com/caimei365/order/controller/OrderClubApi.java
  2. 5 2
      src/main/java/com/caimei365/order/controller/OrderSellerApi.java
  3. 27 6
      src/main/java/com/caimei365/order/controller/OrderSubmitApi.java
  4. 18 0
      src/main/java/com/caimei365/order/feign/UserFeign.java
  5. 5 0
      src/main/java/com/caimei365/order/mapper/BaseMapper.java
  6. 6 0
      src/main/java/com/caimei365/order/mapper/CartClubMapper.java
  7. 102 0
      src/main/java/com/caimei365/order/mapper/CmReportingClubMapper.java
  8. 91 0
      src/main/java/com/caimei365/order/mapper/CmReportingMemberMapper.java
  9. 6 0
      src/main/java/com/caimei365/order/mapper/OrderSellerMapper.java
  10. 20 0
      src/main/java/com/caimei365/order/mapper/SubmitMapper.java
  11. 9 0
      src/main/java/com/caimei365/order/model/bo/OrderParamBo.java
  12. 5 0
      src/main/java/com/caimei365/order/model/dto/SubmitDto.java
  13. 274 0
      src/main/java/com/caimei365/order/model/po/CmReportingClub.java
  14. 202 0
      src/main/java/com/caimei365/order/model/po/CmReportingMember.java
  15. 5 0
      src/main/java/com/caimei365/order/model/vo/OrderShareCodeRecordVo.java
  16. 81 0
      src/main/java/com/caimei365/order/service/CmReportingClubService.java
  17. 1 0
      src/main/java/com/caimei365/order/service/OrderClubService.java
  18. 2 2
      src/main/java/com/caimei365/order/service/OrderSellerService.java
  19. 14 8
      src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java
  20. 117 0
      src/main/java/com/caimei365/order/service/impl/CmReportingClubServiceImpl.java
  21. 67 9
      src/main/java/com/caimei365/order/service/impl/HeliPayServiceImpl.java
  22. 55 0
      src/main/java/com/caimei365/order/service/impl/OrderClubServiceImpl.java
  23. 21 11
      src/main/java/com/caimei365/order/service/impl/OrderSellerServiceImpl.java
  24. 37 1
      src/main/java/com/caimei365/order/service/impl/ShipServiceImpl.java
  25. 60 12
      src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java
  26. 2 0
      src/main/java/com/caimei365/order/utils/CodeUtil.java
  27. 5 0
      src/main/resources/bootstrap.yml
  28. 16 0
      src/main/resources/mapper/BaseMapper.xml
  29. 31 0
      src/main/resources/mapper/CartClubMapper.xml
  30. 261 0
      src/main/resources/mapper/CmReportingClubMapper.xml
  31. 231 0
      src/main/resources/mapper/CmReportingMemberMapper.xml
  32. 2 2
      src/main/resources/mapper/OrderClubMapper.xml
  33. 29 12
      src/main/resources/mapper/OrderSellerMapper.xml
  34. 52 0
      src/main/resources/mapper/SubmitMapper.xml

+ 30 - 4
src/main/java/com/caimei365/order/controller/OrderClubApi.java

@@ -1,5 +1,6 @@
 package com.caimei365.order.controller;
 package com.caimei365.order.controller;
 
 
+import com.caimei365.order.feign.UserFeign;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.OrderDto;
 import com.caimei365.order.model.dto.OrderDto;
 import com.caimei365.order.model.dto.VoucherDto;
 import com.caimei365.order.model.dto.VoucherDto;
@@ -32,6 +33,7 @@ import java.util.Map;
 public class OrderClubApi {
 public class OrderClubApi {
 
 
     private final OrderClubService orderClubService;
     private final OrderClubService orderClubService;
+    private final UserFeign userFeign;
 
 
     /**
     /**
      * 获取各状态订单数量
      * 获取各状态订单数量
@@ -161,19 +163,20 @@ public class OrderClubApi {
      */
      */
     @ApiOperation("机构取消订单(旧:/order/cancel)")
     @ApiOperation("机构取消订单(旧:/order/cancel)")
     @PostMapping("/cancel")
     @PostMapping("/cancel")
-    public ResponseJson<Void> cancelOrder(OrderDto orderDto){
+    public ResponseJson<Void> cancelOrder(OrderDto orderDto) {
         if (null == orderDto.getShopOrderId()) {
         if (null == orderDto.getShopOrderId()) {
             return ResponseJson.error("订单Id不能为空!", null);
             return ResponseJson.error("订单Id不能为空!", null);
         }
         }
         return orderClubService.cancelMainOrder(orderDto.getShopOrderId(), orderDto.getUserIdentity(), orderDto.getRemark());
         return orderClubService.cancelMainOrder(orderDto.getShopOrderId(), orderDto.getUserIdentity(), orderDto.getRemark());
     }
     }
 
 
+
     /**
     /**
      * 机构删除订单
      * 机构删除订单
      *
      *
      * @param orderDto {
      * @param orderDto {
-     *                orderId      订单ID
-     * }
+     *                 orderId      订单ID
+     *                 }
      */
      */
     @ApiOperation("机构删除订单(旧:/order/delete)")
     @ApiOperation("机构删除订单(旧:/order/delete)")
     @PostMapping("/delete")
     @PostMapping("/delete")
@@ -305,6 +308,29 @@ public class OrderClubApi {
         return orderClubService.checkOrderShareCode(userId, shopOrderId, shareCode, code, encryptedData, iv, headers);
         return orderClubService.checkOrderShareCode(userId, shopOrderId, shareCode, code, encryptedData, iv, headers);
     }
     }
 
 
+    /**
+     * 分享订单,校验分享码
+     */
+    @ApiOperation("分享订单,校验分享码(旧:/order/shareCode)")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "userId", value = "查看人身份userId"),
+            @ApiImplicitParam(required = true, name = "shopOrderId", value = "子订单Id"),
+            @ApiImplicitParam(required = false, name = "shareCode", value = "分享码"),
+    })
+    @GetMapping("/share/distributionCode/check")
+    public ResponseJson<String> checkOrderShareDistributionCode(Integer userId, Integer shopOrderId, String shareCode) {
+        if (null == userId) {
+            return ResponseJson.error("userId不能为空!", null);
+        }
+        if (null == shopOrderId) {
+            return ResponseJson.error("订单Id不能为空!", null);
+        }
+        if (StringUtils.isEmpty(shareCode)) {
+            return ResponseJson.error("分享码不能为空!", null);
+        }
+        return orderClubService.checkOrderShareCode(userId, shopOrderId, shareCode);
+    }
+
 
 
     /**
     /**
      * 分享订单,初始商品数据
      * 分享订单,初始商品数据
@@ -312,7 +338,7 @@ public class OrderClubApi {
     @ApiOperation("分享订单,初始商品数据(旧:/order/commodityData)")
     @ApiOperation("分享订单,初始商品数据(旧:/order/commodityData)")
     @ApiImplicitParam(required = true, name = "shopOrderId", value = "订单Id")
     @ApiImplicitParam(required = true, name = "shopOrderId", value = "订单Id")
     @GetMapping("/share/product")
     @GetMapping("/share/product")
-    public ResponseJson<Map<String,Object>> getOrderShareInitProduct(Integer shopOrderId) {
+    public ResponseJson<Map<String, Object>> getOrderShareInitProduct(Integer shopOrderId) {
         if (null == shopOrderId) {
         if (null == shopOrderId) {
             return ResponseJson.error("订单Id不能为空!", null);
             return ResponseJson.error("订单Id不能为空!", null);
         }
         }

+ 5 - 2
src/main/java/com/caimei365/order/controller/OrderSellerApi.java

@@ -51,6 +51,7 @@ public class OrderSellerApi {
     @ApiImplicitParams({
     @ApiImplicitParams({
             @ApiImplicitParam(required = true, name = "serviceProviderId", value = "协销Id"),
             @ApiImplicitParam(required = true, name = "serviceProviderId", value = "协销Id"),
             @ApiImplicitParam(required = false, name = "listType", value = "1:待确认,2:待付款,3:待发货,4:已发货,5:退货款"),
             @ApiImplicitParam(required = false, name = "listType", value = "1:待确认,2:待付款,3:待发货,4:已发货,5:退货款"),
+            @ApiImplicitParam(required = false, name = "type", value = "null:协销,2:分销人员"),
             @ApiImplicitParam(required = false, name = "shopOrderNo", value = "订单编号"),
             @ApiImplicitParam(required = false, name = "shopOrderNo", value = "订单编号"),
             @ApiImplicitParam(required = false, name = "orderSubmitType", value = "1:自主订单, 2:协销或后台订单,3:组员订单"),
             @ApiImplicitParam(required = false, name = "orderSubmitType", value = "1:自主订单, 2:协销或后台订单,3:组员订单"),
             @ApiImplicitParam(required = false, name = "groupServiceId", value = "组员协销id"),
             @ApiImplicitParam(required = false, name = "groupServiceId", value = "组员协销id"),
@@ -60,12 +61,13 @@ public class OrderSellerApi {
     @GetMapping("/list")
     @GetMapping("/list")
     public ResponseJson<PageInfo<ShopOrderVo>> getOrderList(Integer serviceProviderId, Integer listType, Integer orderSubmitType,
     public ResponseJson<PageInfo<ShopOrderVo>> getOrderList(Integer serviceProviderId, Integer listType, Integer orderSubmitType,
                                                             String shopOrderNo, Integer groupServiceId,
                                                             String shopOrderNo, Integer groupServiceId,
+                                                            @RequestParam(required = false) Integer type,
                                                             @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                             @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                             @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
                                                             @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
         if (null == serviceProviderId) {
         if (null == serviceProviderId) {
             return ResponseJson.error("协销Id不能为空!", null);
             return ResponseJson.error("协销Id不能为空!", null);
         }
         }
-        return orderSellerService.getOrderList(serviceProviderId, listType, orderSubmitType, shopOrderNo, groupServiceId, pageNum, pageSize);
+        return orderSellerService.getOrderList(serviceProviderId,type, listType, orderSubmitType, shopOrderNo, groupServiceId, pageNum, pageSize);
     }
     }
 
 
     /**
     /**
@@ -82,6 +84,7 @@ public class OrderSellerApi {
     })
     })
     @GetMapping("/list/club")
     @GetMapping("/list/club")
     public ResponseJson<PageInfo<ShopOrderVo>> getOrderListClub(Integer serviceProviderId, Integer clubId, Integer listType, Integer orderSubmitType,
     public ResponseJson<PageInfo<ShopOrderVo>> getOrderListClub(Integer serviceProviderId, Integer clubId, Integer listType, Integer orderSubmitType,
+                                                                @RequestParam(required = false) Integer type,
                                                             @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                             @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
                                                             @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
                                                             @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
         if (null == serviceProviderId) {
         if (null == serviceProviderId) {
@@ -90,7 +93,7 @@ public class OrderSellerApi {
         if (null == clubId) {
         if (null == clubId) {
             return ResponseJson.error("机构Id不能为空!", null);
             return ResponseJson.error("机构Id不能为空!", null);
         }
         }
-        return orderSellerService.getOrderListClub(serviceProviderId, clubId, listType, orderSubmitType, pageNum, pageSize);
+        return orderSellerService.getOrderListClub(serviceProviderId, clubId, listType, orderSubmitType,type, pageNum, pageSize);
     }
     }
 
 
     /**
     /**

+ 27 - 6
src/main/java/com/caimei365/order/controller/OrderSubmitApi.java

@@ -1,19 +1,20 @@
 package com.caimei365.order.controller;
 package com.caimei365.order.controller;
 
 
+import com.caimei365.order.feign.UserFeign;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.OrderProductDto;
 import com.caimei365.order.model.dto.OrderProductDto;
 import com.caimei365.order.model.dto.RechargeDto;
 import com.caimei365.order.model.dto.RechargeDto;
 import com.caimei365.order.model.dto.SubmitDto;
 import com.caimei365.order.model.dto.SubmitDto;
+import com.caimei365.order.model.po.CmReportingClub;
+import com.caimei365.order.service.CmReportingClubService;
 import com.caimei365.order.service.SubmitService;
 import com.caimei365.order.service.SubmitService;
 import com.caimei365.order.utils.MathUtil;
 import com.caimei365.order.utils.MathUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.http.HttpHeaders;
+import org.springframework.web.bind.annotation.*;
 
 
 import java.util.Map;
 import java.util.Map;
 
 
@@ -30,6 +31,8 @@ import java.util.Map;
 @RequestMapping("/order/submit")
 @RequestMapping("/order/submit")
 public class OrderSubmitApi {
 public class OrderSubmitApi {
     private final SubmitService submitService;
     private final SubmitService submitService;
+    private final UserFeign userFeign;
+    private final CmReportingClubService cmReportingClubService;
 
 
     /**
     /**
      * 生成订单
      * 生成订单
@@ -92,8 +95,8 @@ public class OrderSubmitApi {
         if (null == submitDto.getOrderSource()) {
         if (null == submitDto.getOrderSource()) {
             return ResponseJson.error("订单来源不能为空!", null);
             return ResponseJson.error("订单来源不能为空!", null);
         }
         }
-        // 1,www来源    2,crm来源    6,小程序来源
-        if (null == submitDto.getOrderSource() || !(1 == submitDto.getOrderSource() || 2 == submitDto.getOrderSource() || 6 == submitDto.getOrderSource())) {
+        // 1,www来源    2,crm来源    6,小程序来源  ,9分销系统来源
+        if (null == submitDto.getOrderSource() || !(1 == submitDto.getOrderSource() || 2 == submitDto.getOrderSource() || 6 == submitDto.getOrderSource() || 9 == submitDto.getOrderSource())) {
             return ResponseJson.error("订单来源异常!", null);
             return ResponseJson.error("订单来源异常!", null);
         }
         }
         if (null == submitDto.getCartType()) {
         if (null == submitDto.getCartType()) {
@@ -120,6 +123,24 @@ public class OrderSubmitApi {
         return submitService.generateOrder(submitDto);
         return submitService.generateOrder(submitDto);
     }
     }
 
 
+    @ApiOperation("分销人员提交订单(旧:/order/submit)(/seller/order/submit)")
+    @PostMapping("/distributionGenerate")
+    public ResponseJson distributionGenerateOrder(SubmitDto submitDto, @RequestParam String clubReportingId, @RequestHeader HttpHeaders headers) {
+        CmReportingClub cmReportingClubById = cmReportingClubService.getCmReportingClubById(clubReportingId);
+        if (null==cmReportingClubById) {
+            return ResponseJson.error("报备机构记录异常!", null);
+        }
+        ResponseJson responseJson = userFeign.distributionClubRegister(cmReportingClubById.clubName(), cmReportingClubById.linkMan(), cmReportingClubById.mobile(),submitDto.getServiceProviderId(), headers);
+        if (responseJson.getCode() != 0) {
+            return responseJson;
+        }
+        submitDto.setClubId(Integer.valueOf(responseJson.getMsg()));
+        submitDto.setClubReportingId(clubReportingId);
+        submitDto.setCartType(3);
+        submitDto.setOrderSource(9);
+        return generateOrder(submitDto);
+    }
+
     /**
     /**
      * 生成充值商品订单
      * 生成充值商品订单
      *
      *

+ 18 - 0
src/main/java/com/caimei365/order/feign/UserFeign.java

@@ -1,6 +1,9 @@
 package com.caimei365.order.feign;
 package com.caimei365.order.feign;
 
 
+import com.caimei365.order.model.ResponseJson;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.HttpHeaders;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -37,4 +40,19 @@ public interface UserFeign {
      */
      */
     @PostMapping("/user/login/auth/appletsOrganize")
     @PostMapping("/user/login/auth/appletsOrganize")
     String appletsOrganizeAuthorization(@RequestParam String code, @RequestParam String encryptedData, @RequestParam String iv, @RequestHeader("Referer") String referer);
     String appletsOrganizeAuthorization(@RequestParam String code, @RequestParam String encryptedData, @RequestParam String iv, @RequestHeader("Referer") String referer);
+
+    /**
+     * 功能描述: 分销人员生成特殊机构(注册)
+     *
+     * @param name
+     * @param userName
+     * @param bindMobile
+     * @param headers
+     * @return [name, userName, bindMobile, headers]
+     * @auther: Kaick
+     * @date: 2023/10/10 12:00
+     */
+    @PostMapping("/user/register/distributionClub")
+    ResponseJson distributionClubRegister(@RequestParam String name, @RequestParam String userName, @RequestParam String bindMobile,@RequestParam Integer spId, @RequestHeader HttpHeaders headers);
+
 }
 }

+ 5 - 0
src/main/java/com/caimei365/order/mapper/BaseMapper.java

@@ -83,6 +83,11 @@ public interface BaseMapper {
      */
      */
     Integer getIdentityByUserId(Integer userId);
     Integer getIdentityByUserId(Integer userId);
 
 
+    /**
+     * 根据用户Id查询用户身份
+     */
+    Integer getUserIdentity(@Param("userId") Integer userId,@Param("orderId")Integer orderId,@Param("shopOrderId")Integer shopOrderId);
+
     /**
     /**
      * 根据用户Id查询公司名
      * 根据用户Id查询公司名
      */
      */

+ 6 - 0
src/main/java/com/caimei365/order/mapper/CartClubMapper.java

@@ -148,6 +148,12 @@ public interface CartClubMapper {
      * @return
      * @return
      */
      */
     CartItemVo getCartOrganizeProductId(Integer skuId);
     CartItemVo getCartOrganizeProductId(Integer skuId);
+    /**
+     * 根据skuId获取下单商品信息 -- 分销人员
+     * @param skuId
+     * @return
+     */
+    CartItemVo getDistributionProductId(Integer skuId);
 
 
     List<Integer> findVipCoupon();
     List<Integer> findVipCoupon();
     /**
     /**

+ 102 - 0
src/main/java/com/caimei365/order/mapper/CmReportingClubMapper.java

@@ -0,0 +1,102 @@
+package com.caimei365.order.mapper;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+import com.caimei365.order.model.po.CmReportingClub;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 机构报备Mapper接口
+ *
+ * @author Kaick
+ * @date 2023-10-11
+ */
+@Mapper
+public interface CmReportingClubMapper
+{
+    /**
+     * 通过对象查询机构报备列表
+     *
+     * @param cmReportingClub 机构报备
+     * @return 机构报备集合
+     */
+    public List<CmReportingClub> getCmReportingClubList(CmReportingClub cmReportingClub);
+
+    /**
+     * 通过Id查询机构报备对象
+     *
+     * @param id 机构报备主键
+     * @return 机构报备
+     */
+    public CmReportingClub getCmReportingClubById(String id);
+
+    /**
+     * 通过对象查询机构报备对象
+     *
+     * @param cmReportingClub 机构报备
+     * @return 机构报备
+     */
+    public CmReportingClub getByCmReportingClub(CmReportingClub cmReportingClub);
+
+    /**
+     * 通过对象查询机构报备Id
+     *
+     * @param cmReportingClub 机构报备
+     * @return String
+     */
+    public String getById(CmReportingClub cmReportingClub);
+
+
+    /**
+     * 通过对象查询机构报备记录总数
+     *
+     * @param cmReportingClub 机构报备
+     * @return 机构报备Integer
+     */
+    public Integer getCmReportingClubCount(CmReportingClub cmReportingClub);
+
+    /**
+     * 新增机构报备
+     *
+     * @param cmReportingClub 机构报备
+     * @return 结果
+     */
+    public int addCmReportingClub(CmReportingClub cmReportingClub);
+
+    /**
+     * 修改机构报备
+     *
+     * @param cmReportingClub 机构报备
+     * @return 结果
+     */
+    public int updateCmReportingClub(CmReportingClub cmReportingClub);
+
+    /**
+     * 删除机构报备
+     *
+     * @param id 机构报备主键
+     * @return 结果
+     */
+    public int delCmReportingClubById(String id);
+
+    /**
+     * 批量删除机构报备
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int delCmReportingClub(CmReportingClub cmReportingClub);
+
+    /**
+     * 机构报备商品佣金
+     */
+    public BigDecimal getDistributionProductCommission(Integer productId);
+
+    /**
+     * 分销团队分账号
+     */
+    public String getDistributionSplitCode(Integer id);
+
+}

+ 91 - 0
src/main/java/com/caimei365/order/mapper/CmReportingMemberMapper.java

@@ -0,0 +1,91 @@
+package com.caimei365.order.mapper;
+
+import java.util.List;
+
+import com.caimei365.order.model.po.CmReportingMember;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 分销报备成员Mapper接口
+ *
+ * @author Kaick
+ * @date 2023-10-11
+ */
+@Mapper
+public interface CmReportingMemberMapper
+{
+    /**
+     * 通过对象查询分销报备成员列表
+     *
+     * @param cmReportingMember 分销报备成员
+     * @return 分销报备成员集合
+     */
+    public List<CmReportingMember> getCmReportingMemberList(CmReportingMember cmReportingMember);
+
+    /**
+     * 通过Id查询分销报备成员对象
+     *
+     * @param id 分销报备成员主键
+     * @return 分销报备成员
+     */
+    public CmReportingMember getCmReportingMemberById(String id);
+
+    /**
+     * 通过对象查询分销报备成员对象
+     *
+     * @param cmReportingMember 分销报备成员
+     * @return 分销报备成员
+     */
+    public CmReportingMember getByCmReportingMember(CmReportingMember cmReportingMember);
+
+    /**
+     * 通过对象查询分销报备成员Id
+     *
+     * @param cmReportingMember 分销报备成员
+     * @return String
+     */
+    public String getById(CmReportingMember cmReportingMember);
+
+
+    /**
+     * 通过对象查询分销报备成员记录总数
+     *
+     * @param cmReportingMember 分销报备成员
+     * @return 分销报备成员Integer
+     */
+    public Integer getCmReportingMemberCount(CmReportingMember cmReportingMember);
+
+    /**
+     * 新增分销报备成员
+     *
+     * @param cmReportingMember 分销报备成员
+     * @return 结果
+     */
+    public int addCmReportingMember(CmReportingMember cmReportingMember);
+
+    /**
+     * 修改分销报备成员
+     *
+     * @param cmReportingMember 分销报备成员
+     * @return 结果
+     */
+    public int updateCmReportingMember(CmReportingMember cmReportingMember);
+
+    /**
+     * 删除分销报备成员
+     *
+     * @param id 分销报备成员主键
+     * @return 结果
+     */
+    public int delCmReportingMemberById(String id);
+
+    /**
+     * 批量删除分销报备成员
+     *
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int delCmReportingMember(CmReportingMember cmReportingMember);
+
+}

+ 6 - 0
src/main/java/com/caimei365/order/mapper/OrderSellerMapper.java

@@ -16,6 +16,12 @@ import java.util.List;
  */
  */
 @Mapper
 @Mapper
 public interface OrderSellerMapper {
 public interface OrderSellerMapper {
+
+    /**
+     * 获取该分销人员下的机构用户Id
+     */
+    List<Integer> getDistributionClubUserIds(@Param("id")Integer id,@Param("parentId")Integer parentId);
+
     /**
     /**
      * 获取该协销下的机构用户Id
      * 获取该协销下的机构用户Id
      * @param serviceProviderId 协销Id
      * @param serviceProviderId 协销Id

+ 20 - 0
src/main/java/com/caimei365/order/mapper/SubmitMapper.java

@@ -39,12 +39,25 @@ public interface SubmitMapper {
      */
      */
     Integer getServiceProviderUserId(Integer serviceProviderId);
     Integer getServiceProviderUserId(Integer serviceProviderId);
 
 
+    /**
+     * 获取分销人员用户Id
+     *
+     */
+    Integer getDistributionUserId(Integer id);
+
     /**
     /**
      * 获取数据库商品信息
      * 获取数据库商品信息
      *
      *
      * @param skuId     skuId
      * @param skuId     skuId
      */
      */
     OrderProductPo getProductDetails(Integer skuId);
     OrderProductPo getProductDetails(Integer skuId);
+
+    /**
+     * 获取数据库商品信息
+     *
+     * @param skuId     skuId
+     */
+    OrderProductPo getDistributionProductDetails(Integer skuId);
     /**
     /**
      * 获取数据库商品信息 --组织
      * 获取数据库商品信息 --组织
      *
      *
@@ -119,6 +132,13 @@ public interface SubmitMapper {
      * @return
      * @return
      */
      */
     CmOrganizeSkuPo getOrganizeSkuInfo(@Param("skuId") Integer skuId, @Param("organizeId") Integer organizeId);
     CmOrganizeSkuPo getOrganizeSkuInfo(@Param("skuId") Integer skuId, @Param("organizeId") Integer organizeId);
+
+    /**
+     * 外部商城sku信息
+     * @param skuId
+     * @return
+     */
+    CmOrganizeSkuPo getDistributionSkuInfo(@Param("skuId") Integer skuId, @Param("organizeId") Integer organizeId);
     /**
     /**
      * 查询订单增值税发票
      * 查询订单增值税发票
      */
      */

+ 9 - 0
src/main/java/com/caimei365/order/model/bo/OrderParamBo.java

@@ -29,6 +29,10 @@ public class OrderParamBo implements Serializable {
      * 机构id
      * 机构id
      */
      */
     private Integer clubId;
     private Integer clubId;
+    /**
+     * 报备机构id
+     */
+    private String clubReportingId;
     /**
     /**
      * 组织Id  采美默认为0
      * 组织Id  采美默认为0
      */
      */
@@ -138,4 +142,9 @@ public class OrderParamBo implements Serializable {
      * 是否勾选冷链费
      * 是否勾选冷链费
      */
      */
     private Integer isColdChain;
     private Integer isColdChain;
+
+    /**
+     * 用户身份 0、个人 1、协销 2、会员机构 3、供应商 4.普通机构 6、呵呵商城用户 7、分销人员 8、分销人员生成机构 【V6.2.0版本后0不存在】
+     */
+    private Integer userIdentity;
 }
 }

+ 5 - 0
src/main/java/com/caimei365/order/model/dto/SubmitDto.java

@@ -49,6 +49,11 @@ public class SubmitDto implements Serializable {
      */
      */
     @ApiModelProperty("协销Id")
     @ApiModelProperty("协销Id")
     private Integer serviceProviderId;
     private Integer serviceProviderId;
+    /**
+     * 报备机构ID
+     */
+    @ApiModelProperty("报备机构ID")
+    private String clubReportingId;
     /**
     /**
      * 优惠券Id
      * 优惠券Id
      */
      */

+ 274 - 0
src/main/java/com/caimei365/order/model/po/CmReportingClub.java

@@ -0,0 +1,274 @@
+package com.caimei365.order.model.po;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.apache.ibatis.type.Alias;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import java.util.Date;
+/**
+ * 机构报备对象 cm_reporting_club
+ *
+ * @author Kaick
+ * @date 2023-10-12
+ */
+@Accessors(fluent  = true )
+@Data
+@Alias("CmReportingClub")
+public class CmReportingClub implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+    private String id;
+
+    /** 机构名称 */
+    private String clubName;
+
+    /** 联系人 */
+    private String linkMan;
+
+    /** 手机号 */
+    private String mobile;
+
+    /** 商品id */
+    private Integer productId;
+
+    /** 订单id */
+    private Integer orderId;
+
+    /** 订单状态 :1已成交,0未成交 */
+    private Integer orderStatus;
+
+    /** 锁定状态 :1锁定,0未锁定 */
+    private Integer lockStatus;
+
+    /** 锁定时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date lockTime;
+
+    /** 分销报备锁定人id */
+    private Integer distributionId;
+
+    /** 删除状态 0正常,其他删除 */
+    private Integer delFlag;
+
+    /** 修改时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    /** 添加时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /** 商品总佣金 */
+    private BigDecimal commission;
+
+    /** 结算状态: 1已完结 ,0未完结 */
+    private Integer settleStatus;
+
+    /** 结算时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date settleTime;
+
+    /** 已付商品总佣金 */
+    private BigDecimal paidCommission;
+
+    /** 分账结算状态: 0待确认 1待手动分账 ,2待手动结算,3已结算 */
+    private Integer splitSettleStatus;
+
+    /** 分账结算时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date splitSsettleTime;
+
+    /** 分账号 */
+    private String splitCode;
+
+    public void setId(String  id)
+    {
+        this.id = id;
+    }
+
+    public String  getId()
+    {
+        return id;
+    }
+    public void setClubName(String  clubName)
+    {
+        this.clubName = clubName;
+    }
+
+    public String  getClubName()
+    {
+        return clubName;
+    }
+    public void setLinkMan(String  linkMan)
+    {
+        this.linkMan = linkMan;
+    }
+
+    public String  getLinkMan()
+    {
+        return linkMan;
+    }
+    public void setMobile(String  mobile)
+    {
+        this.mobile = mobile;
+    }
+
+    public String  getMobile()
+    {
+        return mobile;
+    }
+    public void setProductId(Integer  productId)
+    {
+        this.productId = productId;
+    }
+
+    public Integer  getProductId()
+    {
+        return productId;
+    }
+    public void setOrderId(Integer  orderId)
+    {
+        this.orderId = orderId;
+    }
+
+    public Integer  getOrderId()
+    {
+        return orderId;
+    }
+    public void setOrderStatus(Integer  orderStatus)
+    {
+        this.orderStatus = orderStatus;
+    }
+
+    public Integer  getOrderStatus()
+    {
+        return orderStatus;
+    }
+    public void setLockStatus(Integer  lockStatus)
+    {
+        this.lockStatus = lockStatus;
+    }
+
+    public Integer  getLockStatus()
+    {
+        return lockStatus;
+    }
+    public void setLockTime(Date  lockTime)
+    {
+        this.lockTime = lockTime;
+    }
+
+    public Date  getLockTime()
+    {
+        return lockTime;
+    }
+    public void setDistributionId(Integer  distributionId)
+    {
+        this.distributionId = distributionId;
+    }
+
+    public Integer  getDistributionId()
+    {
+        return distributionId;
+    }
+    public void setDelFlag(Integer  delFlag)
+    {
+        this.delFlag = delFlag;
+    }
+
+    public Integer  getDelFlag()
+    {
+        return delFlag;
+    }
+    public void setUpdateTime(Date  updateTime)
+    {
+        this.updateTime = updateTime;
+    }
+
+    public Date  getUpdateTime()
+    {
+        return updateTime;
+    }
+    public void setCreateTime(Date  createTime)
+    {
+        this.createTime = createTime;
+    }
+
+    public Date  getCreateTime()
+    {
+        return createTime;
+    }
+    public void setCommission(BigDecimal  commission)
+    {
+        this.commission = commission;
+    }
+
+    public BigDecimal  getCommission()
+    {
+        return commission;
+    }
+    public void setSettleStatus(Integer  settleStatus)
+    {
+        this.settleStatus = settleStatus;
+    }
+
+    public Integer  getSettleStatus()
+    {
+        return settleStatus;
+    }
+    public void setSettleTime(Date  settleTime)
+    {
+        this.settleTime = settleTime;
+    }
+
+    public Date  getSettleTime()
+    {
+        return settleTime;
+    }
+    public void setPaidCommission(BigDecimal  paidCommission)
+    {
+        this.paidCommission = paidCommission;
+    }
+
+    public BigDecimal  getPaidCommission()
+    {
+        return paidCommission;
+    }
+    public void setSplitSettleStatus(Integer  splitSettleStatus)
+    {
+        this.splitSettleStatus = splitSettleStatus;
+    }
+
+    public Integer  getSplitSettleStatus()
+    {
+        return splitSettleStatus;
+    }
+    public void setSplitSsettleTime(Date  splitSsettleTime)
+    {
+        this.splitSsettleTime = splitSsettleTime;
+    }
+
+    public Date  getSplitSsettleTime()
+    {
+        return splitSsettleTime;
+    }
+    public void setSplitCode(String  splitCode)
+    {
+        this.splitCode = splitCode;
+    }
+
+    public String  getSplitCode()
+    {
+        return splitCode;
+    }
+
+}
+

+ 202 - 0
src/main/java/com/caimei365/order/model/po/CmReportingMember.java

@@ -0,0 +1,202 @@
+package com.caimei365.order.model.po;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import org.apache.ibatis.type.Alias;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import java.util.Date;
+
+/**
+ * 分销报备成员对象 cm_reporting_member
+ *
+ * @author Kaick
+ * @date 2023-10-11
+ */
+@Accessors(fluent  = true )
+@Data
+@Alias("CmReportingMember")
+public class CmReportingMember implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** id */
+    private String id;
+
+    /** 分销报备人id */
+    private Integer distributionId;
+
+    /** 报备机构id */
+    private Integer clubReportingId;
+
+    /** 审核状态:1待审核,2审核通过,3审核失败 */
+    private Integer auditStatus;
+
+    /** 审核备注 */
+    private String auditText;
+
+    /** 审核人用户id */
+    private Integer auditBy;
+
+    /** 审核时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date auditTime;
+
+    /** 删除状态 0正常,其他删除 */
+    private Integer delFlag;
+
+    /** 修改时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+    /** 添加时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /** 备注 */
+    private String remarks;
+
+    /** 商品佣金 */
+    private BigDecimal commission;
+
+    /** 结算状态: 1待确认 ,2待结算 ,3已结算 */
+    private Integer settleStatus;
+
+    /** 结算时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date settleTime;
+
+    public void setId(String  id)
+    {
+        this.id = id;
+    }
+
+    public String  getId()
+    {
+        return id;
+    }
+    public void setDistributionId(Integer  distributionId)
+    {
+        this.distributionId = distributionId;
+    }
+
+    public Integer  getDistributionId()
+    {
+        return distributionId;
+    }
+    public void setClubReportingId(Integer  clubReportingId)
+    {
+        this.clubReportingId = clubReportingId;
+    }
+
+    public Integer  getClubReportingId()
+    {
+        return clubReportingId;
+    }
+    public void setAuditStatus(Integer  auditStatus)
+    {
+        this.auditStatus = auditStatus;
+    }
+
+    public Integer  getAuditStatus()
+    {
+        return auditStatus;
+    }
+    public void setAuditText(String  auditText)
+    {
+        this.auditText = auditText;
+    }
+
+    public String  getAuditText()
+    {
+        return auditText;
+    }
+    public void setAuditBy(Integer  auditBy)
+    {
+        this.auditBy = auditBy;
+    }
+
+    public Integer  getAuditBy()
+    {
+        return auditBy;
+    }
+    public void setAuditTime(Date  auditTime)
+    {
+        this.auditTime = auditTime;
+    }
+
+    public Date  getAuditTime()
+    {
+        return auditTime;
+    }
+    public void setDelFlag(Integer  delFlag)
+    {
+        this.delFlag = delFlag;
+    }
+
+    public Integer  getDelFlag()
+    {
+        return delFlag;
+    }
+    public void setUpdateTime(Date  updateTime)
+    {
+        this.updateTime = updateTime;
+    }
+
+    public Date  getUpdateTime()
+    {
+        return updateTime;
+    }
+    public void setCreateTime(Date  createTime)
+    {
+        this.createTime = createTime;
+    }
+
+    public Date  getCreateTime()
+    {
+        return createTime;
+    }
+    public void setRemarks(String  remarks)
+    {
+        this.remarks = remarks;
+    }
+
+    public String  getRemarks()
+    {
+        return remarks;
+    }
+    public void setCommission(BigDecimal  commission)
+    {
+        this.commission = commission;
+    }
+
+    public BigDecimal  getCommission()
+    {
+        return commission;
+    }
+    public void setSettleStatus(Integer  settleStatus)
+    {
+        this.settleStatus = settleStatus;
+    }
+
+    public Integer  getSettleStatus()
+    {
+        return settleStatus;
+    }
+    public void setSettleTime(Date  settleTime)
+    {
+        this.settleTime = settleTime;
+    }
+
+    public Date  getSettleTime()
+    {
+        return settleTime;
+    }
+
+}
+

+ 5 - 0
src/main/java/com/caimei365/order/model/vo/OrderShareCodeRecordVo.java

@@ -16,6 +16,11 @@ public class OrderShareCodeRecordVo implements Serializable {
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 
 
     private Integer id;
     private Integer id;
+
+    /**
+     * 使用分享码人的userId,方便码有效期内再次查看
+     */
+    private Integer userId;
     /**
     /**
      * 使用分享码人的openid,方便码有效期内再次查看
      * 使用分享码人的openid,方便码有效期内再次查看
      */
      */

+ 81 - 0
src/main/java/com/caimei365/order/service/CmReportingClubService.java

@@ -0,0 +1,81 @@
+package com.caimei365.order.service;
+
+import com.caimei365.order.model.po.CmReportingClub;
+
+import java.util.List;
+
+/**
+ * 机构报备Service接口
+ *
+ * @author Kaick
+ * @date 2023-10-11
+ */
+public interface CmReportingClubService
+{
+    /**
+     * 通过对象查询机构报备列表
+     *
+     * @param cmReportingClub 机构报备
+     * @return 机构报备集合
+     */
+    public List<CmReportingClub> getCmReportingClubList(CmReportingClub cmReportingClub);
+
+    /**
+     * 通过Id查询机构报备
+     *
+     * @param id 机构报备主键
+     * @return 机构报备
+     */
+    public CmReportingClub getCmReportingClubById(String id);
+
+    /**
+     * 通过对象查询机构报备
+     *
+     * @param cmReportingClub 机构报备
+     * @return 机构报备
+     */
+    public CmReportingClub getByCmReportingClub(CmReportingClub cmReportingClub);
+
+    /**
+     * 通过对象查询机构报备Id
+     *
+     * @param cmReportingClub 机构报备主键
+     * @return String
+     */
+    public String getById(CmReportingClub cmReportingClub);
+
+
+    /**
+     * 通过对象查询机构报备记录总数
+     *
+     * @param cmReportingClub 机构报备
+     * @return 机构报备Integer
+     */
+    public int getCmReportingClubCount(CmReportingClub cmReportingClub);
+
+    /**
+     * 新增机构报备
+     *
+     * @param cmReportingClub 机构报备
+     * @return 结果
+     */
+    public int addCmReportingClub(CmReportingClub cmReportingClub);
+
+    /**
+     * 修改机构报备
+     *
+     * @param cmReportingClub 机构报备
+     * @return 结果
+     */
+    public int updateCmReportingClub(CmReportingClub cmReportingClub);
+
+    /**
+     * 删除机构报备信息
+     *
+     * @param id 机构报备主键
+     * @return 结果
+     */
+    public int delCmReportingClubById(String id);
+
+}
+

+ 1 - 0
src/main/java/com/caimei365/order/service/OrderClubService.java

@@ -124,6 +124,7 @@ public interface OrderClubService {
      * @param headers HttpHeaders
      * @param headers HttpHeaders
      */
      */
     ResponseJson<String> checkOrderShareCode(Integer userId, Integer shopOrderId, String shareCode, String code, String encryptedData, String iv, HttpHeaders headers);
     ResponseJson<String> checkOrderShareCode(Integer userId, Integer shopOrderId, String shareCode, String code, String encryptedData, String iv, HttpHeaders headers);
+    ResponseJson<String> checkOrderShareCode(Integer userId, Integer shopOrderId, String shareCode);
     /**
     /**
      * 分享订单,初始商品数据
      * 分享订单,初始商品数据
      * @param shopOrderId 订单Id
      * @param shopOrderId 订单Id

+ 2 - 2
src/main/java/com/caimei365/order/service/OrderSellerService.java

@@ -23,7 +23,7 @@ public interface OrderSellerService {
      * @param pageNum    页码
      * @param pageNum    页码
      * @param pageSize   每页数量
      * @param pageSize   每页数量
      */
      */
-    ResponseJson<PageInfo<ShopOrderVo>> getOrderList(Integer serviceProviderId, Integer listType, Integer orderSubmitType, String shopOrderNo, Integer groupServiceId, int pageNum, int pageSize);
+    ResponseJson<PageInfo<ShopOrderVo>> getOrderList(Integer serviceProviderId,Integer type, Integer listType, Integer orderSubmitType, String shopOrderNo, Integer groupServiceId, int pageNum, int pageSize);
 
 
     /**
     /**
      * 协销下机构总订单列表
      * 协销下机构总订单列表
@@ -34,7 +34,7 @@ public interface OrderSellerService {
      * @param pageNum    页码
      * @param pageNum    页码
      * @param pageSize   每页数量
      * @param pageSize   每页数量
      */
      */
-    ResponseJson<PageInfo<ShopOrderVo>> getOrderListClub(Integer serviceProviderId, Integer clubId, Integer listType, Integer orderSubmitType, int pageNum, int pageSize);
+    ResponseJson<PageInfo<ShopOrderVo>> getOrderListClub(Integer serviceProviderId, Integer clubId, Integer listType, Integer orderSubmitType, Integer type,int pageNum, int pageSize);
 
 
     /**
     /**
      * 协销根据关键词搜索订单
      * 协销根据关键词搜索订单

+ 14 - 8
src/main/java/com/caimei365/order/service/impl/CartClubServiceImpl.java

@@ -1876,6 +1876,11 @@ public class CartClubServiceImpl implements CartClubService {
         log.info("¥¥¥¥¥¥¥¥¥¥ > 立即购买");
         log.info("¥¥¥¥¥¥¥¥¥¥ > 立即购买");
         // 用户组织Id
         // 用户组织Id
         Integer organizeId = baseMapper.getOrganizeId(cartDto.getUserId());
         Integer organizeId = baseMapper.getOrganizeId(cartDto.getUserId());
+        // 用户身份
+        Integer userIdentity = baseMapper.getIdentityByUserId(cartDto.getUserId());
+        if (null == userIdentity) {
+            userIdentity = 0;
+        }
         // 供应商信息
         // 供应商信息
         CartShopVo shop = baseMapper.getShopByProductId(cartDto.getProductId());
         CartShopVo shop = baseMapper.getShopByProductId(cartDto.getProductId());
         if (null == shop) {
         if (null == shop) {
@@ -1883,7 +1888,12 @@ public class CartClubServiceImpl implements CartClubService {
         }
         }
         CartItemVo cartItemVo = null;
         CartItemVo cartItemVo = null;
         if (0 == organizeId) {
         if (0 == organizeId) {
-            cartItemVo = cartClubMapper.getCartItemByProductId(cartDto.getSkuId());
+            if(userIdentity==7){
+                //分销人员sku
+                cartItemVo = cartClubMapper.getDistributionProductId(cartDto.getSkuId());
+            }else {
+                cartItemVo = cartClubMapper.getCartItemByProductId(cartDto.getSkuId());
+            }
         } else {
         } else {
             cartItemVo = cartClubMapper.getCartOrganizeProductId(cartDto.getSkuId());
             cartItemVo = cartClubMapper.getCartOrganizeProductId(cartDto.getSkuId());
         }
         }
@@ -1896,11 +1906,7 @@ public class CartClubServiceImpl implements CartClubService {
                 cartItemVo.setHelpContent(helpContent);
                 cartItemVo.setHelpContent(helpContent);
             }
             }
         }
         }
-        // 用户身份
-        Integer userIdentity = baseMapper.getIdentityByUserId(cartDto.getUserId());
-        if (null == userIdentity) {
-            userIdentity = 0;
-        }
+
         // 会员机构类型:1医美,2生美
         // 会员机构类型:1医美,2生美
         Integer userClubType = 0;
         Integer userClubType = 0;
         if (userIdentity == 2) {
         if (userIdentity == 2) {
@@ -1912,7 +1918,7 @@ public class CartClubServiceImpl implements CartClubService {
         // 超级会员标识
         // 超级会员标识
         Integer svipUserId = baseMapper.getSvipUserIdByUserId(cartDto.getUserId());
         Integer svipUserId = baseMapper.getSvipUserIdByUserId(cartDto.getUserId());
         boolean svipUserFlag = null != svipUserId;
         boolean svipUserFlag = null != svipUserId;
-        if (0 == organizeId) {
+        if (0 == organizeId&&userIdentity!=7) {
             // visibility商品可见度: 3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
             // visibility商品可见度: 3:所有人可见,2:普通机构可见,1:会员机构可见,4:仅医美机构可见
             if (!(cartItemVo.getVisibility() == 3 || cartItemVo.getVisibility() == 2 || (cartItemVo.getVisibility() == 1 && (userIdentity == 2 || svipUserFlag)) || (cartItemVo.getVisibility() == 4 && userClubType == 1))) {
             if (!(cartItemVo.getVisibility() == 3 || cartItemVo.getVisibility() == 2 || (cartItemVo.getVisibility() == 1 && (userIdentity == 2 || svipUserFlag)) || (cartItemVo.getVisibility() == 4 && userClubType == 1))) {
                 return ResponseJson.error("商品不可见!", null);
                 return ResponseJson.error("商品不可见!", null);
@@ -1950,7 +1956,7 @@ public class CartClubServiceImpl implements CartClubService {
             promotions = null;
             promotions = null;
         }
         }
         boolean hasGift = false;
         boolean hasGift = false;
-        if (0 == organizeId) {
+        if (0 == organizeId&&userIdentity!=7) {
             if (1 == cartItemVo.getSvipProductFlag()) {
             if (1 == cartItemVo.getSvipProductFlag()) {
                 // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
                 // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
                 // 超级会员设置商品优惠价
                 // 超级会员设置商品优惠价

+ 117 - 0
src/main/java/com/caimei365/order/service/impl/CmReportingClubServiceImpl.java

@@ -0,0 +1,117 @@
+package com.caimei365.order.service.impl;
+
+import java.util.Date;
+import java.util.List;
+
+import com.caimei365.order.mapper.CmReportingClubMapper;
+import com.caimei365.order.model.po.CmReportingClub;
+import com.caimei365.order.service.CmReportingClubService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+/**
+ * 机构报备Service业务层处理
+ *
+ * @author Kaick
+ * @date 2023-10-11
+ */
+@Service
+public class CmReportingClubServiceImpl implements CmReportingClubService {
+    @Resource
+    private CmReportingClubMapper cmReportingClubMapper;
+
+    /**
+     * 通过对象查询机构报备列表
+     *
+     * @param cmReportingClub 机构报备
+     * @return 机构报备
+     */
+    @Override
+    public List<CmReportingClub> getCmReportingClubList(CmReportingClub cmReportingClub) {
+        return cmReportingClubMapper.getCmReportingClubList(cmReportingClub);
+    }
+
+    /**
+     * 通过Id查询机构报备
+     *
+     * @param id 机构报备主键
+     * @return 机构报备
+     */
+    @Override
+    public CmReportingClub getCmReportingClubById(String id) {
+        return cmReportingClubMapper.getCmReportingClubById(id);
+    }
+
+    /**
+     * 通过对象查询机构报备
+     *
+     * @param cmReportingClub 机构报备
+     * @return 机构报备
+     */
+    @Override
+    public CmReportingClub getByCmReportingClub(CmReportingClub cmReportingClub) {
+        return cmReportingClubMapper.getByCmReportingClub(cmReportingClub);
+    }
+
+    /**
+     * 通过对象查询机构报备Id
+     *
+     * @param cmReportingClub 机构报备
+     * @return String
+     */
+    @Override
+    public String getById(CmReportingClub cmReportingClub) {
+        return cmReportingClubMapper.getById(cmReportingClub);
+    }
+
+
+    /**
+     * 通过对象查询机构报备记录总数
+     *
+     * @param cmReportingClub 机构报备
+     * @return int
+     */
+    @Override
+    public int getCmReportingClubCount(CmReportingClub cmReportingClub) {
+        return cmReportingClubMapper.getCmReportingClubCount(cmReportingClub);
+    }
+
+    /**
+     * 新增机构报备
+     *
+     * @param cmReportingClub 机构报备
+     * @return 结果
+     */
+    @Override
+    public int addCmReportingClub(CmReportingClub cmReportingClub) {
+        cmReportingClub.setCreateTime(new Date());
+        return cmReportingClubMapper.addCmReportingClub(cmReportingClub);
+    }
+
+    /**
+     * 修改机构报备
+     *
+     * @param cmReportingClub 机构报备
+     * @return 结果
+     */
+    @Override
+    public int updateCmReportingClub(CmReportingClub cmReportingClub) {
+        cmReportingClub.setUpdateTime(new Date());
+        return cmReportingClubMapper.updateCmReportingClub(cmReportingClub);
+    }
+
+
+    /**
+     * 删除机构报备信息
+     *
+     * @param id 机构报备主键
+     * @return 结果
+     */
+    @Override
+    public int delCmReportingClubById(String id) {
+        return cmReportingClubMapper.updateCmReportingClub(new CmReportingClub().id(id).delFlag(1));
+        //return cmReportingClubMapper.delCmReportingClubById(id);
+    }
+}
+

+ 67 - 9
src/main/java/com/caimei365/order/service/impl/HeliPayServiceImpl.java

@@ -7,10 +7,7 @@ import com.caimei365.order.components.OnlinePostFormUtil;
 import com.caimei365.order.components.OrderCommonService;
 import com.caimei365.order.components.OrderCommonService;
 import com.caimei365.order.components.WeChatService;
 import com.caimei365.order.components.WeChatService;
 import com.caimei365.order.constant.Constant;
 import com.caimei365.order.constant.Constant;
-import com.caimei365.order.mapper.BaseMapper;
-import com.caimei365.order.mapper.OrderCommonMapper;
-import com.caimei365.order.mapper.OrderRefundMapper;
-import com.caimei365.order.mapper.PayOrderMapper;
+import com.caimei365.order.mapper.*;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.bo.PayParamBo;
 import com.caimei365.order.model.bo.PayParamBo;
 import com.caimei365.order.model.dto.BankListDto;
 import com.caimei365.order.model.dto.BankListDto;
@@ -43,6 +40,7 @@ import java.beans.IntrospectionException;
 import java.io.IOException;
 import java.io.IOException;
 import java.lang.reflect.Field;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.InvocationTargetException;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
@@ -82,6 +80,10 @@ public class HeliPayServiceImpl implements HeliPayService {
     private WeChatService weChatService;
     private WeChatService weChatService;
     @Resource
     @Resource
     private OrderRefundMapper refundMapper;
     private OrderRefundMapper refundMapper;
+    @Resource
+    private CmReportingClubMapper cmReportingClubMapper;
+    @Resource
+    private CmReportingMemberMapper cmReportingMemberMapper;
     @Value("${caimei.wwwDomain}")
     @Value("${caimei.wwwDomain}")
     private String domain;
     private String domain;
 
 
@@ -391,7 +393,35 @@ public class HeliPayServiceImpl implements HeliPayService {
         // 保存 收款项和订单关系
         // 保存 收款项和订单关系
         baseMapper.insertOrderReceiptRelation(relation);
         baseMapper.insertOrderReceiptRelation(relation);
         log.info("【支付异步回调】>>>>>>>>>>>收款项和订单关系(insert[cm_receipt_order_relation])id:" + relation.getId() + ",orderId:" + orderId);
         log.info("【支付异步回调】>>>>>>>>>>>收款项和订单关系(insert[cm_receipt_order_relation])id:" + relation.getId() + ",orderId:" + orderId);
-
+        Integer identity = baseMapper.getIdentityByUserId(order.getUserId());
+        //分销人员下单修改报备记录
+        if (identity == 8) {
+            CmReportingClub byCmReportingClub = cmReportingClubMapper.getByCmReportingClub(new CmReportingClub()
+                    .orderId(order.getOrderId())
+                    .orderStatus(0)
+            );
+            //商品报备佣金
+            BigDecimal commission = cmReportingClubMapper.getDistributionProductCommission(byCmReportingClub.productId());
+            byCmReportingClub
+                    .distributionId(shopOrder.getSpId())
+                    .lockStatus(1)
+                    .lockTime(new Date())
+                    .orderStatus(1)
+                    .commission(commission)
+                    .splitSettleStatus(1)
+                    .settleStatus(0);
+            cmReportingClubMapper.updateCmReportingClub(byCmReportingClub);
+            List<CmReportingMember> cmReportingMemberList = cmReportingMemberMapper.getCmReportingMemberList(new CmReportingMember()
+                    .clubReportingId(Integer.valueOf(byCmReportingClub.id()))
+                    .auditStatus(2)
+            );
+            //商品报备成员佣金
+            BigDecimal memberCommission = MathUtil.div(commission, cmReportingMemberList.size(), 2);
+            cmReportingMemberList.forEach(s -> {
+                s.commission(memberCommission).settleStatus(2);
+                cmReportingMemberMapper.updateCmReportingMember(s);
+            });
+        }
         //当前版本无法线上走充值/订金订单
         //当前版本无法线上走充值/订金订单
         // 商品数据
         // 商品数据
 //        List<OrderProductVo> orderProductList = orderCommonMapper.getOrderProductByOrderId(orderId);
 //        List<OrderProductVo> orderProductList = orderCommonMapper.getOrderProductByOrderId(orderId);
@@ -440,7 +470,7 @@ public class HeliPayServiceImpl implements HeliPayService {
 //        }
 //        }
 
 
         // 线上支付与自主下单送豆(已全部收款),最后一笔线上支付成功后,赠送200采美豆
         // 线上支付与自主下单送豆(已全部收款),最后一笔线上支付成功后,赠送200采美豆
-        if (3 == order.getReceiptStatus() && 0 == order.getSecondHandOrderFlag()) {
+        if (3 == order.getReceiptStatus() && 0 == order.getSecondHandOrderFlag()&&identity != 8) {
             UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
             UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
             beansHistory.setUserId(order.getUserId());
             beansHistory.setUserId(order.getUserId());
             beansHistory.setOrderId(orderId);
             beansHistory.setOrderId(orderId);
@@ -889,7 +919,7 @@ public class HeliPayServiceImpl implements HeliPayService {
         String sign = res.getSign();
         String sign = res.getSign();
         log.info("回调签名" + sign);
         log.info("回调签名" + sign);
         String oriMessage = MyBeanUtils.getSignedByPresetParameter(res, UnionResVo.NEED_SIGN_PARAMS);
         String oriMessage = MyBeanUtils.getSignedByPresetParameter(res, UnionResVo.NEED_SIGN_PARAMS);
-        oriMessage += Constant.SPLIT + Constant.WANGYIN;
+        oriMessage += SPLIT + WANGYIN;
         String checkSign2 = Disguiser.disguiseMD5(oriMessage.trim());
         String checkSign2 = Disguiser.disguiseMD5(oriMessage.trim());
         if (!sign.equals(checkSign2)) {
         if (!sign.equals(checkSign2)) {
             log.error("网银支付异步回调验签失败------------------------------------");
             log.error("网银支付异步回调验签失败------------------------------------");
@@ -1030,9 +1060,37 @@ public class HeliPayServiceImpl implements HeliPayService {
         // 保存 收款项和订单关系
         // 保存 收款项和订单关系
         baseMapper.insertOrderReceiptRelation(relation);
         baseMapper.insertOrderReceiptRelation(relation);
         log.info("【支付异步回调】>>>>>>>>>>>收款项和订单关系(insert[cm_receipt_order_relation])id:" + relation.getId() + ",orderId:" + orderId);
         log.info("【支付异步回调】>>>>>>>>>>>收款项和订单关系(insert[cm_receipt_order_relation])id:" + relation.getId() + ",orderId:" + orderId);
-
+        Integer identity = baseMapper.getIdentityByUserId(order.getUserId());
+        //分销人员下单修改报备记录
+        if (identity == 8) {
+            CmReportingClub byCmReportingClub = cmReportingClubMapper.getByCmReportingClub(new CmReportingClub()
+                    .orderId(order.getOrderId())
+                    .orderStatus(0)
+            );
+            //商品报备佣金
+            BigDecimal commission = cmReportingClubMapper.getDistributionProductCommission(byCmReportingClub.productId());
+            byCmReportingClub
+                    .distributionId(shopOrder.getSpId())
+                    .lockStatus(1)
+                    .lockTime(new Date())
+                    .orderStatus(1)
+                    .commission(commission)
+                    .splitSettleStatus(1)
+                    .settleStatus(0);
+            cmReportingClubMapper.updateCmReportingClub(byCmReportingClub);
+            List<CmReportingMember> cmReportingMemberList = cmReportingMemberMapper.getCmReportingMemberList(new CmReportingMember()
+                    .clubReportingId(Integer.valueOf(byCmReportingClub.id()))
+                    .auditStatus(2)
+            );
+            //商品报备成员佣金
+            BigDecimal memberCommission = MathUtil.div(commission, cmReportingMemberList.size(), 2);
+            cmReportingMemberList.forEach(s -> {
+                s.commission(memberCommission).settleStatus(2);
+                cmReportingMemberMapper.updateCmReportingMember(s);
+            });
+        }
         // 线上支付与自主下单送豆(已全部收款),最后一笔线上支付成功后,赠送200采美豆
         // 线上支付与自主下单送豆(已全部收款),最后一笔线上支付成功后,赠送200采美豆
-        if (3 == order.getReceiptStatus() && 0 == order.getSecondHandOrderFlag()) {
+        if (3 == order.getReceiptStatus() && 0 == order.getSecondHandOrderFlag()&&identity != 8) {
             UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
             UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
             beansHistory.setUserId(order.getUserId());
             beansHistory.setUserId(order.getUserId());
             beansHistory.setOrderId(orderId);
             beansHistory.setOrderId(orderId);

+ 55 - 0
src/main/java/com/caimei365/order/service/impl/OrderClubServiceImpl.java

@@ -65,6 +65,8 @@ public class OrderClubServiceImpl implements OrderClubService {
     private WeChatService weChatService;
     private WeChatService weChatService;
     @Resource
     @Resource
     private PayOrderMapper payOrderMapper;
     private PayOrderMapper payOrderMapper;
+    @Resource
+    private CmReportingClubMapper cmReportingClubMapper;
 
 
     /**
     /**
      * 获取各状态订单数量
      * 获取各状态订单数量
@@ -594,6 +596,15 @@ public class OrderClubServiceImpl implements OrderClubService {
             // 非待确认(或待收待发)订单
             // 非待确认(或待收待发)订单
             return ResponseJson.error("订单异常!", null);
             return ResponseJson.error("订单异常!", null);
         }
         }
+        Integer identity = baseMapper.getIdentityByUserId(shopOrder.getUserId());
+        //分销人员取消订单修改报备记录
+        if (identity == 8) {
+            cmReportingClubMapper.updateCmReportingClub(new CmReportingClub()
+                    .orderId(shopOrder.getOrderId())
+                    .orderStatus(0)
+                    .lockStatus(0)
+            );
+        }
         Date date = new Date();
         Date date = new Date();
         String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
         String curDateStr = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(date);
         String note = "【取消订单】";
         String note = "【取消订单】";
@@ -1075,6 +1086,50 @@ public class OrderClubServiceImpl implements OrderClubService {
             return ResponseJson.error("分享码不正确!", null);
             return ResponseJson.error("分享码不正确!", null);
         }
         }
     }
     }
+    /**
+     * 分享订单,校验分享码
+     *
+     * @param shopOrderId   订单Id
+     * @param shareCode     分享码
+     */
+    @Override
+    public ResponseJson<String> checkOrderShareCode(Integer userId, Integer shopOrderId, String shareCode) {
+        // 用户组织Id
+        Integer identity = baseMapper.getIdentityByUserId(userId);
+        int shopOrderCount = orderClubMapper.countMainShopOrderByOrderId(shopOrderId);
+        if (8!= identity) {
+            return ResponseJson.error("userId不存在!", null);
+        }
+        if (0 == shopOrderCount) {
+            return ResponseJson.error("订单不存在!", null);
+        }
+        // 根据订单Id获取分享码
+        OrderShareCodeVo orderCodeVo = orderClubMapper.getShopOrderCodeById(shopOrderId);
+        if (null == orderCodeVo) {
+            return ResponseJson.error("该订单没有生成分享码!", null);
+        }
+        // 校验分享码
+        if (orderCodeVo.getShareCode().equals(shareCode)) {
+            if (orderCodeVo.getExpiredTime().compareTo(new Date()) > 0) {
+                // 分享码有效, 保存分享码使用记录
+                OrderShareCodeRecordVo codeRecord = new OrderShareCodeRecordVo();
+                codeRecord.setUserId(userId);
+                codeRecord.setAddTime(new Date());
+                codeRecord.setOrderId(orderCodeVo.getOrderId());
+                codeRecord.setShopOrderId(shopOrderId);
+                codeRecord.setDelFlag(0);
+                codeRecord.setShareCodeId(orderCodeVo.getId());
+                orderClubMapper.insertOrderShareCodeRecord(codeRecord);
+                // 返回
+                return ResponseJson.success(0, "查看分享订单!", null);
+            } else {
+                // 分享码过期
+                return ResponseJson.error("分享码已失效!", null);
+            }
+        } else {
+            return ResponseJson.error("分享码不正确!", null);
+        }
+    }
 
 
     /**
     /**
      * 分享订单,初始商品数据
      * 分享订单,初始商品数据

+ 21 - 11
src/main/java/com/caimei365/order/service/impl/OrderSellerServiceImpl.java

@@ -42,20 +42,29 @@ public class OrderSellerServiceImpl implements OrderSellerService {
      * @param pageSize          每页数量
      * @param pageSize          每页数量
      */
      */
     @Override
     @Override
-    public ResponseJson<PageInfo<ShopOrderVo>> getOrderList(Integer serviceProviderId, Integer listType, Integer orderSubmitType, String shopOrderNo, Integer groupServiceId, int pageNum, int pageSize) {
+    public ResponseJson<PageInfo<ShopOrderVo>> getOrderList(Integer serviceProviderId, Integer type,Integer listType, Integer orderSubmitType, String shopOrderNo, Integer groupServiceId, int pageNum, int pageSize) {
         // 获取该协销下的机构用户Id
         // 获取该协销下的机构用户Id
         List<Integer> clubUserIds = new ArrayList<>();
         List<Integer> clubUserIds = new ArrayList<>();
-        if (null != orderSubmitType && 3 == orderSubmitType) {
-            if (null != groupServiceId && groupServiceId > 0) {
-                //组员协销id不为空的时候,查某个组员名下的单
-                clubUserIds = orderSellerMapper.getClubUserIds(groupServiceId);
+        if(null==type){
+            if (null != orderSubmitType && 3 == orderSubmitType) {
+                if (null != groupServiceId && groupServiceId > 0) {
+                    //组员协销id不为空的时候,查某个组员名下的单
+                    clubUserIds = orderSellerMapper.getClubUserIds(groupServiceId);
+                } else {
+                    //查组员订单的时候查该协销是组长还是总管理员,组长查自己名下所有组员机构的订单,管理员查所有其他组员
+                    clubUserIds = orderSellerMapper.getClubUserIdsByRole(serviceProviderId);
+                }
             } else {
             } else {
-                //查组员订单的时候查该协销是组长还是总管理员,组长查自己名下所有组员机构的订单,管理员查所有其他组员
-                clubUserIds = orderSellerMapper.getClubUserIdsByRole(serviceProviderId);
+                clubUserIds = orderSellerMapper.getClubUserIds(serviceProviderId);
+            }
+        }else {
+            if (null != orderSubmitType && 3 == orderSubmitType) {
+                clubUserIds = orderSellerMapper.getDistributionClubUserIds(null,serviceProviderId);
+            }else {
+                clubUserIds = orderSellerMapper.getDistributionClubUserIds(serviceProviderId,null);
             }
             }
-        } else {
-            clubUserIds = orderSellerMapper.getClubUserIds(serviceProviderId);
         }
         }
+
         List<ShopOrderVo> shopOrderList = new ArrayList<>();
         List<ShopOrderVo> shopOrderList = new ArrayList<>();
         // 获取订单列表
         // 获取订单列表
         if (null != clubUserIds && clubUserIds.size() > 0) {
         if (null != clubUserIds && clubUserIds.size() > 0) {
@@ -122,13 +131,14 @@ public class OrderSellerServiceImpl implements OrderSellerService {
      * @param pageSize          每页数量
      * @param pageSize          每页数量
      */
      */
     @Override
     @Override
-    public ResponseJson<PageInfo<ShopOrderVo>> getOrderListClub(Integer serviceProviderId, Integer clubId, Integer listType, Integer orderSubmitType, int pageNum, int pageSize) {
+    public ResponseJson<PageInfo<ShopOrderVo>> getOrderListClub(Integer serviceProviderId, Integer clubId, Integer listType, Integer orderSubmitType, Integer type, int pageNum, int pageSize) {
         // 判断该机构是不是该协销下的 1342采美默认协销经理(官方账号)协销id1342为默认,不受限制
         // 判断该机构是不是该协销下的 1342采美默认协销经理(官方账号)协销id1342为默认,不受限制
         Integer spId = orderSellerMapper.getSpIdByClubId(clubId);
         Integer spId = orderSellerMapper.getSpIdByClubId(clubId);
+        Integer identity = baseMapper.getUserIdentity(baseMapper.getUserIdByClubId(clubId), null,null);
         // 协销组长和总管理员也可以看
         // 协销组长和总管理员也可以看
         Integer leaderId = orderSellerMapper.findLeaderId(spId);
         Integer leaderId = orderSellerMapper.findLeaderId(spId);
         Integer managerId = orderSellerMapper.findManagerId();
         Integer managerId = orderSellerMapper.findManagerId();
-        boolean role = serviceProviderId.equals(leaderId) || serviceProviderId.equals(managerId);
+        boolean role = serviceProviderId.equals(leaderId) || serviceProviderId.equals(managerId)||identity==8;
         if (!role && !serviceProviderId.equals(spId)) {
         if (!role && !serviceProviderId.equals(spId)) {
             if (1342 != spId) {
             if (1342 != spId) {
                 //不是总管理员或组长,看是不是本人
                 //不是总管理员或组长,看是不是本人

+ 37 - 1
src/main/java/com/caimei365/order/service/impl/ShipServiceImpl.java

@@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
@@ -71,7 +72,10 @@ public class ShipServiceImpl implements ShipService {
     private OssService ossService;
     private OssService ossService;
     @Resource
     @Resource
     private OSSUtils ossUtils;
     private OSSUtils ossUtils;
-
+    @Resource
+    private CmReportingClubMapper cmReportingClubMapper;
+    @Resource
+    private CmReportingMemberMapper cmReportingMemberMapper;
     @Resource
     @Resource
     private WeChatService weChatService;
     private WeChatService weChatService;
 
 
@@ -1244,6 +1248,38 @@ public class ShipServiceImpl implements ShipService {
         Integer status = 2;
         Integer status = 2;
         if (0 == wait - amount) {
         if (0 == wait - amount) {
             status = 3;
             status = 3;
+            //分销人员下单修改报备记录
+            Integer identity = baseMapper.getUserIdentity(null,orderId, null);
+            if (identity == 8) {
+                CmReportingClub byCmReportingClub = cmReportingClubMapper.getByCmReportingClub(new CmReportingClub()
+                        .orderId(orderId)
+                        .orderStatus(0)
+                );
+                ShopOrderVo shopOrder = orderCommonMapper.getShopOrderByOrderId(shopOrderId);
+                //商品报备佣金
+                BigDecimal commission = cmReportingClubMapper.getDistributionProductCommission(byCmReportingClub.productId());
+                byCmReportingClub
+                        .distributionId(shopOrder.getSpId())
+                        .lockStatus(1)
+                        .lockTime(new Date())
+                        .orderStatus(1)
+                        .splitCode(cmReportingClubMapper.getDistributionSplitCode(byCmReportingClub.distributionId()))
+                        .commission(commission)
+                        .splitSettleStatus(2)
+                        .settleStatus(0);
+
+                cmReportingClubMapper.updateCmReportingClub(byCmReportingClub);
+                List<CmReportingMember> cmReportingMemberList = cmReportingMemberMapper.getCmReportingMemberList(new CmReportingMember()
+                        .clubReportingId(Integer.valueOf(byCmReportingClub.id()))
+                        .auditStatus(2)
+                );
+                //商品报备成员佣金
+                BigDecimal memberCommission = MathUtil.div(commission, cmReportingMemberList.size(), 2);
+                cmReportingMemberList.forEach(s -> {
+                    s.commission(memberCommission).settleStatus(2);
+                    cmReportingMemberMapper.updateCmReportingMember(s);
+                });
+            }
         }
         }
         shipMapper.updateReceiptStatus(status, shopOrderId);
         shipMapper.updateReceiptStatus(status, shopOrderId);
         // 获取订单下子订单收款状态
         // 获取订单下子订单收款状态

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

@@ -69,6 +69,8 @@ public class SubmitServiceImpl implements SubmitService {
     private RemoteCallService remoteCallService;
     private RemoteCallService remoteCallService;
     @Resource
     @Resource
     private ShipMapper shipMapper;
     private ShipMapper shipMapper;
+    @Resource
+    private CmReportingClubMapper cmReportingClubMapper;
 
 
 
 
     /**
     /**
@@ -131,6 +133,7 @@ public class SubmitServiceImpl implements SubmitService {
         log.info("submitDto===" + submitDto);
         log.info("submitDto===" + submitDto);
         // 获取机构用户Id
         // 获取机构用户Id
         Integer clubUserId = baseMapper.getUserIdByClubId(submitDto.getClubId());
         Integer clubUserId = baseMapper.getUserIdByClubId(submitDto.getClubId());
+
         if (null == clubUserId || clubUserId == 0) {
         if (null == clubUserId || clubUserId == 0) {
             return ResponseJson.error("机构用户信息异常!", null);
             return ResponseJson.error("机构用户信息异常!", null);
         }
         }
@@ -335,8 +338,16 @@ public class SubmitServiceImpl implements SubmitService {
                 }
                 }
             }
             }
         } else if (3 == submitDto.getCartType()) {
         } else if (3 == submitDto.getCartType()) {
-            // 协销下单, 获取协销用户Id
-            Integer spUserId = submitMapper.getServiceProviderUserId(submitDto.getServiceProviderId());
+
+            Integer spUserId = null;
+            if (orderParamBo.getUserIdentity() == 8) {
+                // 分销人员下单, 获取协销用户Id
+                spUserId = submitMapper.getDistributionUserId(submitDto.getServiceProviderId());
+                orderParamBo.setClubReportingId(submitDto.getClubReportingId());
+            } else {
+                // 协销下单, 获取协销用户Id
+                spUserId = submitMapper.getServiceProviderUserId(submitDto.getServiceProviderId());
+            }
             if (null != spUserId && spUserId > 0) {
             if (null != spUserId && spUserId > 0) {
                 buyUserId = spUserId;
                 buyUserId = spUserId;
             } else {
             } else {
@@ -376,7 +387,7 @@ public class SubmitServiceImpl implements SubmitService {
         mainOrder.setOrderSource(orderParamBo.getOrderSource());
         mainOrder.setOrderSource(orderParamBo.getOrderSource());
         // 生成订单号
         // 生成订单号
         if (0 != organizeId) {
         if (0 != organizeId) {
-            orderParamBo.setOrderSource(9);
+            orderParamBo.setOrderSource(10);
         }
         }
         String orderNo = CodeUtil.generateOrderNo(orderParamBo.getOrderSource());
         String orderNo = CodeUtil.generateOrderNo(orderParamBo.getOrderSource());
         mainOrder.setOrderNo(orderNo);
         mainOrder.setOrderNo(orderNo);
@@ -581,7 +592,12 @@ public class SubmitServiceImpl implements SubmitService {
                 // 获取数据库商品信息
                 // 获取数据库商品信息
                 OrderProductPo dbProduct = null;
                 OrderProductPo dbProduct = null;
                 if (0 == organizeId) {
                 if (0 == organizeId) {
-                    dbProduct = submitMapper.getProductDetails(skuId);
+                    //分销人员生成机构
+                    if (orderParamBo.getUserIdentity() == 8) {
+                        dbProduct = submitMapper.getDistributionProductDetails(skuId);
+                    } else {
+                        dbProduct = submitMapper.getProductDetails(skuId);
+                    }
                 } else {
                 } else {
                     dbProduct = submitMapper.getProductOrganizeDetails(skuId);
                     dbProduct = submitMapper.getProductOrganizeDetails(skuId);
                 }
                 }
@@ -683,7 +699,7 @@ public class SubmitServiceImpl implements SubmitService {
                     }
                     }
                     // 计算单价
                     // 计算单价
                     // 超级会员单价折扣计算
                     // 超级会员单价折扣计算
-                    if (0 == organizeId) {
+                    if (0 == organizeId && orderParamBo.getUserIdentity() != 8) {
                         if (null != svipProductPo && 1 == svipProductPo.getSvipProductFlag()) {
                         if (null != svipProductPo && 1 == svipProductPo.getSvipProductFlag()) {
                             // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
                             // 超级会员优惠商品,不参与促销活动(普通机构购买该商品可参与店铺促销)/阶梯价/复购价
                             if (orderParamBo.getSvipUserFlag()) {
                             if (orderParamBo.getSvipUserFlag()) {
@@ -796,7 +812,7 @@ public class SubmitServiceImpl implements SubmitService {
                     product.setPrice(productPrice);
                     product.setPrice(productPrice);
                     if (hasActProductFlag && null != promotions) {
                     if (hasActProductFlag && null != promotions) {
                         // 单品促销
                         // 单品促销
-                        if (0 == organizeId) {
+                        if (0 == organizeId && orderParamBo.getUserIdentity() != 8) {
                             if (promotions.getType() == 1) {
                             if (promotions.getType() == 1) {
                                 // 是否满足单品优惠条件(满足优惠价或者满减在这里进行设值)
                                 // 是否满足单品优惠条件(满足优惠价或者满减在这里进行设值)
                                 if (promotions.getMode() == 1 || MathUtil.compare(productFee, promotions.getTouchPrice()) >= 0) {
                                 if (promotions.getMode() == 1 || MathUtil.compare(productFee, promotions.getTouchPrice()) >= 0) {
@@ -979,7 +995,12 @@ public class SubmitServiceImpl implements SubmitService {
                 // 付供应商税费
                 // 付供应商税费
                 shopTaxFee.set(MathUtil.add(shopTaxFee.get(), product.getShouldPayTotalTax()).doubleValue());
                 shopTaxFee.set(MathUtil.add(shopTaxFee.get(), product.getShouldPayTotalTax()).doubleValue());
                 // 成本 | 佣金比例  商城sku 成本 | 配置比例
                 // 成本 | 佣金比例  商城sku 成本 | 配置比例
-                CmOrganizeSkuPo organizeSkuInfo = submitMapper.getOrganizeSkuInfo(skuId, organizeId);
+                CmOrganizeSkuPo organizeSkuInfo = null;
+                if (orderParamBo.getUserIdentity() == 8) {
+                    organizeSkuInfo = submitMapper.getDistributionSkuInfo(skuId, organizeId);
+                } else {
+                    organizeSkuInfo = submitMapper.getOrganizeSkuInfo(skuId, organizeId);
+                }
                 if (StringUtils.isNotEmpty(organizeSkuInfo.getCostCheckFlag()) && "1".equals(organizeSkuInfo.getCostCheckFlag())) {
                 if (StringUtils.isNotEmpty(organizeSkuInfo.getCostCheckFlag()) && "1".equals(organizeSkuInfo.getCostCheckFlag())) {
                     // 固定成本
                     // 固定成本
                     if (taxFlag) {
                     if (taxFlag) {
@@ -1020,7 +1041,7 @@ public class SubmitServiceImpl implements SubmitService {
                 //有商品无分帐号,走线下
                 //有商品无分帐号,走线下
                 onlinePay.set(false);
                 onlinePay.set(false);
             }
             }
-            if (0 == organizeId) {
+            if (0 == organizeId && orderParamBo.getUserIdentity() != 8) {
                 if (null != shopPromotions) {
                 if (null != shopPromotions) {
                     // 是否满足满减满赠
                     // 是否满足满减满赠
                     if (MathUtil.compare(shopPromotionFee.get(), shopPromotions.getTouchPrice()) >= 0) {
                     if (MathUtil.compare(shopPromotionFee.get(), shopPromotions.getTouchPrice()) >= 0) {
@@ -1142,7 +1163,7 @@ public class SubmitServiceImpl implements SubmitService {
         } else {
         } else {
             mainOrder.setSecondHandOrderFlag(0);
             mainOrder.setSecondHandOrderFlag(0);
         }
         }
-        if (0 == organizeId) {
+        if (0 == organizeId && orderParamBo.getUserIdentity() != 8) {
             // 是否包含活动商品(受订单未支付自动关闭时间影响)  0 否 1 是
             // 是否包含活动商品(受订单未支付自动关闭时间影响)  0 否 1 是
             if (!hasActProductFlag) {
             if (!hasActProductFlag) {
                 mainOrder.setHasActProduct(0);
                 mainOrder.setHasActProduct(0);
@@ -1332,6 +1353,13 @@ public class SubmitServiceImpl implements SubmitService {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             return ResponseJson.error("用户Id为空!", null);
             return ResponseJson.error("用户Id为空!", null);
         }
         }
+        CmReportingClub cmReportingClubById = cmReportingClubMapper.getCmReportingClubById(orderParamBo.getClubReportingId());
+        if (orderParamBo.getUserIdentity() == 8&&null!=cmReportingClubById.orderStatus()) {
+            // 设置手动回滚事务
+            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+            return ResponseJson.error("抱歉,该报备中已有人下单,暂无法下单!", null);
+        }
+
         // 根据用户 Id 查询机构 Id
         // 根据用户 Id 查询机构 Id
         Integer clubId = submitMapper.getClubId(mainOrder.getUserId());
         Integer clubId = submitMapper.getClubId(mainOrder.getUserId());
         mainOrder.setClubId(clubId);
         mainOrder.setClubId(clubId);
@@ -1340,7 +1368,15 @@ public class SubmitServiceImpl implements SubmitService {
          */
          */
         submitMapper.insertMainOrder(mainOrder);
         submitMapper.insertMainOrder(mainOrder);
         log.info("【提交订单】>>>>>>>>>>>>>>>>>>>>>>>>>>新增主订单(insert[cm_order])orderId:" + mainOrder.getOrderId());
         log.info("【提交订单】>>>>>>>>>>>>>>>>>>>>>>>>>>新增主订单(insert[cm_order])orderId:" + mainOrder.getOrderId());
-
+        //分销人员下单修改报备记录
+        if (orderParamBo.getUserIdentity() == 8) {
+            cmReportingClubMapper.updateCmReportingClub(new CmReportingClub()
+                    .id(orderParamBo.getClubReportingId())
+                    .orderId(mainOrder.getOrderId())
+                    .orderStatus(0)
+                    .splitCode(cmReportingClubMapper.getDistributionSplitCode(cmReportingClubById.distributionId()))
+            );
+        }
         //推送信息中心-交易物流
         //推送信息中心-交易物流
         MessageCenter messageCenter = new MessageCenter();
         MessageCenter messageCenter = new MessageCenter();
         messageCenter.setShopID(null);
         messageCenter.setShopID(null);
@@ -2171,7 +2207,9 @@ public class SubmitServiceImpl implements SubmitService {
          * 当前版本仅修改订单商品价格
          * 当前版本仅修改订单商品价格
          * 余额抵扣修改时,未确认修改抵扣记录抵扣金额,已确认则根据差价修改抵扣记录,并返还余额/或再抵扣
          * 余额抵扣修改时,未确认修改抵扣记录抵扣金额,已确认则根据差价修改抵扣记录,并返还余额/或再抵扣
          */
          */
+
         ShopOrderVo shopOrder = shipMapper.getShopOrder(orderProducts.get(0).getShopOrderId());
         ShopOrderVo shopOrder = shipMapper.getShopOrder(orderProducts.get(0).getShopOrderId());
+        Integer identity = baseMapper.getIdentityByUserId(shopOrder.getUserId());
 
 
         // 商品总数量
         // 商品总数量
         AtomicInteger shopProductCount = new AtomicInteger(0);
         AtomicInteger shopProductCount = new AtomicInteger(0);
@@ -2206,7 +2244,12 @@ public class SubmitServiceImpl implements SubmitService {
             // 获取数据库商品信息
             // 获取数据库商品信息
             OrderProductPo dbProduct = null;
             OrderProductPo dbProduct = null;
             if (0 == orderProduct.getOrganizeId()) {
             if (0 == orderProduct.getOrganizeId()) {
-                dbProduct = submitMapper.getProductDetails(skuId);
+                if (identity == 8) {
+                    //分销人员商品价格
+                    dbProduct = submitMapper.getDistributionProductDetails(skuId);
+                } else {
+                    dbProduct = submitMapper.getProductDetails(skuId);
+                }
             } else {
             } else {
                 dbProduct = submitMapper.getProductOrganizeDetails(skuId);
                 dbProduct = submitMapper.getProductOrganizeDetails(skuId);
             }
             }
@@ -2380,7 +2423,12 @@ public class SubmitServiceImpl implements SubmitService {
             shopTaxFee.set(MathUtil.add(shopTaxFee.get(), product.getShouldPayTotalTax()).doubleValue());
             shopTaxFee.set(MathUtil.add(shopTaxFee.get(), product.getShouldPayTotalTax()).doubleValue());
 
 
             // 成本 | 佣金比例  商城sku配置 成本 | 佣金比例
             // 成本 | 佣金比例  商城sku配置 成本 | 佣金比例
-            CmOrganizeSkuPo organizeSkuInfo = submitMapper.getOrganizeSkuInfo(skuId, orderProduct.getOrganizeId());
+            CmOrganizeSkuPo organizeSkuInfo = null;
+            if (identity == 8) {
+                organizeSkuInfo = submitMapper.getDistributionSkuInfo(skuId, orderProduct.getOrganizeId());
+            } else {
+                organizeSkuInfo = submitMapper.getOrganizeSkuInfo(skuId, orderProduct.getOrganizeId());
+            }
             if (StringUtils.isNotEmpty(organizeSkuInfo.getCostCheckFlag()) && "1".equals(organizeSkuInfo.getCostCheckFlag())) {
             if (StringUtils.isNotEmpty(organizeSkuInfo.getCostCheckFlag()) && "1".equals(organizeSkuInfo.getCostCheckFlag())) {
                 // 固定成本
                 // 固定成本
                 if (taxFlag) {
                 if (taxFlag) {

+ 2 - 0
src/main/java/com/caimei365/order/utils/CodeUtil.java

@@ -107,6 +107,8 @@ public class CodeUtil {
         } else if (8 == orderSource) {
         } else if (8 == orderSource) {
             platform = "A";
             platform = "A";
         } else if (9 == orderSource) {
         } else if (9 == orderSource) {
+            platform = "F";
+        } else if (10 == orderSource) {
             platform = "L";
             platform = "L";
         } else {
         } else {
             // 未知来源
             // 未知来源

+ 5 - 0
src/main/resources/bootstrap.yml

@@ -13,3 +13,8 @@ spring:
       # uri: http://47.119.112.46:18001  # 配置中心地址(测试环境)
       # uri: http://47.119.112.46:18001  # 配置中心地址(测试环境)
       uri: http://120.79.162.1:18001     # 配置中心地址(正式环境)
       uri: http://120.79.162.1:18001     # 配置中心地址(正式环境)
       name: order                       # 配置文件名称
       name: order                       # 配置文件名称
+mybatis:
+  # 扫描classpath中mapper目录下的映射配置文件,针对于映射文件放到了resources目录下
+  mapper-locations: classpath:/mapper/*.xml
+  # 定义包别名,使用pojo时可以直接使用pojo的类型名称不用加包名
+  type-aliases-package: com.caimei365.order.model

+ 16 - 0
src/main/resources/mapper/BaseMapper.xml

@@ -88,6 +88,22 @@
         where userID = #{userId}
         where userID = #{userId}
         LIMIT 1
         LIMIT 1
     </select>
     </select>
+    <select id="getUserIdentity" resultType="java.lang.Integer">
+        select ifnull(u.userIdentity, 0)
+        from user u
+        left join cm_shop_order cso on cso.userId=u.userId
+        where 1=1
+        <if test="userId != null">
+            AND u.userId = #{userId}
+        </if>
+        <if test="orderId != null">
+            AND cso.orderId = #{orderId}
+        </if>
+        <if test="shopOrderId != null">
+            AND cso.shopOrderId = #{shopOrderId}
+        </if>
+        LIMIT 1
+    </select>
     <select id="getUserNameByUserId" resultType="java.lang.String">
     <select id="getUserNameByUserId" resultType="java.lang.String">
         select userName
         select userName
         from user
         from user

+ 31 - 0
src/main/resources/mapper/CartClubMapper.xml

@@ -501,6 +501,37 @@
         WHERE copi.validFlag = '2'
         WHERE copi.validFlag = '2'
           AND cs.skuId = #{skuId} and cs.organizeId = 4 and copi.organizeId = 4
           AND cs.skuId = #{skuId} and cs.organizeId = 4 and copi.organizeId = 4
     </select>
     </select>
+    <select id="getDistributionProductId" resultType="com.caimei365.order.model.vo.CartItemVo">
+        SELECT cs.skuId as skuId,
+               p.productID                  AS productId,
+               p.shopID                     AS shopId,
+               p.`name`                     AS `name`,
+               p.mainImage                  AS image,
+               p.productCode,
+               cds.price,
+               cds.price                     AS originalPrice,
+               cs.unit                      AS unit,
+               p.step                       AS step,
+               cs.minBuyNumber AS MIN,
+               p.priceFlag,
+               cs.ladderPriceFlag           AS ladderFlag,
+               cdp.includedTax                AS includedTax,
+               cdp.invoiceType                AS invoiceType,
+               cdp.clubTaxPoint                   AS taxRate,
+               p.productCategory,
+               copi.validFlag                  AS validFlag,
+               p.visibility,
+               p.commodityType              AS commodityType,
+               p.productType,
+               p.returnGoodsStutas
+        FROM cm_sku cs
+                 left join cm_distribution_sku cds on cs.skuId = cds.skuId
+                 LEFT JOIN product p ON p.productID = cs.productId
+                 LEFT JOIN cm_distribution_product cdp ON p.productID = cdp.productId
+                 left join cm_organize_product_info copi on copi.productId = p.productId
+        WHERE copi.validFlag = '2'
+          AND cs.skuId = #{skuId} and cs.organizeId = 0 and copi.organizeId = 0
+    </select>
 
 
     <select id="findVipCoupon" resultType="java.lang.Integer">
     <select id="findVipCoupon" resultType="java.lang.Integer">
         select couponId
         select couponId

+ 261 - 0
src/main/resources/mapper/CmReportingClubMapper.xml

@@ -0,0 +1,261 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei365.order.mapper.CmReportingClubMapper">
+
+    <resultMap type="CmReportingClub" id="CmReportingClubResult">
+        <result property="id"    column="id"    />
+        <result property="clubName"    column="clubName"    />
+        <result property="linkMan"    column="linkMan"    />
+        <result property="mobile"    column="mobile"    />
+        <result property="productId"    column="productId"    />
+        <result property="orderId"    column="orderId"    />
+        <result property="orderStatus"    column="orderStatus"    />
+        <result property="lockStatus"    column="lockStatus"    />
+        <result property="lockTime"    column="lockTime"    />
+        <result property="distributionId"    column="distributionId"    />
+        <result property="delFlag"    column="delFlag"    />
+        <result property="updateTime"    column="updateTime"    />
+        <result property="createTime"    column="createTime"    />
+        <result property="commission"    column="commission"    />
+        <result property="settleStatus"    column="settleStatus"    />
+        <result property="settleTime"    column="settleTime"    />
+    </resultMap>
+
+    <sql id="selectCmReportingClubVo">
+        select
+            cm_reporting_club.id,
+            cm_reporting_club.clubName,
+            cm_reporting_club.linkMan,
+            cm_reporting_club.mobile,
+            cm_reporting_club.productId,
+            cm_reporting_club.orderId,
+            cm_reporting_club.orderStatus,
+            cm_reporting_club.lockStatus,
+            cm_reporting_club.lockTime,
+            cm_reporting_club.distributionId,
+            cm_reporting_club.delFlag,
+            cm_reporting_club.updateTime,
+            cm_reporting_club.createTime,
+            ifnull(cm_reporting_club.commission,0) AS commission,
+            cm_reporting_club.settleStatus,
+            cm_reporting_club.settleTime
+    </sql>
+
+    <select id="getByCmReportingClub" parameterType="CmReportingClub" resultMap="CmReportingClubResult">
+        <include refid="selectCmReportingClubVo"/>
+        from cm_reporting_club AS cm_reporting_club
+        <where>  cm_reporting_club.delFlag = 0
+            <if test="id != null "> and cm_reporting_club.id = #{id}</if>
+            <if test="clubName != null  and clubName != ''"> and cm_reporting_club.clubName like concat('%', #{clubName}, '%')</if>
+            <if test="linkMan != null  and linkMan != ''"> and cm_reporting_club.linkMan = #{linkMan}</if>
+            <if test="mobile != null  and mobile != ''"> and cm_reporting_club.mobile = #{mobile}</if>
+            <if test="productId != null "> and cm_reporting_club.productId = #{productId}</if>
+            <if test="orderId != null "> and cm_reporting_club.orderId = #{orderId}</if>
+            <if test="orderStatus != null "> and cm_reporting_club.orderStatus = #{orderStatus}</if>
+            <if test="lockStatus != null "> and cm_reporting_club.lockStatus = #{lockStatus}</if>
+            <if test="lockTime != null "> and cm_reporting_club.lockTime = #{lockTime}</if>
+            <if test="distributionId != null "> and cm_reporting_club.distributionId = #{distributionId}</if>
+            <if test="updateTime != null "> and cm_reporting_club.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_reporting_club.createTime = #{createTime}</if>
+            <if test="commission != null "> and cm_reporting_club.commission = #{commission}</if>
+            <if test="settleStatus != null "> and cm_reporting_club.settleStatus = #{settleStatus}</if>
+            <if test="settleTime != null "> and cm_reporting_club.settleTime = #{settleTime}</if>
+        </where>
+        group by cm_reporting_club.id
+        order by cm_reporting_club.createTime desc
+        limit 0,1
+    </select>
+
+    <select id="getCmReportingClubList" parameterType="CmReportingClub" resultMap="CmReportingClubResult">
+        <include refid="selectCmReportingClubVo"/>
+        from cm_reporting_club AS cm_reporting_club
+        <where>  cm_reporting_club.delFlag = 0
+            <if test="id != null  and id != ''">
+                and cm_reporting_club.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="clubName != null  and clubName != ''"> and cm_reporting_club.clubName like concat('%', #{clubName}, '%')</if>
+            <if test="linkMan != null  and linkMan != ''"> and cm_reporting_club.linkMan = #{linkMan}</if>
+            <if test="mobile != null  and mobile != ''"> and cm_reporting_club.mobile = #{mobile}</if>
+            <if test="productId != null "> and cm_reporting_club.productId = #{productId}</if>
+            <if test="orderId != null "> and cm_reporting_club.orderId = #{orderId}</if>
+            <if test="orderStatus != null "> and cm_reporting_club.orderStatus = #{orderStatus}</if>
+            <if test="lockStatus != null "> and cm_reporting_club.lockStatus = #{lockStatus}</if>
+            <if test="lockTime != null "> and cm_reporting_club.lockTime = #{lockTime}</if>
+            <if test="distributionId != null "> and cm_reporting_club.distributionId = #{distributionId}</if>
+            <if test="updateTime != null "> and cm_reporting_club.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_reporting_club.createTime = #{createTime}</if>
+            <if test="commission != null "> and cm_reporting_club.commission = #{commission}</if>
+            <if test="settleStatus != null "> and cm_reporting_club.settleStatus = #{settleStatus}</if>
+            <if test="settleTime != null "> and cm_reporting_club.settleTime = #{settleTime}</if>
+        </where>
+        group by cm_reporting_club.id
+        order by cm_reporting_club.createTime desc
+    </select>
+
+    <select id="getCmReportingClubCount" parameterType="CmReportingClub" resultType="Integer">
+        select count(1)
+        from cm_reporting_club AS cm_reporting_club
+        <where>  cm_reporting_club.delFlag = 0
+            <if test="id != null "> and cm_reporting_club.id = #{id}</if>
+            <if test="clubName != null  and clubName != ''"> and cm_reporting_club.clubName like concat('%', #{clubName}, '%')</if>
+            <if test="linkMan != null  and linkMan != ''"> and cm_reporting_club.linkMan = #{linkMan}</if>
+            <if test="mobile != null  and mobile != ''"> and cm_reporting_club.mobile = #{mobile}</if>
+            <if test="productId != null "> and cm_reporting_club.productId = #{productId}</if>
+            <if test="orderId != null "> and cm_reporting_club.orderId = #{orderId}</if>
+            <if test="orderStatus != null "> and cm_reporting_club.orderStatus = #{orderStatus}</if>
+            <if test="lockStatus != null "> and cm_reporting_club.lockStatus = #{lockStatus}</if>
+            <if test="lockTime != null "> and cm_reporting_club.lockTime = #{lockTime}</if>
+            <if test="distributionId != null "> and cm_reporting_club.distributionId = #{distributionId}</if>
+            <if test="updateTime != null "> and cm_reporting_club.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_reporting_club.createTime = #{createTime}</if>
+            <if test="commission != null "> and cm_reporting_club.commission = #{commission}</if>
+            <if test="settleStatus != null "> and cm_reporting_club.settleStatus = #{settleStatus}</if>
+            <if test="settleTime != null "> and cm_reporting_club.settleTime = #{settleTime}</if>
+        </where>
+        group by cm_reporting_club.id
+    </select>
+
+    <select id="getCmReportingClubById" parameterType="String" resultMap="CmReportingClubResult">
+        <include refid="selectCmReportingClubVo"/>
+        from cm_reporting_club AS cm_reporting_club
+        where  cm_reporting_club.delFlag = 0 and cm_reporting_club.id = #{id}
+    </select>
+    <select id="getDistributionProductCommission"  resultType="BigDecimal">
+       select commission
+       from cm_distribution_product AS cm_distribution_product
+       where  cm_distribution_product.productId = #{productId}
+    </select>
+    <select id="getDistributionSplitCode"  resultType="String">
+       select if(a.parentId=0,a.splitCode,(select b.splitCode from cm_distribution AS b where  b.id = a.parentId))
+       from cm_distribution AS a
+       where  a.id = #{id}
+    </select>
+
+
+    <select id="getById" parameterType="CmReportingClub" resultType="String">
+        select id
+        from cm_reporting_club AS cm_reporting_club
+        <where>  cm_reporting_club.delFlag = 0
+            <if test="id != null "> and cm_reporting_club.id = #{id}</if>
+            <if test="clubName != null  and clubName != ''"> and cm_reporting_club.clubName like concat('%', #{clubName}, '%')</if>
+            <if test="linkMan != null  and linkMan != ''"> and cm_reporting_club.linkMan = #{linkMan}</if>
+            <if test="mobile != null  and mobile != ''"> and cm_reporting_club.mobile = #{mobile}</if>
+            <if test="productId != null "> and cm_reporting_club.productId = #{productId}</if>
+            <if test="orderId != null "> and cm_reporting_club.orderId = #{orderId}</if>
+            <if test="orderStatus != null "> and cm_reporting_club.orderStatus = #{orderStatus}</if>
+            <if test="lockStatus != null "> and cm_reporting_club.lockStatus = #{lockStatus}</if>
+            <if test="lockTime != null "> and cm_reporting_club.lockTime = #{lockTime}</if>
+            <if test="distributionId != null "> and cm_reporting_club.distributionId = #{distributionId}</if>
+            <if test="updateTime != null "> and cm_reporting_club.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_reporting_club.createTime = #{createTime}</if>
+            <if test="commission != null "> and cm_reporting_club.commission = #{commission}</if>
+            <if test="settleStatus != null "> and cm_reporting_club.settleStatus = #{settleStatus}</if>
+            <if test="settleTime != null "> and cm_reporting_club.settleTime = #{settleTime}</if>
+        </where>
+        group by cm_reporting_club.id
+        limit 0,1
+    </select>
+
+    <insert id="addCmReportingClub" parameterType="CmReportingClub" useGeneratedKeys="true" keyProperty="id">
+        insert into cm_reporting_club
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null and id != ''">id,</if>
+            <if test="clubName != null and clubName != ''">clubName,</if>
+            <if test="linkMan != null and linkMan != ''">linkMan,</if>
+            <if test="mobile != null and mobile != ''">mobile,</if>
+            <if test="productId != null">productId,</if>
+            <if test="orderId != null">orderId,</if>
+            <if test="orderStatus != null">orderStatus,</if>
+            <if test="lockStatus != null">lockStatus,</if>
+            <if test="lockTime != null">lockTime,</if>
+            <if test="distributionId != null">distributionId,</if>
+            <if test="delFlag != null">delFlag,</if>
+            <if test="updateTime != null">updateTime,</if>
+            <if test="createTime != null">createTime,</if>
+            <if test="commission != null">commission,</if>
+            <if test="settleStatus != null">settleStatus,</if>
+            <if test="settleTime != null">settleTime,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null and id != ''">#{id},</if>
+            <if test="clubName != null and clubName != ''">#{clubName},</if>
+            <if test="linkMan != null and linkMan != ''">#{linkMan},</if>
+            <if test="mobile != null and mobile != ''">#{mobile},</if>
+            <if test="productId != null">#{productId},</if>
+            <if test="orderId != null">#{orderId},</if>
+            <if test="orderStatus != null">#{orderStatus},</if>
+            <if test="lockStatus != null">#{lockStatus},</if>
+            <if test="lockTime != null">#{lockTime},</if>
+            <if test="distributionId != null">#{distributionId},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="commission != null">#{commission},</if>
+            <if test="settleStatus != null">#{settleStatus},</if>
+            <if test="settleTime != null">#{settleTime},</if>
+        </trim>
+    </insert>
+
+    <update id="updateCmReportingClub" parameterType="CmReportingClub">
+        update cm_reporting_club
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="clubName != null and clubName != ''">clubName = #{clubName},</if>
+            <if test="linkMan != null and linkMan != ''">linkMan = #{linkMan},</if>
+            <if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
+            <if test="productId != null">productId = #{productId},</if>
+            <if test="orderId != null">orderId = #{orderId},</if>
+            <if test="orderStatus != null">orderStatus = #{orderStatus},</if>
+            <if test="lockStatus != null">lockStatus = #{lockStatus},</if>
+            <if test="lockTime != null">lockTime = #{lockTime},</if>
+            <if test="distributionId != null">distributionId = #{distributionId},</if>
+            <if test="delFlag != null">delFlag = #{delFlag},</if>
+            <if test="updateTime != null">updateTime = #{updateTime},</if>
+            <if test="createTime != null">createTime = #{createTime},</if>
+            <if test="commission != null">commission = #{commission},</if>
+            <if test="settleStatus != null">settleStatus = #{settleStatus},</if>
+            <if test="settleTime != null">settleTime = #{settleTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+
+    <delete id="delCmReportingClubById" parameterType="String">
+        delete
+        from cm_reporting_club where id = #{id}
+    </delete>
+
+    <delete id="delCmReportingClub" parameterType="CmReportingClub">
+        delete
+        from cm_reporting_club AS cm_reporting_club
+        <where>
+            <if test="id != null "> and cm_reporting_club.id = #{id}</if>
+            <if test="clubName != null  and clubName != ''"> and cm_reporting_club.clubName like concat('%', #{clubName}, '%')</if>
+            <if test="linkMan != null  and linkMan != ''"> and cm_reporting_club.linkMan = #{linkMan}</if>
+            <if test="mobile != null  and mobile != ''"> and cm_reporting_club.mobile = #{mobile}</if>
+            <if test="productId != null "> and cm_reporting_club.productId = #{productId}</if>
+            <if test="orderId != null "> and cm_reporting_club.orderId = #{orderId}</if>
+            <if test="orderStatus != null "> and cm_reporting_club.orderStatus = #{orderStatus}</if>
+            <if test="lockStatus != null "> and cm_reporting_club.lockStatus = #{lockStatus}</if>
+            <if test="lockTime != null "> and cm_reporting_club.lockTime = #{lockTime}</if>
+            <if test="distributionId != null "> and cm_reporting_club.distributionId = #{distributionId}</if>
+            <if test="delFlag != null "> and cm_reporting_club.delFlag = #{delFlag}</if>
+            <if test="updateTime != null "> and cm_reporting_club.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_reporting_club.createTime = #{createTime}</if>
+            <if test="commission != null "> and cm_reporting_club.commission = #{commission}</if>
+            <if test="settleStatus != null "> and cm_reporting_club.settleStatus = #{settleStatus}</if>
+            <if test="settleTime != null "> and cm_reporting_club.settleTime = #{settleTime}</if>
+        </where>
+    </delete>
+</mapper>

+ 231 - 0
src/main/resources/mapper/CmReportingMemberMapper.xml

@@ -0,0 +1,231 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei365.order.mapper.CmReportingMemberMapper">
+
+    <resultMap type="CmReportingMember" id="CmReportingMemberResult">
+        <result property="id"    column="id"    />
+        <result property="distributionId"    column="distributionId"    />
+        <result property="clubReportingId"    column="clubReportingId"    />
+        <result property="auditStatus"    column="auditStatus"    />
+        <result property="auditText"    column="auditText"    />
+        <result property="auditBy"    column="auditBy"    />
+        <result property="auditTime"    column="auditTime"    />
+        <result property="delFlag"    column="delFlag"    />
+        <result property="updateTime"    column="updateTime"    />
+        <result property="createTime"    column="createTime"    />
+        <result property="remarks"    column="remarks"    />
+        <result property="commission"    column="commission"    />
+        <result property="settleStatus"    column="settleStatus"    />
+        <result property="settleTime"    column="settleTime"    />
+    </resultMap>
+
+    <sql id="selectCmReportingMemberVo">
+        select
+            cm_reporting_member.id,
+            cm_reporting_member.distributionId,
+            cm_reporting_member.clubReportingId,
+            cm_reporting_member.auditStatus,
+            cm_reporting_member.auditText,
+            cm_reporting_member.auditBy,
+            cm_reporting_member.auditTime,
+            cm_reporting_member.delFlag,
+            cm_reporting_member.updateTime,
+            cm_reporting_member.createTime,
+            cm_reporting_member.remarks,
+            ifnull(cm_reporting_member.commission,0) AS commission,
+            cm_reporting_member.settleStatus,
+            cm_reporting_member.settleTime
+    </sql>
+
+    <select id="getByCmReportingMember" parameterType="CmReportingMember" resultMap="CmReportingMemberResult">
+        <include refid="selectCmReportingMemberVo"/>
+        from cm_reporting_member AS cm_reporting_member
+        <where>  cm_reporting_member.delFlag = 0
+            <if test="id != null "> and cm_reporting_member.id = #{id}</if>
+            <if test="distributionId != null "> and cm_reporting_member.distributionId = #{distributionId}</if>
+            <if test="clubReportingId != null "> and cm_reporting_member.clubReportingId = #{clubReportingId}</if>
+            <if test="auditStatus != null "> and cm_reporting_member.auditStatus = #{auditStatus}</if>
+            <if test="auditText != null  and auditText != ''"> and cm_reporting_member.auditText = #{auditText}</if>
+            <if test="auditBy != null "> and cm_reporting_member.auditBy = #{auditBy}</if>
+            <if test="auditTime != null "> and cm_reporting_member.auditTime = #{auditTime}</if>
+            <if test="updateTime != null "> and cm_reporting_member.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_reporting_member.createTime = #{createTime}</if>
+            <if test="remarks != null  and remarks != ''"> and cm_reporting_member.remarks = #{remarks}</if>
+            <if test="commission != null "> and cm_reporting_member.commission = #{commission}</if>
+            <if test="settleStatus != null "> and cm_reporting_member.settleStatus = #{settleStatus}</if>
+            <if test="settleTime != null "> and cm_reporting_member.settleTime = #{settleTime}</if>
+        </where>
+        group by cm_reporting_member.id
+        order by cm_reporting_member.createTime desc
+        limit 0,1
+    </select>
+
+    <select id="getCmReportingMemberList" parameterType="CmReportingMember" resultMap="CmReportingMemberResult">
+        <include refid="selectCmReportingMemberVo"/>
+        from cm_reporting_member AS cm_reporting_member
+        <where>  cm_reporting_member.delFlag = 0
+            <if test="id != null  and id != ''">
+                and cm_reporting_member.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="distributionId != null "> and cm_reporting_member.distributionId = #{distributionId}</if>
+            <if test="clubReportingId != null "> and cm_reporting_member.clubReportingId = #{clubReportingId}</if>
+            <if test="auditStatus != null "> and cm_reporting_member.auditStatus = #{auditStatus}</if>
+            <if test="auditText != null  and auditText != ''"> and cm_reporting_member.auditText = #{auditText}</if>
+            <if test="auditBy != null "> and cm_reporting_member.auditBy = #{auditBy}</if>
+            <if test="auditTime != null "> and cm_reporting_member.auditTime = #{auditTime}</if>
+            <if test="updateTime != null "> and cm_reporting_member.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_reporting_member.createTime = #{createTime}</if>
+            <if test="remarks != null  and remarks != ''"> and cm_reporting_member.remarks = #{remarks}</if>
+            <if test="commission != null "> and cm_reporting_member.commission = #{commission}</if>
+            <if test="settleStatus != null "> and cm_reporting_member.settleStatus = #{settleStatus}</if>
+            <if test="settleTime != null "> and cm_reporting_member.settleTime = #{settleTime}</if>
+        </where>
+        group by cm_reporting_member.id
+        order by cm_reporting_member.createTime desc
+    </select>
+
+    <select id="getCmReportingMemberCount" parameterType="CmReportingMember" resultType="Integer">
+        select count(1)
+        from cm_reporting_member AS cm_reporting_member
+        <where>  cm_reporting_member.delFlag = 0
+            <if test="id != null "> and cm_reporting_member.id = #{id}</if>
+            <if test="distributionId != null "> and cm_reporting_member.distributionId = #{distributionId}</if>
+            <if test="clubReportingId != null "> and cm_reporting_member.clubReportingId = #{clubReportingId}</if>
+            <if test="auditStatus != null "> and cm_reporting_member.auditStatus = #{auditStatus}</if>
+            <if test="auditText != null  and auditText != ''"> and cm_reporting_member.auditText = #{auditText}</if>
+            <if test="auditBy != null "> and cm_reporting_member.auditBy = #{auditBy}</if>
+            <if test="auditTime != null "> and cm_reporting_member.auditTime = #{auditTime}</if>
+            <if test="updateTime != null "> and cm_reporting_member.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_reporting_member.createTime = #{createTime}</if>
+            <if test="remarks != null  and remarks != ''"> and cm_reporting_member.remarks = #{remarks}</if>
+            <if test="commission != null "> and cm_reporting_member.commission = #{commission}</if>
+            <if test="settleStatus != null "> and cm_reporting_member.settleStatus = #{settleStatus}</if>
+            <if test="settleTime != null "> and cm_reporting_member.settleTime = #{settleTime}</if>
+        </where>
+        group by cm_reporting_member.id
+    </select>
+
+    <select id="getCmReportingMemberById" parameterType="String" resultMap="CmReportingMemberResult">
+        <include refid="selectCmReportingMemberVo"/>
+        from cm_reporting_member AS cm_reporting_member
+        where  cm_reporting_member.delFlag = 0 and cm_reporting_member.id = #{id}
+    </select>
+
+
+    <select id="getById" parameterType="CmReportingMember" resultType="String">
+        select id
+        from cm_reporting_member AS cm_reporting_member
+        <where>  cm_reporting_member.delFlag = 0
+            <if test="id != null "> and cm_reporting_member.id = #{id}</if>
+            <if test="distributionId != null "> and cm_reporting_member.distributionId = #{distributionId}</if>
+            <if test="clubReportingId != null "> and cm_reporting_member.clubReportingId = #{clubReportingId}</if>
+            <if test="auditStatus != null "> and cm_reporting_member.auditStatus = #{auditStatus}</if>
+            <if test="auditText != null  and auditText != ''"> and cm_reporting_member.auditText = #{auditText}</if>
+            <if test="auditBy != null "> and cm_reporting_member.auditBy = #{auditBy}</if>
+            <if test="auditTime != null "> and cm_reporting_member.auditTime = #{auditTime}</if>
+            <if test="updateTime != null "> and cm_reporting_member.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_reporting_member.createTime = #{createTime}</if>
+            <if test="remarks != null  and remarks != ''"> and cm_reporting_member.remarks = #{remarks}</if>
+            <if test="commission != null "> and cm_reporting_member.commission = #{commission}</if>
+            <if test="settleStatus != null "> and cm_reporting_member.settleStatus = #{settleStatus}</if>
+            <if test="settleTime != null "> and cm_reporting_member.settleTime = #{settleTime}</if>
+        </where>
+        group by cm_reporting_member.id
+        limit 0,1
+    </select>
+
+    <insert id="addCmReportingMember" parameterType="CmReportingMember" useGeneratedKeys="true" keyProperty="id">
+        insert into cm_reporting_member
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null and id != ''">id,</if>
+            <if test="distributionId != null">distributionId,</if>
+            <if test="clubReportingId != null">clubReportingId,</if>
+            <if test="auditStatus != null">auditStatus,</if>
+            <if test="auditText != null and auditText != ''">auditText,</if>
+            <if test="auditBy != null">auditBy,</if>
+            <if test="auditTime != null">auditTime,</if>
+            <if test="delFlag != null">delFlag,</if>
+            <if test="updateTime != null">updateTime,</if>
+            <if test="createTime != null">createTime,</if>
+            <if test="remarks != null and remarks != ''">remarks,</if>
+            <if test="commission != null">commission,</if>
+            <if test="settleStatus != null">settleStatus,</if>
+            <if test="settleTime != null">settleTime,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null and id != ''">#{id},</if>
+            <if test="distributionId != null">#{distributionId},</if>
+            <if test="clubReportingId != null">#{clubReportingId},</if>
+            <if test="auditStatus != null">#{auditStatus},</if>
+            <if test="auditText != null and auditText != ''">#{auditText},</if>
+            <if test="auditBy != null">#{auditBy},</if>
+            <if test="auditTime != null">#{auditTime},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="remarks != null and remarks != ''">#{remarks},</if>
+            <if test="commission != null">#{commission},</if>
+            <if test="settleStatus != null">#{settleStatus},</if>
+            <if test="settleTime != null">#{settleTime},</if>
+        </trim>
+    </insert>
+
+    <update id="updateCmReportingMember" parameterType="CmReportingMember">
+        update cm_reporting_member
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="distributionId != null">distributionId = #{distributionId},</if>
+            <if test="clubReportingId != null">clubReportingId = #{clubReportingId},</if>
+            <if test="auditStatus != null">auditStatus = #{auditStatus},</if>
+            <if test="auditText != null and auditText != ''">auditText = #{auditText},</if>
+            <if test="auditBy != null">auditBy = #{auditBy},</if>
+            <if test="auditTime != null">auditTime = #{auditTime},</if>
+            <if test="delFlag != null">delFlag = #{delFlag},</if>
+            <if test="updateTime != null">updateTime = #{updateTime},</if>
+            <if test="createTime != null">createTime = #{createTime},</if>
+            <if test="remarks != null and remarks != ''">remarks = #{remarks},</if>
+            <if test="commission != null">commission = #{commission},</if>
+            <if test="settleStatus != null">settleStatus = #{settleStatus},</if>
+            <if test="settleTime != null">settleTime = #{settleTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+
+    <delete id="delCmReportingMemberById" parameterType="String">
+        delete
+        from cm_reporting_member where id = #{id}
+    </delete>
+
+    <delete id="delCmReportingMember" parameterType="CmReportingMember">
+        delete
+        from cm_reporting_member AS cm_reporting_member
+        <where>
+            <if test="id != null "> and cm_reporting_member.id = #{id}</if>
+            <if test="distributionId != null "> and cm_reporting_member.distributionId = #{distributionId}</if>
+            <if test="clubReportingId != null "> and cm_reporting_member.clubReportingId = #{clubReportingId}</if>
+            <if test="auditStatus != null "> and cm_reporting_member.auditStatus = #{auditStatus}</if>
+            <if test="auditText != null  and auditText != ''"> and cm_reporting_member.auditText = #{auditText}</if>
+            <if test="auditBy != null "> and cm_reporting_member.auditBy = #{auditBy}</if>
+            <if test="auditTime != null "> and cm_reporting_member.auditTime = #{auditTime}</if>
+            <if test="delFlag != null "> and cm_reporting_member.delFlag = #{delFlag}</if>
+            <if test="updateTime != null "> and cm_reporting_member.updateTime = #{updateTime}</if>
+            <if test="createTime != null "> and cm_reporting_member.createTime = #{createTime}</if>
+            <if test="remarks != null  and remarks != ''"> and cm_reporting_member.remarks = #{remarks}</if>
+            <if test="commission != null "> and cm_reporting_member.commission = #{commission}</if>
+            <if test="settleStatus != null "> and cm_reporting_member.settleStatus = #{settleStatus}</if>
+            <if test="settleTime != null "> and cm_reporting_member.settleTime = #{settleTime}</if>
+        </where>
+    </delete>
+</mapper>

+ 2 - 2
src/main/resources/mapper/OrderClubMapper.xml

@@ -169,8 +169,8 @@
         VALUES (#{orderId}, #{shopOrderId}, #{shareCode}, #{addTime}, #{expiredTime}, #{delFlag})
         VALUES (#{orderId}, #{shopOrderId}, #{shareCode}, #{addTime}, #{expiredTime}, #{delFlag})
     </insert>
     </insert>
     <insert id="insertOrderShareCodeRecord">
     <insert id="insertOrderShareCodeRecord">
-        INSERT INTO cm_mall_share_code_record (openid, shopOrderId, orderID, shareCodeId, addTime, delFlag)
-        VALUES (#{openId}, #{shopOrderId}, #{orderId}, #{shareCodeId}, #{addTime}, #{delFlag})
+        INSERT INTO cm_mall_share_code_record (userId,openid, shopOrderId, orderID, shareCodeId, addTime, delFlag)
+        VALUES (#{userId},#{openId}, #{shopOrderId}, #{orderId}, #{shareCodeId}, #{addTime}, #{delFlag})
     </insert>
     </insert>
     <insert id="insertCouponClub" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
     <insert id="insertCouponClub" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
         INSERT INTO cm_coupon_club(userId, couponId, orderId, returnedId, source, status, createDate, useDate, delFlag)
         INSERT INTO cm_coupon_club(userId, couponId, orderId, returnedId, source, status, createDate, useDate, delFlag)

+ 29 - 12
src/main/resources/mapper/OrderSellerMapper.xml

@@ -6,10 +6,24 @@
         SET lastCheckOrderDate = #{date}
         SET lastCheckOrderDate = #{date}
         WHERE clubID = #{clubId}
         WHERE clubID = #{clubId}
     </update>
     </update>
+    <select id="getDistributionClubUserIds" resultType="java.lang.Integer">
+        SELECT c.userID
+        FROM club c
+        LEFT JOIN user u ON u.userId = c.userId
+        LEFT JOIN cm_distribution cm_distribution ON cm_distribution.id = c.spID
+        WHERE u.userIdentity=8
+        <if test="id != null ">
+            AND cm_distribution.id=#{id}
+        </if>
+        <if test="parentId != null ">
+            AND cm_distribution.parentId=#{parentId}
+        </if>
+    </select>
     <select id="getClubUserIds" resultType="java.lang.Integer">
     <select id="getClubUserIds" resultType="java.lang.Integer">
-        SELECT userID
-        FROM club
-        WHERE spID = #{serviceProviderId}
+        SELECT c.userID
+        FROM club c
+        LEFT JOIN user u ON u.userId = c.userId
+        WHERE c.spID = #{serviceProviderId} and u.userIdentity!=8
     </select>
     </select>
     <select id="getOrderList" resultType="com.caimei365.order.model.vo.OrderVo">
     <select id="getOrderList" resultType="com.caimei365.order.model.vo.OrderVo">
         SELECT
         SELECT
@@ -187,9 +201,10 @@
         ORDER BY cso.orderTime DESC
         ORDER BY cso.orderTime DESC
     </select>
     </select>
     <select id="getSpIdByClubId" resultType="java.lang.Integer">
     <select id="getSpIdByClubId" resultType="java.lang.Integer">
-        SELECT spID
-        FROM club
-        WHERE clubID = #{clubId}
+        SELECT c.spID
+        FROM club c
+        LEFT JOIN user u ON u.userId = c.userId
+        WHERE c.clubID = #{clubId}
     </select>
     </select>
     <select id="getOrderListClub" resultType="com.caimei365.order.model.vo.OrderVo">
     <select id="getOrderListClub" resultType="com.caimei365.order.model.vo.OrderVo">
         SELECT
         SELECT
@@ -503,9 +518,10 @@
         </if>
         </if>
     </select>
     </select>
     <select id="getClubUserIdsByRole" resultType="java.lang.Integer">
     <select id="getClubUserIdsByRole" resultType="java.lang.Integer">
-        SELECT DISTINCT userId FROM club
-        WHERE
-            (SELECT serviceProviderId
+        SELECT DISTINCT c.userId FROM club c
+        LEFT JOIN user u ON u.userId = c.userId
+        WHERE  u.userIdentity!=8
+          and (SELECT serviceProviderId
              FROM cm_serviceteam_manager
              FROM cm_serviceteam_manager
              WHERE serviceProviderId=#{serviceProviderId}) IS NOT NULL
              WHERE serviceProviderId=#{serviceProviderId}) IS NOT NULL
             AND spID IN
             AND spID IN
@@ -513,9 +529,10 @@
             FROM cm_serviceteam_group
             FROM cm_serviceteam_group
             WHERE serviceId!=#{serviceProviderId})
             WHERE serviceId!=#{serviceProviderId})
         UNION
         UNION
-        SELECT userId FROM club
-        WHERE
-            (SELECT serviceProviderId
+        SELECT c.userId FROM club c
+        LEFT JOIN user u ON u.userId = c.userId
+        WHERE  u.userIdentity!=8
+          and  (SELECT serviceProviderId
              FROM cm_serviceteam_manager
              FROM cm_serviceteam_manager
              WHERE serviceProviderId=#{serviceProviderId}) IS NULL
              WHERE serviceProviderId=#{serviceProviderId}) IS NULL
           AND spID IN
           AND spID IN

+ 52 - 0
src/main/resources/mapper/SubmitMapper.xml

@@ -187,6 +187,26 @@
           AND cs.organizeId = #{organizeId}
           AND cs.organizeId = #{organizeId}
           AND copi.organizeId = #{organizeId}
           AND copi.organizeId = #{organizeId}
     </select>
     </select>
+    <select id="getDistributionSkuInfo" resultType="com.caimei365.order.model.po.CmOrganizeSkuPo">
+        SELECT distinct cs.skuId,
+                        cs.productId,
+                        cs.minBuyNumber,
+                        cds.price,
+                        cs.unit,
+                        cs.stock,
+                        ifnull(cds.costCheckFlag, 1)   as costCheckFlag,
+                        IFNULL(cds.organizeCostPrice, 0) AS organizeCostPrice,
+                        IFNULL(cds.cmCostPrice, 0)       AS cmCostPrice,
+                        ifnull(cds.organizePercent, 0)   as organizePercent,
+                        ifnull(cds.shopPercent, 0)       as shopPercent,
+                        ifnull(cds.cmPercent, 0)         as cmPercent
+        FROM cm_sku cs
+                 LEFT JOIN cm_distribution_sku cds ON cs.skuId = cds.skuId
+                 LEFT JOIN cm_organize_product_info copi ON cs.productId = copi.productId
+        WHERE cs.skuId = #{skuId}
+          AND cs.organizeId = #{organizeId}
+          AND copi.organizeId = #{organizeId}
+    </select>
     <select id="getOrderInvoice" resultType="com.caimei365.order.model.po.InvoicePo">
     <select id="getOrderInvoice" resultType="com.caimei365.order.model.po.InvoicePo">
         SELECT id,
         SELECT id,
                orderId,
                orderId,
@@ -211,6 +231,11 @@
         FROM serviceprovider
         FROM serviceprovider
         WHERE serviceProviderID = #{serviceProviderId}
         WHERE serviceProviderID = #{serviceProviderId}
     </select>
     </select>
+    <select id="getDistributionUserId" resultType="java.lang.Integer">
+        SELECT userID
+        FROM cm_distribution
+        WHERE id = #{id}
+    </select>
     <select id="getOrderUserBoById" resultType="com.caimei365.order.model.bo.OrderParamBo">
     <select id="getOrderUserBoById" resultType="com.caimei365.order.model.bo.OrderParamBo">
         SELECT userID AS userId,
         SELECT userID AS userId,
                clubID AS clubId,
                clubID AS clubId,
@@ -218,6 +243,7 @@
                bindMobile,
                bindMobile,
                userMoney,
                userMoney,
                ableUserMoney,
                ableUserMoney,
+               userIdentity,
                userBeans
                userBeans
         FROM user
         FROM user
         WHERE userID = #{userId}
         WHERE userID = #{userId}
@@ -248,6 +274,32 @@
         WHERE cs.skuId = #{skuId}
         WHERE cs.skuId = #{skuId}
           and cs.organizeId = 0
           and cs.organizeId = 0
     </select>
     </select>
+    <select id="getDistributionProductDetails" resultType="com.caimei365.order.model.po.OrderProductPo">
+        SELECT cs.skuId                                                                   AS skuId,
+               p.productID                                                                AS productId,
+               p.shopID                                                                   AS shopId,
+               p.`name`                                                                   AS `name`,
+               p.mainImage                                                                AS image,
+               cds.price,
+               cds.costPrice,
+               cds.costCheckFlag AS costCheckFlag,
+               cds.shopPercent                                                             as costProportional,
+               p.productCategory,
+               cs.ladderPriceFlag,
+               cdp.includedTax,
+               cdp.invoiceType,
+               cdp.clubTaxPoint                                                                 AS taxRate,
+               cs.unit                                                                    AS productUnit,
+               cs.normalPrice,
+               cdp.shopTaxPoint                                                         AS shopTaxRate,
+               p.splitCode                                                                as splitCode
+        FROM product p
+                 LEFT JOIN cm_distribution_product cdp ON p.productID = cdp.productId
+                 LEFT JOIN cm_sku cs on p.productID = cs.productId
+                 LEFT JOIN cm_distribution_sku cds on cds.productID = cs.productId and cds.skuId = cs.skuId
+        WHERE cs.skuId = #{skuId}
+          and cs.organizeId = 0
+    </select>
     <select id="getProductOrganizeDetails" resultType="com.caimei365.order.model.po.OrderProductPo">
     <select id="getProductOrganizeDetails" resultType="com.caimei365.order.model.po.OrderProductPo">
         SELECT cs.skuId                                                                   AS skuId,
         SELECT cs.skuId                                                                   AS skuId,
                p.productID                                                                AS productId,
                p.productID                                                                AS productId,