wujiefeng 9 mesi fa
parent
commit
f51090783d
100 ha cambiato i file con 4046 aggiunte e 0 eliminazioni
  1. 20 0
      .gitignore
  2. 65 0
      RewardClient/pom.xml
  3. 12 0
      RewardClient/src/main/java/com/zhongshu/reward/client/config/RewardClientConfiguration.java
  4. 8 0
      RewardClient/src/main/java/com/zhongshu/reward/client/config/RewardServerConfiguration.java
  5. 35 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/InviteReceiptsRoleModel.java
  6. 19 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/InviteSuccessModel.java
  7. 14 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/ReceiptsDetailModel.java
  8. 16 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/TotalStatisticsModel.java
  9. 81 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/TransferRulerModel.java
  10. 51 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/VipUserModel.java
  11. 21 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/param/QueryTransferParam.java
  12. 113 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/param/TransferRulerParam.java
  13. 47 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/param/WalletReceiptsParam.java
  14. 28 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/param/WalletTransferParam.java
  15. 43 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/wallet/TransferModel.java
  16. 42 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/wallet/TransferStatusModel.java
  17. 51 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/wallet/WalletModel.java
  18. 56 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/wallet/WalletReceiptsModel.java
  19. 89 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/wallet/WxTransferBatchModel.java
  20. 19 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/wechat/AccessTokenVo.java
  21. 25 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/wechat/GenerateSchemeVo.java
  22. 25 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/wechat/MiniAppUserInfoVo.java
  23. 19 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/wechat/PhoneLoginParam.java
  24. 18 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/wechat/PhoneModel.java
  25. 43 0
      RewardClient/src/main/java/com/zhongshu/reward/client/model/wechat/WechatPhoneNumber.java
  26. 41 0
      RewardClient/src/main/java/com/zhongshu/reward/client/ret/CommentException.java
  27. 92 0
      RewardClient/src/main/java/com/zhongshu/reward/client/ret/ResultContent.java
  28. 33 0
      RewardClient/src/main/java/com/zhongshu/reward/client/ret/ResultException.java
  29. 11 0
      RewardClient/src/main/java/com/zhongshu/reward/client/ret/ResultMessage.java
  30. 39 0
      RewardClient/src/main/java/com/zhongshu/reward/client/ret/ResultState.java
  31. 20 0
      RewardClient/src/main/java/com/zhongshu/reward/client/service/InviteRecordFeignService.java
  32. 19 0
      RewardClient/src/main/java/com/zhongshu/reward/client/type/ComputationType.java
  33. 19 0
      RewardClient/src/main/java/com/zhongshu/reward/client/type/DataState.java
  34. 13 0
      RewardClient/src/main/java/com/zhongshu/reward/client/type/OperateType.java
  35. 12 0
      RewardClient/src/main/java/com/zhongshu/reward/client/type/PlatformType.java
  36. 21 0
      RewardClient/src/main/java/com/zhongshu/reward/client/type/ReceiptsStatus.java
  37. 17 0
      RewardClient/src/main/java/com/zhongshu/reward/client/type/ReceiptsType.java
  38. 11 0
      RewardClient/src/main/java/com/zhongshu/reward/client/type/TimeUnitType.java
  39. 10 0
      RewardClient/src/main/java/com/zhongshu/reward/client/type/TransferChannel.java
  40. 28 0
      RewardClient/src/main/java/com/zhongshu/reward/client/type/TransferStatus.java
  41. 12 0
      RewardClient/src/main/java/com/zhongshu/reward/client/type/UserType.java
  42. 12 0
      RewardClient/src/main/java/com/zhongshu/reward/client/type/WalletType.java
  43. 165 0
      RewardServer/pom.xml
  44. 21 0
      RewardServer/src/main/java/com/zhongshu/reward/server/RewardServerApplication.java
  45. 11 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/config/AuthConfig.java
  46. 10 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/config/ClientConfig.java
  47. 14 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/config/MVCConfig.java
  48. 13 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/config/MongoConfig.java
  49. 9 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/config/PushConfig.java
  50. 26 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/config/RedisConfig.java
  51. 27 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/config/SchedulingConfig.java
  52. 31 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/config/SnowFlakeConfig.java
  53. 38 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/config/SwaggerConfig.java
  54. 15 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/config/VipConfig.java
  55. 65 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/config/WeChatConfig.java
  56. 15 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/config/feign/ZswlCloudBdbConfig.java
  57. 11 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/config/feign/ZswlCloudShopConfig.java
  58. 22 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/controller/manager/InviteRecordManagerController.groovy
  59. 47 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/controller/wallet/InviteController.java
  60. 39 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/controller/wallet/TransferRulerController.java
  61. 102 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/controller/wallet/WalletController.java
  62. 14 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/Impl/InviteRecordDaoImpl.java
  63. 44 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/Impl/VipUserRecordDaoImpl.java
  64. 36 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/Impl/WalletDaoImpl.java
  65. 98 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/Impl/WalletReceiptsDaoImpl.java
  66. 111 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/Impl/WxTransferBatchDaoImpl.java
  67. 14 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/InviteReceiptsRoleDao.java
  68. 19 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/InviteRecordDao.java
  69. 14 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/OperateDisableDao.java
  70. 15 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/TransferRulerDao.java
  71. 19 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/VipUserRecordDao.java
  72. 17 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/WalletDao.java
  73. 22 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/WalletReceiptsDao.java
  74. 20 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/WxTransferBatchDao.java
  75. 11 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/WxTransferLogDao.java
  76. 11 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/extend/InviteRecordDaoExtend.java
  77. 14 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/extend/VipUserRecordDaoExtend.java
  78. 10 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/extend/WalletDaoExtend.java
  79. 21 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/extend/WalletReceiptsDaoExtend.java
  80. 22 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/extend/WxTransferBatchDaoExtend.java
  81. 43 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/InviteReceiptsRuler.java
  82. 46 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/InviteRecord.java
  83. 33 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/OperateDisable.java
  84. 86 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/TransferRuler.java
  85. 59 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/VipUserRecord.java
  86. 59 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/Wallet.java
  87. 77 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/WalletReceipts.java
  88. 109 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/WxTransferBatch.java
  89. 26 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/WxTransferLog.java
  90. 42 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/WxTransferScene.java
  91. 23 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/listener/VipEventListener.java
  92. 141 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/service/ChatTransferBatchService.java
  93. 57 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/service/Impl/InviteRecordFeignServiceImpl.java
  94. 8 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/service/Impl/WalletFeignServiceImpl.java
  95. 73 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/service/InviteReceiptsRulerService.java
  96. 90 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/service/RedisService.java
  97. 44 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/service/StatisticsService.java
  98. 66 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/service/TransferRulerService.java
  99. 322 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/service/WalletReceiptsService.java
  100. 59 0
      RewardServer/src/main/java/com/zhongshu/reward/server/core/service/WalletService.java

+ 20 - 0
.gitignore

@@ -0,0 +1,20 @@
+# IDE specific files
+/.idea/
+*.iml
+*.log
+*.gz
+
+# log
+/logs/
+
+# Compiler generated files
+target/
+
+
+# jrebel
+rebel.xml
+
+
+#应用库
+/application/
+/RewardServer/target/

+ 65 - 0
RewardClient/pom.xml

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>com.github.microservice</groupId>
+		<artifactId>PParent</artifactId>
+		<version>1.0.0-SNAPSHOT</version>
+		<relativePath>../../../super/PParent</relativePath>
+	</parent>
+
+
+	<groupId>com.zhongshu</groupId>
+	<artifactId>RewardClient</artifactId>
+	<name>RewardClient</name>
+	<properties>
+		<java.version>11</java.version>
+	</properties>
+	<dependencies>
+
+
+		<dependency>
+			<groupId>com.github.microservice</groupId>
+			<artifactId>PCore</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<!--应用中心客户端-->
+		<dependency>
+			<groupId>com.github.microservice.components</groupId>
+			<artifactId>ApplicationClient</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+
+		<dependency>
+			<groupId>com.github.microservice.auth</groupId>
+			<artifactId>AuthClient</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.github.xiaoymin</groupId>
+			<artifactId>knife4j-spring-boot-starter</artifactId>
+			<version>3.0.3</version>
+		</dependency>
+
+		<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
+		<dependency>
+			<groupId>cn.hutool</groupId>
+			<artifactId>hutool-all</artifactId>
+			<version>5.8.20</version>
+		</dependency>
+
+
+		<dependency>
+			<groupId>com.github.wechatpay-apiv3</groupId>
+			<artifactId>wechatpay-java</artifactId>
+			<version>0.2.12</version>
+		</dependency>
+
+	</dependencies>
+
+
+</project>

+ 12 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/config/RewardClientConfiguration.java

@@ -0,0 +1,12 @@
+package com.zhongshu.reward.client.config;
+
+
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@EnableFeignClients("com.zhongshu.reward.client.service")
+@ComponentScan({"com.zhongshu.reward.client"})
+public class RewardClientConfiguration {
+}

+ 8 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/config/RewardServerConfiguration.java

@@ -0,0 +1,8 @@
+package com.zhongshu.reward.client.config;
+
+
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class RewardServerConfiguration {
+}

+ 35 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/InviteReceiptsRoleModel.java

@@ -0,0 +1,35 @@
+package com.zhongshu.reward.client.model;
+
+import com.zhongshu.reward.client.type.ComputationType;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wjf
+ * @date 2024/8/7
+ */
+@Data
+public class InviteReceiptsRoleModel {
+
+    private String id;
+
+    @ApiModelProperty("规则名称")
+    private String roleName;
+
+    @ApiModelProperty("套餐id")
+    private String setMealId;
+
+    @ApiModelProperty("计算规则:固定、百分比")
+    private ComputationType computation;
+
+    @ApiModelProperty("金额额度")
+    private BigDecimal baseTotal;
+
+    @ApiModelProperty("生效状态")
+    private boolean disable;
+
+    @ApiModelProperty("生效范围是否所有")
+    private boolean isALL = true;
+}

+ 19 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/InviteSuccessModel.java

@@ -0,0 +1,19 @@
+package com.zhongshu.reward.client.model;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wjf
+ * @date 2024/8/13
+ */
+@Data
+public class InviteSuccessModel {
+
+    private String id;
+
+    private String userId;
+
+    private BigDecimal totalAmount;
+}

+ 14 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/ReceiptsDetailModel.java

@@ -0,0 +1,14 @@
+package com.zhongshu.reward.client.model;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wjf
+ * @date 2024/8/12
+ */
+
+@Data
+public class ReceiptsDetailModel {
+}

+ 16 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/TotalStatisticsModel.java

@@ -0,0 +1,16 @@
+package com.zhongshu.reward.client.model;
+
+import lombok.Data;
+
+/**
+ * @author wjf
+ * @date 2024/7/31
+ */
+
+@Data
+public class TotalStatisticsModel {
+
+    private String id;
+
+    private Integer totalAmount;
+}

+ 81 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/TransferRulerModel.java

@@ -0,0 +1,81 @@
+package com.zhongshu.reward.client.model;
+
+import com.zhongshu.reward.client.type.TimeUnitType;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wjf
+ * @date 2024/8/12
+ */
+@Data
+public class TransferRulerModel {
+
+    private String id;
+
+    private Long updateTime;
+
+    private Long createTime;
+
+    /**
+     * 单笔最小提现金额
+     */
+    private BigDecimal minTotal = BigDecimal.ZERO;
+
+    /**
+     * 单笔最大提现金额
+     */
+    private BigDecimal maxTotal = BigDecimal.ZERO;
+
+    /**
+     * 单日最大转账金额
+     */
+    private BigDecimal dayMaxTotal = BigDecimal.ZERO;
+
+    /**
+     * 提现手续费
+     */
+    private BigDecimal commission = BigDecimal.ZERO;
+
+    /**
+     * 提现次数
+     */
+    private Integer size;
+
+    /**
+     * 时间单位
+     */
+    private TimeUnitType timeUnit;
+
+    /**
+     * 每月开始号数
+     */
+    private Integer startDay;
+
+    /**
+     * 每月结束号数
+     */
+    private Integer endDay;
+
+    /**
+     * 每日开始时
+     */
+    private Integer startHour;
+
+    /**
+     * 每日开始分
+     */
+    private Integer startMinute;
+
+    /**
+     * 每日结束时
+     */
+    private Integer endHour;
+
+    /**
+     * 每日结束分
+     */
+    private Integer endMinute;
+
+}

+ 51 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/VipUserModel.java

@@ -0,0 +1,51 @@
+package com.zhongshu.reward.client.model;
+
+import com.zhongshu.reward.client.type.ReceiptsStatus;
+import com.zhongshu.reward.client.type.ReceiptsType;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wjf
+ * @date 2024/8/12
+ */
+@Data
+public class VipUserModel {
+
+    @ApiModelProperty("金额")
+    private BigDecimal total = BigDecimal.ZERO;
+
+    @ApiModelProperty("到账类型")
+    private ReceiptsType receiptsType;
+
+    @ApiModelProperty("状态")
+    private ReceiptsStatus status;
+
+    @ApiModelProperty("预计到账时间")
+    private Long estimatedTime;
+
+    @ApiModelProperty("实际到账时间")
+    private Long receiptsTime;
+
+    @ApiModelProperty("注册时间")
+    private Long registerTime;
+
+    @ApiModelProperty("会员等级")
+    private String planningId;
+
+    @ApiModelProperty("套餐名称")
+    private String planningName;
+
+    @ApiModelProperty("订购时间")
+    private Long operateTime;
+
+    @ApiModelProperty("电话")
+    private String phone;
+
+//    @ApiModelProperty("套餐")
+//    private String saleModalId;
+
+}

+ 21 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/param/QueryTransferParam.java

@@ -0,0 +1,21 @@
+package com.zhongshu.reward.client.model.param;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+/**
+ * @author wjf
+ * @date 2024/7/29
+ */
+@Data
+public class QueryTransferParam {
+
+    @Schema(name = "walletId", description = "钱包id")
+    private String walletId;
+
+    @Schema(name = "year", description = "年")
+    private Integer year;
+
+    @Schema(name = "month", description = "月")
+    private Integer month;
+}

+ 113 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/param/TransferRulerParam.java

