Prechádzať zdrojové kódy

修改订单即算即用后,同步修改售后退款扣减为可用积分而不是冻结积分,峰值也同步

Yangzw 7 mesiacov pred
rodič
commit
5d66b6d30b
17 zmenil súbory, kde vykonal 672 pridanie a 169 odobranie
  1. 52 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/orderpercentage/vo/OrderPercentageDoubleSaveReqVO.java
  2. 68 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/orderpercentage/vo/OrderPercentagePageReqVO.java
  3. 18 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/orderpercentage/vo/OrderPercentageRedisVO.java
  4. 79 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/orderpercentage/vo/OrderPercentageRespVO.java
  5. 59 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/orderpercentage/vo/OrderPercentageSaveReqVO.java
  6. 54 21
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlog/vo/PtProfitLogSaveReqVO.java
  7. 25 7
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/integral/IntegralDO.java
  8. 92 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/orderpercentage/OrderPercentageDO.java
  9. 37 23
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/ptprofitlog/PtProfitLogDO.java
  10. 31 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/orderpercentage/OrderPercentageMapper.java
  11. 7 8
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/integral/IntegralService.java
  12. 60 95
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/integral/IntegralServiceImpl.java
  13. 20 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/orderpercentage/OrderPercentageService.java
  14. 37 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/orderpercentage/OrderPercentageServiceImpl.java
  15. 11 1
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogService.java
  16. 20 12
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogServiceImpl.java
  17. 2 2
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/aftersale/AfterSaleServiceImpl.java

+ 52 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/orderpercentage/vo/OrderPercentageDoubleSaveReqVO.java

@@ -0,0 +1,52 @@
+package cn.newfeifan.mall.module.distri.controller.admin.orderpercentage.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Schema(description = "管理后台 - 积分相关计算浮动百分比设置新增/修改 Request VO")
+@Data
+public class OrderPercentageDoubleSaveReqVO {
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2203")
+    private Long id;
+
+    @Schema(description = "毛利 = 成本 * 0.38... (推广费用)")
+    private String grossProfitPerc;
+
+    @Schema(description = "推广-用户额度 百分比")
+    private String grossProfitUserQuotaPerc;
+
+    @Schema(description = "推广-推荐人额度 百分比")
+    private String grossProfitAncestorQuotaPerc;
+
+    @Schema(description = "推广-合赢奖额度(浮动) 百分比")
+    private String grossProfitBonusQuotaPerc;
+
+    @Schema(description = "推广-平台分成额度(浮动) 百分比")
+    private String grossProfitPlatformQuotaPerc;
+
+    @Schema(description = "分成百分比")
+    private String divideIntoPerc;
+
+    @Schema(description = "购物订单:直推人身价提升", example = "1")
+    private String orderAncestorSocialStatus;
+
+    @Schema(description = "购物订单:本人身价提升", example = "2")
+    private String orderUserSocialStatus;
+
+    @Schema(description = "新用户注册:直推人身价提升", example = "2")
+    private String registerAncestorSocialStatus;
+
+    @Schema(description = "新用户注册:本人身价提升", example = "2")
+    private String registerSocialStatus;
+
+    @Schema(description = "是否启用 0关闭 1启动", example = "2")
+    private Integer status;
+
+    @Schema(description = "用户注册后,获得的基础最大合赢奖、直推奖积分限额")
+    private String baseMaxQuota;
+
+    @Schema(description = "收藏商品获取身价值,同一SPU商品收藏多次无效", example = "1")
+    private String collectSocialStatus;
+
+}

+ 68 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/orderpercentage/vo/OrderPercentagePageReqVO.java

@@ -0,0 +1,68 @@
+package cn.newfeifan.mall.module.distri.controller.admin.orderpercentage.vo;
+
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+import static cn.newfeifan.mall.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - 积分相关计算浮动百分比设置分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class OrderPercentagePageReqVO extends PageParam {
+
+    @Schema(description = "毛利 = 成本 * 0.38... (推广费用)")
+    private String grossProfitPerc;
+
+    @Schema(description = "推广-用户额度 百分比")
+    private String grossProfitUserQuotaPerc;
+
+    @Schema(description = "推广-推荐人额度 百分比")
+    private String grossProfitAncestorQuotaPerc;
+
+    @Schema(description = "推广-合赢奖额度(浮动) 百分比")
+    private String grossProfitBonusQuotaPerc;
+
+    @Schema(description = "推广-平台分成额度(浮动) 百分比")
+    private String grossProfitPlatformQuotaPerc;
+
+    @Schema(description = "分成百分比")
+    private String divideIntoPerc;
+
+    @Schema(description = "购物订单:直推人身价提升", example = "1")
+    private String orderAncestorSocialStatus;
+
+    @Schema(description = "购物订单:本人身价提升", example = "2")
+    private String orderUserSocialStatus;
+
+    @Schema(description = "新用户注册:直推人身价提升", example = "2")
+    private String registerAncestorSocialStatus;
+
+    @Schema(description = "新用户注册:本人身价提升", example = "2")
+    private String registerSocialStatus;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+    @Schema(description = "是否启用 0关闭 1启动", example = "2")
+    private Integer status;
+
+    @Schema(description = "用户注册后,获得的基础最大合赢奖、直推奖积分限额")
+    private String baseMaxQuota;
+
+    @Schema(description = "收藏商品获取身价值,同一SPU商品收藏多次无效", example = "1")
+    private String collectSocialStatus;
+
+    @Schema(description = "用户签到可获取的最大身价值")
+    private String signInSocialStatusMax;
+
+    @Schema(description = "签到获取身价", example = "1")
+    private String signInSocialStatus;
+
+}

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

