Ver Fonte

更新定时查询支付订单

Yangzw há 2 meses atrás
pai
commit
a6df66d8f7
77 ficheiros alterados com 3425 adições e 74 exclusões
  1. 5 0
      feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/constant/DistriConstants.java
  2. 1 0
      feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/ConsumptionEnum.java
  3. 1 0
      feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/ErrorCodeConstants.java
  4. 34 0
      feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/SocialStatusEnum.java
  5. 6 0
      feifan-module-distri/feifan-module-distri-biz/pom.xml
  6. 29 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/duser/vo/DuserInfoVO.java
  7. 56 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/duser/vo/DuserPageReqVO.java
  8. 92 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/duser/vo/DuserRespVO.java
  9. 57 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/duser/vo/DuserSaveReqVO.java
  10. 56 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/integral/vo/IntegralPageReqVO.java
  11. 66 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/integral/vo/IntegralRespVO.java
  12. 58 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/integral/vo/IntegralSaveReqVO.java
  13. 36 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofit/vo/PtProfitPageReqVO.java
  14. 38 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofit/vo/PtProfitRespVO.java
  15. 31 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofit/vo/PtProfitSaveReqVO.java
  16. 54 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/vo/SharePathPageReqVO.java
  17. 66 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/vo/SharePathRespVO.java
  18. 50 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/vo/SharePathSaveReqVO.java
  19. 22 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/vo/SharePathTreeReqVO.java
  20. 18 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/vo/SharePathtransFerenceRelaReqVO.java
  21. 32 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/vo/TreeNode.java
  22. 15 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatus/bo/SocialStatusBO.java
  23. 33 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatus/vo/SocialStatusPageReqVO.java
  24. 35 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatus/vo/SocialStatusRespVO.java
  25. 33 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatus/vo/SocialStatusSaveReqVO.java
  26. 50 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatuschangelog/vo/SocialStatusChangeLogPageReqVO.java
  27. 55 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatuschangelog/vo/SocialStatusChangeLogRespVO.java
  28. 44 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatuschangelog/vo/SocialStatusChangeLogSaveReqVO.java
  29. 26 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatuschangelog/vo/UserSignSocialLogRespVO.java
  30. 75 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/usertopupconsumptionpointsorder/vo/UserTopUpConsumptionPointsOrderPageReqVO.java
  31. 87 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/usertopupconsumptionpointsorder/vo/UserTopUpConsumptionPointsOrderRespVO.java
  32. 74 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/usertopupconsumptionpointsorder/vo/UserTopUpConsumptionPointsOrderSaveReqVO.java
  33. 4 3
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/duser/DuserDO.java
  34. 69 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/sharepath/SharePathDO.java
  35. 43 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/socialstatus/SocialStatusDO.java
  36. 64 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/socialstatuschangelog/SocialStatusChangeLogDO.java
  37. 96 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/usertopupconsumptionpointsorder/UserTopUpConsumptionPointsOrderDO.java
  38. 36 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/duser/DuserMapper.java
  39. 11 8
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ptprofit/PtProfitMapper.java
  40. 60 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/sharepath/SharePathMapper.java
  41. 27 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/socialstatus/SocialStatusMapper.java
  42. 42 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/socialstatuschangelog/SocialStatusChangeLogMapper.java
  43. 41 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/usertopupconsumptionpointsorder/UserTopUpConsumptionPointsOrderMapper.java
  44. 19 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/mq/consumer/topupconsumptionpoints/topupconsumptionpoints/TopUpConsumptionPointsConsumer.java
  45. 11 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/duser/DuserService.java
  46. 59 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/duser/DuserServiceImpl.java
  47. 19 1
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/integral/IntegralService.java
  48. 55 39
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/integral/IntegralServiceImpl.java
  49. 63 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofit/PtProfitService.java
  50. 85 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofit/PtProfitServiceImpl.java
  51. 5 4
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogService.java
  52. 18 1
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogServiceImpl.java
  53. 19 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/sharepath/SharePathService.java
  54. 36 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/sharepath/SharePathServiceImpl.java
  55. 65 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/socialstatus/SocialStatusService.java
  56. 96 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/socialstatus/SocialStatusServiceImpl.java
  57. 23 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/socialstatuschangelog/SocialStatusChangeLogService.java
  58. 40 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/socialstatuschangelog/SocialStatusChangeLogServiceImpl.java
  59. 67 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/usertopupconsumptionpointsorder/UserTopUpConsumptionPointsOrderService.java
  60. 122 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/usertopupconsumptionpointsorder/UserTopUpConsumptionPointsOrderServiceImpl.java
  61. 6 2
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/dataobject/spuapply/SpuApplyDO.java
  62. 11 8
      feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/spuapply/SpuApplyServiceImpl.java
  63. 4 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/dataobject/order/TradeOrderItemDO.java
  64. 22 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/mq/consumer/order/OrderConsumer.java
  65. 6 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderUpdateService.java
  66. 524 4
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderUpdateServiceImpl.java
  67. 3 0
      feifan-module-pay/feifan-module-pay-api/src/main/java/cn/newfeifan/mall/module/pay/enums/DictTypeConstants.java
  68. 9 0
      feifan-module-pay/feifan-module-pay-api/src/main/java/cn/newfeifan/mall/module/pay/enums/fuyouorder/FuYouPayOrderTypeEnum.java
  69. 1 2
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/job/order/PayOrderSyncJob.java
  70. 25 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/order/TradeOrderProducer.java
  71. 6 2
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/channel/PayChannelService.java
  72. 11 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/channel/PayChannelServiceImpl.java
  73. 9 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/fuyouorder/FuYouPayOrderService.java
  74. 73 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/fuyouorder/FuYouPayOrderServiceImpl.java
  75. 1 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/order/PayOrderService.java
  76. 59 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/order/PayOrderServiceImpl.java
  77. 25 0
      feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/topupconsumptionpoints/TopUpConsumptionPointsProducer.java

+ 5 - 0
feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/constant/DistriConstants.java