@@ -0,0 +1,113 @@
+package com.zhongshu.reward.client.model.param;
+
+import com.zhongshu.reward.client.type.TimeUnitType;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiParam;
+import lombok.Data;
+import org.checkerframework.checker.units.qual.min;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import java.math.BigDecimal;
+
+/**
+ * @author wjf
+ * @date 2024/8/12
+ */
+@Data
+public class TransferRulerParam {
+
+    private String id;
+
+    /**
+     * 单笔最小提现金额
+     */
+    @ApiModelProperty("单笔最小提现金额")
+    @Max(value = 200000, message = "单笔提现金额不得超过 2000")
+    @Min(value = 30, message = "单笔提现金额不得低于 3")
+    private BigDecimal minTotal = BigDecimal.ZERO;
+
+    /**
+     * 单笔最大提现金额
+     */
+    @ApiModelProperty("单笔最大提现金额")
+    @Max(value = 200000, message = "单笔提现金额不得超过 2000")
+    @Max(value = 30, message = "单笔提现金额不得低于3")
+    private BigDecimal maxTotal = BigDecimal.ZERO;
+
+    /**
+     * 单日最大转账金额
+     */
+    @ApiModelProperty("单日最大转账金额")
+    private BigDecimal dayMaxTotal = BigDecimal.ZERO;
+
+    /**
+     * 提现手续费
+     */
+    @ApiModelProperty("提现手续费")
+    private BigDecimal commission = BigDecimal.ZERO;
+
+    /**
+     * 提现次数
+     */
+    @ApiModelProperty("提现次数")
+    @Max(value = 2000, message = "单日最大转账金额不得超过 100000")
+
+    private Integer size;
+
+    /**
+     * 时间单位
+     */
+    @ApiModelProperty("时间单位")
+    private TimeUnitType timeUnit;
+
+    /**
+     * 每月开始号数
+     */
+    @ApiModelProperty("每月开始号数")
+    @Max(value = 31, message = "超出月份天数")
+    @Max(value = 1, message = "日数最小为1")
+    private Integer startDay;
+
+    /**
+     * 每月结束号数
+     */
+    @ApiModelProperty("每月结束号数")
+    @Max(value = 31, message = "超出月份天数")
+    @Max(value = 1, message = "日数最小为1")
+    private Integer endDay;
+
+    /**
+     * 每日开始时
+     */
+    @ApiModelProperty("每日开始时")
+    @Max(value = 23, message = "不过超过23时")
+    @Max(value = 0, message = "不得小于0时")
+    private Integer startHour;
+
+    /**
+     * 每日开始分
+     */
+    @Max(value = 23, message = "不过超过23时")
+    @Max(value = 0, message = "不得小于0时")
+    @ApiModelProperty("每日开始分")
+    private Integer startMinute;
+
+    /**
+     * 每日结束时
+     */
+    @Max(value = 59, message = "不过超过59分")
+    @Max(value = 0, message = "不得小于0分")
+    @ApiModelProperty("每日结束时")
+    private Integer endHour;
+
+    /**
+     * 每日结束分
+     */
+    @Max(value = 59, message = "不过超过59分")
+    @Max(value = 0, message = "不得小于0分")
+    @ApiModelProperty("每日结束分")
+    private Integer endMinute;
+}

+ 47 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/param/WalletReceiptsParam.java

@@ -0,0 +1,47 @@
+package com.zhongshu.reward.client.model.param;
+
+
+import com.zhongshu.reward.client.type.ReceiptsType;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wjf
+ * @date 2024/8/6
+ */
+@Data
+public class WalletReceiptsParam {
+
+    /**
+     * 邀请人userId
+     */
+    private String inviteId;
+
+    /**
+     * 购买会员用户id
+     */
+    private String userId;
+
+    /**
+     * 预计到账时间
+     */
+    private Long estimatedTime;
+
+    /**
+     * 到账类型
+     */
+    private ReceiptsType receiptsType;
+
+    /**
+     * 到账金额
+     */
+    private BigDecimal total = BigDecimal.ZERO;
+
+    /**
+     * 外部订单号
+     */
+    private String outTradeNo;
+
+
+}

+ 28 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/param/WalletTransferParam.java

@@ -0,0 +1,28 @@
+package com.zhongshu.reward.client.model.param;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * 钱包提现参数
+ * @author wjf
+ * @date 2024/8/5
+ */
+@Data
+public class WalletTransferParam {
+
+    @Schema(name = "walletId", description = "钱包id")
+    private String walletId;
+
+    @Schema(name = "total", description = "提现金额")
+    private BigDecimal total = BigDecimal.ZERO;
+
+    @Schema(name = "openid", description = "微信openid")
+    private String openid;
+
+    @Schema(name = "appid", description = "appid")
+    private String appid;
+
+}

+ 43 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/wallet/TransferModel.java

@@ -0,0 +1,43 @@
+package com.zhongshu.reward.client.model.wallet;
+
+import com.google.gson.annotations.SerializedName;
+import com.wechat.pay.java.core.cipher.Encryption;
+import com.wechat.pay.java.service.transferbatch.model.TransferDetailInput;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class TransferModel {
+
+
+//    @SerializedName("appid")
+//    private String appid;
+//    /** 商家批次单号 说明:商户系统内部的商家批次单号,要求此参数只能由数字、大小写字母组成,在商户系统内部唯一 */
+    @SerializedName("out_batch_no")
+    private String outBatchNo;
+    /** 批次名称 说明:该笔批量转账的名称 */
+    @SerializedName("batch_name")
+    private String batchName;
+    /** 批次备注 说明:转账说明,UTF8编码,最多允许32个字符 */
+    @SerializedName("batch_remark")
+    private String batchRemark;
+    /** 转账总金额 说明:转账金额单位为“分”。转账总金额必须与批次内所有明细转账金额之和保持一致,否则无法发起转账操作 */
+    @SerializedName("total_amount")
+    private Long totalAmount;
+    /** 转账总笔数 说明:一个转账批次单最多发起一千笔转账。转账总笔数必须与批次内所有明细之和保持一致,否则无法发起转账操作 */
+    @SerializedName("total_num")
+    private Integer totalNum;
+    /** 转账明细列表 说明:发起批量转账的明细列表,最多一千笔 */
+    @Encryption
+    @SerializedName("transfer_detail_list")
+    private List<TransferDetailInput> transferDetailList = new ArrayList<TransferDetailInput>();
+    /** 转账场景ID 说明:该批次转账使用的转账场景,如不填写则使用商家的默认场景,如无默认场景可为空,可前往“商家转账到零钱-前往功能”中申请。 如:1001-现金营销 */
+    @SerializedName("transfer_scene_id")
+    private String transferSceneId;
+}

+ 42 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/wallet/TransferStatusModel.java

@@ -0,0 +1,42 @@
+package com.zhongshu.reward.client.model.wallet;
+
+import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class TransferStatusModel {
+    @SerializedName("batch_id")
+    @Expose(
+            serialize = false
+    )
+    private String batchId;
+    @SerializedName("need_query_detail")
+    @Expose(
+            serialize = false
+    )
+    private Boolean needQueryDetail;
+    @SerializedName("offset")
+    @Expose(
+            serialize = false
+    )
+    private Integer offset;
+    @SerializedName("limit")
+    @Expose(
+            serialize = false
+    )
+    private Integer limit;
+    @SerializedName("detail_status")
+    @Expose(
+            serialize = false
+    )
+    private String detailStatus;
+}

+ 51 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/wallet/WalletModel.java

@@ -0,0 +1,51 @@
+package com.zhongshu.reward.client.model.wallet;
+
+import com.zhongshu.reward.client.type.DataState;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+@Data
+public class WalletModel {
+
+    private String id;
+
+    private Long createTime;
+
+    private Long updateTime;;
+
+    /**
+     * 用户id
+     */
+    private String userId;
+
+    /**
+     * 商铺id
+     */
+    private String shopId;
+
+
+    /**
+     * 账户余额(可提现金额)
+     */
+    private BigDecimal amount;
+
+    /**
+     * 未结算金额
+     */
+    private BigDecimal waitAmount;
+
+    /**
+     * 今日已提现金额
+     */
+    private BigDecimal todayTransferAmount;
+
+    /**
+     * 钱包状态
+     */
+    private DataState dataState;
+}

+ 56 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/wallet/WalletReceiptsModel.java

@@ -0,0 +1,56 @@
+package com.zhongshu.reward.client.model.wallet;
+
+import com.zhongshu.reward.client.type.ReceiptsStatus;
+import com.zhongshu.reward.client.type.ReceiptsType;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wjf
+ * @date 2024/8/6
+ */
+@Data
+public class WalletReceiptsModel {
+
+    private String id;
+
+    private Long createTime;
+
+    private Long updateTime;;
+    /**
+     * 钱包
+     */
+    private String walletId;
+
+    /**
+     * 预计到账时间
+     */
+    private Long estimatedTime;
+
+    /**
+     * 实际到账时间
+     */
+    private Long receiptsTime;
+
+    /**
+     * 到账类型
+     */
+    private ReceiptsType receiptsType;
+
+    /**
+     * 到账金额
+     */
+    private BigDecimal total = BigDecimal.ZERO;
+
+    /**
+     * 状态
+     */
+    private ReceiptsStatus status;
+
+    /**
+     * 外部订单号
+     */
+    private String outTradeNo;
+
+}

+ 89 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/wallet/WxTransferBatchModel.java

@@ -0,0 +1,89 @@
+package com.zhongshu.reward.client.model.wallet;
+
+import com.zhongshu.reward.client.type.TransferChannel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class WxTransferBatchModel {
+
+    private String id;
+
+    private Long createTime;
+
+    private Long updateTime;
+
+    /**
+     * 内部批次单号
+     */
+    private String batchNo;
+
+    /**
+     * (内部)提现明细单号
+     */
+    private String detailNo;
+
+    /**
+     * 提现钱包
+     */
+    private String walletId;
+
+    /**
+     * 提现金额
+     */
+    private BigDecimal total;
+
+    /**
+     * 提现渠道
+     */
+    private TransferChannel channel;
+
+//    /**
+//     * 提现前账户信息
+//     */
+//    private Wallet beforeWalletInfo;
+
+//    /**
+//     * 到账时间
+//     */
+//    private Long tradeTime;
+
+    /**
+     * 批次状态
+     */
+    private String batchStatus;
+
+    /**
+     * 明细状态
+     */
+    private String detailStatus;
+
+    /**
+     * wx批次单号
+     */
+    private String wxBatchId;
+
+    /**
+     * wx批次单号
+     */
+    private String wxDetailId;
+
+    /**
+     * openid
+     */
+    private String openid;
+
+    /**
+     * 异常原因
+     */
+    private String exceptionReason;
+}

+ 19 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/wechat/AccessTokenVo.java

@@ -0,0 +1,19 @@
+package com.zhongshu.reward.client.model.wechat;
+
+import lombok.Data;
+
+/**
+ */
+@Data
+public class AccessTokenVo {
+
+    /**
+     * token
+     */
+    private String accessToken;
+
+    /**
+     * 有效时间,默认2小时
+     */
+    private Integer expiresIn;
+}

+ 25 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/wechat/GenerateSchemeVo.java

@@ -0,0 +1,25 @@
+package com.zhongshu.reward.client.model.wechat;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @Author: wy
+ * @Date: 2023/7/14 10:00
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class GenerateSchemeVo {
+
+    @Schema(description = "错误码")
+    private Integer errCode;
+
+    @Schema(description = "错误信息")
+    private String errMsg;
+
+    @Schema(description = "生成的小程序 scheme 码")
+    private String openLink;
+}

+ 25 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/wechat/MiniAppUserInfoVo.java

@@ -0,0 +1,25 @@
+package com.zhongshu.reward.client.model.wechat;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @Author: wy
+ * @Date: 2023/6/25 17:02
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class MiniAppUserInfoVo {
+
+    private String openid;
+
+    @JsonProperty("session_key")
+    private String sessionKey;
+
+    private String unionid;
+
+    private String msg;
+}

+ 19 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/wechat/PhoneLoginParam.java

@@ -0,0 +1,19 @@
+package com.zhongshu.reward.client.model.wechat;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author TRX
+ * @date 2024/4/17
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class PhoneLoginParam {
+    private String phoneNumber;
+    private String deviceType;
+    private String loginType;
+    String iv;
+}

+ 18 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/wechat/PhoneModel.java

@@ -0,0 +1,18 @@
+package com.zhongshu.reward.client.model.wechat;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author TRX
+ * @date 2024/4/17
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Builder
+public class PhoneModel {
+    private String phone;
+}

+ 43 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/model/wechat/WechatPhoneNumber.java

@@ -0,0 +1,43 @@
+package com.zhongshu.reward.client.model.wechat;
+
+import lombok.Data;
+
+/**
+ *
+ */
+@Data
+public class WechatPhoneNumber {
+
+    /**
+     * 用户绑定的手机号(国外手机号会有区号)
+     */
+    private String phoneNumber;
+
+    /**
+     * 没有区号的手机号
+     */
+    private String purePhoneNumber;
+
+    /**
+     * 区号
+     */
+    private String countryCode;
+
+    /**
+     * 数据水印
+     */
+    private Watermark watermark;
+
+    @Data
+    static class Watermark {
+        /**
+         * 用户获取手机号操作的时间戳
+         */
+        private Integer timestamp;
+
+        /**
+         * 小程序appid
+         */
+        private String appid;
+    }
+}

+ 41 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/ret/CommentException.java

@@ -0,0 +1,41 @@
+package com.zhongshu.reward.client.ret;
+
+/**
+ * @Author: wy
+ * @Date: 2023/6/6 16:43
+ */
+public class CommentException extends RuntimeException {
+
+    private ResultState resultState;
+
+    private String message;
+
+    /**
+     * 参数校验异常构造方法
+     */
+    public CommentException(String message) {
+        this.message = message;
+    }
+
+    public CommentException(ResultState resultState, String message) {
+        this.resultState = resultState;
+        this.message = message;
+    }
+
+    @Override
+    public String getMessage() {
+        return message;
+    }
+
+    public void setMessage(String message) {
+        this.message = message;
+    }
+
+    public ResultState getResultState() {
+        return resultState;
+    }
+
+    public void setResultState(ResultState resultState) {
+        this.resultState = resultState;
+    }
+}

+ 92 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/ret/ResultContent.java