@@ -0,0 +1,18 @@
+package cn.newfeifan.mall.module.distri.controller.admin.orderpercentage.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Builder;
+import lombok.Data;
+import lombok.ToString;
+
+@Schema(description = "管理后台 - 服务启动时存放在redis中的数据 VO")
+@Data
+@ToString(callSuper = true)
+@Builder
+public class OrderPercentageRedisVO {
+    @Schema(description = "用户签到可获取的最大身价值")
+    private String signInSocialStatusMax;
+
+    @Schema(description = "签到获取身价")
+    private String signInSocialStatus;
+}

+ 79 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/orderpercentage/vo/OrderPercentageRespVO.java

@@ -0,0 +1,79 @@
+package cn.newfeifan.mall.module.distri.controller.admin.orderpercentage.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - 积分相关计算浮动百分比设置 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class OrderPercentageRespVO {
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2203")
+    @ExcelProperty("用户编号")
+    private Long id;
+
+    @Schema(description = "毛利 = 成本 * 0.38... (推广费用)")
+    @ExcelProperty("毛利 = 成本 * 0.38... (推广费用)")
+    private String grossProfitPerc;
+
+    @Schema(description = "推广-用户额度 百分比")
+    @ExcelProperty("推广-用户额度 百分比")
+    private String grossProfitUserQuotaPerc;
+
+    @Schema(description = "推广-推荐人额度 百分比")
+    @ExcelProperty("推广-推荐人额度 百分比")
+    private String grossProfitAncestorQuotaPerc;
+
+    @Schema(description = "推广-合赢奖额度(浮动) 百分比")
+    @ExcelProperty("推广-合赢奖额度(浮动) 百分比")
+    private String grossProfitBonusQuotaPerc;
+
+    @Schema(description = "推广-平台分成额度(浮动) 百分比")
+    @ExcelProperty("推广-平台分成额度(浮动) 百分比")
+    private String grossProfitPlatformQuotaPerc;
+
+    @Schema(description = "分成百分比")
+    @ExcelProperty("分成百分比")
+    private String divideIntoPerc;
+
+    @Schema(description = "购物订单:直推人身价提升", example = "1")
+    @ExcelProperty("购物订单:直推人身价提升")
+    private String orderAncestorSocialStatus;
+
+    @Schema(description = "购物订单:本人身价提升", example = "2")
+    @ExcelProperty("购物订单:本人身价提升")
+    private String orderUserSocialStatus;
+
+    @Schema(description = "新用户注册:直推人身价提升", example = "2")
+    @ExcelProperty("新用户注册:直推人身价提升")
+    private String registerAncestorSocialStatus;
+
+    @Schema(description = "新用户注册:本人身价提升", example = "2")
+    @ExcelProperty("新用户注册:本人身价提升")
+    private String registerSocialStatus;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+    @Schema(description = "是否启用 0关闭 1启动", example = "2")
+    private Integer status;
+
+    @Schema(description = "用户注册后,获得的基础最大合赢奖、直推奖积分限额")
+    private String baseMaxQuota;
+
+    @Schema(description = "收藏商品获取身价值,同一SPU商品收藏多次无效", example = "1")
+    @ExcelProperty("收藏商品获取身价值,同一SPU商品收藏多次无效")
+    private String collectSocialStatus;
+
+    @Schema(description = "用户签到可获取的最大身价值")
+    @ExcelProperty("用户签到可获取的最大身价值")
+    private String signInSocialStatusMax;
+
+    @Schema(description = "签到获取身价", example = "1")
+    @ExcelProperty("签到获取身价")
+    private String signInSocialStatus;
+}

+ 59 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/orderpercentage/vo/OrderPercentageSaveReqVO.java