@@ -10,6 +10,11 @@ public class DistriConstants {
 
     public static final Integer MILLION = 1000000;      //百万倍
 
+    public static final Long PT_ID = 1L;
+
+    public static final Boolean IS_EFFECTIVE  = true;
+
+
     // 数据库中,积分比金钱大的倍数,即钱转成积分要乘于此参数
     public static final Integer MONEY2INTEGRAL = PERCENT/100;
     // MONEY2INTEGRAL的BigDecimal版本

+ 1 - 0
feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/ConsumptionEnum.java

@@ -14,6 +14,7 @@ public enum ConsumptionEnum {
     COMMISSION_WITHDRAWAL(5,"佣金提现"),
     PAY_ORDER(6,"购物支付"),
     REFUND_ORDER(7,"退回退款返回"),
+    TOP_UP_GET(8,"充值获得"),
     ;
 
     private final Integer type;

+ 1 - 0
feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/ErrorCodeConstants.java

@@ -31,5 +31,6 @@ public interface ErrorCodeConstants {
     ErrorCode PT_DAILY_BILL_NOT_EXISTS = new ErrorCode(1_003_031_006, "平台每日账单不存在");
 
     ErrorCode CONSUMPTION_CHANGE_LOG_NOT_EXISTS = new ErrorCode(1_002_030_036, "消费分变动记录不存在");
+    ErrorCode USER_TOP_UP_CONSUMPTION_POINTS_ORDER_NOT_EXISTS = new ErrorCode(1_002_030_037, "用户充值消费订单分不存在");
 
 }

+ 34 - 0
feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/SocialStatusEnum.java

@@ -0,0 +1,34 @@
+package cn.newfeifan.mall.module.distri.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public enum SocialStatusEnum {
+
+    REGISTER_SOCIAL(1,"本人注册用户"),
+    REGISTER_ANCESTOR_SOCIAL(2,"成功推荐新用户注册"),
+    SIGN_IN_SOCIAL(3,"签到获取的基础身价值"),
+    FAVORITE_SOCIAL(4,"收藏一个商品获取的身价值"),
+    SHOPPING_SOCIAL(5,"购物自得身价值"),
+    SHOPPING_ANCESTOR_SOCIAL(6,"直推人购物,推荐人获得身价");
+
+    /**
+     * 类型
+     */
+    private final Integer status;
+    /**
+     * 类型的名字
+     */
+    private final String name;
+
+    public static SocialStatusEnum getSocialStatusEnumByCode(int status) {
+        for (SocialStatusEnum socialStatusEnum : SocialStatusEnum.values()) {
+            if (socialStatusEnum.getStatus() == status) {
+                return socialStatusEnum;
+            }
+        }
+        return null;
+    }
+}

+ 6 - 0
feifan-module-distri/feifan-module-distri-biz/pom.xml

@@ -113,5 +113,11 @@
             <groupId>cn.newfeifan.zx</groupId>
             <artifactId>feifan-spring-boot-starter-biz-ip</artifactId>
         </dependency>
+        <dependency>
+            <groupId>cn.newfeifan.zx</groupId>
+            <artifactId>feifan-module-pay-biz</artifactId>
+            <version>2.0.0-jdk8-snapshot</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 </project>

+ 29 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/duser/vo/DuserInfoVO.java

@@ -0,0 +1,29 @@
+package cn.newfeifan.mall.module.distri.controller.admin.duser.vo;
+
+import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Schema(description = "管理后台 - 用户基础信息 Request VO")
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class DuserInfoVO {
+
+
+    @Schema(description = "用户积分信息", example = "IntegralDO")
+    private IntegralDO integralDO;
+
+    @Schema(description = "用户直推人人数", example = "88")
+    private Integer descNo;
+
+    @Schema(description = "团队昨日贡献值=直推奖+合赢奖", example = "88")
+    private Long descPrice;
+
+    @Schema(description = "团队历史总贡献值=直推奖+合赢奖", example = "88")
+    private Long descTotalPrice;
+}

+ 56 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/duser/vo/DuserPageReqVO.java

@@ -0,0 +1,56 @@
+package cn.newfeifan.mall.module.distri.controller.admin.duser.vo;
+
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+import static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 推荐用户分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class DuserPageReqVO extends PageParam {
+
+    @Schema(description = "团队人员ID", example = "17459")
+    private Long userId;
+
+    @Schema(description = "团队人员姓名", example = "李四")
+    private String name;
+
+    @Schema(description = "团队人员手机号码")
+    private String mobile;
+
+    @Schema(description = "团队人员来源")
+    private Integer source;
+
+    @Schema(description = "团队用户当前积分", example = "11037")
+    private Long integralId;
+
+    @Schema(description = "团队用户当前身价id", example = "22096")
+    private Long socialStatusId;
+
+    @Schema(description = "团队用户当前点数")
+    private Long socialStatusPoint;
+
+    @Schema(description = "用户类型", example = "3773")
+    private Long categoryId;
+    @Schema(description = "身价距下一级所需点数")
+    private Long socialUpNeed;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+
+    @Schema(description = "用户名称", example = "张三")
+    private String nickName;
+
+    @Schema(description = "用户名")
+    private String username;
+}

+ 92 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/duser/vo/DuserRespVO.java

@@ -0,0 +1,92 @@
+package cn.newfeifan.mall.module.distri.controller.admin.duser.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 推荐用户 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class DuserRespVO {
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23853")
+    @ExcelProperty("用户编号")
+    private Long id;
+
+    @Schema(description = "团队人员ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17459")
+    @ExcelProperty("团队人员ID")
+    private Long userId;
+
+    @Schema(description = "团队人员姓名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
+    @ExcelProperty("团队人员姓名")
+    private String name;
+
+    @Schema(description = "团队人员手机号码", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("团队人员手机号码")
+    private String mobile;
+
+    @Schema(description = "团队人员来源")
+    @ExcelProperty("团队人员来源")
+    private Integer source;
+
+    @Schema(description = "团队用户当前积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "11037")
+    @ExcelProperty("团队用户当前积分")
+    private Long integralId;
+
+    @Schema(description = "团队用户当前身价id", example = "22096")
+    @ExcelProperty("团队用户当前身价(id)")
+    private Long socialStatusId;
+
+    @Schema(description = "团队用户当前身价等级", example = "等级1")
+    @ExcelProperty("团队用户当前身价(等级)")
+    private String socialStatusLevel;
+
+    @Schema(description = "团队用户当前身价等级名称", example = "白银")
+    @ExcelProperty("团队用户当前身价(等级)")
+    private String socialStatusLevelName;
+
+    @Schema(description = "团队用户当前点数")
+    @ExcelProperty("团队用户当前点数")
+    private Long socialStatusPoint;
+
+    @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "3773")
+    @ExcelProperty("用户类型")
+    private Long categoryId;
+    @Schema(description = "身价距下一级所需点数")
+    @ExcelProperty("身价距下一级所需点数")
+    private Long socialUpNeed;
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "用户名称", example = "张三")
+    @ExcelProperty("用户名称")
+    private String nickName;
+
+    @Schema(description = "推荐人姓名", example = "张三")
+    private String ancNickName;
+
+    @Schema(description = "直推人总数")
+    private Long descendantCount;
+
+    @Schema(description = "后代总数")
+    private Long childrenCount;
+
+    @Schema(description = "用户头像")
+    private String avatar;
+
+    @Schema(description = "用户积分")
+    private Long integral;
+
+    @Schema(description = "用户名")
+    private String username;
+
+    @Schema(description = "冻结积分")
+    private Long freezeIntegral;
+
+    @Schema(description = "推荐人用户名")
+    private String ancUsername;
+}

+ 57 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/duser/vo/DuserSaveReqVO.java

@@ -0,0 +1,57 @@
+package cn.newfeifan.mall.module.distri.controller.admin.duser.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+@Schema(description = "管理后台 - 推荐用户新增/修改 Request VO")
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class DuserSaveReqVO {
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23853")
+    private Long id;
+
+    @Schema(description = "团队人员ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "17459")
+    @NotNull(message = "团队人员ID不能为空")
+    private Long userId;
+
+    @Schema(description = "团队人员姓名", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
+    @NotEmpty(message = "团队人员姓名不能为空")
+    private String name;
+
+    @Schema(description = "团队人员手机号码", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "团队人员手机号码不能为空")
+    private String mobile;
+
+    @Schema(description = "团队人员来源")
+    private Long source;
+
+    @Schema(description = "团队用户当前积分", requiredMode = Schema.RequiredMode.REQUIRED, example = "11037")
+    @NotNull(message = "团队用户当前积分不能为空")
+    private Long integralId;
+
+    @Schema(description = "团队用户当前身价id", example = "22096")
+    private Long socialStatusId;
+
+    @Schema(description = "团队用户当前点数")
+    private Long socialStatusPoint;
+
+    @Schema(description = "身价距下一级所需点数")
+    private Long socialUpNeed;
+
+    @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "3773")
+    @NotNull(message = "用户类型不能为空")
+    private Long categoryId;
+
+    @Schema(description = "用户名称", example = "张三")
+    private String nickName;
+
+}

+ 56 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/integral/vo/IntegralPageReqVO.java

@@ -0,0 +1,56 @@
+package cn.newfeifan.mall.module.distri.controller.admin.integral.vo;
+
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+import static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 推荐用户积分分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class IntegralPageReqVO extends PageParam {
+
+    @Schema(description = "用户ID", example = "19778")
+    private Long userId;
+
+    @Schema(description = "用户类型", example = "17348")
+    private Long categoryId;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    @Schema(description = "用户名称", example = "赵六")
+    private String name;
+
+    @Schema(description = "用户昵称", example = "赵六")
+    private String nickName;
+
+    @Schema(description = "当前积分")
+    private Long currentQuota;
+
+    @Schema(description = "冻结积分")
+    private Long freezeQuota;
+
+    @Schema(description = "合赢奖累计获取积分")
+    private Long accumulatedQuota;
+
+    @Schema(description = "直推奖累计获取积分")
+    private Long ancestorQuota;
+
+    @Schema(description = "最高可获取积分")
+    private Long highQuota;
+
+    @Schema(description = "累计获取的峰值")
+    private Long highQuotaTotal;
+
+    @Schema(description = "当前消费分")
+    private Long consumptionPoints;
+}

+ 66 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/integral/vo/IntegralRespVO.java

@@ -0,0 +1,66 @@
+package cn.newfeifan.mall.module.distri.controller.admin.integral.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 推荐用户积分 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class IntegralRespVO {
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19201")
+    @ExcelProperty("用户编号")
+    private Long id;
+
+    @Schema(description = "用户ID", example = "19778")
+    @ExcelProperty("用户ID")
+    private Long userId;
+
+    @Schema(description = "用户类型", example = "17348")
+    @ExcelProperty("用户类型")
+    private Long categoryId;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "用户名称", example = "赵六")
+    @ExcelProperty("用户名称")
+    private String name;
+
+    @Schema(description = "用户昵称", example = "赵六")
+    @ExcelProperty("用户昵称")
+    private String nickName;
+
+    @Schema(description = "当前积分", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("当前积分")
+    private Long currentQuota;
+
+    @Schema(description = "冻结积分")
+    @ExcelProperty("冻结积分")
+    private Long freezeQuota;
+
+    @Schema(description = "合赢奖累计获取积分")
+    @ExcelProperty("合赢奖累计获取积分")
+    private Long accumulatedQuota;
+
+    @Schema(description = "直推奖累计获取积分")
+    @ExcelProperty("直推奖累计获取积分")
+    private Long ancestorQuota;
+
+    @Schema(description = "最高可获取积分", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("最高可获取积分")
+    private Long highQuota;
+
+    @Schema(description = "累计获取的峰值")
+    @ExcelProperty("累计获取的峰值")
+    private Long highQuotaTotal;
+
+    @Schema(description = "当前消费分", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("当前消费分")
+    private Long consumptionPoints;
+}

+ 58 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/integral/vo/IntegralSaveReqVO.java

@@ -0,0 +1,58 @@
+package cn.newfeifan.mall.module.distri.controller.admin.integral.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotNull;
+
+
+@Schema(description = "管理后台 - 推荐用户积分新增/修改 Request VO")
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class IntegralSaveReqVO {
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19201")
+    private Long id;
+
+    @Schema(description = "用户ID", example = "19778")
+    private Long userId;
+
+    @Schema(description = "用户类型", example = "17348")
+    private Long categoryId;
+
+    @Schema(description = "用户名称", example = "赵六")
+    private String name;
+
+    @Schema(description = "用户昵称", example = "赵六")
+    private String nickName;
+
+    @Schema(description = "当前积分", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "当前积分不能为空")
+    private Long currentQuota;
+
+    @Schema(description = "冻结积分")
+    private Long freezeQuota;
+
+    @Schema(description = "合赢奖累计获取积分")
+    private Long accumulatedQuota;
+
+    @Schema(description = "直推奖累计获取积分")
+    private Long ancestorQuota;
+
+    @Schema(description = "最高可获取积分", requiredMode = Schema.RequiredMode.REQUIRED)
+    private Long highQuota;
+
+    @Schema(description = "冻结的最高可获取积分", requiredMode = Schema.RequiredMode.REQUIRED)
+    private Long freezeHighQuota;
+
+    @Schema(description = "累计获取的峰值")
+    private Long highQuotaTotal;
+
+    @Schema(description = "当前消费分", requiredMode = Schema.RequiredMode.REQUIRED)
+    private Long consumptionPoints;
+}

+ 36 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofit/vo/PtProfitPageReqVO.java

@@ -0,0 +1,36 @@
+package cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo;
+
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+import static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 平台利润分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class PtProfitPageReqVO extends PageParam {
+
+    @Schema(description = "平台服务费(毛利下的百分比收益)")
+    private Long ptAdd;
+
+    @Schema(description = "平台收益(0.3888 之外的收益)")
+    private Long ptGrossAdd;
+
+    @Schema(description = "平台总收益")
+    private Long ptTotalAdd;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    @Schema(description = "利润")
+    private Long profit;
+
+}

+ 38 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofit/vo/PtProfitRespVO.java

@@ -0,0 +1,38 @@
+package cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 平台利润 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class PtProfitRespVO {
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24754")
+    @ExcelProperty("用户编号")
+    private Long id;
+
+    @Schema(description = "平台服务费(毛利下的百分比收益)")
+    @ExcelProperty("平台服务费(毛利下的百分比收益)")
+    private Long ptAdd;
+
+    @Schema(description = "平台收益(0.3888 之外的收益)")
+    @ExcelProperty("平台收益(0.3888 之外的收益)")
+    private Long ptGrossAdd;
+
+    @Schema(description = "平台总收益")
+    @ExcelProperty("平台总收益")
+    private Long ptTotalAdd;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "利润", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("利润")
+    private Long profit;
+}

+ 31 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofit/vo/PtProfitSaveReqVO.java

@@ -0,0 +1,31 @@
+package cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+
+@Schema(description = "管理后台 - 平台利润新增/修改 Request VO")
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class PtProfitSaveReqVO {
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24754")
+    private Long id;
+
+    @Schema(description = "平台服务费(毛利下的百分比收益)")
+    private Long ptAdd;
+
+    @Schema(description = "平台收益(0.3888 之外的收益)")
+    private Long ptGrossAdd;
+
+    @Schema(description = "平台总收益")
+    private Long ptTotalAdd;
+
+    @Schema(description = "利润", requiredMode = Schema.RequiredMode.REQUIRED)
+    private Long profit;
+}

+ 54 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/vo/SharePathPageReqVO.java

@@ -0,0 +1,54 @@
+package cn.newfeifan.mall.module.distri.controller.admin.sharepath.vo;
+
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+import static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 分销用户关系分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class SharePathPageReqVO extends PageParam {
+
+    @Schema(description = "层级")
+    private Integer depth;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    @Schema(description = "推荐人")
+    private Long ancestor;
+
+    @Schema(description = "直推人")
+    private Long descendant;
+
+    @Schema(description = "顺序")
+    private Integer sort;
+
+
+    @Schema(description = "推荐人姓名", example = "王五")
+    private String ancName;
+
+    @Schema(description = "推荐人手机号")
+    private String ancPhone;
+
+    @Schema(description = "直推人姓名", example = "李四")
+    private String descName;
+
+    @Schema(description = "推荐人手机号")
+    private String descPhone;
+
+    @Schema(description = "直推人昵称", example = "张三")
+    private String descNickName;
+    @Schema(description = "推荐人昵称", example = "非繁人")
+    private String ancNickName;
+
+}

+ 66 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/vo/SharePathRespVO.java

@@ -0,0 +1,66 @@
+package cn.newfeifan.mall.module.distri.controller.admin.sharepath.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 分销用户关系 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class SharePathRespVO {
+
+    @Schema(description = "层级")
+    @ExcelProperty("层级")
+    private Integer depth;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12537")
+    @ExcelProperty("id")
+    private Long id;
+
+    @Schema(description = "推荐人")
+    @ExcelProperty("推荐人")
+    private Long ancestor;
+
+    @Schema(description = "直推人")
+    @ExcelProperty("直推人")
+    private Long descendant;
+
+    @Schema(description = "顺序")
+    @ExcelProperty("顺序")
+    private Integer sort;
+
+
+    @Schema(description = "推荐人姓名", example = "王五")
+    @ExcelProperty("推荐人姓名")
+    private String ancName;
+
+    @Schema(description = "推荐人手机号")
+    @ExcelProperty("推荐人手机号")
+    private String ancPhone;
+
+    @Schema(description = "直推人姓名", example = "李四")
+    @ExcelProperty("直推人姓名")
+    private String descName;
+
+    @Schema(description = "推荐人手机号")
+    @ExcelProperty("推荐人手机号")
+    private String descPhone;
+
+    @Schema(description = "推荐人昵称", example = "非繁人")
+    @ExcelProperty("推荐人昵称")
+    private String ancNickName;
+
+    @Schema(description = "直推人昵称", example = "张三")
+    @ExcelProperty("直推人昵称")
+    private String descNickName;
+
+    @Schema(description = "用户头像")
+    private String avatar;
+}

+ 50 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/vo/SharePathSaveReqVO.java

@@ -0,0 +1,50 @@
+package cn.newfeifan.mall.module.distri.controller.admin.sharepath.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Schema(description = "管理后台 - 分销用户关系新增/修改 Request VO")
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SharePathSaveReqVO {
+
+    @Schema(description = "层级")
+    private Integer depth;
+
+    @Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12537")
+    private Long id;
+
+    @Schema(description = "推荐人")
+    private Long ancestor;
+
+    @Schema(description = "直推人")
+    private Long descendant;
+
+    @Schema(description = "顺序")
+    private Integer sort;
+
+    @Schema(description = "链接来源")
+    private Long source;
+
+
+    @Schema(description = "推荐人姓名", example = "王五")
+    private String ancName;
+
+    @Schema(description = "推荐人手机号")
+    private String ancPhone;
+
+    @Schema(description = "直推人姓名", example = "李四")
+    private String descName;
+
+    @Schema(description = "推荐人手机号")
+    private String descPhone;
+    @Schema(description = "推荐人昵称", example = "非繁人")
+    private String ancNickName;
+    @Schema(description = "直推人昵称", example = "张三")
+    private String descNickName;
+}

+ 22 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/vo/SharePathTreeReqVO.java

@@ -0,0 +1,22 @@
+package cn.newfeifan.mall.module.distri.controller.admin.sharepath.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.ToString;
+
+import javax.validation.constraints.NotNull;
+
+@Schema(description = "管理后台 - 分销用户关系树 Request VO")
+@Data
+@ToString(callSuper = true)
+public class SharePathTreeReqVO {
+    @Schema(description = "名称")
+    private String nickName;
+
+    @Schema(description = "电话")
+    private String mobile;
+
+    @Schema(description = "最大层级")
+    @NotNull(message = "最大层级不能为空")
+    private Integer maxDepth;
+}

+ 18 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/vo/SharePathtransFerenceRelaReqVO.java

@@ -0,0 +1,18 @@
+package cn.newfeifan.mall.module.distri.controller.admin.sharepath.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Schema(description = "管理后台 - 分销用户关系转让 Request VO")
+@Data
+public class SharePathtransFerenceRelaReqVO {
+
+
+    @Schema(description = "转让人")
+    private Long ancestor;
+
+    @Schema(description = "被转让人")
+    private Long descendant;
+
+
+}

+ 32 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/sharepath/vo/TreeNode.java

@@ -0,0 +1,32 @@
+package cn.newfeifan.mall.module.distri.controller.admin.sharepath.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class TreeNode {
+    private Long userId;
+    private String name; // 节点名称
+    private String nickname;
+    private String phone;
+    private Integer deep;
+    private Integer value; // 节点值,某些节点可能没有值
+    private Long parentId; // 父亲Id
+    private Boolean hasSon;
+    private Integer sort;
+    private List<TreeNode> children; // 子节点列表
+
+    public Boolean getHasSon() {
+        if (children == null) {
+            return false;
+        }
+        return !children.isEmpty();
+    }
+}

+ 15 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatus/bo/SocialStatusBO.java

@@ -0,0 +1,15 @@
+package cn.newfeifan.mall.module.distri.controller.admin.socialstatus.bo;
+
+import lombok.Builder;
+import lombok.Data;
+
+/**
+ * 身价状态业务对象
+ * 用于封装与社交状态相关的业务数据
+ */
+@Data
+@Builder
+public class SocialStatusBO {
+    private Long id; // 主键ID
+    private Long socialUpNeed; // 身价升级需求值
+}

+ 33 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatus/vo/SocialStatusPageReqVO.java

@@ -0,0 +1,33 @@
+package cn.newfeifan.mall.module.distri.controller.admin.socialstatus.vo;
+
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+import static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 分销用户身价分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class SocialStatusPageReqVO extends PageParam {
+
+    @Schema(description = "身价等级")
+    private String level;
+
+    @Schema(description = "身价名称", example = "芋艿")
+    private String name;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    @Schema(description = "升级所需点数")
+    private Long point;
+
+}

+ 35 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatus/vo/SocialStatusRespVO.java

@@ -0,0 +1,35 @@
+package cn.newfeifan.mall.module.distri.controller.admin.socialstatus.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 分销用户身价 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class SocialStatusRespVO {
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19722")
+    @ExcelProperty("用户编号")
+    private Long id;
+
+    @Schema(description = "身价等级")
+    @ExcelProperty("身价等级")
+    private String level;
+
+    @Schema(description = "身价名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
+    @ExcelProperty("身价名称")
+    private String name;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "升级所需点数")
+    @ExcelProperty("升级所需点数")
+    private Long point;
+
+}

+ 33 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatus/vo/SocialStatusSaveReqVO.java

@@ -0,0 +1,33 @@
+package cn.newfeifan.mall.module.distri.controller.admin.socialstatus.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotEmpty;
+
+@Schema(description = "管理后台 - 分销用户身价新增/修改 Request VO")
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SocialStatusSaveReqVO {
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19722")
+    private Long id;
+
+    @Schema(description = "身价等级")
+    private String level;
+
+    @Schema(description = "身价名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
+    @NotEmpty(message = "身价名称不能为空")
+    private String name;
+
+    @Schema(description = "升级所需点数")
+    private Long point;
+
+
+
+}

+ 50 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatuschangelog/vo/SocialStatusChangeLogPageReqVO.java

@@ -0,0 +1,50 @@
+package cn.newfeifan.mall.module.distri.controller.admin.socialstatuschangelog.vo;
+
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+import static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 会员身价变化日志分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class SocialStatusChangeLogPageReqVO extends PageParam {
+
+    @Schema(description = "会员资产变化类别id", example = "8042")
+    private Long socialStatusChangeCategoryId;
+
+    @Schema(description = "身价点数在本类别操作的变化值")
+    private Long variationValue;
+
+    @Schema(description = "操作对应业务对象id,例如订单id", example = "24060")
+    private Long objectId;
+
+    @Schema(description = "是否已生效")
+    private Boolean effective;
+
+    @Schema(description = "描述", example = "随便")
+    private String description;
+
+    @Schema(description = "计划生效时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] planEffectiveTime;
+
+    @Schema(description = "实际生效时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] actualEffectiveTime;
+
+    @Schema(description = "操作时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    @Schema(description = "用户ID", example = "4593")
+    private Long userId;
+
+}

+ 55 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatuschangelog/vo/SocialStatusChangeLogRespVO.java

@@ -0,0 +1,55 @@
+package cn.newfeifan.mall.module.distri.controller.admin.socialstatuschangelog.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 会员身价变化日志 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class SocialStatusChangeLogRespVO {
+
+    @Schema(description = "会员身价变化日志id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27452")
+    @ExcelProperty("会员身价变化日志id")
+    private Long id;
+
+    @Schema(description = "会员资产变化类别id", requiredMode = Schema.RequiredMode.REQUIRED, example = "8042")
+    @ExcelProperty("会员资产变化类别id")
+    private Long socialStatusChangeCategoryId;
+
+    @Schema(description = "身价点数在本类别操作的变化值", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("身价点数在本类别操作的变化值")
+    private Long variationValue;
+
+    @Schema(description = "操作对应业务对象id,例如订单id", requiredMode = Schema.RequiredMode.REQUIRED, example = "24060")
+    @ExcelProperty("操作对应业务对象id,例如订单id")
+    private Long objectId;
+
+    @Schema(description = "是否已生效", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("是否已生效")
+    private Boolean effective;
+
+    @Schema(description = "描述", example = "随便")
+    @ExcelProperty("描述")
+    private String description;
+
+    @Schema(description = "计划生效时间")
+    @ExcelProperty("计划生效时间")
+    private LocalDateTime planEffectiveTime;
+
+    @Schema(description = "实际生效时间")
+    @ExcelProperty("实际生效时间")
+    private LocalDateTime actualEffectiveTime;
+
+    @Schema(description = "操作时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("操作时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4593")
+    @ExcelProperty("用户ID")
+    private Long userId;
+
+}

+ 44 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatuschangelog/vo/SocialStatusChangeLogSaveReqVO.java

@@ -0,0 +1,44 @@
+package cn.newfeifan.mall.module.distri.controller.admin.socialstatuschangelog.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 会员身价变化日志新增/修改 Request VO")
+@Data
+public class SocialStatusChangeLogSaveReqVO {
+
+    @Schema(description = "会员身价变化日志id", requiredMode = Schema.RequiredMode.REQUIRED, example = "27452")
+    private Long id;
+
+    @Schema(description = "会员资产变化类别id", requiredMode = Schema.RequiredMode.REQUIRED, example = "8042")
+    @NotNull(message = "会员资产变化类别id不能为空")
+    private Long socialStatusChangeCategoryId;
+
+    @Schema(description = "身价点数在本类别操作的变化值", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "身价点数在本类别操作的变化值不能为空")
+    private Long variationValue;
+
+    @Schema(description = "操作对应业务对象id,例如订单id", requiredMode = Schema.RequiredMode.REQUIRED, example = "24060")
+    @NotNull(message = "操作对应业务对象id,例如订单id不能为空")
+    private Long objectId;
+
+    @Schema(description = "是否已生效", requiredMode = Schema.RequiredMode.REQUIRED)
+    private Boolean effective;
+
+    @Schema(description = "描述", example = "随便")
+    private String description;
+
+    @Schema(description = "计划生效时间")
+    private LocalDateTime planEffectiveTime;
+
+    @Schema(description = "实际生效时间")
+    private LocalDateTime actualEffectiveTime;
+
+    @Schema(description = "用户ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4593")
+    @NotNull(message = "用户ID不能为空")
+    private Long userId;
+
+}

+ 26 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/socialstatuschangelog/vo/UserSignSocialLogRespVO.java

@@ -0,0 +1,26 @@
+package cn.newfeifan.mall.module.distri.controller.admin.socialstatuschangelog.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+import static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 会员签到身价变化日志分页 Request VO")
+@Data
+public class UserSignSocialLogRespVO {
+    @Schema(description = "编号", example = "8042")
+    private Long id;
+
+    @Schema(description = "身价点数在本类别操作的变化值")
+    private Long variationValue;
+
+    @Schema(description = "操作时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime createTime;
+
+    @Schema(description = "排序", example = "1")
+    private Integer sort;
+}

+ 75 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/usertopupconsumptionpointsorder/vo/UserTopUpConsumptionPointsOrderPageReqVO.java

@@ -0,0 +1,75 @@
+package cn.newfeifan.mall.module.distri.controller.admin.usertopupconsumptionpointsorder.vo;
+
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+import static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 用户充值消费分订单分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class UserTopUpConsumptionPointsOrderPageReqVO extends PageParam {
+
+    @Schema(description = "订单流水号")
+    private String no;
+
+    @Schema(description = "订单来源终端")
+    private Integer terminal;
+
+    @Schema(description = "用户编号", example = "29707")
+    private Long userId;
+
+    @Schema(description = "用户 IP")
+    private String userIp;
+
+    @Schema(description = "商品标题")
+    private String subject;
+
+    @Schema(description = "充值消费分")
+    private Long topUpConsumptionPoints;
+
+    @Schema(description = "到账消费分")
+    private Long practicalConsumptionPoints;
+
+    @Schema(description = "用户名", example = "李四")
+    private String userName;
+
+    @Schema(description = "支付订单编号", example = "9840")
+    private Long payOrderId;
+
+    @Schema(description = "是否已支付:[0:未支付 1:已经支付过]", example = "2")
+    private Boolean payStatus;
+
+    @Schema(description = "订单支付时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] payTime;
+
+    @Schema(description = "支付成功的支付渠道")
+    private String payChannelCode;
+
+    @Schema(description = "订单完成时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] finishTime;
+
+    @Schema(description = "订单取消时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] cancelTime;
+
+    @Schema(description = "应付金额(总),单位:分", example = "5880")
+    private Integer payPrice;
+
+    @Schema(description = "计算百分比模板")
+    private String percentTemplate;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}

+ 87 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/usertopupconsumptionpointsorder/vo/UserTopUpConsumptionPointsOrderRespVO.java

@@ -0,0 +1,87 @@
+package cn.newfeifan.mall.module.distri.controller.admin.usertopupconsumptionpointsorder.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 用户充值消费分订单 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class UserTopUpConsumptionPointsOrderRespVO {
+
+    @Schema(description = "用户充值消费分订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3828")
+    @ExcelProperty("用户充值消费分订单编号")
+    private Long id;
+
+    @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("订单流水号")
+    private String no;
+
+    @Schema(description = "订单来源终端", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("订单来源终端")
+    private Integer terminal;
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29707")
+    @ExcelProperty("用户编号")
+    private Long userId;
+
+    @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("用户 IP")
+    private String userIp;
+
+    @Schema(description = "商品标题", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("商品标题")
+    private String subject;
+
+    @Schema(description = "充值消费分", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("充值消费分")
+    private Long topUpConsumptionPoints;
+
+    @Schema(description = "到账消费分", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("到账消费分")
+    private Long practicalConsumptionPoints;
+
+    @Schema(description = "用户名", example = "李四")
+    @ExcelProperty("用户名")
+    private String userName;
+
+    @Schema(description = "支付订单编号", example = "9840")
+    @ExcelProperty("支付订单编号")
+    private Long payOrderId;
+
+    @Schema(description = "是否已支付:[0:未支付 1:已经支付过]", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
+    @ExcelProperty("是否已支付:[0:未支付 1:已经支付过]")
+    private Boolean payStatus;
+
+    @Schema(description = "订单支付时间")
+    @ExcelProperty("订单支付时间")
+    private LocalDateTime payTime;
+
+    @Schema(description = "支付成功的支付渠道")
+    @ExcelProperty("支付成功的支付渠道")
+    private String payChannelCode;
+
+    @Schema(description = "订单完成时间")
+    @ExcelProperty("订单完成时间")
+    private LocalDateTime finishTime;
+
+    @Schema(description = "订单取消时间")
+    @ExcelProperty("订单取消时间")
+    private LocalDateTime cancelTime;
+
+    @Schema(description = "应付金额(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5880")
+    @ExcelProperty("应付金额(总),单位:分")
+    private Integer payPrice;
+
+    @Schema(description = "计算百分比模板")
+    @ExcelProperty("计算百分比模板")
+    private String percentTemplate;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+}

+ 74 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/usertopupconsumptionpointsorder/vo/UserTopUpConsumptionPointsOrderSaveReqVO.java

@@ -0,0 +1,74 @@
+package cn.newfeifan.mall.module.distri.controller.admin.usertopupconsumptionpointsorder.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 用户充值消费分订单新增/修改 Request VO")
+@Data
+public class UserTopUpConsumptionPointsOrderSaveReqVO {
+
+    @Schema(description = "用户充值消费分订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3828")
+    private Long id;
+
+    @Schema(description = "订单流水号", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "订单流水号不能为空")
+    private String no;
+
+    @Schema(description = "订单来源终端", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "订单来源终端不能为空")
+    private Integer terminal;
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "29707")
+    @NotNull(message = "用户编号不能为空")
+    private Long userId;
+
+    @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "用户 IP不能为空")
+    private String userIp;
+
+    @Schema(description = "商品标题", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "商品标题不能为空")
+    private String subject;
+
+    @Schema(description = "充值消费分", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "充值消费分不能为空")
+    private Long topUpConsumptionPoints;
+
+    @Schema(description = "到账消费分", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "到账消费分不能为空")
+    private Long practicalConsumptionPoints;
+
+    @Schema(description = "用户名", example = "李四")
+    private String userName;
+
+    @Schema(description = "支付订单编号", example = "9840")
+    private Long payOrderId;
+
+    @Schema(description = "是否已支付:[0:未支付 1:已经支付过]", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
+    @NotNull(message = "是否已支付:[0:未支付 1:已经支付过]不能为空")
+    private Boolean payStatus;
+
+    @Schema(description = "订单支付时间")
+    private LocalDateTime payTime;
+
+    @Schema(description = "支付成功的支付渠道")
+    private String payChannelCode;
+
+    @Schema(description = "订单完成时间")
+    private LocalDateTime finishTime;
+
+    @Schema(description = "订单取消时间")
+    private LocalDateTime cancelTime;
+
+    @Schema(description = "应付金额(总),单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "5880")
+    @NotNull(message = "应付金额(总),单位:分不能为空")
+    private Integer payPrice;
+
+    @Schema(description = "计算百分比模板")
+    private String percentTemplate;
+
+}

+ 4 - 3
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/duser/DuserDO.java

@@ -1,9 +1,6 @@
 package cn.newfeifan.mall.module.distri.dal.dataobject.duser;
 
 import lombok.*;
-import java.util.*;
-import java.time.LocalDateTime;
-import java.time.LocalDateTime;
 import com.baomidou.mybatisplus.annotation.*;
 import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
 
@@ -51,6 +48,10 @@ public class DuserDO extends BaseDO {
      * 团队用户当前身价(等级)
      */
     private Integer socialStatus;
+    /**
+     * 团队用户当前身价id
+     */
+    private Long socialStatusId;
     /**
      * 团队用户当前点数
      */

+ 69 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/sharepath/SharePathDO.java

@@ -0,0 +1,69 @@
+package cn.newfeifan.mall.module.distri.dal.dataobject.sharepath;
+
+import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+/**
+ * 分销用户关系 DO
+ *
+ * @author 非繁人
+ */
+@TableName("distri_share_path")
+@KeySequence("distri_share_path_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SharePathDO extends BaseDO {
+
+    /**
+     * 层级
+     */
+    private Integer depth;
+    /**
+     * id
+     */
+    @TableId
+    private Long id;
+    /**
+     * 推荐人
+     */
+    private Long ancestor;
+    /**
+     * 直推人
+     */
+    private Long descendant;
+    /**
+     * 顺序
+     */
+    private Integer sort;
+    /**
+     * 推荐人姓名
+     */
+    private String ancName;
+    /**
+     * 推荐人手机号
+     */
+    private String ancPhone;
+    /**
+     * 直推人姓名
+     */
+    private String descName;
+    /**
+     * 推荐人手机号
+     */
+    private String descPhone;
+    /**
+     * 直推人昵称
+     */
+    private String descNickName;
+    /**
+     * 推荐人昵称
+     */
+    private String ancNickName;
+}

+ 43 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/socialstatus/SocialStatusDO.java

@@ -0,0 +1,43 @@
+package cn.newfeifan.mall.module.distri.dal.dataobject.socialstatus;
+
+import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+/**
+ * 分销用户身价 DO
+ *
+ * @author 非繁人
+ */
+@TableName("distri_social_status")
+@KeySequence("distri_social_status_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SocialStatusDO extends BaseDO {
+
+    /**
+     * 用户编号
+     */
+    @TableId
+    private Long id;
+    /**
+     * 身价等级
+     */
+    private String level;
+    /**
+     * 身价名称
+     */
+    private String name;
+    /**
+     * 升级所需点数
+     */
+    private Long point;
+
+
+}

+ 64 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/socialstatuschangelog/SocialStatusChangeLogDO.java

@@ -0,0 +1,64 @@
+package cn.newfeifan.mall.module.distri.dal.dataobject.socialstatuschangelog;
+
+import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+import java.time.LocalDateTime;
+
+/**
+ * 会员身价变化日志 DO
+ *
+ * @author 非繁人
+ */
+@TableName("distri_social_status_change_log")
+@KeySequence("distri_social_status_change_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class SocialStatusChangeLogDO extends BaseDO {
+
+    /**
+     * 会员身价变化日志id
+     */
+    @TableId
+    private Long id;
+    /**
+     * 会员资产变化类别id
+     */
+    private Long socialStatusChangeCategoryId;
+    /**
+     * 身价点数在本类别操作的变化值
+     */
+    private Long variationValue;
+    /**
+     * 操作对应业务对象id,例如订单id
+     */
+    private Long objectId;
+    /**
+     * 是否已生效
+     */
+    private Boolean effective;
+    /**
+     * 描述
+     */
+    private String description;
+    /**
+     * 计划生效时间
+     */
+    private LocalDateTime planEffectiveTime;
+    /**
+     * 实际生效时间
+     */
+    private LocalDateTime actualEffectiveTime;
+    /**
+     * 用户ID
+     */
+    private Long userId;
+
+}

+ 96 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/usertopupconsumptionpointsorder/UserTopUpConsumptionPointsOrderDO.java

@@ -0,0 +1,96 @@
+package cn.newfeifan.mall.module.distri.dal.dataobject.usertopupconsumptionpointsorder;
+
+import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+import java.time.LocalDateTime;
+
+/**
+ * 用户充值消费分订单 DO
+ *
+ * @author 非繁人
+ */
+@TableName("distri_user_top_up_consumption_points_order")
+@KeySequence("distri_user_top_up_consumption_points_order_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class UserTopUpConsumptionPointsOrderDO extends BaseDO {
+
+    /**
+     * 用户充值消费分订单编号
+     */
+    @TableId
+    private Long id;
+    /**
+     * 订单流水号
+     */
+    private String no;
+    /**
+     * 订单来源终端
+     */
+    private Integer terminal;
+    /**
+     * 用户编号
+     */
+    private Long userId;
+    /**
+     * 用户 IP
+     */
+    private String userIp;
+    /**
+     * 商品标题
+     */
+    private String subject;
+    /**
+     * 充值消费分
+     */
+    private Long topUpConsumptionPoints;
+    /**
+     * 到账消费分
+     */
+    private Long practicalConsumptionPoints;
+    /**
+     * 用户名
+     */
+    private String userName;
+    /**
+     * 支付订单编号
+     */
+    private Long payOrderId;
+    /**
+     * 是否已支付:[0:未支付 1:已经支付过]
+     */
+    private Boolean payStatus;
+    /**
+     * 订单支付时间
+     */
+    private LocalDateTime payTime;
+    /**
+     * 支付成功的支付渠道
+     */
+    private String payChannelCode;
+    /**
+     * 订单完成时间
+     */
+    private LocalDateTime finishTime;
+    /**
+     * 订单取消时间
+     */
+    private LocalDateTime cancelTime;
+    /**
+     * 应付金额(总),单位:分
+     */
+    private Integer payPrice;
+    /**
+     * 计算百分比模板
+     */
+    private String percentTemplate;
+
+}

+ 36 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/duser/DuserMapper.java

@@ -0,0 +1,36 @@
+package cn.newfeifan.mall.module.distri.dal.mysql.duser;
+
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.module.distri.controller.admin.duser.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.duser.DuserDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 推荐用户 Mapper
+ *
+ * @author 非繁人
+ */
+@Mapper
+public interface DuserMapper extends BaseMapperX<DuserDO> {
+
+
+    default PageResult<DuserDO> selectPage(DuserPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<DuserDO>()
+                .eqIfPresent(DuserDO::getUserId, reqVO.getUserId())
+                .likeIfPresent(DuserDO::getName, reqVO.getName())
+                .eqIfPresent(DuserDO::getMobile, reqVO.getMobile())
+                .eqIfPresent(DuserDO::getIntegralId, reqVO.getIntegralId())
+                .eqIfPresent(DuserDO::getSocialStatusId, reqVO.getSocialStatusId())
+                .eqIfPresent(DuserDO::getSocialStatusPoint, reqVO.getSocialStatusPoint())
+                .betweenIfPresent(DuserDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(DuserDO::getSource, reqVO.getSource())
+                .eqIfPresent(DuserDO::getSocialUpNeed, reqVO.getSocialUpNeed())
+                .eqIfPresent(DuserDO::getCategoryId, reqVO.getCategoryId())
+                .likeIfPresent(DuserDO::getNickName, reqVO.getNickName())
+                .orderByAsc(DuserDO::getId));
+    }
+    int hasParent(Long userId);
+}

+ 11 - 8
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ptprofit/PtProfitMapper.java

@@ -1,6 +1,9 @@
 package cn.newfeifan.mall.module.distri.dal.mysql.ptprofit;
 
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
 import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo.PtProfitPageReqVO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofit.PtProfitDO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -17,14 +20,14 @@ import java.util.Map;
 @Mapper
 public interface PtProfitMapper extends BaseMapperX<PtProfitDO> {
 
-//    default PageResult<PtProfitDO> selectPage(PtProfitPageReqVO reqVO) {
-//        return selectPage(reqVO, new LambdaQueryWrapperX<PtProfitDO>()
-//                .eqIfPresent(PtProfitDO::getPtAdd, reqVO.getPtAdd())
-//                .eqIfPresent(PtProfitDO::getPtGrossAdd, reqVO.getPtGrossAdd())
-//                .eqIfPresent(PtProfitDO::getPtTotalAdd, reqVO.getPtTotalAdd())
-//                .betweenIfPresent(PtProfitDO::getCreateTime, reqVO.getCreateTime())
-//                .orderByDesc(PtProfitDO::getId));
-//    }
+    default PageResult<PtProfitDO> selectPage(PtProfitPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<PtProfitDO>()
+                .eqIfPresent(PtProfitDO::getPtAdd, reqVO.getPtAdd())
+                .eqIfPresent(PtProfitDO::getPtGrossAdd, reqVO.getPtGrossAdd())
+                .eqIfPresent(PtProfitDO::getPtTotalAdd, reqVO.getPtTotalAdd())
+                .betweenIfPresent(PtProfitDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(PtProfitDO::getId));
+    }
 
     @Update("UPDATE distri_integral SET current_quota = current_quota + #{amount},freeze_quota = freeze_quota + #{freeze_mount} WHERE (current_quota + #{amount2})>=0 and user_id=#{userId} and (freeze_quota + #{freeze_mount2})>=0 ")
     int updateUserIntegral(@Param("amount") Long amount,

+ 60 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/sharepath/SharePathMapper.java

@@ -0,0 +1,60 @@
+package cn.newfeifan.mall.module.distri.dal.mysql.sharepath;
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.module.distri.controller.admin.sharepath.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.sharepath.SharePathDO;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 分销用户关系 Mapper
+ *
+ * @author 非繁人
+ */
+@Mapper
+public interface SharePathMapper extends BaseMapperX<SharePathDO> {
+
+    default PageResult<SharePathDO> selectPage(SharePathPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<SharePathDO>()
+                .eqIfPresent(SharePathDO::getDepth, reqVO.getDepth())
+                .betweenIfPresent(SharePathDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(SharePathDO::getAncestor, reqVO.getAncestor())
+                .eqIfPresent(SharePathDO::getDescendant, reqVO.getDescendant())
+                .eqIfPresent(SharePathDO::getSort, reqVO.getSort())
+                .likeIfPresent(SharePathDO::getAncName, reqVO.getAncName())
+                .eqIfPresent(SharePathDO::getAncPhone, reqVO.getAncPhone())
+                .likeIfPresent(SharePathDO::getDescName, reqVO.getDescName())
+                .eqIfPresent(SharePathDO::getDescPhone, reqVO.getDescPhone())
+                .likeIfPresent(SharePathDO::getAncNickName, reqVO.getAncNickName())
+                .likeIfPresent(SharePathDO::getDescNickName, reqVO.getDescNickName())
+                .orderByDesc(SharePathDO::getId));
+    }
+
+    void addNode(@Param("parentId") Long parentId,
+                 @Param("parentName") String parentName,
+                 @Param("parentNickName") String parentNickName,
+                 @Param("parentMobile") String parentMobile,
+
+                 @Param("newDescendantId") Long newDescendantId,
+                 @Param("newDescendantName") String newDescendantName,
+                 @Param("newDescendantNickName") String newDescendantNickName,
+                 @Param("newDescendantMobile") String newDescendantMobile);
+
+
+    int getMaxSortByParentId(@Param("parentId") Long parentId);
+
+    // 删除节点及其子节点的旧祖先关系
+    void deleteOldAncestors(@Param("nodeId") Long nodeId);
+
+    // 添加节点及其子节点的新祖先关系
+    void addNewAncestors(@Param("nodeId") Long nodeId, @Param("newParentId") Long newParentId);
+
+}
+
+
+
+

+ 27 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/socialstatus/SocialStatusMapper.java

@@ -0,0 +1,27 @@
+package cn.newfeifan.mall.module.distri.dal.mysql.socialstatus;
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.module.distri.controller.admin.socialstatus.vo.SocialStatusPageReqVO;
+import cn.newfeifan.mall.module.distri.dal.dataobject.socialstatus.SocialStatusDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 分销用户身价 Mapper
+ *
+ * @author 非繁人
+ */
+@Mapper
+public interface SocialStatusMapper extends BaseMapperX<SocialStatusDO> {
+
+    default PageResult<SocialStatusDO> selectPage(SocialStatusPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<SocialStatusDO>()
+                .eqIfPresent(SocialStatusDO::getLevel, reqVO.getLevel())
+                .likeIfPresent(SocialStatusDO::getName, reqVO.getName())
+                .betweenIfPresent(SocialStatusDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(SocialStatusDO::getPoint, reqVO.getPoint())
+                .orderByDesc(SocialStatusDO::getId));
+    }
+
+}

+ 42 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/socialstatuschangelog/SocialStatusChangeLogMapper.java

@@ -0,0 +1,42 @@
+package cn.newfeifan.mall.module.distri.dal.mysql.socialstatuschangelog;
+
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.module.distri.controller.admin.socialstatuschangelog.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.socialstatuschangelog.SocialStatusChangeLogDO;
+import cn.newfeifan.mall.module.distri.enums.SocialStatusEnum;
+import org.apache.ibatis.annotations.Mapper;
+
+
+/**
+ * 会员身价变化日志 Mapper
+ *
+ * @author 非繁人
+ */
+@Mapper
+public interface SocialStatusChangeLogMapper extends BaseMapperX<SocialStatusChangeLogDO> {
+
+    default PageResult<SocialStatusChangeLogDO> selectPage(SocialStatusChangeLogPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<SocialStatusChangeLogDO>()
+                .eqIfPresent(SocialStatusChangeLogDO::getSocialStatusChangeCategoryId, reqVO.getSocialStatusChangeCategoryId())
+                .eqIfPresent(SocialStatusChangeLogDO::getVariationValue, reqVO.getVariationValue())
+                .eqIfPresent(SocialStatusChangeLogDO::getObjectId, reqVO.getObjectId())
+                .eqIfPresent(SocialStatusChangeLogDO::getEffective, reqVO.getEffective())
+                .eqIfPresent(SocialStatusChangeLogDO::getDescription, reqVO.getDescription())
+                .betweenIfPresent(SocialStatusChangeLogDO::getPlanEffectiveTime, reqVO.getPlanEffectiveTime())
+                .betweenIfPresent(SocialStatusChangeLogDO::getActualEffectiveTime, reqVO.getActualEffectiveTime())
+                .betweenIfPresent(SocialStatusChangeLogDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(SocialStatusChangeLogDO::getUserId, reqVO.getUserId())
+                .orderByDesc(SocialStatusChangeLogDO::getId));
+    }
+
+     default PageResult<SocialStatusChangeLogDO> getUserSignLog(SocialStatusChangeLogPageReqVO pageReqVO){
+        return selectPage(pageReqVO ,new LambdaQueryWrapperX<SocialStatusChangeLogDO>()
+                .eq(SocialStatusChangeLogDO::getUserId, pageReqVO.getUserId())
+                .eq(SocialStatusChangeLogDO::getSocialStatusChangeCategoryId, SocialStatusEnum.SIGN_IN_SOCIAL.getStatus())
+                .orderByDesc(SocialStatusChangeLogDO::getCreateTime)
+        );
+     }
+}

+ 41 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/usertopupconsumptionpointsorder/UserTopUpConsumptionPointsOrderMapper.java

@@ -0,0 +1,41 @@
+package cn.newfeifan.mall.module.distri.dal.mysql.usertopupconsumptionpointsorder;
+
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.module.distri.controller.admin.usertopupconsumptionpointsorder.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.usertopupconsumptionpointsorder.UserTopUpConsumptionPointsOrderDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 用户充值消费分订单 Mapper
+ *
+ * @author 非繁人
+ */
+@Mapper
+public interface UserTopUpConsumptionPointsOrderMapper extends BaseMapperX<UserTopUpConsumptionPointsOrderDO> {
+
+    default PageResult<UserTopUpConsumptionPointsOrderDO> selectPage(UserTopUpConsumptionPointsOrderPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<UserTopUpConsumptionPointsOrderDO>()
+                .eqIfPresent(UserTopUpConsumptionPointsOrderDO::getNo, reqVO.getNo())
+                .eqIfPresent(UserTopUpConsumptionPointsOrderDO::getTerminal, reqVO.getTerminal())
+                .eqIfPresent(UserTopUpConsumptionPointsOrderDO::getUserId, reqVO.getUserId())
+                .eqIfPresent(UserTopUpConsumptionPointsOrderDO::getUserIp, reqVO.getUserIp())
+                .eqIfPresent(UserTopUpConsumptionPointsOrderDO::getSubject, reqVO.getSubject())
+                .eqIfPresent(UserTopUpConsumptionPointsOrderDO::getTopUpConsumptionPoints, reqVO.getTopUpConsumptionPoints())
+                .eqIfPresent(UserTopUpConsumptionPointsOrderDO::getPracticalConsumptionPoints, reqVO.getPracticalConsumptionPoints())
+                .likeIfPresent(UserTopUpConsumptionPointsOrderDO::getUserName, reqVO.getUserName())
+                .eqIfPresent(UserTopUpConsumptionPointsOrderDO::getPayOrderId, reqVO.getPayOrderId())
+                .eqIfPresent(UserTopUpConsumptionPointsOrderDO::getPayStatus, reqVO.getPayStatus())
+                .betweenIfPresent(UserTopUpConsumptionPointsOrderDO::getPayTime, reqVO.getPayTime())
+                .eqIfPresent(UserTopUpConsumptionPointsOrderDO::getPayChannelCode, reqVO.getPayChannelCode())
+                .betweenIfPresent(UserTopUpConsumptionPointsOrderDO::getFinishTime, reqVO.getFinishTime())
+                .betweenIfPresent(UserTopUpConsumptionPointsOrderDO::getCancelTime, reqVO.getCancelTime())
+                .eqIfPresent(UserTopUpConsumptionPointsOrderDO::getPayPrice, reqVO.getPayPrice())
+                .eqIfPresent(UserTopUpConsumptionPointsOrderDO::getPercentTemplate, reqVO.getPercentTemplate())
+                .betweenIfPresent(UserTopUpConsumptionPointsOrderDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(UserTopUpConsumptionPointsOrderDO::getId));
+    }
+
+}

+ 19 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/mq/consumer/topupconsumptionpoints/topupconsumptionpoints/TopUpConsumptionPointsConsumer.java

@@ -0,0 +1,19 @@
+package cn.newfeifan.mall.module.distri.mq.consumer.topupconsumptionpoints.topupconsumptionpoints;
+
+import cn.newfeifan.mall.module.distri.service.usertopupconsumptionpointsorder.UserTopUpConsumptionPointsOrderService;
+import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderDO;
+import org.springframework.context.event.EventListener;
+
+import javax.annotation.Resource;
+
+public class TopUpConsumptionPointsConsumer {
+
+    @Resource
+    private UserTopUpConsumptionPointsOrderService userTopUpConsumptionPointsOrderService;
+
+    @EventListener
+    public void onMessage(PayOrderDO payOrderDO) {
+        //修改订单状态,并计算权益
+        userTopUpConsumptionPointsOrderService.topUpConsumptionPoints(payOrderDO);
+    }
+}

+ 11 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/duser/DuserService.java

@@ -0,0 +1,11 @@
+package cn.newfeifan.mall.module.distri.service.duser;
+
+/**
+ * 推荐用户 Service 接口
+ *
+ * @author 非繁人
+ */
+public interface DuserService {
+
+    void updateDuserSocial(Long userId, Long social, Integer socialStatus);
+}

+ 59 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/duser/DuserServiceImpl.java

@@ -0,0 +1,59 @@
+package cn.newfeifan.mall.module.distri.service.duser;
+
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.module.distri.controller.admin.socialstatus.bo.SocialStatusBO;
+import cn.newfeifan.mall.module.distri.dal.dataobject.duser.DuserDO;
+import cn.newfeifan.mall.module.distri.dal.mysql.duser.DuserMapper;
+import cn.newfeifan.mall.module.distri.enums.SocialStatusEnum;
+import cn.newfeifan.mall.module.distri.service.socialstatus.SocialStatusService;
+import cn.newfeifan.mall.module.distri.service.socialstatuschangelog.SocialStatusChangeLogService;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import java.util.Objects;
+
+import static cn.newfeifan.mall.module.distri.constant.DistriConstants.PT_ID;
+
+/**
+ * 推荐用户 Service 实现类
+ *
+ * @author 非繁人
+ */
+@Service
+@Validated
+public class DuserServiceImpl implements DuserService {
+
+    @Resource
+    private DuserMapper duserMapper;
+    @Resource
+    private SocialStatusChangeLogService socialStatusChangeLogService;
+
+    @Resource
+    private SocialStatusService socialStatusService;
+
+    @Override
+    public void updateDuserSocial(Long userId, Long social, Integer socialStatus) {
+
+        //平台不参与身价
+        if(Objects.equals(userId, PT_ID)){
+            return;
+        }
+
+        //计算本次获得的身价
+        DuserDO duser = getDuserByUser(userId);
+        duser.setSocialStatusPoint(duser.getSocialStatusPoint() + social);
+
+        SocialStatusBO socialStatusBO = socialStatusService.calculateSocial(duser.getSocialStatusPoint());
+        duser.setSocialUpNeed(socialStatusBO.getSocialUpNeed());
+        duser.setSocialStatusId(socialStatusBO.getId());
+
+        duserMapper.updateById(duser);
+
+        socialStatusChangeLogService.createSocialStatusChangeLog(userId, social,userId, SocialStatusEnum.getSocialStatusEnumByCode(socialStatus));
+    }
+
+    private DuserDO getDuserByUser(Long id) {
+        return duserMapper.selectOne(new LambdaQueryWrapperX<DuserDO>().eq(DuserDO::getUserId, id));
+    }
+}

+ 19 - 1
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/integral/IntegralService.java

@@ -1,7 +1,11 @@
 package cn.newfeifan.mall.module.distri.service.integral;
 
+import cn.newfeifan.mall.module.distri.controller.admin.integral.vo.IntegralSaveReqVO;
+import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
 import cn.newfeifan.mall.module.distri.enums.CaclEnum;
 
+import javax.validation.Valid;
+
 /**
  * 推荐用户积分 Service 接口
  *
@@ -63,7 +67,7 @@ public interface IntegralService {
      * @param amount       用户积分变化金额,可为负数
      * @param freezeAmount 用户冻结积分变化金额,可为负数
      */
-    void updateUserIntegral(Long generateUserId,//导致产生积分变动的用户ID
+    Boolean updateUserIntegral(Long generateUserId,//导致产生积分变动的用户ID
                             Long userId, CaclEnum caclEnum, Long amount, Long freezeAmount,
                             Long tradeOrderId,
                             String orderNum
@@ -100,4 +104,18 @@ public interface IntegralService {
      * @param tradeOrderNum 订单编号
      */
     void updateUserConsumptionPoints(Long generateUserId, Long userId, Long payConsumptionPoints, Long tradeOrderId, String tradeOrderNum);
+
+    /**
+     * 根据用户ID查询是否有钱包
+     * @param descendant 用户id
+     * @return 钱包
+     */
+    IntegralDO selectByUser(Long descendant);
+
+    /**
+     * 更新推荐用户积分
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateIntegral(@Valid IntegralSaveReqVO updateReqVO);
 }

+ 55 - 39
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/integral/IntegralServiceImpl.java

@@ -1,10 +1,11 @@
 package cn.newfeifan.mall.module.distri.service.integral;
 
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
 import cn.newfeifan.mall.module.distri.controller.admin.consumptionchangelog.vo.ConsumptionChangeLogSaveReqVO;
+import cn.newfeifan.mall.module.distri.controller.admin.integral.vo.IntegralSaveReqVO;
 import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.PtProfitLogSaveReqVO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
-import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlog.PtProfitLogDO;
 import cn.newfeifan.mall.module.distri.dal.mysql.integral.IntegralMapper;
 import cn.newfeifan.mall.module.distri.dal.mysql.ptprofit.PtProfitMapper;
 import cn.newfeifan.mall.module.distri.enums.CaclEnum;
@@ -12,12 +13,16 @@ import cn.newfeifan.mall.module.distri.enums.ConsumptionEnum;
 import cn.newfeifan.mall.module.distri.service.consumptionchangelog.ConsumptionChangeLogService;
 import cn.newfeifan.mall.module.distri.service.orderpercentage.OrderPercentageService;
 import cn.newfeifan.mall.module.distri.service.ptprofitlog.PtProfitLogService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 
 import javax.annotation.Resource;
 import java.util.Map;
 
+import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.INTEGRAL_NOT_EXISTS;
+
 /**
  * 推荐用户积分 Service 实现类
  *
@@ -49,58 +54,50 @@ public class IntegralServiceImpl implements IntegralService {
      * @param freezeAmount 用户冻结积分变化金额,可为负数
      */
     @Override
-    public void updateUserIntegral(Long generateUserId,//导致产生积分变动的用户ID
+    public Boolean updateUserIntegral(Long generateUserId,//导致产生积分变动的用户ID
                                    Long userId, CaclEnum caclEnum, Long amount, Long freezeAmount,
                                    Long tradeOrderId,
                                    String orderNum
     ) {
-        //修改用户积分钱包的积分
-        IntegralDO integralDO = integralMapper.selectOne(IntegralDO::getUserId, userId);
+        Boolean success = null;
 
-        // 退款返回 为 +
-        integralDO.setCurrentQuota(integralDO.getCurrentQuota() + amount);
-
-        // 直推奖超出额度
-        Long ancestorQuotaAmount = 0L;
-        // 如果是推荐人
-        if (caclEnum.getType().equals(CaclEnum.ORDER_REFUND_INTEGRAL_ANCESTER.getType())) {
+        //修改用户积分钱包的积分
+        int effectRowNum = ptProfitMapper.updateUserIntegral(amount,amount,freezeAmount,freezeAmount,userId);
 
-            PtProfitLogDO profitLog = ptProfitLogService.selectProfitLogByUserIdWithProfitStatus(userId, CaclEnum.RECOMMENDED_PERSON_QUOTA.getType(), orderNum);
+        if (effectRowNum==1) {//如果成功修改积分记录
+            success = true;
 
-            if(profitLog.getAncestorQuotaAmount() != null && profitLog.getAncestorQuotaAmount() != 0){
-                ancestorQuotaAmount = profitLog.getAncestorQuotaAmount();
-            }
-            integralDO.setCurrentQuota(integralDO.getCurrentQuota() + ancestorQuotaAmount);
-            // 退回扣减的最大可用额度,和累加获得的直推奖额度
-            integralDO.setHighQuota(integralDO.getHighQuota() - amount - ancestorQuotaAmount);
-            integralDO.setAncestorQuota(integralDO.getAncestorQuota() + amount + ancestorQuotaAmount);
-        }
+            //用户修改后的当前可用的钱包余额
+            Long afterAmount = null;
+            //用户修改后的冻结积分钱包余额
+            Long afterFreezeAmount = null;
 
-        integralMapper.updateById(integralDO);
+            //查询用户修改后的积分
+            Map<String, Object> map = ptProfitMapper.selectUserIntegral(userId);
+            Object currentQuotaObj = map.get("current_quota");
+            Object freezeQuotaObj = map.get("freeze_quota");
 
-        //用户修改后的当前可用的钱包余额
-        Long afterAmount = null;
-        //用户修改后的冻结积分钱包余额
-        Long afterFreezeAmount = null;
+            afterAmount = (Long)currentQuotaObj;
+            afterFreezeAmount = (Long)freezeQuotaObj;
 
-        //查询用户修改后的积分
-        Map<String, Object> map = ptProfitMapper.selectUserIntegral(userId);
-        Object currentQuotaObj = map.get("current_quota");
-        Object freezeQuotaObj = map.get("freeze_quota");
+            if(afterAmount<0||afterFreezeAmount<0){
+                throw new RuntimeException("用户钱包为负数:用户IO为"+userId+"的用户可用钱包为"+afterAmount+",冻结钱包为"+afterFreezeAmount);
+            }
 
-        afterAmount = (Long) currentQuotaObj;
-        afterFreezeAmount = (Long) freezeQuotaObj;
+            //记录用户的积分变动日志
+            ptProfitLogService.addMessage(generateUserId,//导致产生积分变动的用户ID
+                    userId, caclEnum, amount, afterAmount,
+                    freezeAmount, afterFreezeAmount,null,tradeOrderId,orderNum);
 
-        //记录用户的积分变动日志
-        if (caclEnum.getType().equals(CaclEnum.ORDER_REFUND_INTEGRAL_ANCESTER.getType())) {
-            OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus();
-            ptProfitLogService.addMessage(generateUserId, userId, caclEnum, amount + ancestorQuotaAmount, afterAmount,
-                    freezeAmount, afterFreezeAmount, null, tradeOrderId, orderNum, -amount - ancestorQuotaAmount, integralDO.getHighQuota() + Long.parseLong(orderPercentageDO.getBaseMaxQuota()));
-        } else {
-            ptProfitLogService.addMessage(generateUserId, userId, caclEnum, amount, afterAmount,
-                    freezeAmount, afterFreezeAmount, null, tradeOrderId, orderNum, null, null);
+        }else if(effectRowNum<1){//如果钱包积分不足,不够抵扣
+            success = false;
+        } else if (effectRowNum>1) {
+//            success = false;
+            throw new RuntimeException("用户IO为"+userId+"的用户钱包不只一个!");
         }
 
+        return success;
+
     }
 
     @Override
@@ -146,6 +143,25 @@ public class IntegralServiceImpl implements IntegralService {
 
     }
 
+    @Override
+    public IntegralDO selectByUser(Long descendant) {
+        return integralMapper.selectOne(new LambdaQueryWrapper<IntegralDO>().eq(IntegralDO::getUserId, descendant));
+    }
+
+    @Override
+    public void updateIntegral(IntegralSaveReqVO updateReqVO) {
+        // 校验存在
+        validateIntegralExists(updateReqVO.getId());
+        // 更新
+        IntegralDO updateObj = BeanUtils.toBean(updateReqVO, IntegralDO.class);
+        integralMapper.updateById(updateObj);
+    }
+    private void validateIntegralExists(Long id) {
+        if (integralMapper.selectById(id) == null) {
+            throw exception(INTEGRAL_NOT_EXISTS);
+        }
+    }
+
 //
 //    /**
 //     * 修改用户身价

+ 63 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofit/PtProfitService.java

@@ -0,0 +1,63 @@
+package cn.newfeifan.mall.module.distri.service.ptprofit;
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofit.PtProfitDO;
+
+import javax.validation.Valid;
+import java.util.List;
+
+/**
+ * 平台利润 Service 接口
+ *
+ * @author 非繁人
+ */
+public interface PtProfitService {
+
+    /**
+     * 创建平台利润
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createPtProfit(@Valid PtProfitSaveReqVO createReqVO);
+
+    /**
+     * 更新平台利润
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updatePtProfit(@Valid PtProfitSaveReqVO updateReqVO);
+
+    /**
+     * 删除平台利润
+     *
+     * @param id 编号
+     */
+    void deletePtProfit(Long id);
+
+    /**
+     * 获得平台利润
+     *
+     * @param id 编号
+     * @return 平台利润
+     */
+    PtProfitDO getPtProfit(Long id);
+
+    /**
+     * 获得平台利润分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 平台利润分页
+     */
+    PageResult<PtProfitDO> getPtProfitPage(PtProfitPageReqVO pageReqVO);
+
+    /**
+     * 获取当前平台信息
+     */
+    PtProfitDO getPtProfit();
+
+
+    void saveBatch(List<PtProfitSaveReqVO> ptProfitSaveReqVOS);
+
+}

+ 85 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofit/PtProfitServiceImpl.java

@@ -0,0 +1,85 @@
+package cn.newfeifan.mall.module.distri.service.ptprofit;
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofit.PtProfitDO;
+import cn.newfeifan.mall.module.distri.dal.mysql.ptprofit.PtProfitMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.PT_PROFIT_NOT_EXISTS;
+
+/**
+ * 平台利润 Service 实现类
+ *
+ * @author 非繁人
+ */
+@Service
+@Validated
+public class PtProfitServiceImpl implements PtProfitService {
+
+    @Resource
+    private PtProfitMapper ptProfitMapper;
+
+    @Override
+    public Long createPtProfit(PtProfitSaveReqVO createReqVO) {
+        // 插入
+        PtProfitDO ptProfit = BeanUtils.toBean(createReqVO, PtProfitDO.class);
+        ptProfitMapper.insert(ptProfit);
+        // 返回
+        return ptProfit.getId();
+    }
+
+    @Override
+    public void updatePtProfit(PtProfitSaveReqVO updateReqVO) {
+        // 校验存在
+        validatePtProfitExists(updateReqVO.getId());
+        // 更新
+        PtProfitDO updateObj = BeanUtils.toBean(updateReqVO, PtProfitDO.class);
+        ptProfitMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deletePtProfit(Long id) {
+        // 校验存在
+        validatePtProfitExists(id);
+        // 删除
+        ptProfitMapper.deleteById(id);
+    }
+
+    private void validatePtProfitExists(Long id) {
+        if (ptProfitMapper.selectById(id) == null) {
+            throw exception(PT_PROFIT_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public PtProfitDO getPtProfit(Long id) {
+        return ptProfitMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<PtProfitDO> getPtProfitPage(PtProfitPageReqVO pageReqVO) {
+        return ptProfitMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public PtProfitDO getPtProfit() {
+        return ptProfitMapper.selectList(new LambdaQueryWrapperX<PtProfitDO>()).get(0);
+    }
+
+    @Override
+    public void saveBatch(List<PtProfitSaveReqVO> ptProfitSaveReqVOS) {
+
+        List<PtProfitDO> ptProfit = BeanUtils.toBean(ptProfitSaveReqVOS, PtProfitDO.class);
+        ptProfitMapper.insertBatch(ptProfit);
+
+    }
+
+}

+ 5 - 4
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogService.java

@@ -63,12 +63,13 @@ public interface PtProfitLogService {
 
     //记录用户的积分变动日志
     void addMessage(Long generateUserId,//导致产生积分变动的用户ID
-                    Long userId, CaclEnum caclEnum, Integer amount,
-                    Integer afterAmount, Integer freezeAmount,
-                    Integer afterFreezeAmount, String percentTemplate,
+                    Long userId, //实际变动积分的用户ID
+                    CaclEnum caclEnum, Long amount,
+                    Long afterAmount, Long freezeAmount,
+                    Long afterFreezeAmount, String percentTemplate,
                     Long tradeOrderId,
                     String OrderNum
-                    );
+    );
 
     void addMessage(Long generateUserId,//导致产生积分变动的用户ID
             Long userId, CaclEnum caclEnum, Long amount, Long afterAmount,

+ 18 - 1
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogServiceImpl.java

@@ -86,7 +86,24 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
     }
 
     @Override
-    public void addMessage(Long generateUserId,Long userId, CaclEnum caclEnum, Integer amount, Integer afterAmount, Integer freezeAmount, Integer afterFreezeAmount, String percentTemplate, Long tradeOrderId, String OrderNum) {
+    public void addMessage(Long generateUserId,//导致产生积分变动的用户ID
+                           Long userId, //实际变动积分的用户ID
+                           CaclEnum caclEnum, Long amount, Long afterAmount,
+                           Long freezeAmount, Long afterFreezeAmount,
+                           String percentTemplate,
+                           Long tradeOrderId,
+                           String OrderNum
+    ) {
+        PtProfitLogSaveReqVO ptProfitLog = PtProfitLogSaveReqVO.builder()
+                .afterAmount(afterAmount)
+                .amount(amount)
+                .percentTemplate(percentTemplate)
+                .userId(userId)
+                .generateUserId(generateUserId)
+                .profitStatus(caclEnum.getType()).orderId(tradeOrderId).orderNo(OrderNum)
+                .freezeAmount(freezeAmount).afterFreezeAmount(afterFreezeAmount)
+                .build();
+        ptProfitLogMapper.insert(BeanUtils.toBean(ptProfitLog, PtProfitLogDO.class));
 
     }
 

+ 19 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/sharepath/SharePathService.java

@@ -0,0 +1,19 @@
+package cn.newfeifan.mall.module.distri.service.sharepath;
+
+import cn.newfeifan.mall.module.distri.dal.dataobject.sharepath.SharePathDO;
+
+
+/**
+ * 分销用户关系 Service 接口
+ *
+ * @author 非繁人
+ */
+public interface SharePathService {
+    /**
+     * 通过直推人, 获取当前的直推关系
+     *
+     * @param userId 用户id
+     * @return 推荐人
+     */
+    SharePathDO getSharePathByDescendant(Long userId);
+}

+ 36 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/sharepath/SharePathServiceImpl.java

@@ -0,0 +1,36 @@
+package cn.newfeifan.mall.module.distri.service.sharepath;
+
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.module.distri.dal.dataobject.sharepath.SharePathDO;
+import cn.newfeifan.mall.module.distri.dal.mysql.sharepath.SharePathMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 分销用户关系 Service 实现类
+ *
+ * @author 非繁人
+ */
+@Service
+@Validated
+public class SharePathServiceImpl implements SharePathService {
+
+    @Resource
+    private SharePathMapper sharePathMapper;
+    @Override
+    public SharePathDO getSharePathByDescendant(Long userId) {
+
+        List<SharePathDO> sharePathDOS = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>().eqIfPresent(SharePathDO::getDescendant, userId)
+                .eqIfPresent(SharePathDO::getDepth, 1));
+        if (sharePathDOS.isEmpty()) {
+            return null;
+        }
+        return sharePathDOS.get(0);
+    }
+
+
+
+}

+ 65 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/socialstatus/SocialStatusService.java

@@ -0,0 +1,65 @@
+package cn.newfeifan.mall.module.distri.service.socialstatus;
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.module.distri.controller.admin.socialstatus.bo.SocialStatusBO;
+import cn.newfeifan.mall.module.distri.controller.admin.socialstatus.vo.SocialStatusPageReqVO;
+import cn.newfeifan.mall.module.distri.controller.admin.socialstatus.vo.SocialStatusSaveReqVO;
+import cn.newfeifan.mall.module.distri.dal.dataobject.socialstatus.SocialStatusDO;
+
+import javax.validation.Valid;
+
+/**
+ * 分销用户身价 Service 接口
+ *
+ * @author 非繁人
+ */
+public interface SocialStatusService {
+
+    /**
+     * 创建分销用户身价
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createSocialStatus(@Valid SocialStatusSaveReqVO createReqVO);
+
+    /**
+     * 更新分销用户身价
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateSocialStatus(@Valid SocialStatusSaveReqVO updateReqVO);
+
+    /**
+     * 删除分销用户身价
+     *
+     * @param id 编号
+     */
+    void deleteSocialStatus(Long id);
+
+    /**
+     * 获得分销用户身价
+     *
+     * @param id 编号
+     * @return 分销用户身价
+     */
+    SocialStatusDO getSocialStatus(Long id);
+
+    /**
+     * 获得分销用户身价分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 分销用户身价分页
+     */
+    PageResult<SocialStatusDO> getSocialStatusPage(SocialStatusPageReqVO pageReqVO);
+
+
+    /**
+     * 获得身价对象
+     *
+     * @param point 用户当前身价
+     * @return 身价对象
+     */
+    SocialStatusBO calculateSocial(Long point);
+
+}

+ 96 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/socialstatus/SocialStatusServiceImpl.java

@@ -0,0 +1,96 @@
+package cn.newfeifan.mall.module.distri.service.socialstatus;
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+import cn.newfeifan.mall.module.distri.controller.admin.socialstatus.bo.SocialStatusBO;
+import cn.newfeifan.mall.module.distri.controller.admin.socialstatus.vo.SocialStatusPageReqVO;
+import cn.newfeifan.mall.module.distri.controller.admin.socialstatus.vo.SocialStatusSaveReqVO;
+import cn.newfeifan.mall.module.distri.dal.dataobject.socialstatus.SocialStatusDO;
+import cn.newfeifan.mall.module.distri.dal.mysql.socialstatus.SocialStatusMapper;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.SOCIAL_STATUS_NOT_EXISTS;
+
+/**
+ * 分销用户身价 Service 实现类
+ *
+ * @author 非繁人
+ */
+@Service
+@Validated
+public class SocialStatusServiceImpl implements SocialStatusService {
+
+    @Resource
+    private SocialStatusMapper socialStatusMapper;
+
+    @Override
+    public Long createSocialStatus(SocialStatusSaveReqVO createReqVO) {
+        // 插入
+        SocialStatusDO socialStatus = BeanUtils.toBean(createReqVO, SocialStatusDO.class);
+        socialStatusMapper.insert(socialStatus);
+        // 返回
+        return socialStatus.getId();
+    }
+
+    @Override
+    public void updateSocialStatus(SocialStatusSaveReqVO updateReqVO) {
+        // 校验存在
+        validateSocialStatusExists(updateReqVO.getId());
+        // 更新
+        SocialStatusDO updateObj = BeanUtils.toBean(updateReqVO, SocialStatusDO.class);
+        socialStatusMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteSocialStatus(Long id) {
+        // 校验存在
+        validateSocialStatusExists(id);
+        // 删除
+        socialStatusMapper.deleteById(id);
+    }
+
+    private void validateSocialStatusExists(Long id) {
+        if (socialStatusMapper.selectById(id) == null) {
+            throw exception(SOCIAL_STATUS_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public SocialStatusDO getSocialStatus(Long id) {
+        return socialStatusMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<SocialStatusDO> getSocialStatusPage(SocialStatusPageReqVO pageReqVO) {
+        return socialStatusMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public SocialStatusBO calculateSocial(Long point) {
+        List<SocialStatusDO> socialStatusDOS = socialStatusMapper.selectList(new LambdaQueryWrapper<SocialStatusDO>()
+                .orderByAsc(SocialStatusDO::getPoint)
+        );
+
+        SocialStatusBO socialStatusBO = SocialStatusBO.builder().build();
+        for (int i = 0; i < socialStatusDOS.size(); i++) {
+            if (point < socialStatusDOS.get(i).getPoint()) {
+                socialStatusBO.setId(socialStatusDOS.get(i - 1).getId());
+                socialStatusBO.setSocialUpNeed(socialStatusDOS.get(i).getPoint() - point);
+                break;
+            }
+        }
+        if(socialStatusBO.getId() == null){
+            socialStatusBO.setId(socialStatusDOS.get(socialStatusDOS.size() - 1).getId());
+            socialStatusBO.setSocialUpNeed(0L);
+        }
+        return socialStatusBO;
+    }
+
+
+}

+ 23 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/socialstatuschangelog/SocialStatusChangeLogService.java

@@ -0,0 +1,23 @@
+package cn.newfeifan.mall.module.distri.service.socialstatuschangelog;
+
+import cn.newfeifan.mall.module.distri.enums.SocialStatusEnum;
+
+
+/**
+ * 会员身价变化日志 Service 接口
+ *
+ * @author 非繁人
+ */
+public interface SocialStatusChangeLogService {
+
+    /**
+     * 创建会员身价变化日志
+     *
+     * @param userId 用户编号
+     * @param socialValue 身价值
+     * @param objectId 业务对象编号
+     * @param socialStatusEnum 业务对象枚举
+     * @return 编号
+     */
+    Long createSocialStatusChangeLog(Long userId, Long socialValue, Long objectId, SocialStatusEnum socialStatusEnum);
+}

+ 40 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/socialstatuschangelog/SocialStatusChangeLogServiceImpl.java

@@ -0,0 +1,40 @@
+package cn.newfeifan.mall.module.distri.service.socialstatuschangelog;
+
+import cn.newfeifan.mall.module.distri.dal.dataobject.socialstatuschangelog.SocialStatusChangeLogDO;
+import cn.newfeifan.mall.module.distri.dal.mysql.socialstatuschangelog.SocialStatusChangeLogMapper;
+import cn.newfeifan.mall.module.distri.enums.SocialStatusEnum;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+
+import static cn.newfeifan.mall.module.distri.constant.DistriConstants.IS_EFFECTIVE;
+
+/**
+ * 会员身价变化日志 Service 实现类
+ *
+ * @author 非繁人
+ */
+@Service
+@Validated
+public class SocialStatusChangeLogServiceImpl implements SocialStatusChangeLogService {
+
+    @Resource
+    private SocialStatusChangeLogMapper socialStatusChangeLogMapper;
+
+    @Override
+    public Long createSocialStatusChangeLog(Long userId, Long socialValue, Long objectId, SocialStatusEnum socialStatusEnum) {
+        // 插入
+        SocialStatusChangeLogDO socialStatusChangeLog = SocialStatusChangeLogDO.builder()
+                .socialStatusChangeCategoryId(Long.valueOf(socialStatusEnum.getStatus()))
+                .description(socialStatusEnum.getName())
+                .variationValue(socialValue)
+                .objectId(objectId)
+                .effective(IS_EFFECTIVE)
+                .userId(userId).build();
+        socialStatusChangeLogMapper.insert(socialStatusChangeLog);
+        // 返回
+        return socialStatusChangeLog.getId();
+    }
+
+}

+ 67 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/usertopupconsumptionpointsorder/UserTopUpConsumptionPointsOrderService.java

@@ -0,0 +1,67 @@
+package cn.newfeifan.mall.module.distri.service.usertopupconsumptionpointsorder;
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.module.distri.controller.admin.usertopupconsumptionpointsorder.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.usertopupconsumptionpointsorder.UserTopUpConsumptionPointsOrderDO;
+import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderDO;
+
+import javax.validation.Valid;
+import java.util.List;
+
+/**
+ * 用户充值消费分订单 Service 接口
+ *
+ * @author 非繁人
+ */
+public interface UserTopUpConsumptionPointsOrderService {
+
+    /**
+     * 创建用户充值消费分订单
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createUserTopUpConsumptionPointsOrder(@Valid UserTopUpConsumptionPointsOrderSaveReqVO createReqVO);
+
+    /**
+     * 更新用户充值消费分订单
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateUserTopUpConsumptionPointsOrder(@Valid UserTopUpConsumptionPointsOrderSaveReqVO updateReqVO);
+
+    /**
+     * 删除用户充值消费分订单
+     *
+     * @param id 编号
+     */
+    void deleteUserTopUpConsumptionPointsOrder(Long id);
+
+    /**
+     * 获得用户充值消费分订单
+     *
+     * @param id 编号
+     * @return 用户充值消费分订单
+     */
+    UserTopUpConsumptionPointsOrderDO getUserTopUpConsumptionPointsOrder(Long id);
+
+    /**
+     * 获得用户充值消费分订单分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 用户充值消费分订单分页
+     */
+    PageResult<UserTopUpConsumptionPointsOrderDO> getUserTopUpConsumptionPointsOrderPage(UserTopUpConsumptionPointsOrderPageReqVO pageReqVO);
+
+    /**
+     * 充值消费
+     * @param payOrderDO 支付订单
+     */
+    void topUpConsumptionPoints(PayOrderDO payOrderDO);
+
+    /**
+     * 获取充值消费列表
+     * @return 充值列表
+     */
+    List<UserTopUpConsumptionPointsOrderDO> getUserTopUpConsumptionPointsOrderList();
+}

+ 122 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/usertopupconsumptionpointsorder/UserTopUpConsumptionPointsOrderServiceImpl.java

@@ -0,0 +1,122 @@
+package cn.newfeifan.mall.module.distri.service.usertopupconsumptionpointsorder;
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+import cn.newfeifan.mall.module.distri.controller.admin.consumptionchangelog.vo.ConsumptionChangeLogSaveReqVO;
+import cn.newfeifan.mall.module.distri.controller.admin.integral.vo.IntegralSaveReqVO;
+import cn.newfeifan.mall.module.distri.controller.admin.usertopupconsumptionpointsorder.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
+import cn.newfeifan.mall.module.distri.dal.dataobject.usertopupconsumptionpointsorder.UserTopUpConsumptionPointsOrderDO;
+import cn.newfeifan.mall.module.distri.dal.mysql.usertopupconsumptionpointsorder.UserTopUpConsumptionPointsOrderMapper;
+import cn.newfeifan.mall.module.distri.enums.ConsumptionEnum;
+import cn.newfeifan.mall.module.distri.service.consumptionchangelog.ConsumptionChangeLogService;
+import cn.newfeifan.mall.module.distri.service.integral.IntegralService;
+import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderDO;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.List;
+
+import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.USER_TOP_UP_CONSUMPTION_POINTS_ORDER_NOT_EXISTS;
+
+/**
+ * 用户充值消费分订单 Service 实现类
+ *
+ * @author 非繁人
+ */
+@Service
+@Validated
+public class UserTopUpConsumptionPointsOrderServiceImpl implements UserTopUpConsumptionPointsOrderService {
+
+    @Resource
+    private UserTopUpConsumptionPointsOrderMapper userTopUpConsumptionPointsOrderMapper;
+    @Resource
+    private IntegralService integralService;
+    @Resource
+    private ConsumptionChangeLogService consumptionChangeLogService;
+
+    @Override
+    public Long createUserTopUpConsumptionPointsOrder(UserTopUpConsumptionPointsOrderSaveReqVO createReqVO) {
+        // 插入
+        UserTopUpConsumptionPointsOrderDO userTopUpConsumptionPointsOrder = BeanUtils.toBean(createReqVO, UserTopUpConsumptionPointsOrderDO.class);
+        userTopUpConsumptionPointsOrderMapper.insert(userTopUpConsumptionPointsOrder);
+        // 返回
+        return userTopUpConsumptionPointsOrder.getId();
+    }
+
+    @Override
+    public void updateUserTopUpConsumptionPointsOrder(UserTopUpConsumptionPointsOrderSaveReqVO updateReqVO) {
+        // 校验存在
+        validateUserTopUpConsumptionPointsOrderExists(updateReqVO.getId());
+        // 更新
+        UserTopUpConsumptionPointsOrderDO updateObj = BeanUtils.toBean(updateReqVO, UserTopUpConsumptionPointsOrderDO.class);
+        userTopUpConsumptionPointsOrderMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteUserTopUpConsumptionPointsOrder(Long id) {
+        // 校验存在
+        validateUserTopUpConsumptionPointsOrderExists(id);
+        // 删除
+        userTopUpConsumptionPointsOrderMapper.deleteById(id);
+    }
+
+    private void validateUserTopUpConsumptionPointsOrderExists(Long id) {
+        if (userTopUpConsumptionPointsOrderMapper.selectById(id) == null) {
+            throw exception(USER_TOP_UP_CONSUMPTION_POINTS_ORDER_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public UserTopUpConsumptionPointsOrderDO getUserTopUpConsumptionPointsOrder(Long id) {
+        return userTopUpConsumptionPointsOrderMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<UserTopUpConsumptionPointsOrderDO> getUserTopUpConsumptionPointsOrderPage(UserTopUpConsumptionPointsOrderPageReqVO pageReqVO) {
+        pageReqVO.setPayStatus(true);
+        return userTopUpConsumptionPointsOrderMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public void topUpConsumptionPoints(PayOrderDO payOrderDO) {
+        UserTopUpConsumptionPointsOrderDO topUpOrder = userTopUpConsumptionPointsOrderMapper.selectById(payOrderDO.getMerchantOrderId());
+
+        if(topUpOrder.getPayStatus()){
+            return;
+        }
+
+        // 修改订单状态
+        userTopUpConsumptionPointsOrderMapper.updateById(UserTopUpConsumptionPointsOrderDO.builder()
+                .id(topUpOrder.getId())
+                .payStatus(true)
+                .payTime(LocalDateTime.now())
+                .payChannelCode(payOrderDO.getChannelCode())
+                .finishTime(LocalDateTime.now())
+                .build());
+
+        // 获取钱包
+        IntegralDO integralDO = integralService.selectByUser(topUpOrder.getUserId());
+        integralDO.setConsumptionPoints(integralDO.getConsumptionPoints() + topUpOrder.getPracticalConsumptionPoints());
+        integralService.updateIntegral(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
+
+        // 消费分变动日志
+        consumptionChangeLogService.createConsumptionChangeLog(ConsumptionChangeLogSaveReqVO.builder()
+                .userId(topUpOrder.getUserId())
+                .consumptionStatus(ConsumptionEnum.TOP_UP_GET.getType())
+                .consumptionPoints(topUpOrder.getPracticalConsumptionPoints())
+                .afterConsumptionPoints(integralDO.getConsumptionPoints())
+                .practicalConsumptionPoints(topUpOrder.getTopUpConsumptionPoints())
+                .generateUserId(topUpOrder.getUserId())
+                .build());
+    }
+
+    @Override
+    public List<UserTopUpConsumptionPointsOrderDO> getUserTopUpConsumptionPointsOrderList() {
+        return userTopUpConsumptionPointsOrderMapper.selectList(UserTopUpConsumptionPointsOrderDO::getPayStatus,true);
+    }
+
+}

+ 6 - 2
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/dal/dataobject/spuapply/SpuApplyDO.java

@@ -1,8 +1,11 @@
 package cn.newfeifan.mall.module.product.dal.dataobject.spuapply;
 
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
 import lombok.*;
 import java.time.LocalDateTime;
 import java.math.BigDecimal;
+import java.util.List;
+
 import com.baomidou.mybatisplus.annotation.*;
 import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
 
@@ -11,7 +14,7 @@ import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
  *
  * @author 非繁人
  */
-@TableName("product_spu_apply")
+@TableName(value = "product_spu_apply", autoResultMap = true)
 @KeySequence("product_spu_apply_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
 @Data
 @EqualsAndHashCode(callSuper = true)
@@ -67,7 +70,8 @@ public class SpuApplyDO extends BaseDO {
  数组,以逗号分隔
  最多上传15张
      */
-    private String sliderPicUrls;
+    @TableField(typeHandler = JacksonTypeHandler.class)
+    private List<String> sliderPicUrls;
     /**
      * 排序字段
      */

+ 11 - 8
feifan-module-mall/feifan-module-product-biz/src/main/java/cn/newfeifan/mall/module/product/service/spuapply/SpuApplyServiceImpl.java

@@ -88,7 +88,7 @@ public class SpuApplyServiceImpl implements SpuApplyService {
 
         SpuApplyDO spuApply = BeanUtils.toBean(createReqVO, SpuApplyDO.class);
         // 初始化 SPU 中 SKU 相关属性
-        initSpuFromSkus(spuApply, skuSaveReqList);
+        initSpuFromSkus(spuApply, skuSaveReqList, true);
 
         //加入商户、店铺信息
         UserShopDetailsVO userShopDetails = userService.getUserShopDetails();
@@ -118,10 +118,11 @@ public class SpuApplyServiceImpl implements SpuApplyService {
      * 基于 SKU 的信息,初始化 SPU 的信息
      * 主要是计数相关的字段,例如说市场价、最大最小价、库存等等
      *
-     * @param spu  商品 SPU
-     * @param skus 商品 SKU 数组
+     * @param spu   商品 SPU
+     * @param skus  商品 SKU 数组
+     * @param isAdd 是否为新增
      */
-    private void initSpuFromSkus(SpuApplyDO spu, List<SkuApplySaveReqVO> skus) {
+    private void initSpuFromSkus(SpuApplyDO spu, List<SkuApplySaveReqVO> skus, Boolean isAdd) {
         //是否是高精度商品
         if (!spu.getHighPrecision()) {
             // sku 单价最低的商品的价格
@@ -139,7 +140,9 @@ public class SpuApplyServiceImpl implements SpuApplyService {
         spu.setStock(getSumValue(skus, SkuApplySaveReqVO::getStock, Integer::sum));
         // 若是 spu 已有状态则不处理
         if (spu.getStatus() == null) {
-//            spu.setStatus(ProductSpuStatusEnum.ENABLE.getStatus()); // 默认状态为上架
+            if (isAdd) {
+                spu.setStatus(ProductSpuStatusEnum.ENABLE.getStatus()); // 默认状态为上架
+            }
             spu.setSalesCount(0); // 默认商品销量
             spu.setBrowseCount(0); // 默认商品浏览量
         }
@@ -167,7 +170,7 @@ public class SpuApplyServiceImpl implements SpuApplyService {
         SpuApplyDO updateObj = BeanUtils.toBean(updateReqVO, SpuApplyDO.class);
         SpuApplyDO spuApplyDO = spuApplyMapper.selectById(updateReqVO.getId());
         updateObj.setStatus(spuApplyDO.getStatus());
-        initSpuFromSkus(updateObj, skuSaveReqList);
+        initSpuFromSkus(updateObj, skuSaveReqList, false);
 
         //最大推广费, 单位: 分  add by Ben
         Integer maxPromotionFee = 0;
@@ -338,14 +341,14 @@ public class SpuApplyServiceImpl implements SpuApplyService {
     public void updateSpuStatus(ProductSpuUpdateStatusReqVO updateReqVO) {
 
         // 商户不允许回收商品
-        if(updateReqVO.getStatus().equals(ProductSpuStatusEnum.RECYCLE.getStatus())){
+        if (updateReqVO.getStatus().equals(ProductSpuStatusEnum.RECYCLE.getStatus())) {
             ErrorCode ERROR = new ErrorCode(1_008_005_001, "商户不允许回收商品");
             throw exception(ERROR);
         }
 
         // 如果商户的商品在回收站中,则商品不允许上下架
         SpuApplyDO spuApplyDO = spuApplyMapper.selectById(updateReqVO.getId());
-        if(spuApplyDO.getStatus().equals(ProductSpuStatusEnum.RECYCLE.getStatus())){
+        if (spuApplyDO.getStatus().equals(ProductSpuStatusEnum.RECYCLE.getStatus())) {
             ErrorCode SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR = new ErrorCode(1_008_005_001, "商品在回收站中不允许上下架");
             throw exception(SPU_SAVE_FAIL_CATEGORY_LEVEL_ERROR);
         }

+ 4 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/dataobject/order/TradeOrderItemDO.java

@@ -193,6 +193,10 @@ public class TradeOrderItemDO extends BaseDO {
      * 退还的使用的消费分
      */
     private Long refundConsumption;
+    /**
+     * 成本价,单位: 分
+     */
+    private Integer costPrice;
 
     /**
      * 商品属性

+ 22 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/mq/consumer/order/OrderConsumer.java

@@ -0,0 +1,22 @@
+package cn.newfeifan.mall.module.trade.mq.consumer.order;
+
+import cn.newfeifan.mall.module.trade.service.order.TradeOrderUpdateService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.event.EventListener;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Component
+@Slf4j
+public class OrderConsumer {
+
+    @Resource
+    private TradeOrderUpdateService tradeOrderUpdateService;
+
+    @EventListener
+    public void onMessage(Long payOrderId) {
+        //修改订单状态,并计算权益
+        tradeOrderUpdateService.updateOrderPaid(payOrderId);
+    }
+}

+ 6 - 0
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderUpdateService.java

@@ -196,4 +196,10 @@ public interface TradeOrderUpdateService {
     void cancelPaidOrder(Long userId, Long orderId);
 
     void updateOrderById(TradeOrderDO order);
+
+    /**
+     *  修改订单状态
+     * @param payOrderId 支付订单id
+     */
+    void updateOrderPaid(Long payOrderId);
 }

+ 524 - 4
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderUpdateServiceImpl.java

@@ -12,6 +12,22 @@ import cn.newfeifan.mall.framework.common.enums.UserTypeEnum;
 import cn.newfeifan.mall.framework.common.util.json.JsonUtils;
 import cn.newfeifan.mall.framework.common.util.number.MoneyUtils;
 import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.module.distri.constant.DistriConstants;
+import cn.newfeifan.mall.module.distri.controller.admin.integral.vo.IntegralSaveReqVO;
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo.PtProfitSaveReqVO;
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.PtProfitLogSaveReqVO;
+import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
+import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofit.PtProfitDO;
+import cn.newfeifan.mall.module.distri.dal.dataobject.sharepath.SharePathDO;
+import cn.newfeifan.mall.module.distri.dal.mysql.orderpercentage.OrderPercentageMapper;
+import cn.newfeifan.mall.module.distri.enums.CaclEnum;
+import cn.newfeifan.mall.module.distri.enums.SocialStatusEnum;
+import cn.newfeifan.mall.module.distri.service.duser.DuserService;
+import cn.newfeifan.mall.module.distri.service.integral.IntegralService;
+import cn.newfeifan.mall.module.distri.service.ptprofit.PtProfitService;
+import cn.newfeifan.mall.module.distri.service.ptprofitlog.PtProfitLogService;
+import cn.newfeifan.mall.module.distri.service.sharepath.SharePathService;
 import cn.newfeifan.mall.module.member.api.address.MemberAddressApi;
 import cn.newfeifan.mall.module.member.api.address.dto.MemberAddressRespDTO;
 import cn.newfeifan.mall.module.pay.api.order.PayOrderApi;
@@ -20,6 +36,8 @@ import cn.newfeifan.mall.module.pay.api.order.dto.PayOrderRespDTO;
 import cn.newfeifan.mall.module.pay.enums.order.PayOrderStatusEnum;
 import cn.newfeifan.mall.module.product.api.comment.ProductCommentApi;
 import cn.newfeifan.mall.module.product.api.comment.dto.ProductCommentCreateReqDTO;
+import cn.newfeifan.mall.module.product.dal.dataobject.sku.ProductSkuDO;
+import cn.newfeifan.mall.module.product.dal.mysql.sku.ProductSkuMapper;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderDeliveryReqVO;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderRemarkReqVO;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderUpdateAddressReqVO;
@@ -52,6 +70,7 @@ import cn.newfeifan.mall.module.trade.service.price.bo.TradePriceCalculateReqBO;
 import cn.newfeifan.mall.module.trade.service.price.bo.TradePriceCalculateRespBO;
 import cn.newfeifan.mall.module.trade.service.price.calculator.TradePriceCalculatorHelper;
 import cn.newfeifan.mall.module.trade.utils.wechat.WcChatMessageUtils;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.gson.Gson;
 import com.google.gson.JsonObject;
 import com.kuaidi100.sdk.api.Subscribe;
@@ -64,16 +83,17 @@ import com.kuaidi100.sdk.request.SubscribeReq;
 import lombok.extern.slf4j.Slf4j;
 import org.jetbrains.annotations.NotNull;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.math.RoundingMode;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
+import java.util.*;
 
 import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.*;
@@ -97,6 +117,20 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
     @Resource
     private TradeOrderItemMapper tradeOrderItemMapper;
     @Resource
+    private PtProfitService ptProfitService;
+    @Resource
+    private PtProfitLogService ptProfitLogService;
+    @Resource
+    private IntegralService integralService;
+    @Resource
+    @Lazy
+    private DuserService duserService;
+    @Resource
+    @Lazy
+    private SharePathService sharePathService;
+    @Resource
+    private ProductSkuMapper productSkuMapper;
+    @Resource
     private TradeNoRedisDAO tradeNoRedisDAO;
 
     @Resource
@@ -126,6 +160,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
     @Value("${feifan.trade.express.kd100.key}")
     private String key;
 
+    @Resource
+    private OrderPercentageMapper orderPercentageMapper;
+
     // =================== Order ===================
 
     @Override
@@ -959,6 +996,489 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
         tradeOrderMapper.updateById(order);
     }
 
+    @Override
+    @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_PAY)
+    @Transactional(rollbackFor = Exception.class)
+    public void updateOrderPaid(Long payOrderId) {
+        //查询订单提成比例
+        QueryWrapper<OrderPercentageDO> queryWrapper = new QueryWrapper<>();
+        OrderPercentageDO orderPercentageDO = orderPercentageMapper.selectOne(queryWrapper);//表中只有一条记录
+
+        /*
+         * 毛利 = 成本 * 0.38... (推广费用)
+         */
+        String grossProfitPerc = orderPercentageDO.getGrossProfitPerc();
+
+        /*
+         * 购物本人自得 百分比
+         */
+        String grossProfitUserQuotaPerc = orderPercentageDO.getGrossProfitUserQuotaPerc();
+
+        /*
+         * 推荐人(上一级) 百分比
+         */
+        String grossProfitAncestorQuotaPerc = orderPercentageDO.getGrossProfitAncestorQuotaPerc();
+
+        //add by Ben 根据支付订单id,查询所有 支付订单 对应的 订单
+        List<TradeOrderDO> TradeOrderDOList = tradeOrderMapper.selectList("pay_order_id", payOrderId);
+
+        //购物者ID
+        Long memberUserIdOfTradeOrder = TradeOrderDOList.get(0).getUserId();
+        //20240604 推荐人(上级用户ID)
+        Long ancesterUserId = tradeOrderMapper.selectAncesterByMemberUserId(memberUserIdOfTradeOrder);
+
+        for (TradeOrderDO tradeOrderDO : TradeOrderDOList) {
+
+            Long tradeOrderId = tradeOrderDO.getId();
+
+//            System.out.println("#########updateOrderPaid####tradeOrderId:"+tradeOrderId);
+
+            // 1. 校验并获得交易订单(可支付)
+            KeyValue<TradeOrderDO, PayOrderRespDTO> orderResult = validateOrderPayable(tradeOrderId, payOrderId);
+
+            TradeOrderDO order = orderResult.getKey();
+            PayOrderRespDTO payOrder = orderResult.getValue();
+
+            // 2. 更新 TradeOrderDO 状态为已支付,等待发货
+            int updateCount = tradeOrderMapper.updateByIdAndStatus(tradeOrderId, order.getStatus(),
+                    new TradeOrderDO().setStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()).setPayStatus(true)
+                            .setPayTime(LocalDateTime.now()).setPayChannelCode(payOrder.getChannelCode()));
+
+//            System.out.println("#########updateOrderPaid####updateCount:"+updateCount);
+
+            if (updateCount == 0) {
+                throw exception(ORDER_UPDATE_PAID_STATUS_NOT_UNPAID);
+            }
+
+            //注释 by Ben ,下面是系统原来的营销部分,和我们业务对不上,注释掉
+            // 3. 执行 TradeOrderHandler 的后置处理
+//            List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(tradeOrderId);
+
+            //注释 by Ben ,下面是系统原来的营销部分,和我们业务对不上,注释掉
+//            tradeOrderHandlers.forEach(handler -> handler.afterPayOrder(order, orderItems));
+
+            // 4. 记录订单日志
+            TradeOrderLogUtils.setOrderInfo(order.getId(), order.getStatus(), TradeOrderStatusEnum.UNDELIVERED.getStatus());
+            TradeOrderLogUtils.setUserInfo(order.getUserId(), UserTypeEnum.MEMBER.getValue());
+
+
+            // 5. 增加用户冻结积分 20240420
+
+
+            List<Long> skuList = new ArrayList<>();
+            //汇总各订单项利润
+            List<TradeOrderItemDO> TradeOrderItemList = tradeOrderItemMapper.selectList("order_id", order.getId());
+            for (TradeOrderItemDO tradeOrderItemDO : TradeOrderItemList) {
+                Long skuId = tradeOrderItemDO.getSkuId();
+                skuList.add(skuId);
+            }
+
+            List<ProductSkuDO> productSkuDOS = productSkuMapper.selectBatchIds(skuList);
+            Map<Long, ProductSkuDO> skuDOMap = new HashMap<>();
+            for (ProductSkuDO productSkuDO : productSkuDOS) {
+                skuDOMap.put(productSkuDO.getId(), productSkuDO);
+            }
+
+            Long totalFreezeAmount = 0L;//用户总的冻结积分
+
+            Long totalAncestorFreezeAmount = 0L;//推荐人总的冻结积分
+
+            Long totalFreezeHighQuota = 0L;//冻结峰值
+
+            for (TradeOrderItemDO tradeOrderItemDO : TradeOrderItemList) {
+                ProductSkuDO productSkuDO = skuDOMap.get(tradeOrderItemDO.getSkuId());
+                //这类商品的总推广费
+                Integer promotionExpenses = (productSkuDO.getPrice() - productSkuDO.getCostPrice())
+                        * tradeOrderItemDO.getCount();
+
+                //把商品项的推广费,转换为这项商品直推人获得的冻结积分
+                Long itemFreezeAmount =
+                        promotionExpenses2GrossProfitAncestorQuota(promotionExpenses,
+                                grossProfitPerc,//毛利 = 成本 * 0.38... (推广费用)
+                                grossProfitUserQuotaPerc//消费者自得额度 百分比
+                        );
+
+
+                //把商品项的推广费,转换为这项商品推荐人(上级)获得的冻结积分
+                Long ancestorItemFreezeAmount =
+                        promotionExpenses2GrossProfitAncestorQuota(promotionExpenses,
+                                grossProfitPerc,//毛利 = 成本 * 0.38... (推广费用)
+                                grossProfitAncestorQuotaPerc//消费者自得额度 百分比
+                        );
+
+                //峰值为毛利的十倍
+                BigDecimal grossProfit = new BigDecimal(promotionExpenses).multiply(new BigDecimal(grossProfitPerc)).setScale(4, RoundingMode.DOWN);
+                BigDecimal freezeHighQuota = grossProfit.multiply(new BigDecimal("10"));
+                freezeHighQuota = money2Integral(freezeHighQuota);
+                Long freezeHighQuotaInt = freezeHighQuota.longValue();
+
+                totalFreezeAmount += itemFreezeAmount;
+                totalAncestorFreezeAmount += ancestorItemFreezeAmount;
+                totalFreezeHighQuota += freezeHighQuotaInt;
+
+                //记录用户在此订单项获得的冻结积分
+                TradeOrderItemDO toid = new TradeOrderItemDO();
+                toid.setId(tradeOrderItemDO.getId());
+                toid.setIncreaseIntegral(itemFreezeAmount);
+                toid.setAncestorIncreaseIntegral(ancestorItemFreezeAmount);//20240504 add by Ben
+                toid.setFreezeHighQuota(freezeHighQuotaInt);
+                tradeOrderItemMapper.updateById(toid);
+            }
+
+            //把商品的推广费总额,转换为直推人获得的冻结积分
+//            Integer freezeAmount = promotionExpenses2GrossProfitAncestorQuota(orderPercentageMapper,totalPromotionExpenses);
+
+            String OrderNum = order.getNo();
+            //修改购物者本人获得的冻结积分
+            integralService.updateUserIntegral(tradeOrderDO.getUserId(), tradeOrderDO.getUserId(), CaclEnum.ORDER_PAY_INTEGRAL_CONSUMER, 0L, totalFreezeAmount, tradeOrderId, OrderNum);
+
+            //修改推荐人(上级)获得的冻结积分
+            integralService.updateUserIntegral(tradeOrderDO.getUserId(), ancesterUserId, CaclEnum.ORDER_PAY_INTEGRAL_ANCESTER, 0L, totalAncestorFreezeAmount, tradeOrderId, OrderNum);
+
+            //修改购物者本人获得的冻结峰值
+            integralService.updateIntegralFreezeHighQuota(tradeOrderDO.getUserId(), tradeOrderDO.getUserId(), CaclEnum.ORDER_PAY_FREEZE_HIGH_QUOTA, totalFreezeHighQuota, tradeOrderId, OrderNum);
+            log.warn("[TradeOrderUpdateServiceImpl.updateOrderPaid]$$$:[tradeOrderId({}),ancesterUserId({}),totalAncestorFreezeAmount({})]" + new Date(),
+                    tradeOrderId, ancesterUserId, totalAncestorFreezeAmount);
+
+            // 发送给微信消息给系统用户待发货消息
+//            sentWcChatMessage(order);
+        }
+
+        // 七天获得变为即算即得,后续如果恢复把这里注释即可,并打开平台定时任务得订单结算
+        calc(TradeOrderDOList, orderPercentageDO, JsonUtils.toJsonString(orderPercentageDO));
+    }
+
+    /**
+     * 计算订单支付成功后,订单项的冻结积分转换
+     *
+     * @param tradeOrderDOList  订单列表
+     * @param orderPercentageDO 参数百分比
+     * @param percentTemplate   计算百分比模板
+     */
+    private void calc(List<TradeOrderDO> tradeOrderDOList, OrderPercentageDO orderPercentageDO, String percentTemplate) {
+        // 平台收益日志
+        List<PtProfitLogSaveReqVO> ptProfitLogSaveReqVOS = new ArrayList<>();
+
+        // todo 修改用户身价 如何从订单中获取身价?
+        BigDecimal oneHundred = new BigDecimal(BigInteger.ONE);
+
+
+        // 计算,毛利中100 之外的百分比
+        BigDecimal otherOneHundred = oneHundred.subtract(new BigDecimal(orderPercentageDO.getGrossProfitUserQuotaPerc()))
+                .subtract(new BigDecimal(orderPercentageDO.getGrossProfitAncestorQuotaPerc()))
+                .subtract(new BigDecimal(orderPercentageDO.getGrossProfitPlatformQuotaPerc()));
+
+
+        tradeOrderDOList.forEach(k -> {
+            PtProfitDO ptProfitDO = ptProfitService.getPtProfit();
+            // 平台收益
+            List<PtProfitSaveReqVO> ptProfitSaveReqVOS = new ArrayList<>();
+
+            List<TradeOrderItemDO> tradeOrderItemDOS = tradeOrderItemMapper.selectListByOrderId(k.getId());
+
+            // 计算
+            // 计算利润: (价格 - 成本价格) * 产品数量
+            //用户自得和直推奖不用计算,从orderItem里面获取
+            final BigDecimal[] profit = {new BigDecimal("0"), new BigDecimal("0"), new BigDecimal("0"), new BigDecimal("0")};
+            tradeOrderItemDOS.forEach(j -> {
+                BigDecimal onePrice = new BigDecimal(j.getPrice());
+                BigDecimal oneCostPrice = new BigDecimal(j.getCostPrice());
+                BigDecimal productCount = new BigDecimal(j.getCount());
+                BigDecimal oneGrossProfit = onePrice.subtract(oneCostPrice).multiply(productCount);
+                profit[0] = profit[0].add(oneGrossProfit);  // 注意这里的改动
+                profit[1] = profit[1].add(new BigDecimal(j.getIncreaseIntegral()));     //自得积分
+                profit[2] = profit[2].add(new BigDecimal(j.getAncestorIncreaseIntegral()));     //直推奖
+                profit[3] = profit[3].add(new BigDecimal(j.getFreezeHighQuota()));     //用户获得冻结最大可用额度
+
+                // 遍历订单项拿到订单项编号
+                //将当前订单项设置为已分配权益
+                TradeOrderItemDO item = new TradeOrderItemDO();
+                item.setId(j.getId());
+                item.setDistributeBenefit(true);
+                tradeOrderItemMapper.updateById(item);
+            });
+
+
+            // 计算毛利: 利润 * 1
+            BigDecimal grossProfit = profit[0].multiply(new BigDecimal(orderPercentageDO.getGrossProfitPerc())).setScale(4, RoundingMode.DOWN);
+
+            // 计算平台收益
+            BigDecimal grossProfitAfterBonus = profit[0].multiply(oneHundred.subtract(new BigDecimal(orderPercentageDO.getGrossProfitPerc()))).setScale(4, RoundingMode.DOWN);
+
+            if (otherOneHundred.compareTo(new BigDecimal(BigInteger.ZERO)) > 0) {
+                grossProfitAfterBonus = grossProfitAfterBonus.add(grossProfit.multiply(otherOneHundred).setScale(4, RoundingMode.DOWN));
+            }
+
+            // 用户所得: 毛利 * 0.35
+            BigDecimal descendantQuota = profit[1];
+
+            // 直推奖: 毛利 * 0.3 (上一级)
+            BigDecimal ancestorQuota = profit[2];
+
+            // 平台服务费: 毛利 * 0.05
+            BigDecimal platformQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitPlatformQuotaPerc())).setScale(4, RoundingMode.DOWN);
+
+
+            // 计算当前下单人的毛利的十倍
+//            BigDecimal highQuota = grossProfit.multiply(new BigDecimal("10")).setScale(4, RoundingMode.DOWN);
+            BigDecimal highQuota = profit[3];
+
+            // 乘以 10000 并转换为整数
+            Long ancestorQuotaInt = ancestorQuota.longValue();
+            Long descendantQuotaInt = descendantQuota.longValue();
+            Long highQuotaInt = highQuota.longValue();
+            Long grossProfitAfterBonusInt = grossProfitAfterBonus.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
+            Long platformQuotaInt = platformQuota.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
+
+
+            // 获取当前下单人关系
+            SharePathDO sharePath = sharePathService.getSharePathByDescendant(k.getUserId());
+            // 如果sharePath为空, 则说明没有直推人关系
+            IntegralDO integralDOAncestor = integralService.selectByUser(sharePath.getAncestor());      //父级
+            IntegralDO integralDO = integralService.selectByUser(sharePath.getDescendant());            //自己
+            IntegralDO ptIntegral = integralService.selectByUser(1L);                         //pt
+
+
+            // ========== 身价计算 ==============
+            //推荐人身价计算
+            double orderAncestorSocialStatus = Double.parseDouble(orderPercentageDO.getOrderAncestorSocialStatus());
+            double ancestorSocial = k.getTotalPrice() * orderAncestorSocialStatus / 100;
+            duserService.updateDuserSocial(integralDOAncestor.getUserId(), (long) ancestorSocial, SocialStatusEnum.SHOPPING_ANCESTOR_SOCIAL.getStatus());
+
+            //自得身价计算
+            double orderUserSocialStatus = Double.parseDouble(orderPercentageDO.getOrderUserSocialStatus());
+            double descendantSocial = k.getTotalPrice() * orderUserSocialStatus / 100;
+            duserService.updateDuserSocial(integralDO.getUserId(), (long) descendantSocial, SocialStatusEnum.SHOPPING_SOCIAL.getStatus());
+
+            /*
+            原本这里有添加到distri_order_calc表的记录,但是现在要合赢奖和(直推奖、自得奖)分开,所以现在搬走了
+             */
+
+            // ========== 修改用户钱包 =================
+
+            //直推奖也要限制额度
+            Long ancestorHighQuota = integralDOAncestor.getHighQuota() + new BigDecimal(orderPercentageDO.getBaseMaxQuota()).longValue();//加上基础的最大额度值
+
+            //amount用于记录本次添加的值
+            Long amount = 0L;
+            //平台需要补回的收益
+            Long ptReplenish = ancestorQuotaInt;
+
+            //如果直推人的可获取额度大于0,则能够获取
+            if (ancestorHighQuota.compareTo(0L) > 0) {
+                if (ancestorHighQuota.compareTo(ancestorQuotaInt) > 0) {
+                    //如果最大额度 > 直推人可获取额度,则直接获取
+                    amount = ancestorQuotaInt;
+                    //平台没有需要补回的收益
+                    ptReplenish = 0L;
+                } else {
+                    //如果最大额度 < 直推人可获取额度,则获取自己的最大额度
+                    amount = ancestorHighQuota;
+                    //用户本次没有拿到的直推奖
+                    ptReplenish = ancestorQuotaInt - ancestorHighQuota;
+                }
+            }
+            changeUserWallet(integralDO, integralDOAncestor, ptIntegral, amount,
+                    descendantQuotaInt, highQuotaInt, grossProfitAfterBonusInt, platformQuotaInt, ptReplenish);
+
+            // ========== 修改平台信息 =================
+            // 每个订单计算的过程
+            // 增加平台收益
+            // 平台服务费
+            PtProfitSaveReqVO ptProfitSaveReqVO =
+                    PtProfitSaveReqVO.builder()
+                            .ptAdd(platformQuotaInt)
+                            .ptGrossAdd(grossProfitAfterBonusInt)
+                            .ptTotalAdd(platformQuotaInt + grossProfitAfterBonusInt).build();
+
+
+            // 当直推人获取的积分额度不足时,平台收益要加回来,并生成log
+            if (ptReplenish.compareTo(0L) > 0) {
+                calcIntegral(ptProfitSaveReqVOS, ptProfitSaveReqVO, ptReplenish,
+                        k.getId(), k.getNo());
+            }
+
+            ptProfitSaveReqVOS.add(ptProfitSaveReqVO);
+            // ========== 增加日志记录 =================
+
+            // 平台记录
+            // 平台总收益
+            // 平台总收益
+            PtProfitLogSaveReqVO ptTotal = PtProfitLogSaveReqVO.builder()
+                    .orderId(k.getId())
+                    .profitStatus(CaclEnum.PLATFORM_TOTAL_ADD.getType())
+                    .orderNo(k.getNo())
+                    .amount(platformQuotaInt + grossProfitAfterBonusInt)
+                    .afterAmount(ptProfitDO.getPtTotalAdd() + platformQuotaInt + grossProfitAfterBonusInt)
+                    .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
+                    .build();
+            // 平台收益
+            PtProfitLogSaveReqVO ptGrossAddLog = PtProfitLogSaveReqVO.builder()
+                    .orderId(k.getId())
+                    .profitStatus(CaclEnum.PLATFORM_REVENUE.getType())
+                    .orderNo(k.getNo())
+                    .amount(grossProfitAfterBonusInt)
+                    .afterAmount(ptProfitDO.getPtGrossAdd() + ptProfitSaveReqVO.getPtGrossAdd())
+                    .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
+                    .build();
+
+            // 平台服务费
+            PtProfitLogSaveReqVO ptAddLog = PtProfitLogSaveReqVO.builder()
+                    .orderId(k.getId())
+                    .profitStatus(CaclEnum.PLATFORM_SERVICE_FEE.getType())
+                    .orderNo(k.getNo())
+                    .amount(platformQuotaInt)
+                    .afterAmount(ptProfitDO.getPtAdd() + ptProfitSaveReqVO.getPtAdd())
+                    .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
+                    .build();
+
+
+            // 直推奖记录
+            PtProfitLogSaveReqVO tjrLog = PtProfitLogSaveReqVO.builder()
+                    .orderId(k.getId())
+                    .profitStatus(CaclEnum.RECOMMENDED_PERSON_QUOTA.getType())
+                    .orderNo(k.getNo())
+                    .userId(sharePath.getAncestor())
+                    .amount(amount)
+                    .afterAmount(integralDOAncestor.getCurrentQuota())
+                    .freezeAmount(-amount)
+                    .afterFreezeAmount(integralDOAncestor.getFreezeQuota())
+                    .ancestorQuotaAmount(ptReplenish)
+                    .maxAvailablePointsAmount(-amount)
+                    .afterMaxAvailablePointsAmount(ancestorHighQuota - amount)
+                    .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
+                    .build();
+
+
+            // 用户自得记录 + 户冻结积分转化成可用 + 扣减最高可用额度记录
+            PtProfitLogSaveReqVO ztrLog = PtProfitLogSaveReqVO.builder()
+                    .orderId(k.getId())
+                    .profitStatus(CaclEnum.DIRECT_REFERRAL_QUOTA.getType())
+                    .orderNo(k.getNo())
+                    .userId(sharePath.getDescendant())
+                    .amount(descendantQuotaInt)
+                    .afterAmount(integralDO.getCurrentQuota())
+                    .freezeAmount(-descendantQuotaInt)
+                    .afterFreezeAmount(integralDO.getFreezeQuota())
+                    .maxAvailablePointsAmount(highQuotaInt)
+                    .afterMaxAvailablePointsAmount(integralDO.getHighQuota() + new BigDecimal(orderPercentageDO.getBaseMaxQuota()).longValue())
+                    .freezeHighQuota(-highQuotaInt)
+                    .afterFreezeHighQuota(integralDO.getFreezeHighQuota())
+                    .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
+                    .build();
+
+            ptProfitLogSaveReqVOS.add(ptTotal);
+            ptProfitLogSaveReqVOS.add(ptGrossAddLog);
+            ptProfitLogSaveReqVOS.add(ptAddLog);
+            ptProfitLogSaveReqVOS.add(tjrLog);
+            ptProfitLogSaveReqVOS.add(ztrLog);
+
+
+            PtProfitDO ptProfit = ptProfitService.getPtProfit();
+            // 计算总积分
+            Long total = ptProfitSaveReqVOS.stream().mapToLong(PtProfitSaveReqVO::getPtTotalAdd).sum();
+            Long add = ptProfitSaveReqVOS.stream().mapToLong(PtProfitSaveReqVO::getPtAdd).sum();
+            Long grossAdd = ptProfitSaveReqVOS.stream().mapToLong(PtProfitSaveReqVO::getPtGrossAdd).sum();
+            ptProfit.setPtAdd(ptProfit.getPtAdd() + add);
+            ptProfit.setPtTotalAdd(ptProfit.getPtTotalAdd() + total);
+            ptProfit.setPtGrossAdd(ptProfit.getPtGrossAdd() + grossAdd);
+            PtProfitSaveReqVO ptProfitSaveReqVO2 = PtProfitSaveReqVO.builder()
+                    .id(ptProfitDO.getId())
+                    .ptTotalAdd(ptProfit.getPtTotalAdd())
+                    .ptAdd(ptProfit.getPtAdd())
+                    .ptGrossAdd(ptProfit.getPtGrossAdd()).build();
+            ptProfitService.updatePtProfit(ptProfitSaveReqVO2);
+        });
+
+        // 信息整合
+        ptProfitLogService.saveBatch(ptProfitLogSaveReqVOS);
+    }
+
+    /**
+     * 在用户获取直推奖的时候溢出的需要加入到平台,并记录log
+     */
+    private void calcIntegral(List<PtProfitSaveReqVO> ptProfitSaveReqVOS, PtProfitSaveReqVO ptProfitSaveReqVO
+            , Long ancestorQuotaInt, Long orderId, String orderNo) {
+        ptProfitSaveReqVO.setPtGrossAdd(ptProfitSaveReqVO.getPtGrossAdd() + ancestorQuotaInt);
+        ptProfitSaveReqVO.setPtTotalAdd(ptProfitSaveReqVO.getPtGrossAdd() + ptProfitSaveReqVO.getPtAdd());
+
+        PtProfitLogSaveReqVO ptProfitLog = PtProfitLogSaveReqVO.builder()
+                .orderId(orderId)
+                .profitStatus(CaclEnum.GROSS_PROFIT_ANCESTOR_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT.getType())
+                .orderNo(orderNo)
+                .amount(ancestorQuotaInt)
+                .afterAmount(ptProfitSaveReqVOS.stream().mapToLong(PtProfitSaveReqVO::getPtGrossAdd).sum() + ancestorQuotaInt)
+                .build();
+        ptProfitLogService.createPtProfitLog(ptProfitLog);
+    }
+
+    private void changeUserWallet(IntegralDO integralDO, IntegralDO integralDOAncestor, IntegralDO pt,
+                                  Long ancestorQuota, Long descendantQuota, Long highQuota, Long ptA, Long ptB, Long ptReplenish) {
+        // 修改用户钱包
+        // 增加直推人额度
+        integralDO.setHighQuota(integralDO.getHighQuota() + highQuota);
+        //增加累计峰值
+        integralDO.setHighQuotaTotal(integralDO.getHighQuotaTotal() + highQuota);
+        integralDO.setFreezeHighQuota(integralDO.getFreezeHighQuota() - highQuota);
+        // todo 增加累计额度
+
+        integralDO.setCurrentQuota(integralDO.getCurrentQuota() + descendantQuota);
+        integralDO.setFreezeQuota(integralDO.getFreezeQuota() - descendantQuota);
+        // 增加推荐人额度
+        integralDOAncestor.setCurrentQuota(integralDOAncestor.getCurrentQuota() + ancestorQuota);
+        // 减少推荐人的可获取额度
+        integralDOAncestor.setHighQuota(integralDOAncestor.getHighQuota() - ancestorQuota);
+        integralDOAncestor.setAncestorQuota(integralDOAncestor.getAncestorQuota() + ancestorQuota);
+        integralDOAncestor.setFreezeQuota(integralDOAncestor.getFreezeQuota() - ancestorQuota - ptReplenish);
+        integralService.updateIntegral(cn.newfeifan.mall.framework.common.util.object.BeanUtils.toBean(integralDOAncestor, IntegralSaveReqVO.class));
+
+        // 增加平台额度
+        pt.setCurrentQuota(pt.getCurrentQuota() + ptA + ptB);
+
+        integralService.updateIntegral(cn.newfeifan.mall.framework.common.util.object.BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
+        integralService.updateIntegral(cn.newfeifan.mall.framework.common.util.object.BeanUtils.toBean(pt, IntegralSaveReqVO.class));
+
+    }
+
+    public static Long promotionExpenses2GrossProfitAncestorQuota(
+            /*
+            商品的推广费总额
+             */
+            Integer promotionExpenses,
+            /*
+             * 毛利 = 成本 * 0.38... (推广费用)
+             */
+            String grossProfitPerc,
+            /*
+             * 推广-推荐人/消费者本人额度 百分比
+             */
+            String grossProfitAncestorQuotaPerc
+    ) {
+
+        //转为BigDecimal
+        BigDecimal profit = new BigDecimal(String.valueOf(promotionExpenses));
+
+        // 计算毛利: 利润 * 0.38
+        BigDecimal grossProfit = profit.multiply(new BigDecimal(grossProfitPerc)).setScale(4, RoundingMode.DOWN);
+
+        // 计算直推人额度: 毛利 * 0.35
+        BigDecimal descendantQuota = grossProfit.multiply(new BigDecimal(grossProfitAncestorQuotaPerc)).setScale(4, RoundingMode.DOWN);
+
+        //把钱转为:增加的冻结积分
+        BigDecimal freezeAmount_bigDecimal = money2Integral(descendantQuota);
+
+        return freezeAmount_bigDecimal.longValue();
+    }
+
+    public static BigDecimal money2Integral(BigDecimal money) {
+        return money.multiply(DistriConstants.MONEY2INTEGRAL_BIG_DECIMAL);
+    }
+
     /**
      * 创建单个订单的评论
      *

+ 3 - 0
feifan-module-pay/feifan-module-pay-api/src/main/java/cn/newfeifan/mall/module/pay/enums/DictTypeConstants.java

@@ -40,4 +40,7 @@ public interface DictTypeConstants {
 
     String TRADE_NO = "trade_no:";
 
+    String TUP_UP_NO = "-top-up";
+
+
 }

+ 9 - 0
feifan-module-pay/feifan-module-pay-api/src/main/java/cn/newfeifan/mall/module/pay/enums/fuyouorder/FuYouPayOrderTypeEnum.java

@@ -28,4 +28,13 @@ public enum FuYouPayOrderTypeEnum {
     private final String code;
 
     private final String describe;
+
+    public static String getCode(String code){
+        for (FuYouPayOrderTypeEnum type : FuYouPayOrderTypeEnum.values()) {
+            if(type.getCode().equals(code)){
+                return type.getCode();
+            }
+        }
+        return null;
+    }
 }

+ 1 - 2
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/job/order/PayOrderSyncJob.java

@@ -12,7 +12,6 @@ import java.time.LocalDateTime;
 
 /**
  * 支付订单的同步 Job
- *
  * 由于支付订单的状态,是由支付渠道异步通知进行同步,考虑到异步通知可能会失败(小概率),所以需要定时进行同步。
  *
  * @author 非繁源码
@@ -22,7 +21,6 @@ public class PayOrderSyncJob implements JobHandler {
 
     /**
      * 同步创建时间在 N 分钟之前的订单
-     *
      * 为什么同步 10 分钟之前的订单?
      *  因为一个订单发起支付,到支付成功,大多数在 10 分钟内,需要保证轮询到。
      *  如果设置为 30、60 或者更大时间范围,会导致轮询的订单太多,影响性能。当然,你也可以根据自己的业务情况来处理。
@@ -35,6 +33,7 @@ public class PayOrderSyncJob implements JobHandler {
     @Override
     @TenantJob
     public String execute(String param) {
+        System.out.println("==============================时间" + LocalDateTime.now());
         LocalDateTime minCreateTime = LocalDateTime.now().minus(CREATE_TIME_DURATION_BEFORE);
         int count = orderService.syncOrder(minCreateTime);
         return StrUtil.format("同步支付订单 {} 个", count);

+ 25 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/order/TradeOrderProducer.java

@@ -0,0 +1,25 @@
+package cn.newfeifan.mall.module.pay.order;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Slf4j
+@Component
+public class TradeOrderProducer {
+    @Resource
+    private ApplicationContext applicationContext;
+
+
+    /**
+     * 发送订单消息
+     *
+     * @param payOrderId 支付订单id
+     */
+    public void sendTradeOrderMessage(Long payOrderId) {
+        applicationContext.publishEvent(payOrderId);
+    }
+
+}

+ 6 - 2
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/channel/PayChannelService.java

@@ -66,7 +66,6 @@ public interface PayChannelService {
 
     /**
      * 支付渠道的合法性
-     *
      * 如果不合法,抛出 {@link ServiceException} 业务异常
      *
      * @param id 渠道编号
@@ -76,7 +75,6 @@ public interface PayChannelService {
 
     /**
      * 支付渠道的合法性
-     *
      * 如果不合法,抛出 {@link ServiceException} 业务异常
      *
      * @param appId 应用编号
@@ -101,4 +99,10 @@ public interface PayChannelService {
      */
     PayClient getPayClient(Long id);
 
+    /**
+     * 判断支付渠道是否符合要求
+     * @param channelId 通道ID
+     * @return 是否符合
+     */
+    boolean getChannelById(Long channelId);
 }

+ 11 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/channel/PayChannelServiceImpl.java

@@ -13,6 +13,7 @@ import cn.newfeifan.mall.module.pay.controller.admin.channel.vo.PayChannelUpdate
 import cn.newfeifan.mall.module.pay.convert.channel.PayChannelConvert;
 import cn.newfeifan.mall.module.pay.dal.dataobject.channel.PayChannelDO;
 import cn.newfeifan.mall.module.pay.dal.mysql.channel.PayChannelMapper;
+import cn.newfeifan.mall.module.pay.enums.fuyouorder.FuYouPayOrderTypeEnum;
 import cn.newfeifan.mall.module.pay.framework.pay.core.WalletPayClient;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
@@ -205,4 +206,14 @@ public class PayChannelServiceImpl implements PayChannelService {
         return clientCache.getUnchecked(id);
     }
 
+    @Override
+    public boolean getChannelById(Long channelId) {
+        PayChannelDO payChannelDO = payChannelMapper.selectById(channelId);
+
+        if(payChannelDO == null) return false;
+
+        String code = FuYouPayOrderTypeEnum.getCode(payChannelDO.getCode());
+        return code != null;
+    }
+
 }

+ 9 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/fuyouorder/FuYouPayOrderService.java

@@ -5,6 +5,7 @@ import cn.newfeifan.mall.framework.pay.core.client.PayClient;
 import cn.newfeifan.mall.module.pay.api.refund.dto.PayRefundCreateReqDTO;
 import cn.newfeifan.mall.module.pay.dal.dataobject.channel.PayChannelDO;
 import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderDO;
+import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderExtensionDO;
 import cn.newfeifan.mall.module.pay.dal.dataobject.refund.PayRefundDO;
 
 /**
@@ -15,4 +16,12 @@ import cn.newfeifan.mall.module.pay.dal.dataobject.refund.PayRefundDO;
 public interface FuYouPayOrderService {
 
     void payRefund(PayRefundCreateReqDTO reqDTO, PayOrderDO order, PayRefundDO refund, PayChannelDO channel, PayClient client);
+
+    /**
+     * 获得支付订单
+     *
+     * @param payOrderExtensionDO 支付扩展订单
+     * @param payOrderDO 支付订单
+     */
+    PayOrderDO getPayOrderByStatus(PayOrderExtensionDO payOrderExtensionDO, PayOrderDO payOrderDO);
 }

+ 73 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/fuyouorder/FuYouPayOrderServiceImpl.java

@@ -5,14 +5,19 @@ import cn.newfeifan.mall.framework.pay.core.client.PayClient;
 import cn.newfeifan.mall.module.pay.api.refund.dto.PayRefundCreateReqDTO;
 import cn.newfeifan.mall.module.pay.dal.dataobject.channel.PayChannelDO;
 import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderDO;
+import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderExtensionDO;
 import cn.newfeifan.mall.module.pay.dal.dataobject.refund.PayRefundDO;
+import cn.newfeifan.mall.module.pay.dal.mysql.order.PayOrderExtensionMapper;
 import cn.newfeifan.mall.module.pay.dal.mysql.refund.PayRefundMapper;
 import cn.newfeifan.mall.module.pay.dal.redis.no.PayNoRedisDAO;
 import cn.newfeifan.mall.module.pay.enums.fuyouorder.AfterSaleOrderTypeEnum;
 import cn.newfeifan.mall.module.pay.enums.notify.PayNotifyTypeEnum;
+import cn.newfeifan.mall.module.pay.enums.order.PayOrderStatusEnum;
 import cn.newfeifan.mall.module.pay.enums.refund.PayRefundStatusEnum;
+import cn.newfeifan.mall.module.pay.fuiou.reqdata.CommonQueryDataReq;
 import cn.newfeifan.mall.module.pay.fuiou.reqdata.RefundDataReq;
 import cn.newfeifan.mall.module.pay.fuiou.respVO.FuYouPayRefundResponse;
+import cn.newfeifan.mall.module.pay.fuiou.respVO.FuYouQueryPayOrderResponseVO;
 import cn.newfeifan.mall.module.pay.fuiou.util.DateUtils;
 import cn.newfeifan.mall.module.pay.fuiou.util.FuiouHttpPoster;
 import cn.newfeifan.mall.module.pay.fuiou.util.MD5;
@@ -21,6 +26,7 @@ import cn.newfeifan.mall.module.pay.service.order.PayOrderService;
 import com.alibaba.fastjson.JSON;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -47,6 +53,12 @@ public class FuYouPayOrderServiceImpl implements FuYouPayOrderService {
     @Resource
     private PayNotifyService notifyService;
 
+    @Resource
+    @Lazy
+    private PayOrderService payOrderService;
+    @Resource
+    private PayOrderExtensionMapper orderExtensionMapper;
+
     @Override
     public void payRefund(PayRefundCreateReqDTO reqDTO, PayOrderDO order, PayRefundDO refund, PayChannelDO channel, PayClient client) {
         String no = noRedisDAO.generate(FUYOU_TRADE_ORDER_NO_PREFIX);
@@ -121,4 +133,65 @@ public class FuYouPayOrderServiceImpl implements FuYouPayOrderService {
             throw exception(ERROR);
         }
     }
+
+    @Override
+    public PayOrderDO getPayOrderByStatus(PayOrderExtensionDO payOrderExtensionDO, PayOrderDO payOrder) {
+
+        // 用一个新的对象接收,避免修改原对象
+        PayOrderDO payOrderDO = payOrderService.getOrder(payOrder.getId());
+
+        FuiouHttpPoster http = new FuiouHttpPoster();
+        http.setCharset("utf-8");
+        http.setUrl("https://aipay.fuioupay.com/aggregatePay/commonQuery");
+        CommonQueryDataReq req = new CommonQueryDataReq();
+        req.setVersion("1.0");
+        req.setMchnt_cd(mchnt_cd);
+        req.setRandom_str(DateUtils.getCurrentDate("yyyyMMddHHmmss")
+                + "568974");
+        req.setOrder_type(payOrderExtensionDO.getChannelCode());
+        req.setMchnt_order_no(payOrderDO.getPayOrderNo());
+        req.setTerm_id(term_id);
+        String data = MD5.MD5Encode(req.getMchnt_cd() + "|" + req.getOrder_type() + "|" +
+                req.getMchnt_order_no() + "|" + req.getTerm_id() + "|" + req.getRandom_str() + "|" +
+                req.getVersion() + "|" + privateKey);
+        req.setSign(data);
+
+        String res;
+        try {
+            res = http.newPost(JSON.toJSONString(req));
+
+            ObjectMapper mapper = new ObjectMapper();
+            FuYouQueryPayOrderResponseVO resp = mapper.readValue(res, FuYouQueryPayOrderResponseVO.class);
+
+            // 当响应结果为000000且交易状态为SUCCESS时才是支付成功
+            if (resp.getResult_code().equals(resultCode) && resp.getTrans_stat().equals(transStatus)) {
+                // 修改订单扩展信息
+                payOrderExtensionDO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus());
+
+                // 修改订单信息
+                payOrderDO.setStatus(PayOrderStatusEnum.SUCCESS.getStatus());
+                payOrderDO.setExtensionId(payOrderExtensionDO.getId());
+                payOrderDO.setNo(payOrderExtensionDO.getNo());
+                payOrderDO.setChannelOrderNo(resp.getTransaction_id());
+                payOrderDO.setChannelUserId(resp.getBuyer_id());
+                payOrderDO.setChannelId(payOrderExtensionDO.getChannelId());
+                payOrderDO.setChannelCode(payOrderExtensionDO.getChannelCode());
+
+                payOrderService.updatePayOrder(payOrderDO);
+            } else {
+                // 否则支付失败, 记录错误信息
+                payOrderExtensionDO.setChannelErrorCode(resp.getResult_code());
+                payOrderExtensionDO.setChannelErrorMsg(resp.getResult_msg());
+
+            }
+            payOrderExtensionDO.setChannelNotifyData(res);
+            orderExtensionMapper.updateById(payOrderExtensionDO);
+
+        } catch (Exception e) {
+            ErrorCode ERROR = new ErrorCode(1_007_901_006, "查询支付订单失败");
+            throw exception(ERROR);
+        }
+
+        return payOrderDO;
+    }
 }

+ 1 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/order/PayOrderService.java

@@ -153,4 +153,5 @@ public interface PayOrderService {
      */
     PayOrderDO getOrderByTradeOrderId(Long id);
 
+    void updatePayOrder(PayOrderDO payOrderDO);
 }

+ 59 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/service/order/PayOrderServiceImpl.java

@@ -25,15 +25,20 @@ import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderExtensionDO;
 import cn.newfeifan.mall.module.pay.dal.mysql.order.PayOrderExtensionMapper;
 import cn.newfeifan.mall.module.pay.dal.mysql.order.PayOrderMapper;
 import cn.newfeifan.mall.module.pay.dal.redis.no.PayNoRedisDAO;
+import cn.newfeifan.mall.module.pay.enums.DictTypeConstants;
 import cn.newfeifan.mall.module.pay.enums.notify.PayNotifyTypeEnum;
 import cn.newfeifan.mall.module.pay.enums.order.PayOrderStatusEnum;
 import cn.newfeifan.mall.module.pay.framework.pay.config.PayProperties;
+import cn.newfeifan.mall.module.pay.order.TradeOrderProducer;
 import cn.newfeifan.mall.module.pay.service.app.PayAppService;
 import cn.newfeifan.mall.module.pay.service.channel.PayChannelService;
+import cn.newfeifan.mall.module.pay.service.fuyouorder.FuYouPayOrderService;
 import cn.newfeifan.mall.module.pay.service.notify.PayNotifyService;
+import cn.newfeifan.mall.module.pay.topupconsumptionpoints.TopUpConsumptionPointsProducer;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.google.common.annotations.VisibleForTesting;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
@@ -76,6 +81,15 @@ public class PayOrderServiceImpl implements PayOrderService {
     @Resource
     private PayNotifyService notifyService;
 
+    @Resource
+    private TradeOrderProducer tradeOrderProducer;
+    @Resource
+    private TopUpConsumptionPointsProducer topUpConsumptionPointsProducer;
+
+    @Resource
+    @Lazy
+    private FuYouPayOrderService fuYouPayOrderService;
+
     @Override
     public PayOrderDO getOrder(Long id) {
         return orderMapper.selectById(id);
@@ -359,6 +373,18 @@ public class PayOrderServiceImpl implements PayOrderService {
         if (updateCounts == 0) { // 校验状态,必须是待支付
             throw exception(PAY_ORDER_STATUS_IS_NOT_WAITING);
         }
+        PayOrderDO payOrderDO = orderMapper.selectById(order.getId());
+        System.out.println(payOrderDO.getStatus());
+
+        // 判断是商品订单还是充值订单
+        if (payOrderDO.getNo().contains(DictTypeConstants.TUP_UP_NO)) {
+            // 充值消费分订单
+            topUpConsumptionPointsProducer.sendTradeOrderMessage(payOrderDO);
+        } else {
+            //如果确实是漏了订单未支付成功,那就补充回来
+            tradeOrderProducer.sendTradeOrderMessage(order.getId());
+        }
+
         log.info("[updateOrderExtensionSuccess][order({}) 更新为已支付]", order.getId());
         return false;
     }
@@ -471,12 +497,35 @@ public class PayOrderServiceImpl implements PayOrderService {
      */
     private boolean syncOrder(PayOrderExtensionDO orderExtension) {
         try {
+
+            // 如果是对接富友的支付单,则查询富友的订单状态
+            if (channelService.getChannelById(orderExtension.getChannelId())) {
+                PayOrderDO order = orderMapper.selectById(orderExtension.getOrderId());
+
+                // 查询状态,修改支付订单状态
+                PayOrderDO payOrder = fuYouPayOrderService.getPayOrderByStatus(orderExtension, order);
+
+                // 支付单状态发生变化才更新
+                if (payOrder != null && !payOrder.getStatus().equals(order.getStatus()) && payOrder.getStatus().equals(PayOrderStatusEnum.SUCCESS.getStatus())) {
+                    // 判断是商品订单还是充值订单
+                    if (payOrder.getPayOrderNo().contains(DictTypeConstants.TUP_UP_NO)) {
+                        // 充值消费分订单
+                        topUpConsumptionPointsProducer.sendTradeOrderMessage(payOrder);
+                    } else {
+                        // 修改订单状态
+                        tradeOrderProducer.sendTradeOrderMessage(order.getId());
+                    }
+                }
+                return true;
+            }
+
             // 1.1 查询支付订单信息
             PayClient payClient = channelService.getPayClient(orderExtension.getChannelId());
             if (payClient == null) {
                 log.error("[syncOrder][渠道编号({}) 找不到对应的支付客户端]", orderExtension.getChannelId());
                 return false;
             }
+            log.info("支付订单号NO:" + orderExtension.getNo());
             PayOrderRespDTO respDTO = payClient.getOrder(orderExtension.getNo());
             // 1.2 回调支付结果
             notifyOrder(orderExtension.getChannelId(), respDTO);
@@ -511,6 +560,11 @@ public class PayOrderServiceImpl implements PayOrderService {
         return   orderMapper.selectOne(new LambdaQueryWrapper<PayOrderDO>().eq(PayOrderDO::getMerchantOrderId,id));
     }
 
+    @Override
+    public void updatePayOrder(PayOrderDO payOrderDO) {
+        orderMapper.updateById(payOrderDO);
+    }
+
     /**
      * 同步单个支付单
      *
@@ -525,6 +579,11 @@ public class PayOrderServiceImpl implements PayOrderService {
                 if (PayOrderStatusEnum.isClosed(orderExtension.getStatus())) {
                     continue;
                 }
+
+                if (channelService.getChannelById(orderExtension.getChannelId())) {
+                    return false;
+                }
+
                 // 情况一:校验数据库中的 orderExtension 是不是已支付
                 if (PayOrderStatusEnum.isSuccess(orderExtension.getStatus())) {
                     log.error("[expireOrder][order({}) 的 extension({}) 已支付,可能是数据不一致]",

+ 25 - 0
feifan-module-pay/feifan-module-pay-biz/src/main/java/cn/newfeifan/mall/module/pay/topupconsumptionpoints/TopUpConsumptionPointsProducer.java

@@ -0,0 +1,25 @@
+package cn.newfeifan.mall.module.pay.topupconsumptionpoints;
+
+import cn.newfeifan.mall.module.pay.dal.dataobject.order.PayOrderDO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Slf4j
+@Component
+public class TopUpConsumptionPointsProducer {
+
+    @Resource
+    private ApplicationContext applicationContext;
+
+    /**
+     * 发送订单消息
+     *
+     * @param payOrder 支付订单
+     */
+    public void sendTradeOrderMessage(PayOrderDO payOrder) {
+        applicationContext.publishEvent(payOrder);
+    }
+}