@@ -0,0 +1,92 @@
+package com.zhongshu.reward.client.ret;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.*;
+
+import java.util.Optional;
+
+/**
+ * 结果
+ *
+ * @param <T>
+ */
+@Builder
+@ToString(callSuper = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@AllArgsConstructor
+@NoArgsConstructor
+public class ResultContent<T> {
+
+    //内容
+    @Getter
+    @Setter
+    private T content;
+
+    //状态
+    @Getter
+    @Setter
+    private ResultState state;
+
+    //文本
+    @Getter
+    @Setter
+    private String msg;
+
+
+    //异常
+    @Getter
+    @Setter
+    private ResultException exception;
+
+
+    /**
+     * 获取内容
+     *
+     * @return
+     */
+    public Optional<T> optionalContent() {
+        return Optional.ofNullable(this.content);
+    }
+
+    public static <T> ResultContent build(ResultState state, T content) {
+        return ResultContent.builder().state(state).content(content).msg(state.getRemark()).build();
+    }
+
+    public static <T> ResultContent build(boolean bool) {
+        return build(bool ? ResultState.Success : ResultState.Fail, null);
+    }
+
+    public static <T> ResultContent build(ResultState state) {
+        return build(state, null);
+    }
+
+    public static <T> ResultContent buildContent(T content) {
+        return build(content == null ? ResultState.Fail : ResultState.Success, content);
+    }
+
+    public static <T> ResultContent buildFail(String msg) {
+        return ResultContent.builder().state(ResultState.Fail).msg(msg).build();
+    }
+
+    public static <T> ResultContent buildSuccess(String msg) {
+        return build(ResultState.Success, msg);
+    }
+
+    public static <T> ResultContent buildSuccess(T content) {
+        return build(ResultState.Success, content);
+    }
+
+    public static <T> ResultContent buildSuccess() {
+        return build(ResultState.Success, ResultState.Success.getRemark());
+    }
+
+    public boolean isSuccess()
+    {
+        return ResultState.Success.equals(this.state);
+    }
+
+    public boolean isFailed()
+    {
+        return !ResultState.Success.equals(this.state);
+    }
+}

+ 33 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/ret/ResultException.java

@@ -0,0 +1,33 @@
+package com.zhongshu.reward.client.ret;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 结果集异常
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class ResultException {
+
+    private String type;
+    private String cls;
+    private String message;
+
+
+    /**
+     * 创建异常对象
+     *
+     * @param e
+     * @return
+     */
+    public static ResultException build(Exception e) {
+        ResultException exception = new ResultException();
+        exception.type = e.getClass().getSimpleName();
+        exception.cls = e.getClass().getName();
+        exception.message = e.getMessage();
+        return exception;
+    }
+}

+ 11 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/ret/ResultMessage.java

@@ -0,0 +1,11 @@
+package com.zhongshu.reward.client.ret;
+
+/**
+ * @author TRX
+ * @date 2024/5/31
+ */
+public class ResultMessage {
+    public static final String DATA_NOT_EXIST = "数据不存在:%s";
+
+    public static final String NAME_EXIST = "名称已存在:%s";
+}

+ 39 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/ret/ResultState.java

@@ -0,0 +1,39 @@
+package com.zhongshu.reward.client.ret;
+
+import lombok.Getter;
+
+/**
+ * 结果状态模板
+ */
+public enum ResultState {
+
+    Success("成功"),
+    Fail("失败"),
+    Error("错误"),
+    Exception("异常"),
+    Robot("机器验证"),
+
+    UserExit("用户存在"),
+    UserNotExit("用户不存在"),
+    UserOrPassWordError("用户名或密码错误"),
+
+    NOT_TOKEN_ERROR("token获取失败"),
+    NOT_AUTH_ERROR("需要授权"),
+    EXPIRE_ERROR( "token已过期"),
+    INVALID_TOKEN("无效token"),
+    LOGIN_REQUIRED("需要登录"),
+    CODE_ERROR("验证码错误"),
+
+    AccountNotNull("账户不能为空"),
+    AccountExists("用户存在"),
+    AccountNotExists("账户不存在"),
+    NOT_WECHAT_AUTH("用户微信未授权"),
+    ;
+
+    @Getter
+    private String remark;
+
+    ResultState(String remark) {
+        this.remark = remark;
+    }
+}

+ 20 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/service/InviteRecordFeignService.java

@@ -0,0 +1,20 @@
+package com.zhongshu.reward.client.service;
+
+import com.zhongshu.reward.client.type.UserType;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author wjf
+ * @date 2024/8/9
+ */
+@FeignClient(name = "rewardserver/manager/inviteRecord")
+public interface InviteRecordFeignService {
+
+
+    @ApiOperation("邀请")
+    @RequestMapping(value = "goodsDetail", method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_VALUE})
+    void invite(@RequestParam("phone") String phone, @RequestParam("userId") String userId, @RequestParam("inviteUserId") String inviteUserId, @RequestParam("userType")UserType userType, @RequestParam("registerTime") Long registerTime);
+}

+ 19 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/type/ComputationType.java

@@ -0,0 +1,19 @@
+package com.zhongshu.reward.client.type;
+
+/**
+ * 返利计算方式
+ * @author wjf
+ * @date 2024/8/7
+ */
+public enum ComputationType {
+
+    /**
+     * 固定金额
+     */
+    FIXED,
+
+    /**
+     * 百分比
+     */
+    RATIO;
+}

+ 19 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/type/DataState.java

@@ -0,0 +1,19 @@
+package com.zhongshu.reward.client.type;
+
+import lombok.Getter;
+
+/**
+ * 数据状态
+ */
+public enum DataState {
+    Enable("启用"),
+    Disable("已停用"),
+    ;
+
+    @Getter
+    private String remark;
+
+    DataState(String remark) {
+        this.remark = remark;
+    }
+}

+ 13 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/type/OperateType.java

@@ -0,0 +1,13 @@
+package com.zhongshu.reward.client.type;
+
+/**
+ * @author wjf
+ * @date 2024/8/14
+ */
+public enum OperateType {
+
+    /**
+     * 提现
+     */
+    TRANSFER;
+}

+ 12 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/type/PlatformType.java

@@ -0,0 +1,12 @@
+package com.zhongshu.reward.client.type;
+
+/**
+ * @author wjf
+ * @date 2024/8/13
+ */
+public enum PlatformType {
+
+    CLIENT,
+
+    SHOP
+}

+ 21 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/type/ReceiptsStatus.java

@@ -0,0 +1,21 @@
+package com.zhongshu.reward.client.type;
+
+/**
+ * @author wjf
+ * @date 2024/8/6
+ */
+public enum ReceiptsStatus {
+
+    /**
+     * 未结算
+     */
+    WAIT,
+    /**
+     * 已结算
+     */
+    RECEIPTS,
+    /**
+     * 无返利
+     */
+    CANCEL
+}

+ 17 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/type/ReceiptsType.java

@@ -0,0 +1,17 @@
+package com.zhongshu.reward.client.type;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+public enum ReceiptsType {
+
+    /**
+     * 返利
+     */
+    REBATE,
+    /**
+     * 佣金
+     */
+    COMMISSION,
+}

+ 11 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/type/TimeUnitType.java

@@ -0,0 +1,11 @@
+package com.zhongshu.reward.client.type;
+
+/**
+ * @author wjf
+ * @date 2024/8/7
+ */
+public enum TimeUnitType {
+
+    MONTH,
+    DAY
+}

+ 10 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/type/TransferChannel.java

@@ -0,0 +1,10 @@
+package com.zhongshu.reward.client.type;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+public enum TransferChannel {
+
+    WeChat
+}

+ 28 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/type/TransferStatus.java

@@ -0,0 +1,28 @@
+package com.zhongshu.reward.client.type;
+
+import lombok.Getter;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+public enum TransferStatus {
+
+    PROCESSING("提现处理中"),
+
+    SUCCESS("已成功"),
+
+    FAIL("失败"),
+
+    CLOSE("已关闭")
+    ;
+
+
+
+    @Getter
+    private String remark;
+
+    TransferStatus(String remark){
+        this.remark =remark;
+    }
+}

+ 12 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/type/UserType.java

@@ -0,0 +1,12 @@
+package com.zhongshu.reward.client.type;
+
+/**
+ * @author wjf
+ * @date 2024/8/9
+ */
+public enum UserType {
+
+    NEW,
+
+    OLD
+}

+ 12 - 0
RewardClient/src/main/java/com/zhongshu/reward/client/type/WalletType.java

@@ -0,0 +1,12 @@
+package com.zhongshu.reward.client.type;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+public enum WalletType {
+
+    USER,
+
+    SHOP
+}

+ 165 - 0
RewardServer/pom.xml

@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>com.github.microservice</groupId>
+		<artifactId>PParent</artifactId>
+		<version>1.0.0-SNAPSHOT</version>
+		<relativePath>../../../super/PParent</relativePath>
+	</parent>
+
+
+	<groupId>com.zhongshu</groupId>
+	<artifactId>RewardServer</artifactId>
+	<name>RewardServer</name>
+	<description>返利中心</description>
+	<properties>
+		<java.version>11</java.version>
+	</properties>
+	<dependencies>
+
+		<dependency>
+			<groupId>com.github.microservice</groupId>
+			<artifactId>PCore</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<!--应用中心客户端-->
+		<dependency>
+			<groupId>com.github.microservice.components</groupId>
+			<artifactId>ApplicationClient</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+
+		<dependency>
+			<groupId>com.zswl.cloud.bdb</groupId>
+			<artifactId>zswl-cloud-bdb-client</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.zswl.cloud.shop</groupId>
+			<artifactId>zswl-cloud-shop-client</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.zhongshu</groupId>
+			<artifactId>VipClient</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+
+		<dependency>
+			<groupId>com.github.microservice.components</groupId>
+			<artifactId>MongodbData</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>com.github.microservice.components</groupId>
+			<artifactId>RedisData</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+
+		<dependency>
+			<groupId>com.alibaba</groupId>
+			<artifactId>fastjson</artifactId>
+			<version>2.0.38</version>
+		</dependency>
+        <dependency>
+            <groupId>com.aliyun.oss</groupId>
+            <artifactId>aliyun-sdk-oss</artifactId>
+            <version>3.14.0</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.zhongshu</groupId>
+            <artifactId>RewardClient</artifactId>
+			<version>${project.version}</version>
+        </dependency>
+
+		<dependency>
+			<groupId>com.github.microservice.netdisk</groupId>
+			<artifactId>NetDiskClient</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+        <dependency>
+            <groupId>com.alibaba.fastjson2</groupId>
+            <artifactId>fastjson2</artifactId>
+            <version>2.0.38</version>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba.fastjson2</groupId>
+            <artifactId>fastjson2</artifactId>
+            <version>2.0.38</version>
+        </dependency>
+
+		<dependency>
+			<groupId>com.github.microservice.components</groupId>
+			<artifactId>PushCenterClient</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+
+<!--		<dependency>-->
+<!--			<groupId>org.redisson</groupId>-->
+<!--			<artifactId>redisson-spring-boot-starter</artifactId>-->
+<!--			<version>3.17.1</version> &lt;!&ndash; 请根据实际情况选择版本 &ndash;&gt;-->
+<!--		</dependency>-->
+
+
+    </dependencies>
+
+	<build>
+
+
+		<plugins>
+			<plugin>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+				<configuration>
+					<fork>true</fork>
+				</configuration>
+				<executions>
+					<execution>
+						<goals>
+							<goal>repackage</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-jar-plugin</artifactId>
+				<configuration>
+					<excludes>
+						<!-- This is where the exclusion occurs -->
+						<exclude>**/application-*.yml</exclude>
+					</excludes>
+				</configuration>
+			</plugin>
+
+		</plugins>
+
+		<!-- properties 取 pom 配置 -->
+		<resources>
+			<resource>
+				<directory>src/main/java</directory>
+				<includes>
+					<include>**/*.xml</include>
+				</includes>
+			</resource>
+			<resource>
+				<directory>src/main/resources</directory>
+				<filtering>true</filtering>
+			</resource>
+		</resources>
+
+	</build>
+</project>

+ 21 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/RewardServerApplication.java

@@ -0,0 +1,21 @@
+package com.zhongshu.reward.server;
+
+import com.github.microservice.app.annotation.EnableApplicationClient;
+import com.github.microservice.core.boot.ApplicationBootSuper;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+
+@SpringBootApplication
+@EnableApplicationClient
+@EnableScheduling
+@ComponentScan("com.zhongshu.reward.server.core")
+public class RewardServerApplication extends ApplicationBootSuper {
+
+	public static void main(String[] args) {
+		SpringApplication.run(RewardServerApplication.class, args);
+	}
+
+}

+ 11 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/config/AuthConfig.java

@@ -0,0 +1,11 @@
+package com.zhongshu.reward.server.core.config;
+
+import com.github.microservice.auth.config.AuthClientConfiguration;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+
+@Configuration
+@Import(AuthClientConfiguration.class)
+public class AuthConfig {
+}

+ 10 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/config/ClientConfig.java

@@ -0,0 +1,10 @@
+package com.zhongshu.reward.server.core.config;
+
+import com.zhongshu.reward.client.config.RewardServerConfiguration;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+@Configuration
+@Import(RewardServerConfiguration.class)
+public class ClientConfig {
+}

+ 14 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/config/MVCConfig.java

@@ -0,0 +1,14 @@
+package com.zhongshu.reward.server.core.config;
+
+import com.github.microservice.core.mvc.MVCConfiguration;
+import com.github.microservice.core.mvc.MVCResponseConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+@Import({MVCConfiguration.class, MVCResponseConfiguration.class})
+@Configuration
+public class MVCConfig {
+
+}

+ 13 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/config/MongoConfig.java

@@ -0,0 +1,13 @@
+package com.zhongshu.reward.server.core.config;
+
+
+import com.github.microservice.components.data.mongo.mongo.config.MongoConfiguration;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
+
+@Configuration
+@Import(MongoConfiguration.class)
+@EnableMongoRepositories("com.zhongshu.reward.server.core.dao")
+public class MongoConfig {
+}

+ 9 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/config/PushConfig.java

@@ -0,0 +1,9 @@
+package com.zhongshu.reward.server.core.config;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@ComponentScan("com.github.microservice.components.push")
+public class PushConfig {
+}

+ 26 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/config/RedisConfig.java

@@ -0,0 +1,26 @@
+package com.zhongshu.reward.server.core.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+@Configuration
+public class RedisConfig {
+    /**
+     * 自定义Key为String类型Value为Object类型的Redis操作模板
+     */
+    @Bean(name = "redisTemplate")
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory){
+        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
+        redisTemplate.setConnectionFactory(redisConnectionFactory);
+
+        // key采用String的序列化方式
+        redisTemplate.setKeySerializer(new StringRedisSerializer());
+        // hash的key也采用String的序列化方式
+        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
+ 
+        return redisTemplate;
+    }
+}

+ 27 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/config/SchedulingConfig.java

@@ -0,0 +1,27 @@
+package com.zhongshu.reward.server.core.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.SchedulingConfigurer;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
+import org.springframework.scheduling.config.ScheduledTaskRegistrar;
+
+@Configuration
+@EnableScheduling
+public class SchedulingConfig implements SchedulingConfigurer {
+
+    @Bean
+    public ThreadPoolTaskScheduler taskScheduler() {
+        ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
+        scheduler.setPoolSize(5); // 设置线程池大小
+        scheduler.setThreadNamePrefix("scheduled-task-");
+        scheduler.setRemoveOnCancelPolicy(true);
+        return scheduler;
+    }
+
+    @Override
+    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
+        taskRegistrar.setTaskScheduler(taskScheduler());
+    }
+}

+ 31 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/config/SnowFlakeConfig.java

@@ -0,0 +1,31 @@
+package com.zhongshu.reward.server.core.config;
+
+import cn.hutool.core.lang.Snowflake;
+import cn.hutool.core.util.IdUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.client.ServiceInstance;
+import org.springframework.cloud.client.discovery.DiscoveryClient;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.List;
+
+@Configuration
+public class SnowFlakeConfig {
+    @Autowired
+    DiscoveryClient discoveryClient;
+
+    @Value("${spring.application.name}")
+    private String applicationName;
+
+
+    @Bean
+    public Snowflake snowflake(){
+
+        List<ServiceInstance> instances = discoveryClient.getInstances(applicationName);
+
+        return IdUtil.getSnowflake(instances.size());
+    }
+
+}

+ 38 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/config/SwaggerConfig.java

@@ -0,0 +1,38 @@
+package com.zhongshu.reward.server.core.config;
+
+import com.github.microservice.components.swagger.config.SwaggerConfiguration;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@Configuration
+@EnableSwagger2
+@Import(SwaggerConfiguration.class)
+public class SwaggerConfig {
+
+
+//    @Value("${spring.application.name}")
+//    private String applicationName;
+//    @Bean
+//    public Docket defaultApi() {
+//        return new Docket(DocumentationType.SWAGGER_2)
+//                .host("https://api.dev.zonelife.cn/")
+//                .apiInfo(apiInfo())
+//                .groupName(applicationName)
+//                .select()
+//                // 添加@Api注解才显示
+//                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
+//                .paths(PathSelectors.any())
+//                .build();
+//    }
+//
+//    /**
+//     * swagger-api接口描述信息
+//     */
+//    private ApiInfo apiInfo() {
+//        return new ApiInfoBuilder()
+//                .title(applicationName)
+//                .version("1.0.0")
+//                .build();
+//    }
+}