@@ -0,0 +1,59 @@
+package cn.newfeifan.mall.module.distri.controller.admin.orderpercentage.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Schema(description = "管理后台 - 积分相关计算浮动百分比设置新增/修改 Request VO")
+@Data
+public class OrderPercentageSaveReqVO {
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2203")
+    private Long id;
+
+    @Schema(description = "毛利 = 成本 * 0.38... (推广费用)")
+    private String grossProfitPerc;
+
+    @Schema(description = "推广-用户额度 百分比")
+    private String grossProfitUserQuotaPerc;
+
+    @Schema(description = "推广-推荐人额度 百分比")
+    private String grossProfitAncestorQuotaPerc;
+
+    @Schema(description = "推广-合赢奖额度(浮动) 百分比")
+    private String grossProfitBonusQuotaPerc;
+
+    @Schema(description = "推广-平台分成额度(浮动) 百分比")
+    private String grossProfitPlatformQuotaPerc;
+
+    @Schema(description = "分成百分比")
+    private String divideIntoPerc;
+
+    @Schema(description = "购物订单:直推人身价提升", example = "1")
+    private String orderAncestorSocialStatus;
+
+    @Schema(description = "购物订单:本人身价提升", example = "2")
+    private String orderUserSocialStatus;
+
+    @Schema(description = "新用户注册:直推人身价提升", example = "2")
+    private String registerAncestorSocialStatus;
+
+    @Schema(description = "新用户注册:本人身价提升", example = "2")
+    private String registerSocialStatus;
+
+    @Schema(description = "是否启用 0关闭 1启动", example = "2")
+    private Integer status;
+
+    @Schema(description = "用户注册后,获得的基础最大合赢奖、直推奖积分限额")
+    private String baseMaxQuota;
+
+    @Schema(description = "收藏商品获取身价值,同一SPU商品收藏多次无效", example = "1")
+    private String collectSocialStatus;
+
+    @Schema(description = "用户签到可获取的最大身价值")
+    private String signInSocialStatusMax;
+
+    @Schema(description = "签到获取身价", example = "1")
+    private String signInSocialStatus;
+
+
+}

+ 54 - 21
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlog/vo/PtProfitLogSaveReqVO.java

@@ -1,8 +1,11 @@
 package cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo;
 
+import com.alibaba.excel.annotation.ExcelProperty;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.*;
 
+import java.time.LocalDateTime;
+
 
 @Schema(description = "管理后台 - 平台利润记录新增/修改 Request VO")
 @Data