+ 15 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/config/VipConfig.java

@@ -0,0 +1,15 @@
+package com.zhongshu.reward.server.core.config;
+
+import com.github.microservice.auth.config.AuthClientConfiguration;
+import com.zhongshu.vip.client.config.VipCenterClientConfiguration;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+/**
+ * @author wjf
+ * @date 2024/8/8
+ */
+@Configuration
+@Import(VipCenterClientConfiguration.class)
+public class VipConfig {
+}

+ 65 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/config/WeChatConfig.java

@@ -0,0 +1,65 @@
+package com.zhongshu.reward.server.core.config;
+
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+@Data
+@Component
+//@Configuration
+@ConfigurationProperties(prefix = "wechat")
+public class WeChatConfig {
+
+    /**
+     * 商户号
+     */
+    private String merchantId;
+
+    /**
+     * 商户API私钥
+     */
+    private String privateKey;
+
+    /**
+     * 商户证书序列号
+     */
+    private String merchantSerialNumber;
+
+    /**
+     * 商户APIV3密钥
+     */
+    private String apiV3Key;
+
+    /**
+     * 资金类型 (归类)
+     */
+    private String transferSceneId;
+
+    /**
+     * 商户id
+     */
+    private String appid;
+
+//    @Bean
+//    public TransferBatchService index() {
+//        // 初始化商户配置
+//        Config config =
+//                new RSAAutoCertificateConfig.Builder()
+//                        .merchantId(merchantId)
+//                        // 使用 com.wechat.pay.java.core.util
+//                        // 中的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
+//                        .privateKey(privateKey)
+//                        .merchantSerialNumber(merchantSerialNumber)
+//                        .apiV3Key(apiV3Key)
+//                        .build();
+//
+////        com.wechat.pay.java.core.util.PemUtil
+//
+//        // 初始化服务
+//        return new TransferBatchService.Builder().config(config).build();
+//
+//
+//    }
+
+}

+ 15 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/config/feign/ZswlCloudBdbConfig.java

@@ -0,0 +1,15 @@
+package com.zhongshu.reward.server.core.config.feign;
+
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author wjf
+ * @date 2024/8/7
+ */
+@EnableFeignClients("com.zswl.cloud.bdb.client.service")
+@ComponentScan("com.zswl.cloud.bdb.client")
+@Configuration
+public class ZswlCloudBdbConfig {
+}

+ 11 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/config/feign/ZswlCloudShopConfig.java

@@ -0,0 +1,11 @@
+package com.zhongshu.reward.server.core.config.feign;
+
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+@EnableFeignClients("com.zswl.cloud.shop.client.service")
+@ComponentScan("com.zswl.cloud.shop.client")
+@Configuration
+public class ZswlCloudShopConfig {
+}

+ 22 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/controller/manager/InviteRecordManagerController.groovy

@@ -0,0 +1,22 @@
+package com.zhongshu.reward.server.core.controller.manager
+
+import com.github.microservice.auth.client.service.EnterpriseService
+import com.zhongshu.reward.client.service.InviteRecordFeignService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController
+import springfox.documentation.annotations.ApiIgnore;
+
+/**
+ * @author wjf
+ * @date 2024/8/9
+ */
+@RestController
+@RequestMapping("/manager/inviteRecord")
+@ApiIgnore
+ class InviteRecordManagerController {
+
+    @Autowired
+    @Delegate(methodAnnotations = true, parameterAnnotations = true, includeTypes = InviteRecordFeignService.class, interfaces = false)
+    private InviteRecordFeignService inviteRecordFeignService
+}

+ 47 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/controller/wallet/InviteController.java

@@ -0,0 +1,47 @@
+package com.zhongshu.reward.server.core.controller.wallet;
+
+import com.github.microservice.auth.security.annotations.ResourceAuth;
+import com.github.microservice.auth.security.type.AuthType;
+import com.zhongshu.reward.server.core.domain.WalletReceipts;
+import com.zhongshu.reward.server.core.service.StatisticsService;
+import com.zhongshu.reward.server.core.service.WalletReceiptsService;
+import io.swagger.annotations.Api;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author wjf
+ * @date 2024/8/12
+ */
+
+@Slf4j
+@RestController
+@RequestMapping("/invite")
+@Api(tags = "推广邀请")
+public class InviteController {
+
+    @Autowired
+    WalletReceiptsService walletReceiptsService;
+
+    @Autowired
+    StatisticsService statisticsService;
+
+    @Operation(summary = "邀请奖励明细", description = "邀请奖励明细")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @GetMapping(value = "rewardDetailList")
+    public Object rewardDetailList(@RequestParam("year") Integer year, @RequestParam("month") Integer month){
+        return walletReceiptsService.rewardDetail(year, month);
+    }
+
+    @Operation(summary = "我的邀请", description = "我的邀请")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @GetMapping(value = "myInvite")
+    public Object myInvite(){
+        return statisticsService.myInvite();
+    }
+}

+ 39 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/controller/wallet/TransferRulerController.java

@@ -0,0 +1,39 @@
+package com.zhongshu.reward.server.core.controller.wallet;
+
+import com.github.microservice.auth.security.annotations.ResourceAuth;
+import com.github.microservice.auth.security.type.AuthType;
+import com.zhongshu.reward.client.model.param.TransferRulerParam;
+import com.zhongshu.reward.server.core.service.TransferRulerService;
+import io.swagger.annotations.Api;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author wjf
+ * @date 2024/8/12
+ */
+@Slf4j
+@RestController
+@RequestMapping("/transferRuler")
+@Api(tags = "提现规则设置")
+public class TransferRulerController {
+
+    @Autowired
+    TransferRulerService transferRulerService;
+
+    @Operation(summary = "新增/修改提现规则", description = "新增/修改提现规则")
+//    @ResourceAuth(value = "user", type = AuthType.User)
+    @PostMapping("saveOrUpdate")
+    public Object saveOrUpdate(@RequestBody TransferRulerParam param){
+        return transferRulerService.saveOrUpdate(param);
+    }
+
+    @Operation(summary = "获取提现规则", description = "获取提现规则")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @GetMapping("getRuler")
+    public Object getRuler(){
+        return transferRulerService.getRuler();
+    }
+}

+ 102 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/controller/wallet/WalletController.java

@@ -0,0 +1,102 @@
+package com.zhongshu.reward.server.core.controller.wallet;
+
+import com.github.microservice.auth.security.annotations.ResourceAuth;
+import com.github.microservice.auth.security.type.AuthType;
+import com.zhongshu.reward.client.model.param.QueryTransferParam;
+import com.zhongshu.reward.client.model.param.WalletTransferParam;
+import com.zhongshu.reward.client.model.wechat.MiniAppUserInfoVo;
+import com.zhongshu.reward.client.ret.ResultContent;
+import com.zhongshu.reward.client.type.PlatformType;
+import com.zhongshu.reward.server.core.service.WalletReceiptsService;
+import com.zhongshu.reward.server.core.service.WalletService;
+import com.zhongshu.reward.server.core.service.WxTransferService;
+import com.zhongshu.reward.server.core.util.wx.WechatCUtil;
+import com.zhongshu.reward.server.core.util.wx.WechatSUtil;
+import groovyjarjarpicocli.CommandLine;
+import io.swagger.annotations.Api;
+import io.swagger.v3.oas.annotations.Operation;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+@Slf4j
+@RestController
+@RequestMapping("/wallet")
+@Api(tags = "钱包")
+public class WalletController {
+
+    @Autowired
+    WalletService walletService;
+
+    @Autowired
+    WxTransferService wxTransferService;
+
+    @Autowired
+    WalletReceiptsService walletReceiptsService;
+
+    @Autowired
+    WechatCUtil wechatCUtil;
+
+    @Autowired
+    WechatSUtil wechatSUtil;
+
+    @Operation(summary = "获取(开通)当前用户钱包信息", description = "获取(开通)当前用户钱包信息")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @GetMapping ("getWallet")
+    public Object getWalletByUser(){
+        return walletService.getWallet();
+    }
+
+    @SneakyThrows
+    @Operation(summary = "获取openid", description = "获取openid")
+//    @ResourceAuth(value = "user", type = AuthType.User)
+    @GetMapping ("getOpenId")
+    public Object getOpenId(@RequestParam("platformType") PlatformType platformType, @RequestParam("jscode") String jscode){
+
+        if (platformType.equals(PlatformType.CLIENT)){
+            MiniAppUserInfoVo miniAppUserInfo = wechatCUtil.getMiniAppUserInfo(jscode);
+            return ResultContent.buildContent(miniAppUserInfo.getOpenid());
+        }else if (platformType.equals(PlatformType.SHOP)){
+            MiniAppUserInfoVo miniAppUserInfo = wechatSUtil.getMiniAppUserInfo(jscode);
+            return ResultContent.buildContent(miniAppUserInfo.getOpenid());
+        }
+        return ResultContent.buildFail("没有此平台");
+    }
+
+    @Operation(summary = "发起提现", description = "发起提现")
+//    @ResourceAuth(value = "user", type = AuthType.User)
+    @PostMapping (value = "transfer", consumes = MediaType.APPLICATION_JSON_VALUE)
+    public Object transfer(@RequestBody WalletTransferParam param){
+        return wxTransferService.transfer(param);
+    }
+
+
+    @Operation(summary = "查询提现列表", description = "查询提现列表")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @PostMapping (value = "queryTransfer", consumes = MediaType.APPLICATION_JSON_VALUE)
+    public Object queryTransfer(@RequestBody QueryTransferParam param){
+        return wxTransferService.queryTransfer(param.getWalletId(), param.getYear(), param.getMonth());
+    }
+
+    @Operation(summary = "查询即将到账", description = "查询即将到账")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @GetMapping (value = "listByWallet")
+    public Object listByWallet(){
+        return walletReceiptsService.listByWallet();
+    }
+
+    @Operation(summary = "即将到账详情", description = "邀请奖励明细")
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @GetMapping (value = "receiptsDetail")
+    public Object receiptsDetail(@RequestParam("receiptsId") String receiptsId){
+        return walletReceiptsService.receiptsDetail(receiptsId);
+    }
+
+
+}

+ 14 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/Impl/InviteRecordDaoImpl.java

@@ -0,0 +1,14 @@
+package com.zhongshu.reward.server.core.dao.Impl;
+
+import com.zhongshu.reward.server.core.dao.extend.InviteRecordDaoExtend;
+import com.zhongshu.reward.server.core.domain.InviteRecord;
+import org.springframework.data.mongodb.core.query.Criteria;
+
+/**
+ * @author wjf
+ * @date 2024/8/9
+ */
+public class InviteRecordDaoImpl implements InviteRecordDaoExtend {
+
+
+}

+ 44 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/Impl/VipUserRecordDaoImpl.java

@@ -0,0 +1,44 @@
+package com.zhongshu.reward.server.core.dao.Impl;
+
+import com.zhongshu.reward.server.core.dao.extend.VipUserRecordDaoExtend;
+import com.zhongshu.reward.server.core.domain.VipUserRecord;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+
+import java.util.List;
+
+/**
+ * @author wjf
+ * @date 2024/8/13
+ */
+public class VipUserRecordDaoImpl implements VipUserRecordDaoExtend {
+
+    @Autowired
+    MongoTemplate mongoTemplate;
+
+    @Override
+    public VipUserRecord findTopOneByOperateTime(String userId, Long startTime, Long endTime) {
+
+        Criteria criteria = new Criteria();
+
+        criteria.andOperator(Criteria.where("operateTime").gte(startTime),Criteria.where("operateTime").lte(endTime));
+
+//        criteria.and("operateTime").gte(startTime);
+//
+//        criteria.and("operateTime").lte(endTime);
+
+
+        criteria.and("cpId").is(userId);
+
+        Query query = Query.query(criteria);
+        query.with(Sort.by(Sort.Order.desc("operateTime")));
+        List<VipUserRecord> vipUserRecords = mongoTemplate.find(query, VipUserRecord.class);
+        if (vipUserRecords.isEmpty()){
+            return null;
+        }
+        return vipUserRecords.get(0);
+    }
+}

+ 36 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/Impl/WalletDaoImpl.java

@@ -0,0 +1,36 @@
+package com.zhongshu.reward.server.core.dao.Impl;
+
+import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
+import com.zhongshu.reward.server.core.dao.extend.WalletDaoExtend;
+import com.zhongshu.reward.server.core.domain.Wallet;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.data.mongodb.core.query.Update;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+public class WalletDaoImpl implements WalletDaoExtend {
+
+    @Autowired
+    DBHelper dbHelper;
+
+    @Autowired
+    MongoTemplate mongoTemplate;
+
+    @Override
+    public boolean resetTodayAmount() {
+        Query query = Query.query(Criteria.where("todayTransferAmount").ne(BigDecimal.ZERO));
+        Update update = new Update();
+        update.set("todayTransferAmount", BigDecimal.ZERO);
+        this.dbHelper.updateTime(update);
+        return this.mongoTemplate.updateMulti(
+                query, update, Wallet.class
+        ).getModifiedCount() > 0;
+    }
+}

+ 98 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/Impl/WalletReceiptsDaoImpl.java

@@ -0,0 +1,98 @@
+package com.zhongshu.reward.server.core.dao.Impl;
+
+import com.zhongshu.reward.client.model.InviteSuccessModel;
+import com.zhongshu.reward.client.model.TotalStatisticsModel;
+import com.zhongshu.reward.client.type.ReceiptsStatus;
+import com.zhongshu.reward.client.type.ReceiptsType;
+import com.zhongshu.reward.server.core.dao.WalletReceiptsDao;
+import com.zhongshu.reward.server.core.dao.extend.WalletReceiptsDaoExtend;
+import com.zhongshu.reward.server.core.domain.WalletReceipts;
+import org.apache.commons.lang3.StringUtils;
+import org.hibernate.query.criteria.internal.compile.CriteriaCompiler;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.aggregation.Aggregation;
+import org.springframework.data.mongodb.core.aggregation.AggregationResults;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+
+import java.util.List;
+
+/**
+ * @author wjf
+ * @date 2024/8/12
+ */
+public class WalletReceiptsDaoImpl implements WalletReceiptsDaoExtend {
+
+    @Autowired
+    MongoTemplate mongoTemplate;
+
+    @Override
+    public List<WalletReceipts> inviteDetail(String inviteUserId, Long startTime, Long endTime) {
+        Criteria criteria = new Criteria();
+        criteria.andOperator(Criteria.where("createTime").gte(startTime),Criteria.where("createTime").lte(endTime));
+
+
+        if (StringUtils.isNotEmpty(inviteUserId)){
+            criteria.and("inviteUserId").is(inviteUserId);
+        }
+        Query query = Query.query(criteria);
+        query.with(Sort.by(Sort.Order.desc("createTime")));
+
+        return mongoTemplate.find(query, WalletReceipts.class);
+    }
+
+    @Override
+    public List<WalletReceipts> listMonth(Long startTime, Long endTime) {
+        Criteria criteria = new Criteria();
+        criteria.andOperator(Criteria.where("createTime").gte(startTime),Criteria.where("createTime").lte(endTime));
+
+//        criteria.and("createTime").gte(startTime);
+//
+//        criteria.and("createTime").lte(endTime);
+
+        criteria.and("receiptsType").is(ReceiptsType.COMMISSION);
+        criteria.and("status").is(ReceiptsStatus.WAIT);
+        Query query = Query.query(criteria);
+        query.with(Sort.by(Sort.Order.desc("createTime")));
+
+        return mongoTemplate.find(query, WalletReceipts.class);
+    }
+
+    @Override
+    public List<InviteSuccessModel> myInvite(String userId) {
+        Criteria criteria = new Criteria();
+        criteria.and("inviteUserId").is(userId);
+        criteria.and("status").in(List.of(ReceiptsStatus.WAIT, ReceiptsStatus.RECEIPTS));
+
+        Aggregation aggregation = Aggregation.newAggregation(
+                Aggregation.match(criteria),
+//                Aggregation.project("_id","amountTotal"),
+                Aggregation.group("userId").sum("total").as("totalAmount"),
+                Aggregation.project().and("_id").as("userId").and("totalAmount").as("totalAmount")
+//                Aggregation.group("tradeType").last("tradeType").as("_id")
+        );
+
+
+        AggregationResults<InviteSuccessModel> groupList = mongoTemplate.aggregate(aggregation, WalletReceipts.class, InviteSuccessModel.class);
+        return groupList.getMappedResults();
+    }
+
+    @Override
+    public List<WalletReceipts> listMonthBySetMealCode(Long startTime, Long endTime, List<String> setMealCodeList) {
+        Criteria criteria = new Criteria();
+        criteria.andOperator(Criteria.where("createTime").gte(startTime),Criteria.where("createTime").lte(endTime));
+
+//        criteria.and("createTime").gte(startTime);
+//
+//        criteria.and("createTime").lte(endTime);
+
+        criteria.and("receiptsType").is(ReceiptsType.COMMISSION);
+        criteria.and("status").in(ReceiptsStatus.WAIT,ReceiptsStatus.RECEIPTS);
+        criteria.and("outTradeNo").in(setMealCodeList);
+        Query query = Query.query(criteria);
+        query.with(Sort.by(Sort.Order.asc("createTime")));
+        return mongoTemplate.find(query, WalletReceipts.class);
+    }
+}

+ 111 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/Impl/WxTransferBatchDaoImpl.java

@@ -0,0 +1,111 @@
+package com.zhongshu.reward.server.core.dao.Impl;
+
+import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
+import com.zhongshu.reward.client.model.TotalStatisticsModel;
+import com.zhongshu.reward.client.type.TransferStatus;
+import com.zhongshu.reward.server.core.dao.extend.WxTransferBatchDaoExtend;
+import com.zhongshu.reward.server.core.domain.WxTransferBatch;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.aggregation.Aggregation;
+import org.springframework.data.mongodb.core.aggregation.AggregationResults;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.data.mongodb.core.query.Update;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+public class WxTransferBatchDaoImpl implements WxTransferBatchDaoExtend {
+
+    @Autowired
+    MongoTemplate mongoTemplate;
+
+    @Autowired
+    DBHelper dbHelper;
+
+
+    @Override
+    public List<WxTransferBatch> list(String walletId, Long startTime, Long endTime) {
+        Criteria criteria = new Criteria();
+
+        if (ObjectUtils.isNotEmpty(walletId)){
+            criteria.and("wallet._id").is(walletId);
+        }
+
+        if (null != startTime){
+            criteria.and("createTime").gte(startTime);
+        }
+
+        if (null != endTime){
+            criteria.and("createTime").lte(endTime);
+        }
+
+        Query query = Query.query(criteria);
+        query.with(Sort.by(Sort.Order.desc("createTime")));
+
+        return mongoTemplate.find(query, WxTransferBatch.class);
+    }
+
+    @Override
+    public boolean updateStatus(String id, String batchStatus, String detailStatus, TransferStatus transferStatus) {
+        Query query = Query.query(Criteria.where("_id").is(id));
+        Update update = new Update();
+        update.set("batchStatus", batchStatus);
+        update.set("detailStatus", detailStatus);
+        update.set("transferStatus", transferStatus);
+        this.dbHelper.updateTime(update);
+        return this.mongoTemplate.updateFirst(
+                query, update, WxTransferBatch.class
+        ).getModifiedCount() > 0;
+    }
+
+    public Integer countByTime(String walletId, Long startTime, Long endTime) {
+        Criteria criteria = new Criteria();
+        criteria.and("wallet._id").is(walletId);
+        criteria.andOperator(Criteria.where("createTime").gte(startTime),Criteria.where("createTime").lte(endTime));
+//        criteria.and("createTime").gte(startTime);
+//        criteria.and("createTime").lte(endTime);
+        criteria.and("transferStatus").in(List.of(TransferStatus.PROCESSING, TransferStatus.SUCCESS));
+
+        Query query = Query.query(criteria);
+        query.with(Sort.by(Sort.Order.desc("createTime")));
+        List<WxTransferBatch> wxTransferBatches = mongoTemplate.find(query, WxTransferBatch.class);
+        if (wxTransferBatches.isEmpty()){
+            return 0;
+        }
+        return wxTransferBatches.size();
+    }
+
+    public Integer sumDayTotal(String walletId, Long startTime, Long endTime){
+
+        Criteria criteria = new Criteria();
+        criteria.and("wallet._id").is(walletId);
+        criteria.andOperator(Criteria.where("createTime").gte(startTime),Criteria.where("createTime").lte(endTime));
+//        criteria.and("createTime").gte(startTime);
+//        criteria.and("createTime").lte(endTime);
+        criteria.and("transferStatus").in(List.of(TransferStatus.PROCESSING, TransferStatus.SUCCESS));
+
+        Aggregation aggregation = Aggregation.newAggregation(
+                Aggregation.match(criteria),
+//                Aggregation.project("_id","amountTotal"),
+                Aggregation.group("wallet._id").sum("total").as("totalAmount")
+//                Aggregation.group("tradeType").last("tradeType").as("_id")
+        );
+
+
+        AggregationResults<TotalStatisticsModel> groupList = mongoTemplate.aggregate(aggregation, WxTransferBatch.class, TotalStatisticsModel.class);
+
+        if (groupList.getMappedResults().size()==0){
+            return 0;
+        }
+        return groupList.getMappedResults().get(0).getTotalAmount();
+    }
+
+}

+ 14 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/InviteReceiptsRoleDao.java

@@ -0,0 +1,14 @@
+package com.zhongshu.reward.server.core.dao;
+
+import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.reward.server.core.domain.InviteReceiptsRuler;
+
+/**
+ * @author wjf
+ * @date 2024/8/7
+ */
+public interface InviteReceiptsRoleDao extends MongoDao<InviteReceiptsRuler> {
+
+    boolean existsBySetMealIdAndDisable(String setMealId, boolean disable);
+
+}

+ 19 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/InviteRecordDao.java

@@ -0,0 +1,19 @@
+package com.zhongshu.reward.server.core.dao;
+
+import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.reward.server.core.dao.extend.InviteRecordDaoExtend;
+import com.zhongshu.reward.server.core.domain.InviteRecord;
+
+/**
+ * @author wjf
+ * @date 2024/8/9
+ */
+public interface InviteRecordDao extends MongoDao<InviteRecord>, InviteRecordDaoExtend {
+
+    boolean existsByUserId(String userId);
+
+    InviteRecord findTopByUserIdOrderByCreateTime(String userId);
+
+    Integer countByInviteUserId(String inviteUserId);
+
+}

+ 14 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/OperateDisableDao.java

@@ -0,0 +1,14 @@
+package com.zhongshu.reward.server.core.dao;
+
+import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.reward.client.type.OperateType;
+import com.zhongshu.reward.server.core.domain.OperateDisable;
+
+/**
+ * @author wjf
+ * @date 2024/8/14
+ */
+public interface OperateDisableDao extends MongoDao<OperateDisable> {
+
+    OperateDisable findTopByUserIdAndType(String userId, OperateType type);
+}

+ 15 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/TransferRulerDao.java

@@ -0,0 +1,15 @@
+package com.zhongshu.reward.server.core.dao;
+
+import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.reward.server.core.domain.TransferRuler;
+
+/**
+ * @author wjf
+ * @date 2024/8/7
+ */
+public interface TransferRulerDao extends MongoDao<TransferRuler> {
+
+    TransferRuler findTop1ById(String id);
+
+
+}

+ 19 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/VipUserRecordDao.java

@@ -0,0 +1,19 @@
+package com.zhongshu.reward.server.core.dao;
+
+import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.reward.server.core.dao.extend.VipUserRecordDaoExtend;
+import com.zhongshu.reward.server.core.domain.VipUserRecord;
+
+import java.util.List;
+
+/**
+ * @author wjf
+ * @date 2024/8/8
+ */
+public interface VipUserRecordDao extends MongoDao<VipUserRecord>, VipUserRecordDaoExtend {
+
+    boolean existsByCpIdAndSucIn(String cpId, List<Integer> suc);
+    VipUserRecord findTop1ByCpIdAndSucOrderByOperateTime(String cpId, Integer suc);
+
+    VipUserRecord findTop1ByCpIdOrderByOperateTime(String cpId);
+}

+ 17 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/WalletDao.java

@@ -0,0 +1,17 @@
+package com.zhongshu.reward.server.core.dao;
+
+
+import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.reward.server.core.dao.extend.WalletDaoExtend;
+import com.zhongshu.reward.server.core.domain.Wallet;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+public interface WalletDao extends MongoDao<Wallet>, WalletDaoExtend {
+
+    Wallet findByUserId(String userId);
+
+    Wallet findTop1ById(String id);
+}

+ 22 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/WalletReceiptsDao.java

@@ -0,0 +1,22 @@
+package com.zhongshu.reward.server.core.dao;
+
+import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.reward.server.core.dao.extend.WalletReceiptsDaoExtend;
+import com.zhongshu.reward.server.core.domain.WalletReceipts;
+
+import java.util.List;
+
+/**
+ * @author wjf
+ * @date 2024/8/6
+ */
+public interface WalletReceiptsDao extends MongoDao<WalletReceipts>, WalletReceiptsDaoExtend {
+
+    List<WalletReceipts> findByWallet_IdOrderByCreateTimeDesc(String walletId);
+
+    WalletReceipts findTopByOutTradeNo(String outTradeNo);
+
+    WalletReceipts findTop1ById(String id);
+
+    WalletReceipts findTop1ByVipUserRecord_IdAndVipUserRecord_First(String vipUserRecordId, boolean first);
+}

+ 20 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/WxTransferBatchDao.java

@@ -0,0 +1,20 @@
+package com.zhongshu.reward.server.core.dao;
+
+
+import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.reward.client.type.TransferStatus;
+import com.zhongshu.reward.server.core.dao.extend.WxTransferBatchDaoExtend;
+import com.zhongshu.reward.server.core.domain.WxTransferBatch;
+
+import java.util.List;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+public interface WxTransferBatchDao extends MongoDao<WxTransferBatch>, WxTransferBatchDaoExtend {
+
+    WxTransferBatch findTop1ById(String id);
+
+    List<WxTransferBatch> findByTransferStatus(TransferStatus transferStatus);
+}

+ 11 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/WxTransferLogDao.java

@@ -0,0 +1,11 @@
+package com.zhongshu.reward.server.core.dao;
+
+import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.reward.server.core.domain.WxTransferLog;
+
+/**
+ * @author wjf
+ * @date 2024/8/14
+ */
+public interface WxTransferLogDao extends MongoDao<WxTransferLog> {
+}

+ 11 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/extend/InviteRecordDaoExtend.java

@@ -0,0 +1,11 @@
+package com.zhongshu.reward.server.core.dao.extend;
+
+import com.zhongshu.reward.server.core.domain.InviteRecord;
+
+/**
+ * @author wjf
+ * @date 2024/8/9
+ */
+public interface InviteRecordDaoExtend {
+
+}

+ 14 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/extend/VipUserRecordDaoExtend.java

@@ -0,0 +1,14 @@
+package com.zhongshu.reward.server.core.dao.extend;
+
+import com.zhongshu.reward.server.core.domain.VipUserRecord;
+
+import java.util.List;
+
+/**
+ * @author wjf
+ * @date 2024/8/13
+ */
+public interface VipUserRecordDaoExtend {
+
+    VipUserRecord findTopOneByOperateTime(String userId, Long startTime, Long endTime);
+}

+ 10 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/extend/WalletDaoExtend.java

@@ -0,0 +1,10 @@
+package com.zhongshu.reward.server.core.dao.extend;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+public interface WalletDaoExtend {
+
+    boolean resetTodayAmount();
+}

+ 21 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/extend/WalletReceiptsDaoExtend.java

@@ -0,0 +1,21 @@
+package com.zhongshu.reward.server.core.dao.extend;
+
+import com.zhongshu.reward.client.model.InviteSuccessModel;
+import com.zhongshu.reward.server.core.domain.WalletReceipts;
+
+import java.util.List;
+
+/**
+ * @author wjf
+ * @date 2024/8/12
+ */
+public interface WalletReceiptsDaoExtend {
+
+    List<WalletReceipts> inviteDetail(String inviteUserId, Long startTime, Long endTime);
+
+    List<WalletReceipts> listMonth(Long startTime, Long endTime);
+
+    List<InviteSuccessModel> myInvite(String userId);
+
+    List<WalletReceipts> listMonthBySetMealCode(Long startTime, Long endTime, List<String> setMealCodeList);
+}

+ 22 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/dao/extend/WxTransferBatchDaoExtend.java

@@ -0,0 +1,22 @@
+package com.zhongshu.reward.server.core.dao.extend;
+
+
+import com.zhongshu.reward.client.type.TransferStatus;
+import com.zhongshu.reward.server.core.domain.WxTransferBatch;
+
+import java.util.List;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+public interface WxTransferBatchDaoExtend {
+
+    List<WxTransferBatch> list(String walletId, Long startTime, Long endTime);
+
+    boolean updateStatus(String id, String batchStatus, String detailStatus, TransferStatus transferStatus);
+
+    Integer countByTime(String walletId, Long startTime, Long endTime);
+
+    Integer sumDayTotal(String walletId, Long startTime, Long endTime);
+}

+ 43 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/InviteReceiptsRuler.java

@@ -0,0 +1,43 @@
+package com.zhongshu.reward.server.core.domain;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import com.zhongshu.reward.client.type.ComputationType;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wjf
+ * @date 2024/8/7
+ */
+@Data
+@Builder
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+public class InviteReceiptsRuler extends SuperEntity {
+
+    @ApiModelProperty("规则名称")
+    private String roleName;
+
+    @ApiModelProperty("套餐id")
+    private String setMealId;
+
+    @ApiModelProperty("计算规则:固定、百分比")
+    private ComputationType computation;
+
+    @ApiModelProperty("金额额度")
+    private BigDecimal baseTotal;
+
+    @ApiModelProperty("生效状态")
+    private boolean disable;
+
+    @ApiModelProperty("生效范围是否所有")
+    private boolean isALL = true;
+
+}

+ 46 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/InviteRecord.java