@@ -11,41 +14,71 @@ import lombok.*;
 @NoArgsConstructor
 public class PtProfitLogSaveReqVO {
 
-    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12046")
-    private Long id;
-
-    /**
-     * 产生积分的用户ID,例如:下订单的用户ID
-     */
-    @Schema(description = "产生积分的用户ID", example = "6982")
-    private Long generateUserId;
-
-    @Schema(description = "增加金额")
-    private Long amount;
-
-    @Schema(description = "增加后金额")
-    private Long afterAmount;
-
-    @Schema(description = "变动的冻结积分")
-    private Long freezeAmount;
-
-    @Schema(description = "变动后的冻结积分值")
-    private Long afterFreezeAmount;
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
 
-    @Schema(description = "收益类型 1:平台服务器费 2:平台收益 3推荐人额度 4直推人额度 5合赢奖 6最高可以获得积分", example = "2")
+    @Schema(description = "收益类型 1:平台服务器费 2:平台收益 3用户下单返回毛利额度 4直推人额度 5合赢奖", example = "2")
+    @ExcelProperty("收益类型 1:平台服务器费 2:平台收益 3用户下单返回毛利额度 4直推人额度 5合赢奖")
     private Integer profitStatus;
 
+    @Schema(description = "收益类型名称")
+    private String profitStatusName;
+
     @Schema(description = "用户ID , 只有收益类型为 3,4才有值", example = "6982")
+    @ExcelProperty("用户ID , 只有收益类型为 3,4才有值")
     private Long userId;
 
     @Schema(description = "订单Id", example = "26464")
+    @ExcelProperty("订单Id")
     private Long orderId;
 
     @Schema(description = "订单编号")
+    @ExcelProperty("订单编号")
     private String orderNo;
 
+    @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5931")
+    @ExcelProperty("编号")
+    private Long id;
+
+    @Schema(description = "变动的当前可用积分值(可为负数)")
+    @ExcelProperty("变动的当前可用积分值(可为负数)")
+    private Long amount;
+
+    @Schema(description = "变动后当前可用积分钱包的余额")
+    @ExcelProperty("变动后当前可用积分钱包的余额")
+    private Long afterAmount;
+
+    @Schema(description = "变动的冻结积分值(可为负数)")
+    @ExcelProperty("变动的冻结积分值(可为负数)")
+    private Long freezeAmount;
+
+    @Schema(description = "变动后冻结积分钱包的余额")
+    @ExcelProperty("变动后冻结积分钱包的余额")
+    private Long afterFreezeAmount;
+
     @Schema(description = "计算百分比模板")
+    @ExcelProperty("计算百分比模板")
     private String percentTemplate;
+
+    @Schema(description = "最大可用积分变化值")
+    private Long maxAvailablePointsAmount;
+
+    @Schema(description = "最大可用积分额度")
+    private Long afterMaxAvailablePointsAmount;
+
+    @Schema(description = "合赢奖超出额度")
+    private Long accumulatedQuotaAmount;
+
+    @Schema(description = "直推奖超出额度")
+    private Long ancestorQuotaAmount;
+
+    @Schema(description = "显示这条记录是由谁产生的用户名")
+    private String username;
+
+    @Schema(description = "产生积分的用户ID,例如:下订单的用户ID", example = "31502")
+    private Long generateUserId;
+
     @Schema(description = "变动的冻结最大可用额度")
     private Long freezeHighQuota;
 

+ 25 - 7
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/integral/IntegralDO.java

@@ -28,6 +28,18 @@ public class IntegralDO extends BaseDO {
      * 用户ID
      */
     private Long userId;
+    /**
+     * 用户类型
+     */
+    private Long categoryId;
+    /**
+     * 用户名称
+     */
+    private String name;
+    /**
+     * 用户昵称
+     */
+    private String nickName;
     /**
      * 当前积分
      */
@@ -37,18 +49,24 @@ public class IntegralDO extends BaseDO {
      */
     private Long freezeQuota;
     /**
-     * 用户类型
+     * 合赢奖累计获取积分
+     */
+    private Long accumulatedQuota;
+    /**
+     * 直推奖累计获取积分
+     */
+    private Long ancestorQuota;
+    /**
+     * 最高可获取积分
      */
-    private Long categoryId;
-
     private Long highQuota;
-
-    private String name;
-
-    private String nickName;
     /**
      * 冻结的最高可获取积分
      */
     private Long freezeHighQuota;
+    /**
+     * 累计获取的峰值
+     */
+    private Long highQuotaTotal;
 
 }

+ 92 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/orderpercentage/OrderPercentageDO.java

@@ -0,0 +1,92 @@
+package cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage;
+
+import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+/**
+ * 积分相关计算浮动百分比设置 DO
+ *
+ * @author 非繁人
+ */
+@TableName("distri_order_percentage")
+@KeySequence("distri_order_percentage_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class OrderPercentageDO extends BaseDO {
+
+    /**
+     * 用户编号
+     */
+    @TableId
+    private Long id;
+    /**
+     * 毛利 = 成本 * 0.38... (推广费用)
+     */
+    private String grossProfitPerc;
+    /**
+     * 推广-用户额度 百分比
+     */
+    private String grossProfitUserQuotaPerc;
+    /**
+     * 推广-推荐人额度 百分比
+     */
+    private String grossProfitAncestorQuotaPerc;
+    /**
+     * 推广-合赢奖额度(浮动) 百分比
+     */
+    private String grossProfitBonusQuotaPerc;
+    /**
+     * 推广-平台分成额度(浮动) 百分比
+     */
+    private String grossProfitPlatformQuotaPerc;
+    /**
+     * 分成百分比
+     */
+    private String divideIntoPerc;
+
+    /**
+     * 购物订单:直推人身价提升
+     */
+    private String orderAncestorSocialStatus;
+    /**
+     * 购物订单:本人身价提升
+     */
+    private String orderUserSocialStatus;
+    /**
+     * 新用户注册:直推人身价提升
+     */
+    private String registerAncestorSocialStatus;
+    /**
+     * 新用户注册:本人身价提升
+     */
+    private String registerSocialStatus;
+
+    private Integer status;
+
+    /**
+     * 用户注册后,获得的基础最大合赢奖、直推奖积分限额
+     */
+    private String baseMaxQuota;
+
+    /**
+     * 收藏商品获取身价值,同一SPU商品收藏多次无效
+     */
+    private String collectSocialStatus;
+
+    /**
+     * 用户签到可获取的最大身价值
+     */
+    private String signInSocialStatusMax;
+    /**
+     * 签到获取身价
+     */
+    private String signInSocialStatus;
+
+}

+ 37 - 23
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/ptprofitlog/PtProfitLogDO.java

@@ -20,55 +20,69 @@ import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
 public class PtProfitLogDO extends BaseDO {
 
     /**
-     * 用户编号
+     * 收益类型 1:平台服务器费 2:平台收益 3用户下单返回毛利额度 4直推人额度 5合赢奖
+     */
+    private Integer profitStatus;
+    /**
+     * 实际变动积分的用户ID , 只有收益类型为 3,4才有值
+     */
+    private Long userId;
+
+    /**
+     * 产生积分的用户ID,例如:下订单的用户ID
+     */
+    private Long generateUserId;
+
+    /**
+     * 订单Id
+     */
+    private Long orderId;
+    /**
+     * 订单编号
+     */
+    private String orderNo;
+    /**
+     * 编号
      */
     @TableId
     private Long id;
     /**
-     * 增加金额
+     * 变动的当前可用积分值(可为负数)
      */
     private Long amount;
     /**
-     * 增加后金额
+     * 变动后当前可用积分钱包的余
      */
     private Long afterAmount;
-
     /**
-     * 增加冻结金额
+     * 变动的冻结积分值(可为负数)
      */
     private Long freezeAmount;
     /**
-     * 增加后冻结金额
+     * 变动后冻结积分钱包的余
      */
     private Long afterFreezeAmount;
-
-
-    /**
-     * 收益类型 1:平台服务器费 2:平台收益 3用户下单返回毛利额度 4直推人额度 5合赢奖
-     */
-    private Integer profitStatus;
     /**
-     * 用户ID , 只有收益类型为 3,4才有值
+     * 计算百分比模板
      */
-    private Long userId;
+    private String percentTemplate;
 
     /**
-     * 导致积分发生变化的用户ID
+     * 最大可用积分变化值
      */
-    private Long generateUserId;
-
+    private Long maxAvailablePointsAmount;
     /**
-     * 订单Id
+     * 最大可用积分额度
      */
-    private Long orderId;
+    private Long afterMaxAvailablePointsAmount;
     /**
-     * 订单编号
+     * 合赢奖超出额度
      */
-    private String orderNo;
+    private Long accumulatedQuotaAmount;
     /**
-     * 计算百分比模板
+     * 直推奖超出额度
      */
-    private String percentTemplate;
+    private Long ancestorQuotaAmount;
 
     /**
      * 变动的冻结最大可用额度

+ 31 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/orderpercentage/OrderPercentageMapper.java

@@ -0,0 +1,31 @@
+package cn.newfeifan.mall.module.distri.dal.mysql.orderpercentage;
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.module.distri.controller.admin.orderpercentage.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 积分相关计算浮动百分比设置 Mapper
+ *
+ * @author 非繁人
+ */
+@Mapper
+public interface OrderPercentageMapper extends BaseMapperX<OrderPercentageDO> {
+
+    default PageResult<OrderPercentageDO> selectPage(OrderPercentagePageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<OrderPercentageDO>()
+                .betweenIfPresent(OrderPercentageDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(OrderPercentageDO::getGrossProfitPerc, reqVO.getGrossProfitPerc())
+                .eqIfPresent(OrderPercentageDO::getGrossProfitUserQuotaPerc, reqVO.getGrossProfitUserQuotaPerc())
+                .eqIfPresent(OrderPercentageDO::getGrossProfitAncestorQuotaPerc, reqVO.getGrossProfitAncestorQuotaPerc())
+                .eqIfPresent(OrderPercentageDO::getGrossProfitBonusQuotaPerc, reqVO.getGrossProfitBonusQuotaPerc())
+                .eqIfPresent(OrderPercentageDO::getGrossProfitPlatformQuotaPerc, reqVO.getGrossProfitPlatformQuotaPerc())
+                .eqIfPresent(OrderPercentageDO::getDivideIntoPerc, reqVO.getDivideIntoPerc())
+                .eqIfPresent(OrderPercentageDO::getStatus, reqVO.getStatus())
+                .orderByDesc(OrderPercentageDO::getId));
+    }
+
+}

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

@@ -58,16 +58,15 @@ public interface IntegralService {
     /**
      * 修改用户积分
      *
-     * @param userId 要修改积分的用户
-     * @param caclEnum 导致积分变化的事件类型枚举
-     * @param amount 用户积分变化金额,可为负数
+     * @param userId       要修改积分的用户
+     * @param caclEnum     导致积分变化的事件类型枚举
+     * @param amount       用户积分变化金额,可为负数
      * @param freezeAmount 用户冻结积分变化金额,可为负数
-     * @return 返回是否执行成功。执行失败,通常是就是用户积分不足,没积分抵扣
      */
-    Boolean updateUserIntegral(Long generateUserId,//导致产生积分变动的用户ID
-            Long userId, CaclEnum caclEnum, Long amount, Long freezeAmount,
-                               Long tradeOrderId,
-                               String orderNum
+    void updateUserIntegral(Long generateUserId,//导致产生积分变动的用户ID
+                            Long userId, CaclEnum caclEnum, Long amount, Long freezeAmount,
+                            Long tradeOrderId,
+                            String orderNum
                                );
 
 //    /**

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

@@ -2,9 +2,12 @@ package cn.newfeifan.mall.module.distri.service.integral;
 
 import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.PtProfitLogSaveReqVO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
+import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlog.PtProfitLogDO;
 import cn.newfeifan.mall.module.distri.dal.mysql.integral.IntegralMapper;
 import cn.newfeifan.mall.module.distri.dal.mysql.ptprofit.PtProfitMapper;
 import cn.newfeifan.mall.module.distri.enums.CaclEnum;
+import cn.newfeifan.mall.module.distri.service.orderpercentage.OrderPercentageService;
 import cn.newfeifan.mall.module.distri.service.ptprofitlog.PtProfitLogService;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
@@ -21,133 +24,95 @@ import java.util.Map;
 @Validated
 public class IntegralServiceImpl implements IntegralService {
 
-//    @Resource
-//    private DuserMapper duserMapper;
-
-//    @Resource
-//    private IntegralMapper integralMapper;
-
     @Resource
     private PtProfitMapper ptProfitMapper;
-
     @Resource
     private IntegralMapper integralMapper;
-
     @Resource
     private PtProfitLogService ptProfitLogService;
-
-//    @Override
-//    public Long createIntegral(IntegralSaveReqVO createReqVO) {
-//        // 插入
-//        IntegralDO integral = BeanUtils.toBean(createReqVO, IntegralDO.class);
-//        integralMapper.insert(integral);
-//        // 返回
-//        return integral.getId();
-//    }
-//
-//    @Override
-//    public void updateIntegral(IntegralSaveReqVO updateReqVO) {
-//        // 校验存在
-//        validateIntegralExists(updateReqVO.getId());
-//        // 更新
-//        IntegralDO updateObj = BeanUtils.toBean(updateReqVO, IntegralDO.class);
-//        integralMapper.updateById(updateObj);
-//    }
-//
-//    @Override
-//    public void deleteIntegral(Long id) {
-//        // 校验存在
-//        validateIntegralExists(id);
-//        // 删除
-//        integralMapper.deleteById(id);
-//    }
-//
-//    private void validateIntegralExists(Long id) {
-//        if (integralMapper.selectById(id) == null) {
-//            throw exception(INTEGRAL_NOT_EXISTS);
-//        }
-//    }
-//
-//    @Override
-//    public IntegralDO getIntegral(Long id) {
-//        return integralMapper.selectOne(new LambdaQueryWrapperX<IntegralDO>().eq(IntegralDO::getUserId,id));
-//    }
-//
-//    @Override
-//    public PageResult<IntegralDO> getIntegralPage(IntegralPageReqVO pageReqVO) {
-//        return integralMapper.selectPage(pageReqVO);
-//    }
-//
-//    @Override
-//    public IntegralDO selectByUser(Long descendant) {
-//        return integralMapper.selectOne(new LambdaQueryWrapper<IntegralDO>().eq(IntegralDO::getUserId, descendant));
-//    }
+    @Resource
+    private OrderPercentageService orderPercentageService;
 
     /**
      * add by Ben
      * 修改用户积分
      *
-     * @param userId 要修改积分的用户
-     * @param caclEnum 导致积分变化的事件类型枚举
-     * @param amount 用户可用积分变化金额,可为负数
+     * @param userId       要修改积分的用户
+     * @param caclEnum     导致积分变化的事件类型枚举
+     * @param amount       用户可用积分变化金额,可为负数
      * @param freezeAmount 用户冻结积分变化金额,可为负数
-     * @return 返回是否执行成功。执行失败,通常是就是用户积分不足,没积分抵扣
      */
     @Override
-    public Boolean updateUserIntegral(Long generateUserId,//导致产生积分变动的用户ID
-            Long userId, CaclEnum caclEnum, Long amount, Long freezeAmount,
-                                      Long tradeOrderId,
-                                      String OrderNum
-                                      ) {
-        Boolean success = null;
-
+    public void updateUserIntegral(Long generateUserId,//导致产生积分变动的用户ID
+                                   Long userId, CaclEnum caclEnum, Long amount, Long freezeAmount,
+                                   Long tradeOrderId,
+                                   String orderNum
+    ) {
         //修改用户积分钱包的积分
-        int effectRowNum = ptProfitMapper.updateUserIntegral(amount,amount,freezeAmount,freezeAmount,userId);
-
-        if (effectRowNum==1) {//如果成功修改积分记录
-            success = true;
+        IntegralDO integralDO = integralMapper.selectOne(IntegralDO::getUserId, userId);
 
-            //用户修改后的当前可用的钱包余额
-            Long afterAmount = null;
-            //用户修改后的冻结积分钱包余额
-            Long afterFreezeAmount = null;
+        // 退款返回 为 +
+        integralDO.setCurrentQuota(integralDO.getCurrentQuota() + amount);
 
-            //查询用户修改后的积分
-            Map<String, Object> map = ptProfitMapper.selectUserIntegral(userId);
-            Object currentQuotaObj = map.get("current_quota");
-            Object freezeQuotaObj = map.get("freeze_quota");
+        // 直推奖超出额度
+        Long ancestorQuotaAmount = 0L;
+        // 如果是推荐人
+        if (caclEnum.getType().equals(CaclEnum.ORDER_REFUND_INTEGRAL_ANCESTER.getType())) {
 
-            afterAmount = (Long)currentQuotaObj;
-            afterFreezeAmount = (Long)freezeQuotaObj;
+            PtProfitLogDO profitLog = ptProfitLogService.selectProfitLogByUserIdWithProfitStatus(userId, CaclEnum.RECOMMENDED_PERSON_QUOTA.getType(), orderNum);
 
-            if(afterAmount<0||afterFreezeAmount<0){
-                throw new RuntimeException("用户钱包为负数:用户IO为"+userId+"的用户可用钱包为"+afterAmount+",冻结钱包为"+afterFreezeAmount);
+            if(profitLog.getAncestorQuotaAmount() != null && profitLog.getAncestorQuotaAmount() != 0){
+                ancestorQuotaAmount = profitLog.getAncestorQuotaAmount();
             }
+            integralDO.setCurrentQuota(integralDO.getCurrentQuota() + ancestorQuotaAmount);
+            // 退回扣减的最大可用额度,和累加获得的直推奖额度
+            integralDO.setHighQuota(integralDO.getHighQuota() - amount - ancestorQuotaAmount);
+            integralDO.setAncestorQuota(integralDO.getAncestorQuota() + amount + ancestorQuotaAmount);
+        }
+
+        integralMapper.updateById(integralDO);
+
+        //用户修改后的当前可用的钱包余额
+        Long afterAmount = null;
+        //用户修改后的冻结积分钱包余额
+        Long afterFreezeAmount = null;
 
-            //记录用户的积分变动日志
-            ptProfitLogService.addMessage(generateUserId,userId, caclEnum, amount, afterAmount,
-                    freezeAmount, afterFreezeAmount,null,tradeOrderId,OrderNum);
+        //查询用户修改后的积分
+        Map<String, Object> map = ptProfitMapper.selectUserIntegral(userId);
+        Object currentQuotaObj = map.get("current_quota");
+        Object freezeQuotaObj = map.get("freeze_quota");
 
-        }else if(effectRowNum<1){//如果钱包积分不足,不够抵扣
-            success = false;
-        } else if (effectRowNum>1) {
-//            success = false;
-            throw new RuntimeException("用户IO为"+userId+"的用户钱包不只一个!");
+        afterAmount = (Long) currentQuotaObj;
+        afterFreezeAmount = (Long) freezeQuotaObj;
+
+        //记录用户的积分变动日志
+        if (caclEnum.getType().equals(CaclEnum.ORDER_REFUND_INTEGRAL_ANCESTER.getType())) {
+            OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus();
+            ptProfitLogService.addMessage(generateUserId, userId, caclEnum, amount + ancestorQuotaAmount, afterAmount,
+                    freezeAmount, afterFreezeAmount, null, tradeOrderId, orderNum, -amount - ancestorQuotaAmount, integralDO.getHighQuota() + Long.parseLong(orderPercentageDO.getBaseMaxQuota()));
+        } else {
+            ptProfitLogService.addMessage(generateUserId, userId, caclEnum, amount, afterAmount,
+                    freezeAmount, afterFreezeAmount, null, tradeOrderId, orderNum, null, null);
         }
 
-        return success;
     }
 
     @Override
     public void updateIntegralFreezeHighQuota(Long generateUserId, Long userId, CaclEnum caclEnum, Long totalFreezeHighQuota, Long tradeOrderId, String orderNum) {
-        IntegralDO integralDO = integralMapper.selectOne(IntegralDO::getUserId,userId);
-        integralDO.setFreezeHighQuota(integralDO.getFreezeHighQuota() - totalFreezeHighQuota);
+        IntegralDO integralDO = integralMapper.selectOne(IntegralDO::getUserId, userId);
+//        integralDO.setFreezeHighQuota(integralDO.getFreezeHighQuota() - totalFreezeHighQuota);
+        integralDO.setHighQuota(integralDO.getHighQuota() - totalFreezeHighQuota);
+        integralDO.setHighQuotaTotal(integralDO.getHighQuotaTotal() - totalFreezeHighQuota);
         integralMapper.updateById(integralDO);
 
+        OrderPercentageDO orderPercentageDO = orderPercentageService.queryStatus();
+
         //记录用户的积分变动日志
         PtProfitLogSaveReqVO profitLogSaveReqVO = PtProfitLogSaveReqVO.builder()
-                .freezeHighQuota(-totalFreezeHighQuota)
-                .afterFreezeHighQuota(integralDO.getFreezeHighQuota())
+//                .freezeHighQuota(-totalFreezeHighQuota)
+//                .afterFreezeHighQuota(integralDO.getFreezeHighQuota())
+                .maxAvailablePointsAmount(-totalFreezeHighQuota)
+                .afterMaxAvailablePointsAmount(integralDO.getHighQuota() + Long.parseLong(orderPercentageDO.getBaseMaxQuota()))     // 系统设置的最大可用积分
                 .userId(userId)
                 .generateUserId(generateUserId)
                 .profitStatus(caclEnum.getType())

+ 20 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/orderpercentage/OrderPercentageService.java

@@ -0,0 +1,20 @@
+package cn.newfeifan.mall.module.distri.service.orderpercentage;
+
+import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
+
+
+/**
+ * 积分相关计算浮动百分比设置 Service 接口
+ *
+ * @author 非繁人
+ */
+public interface OrderPercentageService {
+
+    /**
+     * 查找默认计算参数
+     * @return 参数百分比
+     */
+    OrderPercentageDO queryStatus();
+
+
+}

+ 37 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/orderpercentage/OrderPercentageServiceImpl.java

@@ -0,0 +1,37 @@
+package cn.newfeifan.mall.module.distri.service.orderpercentage;
+
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
+import cn.newfeifan.mall.module.distri.dal.mysql.orderpercentage.OrderPercentageMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 积分相关计算浮动百分比设置 Service 实现类
+ *
+ * @author 非繁人
+ */
+@Service
+@Validated
+@Slf4j
+public class OrderPercentageServiceImpl implements OrderPercentageService {
+
+    @Resource
+    private OrderPercentageMapper orderPercentageMapper;
+
+    @Override
+    public OrderPercentageDO queryStatus() {
+        List<OrderPercentageDO> orderPercentageDOS = orderPercentageMapper.selectList(new LambdaQueryWrapperX<OrderPercentageDO>()
+                .eqIfPresent(OrderPercentageDO::getStatus, 1));
+
+        if (orderPercentageDOS.isEmpty()) {
+            return null;
+        }
+        return orderPercentageDOS.get(0);
+    }
+
+}

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

@@ -75,11 +75,21 @@ public interface PtProfitLogService {
                     Long freezeAmount, Long afterFreezeAmount,
                     String percentTemplate,
                     Long tradeOrderId,
-                    String OrderNum
+                    String OrderNum,
+                    Long maxAvailablePointsAmount ,
+                    Long afterMaxAvailablePointsAmount
     );
 
     String getYesterdayLog(List<Long> sonsId);
 
     String getTotalLog(List<Long> sonsId);
 
+    /**
+     * 用来查询用户这条订单获取的积分记录
+     * @param userId 用户id
+     * @param type 日志类型
+     * @param orderNum 订单号
+     * @return  记录
+     */
+    PtProfitLogDO selectProfitLogByUserIdWithProfitStatus(Long userId, Integer type, String orderNum);
 }

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

@@ -76,8 +76,7 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
 //            ptProfitLogRespVO.setProfitStatusName(Objects.requireNonNull(CaclEnum.getCaclEnumByValue(ptProfitLogRespVO.getProfitStatus())).getName());
 //        }
 
-        PageResult<PtProfitLogRespVO> result = null;
-        return result;
+        return null;
     }
 
     @Override
@@ -93,15 +92,15 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
 
     /**
      * 添加一条用户积分日志消息
-     * @param userId
-     * @param caclEnum
-     * @param amount
-     * @param afterAmount
-     * @param freezeAmount
-     * @param afterFreezeAmount
-     * @param percentTemplate
-     * @param tradeOrderId
-     * @param OrderNum
+     * @param userId 用户id
+     * @param caclEnum 计算类型
+     * @param amount 可用积分
+     * @param afterAmount 变动后积分
+     * @param freezeAmount 冻结积分
+     * @param afterFreezeAmount 变动和冻结积分
+     * @param percentTemplate 模板
+     * @param tradeOrderId 订单id
+     * @param OrderNum 订单编号
      */
     @Override
     public void addMessage(Long generateUserId,//导致产生积分变动的用户ID
@@ -109,7 +108,9 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
                            Long freezeAmount, Long afterFreezeAmount,
                            String percentTemplate,
                            Long tradeOrderId,
-                           String OrderNum
+                           String OrderNum,
+                           Long maxAvailablePointsAmount ,
+                           Long afterMaxAvailablePointsAmount
     ) {
         PtProfitLogSaveReqVO ptProfitLog = PtProfitLogSaveReqVO.builder()
                 .afterAmount(afterAmount)
@@ -119,6 +120,8 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
                 .generateUserId(generateUserId)
                 .profitStatus(caclEnum.getType()).orderId(tradeOrderId).orderNo(OrderNum)
                 .freezeAmount(freezeAmount).afterFreezeAmount(afterFreezeAmount)
+                .maxAvailablePointsAmount(maxAvailablePointsAmount)
+                .afterMaxAvailablePointsAmount(afterMaxAvailablePointsAmount)
                 .build();
         ptProfitLogMapper.insert(BeanUtils.toBean(ptProfitLog, PtProfitLogDO.class));
 
@@ -162,4 +165,9 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
         return sum + "";
     }
 
+    @Override
+    public PtProfitLogDO selectProfitLogByUserIdWithProfitStatus(Long userId, Integer type, String orderNum) {
+        return ptProfitLogMapper.selectOne(PtProfitLogDO::getUserId,userId,PtProfitLogDO::getProfitStatus,type,PtProfitLogDO::getOrderNo,orderNum);
+    }
+
 }

+ 2 - 2
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/aftersale/AfterSaleServiceImpl.java

@@ -464,12 +464,12 @@ public class AfterSaleServiceImpl implements AfterSaleService {
 
 
         //订单退款,收回消费者获得的冻结积分
-        integralService.updateUserIntegral(orderUserId,orderUserId, CaclEnum.ORDER_REFUND_INTEGRAL_CONSUMER, 0L,increaseIntegral*(-1),tradeOrderId,tradeOrderNum);
+        integralService.updateUserIntegral(orderUserId,orderUserId, CaclEnum.ORDER_REFUND_INTEGRAL_CONSUMER, increaseIntegral*(-1),0L,tradeOrderId,tradeOrderNum);
 
         //20240604 推荐人(上级用户ID)
         Long ancesterUserId = tradeOrderMapper.selectAncesterByMemberUserId(orderUserId);
         //订单退款,收回消费者推荐人获得的冻结积分
-        integralService.updateUserIntegral(orderUserId,ancesterUserId, CaclEnum.ORDER_REFUND_INTEGRAL_ANCESTER, 0L,ancestorIncreaseIntegral*(-1),tradeOrderId,tradeOrderNum);
+        integralService.updateUserIntegral(orderUserId,ancesterUserId, CaclEnum.ORDER_REFUND_INTEGRAL_ANCESTER, ancestorIncreaseIntegral*(-1),0L,tradeOrderId,tradeOrderNum);
 
         //订单退款,收回消费者获得的冻结峰值
         integralService.updateIntegralFreezeHighQuota(orderUserId,orderUserId, CaclEnum.ORDER_REFUND_ORDER_PAY_FREEZE_HIGH_QUOTA, freezeHighQuota,tradeOrderId,tradeOrderNum);