@@ -0,0 +1,46 @@
+package com.zhongshu.reward.server.core.domain;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import com.zhongshu.reward.client.type.UserType;
+import com.zhongshu.vip.client.model.param.VipUserParam;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+/**
+ * @author wjf
+ * @date 2024/8/9
+ */
+@Data
+@Builder
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+public class InviteRecord extends SuperEntity {
+
+    /**
+     * 被邀请人id
+     */
+    private String userId;
+
+    /**
+     * 被邀请用户手机号
+     */
+    private String phone;
+
+    /**
+     * 邀请用户id
+     */
+    private String inviteUserId;
+
+    /**
+     * 用户类型
+     */
+    private UserType userType;
+
+    private Long registerTime;
+
+}

+ 33 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/OperateDisable.java

@@ -0,0 +1,33 @@
+package com.zhongshu.reward.server.core.domain;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import com.zhongshu.reward.client.type.OperateType;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.index.Indexed;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.util.Date;
+
+/**
+ * @author wjf
+ * @date 2024/8/14
+ */
+@Data
+@Builder
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+public class OperateDisable extends SuperEntity {
+
+    @Indexed
+    private String userId;
+
+    @Indexed
+    private OperateType type;
+
+    @Indexed(expireAfterSeconds = 0)
+    private Date TTL;
+}

+ 86 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/TransferRuler.java

@@ -0,0 +1,86 @@
+package com.zhongshu.reward.server.core.domain;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import com.zhongshu.reward.client.type.TimeUnitType;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.math.BigDecimal;
+
+/**
+ * 提现规则设置
+ * @author wjf
+ * @date 2024/8/7
+ */
+@Data
+@Builder
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+public class TransferRuler extends SuperEntity {
+
+    /**
+     * 单笔最小提现金额
+     */
+    private BigDecimal minTotal = BigDecimal.ZERO;
+
+    /**
+     * 单笔最大提现金额
+     */
+    private BigDecimal maxTotal = BigDecimal.ZERO;
+
+    /**
+     * 单日最大转账金额
+     */
+    private BigDecimal dayMaxTotal = BigDecimal.ZERO;
+
+    /**
+     * 提现手续费
+     */
+    private BigDecimal commission = BigDecimal.ZERO;
+
+    /**
+     * 提现次数
+     */
+    private Integer size;
+
+    /**
+     * 时间单位
+     */
+    private TimeUnitType timeUnit;
+
+    /**
+     * 每月开始号数
+     */
+    private Integer startDay;
+
+    /**
+     * 每月结束号数
+     */
+    private Integer endDay;
+
+    /**
+     * 每日开始时
+     */
+    private Integer startHour;
+
+    /**
+     * 每日开始分
+     */
+    private Integer startMinute;
+
+    /**
+     * 每日结束时
+     */
+    private Integer endHour;
+
+    /**
+     * 每日结束分
+     */
+    private Integer endMinute;
+
+}

+ 59 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/VipUserRecord.java

@@ -0,0 +1,59 @@
+package com.zhongshu.reward.server.core.domain;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+/**
+ * @author wjf
+ * @date 2024/8/8
+ */
+@Data
+@Builder
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+public class VipUserRecord extends SuperEntity {
+
+    @ApiModelProperty(value = "操作类型:1 订阅、 -1 退订 4:激活 5:暂停", required = true)
+    private Integer suc;
+
+    @ApiModelProperty(value = "和校园唯一识别码", required = true)
+    private String operBatch;
+
+    @ApiModelProperty(value = "用户id", required = true)
+    private String cpId;
+
+    @ApiModelProperty("会员等级")
+    private String planningId;
+
+    @ApiModelProperty("套餐名称")
+    private String planningName;
+
+    @ApiModelProperty("订购时间")
+    private Long operateTime;
+
+    @ApiModelProperty("渠道类型")
+    private String channelType;
+
+    @ApiModelProperty("渠道编码")
+    private String channelCode;
+
+    @ApiModelProperty("扩展参数")
+    private String extension;
+
+    @ApiModelProperty("电话")
+    private String phone;
+
+    @ApiModelProperty("套餐")
+    private String saleModalId;
+
+    @ApiModelProperty("5,6,7,8,9折扣")
+    private Integer discount;
+
+    private boolean first;
+}

+ 59 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/Wallet.java

@@ -0,0 +1,59 @@
+package com.zhongshu.reward.server.core.domain;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import com.zhongshu.reward.client.type.DataState;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.index.Indexed;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.math.BigDecimal;
+
+/**
+ * 钱包
+ * @author wjf
+ * @date 2024/8/5
+ */
+@Data
+@Builder
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+public class Wallet extends SuperEntity {
+
+    /**
+     * 用户id
+     */
+    @Indexed
+    private String userId;
+
+    /**
+     * 商铺id
+     */
+    @Indexed
+    private String shopId;
+
+
+    /**
+     * 账户余额(可提现金额)
+     */
+    private BigDecimal amount = BigDecimal.ZERO;
+
+    /**
+     * 未结算金额
+     */
+    private BigDecimal waitAmount = BigDecimal.ZERO;
+
+    /**
+     * 当日已提现金额
+     */
+    private BigDecimal todayTransferAmount = BigDecimal.ZERO;
+
+    /**
+     * 钱包状态
+     */
+    private DataState dataState;
+
+}

+ 77 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/WalletReceipts.java

@@ -0,0 +1,77 @@
+package com.zhongshu.reward.server.core.domain;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import com.zhongshu.reward.client.type.ReceiptsStatus;
+import com.zhongshu.reward.client.type.ReceiptsType;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.mapping.DBRef;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.math.BigDecimal;
+
+/**
+ * 到账记录
+ * @author wjf
+ * @date 2024/8/5
+ */
+@Data
+@Builder
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+public class WalletReceipts extends SuperEntity {
+
+    /**
+     * 钱包
+     */
+    @DBRef(lazy = true)
+    private Wallet wallet;
+
+    /**
+     * 邀请人id
+     */
+    private String inviteUserId;
+
+    /**
+     * 被邀请人id
+     */
+    private String userId;
+
+    /**
+     * 预计到账时间
+     */
+    private Long estimatedTime;
+
+    /**
+     * 实际到账时间
+     */
+    private Long receiptsTime;
+
+    /**
+     * 到账类型
+     */
+    private ReceiptsType receiptsType;
+
+    /**
+     * 到账金额
+     */
+    private BigDecimal total = BigDecimal.ZERO;
+
+    /**
+     * 状态
+     */
+    private ReceiptsStatus status;
+
+    /**
+     * 外部订单号
+     */
+    private String outTradeNo;
+
+    /**
+     * 产生入账的订阅消息
+     */
+    private VipUserRecord vipUserRecord;
+}

+ 109 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/WxTransferBatch.java

@@ -0,0 +1,109 @@
+package com.zhongshu.reward.server.core.domain;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import com.zhongshu.reward.client.type.TransferChannel;
+import com.zhongshu.reward.client.type.TransferStatus;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.index.Indexed;
+import org.springframework.data.mongodb.core.mapping.DBRef;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.math.BigDecimal;
+
+/**
+ * 提现记录
+ * @author wjf
+ * @date 2024/8/5
+ */
+@Data
+@Builder
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+public class WxTransferBatch extends SuperEntity {
+
+    /**
+     * 内部批次单号
+     */
+    @Indexed(unique = true)
+    private String batchNo;
+
+    /**
+     * (内部)提现明细单号
+     */
+    @Indexed
+    private String detailNo;
+
+    /**
+     * 提现钱包
+     */
+    @DBRef(lazy = true)
+    private Wallet wallet;
+
+    /**
+     * 提现金额
+     */
+    private BigDecimal total;
+
+    /**
+     * 提现渠道
+     */
+    @Indexed
+    private TransferChannel channel;
+
+    /**
+     * 提现前账户信息
+     */
+    private Wallet beforeWalletInfo;
+
+//    /**
+//     * 到账时间
+//     */
+//    private Long tradeTime;
+
+    /**
+     * 订单状态
+     */
+    @Indexed
+    private TransferStatus transferStatus;
+
+    /**
+     * 批次状态
+     */
+    @Indexed
+    private String batchStatus;
+
+    /**
+     * 明细状态
+     */
+    @Indexed
+    private String detailStatus;
+
+
+    private String closeReason;
+
+    /**
+     * wx批次单号
+     */
+    @Indexed
+    private String wxBatchId;
+
+    /**
+     * wx批次单号
+     */
+    @Indexed
+    private String wxDetailId;
+
+    /**
+     * openid
+     */
+    private String openid;
+
+    /**
+     * 异常原因
+     */
+    private String failReason;
+}

+ 26 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/WxTransferLog.java

@@ -0,0 +1,26 @@
+package com.zhongshu.reward.server.core.domain;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+/**
+ * @author wjf
+ * @date 2024/8/14
+ */
+@Data
+@Builder
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+public class WxTransferLog extends SuperEntity {
+
+    private String requestBody;
+
+    private String resultContent;
+
+    private String resultState;
+}

+ 42 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/domain/WxTransferScene.java

@@ -0,0 +1,42 @@
+package com.zhongshu.reward.server.core.domain;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.mongodb.core.index.Indexed;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.math.BigDecimal;
+
+/**
+ * 微信转账场景
+ * @author wjf
+ * @date 2024/8/5
+ */
+@Data
+@Builder
+@Document
+@AllArgsConstructor
+@NoArgsConstructor
+public class WxTransferScene extends SuperEntity {
+
+    /**
+     * 转账场景id
+     */
+    @Indexed
+    private String sceneId;
+
+    /**
+     * 单次转账额度
+     */
+    private BigDecimal onceTotal;
+
+    /**
+     * 单日转账额度
+     */
+    private BigDecimal dayTotal;
+
+
+}

+ 23 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/listener/VipEventListener.java

@@ -0,0 +1,23 @@
+package com.zhongshu.reward.server.core.listener;
+
+import com.github.microservice.auth.client.event.auth.EnterpriseApplicationEvent;
+import com.zhongshu.vip.client.event.VipUserEvent;
+import lombok.extern.slf4j.Slf4j;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.context.ApplicationListener;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author wjf
+ * @date 2024/8/7
+ */
+@Slf4j
+@Order(100)
+@Component
+public class VipEventListener implements ApplicationListener<VipUserEvent> {
+    @Override
+    public void onApplicationEvent(VipUserEvent event) {
+        log.info("收到用户会员订阅消息:{}", event.getStreamModel());
+    }
+}

+ 141 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/service/ChatTransferBatchService.java

@@ -0,0 +1,141 @@
+package com.zhongshu.reward.server.core.service;
+
+import cn.hutool.core.lang.Snowflake;
+import com.github.microservice.core.util.JsonUtil;
+import com.wechat.pay.java.core.Config;
+import com.wechat.pay.java.core.RSAAutoCertificateConfig;
+import com.wechat.pay.java.core.exception.HttpException;
+import com.wechat.pay.java.core.exception.MalformedMessageException;
+import com.wechat.pay.java.core.exception.ServiceException;
+import com.wechat.pay.java.service.transferbatch.TransferBatchService;
+import com.wechat.pay.java.service.transferbatch.model.*;
+import com.zhongshu.reward.client.model.wallet.TransferModel;
+import com.zhongshu.reward.client.model.wallet.TransferStatusModel;
+import com.zhongshu.reward.server.core.config.WeChatConfig;
+import com.zhongshu.reward.server.core.dao.WxTransferLogDao;
+import com.zhongshu.reward.server.core.domain.WxTransferLog;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+
+@Service
+@Slf4j
+public class ChatTransferBatchService {
+
+    @Autowired
+    WeChatConfig weChatConfig;
+
+
+//    @Autowired
+//    TransferBatchService service;
+
+    public static TransferBatchService service;
+
+    @Autowired
+    Snowflake snowflake;
+
+    @Autowired
+    WxTransferLogDao wxTransferLogDao;
+
+
+
+    public  Config RSAAutoCertificateConfig(){
+        log.info(Thread.currentThread().getContextClassLoader().getResource("").getPath() + weChatConfig.getPrivateKey());
+        // 初始化商户配置
+
+        return new  RSAAutoCertificateConfig.Builder()
+                        .merchantId(weChatConfig.getMerchantId())
+                        // 使用 com.wechat.pay.java.core.util
+                        // 中的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
+                        .privateKeyFromPath(Thread.currentThread().getContextClassLoader().getResource("").getPath() + weChatConfig.getPrivateKey())
+                        .merchantSerialNumber(weChatConfig.getMerchantSerialNumber())
+                        .apiV3Key(weChatConfig.getApiV3Key())
+                        .build();
+
+    }
+
+
+    /**
+     * 通过微信批次单号查询批次单
+     */
+    public  TransferBatchEntity getTransferBatchByNo(TransferStatusModel transferStatusModel) {
+        Config config = RSAAutoCertificateConfig();
+        // 初始化服务
+        service = new TransferBatchService.Builder().config(config).build();
+
+        GetTransferBatchByNoRequest request = new GetTransferBatchByNoRequest();
+        BeanUtils.copyProperties(transferStatusModel, request);
+        return service.getTransferBatchByNo(request);
+    }
+
+//    /**
+//     * 通过商家批次单号查询批次单
+//     */
+//    public  TransferBatchEntity getTransferBatchByOutNo() {
+//
+//        GetTransferBatchByOutNoRequest request = new GetTransferBatchByOutNoRequest();
+//        return service.getTransferBatchByOutNo(request);
+//    }
+
+    /**
+     * 发起商家转账
+     */
+    public InitiateBatchTransferResponse initiateBatchTransfer(TransferModel transferModel, String appid) {
+        WxTransferLog wxTransferErrorLog = new WxTransferLog();
+        Config config = RSAAutoCertificateConfig();
+        // 初始化服务
+        service = new TransferBatchService.Builder().config(config).build();
+        try {
+            InitiateBatchTransferRequest request = new InitiateBatchTransferRequest();
+            BeanUtils.copyProperties(transferModel,request);
+            request.setAppid(appid);
+            request.setTransferSceneId(transferModel.getTransferSceneId());
+            request.setTransferSceneId(weChatConfig.getTransferSceneId());
+            InitiateBatchTransferResponse initiateBatchTransferResponse = service.initiateBatchTransfer(request);
+
+            wxTransferErrorLog.setRequestBody(JsonUtil.toJson(request));
+            wxTransferErrorLog.setResultContent(JsonUtil.toJson(initiateBatchTransferResponse));
+            wxTransferErrorLog.setResultState("SUCCESS");
+            wxTransferLogDao.save(wxTransferErrorLog);
+            return initiateBatchTransferResponse;
+        } catch (HttpException e) { // 发送HTTP请求失败
+            // 调用e.getHttpRequest()获取请求打印日志或上报监控,更多方法见HttpException定义
+            log.info("发送HTTP请求失败:{}", e.getHttpRequest());
+            wxTransferErrorLog.setRequestBody(JsonUtil.toJson(transferModel));
+            wxTransferErrorLog.setResultContent(JsonUtil.toJson(e.getHttpRequest()));
+        } catch (ServiceException e) { // 服务返回状态小于200或大于等于300,例如500
+            // 调用e.getResponseBody()获取返回体打印日志或上报监控,更多方法见ServiceException定义
+            log.info("请求失败2:{}", e.getResponseBody());
+            wxTransferErrorLog.setRequestBody(JsonUtil.toJson(transferModel));
+            wxTransferErrorLog.setResultContent(e.getResponseBody());
+        } catch (MalformedMessageException e) { // 服务返回成功,返回体类型不合法,或者解析返回体失败
+            // 调用e.getMessage()获取信息打印日志或上报监控,更多方法见MalformedMessageException定义
+            log.info("请求失败3:{}", e.getMessage());
+            wxTransferErrorLog.setRequestBody(JsonUtil.toJson(transferModel));
+            wxTransferErrorLog.setResultContent(e.getMessage());
+        }
+        wxTransferErrorLog.setResultState("Exception");
+        wxTransferLogDao.save(wxTransferErrorLog);
+        return null;
+    }
+
+//    /**
+//     * 通过微信明细单号查询明细单
+//     */
+//    public  TransferDetailEntity getTransferDetailByNo() {
+//
+//        GetTransferDetailByNoRequest request = new GetTransferDetailByNoRequest();
+//        return service.getTransferDetailByNo(request);
+//    }
+//
+//    /**
+//     * 通过商家明细单号查询明细单
+//     */
+//    public  TransferDetailEntity getTransferDetailByOutNo() {
+//
+//        GetTransferDetailByOutNoRequest request = new GetTransferDetailByOutNoRequest();
+//        return service.getTransferDetailByOutNo(request);
+//    }
+}

+ 57 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/service/Impl/InviteRecordFeignServiceImpl.java

@@ -0,0 +1,57 @@
+package com.zhongshu.reward.server.core.service.Impl;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson2.JSONObject;
+import com.zhongshu.reward.client.service.InviteRecordFeignService;
+import com.zhongshu.reward.client.type.UserType;
+import com.zhongshu.reward.server.core.dao.InviteRecordDao;
+import com.zhongshu.reward.server.core.domain.InviteRecord;
+import com.zhongshu.vip.client.model.VipUserModel;
+import com.zhongshu.vip.client.service.VipUserService;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @author wjf
+ * @date 2024/8/9
+ */
+@Service
+@Slf4j
+public class InviteRecordFeignServiceImpl implements InviteRecordFeignService {
+
+    @Autowired
+    InviteRecordDao inviteRecordDao;
+
+    @Autowired
+    VipUserService vipUserService;
+
+
+    /**
+     * 生成邀请记录
+     * @param userId
+     * @param inviteUserId
+     * @param userType
+     */
+    public void invite(String phone, String userId, String inviteUserId, UserType userType, Long registerTime){
+        //查询有无邀请记录
+        if (inviteRecordDao.existsByUserId(userId)){
+           log.info("已被其他用户邀请");
+        }else {
+            InviteRecord inviteRecord = new InviteRecord();
+            inviteRecord.setUserId(userId);
+            inviteRecord.setInviteUserId(inviteUserId);
+            inviteRecord.setUserType(userType);
+            inviteRecord.setPhone(phone);
+            inviteRecord.setRegisterTime(registerTime);
+            inviteRecordDao.save(inviteRecord);
+        }
+    }
+
+
+}

+ 8 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/service/Impl/WalletFeignServiceImpl.java

@@ -0,0 +1,8 @@
+package com.zhongshu.reward.server.core.service.Impl;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+public class WalletFeignServiceImpl {
+}

+ 73 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/service/InviteReceiptsRulerService.java

@@ -0,0 +1,73 @@
+package com.zhongshu.reward.server.core.service;
+
+import com.zhongshu.reward.client.model.InviteReceiptsRoleModel;
+import com.zhongshu.reward.client.ret.ResultContent;
+import com.zhongshu.reward.server.core.dao.InviteReceiptsRoleDao;
+import com.zhongshu.reward.server.core.dao.VipUserRecordDao;
+import com.zhongshu.reward.server.core.domain.InviteReceiptsRuler;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 邀请返利
+ * @author wjf
+ * @date 2024/8/7
+ */
+@Service
+public class InviteReceiptsRulerService {
+
+    @Autowired
+    InviteReceiptsRoleDao inviteReceiptsRoleDao;
+
+    @Autowired
+    VipUserRecordDao vipUserRecordDao;
+
+    @Autowired
+    WalletReceiptsService walletReceiptsService;
+
+
+
+    /**
+     * 添加推广规则
+     * @param inviteReceiptsRoleModel
+     * @return
+     */
+//    public Object add(InviteReceiptsRoleModel inviteReceiptsRoleModel){
+//        boolean existsBySetMeal= inviteReceiptsRoleDao.existsBySetMealIdAndDisable(inviteReceiptsRoleModel.getSetMealId(), false);
+//        if (existsBySetMeal){
+//            return ResultContent.buildFail("该套餐存在推广规则");
+//        }
+//        InviteReceiptsRuler inviteReceiptsRole = new InviteReceiptsRuler();
+//        BeanUtils.copyProperties(inviteReceiptsRoleModel, inviteReceiptsRole);
+//        return ResultContent.buildContent(toModel(inviteReceiptsRoleDao.save(inviteReceiptsRole)));
+//    }
+
+    public Object update(InviteReceiptsRoleModel inviteReceiptsRoleModel){
+        if (StringUtils.isEmpty(inviteReceiptsRoleModel.getId())) {//添加
+            boolean existsBySetMeal= inviteReceiptsRoleDao.existsBySetMealIdAndDisable(inviteReceiptsRoleModel.getSetMealId(), false);
+            if (existsBySetMeal){
+                return ResultContent.buildFail("该套餐存在推广规则");
+            }
+        }else if (!inviteReceiptsRoleDao.existsById(inviteReceiptsRoleModel.getId())){
+            return ResultContent.buildContent("找不到要修改的推广规则");
+        }
+
+        InviteReceiptsRuler inviteReceiptsRuler = new InviteReceiptsRuler();
+        BeanUtils.copyProperties(inviteReceiptsRoleModel, inviteReceiptsRuler);
+        return ResultContent.buildContent(toModel(inviteReceiptsRoleDao.save(inviteReceiptsRuler)));
+    }
+
+
+
+
+    InviteReceiptsRoleModel toModel(InviteReceiptsRuler inviteReceiptsRuler){
+        InviteReceiptsRoleModel model = new InviteReceiptsRoleModel();
+        if (ObjectUtils.isNotEmpty(inviteReceiptsRuler)){
+            BeanUtils.copyProperties(inviteReceiptsRuler, model);
+        }
+        return model;
+    }
+}

+ 90 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/service/RedisService.java

@@ -0,0 +1,90 @@
+package com.zhongshu.reward.server.core.service;
+
+import com.zhongshu.reward.client.ret.CommentException;
+import org.checkerframework.checker.units.qual.C;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.stereotype.Service;
+
+import java.util.concurrent.TimeUnit;
+
+
+@Service
+public class RedisService {
+
+    @Autowired
+    private StringRedisTemplate template;
+
+    public void addExpireToken(String loginName, String token, long tokenExpirePeriod) {
+        try {
+            String[] tokens = token.split("\\.");
+            //template.boundValueOps(tokenKey).set(loginName, 10000, TimeUnit.MILLISECONDS);
+            template.opsForValue().set(tokens[1], loginName, tokenExpirePeriod, TimeUnit.MILLISECONDS);
+        } catch (Exception e) {
+            throw new CommentException("系统故障,请联系服务商");
+        }
+    }
+
+    public void removeExpireToken(String loginName, String token) {
+        try {
+            String[] tokens = token.split("\\.");
+            //template.boundValueOps(tokenKey).set(loginName, 10000, TimeUnit.MILLISECONDS);
+            template.delete(tokens[1]);
+        } catch (Exception e) {
+            throw new CommentException("系统故障,请联系服务商");
+        }
+    }
+
+    public boolean verifyExpireJwtToken(String loginName, String jwtToken) {
+        try {
+            String[] tokens = jwtToken.split("\\.");
+            //template.boundValueOps(tokenKey).set(loginName, 10000, TimeUnit.MILLISECONDS);
+            return template.hasKey(tokens[1]);
+        } catch (Exception e) {
+            throw new CommentException("系统故障,请联系服务商");
+        }
+    }
+
+    public boolean verifyExpireCode(String code) {
+        try {
+            //template.boundValueOps(tokenKey).set(loginName, 10000, TimeUnit.MILLISECONDS);
+            return template.hasKey(code);
+        } catch (Exception e) {
+            throw new CommentException("系统故障,请联系服务商");
+        }
+    }
+
+
+    public void setValue(String key, String value, long expirePeriod) {
+        try {
+            template.opsForValue().set(key, value, expirePeriod, TimeUnit.MILLISECONDS);
+        } catch (Exception e) {
+            throw new CommentException("系统故障,请联系服务商");
+        }
+    }
+
+    public void setValueSecond(String key, String value, long expirePeriod) {
+        try {
+            template.opsForValue().set(key, value, expirePeriod, TimeUnit.SECONDS);
+        } catch (Exception e) {
+            throw new CommentException("系统故障,请联系服务商");
+        }
+    }
+
+    public String getValue(String key) {
+        try {
+            return template.opsForValue().get(key);
+        } catch (Exception e) {
+            throw new CommentException("系统故障,请联系服务商");
+        }
+    }
+
+    public void removeValue(String key) {
+        try {
+            template.delete(key);
+        } catch (Exception e) {
+            throw new CommentException("系统故障,请联系服务商");
+        }
+    }
+
+}

+ 44 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/service/StatisticsService.java

@@ -0,0 +1,44 @@
+package com.zhongshu.reward.server.core.service;
+
+import com.github.microservice.auth.security.helper.AuthHelper;
+import com.github.microservice.core.util.iterator.IteratorUtil;
+import com.zhongshu.reward.client.model.InviteSuccessModel;
+import com.zhongshu.reward.client.ret.ResultContent;
+import com.zhongshu.reward.server.core.dao.InviteRecordDao;
+import com.zhongshu.reward.server.core.dao.WalletReceiptsDao;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * @author wjf
+ * @date 2024/8/13
+ */
+@Service
+public class StatisticsService {
+
+    @Autowired
+    AuthHelper authHelper;
+
+    @Autowired
+    InviteRecordDao inviteRecordDao;
+
+    @Autowired
+    WalletReceiptsDao walletReceiptsDao;
+
+    public Object myInvite(){
+        String userId = authHelper.getCurrentUser().getUserId();
+        Integer inviteCount = inviteRecordDao.countByInviteUserId(userId);
+        List<InviteSuccessModel> inviteSuccessModels = walletReceiptsDao.myInvite(userId);
+        BigDecimal totalAmount = BigDecimal.ZERO;
+        if (!inviteSuccessModels.isEmpty()){
+            totalAmount = inviteSuccessModels.stream().map(InviteSuccessModel::getTotalAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
+        }
+        return ResultContent.buildContent(Map.of("inviteCount", inviteCount, "success", inviteSuccessModels.size(), "totalAmount", totalAmount));
+    }
+}

+ 66 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/service/TransferRulerService.java

@@ -0,0 +1,66 @@
+package com.zhongshu.reward.server.core.service;
+
+import com.github.microservice.core.util.result.content.ResultContent;
+import com.github.microservice.core.util.result.content.ResultState;
+import com.zhongshu.reward.client.model.TransferRulerModel;
+import com.zhongshu.reward.client.model.param.TransferRulerParam;
+import com.zhongshu.reward.server.core.dao.TransferRulerDao;
+import com.zhongshu.reward.server.core.domain.TransferRuler;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Example;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * @author wjf
+ * @date 2024/8/12
+ */
+@Service
+public class TransferRulerService {
+
+    @Autowired
+    TransferRulerDao transferRulerDao;
+
+
+    public Object saveOrUpdate(TransferRulerParam param){
+        if (StringUtils.isNotEmpty(param.getId())){
+            TransferRuler transferRuler = transferRulerDao.findTop1ById(param.getId());
+            if (ObjectUtils.isEmpty(transferRuler)){
+                return ResultContent.build(ResultState.Fail, "规则不存在");
+            }
+            BeanUtils.copyProperties(param, transferRuler);
+            transferRulerDao.save(transferRuler);
+            return ResultContent.buildContent(toModel(transferRuler));
+        }else {
+            List<TransferRuler> all = transferRulerDao.findAll();
+            if (!all.isEmpty()){
+                return ResultContent.build(ResultState.Fail, "已设置规则,请勿重复添加");
+            }
+            TransferRuler transferRuler = new TransferRuler();
+            BeanUtils.copyProperties(param, transferRuler);
+            transferRulerDao.save(transferRuler);
+            return ResultContent.buildContent(toModel(transferRuler));
+        }
+    }
+
+    public Object getRuler(){
+        List<TransferRuler> all = transferRulerDao.findAll(Example.of(TransferRuler.builder().build()));
+        if (all.isEmpty()){
+            return ResultContent.build(ResultState.Success);
+        }
+        return ResultContent.buildContent(toModel(all.get(0)));
+    }
+
+    TransferRulerModel toModel(TransferRuler transferRuler){
+        TransferRulerModel model = new TransferRulerModel();
+        if (ObjectUtils.isNotEmpty(transferRuler)){
+            BeanUtils.copyProperties(transferRuler, model);
+        }
+        return model;
+    }
+}

+ 322 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/service/WalletReceiptsService.java

@@ -0,0 +1,322 @@
+package com.zhongshu.reward.server.core.service;
+
+import com.github.microservice.auth.security.helper.AuthHelper;
+import com.github.microservice.core.util.result.content.ResultContent;
+import com.github.microservice.core.util.result.content.ResultState;
+import com.zhongshu.reward.client.model.VipUserModel;
+import com.zhongshu.reward.client.model.wallet.WalletReceiptsModel;
+import com.zhongshu.reward.client.type.ReceiptsStatus;
+import com.zhongshu.reward.client.type.ReceiptsType;
+import com.zhongshu.reward.client.type.UserType;
+import com.zhongshu.reward.server.core.dao.InviteRecordDao;
+import com.zhongshu.reward.server.core.dao.VipUserRecordDao;
+import com.zhongshu.reward.server.core.dao.WalletDao;
+import com.zhongshu.reward.server.core.dao.WalletReceiptsDao;
+import com.zhongshu.reward.server.core.domain.InviteRecord;
+import com.zhongshu.reward.server.core.domain.VipUserRecord;
+import com.zhongshu.reward.server.core.domain.Wallet;
+import com.zhongshu.reward.server.core.domain.WalletReceipts;
+import com.zhongshu.reward.server.core.util.DateUtils;
+import com.zhongshu.vip.client.model.param.VipUserParam;
+import com.zswl.cloud.bdb.client.service.InviteReceiptsRoleFeignService;
+import com.zswl.cloud.bdb.client.vo.InviteReceiptsRoleVo;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/**
+ * @author wjf
+ * @date 2024/8/6
+ */
+@Service
+@Slf4j
+public class WalletReceiptsService {
+
+    @Autowired
+    WalletDao walletDao;
+
+    @Autowired
+    WalletService walletService;
+
+    @Autowired
+    WalletReceiptsDao walletReceiptsDao;
+
+    @Autowired
+    VipUserRecordDao vipUserRecordDao;
+
+    @Autowired
+    InviteRecordDao inviteRecordDao;
+
+    @Autowired
+    AuthHelper authHelper;
+
+    @Autowired
+    InviteReceiptsRoleFeignService inviteReceiptsRoleFeignService;
+
+
+    /**
+     * 邀请返利入账
+     * @param
+     * @return
+     */
+    @Transactional
+    public void receipts(VipUserRecord vipUserRecord){
+        //校验对应套餐返利规则
+        com.zswl.cloud.bdb.client.ret.ResultContent<InviteReceiptsRoleVo> rulerResultContent = inviteReceiptsRoleFeignService.getOne(vipUserRecord.getPlanningId());
+        if (rulerResultContent.getState().equals(com.zswl.cloud.bdb.client.ret.ResultState.Success)){
+            InviteReceiptsRoleVo rulerVo = rulerResultContent.getContent();
+            if (rulerVo.isFirst() && vipUserRecord.getSuc().equals(1)){
+                vipUserRecord.setFirst(false);
+                //订阅
+                //查询邀请关系
+                InviteRecord inviteRecord = inviteRecordDao.findTopByUserIdOrderByCreateTime(vipUserRecord.getCpId());
+                if (Objects.nonNull(inviteRecord) && inviteRecord.getUserType().equals(UserType.NEW)){
+                    if (rulerVo.getFirstPurchaseDay()!=null && !vipUserRecordDao.existsByCpIdAndSucIn(vipUserRecord.getCpId(), List.of(1))) {
+                        vipUserRecord.setFirst(true);
+                        //订阅入账
+                        WalletReceipts walletReceipts = new WalletReceipts();
+                        //获取邀请人userid
+                        String inviteId = inviteRecord.getInviteUserId();
+                        Wallet wallet = walletService.getWalletByUserId(inviteId);
+                        walletReceipts.setWallet(wallet);
+                        walletReceipts.setInviteUserId(inviteId);
+                        walletReceipts.setUserId(vipUserRecord.getCpId());
+                        walletReceipts.setReceiptsType(ReceiptsType.COMMISSION);
+                        walletReceipts.setOutTradeNo(vipUserRecord.getPlanningId());
+                        walletReceipts.setTotal(rulerVo.getBaseTotal());
+                        walletReceipts.setEstimatedTime(DateUtils.nextMonthDayStartTime(rulerVo.getDay()));
+                        walletReceipts.setVipUserRecord(vipUserRecord);
+                        //邀请人钱包
+                        walletReceipts.setStatus(ReceiptsStatus.WAIT);
+                        wallet.setWaitAmount(wallet.getWaitAmount().add(rulerVo.getBaseTotal()));
+                        walletDao.save(wallet);
+                        walletReceiptsDao.save(walletReceipts);
+                }
+            }
+        }else if (vipUserRecord.getSuc().equals(-1) || vipUserRecord.getSuc().equals(5)){
+                VipUserRecord lastOne = vipUserRecordDao.findTop1ByCpIdAndSucOrderByOperateTime(vipUserRecord.getCpId(), 1);
+                //上一单首购
+                if (ObjectUtils.isNotEmpty(lastOne) && lastOne.isFirst() && Math.abs(vipUserRecord.getOperateTime() - lastOne.getOperateTime()) < 24L *60*60*1000*rulerVo.getFirstPurchaseDay()){
+                    WalletReceipts walletReceipts = walletReceiptsDao.findTop1ByVipUserRecord_IdAndVipUserRecord_First(lastOne.getId(), true);
+                    if (ObjectUtils.isNotEmpty(walletReceipts)){
+                        walletReceipts.setStatus(ReceiptsStatus.CANCEL);
+                        Wallet wallet = walletService.getWalletByUserId(walletReceipts.getInviteUserId());
+                        wallet.setWaitAmount(wallet.getWaitAmount().subtract(walletReceipts.getTotal()));
+                        walletDao.save(wallet);
+                        walletReceiptsDao.save(walletReceipts);
+                    }
+                }
+            }
+        }
+        vipUserRecordDao.save(vipUserRecord);
+    }
+
+
+    /**
+     * 结算
+     */
+    public void settle(){
+        Long startTime = DateUtils.lastMonthStartTime();
+        Long endTime = DateUtils.lastMonthEndTime();
+        List<WalletReceipts> list = walletReceiptsDao.listMonth(startTime, endTime);
+
+        List<WalletReceipts> receipts = new ArrayList<>();
+        List<Wallet> wallets = new ArrayList<>();
+
+        //首次订购
+        list.forEach(it -> {
+            if (it.getVipUserRecord().isFirst()) {
+                addAmount(it);
+            }
+        });
+
+        //持续订购
+        List<WalletReceipts> keep  = list.stream().map(it -> {
+            if (!it.getVipUserRecord().isFirst()) {
+                return it;
+            }
+            return null;
+        }).collect(Collectors.toList());
+
+        keep.forEach(it->{
+            boolean cancel = vipUserRecordDao.existsByCpIdAndSucIn(it.getUserId(), List.of(-1, 5));
+            if (!cancel){//无退订消息
+                addAmount(it);
+            }else {
+                VipUserRecord cancelRecord = vipUserRecordDao.findTopOneByOperateTime(it.getUserId(), DateUtils.lastMonthDayStartTime(1), DateUtils.lastMonthDayStartTime(6));
+                if (ObjectUtils.isEmpty(cancelRecord) || cancelRecord.getSuc().equals(1) || cancelRecord.getSuc().equals(4)){
+                    //上月1-5号无退订消息或消息为订购:默认扣款成功。。。
+                    addAmount(it);
+                }else {
+                    cancel(it);
+                }
+            }
+        });
+        walletDao.saveAll(wallets);
+        walletReceiptsDao.saveAll(receipts);
+
+    }
+
+    public void autoReceipts(){
+        //获取设置持续订购返利的套餐规则
+        com.zswl.cloud.bdb.client.ret.ResultContent<List<InviteReceiptsRoleVo>> rulerResult = inviteReceiptsRoleFeignService.listKeep();
+        if (rulerResult.getState().equals(com.zswl.cloud.bdb.client.ret.ResultState.Success)){
+            List<InviteReceiptsRoleVo> rulerList = rulerResult.getContent();
+            if (rulerList.isEmpty()){
+                return;
+            }
+            List<String> setMealCodeList = rulerList.stream().map(InviteReceiptsRoleVo::getSetMealCode).collect(Collectors.toList());
+
+            //获取上月所有入帐单(待结算和已结算的)
+            Long startTime = DateUtils.lastMonthStartTime();
+            Long endTime = DateUtils.lastMonthEndTime();
+            List<WalletReceipts> walletReceiptsList = walletReceiptsDao.listMonthBySetMealCode(startTime, endTime, setMealCodeList);
+            if (walletReceiptsList.isEmpty()){
+                return;
+            }
+
+            rulerList.forEach(ruler->{
+                walletReceiptsList.forEach(walletReceipts -> {
+                    //匹配规则
+                    if (walletReceipts.getOutTradeNo().equals(ruler.getSetMealCode())){
+                        //上月最新消息
+                        VipUserRecord topOne = vipUserRecordDao.findTopOneByOperateTime(walletReceipts.getUserId(), startTime, endTime);
+                        if (Objects.isNull(topOne)){
+                            //上月无消息,生成入账
+                            insertReceipts(ruler, walletReceipts);
+                        }else if (topOne.getSuc().equals(1) || topOne.getSuc().equals(4)){
+                            //上月最后消息为订购,生成入账
+                            insertReceipts(ruler, walletReceipts);
+                        }
+                    }
+                });
+            });
+        }
+    }
+
+
+    private void insertReceipts(InviteReceiptsRoleVo ruler, WalletReceipts it) {
+        WalletReceipts walletReceipts = new WalletReceipts();
+        walletReceipts.setWallet(it.getWallet());
+        walletReceipts.setInviteUserId(it.getInviteUserId());
+        walletReceipts.setUserId(it.getUserId());
+        walletReceipts.setEstimatedTime(DateUtils.nextMonthDayStartTime(ruler.getDay()));
+        walletReceipts.setReceiptsType(ReceiptsType.COMMISSION);
+        walletReceipts.setTotal(ruler.getBaseTotal());
+        walletReceipts.setStatus(ReceiptsStatus.WAIT);
+        walletReceipts.setOutTradeNo(ruler.getSetMealCode());
+        VipUserRecord vipUserRecord = it.getVipUserRecord();
+        vipUserRecord.setId(null);
+        vipUserRecord.setFirst(false);
+        vipUserRecord.setPlanningId(ruler.getSetMealCode());
+        walletReceipts.setVipUserRecord(vipUserRecord);
+        Wallet wallet = walletReceipts.getWallet();
+        wallet.setWaitAmount(wallet.getWaitAmount().add(ruler.getBaseTotal()));
+        walletDao.save(wallet);
+        walletReceiptsDao.save(walletReceipts);
+    }
+
+    private void addAmount(WalletReceipts it) {
+        it.setStatus(ReceiptsStatus.RECEIPTS);
+        it.setReceiptsTime(new Date().getTime());
+        Wallet wallet = it.getWallet();
+        wallet.setWaitAmount(wallet.getWaitAmount().subtract(it.getTotal()));
+        wallet.setAmount(wallet.getAmount().add(it.getTotal()));
+        walletDao.save(wallet);
+        walletReceiptsDao.save(it);
+    }
+
+    private void cancel(WalletReceipts it){
+        it.setStatus(ReceiptsStatus.CANCEL);
+        Wallet wallet = it.getWallet();
+        wallet.setWaitAmount(wallet.getWaitAmount().subtract(it.getTotal()));
+        walletDao.save(wallet);
+        walletReceiptsDao.save(it);
+    }
+
+    /**
+     * 取消返利入账
+     * @param
+     * @return
+     */
+    @Transactional
+    public Object cancelReceipts(String outTradeNo){
+
+        WalletReceipts walletReceipts = walletReceiptsDao.findTopByOutTradeNo(outTradeNo);
+        if (ObjectUtils.isEmpty(walletReceipts)){
+            return ResultContent.build(ResultState.Fail,"返利订单不存在或未入账");
+        }
+        if (!walletReceipts.getStatus().equals(ReceiptsStatus.WAIT)){
+            return ResultContent.build(ResultState.Fail,"订单不处于未结算状态");
+        }
+
+        walletReceipts.setStatus(ReceiptsStatus.CANCEL);
+        walletReceiptsDao.save(walletReceipts);
+        Wallet wallet = walletDao.findTop1ById(walletReceipts.getWallet().getId());
+        wallet.setWaitAmount(wallet.getWaitAmount().subtract(walletReceipts.getTotal()));
+        walletDao.save(wallet);
+        return ResultContent.build(ResultState.Success);
+    }
+
+    public Object listByWallet(){
+        String userId = authHelper.getCurrentUser().getUserId();
+        Wallet wallet = walletService.getWalletByUserId(userId);
+        List<WalletReceipts> list = walletReceiptsDao.findByWallet_IdOrderByCreateTimeDesc(wallet.getId());
+        return ResultContent.buildContent(list.stream().map(this::toModel).collect(Collectors.toList()));
+    }
+
+    public Object receiptsDetail(String receiptsId){
+        WalletReceipts walletReceipts = walletReceiptsDao.findTop1ById(receiptsId);
+        if (ObjectUtils.isEmpty(walletReceipts)){
+            return ResultContent.build(ResultState.Fail, "记录不存在");
+        }
+        VipUserRecord vipUserRecord = walletReceipts.getVipUserRecord();
+        VipUserModel vipUserModel = new VipUserModel();
+        BeanUtils.copyProperties(vipUserRecord, vipUserModel);
+        BeanUtils.copyProperties(walletReceipts, vipUserModel);
+        InviteRecord inviteRecord = inviteRecordDao.findTopByUserIdOrderByCreateTime(walletReceipts.getUserId());
+        if (ObjectUtils.isNotEmpty(inviteRecord)){
+            vipUserModel.setReceiptsTime(inviteRecord.getRegisterTime());
+            vipUserModel.setPhone(inviteRecord.getPhone());
+        }
+        return ResultContent.buildContent(vipUserModel);
+    }
+
+    public Object rewardDetail(Integer year, Integer month){
+        String userId = authHelper.getCurrentUser().getUserId();
+        Long monthStartTime = DateUtils.getMonthStartTime(year, month);
+        Long monthEndTime = DateUtils.getMonthEndTime(year, month);
+        List<WalletReceipts> walletReceipts = walletReceiptsDao.inviteDetail(userId, monthStartTime, monthEndTime);
+        return ResultContent.buildContent(walletReceipts.stream().map(this::toVipUserModel).collect(Collectors.toList()));
+    }
+
+    private VipUserModel toVipUserModel(WalletReceipts walletReceipts) {
+        VipUserModel vipUserModel = new VipUserModel();
+        if (ObjectUtils.isNotEmpty(walletReceipts)){
+            VipUserRecord vipUserRecord = walletReceipts.getVipUserRecord();
+            BeanUtils.copyProperties(vipUserRecord, vipUserModel);
+            BeanUtils.copyProperties(walletReceipts, vipUserModel);
+        }
+        return vipUserModel;
+    }
+
+    WalletReceiptsModel toModel(WalletReceipts walletReceipts){
+        WalletReceiptsModel model = new WalletReceiptsModel();
+        if (null != walletReceipts){
+            BeanUtils.copyProperties(walletReceipts, model, "wallet");
+            model.setWalletId(walletReceipts.getWallet().getId());
+        }
+        return model;
+    }
+}

+ 59 - 0
RewardServer/src/main/java/com/zhongshu/reward/server/core/service/WalletService.java

@@ -0,0 +1,59 @@
+package com.zhongshu.reward.server.core.service;
+
+import com.github.microservice.auth.security.helper.AuthHelper;
+import com.github.microservice.core.util.result.content.ResultContent;
+import com.zhongshu.reward.client.model.wallet.WalletModel;
+import com.zhongshu.reward.client.type.DataState;
+import com.zhongshu.reward.server.core.dao.WalletDao;
+import com.zhongshu.reward.server.core.domain.Wallet;
+import org.apache.commons.lang3.ObjectUtils;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author wjf
+ * @date 2024/8/5
+ */
+@Service
+public class WalletService {
+
+    @Autowired
+    AuthHelper authHelper;
+
+    @Autowired
+    WalletDao walletDao;
+
+
+    /**
+     * 获取当前登录用户(开通)钱包
+     */
+    public ResultContent getWallet(){
+        Wallet wallet = getWalletByUserId(null);
+        return ResultContent.buildContent(toModel(wallet));
+    }
+
+    @NotNull
+    public Wallet getWalletByUserId(String userId) {
+        if (ObjectUtils.isEmpty(userId)){
+            userId = authHelper.getCurrentUser().getUserId();
+        }
+        Wallet wallet = walletDao.findByUserId(userId);
+        if (wallet==null){
+            wallet = new Wallet();
+            wallet.setUserId(userId);
+            wallet.setDataState(DataState.Enable);
+            wallet = walletDao.save(wallet);
+        }
+        return wallet;
+    }
+
+    private WalletModel toModel(Wallet wallet){
+        WalletModel walletModel = new WalletModel();
+        if (wallet!=null){
+            BeanUtils.copyProperties(wallet, walletModel);
+        }
+        return walletModel;
+    }
+}

Some files were not shown because too many files changed in this diff