Browse Source

Merge branch 'dev/2024/0613/update-admin-local-Y' of Harper/feifan-backend-zx-admin into master

修改合赢奖的计算程序
Yangzw 8 months ago
parent
commit
7531b26d2e
42 changed files with 1310 additions and 323 deletions
  1. 2 1
      feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/CaclEnum.java
  2. 2 0
      feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/ErrorCodeConstants.java
  3. 96 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailyawardrecords/DailyAwardRecordsController.java
  4. 24 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailyawardrecords/vo/DailyAwardRecordsPageReqVO.java
  5. 37 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailyawardrecords/vo/DailyAwardRecordsRespVO.java
  6. 30 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailyawardrecords/vo/DailyAwardRecordsSaveReqVO.java
  7. 95 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailybill/DailyBillController.java
  8. 40 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailybill/vo/DailyBillPageReqVO.java
  9. 48 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailybill/vo/DailyBillRespVO.java
  10. 37 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailybill/vo/DailyBillSaveReqVO.java
  11. 44 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/dailyawardrecords/DailyAwardRecordsDO.java
  12. 55 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/dailybill/DailyBillDO.java
  13. 27 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/dailyawardrecords/DailyAwardRecordsMapper.java
  14. 32 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/dailybill/DailyBillMapper.java
  15. 2 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ordercalc/OrderCalcMapper.java
  16. 2 1
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ptprofitlog/PtProfitLogMapper.java
  17. 1 3
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/mq/consumer/order/OrderConsumer.java
  18. 8 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/mq/message/order/CalcMessage.java
  19. 66 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/dailyawardrecords/DailyAwardRecordsService.java
  20. 146 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/dailyawardrecords/DailyAwardRecordsServiceImpl.java
  21. 60 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/dailybill/DailyBillService.java
  22. 76 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/dailybill/DailyBillServiceImpl.java
  23. 2 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/duser/DuserServiceImpl.java
  24. 2 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/integral/IntegralServiceImpl.java
  25. 3 2
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ordercalc/OrderCalcService.java
  26. 164 91
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ordercalc/OrderCalcServiceImpl.java
  27. 22 7
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/partitioncrash/PartitionCrashServiceImpl.java
  28. 3 2
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogService.java
  29. 22 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogServiceImpl.java
  30. 15 13
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/sharepath/SharePathServiceImpl.java
  31. 12 0
      feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/dailyawardrecords/DailyAwardRecordsMapper.xml
  32. 12 0
      feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/dailybill/DailyBillMapper.xml
  33. 6 0
      feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/ordercalc/OrderCalcMapper.xml
  34. 0 131
      feifan-module-distri/feifan-module-distri-biz/src/test/java/cn/newfeifan/mall/module/distri/service/usersigninlog/UserSignInLogServiceImplTest.java
  35. 0 1
      feifan-module-mall/feifan-module-trade-api/src/main/java/cn/newfeifan/mall/module/trade/enums/ErrorCodeConstants.java
  36. 9 36
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/TradeOrderController.java
  37. 6 1
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/mysql/order/TradeOrderMapper.java
  38. 6 31
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/job/order/TradeOrderAutoCalcJob.java
  39. 9 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderQueryService.java
  40. 36 0
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/service/order/TradeOrderQueryServiceImpl.java
  41. 32 1
      feifan-module-mall/feifan-module-trade-biz/src/main/resources/mapper/order/BrokerageUserMapper.xml
  42. 19 2
      sql/mysql/建空库SQL/13_20240617.sql

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

@@ -13,7 +13,7 @@ public enum CaclEnum {
     DIRECT_REFERRAL_QUOTA(4, "购物获得","购物获得可用积分"),       //购物用户自得额度
     TOGETHER_AWARD(5, "合赢奖","合赢奖"),
     HIGH_QUOTA(6, "最高可以获得积分","最高可以获得积分"),
-    SMALL_QUOTA_CRASH(7, "合赢奖获得","小区额度分配"),
+    SMALL_QUOTA_CRASH(7, "合赢奖获得","小区额度分配(冻结的)"),
     AFTER_CRASH_CALC_PT_TOTAL_QUOTA(8, "碰撞后计算平台总收益","碰撞后计算平台总收益"),
     ORDER_PAY_INTEGRAL(9, "购物支付","购物使用积分进行支付"),      //购物使用积分进行支付
     ORDER_REFUND_INTEGRAL(10, "退回退款返回","退回退款订单项,消费者支付的积分"),
@@ -26,6 +26,7 @@ public enum CaclEnum {
     ORDER_REFUND_INTEGRAL_CONSUMER(19,"订单退款","订单退款,收回消费者获得的冻结积分"),
     ORDER_REFUND_INTEGRAL_ANCESTER(20,"订单退款","订单退款,收回消费者的推荐人,获得的冻结积分"),
     ORDER_PAY_INTEGRAL_CONSUMER(21, "购物获得","消费者购物,获得冻结积分"),//购物者本人 获得积分
+    SMALL_QUOTA_CRASH_SETTLE(22, "合赢奖结算获得","每天计算的合赢奖7天后结算"),
     ;
 
     /**

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

@@ -29,5 +29,7 @@ public interface ErrorCodeConstants {
     ErrorCode GROSS_PROFIT_BONUS_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT = new ErrorCode(1_002_030_022, "合赢奖不能超过最大限制");
     ErrorCode USER_SIGN_IN_LOG_NOT_EXISTS = new ErrorCode(1_002_030_023, "签到日志不存在");
     ErrorCode PT_PROFIT_LOG_DETAILS_NOT_EXISTS = new ErrorCode(1_002_030_024, "平台利润记录详情不存在");
+    ErrorCode DAILY_BILL_NOT_EXISTS = new ErrorCode(1_002_030_025, "每日账单详细不存在");
+    ErrorCode DAILY_AWARD_RECORDS_NOT_EXISTS = new ErrorCode(1_002_030_026, "每日用户获得合赢奖记录不存在");
 
 }

+ 96 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailyawardrecords/DailyAwardRecordsController.java

@@ -0,0 +1,96 @@
+package cn.newfeifan.mall.module.distri.controller.admin.dailyawardrecords;
+
+import org.springframework.context.annotation.Lazy;
+import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.security.access.prepost.PreAuthorize;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+
+import javax.validation.*;
+import javax.servlet.http.*;
+import java.util.*;
+import java.io.IOException;
+
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.pojo.CommonResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
+
+import cn.newfeifan.mall.framework.excel.core.util.ExcelUtils;
+
+import cn.newfeifan.mall.framework.operatelog.core.annotations.OperateLog;
+import static cn.newfeifan.mall.framework.operatelog.core.enums.OperateTypeEnum.*;
+
+import cn.newfeifan.mall.module.distri.controller.admin.dailyawardrecords.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.dailyawardrecords.DailyAwardRecordsDO;
+import cn.newfeifan.mall.module.distri.service.dailyawardrecords.DailyAwardRecordsService;
+
+@Tag(name = "管理后台 - 每日用户获得合赢奖记录")
+@RestController
+@RequestMapping("/distri/daily-award-records")
+@Validated
+public class DailyAwardRecordsController {
+
+    @Resource
+    @Lazy
+    private DailyAwardRecordsService dailyAwardRecordsService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建每日用户获得合赢奖记录")
+    @PreAuthorize("@ss.hasPermission('distri:daily-award-records:create')")
+    public CommonResult<Long> createDailyAwardRecords(@Valid @RequestBody DailyAwardRecordsSaveReqVO createReqVO) {
+        return success(dailyAwardRecordsService.createDailyAwardRecords(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新每日用户获得合赢奖记录")
+    @PreAuthorize("@ss.hasPermission('distri:daily-award-records:update')")
+    public CommonResult<Boolean> updateDailyAwardRecords(@Valid @RequestBody DailyAwardRecordsSaveReqVO updateReqVO) {
+        dailyAwardRecordsService.updateDailyAwardRecords(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除每日用户获得合赢奖记录")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('distri:daily-award-records:delete')")
+    public CommonResult<Boolean> deleteDailyAwardRecords(@RequestParam("id") Long id) {
+        dailyAwardRecordsService.deleteDailyAwardRecords(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得每日用户获得合赢奖记录")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('distri:daily-award-records:query')")
+    public CommonResult<DailyAwardRecordsRespVO> getDailyAwardRecords(@RequestParam("id") Long id) {
+        DailyAwardRecordsDO dailyAwardRecords = dailyAwardRecordsService.getDailyAwardRecords(id);
+        return success(BeanUtils.toBean(dailyAwardRecords, DailyAwardRecordsRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得每日用户获得合赢奖记录分页")
+    @PreAuthorize("@ss.hasPermission('distri:daily-award-records:query')")
+    public CommonResult<PageResult<DailyAwardRecordsRespVO>> getDailyAwardRecordsPage(@Valid DailyAwardRecordsPageReqVO pageReqVO) {
+        PageResult<DailyAwardRecordsDO> pageResult = dailyAwardRecordsService.getDailyAwardRecordsPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, DailyAwardRecordsRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出每日用户获得合赢奖记录 Excel")
+    @PreAuthorize("@ss.hasPermission('distri:daily-award-records:export')")
+    @OperateLog(type = EXPORT)
+    public void exportDailyAwardRecordsExcel(@Valid DailyAwardRecordsPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<DailyAwardRecordsDO> list = dailyAwardRecordsService.getDailyAwardRecordsPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "每日用户获得合赢奖记录.xls", "数据", DailyAwardRecordsRespVO.class,
+                        BeanUtils.toBean(list, DailyAwardRecordsRespVO.class));
+    }
+
+}

+ 24 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailyawardrecords/vo/DailyAwardRecordsPageReqVO.java

@@ -0,0 +1,24 @@
+package cn.newfeifan.mall.module.distri.controller.admin.dailyawardrecords.vo;
+
+import lombok.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+
+@Schema(description = "管理后台 - 每日用户获得合赢奖记录分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class DailyAwardRecordsPageReqVO extends PageParam {
+
+    @Schema(description = "用户编号", example = "1755")
+    private Long userId;
+
+    @Schema(description = "奖励金额,必填")
+    private Long amount;
+
+    @Schema(description = "是否已结算,默认为未结算")
+    private Boolean settled;
+
+    @Schema(description = "日志Id", example = "16092")
+    private Long logId;
+}

+ 37 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailyawardrecords/vo/DailyAwardRecordsRespVO.java

@@ -0,0 +1,37 @@
+package cn.newfeifan.mall.module.distri.controller.admin.dailyawardrecords.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.time.LocalDateTime;
+import com.alibaba.excel.annotation.*;
+
+@Schema(description = "管理后台 - 每日用户获得合赢奖记录 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class DailyAwardRecordsRespVO {
+
+    @Schema(description = "奖励记录ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "20923")
+    @ExcelProperty("奖励记录ID")
+    private Long id;
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1755")
+    @ExcelProperty("用户编号")
+    private Long userId;
+
+    @Schema(description = "奖励金额,必填", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("奖励金额,必填")
+    private Long amount;
+
+    @Schema(description = "是否已结算,默认为未结算", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("是否已结算,默认为未结算")
+    private Boolean settled;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "日志Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16092")
+    @ExcelProperty("日志Id")
+    private Long logId;
+
+}

+ 30 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailyawardrecords/vo/DailyAwardRecordsSaveReqVO.java

@@ -0,0 +1,30 @@
+package cn.newfeifan.mall.module.distri.controller.admin.dailyawardrecords.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import javax.validation.constraints.*;
+
+@Schema(description = "管理后台 - 每日用户获得合赢奖记录新增/修改 Request VO")
+@Data
+@Builder
+public class DailyAwardRecordsSaveReqVO {
+
+    @Schema(description = "奖励记录ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "20923")
+    private Long id;
+
+    @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1755")
+    @NotNull(message = "用户编号不能为空")
+    private Long userId;
+
+    @Schema(description = "奖励金额,必填", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "奖励金额,必填不能为空")
+    private Long amount;
+
+    @Schema(description = "是否已结算,默认为未结算", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "是否已结算,默认为未结算不能为空")
+    private Boolean settled;
+
+    @Schema(description = "日志Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "16092")
+    @NotNull(message = "日志Id不能为空")
+    private Long logId;
+}

+ 95 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailybill/DailyBillController.java

@@ -0,0 +1,95 @@
+package cn.newfeifan.mall.module.distri.controller.admin.dailybill;
+
+import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.security.access.prepost.PreAuthorize;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+
+import javax.validation.constraints.*;
+import javax.validation.*;
+import javax.servlet.http.*;
+import java.util.*;
+import java.io.IOException;
+
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.pojo.CommonResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
+
+import cn.newfeifan.mall.framework.excel.core.util.ExcelUtils;
+
+import cn.newfeifan.mall.framework.operatelog.core.annotations.OperateLog;
+import static cn.newfeifan.mall.framework.operatelog.core.enums.OperateTypeEnum.*;
+
+import cn.newfeifan.mall.module.distri.controller.admin.dailybill.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.dailybill.DailyBillDO;
+import cn.newfeifan.mall.module.distri.service.dailybill.DailyBillService;
+
+@Tag(name = "管理后台 - 每日账单")
+@RestController
+@RequestMapping("/distri/daily-bill")
+@Validated
+public class DailyBillController {
+
+    @Resource
+    private DailyBillService dailyBillService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建每日账单")
+    @PreAuthorize("@ss.hasPermission('distri:daily-bill:create')")
+    public CommonResult<Long> createDailyBill(@Valid @RequestBody DailyBillSaveReqVO createReqVO) {
+        return success(dailyBillService.createDailyBill(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新每日账单")
+    @PreAuthorize("@ss.hasPermission('distri:daily-bill:update')")
+    public CommonResult<Boolean> updateDailyBill(@Valid @RequestBody DailyBillSaveReqVO updateReqVO) {
+        dailyBillService.updateDailyBill(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除每日账单")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('distri:daily-bill:delete')")
+    public CommonResult<Boolean> deleteDailyBill(@RequestParam("id") Long id) {
+        dailyBillService.deleteDailyBill(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得每日账单")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('distri:daily-bill:query')")
+    public CommonResult<DailyBillRespVO> getDailyBill(@RequestParam("id") Long id) {
+        DailyBillDO dailyBill = dailyBillService.getDailyBill(id);
+        return success(BeanUtils.toBean(dailyBill, DailyBillRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得每日账单分页")
+    @PreAuthorize("@ss.hasPermission('distri:daily-bill:query')")
+    public CommonResult<PageResult<DailyBillRespVO>> getDailyBillPage(@Valid DailyBillPageReqVO pageReqVO) {
+        PageResult<DailyBillDO> pageResult = dailyBillService.getDailyBillPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, DailyBillRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出每日账单 Excel")
+    @PreAuthorize("@ss.hasPermission('distri:daily-bill:export')")
+    @OperateLog(type = EXPORT)
+    public void exportDailyBillExcel(@Valid DailyBillPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<DailyBillDO> list = dailyBillService.getDailyBillPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "每日账单.xls", "数据", DailyBillRespVO.class,
+                        BeanUtils.toBean(list, DailyBillRespVO.class));
+    }
+
+}

+ 40 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailybill/vo/DailyBillPageReqVO.java

@@ -0,0 +1,40 @@
+package cn.newfeifan.mall.module.distri.controller.admin.dailybill.vo;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+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 DailyBillPageReqVO extends PageParam {
+
+    @Schema(description = "金额,单位:分")
+    private Integer amount;
+
+    @Schema(description = "确收金额,单位:分")
+    private Integer receivedAmount;
+
+    @Schema(description = "订单数,默认为0", example = "16252")
+    private Integer orderCount;
+
+    @Schema(description = "店铺ID", example = "28751")
+    private Integer shopId;
+
+    @Schema(description = "商户ID", example = "26719")
+    private Integer merchantId;
+
+    @Schema(description = "订单ID列表")
+    private String orderIds;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}

+ 48 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailybill/vo/DailyBillRespVO.java

@@ -0,0 +1,48 @@
+package cn.newfeifan.mall.module.distri.controller.admin.dailybill.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.util.*;
+import java.util.*;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+import com.alibaba.excel.annotation.*;
+
+@Schema(description = "管理后台 - 每日账单 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class DailyBillRespVO {
+
+    @Schema(description = "账单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17268")
+    @ExcelProperty("账单编号")
+    private Long id;
+
+    @Schema(description = "金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("金额,单位:分")
+    private Integer amount;
+
+    @Schema(description = "确收金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("确收金额,单位:分")
+    private Integer receivedAmount;
+
+    @Schema(description = "订单数,默认为0", requiredMode = Schema.RequiredMode.REQUIRED, example = "16252")
+    @ExcelProperty("订单数,默认为0")
+    private Integer orderCount;
+
+    @Schema(description = "店铺ID", example = "28751")
+    @ExcelProperty("店铺ID")
+    private Integer shopId;
+
+    @Schema(description = "商户ID", example = "26719")
+    @ExcelProperty("商户ID")
+    private Integer merchantId;
+
+    @Schema(description = "订单ID列表", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("订单ID列表")
+    private String orderIds;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+}

+ 37 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/dailybill/vo/DailyBillSaveReqVO.java

@@ -0,0 +1,37 @@
+package cn.newfeifan.mall.module.distri.controller.admin.dailybill.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.util.*;
+import javax.validation.constraints.*;
+
+@Schema(description = "管理后台 - 每日账单新增/修改 Request VO")
+@Data
+public class DailyBillSaveReqVO {
+
+    @Schema(description = "账单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17268")
+    private Long id;
+
+    @Schema(description = "金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "金额,单位:分不能为空")
+    private Integer amount;
+
+    @Schema(description = "确收金额,单位:分", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "确收金额,单位:分不能为空")
+    private Integer receivedAmount;
+
+    @Schema(description = "订单数,默认为0", requiredMode = Schema.RequiredMode.REQUIRED, example = "16252")
+    @NotNull(message = "订单数,默认为0不能为空")
+    private Integer orderCount;
+
+    @Schema(description = "店铺ID", example = "28751")
+    private Integer shopId;
+
+    @Schema(description = "商户ID", example = "26719")
+    private Integer merchantId;
+
+    @Schema(description = "订单ID列表", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "订单ID列表不能为空")
+    private String orderIds;
+
+}

+ 44 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/dailyawardrecords/DailyAwardRecordsDO.java

@@ -0,0 +1,44 @@
+package cn.newfeifan.mall.module.distri.dal.dataobject.dailyawardrecords;
+
+import lombok.*;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 每日用户获得合赢奖记录 DO
+ *
+ * @author 非繁人
+ */
+@TableName("distri_daily_award_records")
+@KeySequence("distri_daily_award_records_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class DailyAwardRecordsDO extends BaseDO {
+
+    /**
+     * 奖励记录ID
+     */
+    @TableId
+    private Long id;
+    /**
+     * 用户编号
+     */
+    private Long userId;
+    /**
+     * 奖励金额,必填
+     */
+    private Long amount;
+    /**
+     * 是否已结算,默认为未结算
+     */
+    private Boolean settled;
+    /**
+     * 日志Id
+     */
+    private Long logId;
+
+}

+ 55 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/dailybill/DailyBillDO.java

@@ -0,0 +1,55 @@
+package cn.newfeifan.mall.module.distri.dal.dataobject.dailybill;
+
+import lombok.*;
+import java.util.*;
+import java.time.LocalDateTime;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 每日账单 DO
+ *
+ * @author 非繁人
+ */
+@TableName("distri_daily_bill")
+@KeySequence("distri_daily_bill_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class DailyBillDO extends BaseDO {
+
+    /**
+     * 账单编号
+     */
+    @TableId
+    private Long id;
+    /**
+     * 金额,单位:分
+     */
+    private Integer amount;
+    /**
+     * 确收金额,单位:分
+     */
+    private Integer receivedAmount;
+    /**
+     * 订单数,默认为0
+     */
+    private Integer orderCount;
+    /**
+     * 店铺ID
+     */
+    private Integer shopId;
+    /**
+     * 商户ID
+     */
+    private Integer merchantId;
+    /**
+     * 订单ID列表
+     */
+    private String orderIds;
+
+}

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

@@ -0,0 +1,27 @@
+package cn.newfeifan.mall.module.distri.dal.mysql.dailyawardrecords;
+
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
+import cn.newfeifan.mall.module.distri.dal.dataobject.dailyawardrecords.DailyAwardRecordsDO;
+import org.apache.ibatis.annotations.Mapper;
+import cn.newfeifan.mall.module.distri.controller.admin.dailyawardrecords.vo.*;
+
+/**
+ * 每日用户获得合赢奖记录 Mapper
+ *
+ * @author 非繁人
+ */
+@Mapper
+public interface DailyAwardRecordsMapper extends BaseMapperX<DailyAwardRecordsDO> {
+
+    default PageResult<DailyAwardRecordsDO> selectPage(DailyAwardRecordsPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<DailyAwardRecordsDO>()
+                .eqIfPresent(DailyAwardRecordsDO::getUserId, reqVO.getUserId())
+                .eqIfPresent(DailyAwardRecordsDO::getAmount, reqVO.getAmount())
+                .eqIfPresent(DailyAwardRecordsDO::getSettled, reqVO.getSettled())
+                .orderByDesc(DailyAwardRecordsDO::getId));
+    }
+
+}

+ 32 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/dailybill/DailyBillMapper.java

@@ -0,0 +1,32 @@
+package cn.newfeifan.mall.module.distri.dal.mysql.dailybill;
+
+import java.util.*;
+
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
+import cn.newfeifan.mall.module.distri.dal.dataobject.dailybill.DailyBillDO;
+import org.apache.ibatis.annotations.Mapper;
+import cn.newfeifan.mall.module.distri.controller.admin.dailybill.vo.*;
+
+/**
+ * 每日账单 Mapper
+ *
+ * @author 非繁人
+ */
+@Mapper
+public interface DailyBillMapper extends BaseMapperX<DailyBillDO> {
+
+    default PageResult<DailyBillDO> selectPage(DailyBillPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<DailyBillDO>()
+                .eqIfPresent(DailyBillDO::getAmount, reqVO.getAmount())
+                .eqIfPresent(DailyBillDO::getReceivedAmount, reqVO.getReceivedAmount())
+                .eqIfPresent(DailyBillDO::getOrderCount, reqVO.getOrderCount())
+                .eqIfPresent(DailyBillDO::getShopId, reqVO.getShopId())
+                .eqIfPresent(DailyBillDO::getMerchantId, reqVO.getMerchantId())
+                .eqIfPresent(DailyBillDO::getOrderIds, reqVO.getOrderIds())
+                .betweenIfPresent(DailyBillDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(DailyBillDO::getId));
+    }
+
+}

+ 2 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ordercalc/OrderCalcMapper.java

@@ -38,4 +38,6 @@ public interface OrderCalcMapper extends BaseMapperX<OrderCalcDO> {
     }
 
     void updateOrderItemById(@Param("orderItemId")Long orderItemId);
+
+    void updateOrderItemTransitionTime(@Param("orderItemId") Long orderItemId);
 }

+ 2 - 1
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ptprofitlog/PtProfitLogMapper.java

@@ -35,7 +35,8 @@ public interface PtProfitLogMapper extends BaseMapperX<PtProfitLogDO> {
                 ORDER_PAY_INTEGRAL_ANCESTER.getType(),
                 ORDER_REFUND_INTEGRAL_CONSUMER.getType(),
                 ORDER_REFUND_INTEGRAL_ANCESTER.getType(),
-                ORDER_PAY_INTEGRAL_CONSUMER.getType());
+                ORDER_PAY_INTEGRAL_CONSUMER.getType(),
+                SMALL_QUOTA_CRASH_SETTLE.getType());
 
         if(reqVO.getUserId().equals(PT_ID)){
             profitStatus = Arrays.asList(

+ 1 - 3
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/mq/consumer/order/OrderConsumer.java

@@ -1,7 +1,6 @@
 package cn.newfeifan.mall.module.distri.mq.consumer.order;
 
 import cn.newfeifan.mall.module.distri.mq.message.order.CalcMessage;
-import cn.newfeifan.mall.module.distri.mq.message.order.DistriOrderMessage;
 import cn.newfeifan.mall.module.distri.service.ordercalc.OrderCalcService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.event.EventListener;
@@ -9,7 +8,6 @@ import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
-import java.util.List;
 
 
 @Component
@@ -24,7 +22,7 @@ public class OrderConsumer {
     public void onMessage(CalcMessage calcMessage) {
         log.info("[onMessage][消息内容({})]", calcMessage);
         // todo 计算数据
-        orderCalcService.calc(calcMessage.getOrderCalcMessages());
+        orderCalcService.calc(calcMessage.getOrderCalcMessages(),calcMessage.getBonusQuotaOrderDO());
 
     }
 

+ 8 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/mq/message/order/CalcMessage.java

@@ -13,7 +13,15 @@ import java.util.List;
 @AllArgsConstructor
 public class CalcMessage {
     List<DistriOrderMessage> distriOrderMessages;
+    /**
+     * 用来存储发货后七天的订单计算信息(用来计算直推奖,自得奖)
+     */
     List<OrderCalcMessage> orderCalcMessages;
 
+    /**
+     * 用来存储每天的订单(用来计算合赢奖的)
+     */
+    List<OrderCalcMessage> bonusQuotaOrderDO;
+
 
 }

+ 66 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/dailyawardrecords/DailyAwardRecordsService.java

@@ -0,0 +1,66 @@
+package cn.newfeifan.mall.module.distri.service.dailyawardrecords;
+
+import javax.validation.*;
+import cn.newfeifan.mall.module.distri.controller.admin.dailyawardrecords.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.dailyawardrecords.DailyAwardRecordsDO;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+
+/**
+ * 每日用户获得合赢奖记录 Service 接口
+ *
+ * @author 非繁人
+ */
+public interface DailyAwardRecordsService {
+
+    /**
+     * 创建每日用户获得合赢奖记录
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createDailyAwardRecords(@Valid DailyAwardRecordsSaveReqVO createReqVO);
+
+    /**
+     * 更新每日用户获得合赢奖记录
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateDailyAwardRecords(@Valid DailyAwardRecordsSaveReqVO updateReqVO);
+
+    /**
+     * 删除每日用户获得合赢奖记录
+     *
+     * @param id 编号
+     */
+    void deleteDailyAwardRecords(Long id);
+
+    /**
+     * 获得每日用户获得合赢奖记录
+     *
+     * @param id 编号
+     * @return 每日用户获得合赢奖记录
+     */
+    DailyAwardRecordsDO getDailyAwardRecords(Long id);
+
+    /**
+     * 获得每日用户获得合赢奖记录分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 每日用户获得合赢奖记录分页
+     */
+    PageResult<DailyAwardRecordsDO> getDailyAwardRecordsPage(DailyAwardRecordsPageReqVO pageReqVO);
+
+    /**
+     * 添加每日用户获得合赢奖记录
+     *
+     * @param userId 用户编号
+     * @param amount 获得的合赢奖
+     * @param logId 日志编号
+     */
+    void addDailyAwardRecords(Long userId, Long amount, Long logId);
+
+    /**
+     * 获取七天前的合赢奖记录,将他转换成可用积分
+     */
+    void transitionBonus();
+}

+ 146 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/dailyawardrecords/DailyAwardRecordsServiceImpl.java

@@ -0,0 +1,146 @@
+package cn.newfeifan.mall.module.distri.service.dailyawardrecords;
+
+import cn.newfeifan.mall.module.distri.controller.admin.integral.vo.IntegralSaveReqVO;
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.PtProfitLogSaveReqVO;
+import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
+import cn.newfeifan.mall.module.distri.enums.CaclEnum;
+import cn.newfeifan.mall.module.distri.service.integral.IntegralService;
+import cn.newfeifan.mall.module.distri.service.ptprofitlog.PtProfitLogService;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+
+import org.springframework.validation.annotation.Validated;
+
+import cn.newfeifan.mall.module.distri.controller.admin.dailyawardrecords.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.dailyawardrecords.DailyAwardRecordsDO;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+
+import cn.newfeifan.mall.module.distri.dal.mysql.dailyawardrecords.DailyAwardRecordsMapper;
+
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
+
+import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*;
+
+/**
+ * 每日用户获得合赢奖记录 Service 实现类
+ *
+ * @author 非繁人
+ */
+@Service
+@Validated
+public class DailyAwardRecordsServiceImpl implements DailyAwardRecordsService {
+
+    @Resource
+    private DailyAwardRecordsMapper dailyAwardRecordsMapper;
+
+    @Resource
+    private IntegralService integralService;
+
+    @Resource
+    private PtProfitLogService ptProfitLogService;
+
+    @Override
+    public Long createDailyAwardRecords(DailyAwardRecordsSaveReqVO createReqVO) {
+        // 插入
+        DailyAwardRecordsDO dailyAwardRecords = BeanUtils.toBean(createReqVO, DailyAwardRecordsDO.class);
+        dailyAwardRecordsMapper.insert(dailyAwardRecords);
+        // 返回
+        return dailyAwardRecords.getId();
+    }
+
+    @Override
+    public void updateDailyAwardRecords(DailyAwardRecordsSaveReqVO updateReqVO) {
+        // 校验存在
+        validateDailyAwardRecordsExists(updateReqVO.getId());
+        // 更新
+        DailyAwardRecordsDO updateObj = BeanUtils.toBean(updateReqVO, DailyAwardRecordsDO.class);
+        dailyAwardRecordsMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteDailyAwardRecords(Long id) {
+        // 校验存在
+        validateDailyAwardRecordsExists(id);
+        // 删除
+        dailyAwardRecordsMapper.deleteById(id);
+    }
+
+    private void validateDailyAwardRecordsExists(Long id) {
+        if (dailyAwardRecordsMapper.selectById(id) == null) {
+            throw exception(DAILY_AWARD_RECORDS_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public DailyAwardRecordsDO getDailyAwardRecords(Long id) {
+        return dailyAwardRecordsMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<DailyAwardRecordsDO> getDailyAwardRecordsPage(DailyAwardRecordsPageReqVO pageReqVO) {
+        return dailyAwardRecordsMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public void addDailyAwardRecords(Long userId, Long amount, Long logId) {
+        DailyAwardRecordsSaveReqVO createReqVO = DailyAwardRecordsSaveReqVO
+                .builder()
+                .userId(userId)
+                .amount(amount)
+                .settled(false)
+                .logId(logId)
+                .build();
+        DailyAwardRecordsDO dailyAwardRecords = BeanUtils.toBean(createReqVO, DailyAwardRecordsDO.class);
+        dailyAwardRecordsMapper.insert(dailyAwardRecords);
+    }
+
+    @Override
+    public void transitionBonus() {
+        // 获取当前时间减去7天
+        LocalDateTime sevenDaysAgo = LocalDateTime.now().minusDays(7);
+
+        // 格式化成数据库可以识别的日期时间格式(假设数据库字段为 LocalDateTime 类型)
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String formattedDate = sevenDaysAgo.format(formatter);
+
+        //获取到当前7天前未结算的记录
+        List<DailyAwardRecordsDO> dailyAwardRecordsSaveReqVOS = dailyAwardRecordsMapper.selectList(new LambdaQueryWrapper<DailyAwardRecordsDO>()
+                .eq(DailyAwardRecordsDO::getSettled, false)
+                .lt(DailyAwardRecordsDO::getCreateTime, formattedDate)
+        );
+
+        dailyAwardRecordsSaveReqVOS.forEach(dailyAwardRecordsDO -> {
+            //获取用户钱包
+            IntegralDO integralDO = integralService.getIntegralByUserId(dailyAwardRecordsDO.getUserId());
+            //减去待确权
+            integralDO.setFreezeQuota(integralDO.getFreezeQuota() - dailyAwardRecordsDO.getAmount());
+            //加入可用
+            integralDO.setCurrentQuota(integralDO.getCurrentQuota() + dailyAwardRecordsDO.getAmount());
+            integralService.updateIntegral(IntegralSaveReqVO.builder()
+                    .id(integralDO.getId())
+                    .freezeQuota(integralDO.getFreezeQuota())
+                    .currentQuota(integralDO.getCurrentQuota())
+                    .build());
+
+            PtProfitLogSaveReqVO winWinLog = PtProfitLogSaveReqVO.builder()
+                    .profitStatus(CaclEnum.SMALL_QUOTA_CRASH_SETTLE.getType())
+                    .userId(dailyAwardRecordsDO.getUserId())
+                    .amount(dailyAwardRecordsDO.getAmount())
+                    .afterAmount(integralDO.getCurrentQuota())
+                    .freezeAmount(-dailyAwardRecordsDO.getAmount())
+                    .afterFreezeAmount(integralDO.getFreezeQuota())
+                    .build();
+            ptProfitLogService.createPtProfitLog(winWinLog);
+
+            dailyAwardRecordsDO.setSettled(true);
+            dailyAwardRecordsMapper.updateById(dailyAwardRecordsDO);
+        });
+    }
+
+}

+ 60 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/dailybill/DailyBillService.java

@@ -0,0 +1,60 @@
+package cn.newfeifan.mall.module.distri.service.dailybill;
+
+import java.util.*;
+import javax.validation.*;
+import cn.newfeifan.mall.module.distri.controller.admin.dailybill.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.dailybill.DailyBillDO;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.pojo.PageParam;
+
+/**
+ * 每日账单 Service 接口
+ *
+ * @author 非繁人
+ */
+public interface DailyBillService {
+
+    /**
+     * 创建每日账单
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createDailyBill(@Valid DailyBillSaveReqVO createReqVO);
+
+    /**
+     * 更新每日账单
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateDailyBill(@Valid DailyBillSaveReqVO updateReqVO);
+
+    /**
+     * 删除每日账单
+     *
+     * @param id 编号
+     */
+    void deleteDailyBill(Long id);
+
+    /**
+     * 获得每日账单
+     *
+     * @param id 编号
+     * @return 每日账单
+     */
+    DailyBillDO getDailyBill(Long id);
+
+    /**
+     * 获得每日账单分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 每日账单分页
+     */
+    PageResult<DailyBillDO> getDailyBillPage(DailyBillPageReqVO pageReqVO);
+
+    /**
+     * 计算每家店铺每日的订单
+     */
+    void caleDailyBill();
+
+}

+ 76 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/dailybill/DailyBillServiceImpl.java

@@ -0,0 +1,76 @@
+package cn.newfeifan.mall.module.distri.service.dailybill;
+
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+
+import java.util.*;
+import cn.newfeifan.mall.module.distri.controller.admin.dailybill.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.dailybill.DailyBillDO;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
+
+import cn.newfeifan.mall.module.distri.dal.mysql.dailybill.DailyBillMapper;
+
+import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*;
+
+/**
+ * 每日账单 Service 实现类
+ *
+ * @author 非繁人
+ */
+@Service
+@Validated
+public class DailyBillServiceImpl implements DailyBillService {
+
+    @Resource
+    private DailyBillMapper dailyBillMapper;
+
+    @Override
+    public Long createDailyBill(DailyBillSaveReqVO createReqVO) {
+        // 插入
+        DailyBillDO dailyBill = BeanUtils.toBean(createReqVO, DailyBillDO.class);
+        dailyBillMapper.insert(dailyBill);
+        // 返回
+        return dailyBill.getId();
+    }
+
+    @Override
+    public void updateDailyBill(DailyBillSaveReqVO updateReqVO) {
+        // 校验存在
+        validateDailyBillExists(updateReqVO.getId());
+        // 更新
+        DailyBillDO updateObj = BeanUtils.toBean(updateReqVO, DailyBillDO.class);
+        dailyBillMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteDailyBill(Long id) {
+        // 校验存在
+        validateDailyBillExists(id);
+        // 删除
+        dailyBillMapper.deleteById(id);
+    }
+
+    private void validateDailyBillExists(Long id) {
+        if (dailyBillMapper.selectById(id) == null) {
+            throw exception(DAILY_BILL_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public DailyBillDO getDailyBill(Long id) {
+        return dailyBillMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<DailyBillDO> getDailyBillPage(DailyBillPageReqVO pageReqVO) {
+        return dailyBillMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public void caleDailyBill() {
+    }
+
+}

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

@@ -23,6 +23,7 @@ import cn.newfeifan.mall.module.member.convert.user.MemberUserConvert;
 import cn.newfeifan.mall.module.member.dal.dataobject.user.MemberUserDO;
 import cn.newfeifan.mall.module.member.service.user.MemberUserService;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -61,6 +62,7 @@ public class DuserServiceImpl implements DuserService {
     private SharePathMapper sharePathMapper;
 
     @Resource
+    @Lazy
     private SharePathService sharePathService;
 
     @Resource

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

@@ -3,6 +3,7 @@ package cn.newfeifan.mall.module.distri.service.integral;
 import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.newfeifan.mall.module.distri.service.sharepath.SharePathService;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -34,6 +35,7 @@ public class IntegralServiceImpl implements IntegralService {
     private IntegralMapper integralMapper;
 
     @Resource
+    @Lazy
     private SharePathService sharePathService;
 
     @Override

+ 3 - 2
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ordercalc/OrderCalcService.java

@@ -56,9 +56,10 @@ public interface OrderCalcService {
 
     /**
      * 计算订单信息
-     * @param tradeOrderDO
+     * @param tradeOrderDO 直推奖和用户自得获得的计算(发货7天后)
+     * @param bonusQuotaOrderDO   合计奖的计算(发货7天后)
      */
-    void calc(List<OrderCalcMessage> tradeOrderDO);
+    void calc(List<OrderCalcMessage> tradeOrderDO,List<OrderCalcMessage> bonusQuotaOrderDO);
 
 
     List<OrderCalcDO> queryTodayCalcByUserIds(LocalDateTime todayStart, LocalDateTime todayEnd,List<Long> userList);

+ 164 - 91
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ordercalc/OrderCalcServiceImpl.java

@@ -2,7 +2,6 @@ package cn.newfeifan.mall.module.distri.service.ordercalc;
 
 import cn.newfeifan.mall.framework.common.util.json.JsonUtils;
 import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
-import cn.newfeifan.mall.module.distri.controller.admin.duser.vo.DuserSaveReqVO;
 import cn.newfeifan.mall.module.distri.controller.admin.integral.vo.IntegralSaveReqVO;
 import cn.newfeifan.mall.module.distri.controller.admin.ptprofit.vo.PtProfitSaveReqVO;
 import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlog.vo.PtProfitLogSaveReqVO;
@@ -16,6 +15,8 @@ import cn.newfeifan.mall.module.distri.enums.SocialStatusEnum;
 import cn.newfeifan.mall.module.distri.mq.message.order.DistriOrderMessage;
 import cn.newfeifan.mall.module.distri.mq.message.order.OrderCalcMessage;
 import cn.newfeifan.mall.module.distri.mq.message.order.OrderItemMessage;
+import cn.newfeifan.mall.module.distri.service.dailyawardrecords.DailyAwardRecordsService;
+import cn.newfeifan.mall.module.distri.service.dailybill.DailyBillService;
 import cn.newfeifan.mall.module.distri.service.duser.DuserService;
 import cn.newfeifan.mall.module.distri.service.integral.IntegralService;
 import cn.newfeifan.mall.module.distri.service.orderpercentage.OrderPercentageService;
@@ -88,6 +89,12 @@ public class OrderCalcServiceImpl implements OrderCalcService {
     @Resource
     private PtProfitLogDetailsService ptProfitLogDetailsService;
 
+    @Resource
+    private DailyBillService dailyBillService;
+
+    @Resource
+    private DailyAwardRecordsService dailyAwardRecordsService;
+
     @Override
     public Long createOrderCalc(OrderCalcSaveReqVO createReqVO) {
         // 插入
@@ -133,7 +140,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void calc(List<OrderCalcMessage> tradeOrderDO) {
+    public void calc(List<OrderCalcMessage> tradeOrderDO, List<OrderCalcMessage> bonusQuotaOrderDO) {
 
         // 获取到当前订单的所有人
         List<Long> userId = tradeOrderDO.stream().map(OrderCalcMessage::getUserId).collect(Collectors.toList());
@@ -147,15 +154,138 @@ public class OrderCalcServiceImpl implements OrderCalcService {
             // 当前计算百分比模板
             String percentTemplate = JsonUtils.toJsonString(orderPercentageDO);
             calc(tradeOrderDO, orderPercentageDO, percentTemplate);
+
+            /*
+            计算合赢奖三部曲:
+                1:计算每日订单
+                2:计算每日合赢奖的收益(冻结的)
+                3:将冻结的合赢将转换成可用的
+             */
+            //计算每日订单收益
+            //  1
+            calcDailyBill(bonusQuotaOrderDO, orderPercentageDO, percentTemplate);
         } catch (Exception e) {
             System.out.println(e.getMessage());
         } finally {
             // todo 计算当天用户的碰撞
             // 计算兄弟分区, 以及后代分区
-            partitionCrashService.calcCrash(userId);
+            //  2
+            List<Long> userId2 = bonusQuotaOrderDO.stream().map(OrderCalcMessage::getUserId).collect(Collectors.toList());
+            partitionCrashService.calcCrash(userId2);
+
+            //  3
+            dailyAwardRecordsService.transitionBonus();
+
+            // 计算每家店铺每日订单
+            dailyBillService.caleDailyBill();
         }
     }
 
+    /**
+     * 将原来程序中的合赢将计算程序分离出来(这里用来计算每日的订单合赢奖)
+     *
+     * @param bonusQuotaOrderDO 每日符合条件的订单
+     * @param orderPercentageDO 订单百分比
+     * @param percentTemplate   计算比例模板
+     */
+
+    private void calcDailyBill(List<OrderCalcMessage> bonusQuotaOrderDO, OrderPercentageDO orderPercentageDO, String percentTemplate) {
+        // 每个订单收益
+        List<OrderCalcSaveReqVO> saveList = new ArrayList<>();
+
+        bonusQuotaOrderDO.forEach(k -> {
+            // 添加平台利润记录详情
+            List<PtProfitLogDetailsSaveReqVO> ptProfitLogDetailsSaveReqVOS = new ArrayList<>();
+            // 计算单个订单的总单价
+            long priceStream = k.getOrderItemMessages().stream().mapToLong(OrderItemMessage::getPrice).sum();
+            // 计算单个订单的总成本
+            long longStream = k.getOrderItemMessages().stream().mapToLong(OrderItemMessage::getCostPrice).sum();
+            BigDecimal price = new BigDecimal(priceStream);
+            BigDecimal costPrice = new BigDecimal(longStream);
+
+            // 计算
+            // 计算利润: (价格 - 成本价格) * 产品数量
+            //用户自得和直推奖不用计算,从orderItem里面获取
+            final BigDecimal[] profit = {new BigDecimal("0"), new BigDecimal("0"), new BigDecimal("0")};
+            k.getOrderItemMessages().forEach(j -> {
+                BigDecimal onePrice = new BigDecimal(j.getPrice());
+                BigDecimal oneCostPrice = new BigDecimal(j.getCostPrice());
+                BigDecimal productCount = new BigDecimal(j.getCount());
+                BigDecimal oneGrossProfit = onePrice.subtract(oneCostPrice).multiply(productCount);
+                profit[0] = profit[0].add(oneGrossProfit);  // 注意这里的改动
+                profit[1] = profit[1].add(new BigDecimal(j.getIncreaseIntegral()));     //自得积分
+                profit[2] = profit[2].add(new BigDecimal(j.getAncestorIncreaseIntegral()));     //自得积分
+
+                // 参与过订单计算后就标记为已分配权益
+                updateOrderItemTransitionTime(j.getOrderItemId());
+                //  添加日志表的二级表
+                PtProfitLogDetailsSaveReqVO ptProfitLogDetailsSaveReqVO = PtProfitLogDetailsSaveReqVO.builder()
+                        .orderItemId(j.getOrderItemId())
+                        .build();
+                ptProfitLogDetailsSaveReqVOS.add(ptProfitLogDetailsSaveReqVO);
+            });
+
+            // 计算毛利: 利润 * 1
+            BigDecimal grossProfit = profit[0].multiply(new BigDecimal(orderPercentageDO.getGrossProfitPerc())).setScale(4, RoundingMode.DOWN);
+            // 合赢将: 毛利 * 0.12
+            BigDecimal bonusQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitBonusQuotaPerc())).setScale(4, RoundingMode.DOWN);
+
+            // 用户所得: 毛利 * 0.35
+            BigDecimal descendantQuota = profit[1];
+
+            // 直推奖: 毛利 * 0.3 (上一级)
+            BigDecimal ancestorQuota = profit[2];
+
+            Long grossProfitInt = grossProfit.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
+            Long bonusQuotaInt = bonusQuota.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
+            BigDecimal platformQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitPlatformQuotaPerc())).setScale(4, RoundingMode.DOWN);
+
+            Long ancestorQuotaInt = ancestorQuota.longValue();
+            Long descendantQuotaInt = descendantQuota.longValue();
+            Long platformQuotaInt = platformQuota.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
+
+            // ========== 汇总计算 =================
+            OrderCalcSaveReqVO orderCalcSaveReqVO = OrderCalcSaveReqVO.builder()
+                    .userId(k.getUserId())
+                    .orderNo(k.getNo())
+                    .orderId(k.getOrderId())
+                    .cost(costPrice.longValue())
+                    .price(price.longValue())
+                    .productCount(k.getProductCount())
+                    .nickName(k.getNickName())
+                    .name(k.getName())
+                    .grossProfit(grossProfitInt)
+                    .grossProfitUserQuota(descendantQuotaInt)
+                    .grossProfitPlatformQuota(platformQuotaInt)
+                    .grossProfitAncestorQuota(ancestorQuotaInt)
+                    .percentTemplate(percentTemplate).build();
+            saveList.add(orderCalcSaveReqVO);
+
+            // 合赢奖记录
+            PtProfitLogSaveReqVO hyjLog = PtProfitLogSaveReqVO.builder()
+                    .orderId(k.getOrderId())
+                    .profitStatus(CaclEnum.TOGETHER_AWARD.getType())
+                    .orderNo(k.getNo())
+                    .amount(bonusQuotaInt)
+                    .afterAmount(0L)
+                    .generateUserId(k.getUserId())
+                    .percentTemplate(percentTemplate).build();
+            // 添加获得合赢奖的记录
+            hyjLog.setId(ptProfitLogService.createPtProfitLog(hyjLog));
+            for (PtProfitLogDetailsSaveReqVO ptProfitLogDetailsSaveReqVO : ptProfitLogDetailsSaveReqVOS) {
+                ptProfitLogDetailsSaveReqVO.setDistriPtProfitLogId(hyjLog.getId());
+            }
+            ptProfitLogDetailsService.saveBatch(ptProfitLogDetailsSaveReqVOS);
+        });
+
+        // 将信息存储到数据库中
+        orderCalcMapper.insertBatch(BeanUtils.toBean(saveList, OrderCalcDO.class));
+    }
+
+    private void updateOrderItemTransitionTime(Long orderItemId) {
+        orderCalcMapper.updateOrderItemTransitionTime(orderItemId);
+    }
+
     @Override
     public List<OrderCalcDO> queryTodayCalcByUserIds(LocalDateTime todayStart, LocalDateTime todayEnd, List<Long> userList) {
         return orderCalcMapper.selectList(new LambdaQueryWrapperX<OrderCalcDO>()
@@ -170,18 +300,12 @@ public class OrderCalcServiceImpl implements OrderCalcService {
 
     private void calc(List<OrderCalcMessage> tradeOrderDO, OrderPercentageDO orderPercentageDO, String percentTemplate) {
 
-        List<PtProfitSaveReqVO> savePFitMap = new ArrayList<>();
-        // 每个订单收益
-        List<OrderCalcSaveReqVO> saveList = new ArrayList<>();
-        // 平台收益
-        List<PtProfitSaveReqVO> ptProfitSaveReqVOS = new ArrayList<>();
         // 平台收益日志
         List<PtProfitLogSaveReqVO> ptProfitLogSaveReqVOS = new ArrayList<>();
         // 修改用户钱包
         List<IntegralSaveReqVO> integralSaveReqVOS = new ArrayList<>();
 
         // todo 修改用户身价 如何从订单中获取身价?
-        List<DuserSaveReqVO> duserSaveReqVOS = new ArrayList<>();
         BigDecimal oneHundred = new BigDecimal(BigInteger.ONE);
 
 
@@ -191,20 +315,10 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                 .subtract(new BigDecimal(orderPercentageDO.getGrossProfitPlatformQuotaPerc()));
 
 
-        PtProfitDO ptProfitDO = ptProfitService.getPtProfit();
-        PtProfitDO finalPtProfitDO = ptProfitDO;
         tradeOrderDO.forEach(k -> {
-
-            // 计算单个订单的总单价
-            long priceStream = k.getOrderItemMessages().stream().mapToLong(OrderItemMessage::getPrice).sum();
-            // 计算单个订单的总成本
-            long longStream = k.getOrderItemMessages().stream().mapToLong(OrderItemMessage::getCostPrice).sum();
-            BigDecimal price = new BigDecimal(priceStream);
-            BigDecimal costPrice = new BigDecimal(longStream);
-
-            // 添加平台利润记录详情
-            List<PtProfitLogDetailsSaveReqVO> ptProfitLogDetailsSaveReqVOS = new ArrayList<>();
-
+            PtProfitDO ptProfitDO = ptProfitService.getPtProfit();
+            // 平台收益
+            List<PtProfitSaveReqVO> ptProfitSaveReqVOS = new ArrayList<>();
 
             // 计算
             // 计算利润: (价格 - 成本价格) * 产品数量
@@ -220,11 +334,8 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                 profit[2] = profit[2].add(new BigDecimal(j.getAncestorIncreaseIntegral()));     //自得积分
 
                 // 遍历订单项拿到订单项编号
+                //将当前订单项设置为已分配权益
                 updateOrderItem(j.getOrderItemId());
-                PtProfitLogDetailsSaveReqVO ptProfitLogDetailsSaveReqVO = PtProfitLogDetailsSaveReqVO.builder()
-                        .orderItemId(j.getOrderItemId())
-                        .build();
-                ptProfitLogDetailsSaveReqVOS.add(ptProfitLogDetailsSaveReqVO);
             });
 
 
@@ -244,9 +355,6 @@ public class OrderCalcServiceImpl implements OrderCalcService {
             // 直推奖: 毛利 * 0.3 (上一级)
             BigDecimal ancestorQuota = profit[2];
 
-            // 合赢将: 毛利 * 0.12
-            BigDecimal bonusQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitBonusQuotaPerc())).setScale(4, RoundingMode.DOWN);
-
             // 平台服务费: 毛利 * 0.05
             BigDecimal platformQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitPlatformQuotaPerc())).setScale(4, RoundingMode.DOWN);
 
@@ -255,10 +363,8 @@ public class OrderCalcServiceImpl implements OrderCalcService {
             BigDecimal highQuota = grossProfit.multiply(new BigDecimal("10")).setScale(4, RoundingMode.DOWN);
 
             // 乘以 10000 并转换为整数
-            Long grossProfitInt = grossProfit.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
             Long ancestorQuotaInt = ancestorQuota.longValue();
             Long descendantQuotaInt = descendantQuota.longValue();
-            Long bonusQuotaInt = bonusQuota.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
             Long highQuotaInt = highQuota.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
             Long grossProfitAfterBonusInt = grossProfitAfterBonus.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
             Long platformQuotaInt = platformQuota.multiply(new BigDecimal("10000")).setScale(0, RoundingMode.DOWN).longValue();
@@ -283,23 +389,10 @@ public class OrderCalcServiceImpl implements OrderCalcService {
             double descendantSocial = k.getOrderItemMessages().get(0).getTotalPrice() * orderUserSocialStatus / 100;
             duserService.updateDuserSocial(integralDO.getUserId(), (long) descendantSocial, SocialStatusEnum.SHOPPING_SOCIAL.getStatus());
 
+            /*
+            原本这里有添加到distri_order_calc表的记录,但是现在要合赢奖和(直推奖、自得奖)分开,所以现在搬走了
+             */
 
-            // ========== 汇总计算 =================
-            OrderCalcSaveReqVO orderCalcSaveReqVO = OrderCalcSaveReqVO.builder()
-                    .userId(k.getUserId())
-                    .orderNo(k.getNo())
-                    .orderId(k.getOrderId())
-                    .cost(costPrice.longValue())
-                    .price(price.longValue())
-                    .productCount(k.getProductCount())
-                    .nickName(k.getNickName())
-                    .name(k.getName())
-                    .grossProfit(grossProfitInt)
-                    .grossProfitUserQuota(descendantQuotaInt)
-                    .grossProfitAncestorQuota(ancestorQuotaInt)
-                    .grossProfitPlatformQuota(platformQuotaInt)
-                    .percentTemplate(percentTemplate).build();
-            saveList.add(orderCalcSaveReqVO);
             // ========== 修改用户钱包 =================
 
             //直推奖也要限制额度
@@ -416,51 +509,31 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                     .generateUserId(integralDO.getUserId())
                     .build();
 
-            // 合赢奖记录
-            PtProfitLogSaveReqVO hyjLog = PtProfitLogSaveReqVO.builder()
-                    .orderId(k.getOrderId())
-                    .profitStatus(CaclEnum.TOGETHER_AWARD.getType())
-                    .orderNo(k.getNo())
-                    .amount(bonusQuotaInt)
-                    .afterAmount(0L)
-                    .generateUserId(integralDO.getUserId())
-                    .percentTemplate(percentTemplate).build();
-            // 添加获得合赢奖的记录
-            hyjLog.setId(ptProfitLogService.createPtProfitLog(hyjLog));
-            for (PtProfitLogDetailsSaveReqVO ptProfitLogDetailsSaveReqVO : ptProfitLogDetailsSaveReqVOS) {
-                ptProfitLogDetailsSaveReqVO.setDistriPtProfitLogId(hyjLog.getId());
-            }
-            ptProfitLogDetailsService.saveBatch(ptProfitLogDetailsSaveReqVOS);
-
             ptProfitLogSaveReqVOS.add(ptTotal);
             ptProfitLogSaveReqVOS.add(ptGrossAddLog);
             ptProfitLogSaveReqVOS.add(ptAddLog);
             ptProfitLogSaveReqVOS.add(tjrLog);
             ptProfitLogSaveReqVOS.add(ztrLog);
 
+
+            PtProfitDO ptProfit = ptProfitService.getPtProfit();
+            // 计算总积分
+            Long total = ptProfitSaveReqVOS.stream().mapToLong(PtProfitSaveReqVO::getPtTotalAdd).sum();
+            Long add = ptProfitSaveReqVOS.stream().mapToLong(PtProfitSaveReqVO::getPtAdd).sum();
+            Long grossAdd = ptProfitSaveReqVOS.stream().mapToLong(PtProfitSaveReqVO::getPtGrossAdd).sum();
+            ptProfit.setPtAdd(ptProfit.getPtAdd() + add);
+            ptProfit.setPtTotalAdd(ptProfit.getPtTotalAdd() + total);
+            ptProfit.setPtGrossAdd(ptProfit.getPtGrossAdd() + grossAdd);
+            PtProfitSaveReqVO ptProfitSaveReqVO2 = PtProfitSaveReqVO.builder()
+                    .id(ptProfitDO.getId())
+                    .ptTotalAdd(ptProfit.getPtTotalAdd())
+                    .ptAdd(ptProfit.getPtAdd())
+                    .ptGrossAdd(ptProfit.getPtGrossAdd()).build();
+            ptProfitService.updatePtProfit(ptProfitSaveReqVO2);
         });
 
         // 信息整合
-        // 将信息存储到数据库中
-        orderCalcMapper.insertBatch(BeanUtils.toBean(saveList, OrderCalcDO.class));
-
         ptProfitLogService.saveBatch(ptProfitLogSaveReqVOS);
-
-        PtProfitDO ptProfit = ptProfitService.getPtProfit();
-        // 计算总积分
-        Long total = ptProfitSaveReqVOS.stream().mapToLong(PtProfitSaveReqVO::getPtTotalAdd).sum();
-        Long add = ptProfitSaveReqVOS.stream().mapToLong(PtProfitSaveReqVO::getPtAdd).sum();
-        Long grossAdd = ptProfitSaveReqVOS.stream().mapToLong(PtProfitSaveReqVO::getPtGrossAdd).sum();
-        ptProfit.setPtAdd(ptProfit.getPtAdd() + add);
-        ptProfit.setPtTotalAdd(ptProfit.getPtTotalAdd() + total);
-        ptProfit.setPtGrossAdd(ptProfit.getPtGrossAdd() + grossAdd);
-        PtProfitSaveReqVO ptProfitSaveReqVO = PtProfitSaveReqVO.builder()
-                .id(ptProfitDO.getId())
-                .ptTotalAdd(ptProfit.getPtTotalAdd())
-                .ptAdd(ptProfit.getPtAdd())
-                .ptGrossAdd(ptProfit.getPtGrossAdd()).build();
-        ptProfitService.updatePtProfit(ptProfitSaveReqVO);
-
     }
 
     /**
@@ -516,15 +589,15 @@ public class OrderCalcServiceImpl implements OrderCalcService {
     /**
      * 修改用户钱包
      *
-     * @param integralSaveReqVOS
-     * @param integralDO
-     * @param integralDOAncestor
-     * @param pt
-     * @param ancestorQuota
-     * @param descendantQuota
-     * @param highQuota
-     * @param ptA
-     * @param ptB
+     * @param integralSaveReqVOS
+     * @param integralDO 当前用户钱包
+     * @param integralDOAncestor 推荐人钱包
+     * @param pt pt钱包
+     * @param ancestorQuota 推荐人额度
+     * @param descendantQuota 直推人额度
+     * @param highQuota 最大可用额度
+     * @param ptA pt收益
+     * @param ptB pt服务费
      */
     private void changeUserWallet(List<IntegralSaveReqVO> integralSaveReqVOS, IntegralDO integralDO, IntegralDO integralDOAncestor, IntegralDO pt,
                                   Long ancestorQuota, Long descendantQuota, Long highQuota, Long ptA, Long ptB) {

+ 22 - 7
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/partitioncrash/PartitionCrashServiceImpl.java

@@ -15,6 +15,7 @@ import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitdailystatisticslog
 import cn.newfeifan.mall.module.distri.dal.mysql.ptprofit.PtProfitMapper;
 import cn.newfeifan.mall.module.distri.dal.mysql.ptprofitdailystatisticslog.PtProfitDailyStatisticsLogMapper;
 import cn.newfeifan.mall.module.distri.enums.CaclEnum;
+import cn.newfeifan.mall.module.distri.service.dailyawardrecords.DailyAwardRecordsService;
 import cn.newfeifan.mall.module.distri.service.duser.DuserService;
 import cn.newfeifan.mall.module.distri.service.integral.IntegralService;
 import cn.newfeifan.mall.module.distri.service.orderpercentage.OrderPercentageService;
@@ -96,6 +97,9 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
     @Resource
     private PtProfitMapper ptProfitMapper;
 
+    @Resource
+    private DailyAwardRecordsService dailyAwardRecordsService;
+
 
     @Override
     public Long createPartitionCrash(PartitionCrashSaveReqVO createReqVO) {
@@ -172,6 +176,7 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
         List<PartitionCrashSaveReqVO> partitionCrashSaveReqVOS = new ArrayList<>();
 
         duserDOS.forEach(k -> {
+
             // 获取当前用户的钱包
             IntegralDO integralDO = integralDOMap.get(k.getUserId());
             // 获取当前父亲的钱包
@@ -286,15 +291,18 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
                         }
                         addHighQuota(userHighQuotaMap, integralDO.getUserId(), amount);
                     }
-                    integralDO.setCurrentQuota(integralDO.getCurrentQuota() + amount);
+                    integralDO.setFreezeQuota(integralDO.getFreezeQuota() + amount);
                     integralDO.setHighQuota(integralDO.getHighQuota() - amount);
 
 
                     integralDO.setAccumulatedQuota(integralDO.getAccumulatedQuota() + amount);
                     // 碰撞后的额度添加到日志中 增加日志模块
                     integralService.updateIntegral(BeanUtils.toBean(integralDO, IntegralSaveReqVO.class));
-                    ptProfitLogService.addMessage(k.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, amount,
-                            integralDO.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO), ptReplenish, -amount, highQuota - amount);
+                    Long logId = ptProfitLogService.addMessageFreeze(k.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, amount,
+                            integralDO.getFreezeQuota(), JsonUtils.toJsonString(orderPercentageDO), ptReplenish, -amount, highQuota - amount);
+
+                    //记录每日用户有合赢将的记录,后面用来结算的
+                    dailyAwardRecordsService.addDailyAwardRecords(integralDO.getUserId(),amount, logId);
                 }
 
                 //直推人的上级的本次添加积分
@@ -315,13 +323,16 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
                     }
                     // 减去最高额度
                     parentIntegralDo.setHighQuota(parentIntegralDo.getHighQuota() - parentAmount);
-                    parentIntegralDo.setCurrentQuota(parentIntegralDo.getCurrentQuota() + parentAmount);
+                    parentIntegralDo.setFreezeQuota(parentIntegralDo.getFreezeQuota() + parentAmount);
 
                     parentIntegralDo.setAccumulatedQuota(parentIntegralDo.getAccumulatedQuota() + parentAmount);
                     // 碰撞后的额度添加到日志中 增加日志模块
                     integralService.updateIntegral(BeanUtils.toBean(parentIntegralDo, IntegralSaveReqVO.class));
-                    ptProfitLogService.addMessage(parentIntegralDo.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, parentAmount,
-                            parentIntegralDo.getCurrentQuota(), JsonUtils.toJsonString(orderPercentageDO), parentPtReplenish, -parentAmount, parentHighQuota - parentAmount);
+                    Long logId = ptProfitLogService.addMessageFreeze(parentIntegralDo.getUserId(), CaclEnum.SMALL_QUOTA_CRASH, parentAmount,
+                            parentIntegralDo.getFreezeQuota(), JsonUtils.toJsonString(orderPercentageDO), parentPtReplenish, -parentAmount, parentHighQuota - parentAmount);
+
+                    //记录每日用户有合赢将的记录,后面用来结算的
+                    dailyAwardRecordsService.addDailyAwardRecords(parentIntegralDo.getUserId(),parentAmount,logId);
                 }
 
                 if (!ptReplenish.equals(0L)) {
@@ -362,6 +373,7 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
         // 计算平台积分
         // 获取当前平台的额度
         PtProfitDO ptProfit = ptProfitService.getPtProfit();
+        IntegralDO ptIntegralDO = integralService.selectByUser(PT_ID);
         // 遍历hashMap
         for (HashMap<Long, Long> longIntegerHashMap : afterCrashMap) {
             for (Map.Entry<Long, Long> entry : longIntegerHashMap.entrySet()) {
@@ -413,8 +425,9 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
 
 
                     // 扣除平台收益
-                    log.info("扣除平台收益[合赢奖] " + "用户 " + entry.getKey() + "额度: " + amount);
+                    log.info("扣除平台收益[合赢奖] " + "用户: " + entry.getKey() + "额度: " + amount);
                     ptProfit.setPtGrossAdd(ptProfit.getPtGrossAdd() - amount);
+                    ptIntegralDO.setCurrentQuota(ptIntegralDO.getCurrentQuota() - amount);
                     // 平台扣除积分
                     ptProfit.setPtTotalAdd(ptProfit.getPtTotalAdd() - amount);
                     // 碰撞后的额度添加到日志中 增加日志模块
@@ -425,6 +438,8 @@ public class PartitionCrashServiceImpl implements PartitionCrashService {
                 }
             }
         }
+
+        integralService.updateIntegral(BeanUtils.toBean(ptIntegralDO, IntegralSaveReqVO.class));
         ptProfitService.updatePtProfit(PtProfitSaveReqVO.builder().id(ptProfit.getId())
                 .ptAdd(ptProfit.getPtAdd())
                 .ptGrossAdd(ptProfit.getPtGrossAdd())

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

@@ -66,13 +66,14 @@ public interface PtProfitLogService {
      * @param accumulatedQuotAmount  合赢奖溢出
      */
     void addMessage(Long userId, CaclEnum caclEnum, Long amount, Long afterAmount, String jsonString,Long accumulatedQuotAmount, Long maxAvailablePointsAmount ,Long afterMaxAvailablePointsAmount);
+    Long addMessageFreeze(Long userId, CaclEnum caclEnum, Long amount, Long afterAmount, String jsonString,Long accumulatedQuotAmount, Long maxAvailablePointsAmount ,Long afterMaxAvailablePointsAmount);
     void addMessage(Long userId, CaclEnum caclEnum, Integer amount, Integer afterAmount);
 
     /**
      * 获取昨日的日志信息
      *
-     * @param sonsId
-     * @return
+     * @param sonsId 后代分区id
+     * @return 贡献值
      */
     String getYesterdayLog(List<Long> sonsId);
 

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

@@ -108,6 +108,28 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
         // todo 发送通知
         // todo 发短信
 
+    }
+    @Override
+    public Long addMessageFreeze(Long userId, CaclEnum caclEnum, Long amount, Long afterAmount, String percentTemplate,Long accumulatedQuotAmount, Long maxAvailablePointsAmount ,Long afterMaxAvailablePointsAmount) {
+        PtProfitLogSaveReqVO ptProfitLog = PtProfitLogSaveReqVO.builder()
+                .afterFreezeAmount(afterAmount)
+                .freezeAmount(amount)
+                .percentTemplate(percentTemplate)
+                .profitStatus(caclEnum.getType())
+                .accumulatedQuotaAmount(accumulatedQuotAmount)
+                .maxAvailablePointsAmount(maxAvailablePointsAmount)
+                .afterMaxAvailablePointsAmount(afterMaxAvailablePointsAmount)
+                .generateUserId(userId)
+                .build();
+        if(caclEnum.getType().equals(SMALL_QUOTA_CRASH.getType())){
+            ptProfitLog.setUserId(userId);
+        }
+        PtProfitLogDO bean = BeanUtils.toBean(ptProfitLog, PtProfitLogDO.class);
+                ptProfitLogMapper.insert(bean);
+        return bean.getId();
+        // todo 发送通知
+        // todo 发短信
+
     }
 
     @Override

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

@@ -110,20 +110,22 @@ public class SharePathServiceImpl implements SharePathService {
         duserService.hasUserAndCreat(createReqVO);
 
         // 存储他们之间的关系
-        sharePathMapper.addNode(
-                createReqVO.getAncestor(),
-                ancestor.getName(),
-                ancestor.getNickname(),
-                ancestor.getMobile(),
-
-                createReqVO.getDescendant(),
-                descendant.getName(),
-                descendant.getNickname(),
-                descendant.getMobile());
+        if (!Objects.equals(createReqVO.getDescendant(), PT_ID)) {
+            sharePathMapper.addNode(
+                    createReqVO.getAncestor(),
+                    ancestor.getName(),
+                    ancestor.getNickname(),
+                    ancestor.getMobile(),
+
+                    createReqVO.getDescendant(),
+                    descendant.getName(),
+                    descendant.getNickname(),
+                    descendant.getMobile());
+        }
 
         OrderPercentageDO orderPercentageDO = orderPercentageMapper.selectList().get(0);
         duserService.updateDuserSocial(createReqVO.getAncestor(), Long.valueOf(orderPercentageDO.getRegisterAncestorSocialStatus()), SocialStatusEnum.REGISTER_ANCESTOR_SOCIAL.getStatus());
-        socialStatusChangeLogService.createSocialStatusChangeLog(createReqVO.getAncestor(), Long.valueOf(orderPercentageDO.getRegisterAncestorSocialStatus()),createReqVO.getAncestor(), SocialStatusEnum.REGISTER_ANCESTOR_SOCIAL);
+        socialStatusChangeLogService.createSocialStatusChangeLog(createReqVO.getAncestor(), Long.valueOf(orderPercentageDO.getRegisterAncestorSocialStatus()), createReqVO.getAncestor(), SocialStatusEnum.REGISTER_ANCESTOR_SOCIAL);
 
     }
 
@@ -148,7 +150,7 @@ public class SharePathServiceImpl implements SharePathService {
         List<SharePathDO> sharePathDO = sharePathMapper.selectList(new LambdaQueryWrapperX<SharePathDO>()
                 .eqIfPresent(SharePathDO::getDescendant, descendant)
                 .eqIfPresent(SharePathDO::getDepth, 1));
-        return sharePathDO != null;
+        return !sharePathDO.isEmpty();
     }
 
     @Override
@@ -250,7 +252,7 @@ public class SharePathServiceImpl implements SharePathService {
         if (integral != null) memberUserRespVO.setCurrentQuota(integral.getCurrentQuota());
 
         SocialStatusDO socialStatus = socialStatusService.getSocialStatus(duser.getSocialStatusId());
-        if(socialStatus == null) return memberUserRespVO;
+        if (socialStatus == null) return memberUserRespVO;
         memberUserRespVO.setCurrentMemberWorthLevelName(socialStatus.getName());
         memberUserRespVO.setCurrentMemberWorthLevel(socialStatus.getLevel());
 

+ 12 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/dailyawardrecords/DailyAwardRecordsMapper.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.newfeifan.mall.module.distri.dal.mysql.dailyawardrecords.DailyAwardRecordsMapper">
+
+    <!--
+        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
+        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
+        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
+        文档可见:https://www.zhongxing.cn/MyBatis/x-plugins/
+     -->
+
+</mapper>

+ 12 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/dailybill/DailyBillMapper.xml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.newfeifan.mall.module.distri.dal.mysql.dailybill.DailyBillMapper">
+
+    <!--
+        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
+        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
+        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
+        文档可见:https://www.zhongxing.cn/MyBatis/x-plugins/
+     -->
+
+</mapper>

+ 6 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/ordercalc/OrderCalcMapper.xml

@@ -14,4 +14,10 @@
         set distribute_benefit = 1
         where id = #{orderItemId}
     </update>
+
+    <update id="updateOrderItemTransitionTime">
+        update trade_order_item
+        set transition_time = now()
+        where id = #{orderItemId}
+    </update>
 </mapper>

+ 0 - 131
feifan-module-distri/feifan-module-distri-biz/src/test/java/cn/newfeifan/mall/module/distri/service/usersigninlog/UserSignInLogServiceImplTest.java

@@ -1,131 +0,0 @@
-package cn.newfeifan.mall.module.distri.service.usersigninlog;
-
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-import javax.annotation.Resource;
-
-import cn.newfeifan.mall.framework.test.core.ut.BaseDbUnitTest;
-
-import cn.newfeifan.mall.module.distri.controller.admin.usersigninlog.vo.*;
-import cn.newfeifan.mall.module.distri.dal.dataobject.usersigninlog.UserSignInLogDO;
-import cn.newfeifan.mall.module.distri.dal.mysql.usersigninlog.UserSignInLogMapper;
-import cn.newfeifan.mall.framework.common.pojo.PageResult;
-
-import org.springframework.context.annotation.Import;
-
-import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*;
-import static cn.newfeifan.mall.framework.test.core.util.AssertUtils.*;
-import static cn.newfeifan.mall.framework.test.core.util.RandomUtils.*;
-import static cn.newfeifan.mall.framework.common.util.date.LocalDateTimeUtils.*;
-import static cn.newfeifan.mall.framework.common.util.object.ObjectUtils.*;
-import static org.junit.jupiter.api.Assertions.*;
-
-/**
- * {@link UserSignInLogServiceImpl} 的单元测试类
- *
- * @author 非繁人
- */
-@Import(UserSignInLogServiceImpl.class)
-public class UserSignInLogServiceImplTest extends BaseDbUnitTest {
-
-    @Resource
-    private UserSignInLogServiceImpl userSignInLogService;
-
-    @Resource
-    private UserSignInLogMapper userSignInLogMapper;
-
-    @Test
-    public void testCreateUserSignInLog_success() {
-        // 准备参数
-        UserSignInLogSaveReqVO createReqVO = randomPojo(UserSignInLogSaveReqVO.class).setId(null);
-
-        // 调用
-        Long userSignInLogId = userSignInLogService.createUserSignInLog(createReqVO);
-        // 断言
-        assertNotNull(userSignInLogId);
-        // 校验记录的属性是否正确
-        UserSignInLogDO userSignInLog = userSignInLogMapper.selectById(userSignInLogId);
-        assertPojoEquals(createReqVO, userSignInLog, "id");
-    }
-
-    @Test
-    public void testUpdateUserSignInLog_success() {
-        // mock 数据
-        UserSignInLogDO dbUserSignInLog = randomPojo(UserSignInLogDO.class);
-        userSignInLogMapper.insert(dbUserSignInLog);// @Sql: 先插入出一条存在的数据
-        // 准备参数
-        UserSignInLogSaveReqVO updateReqVO = randomPojo(UserSignInLogSaveReqVO.class, o -> {
-            o.setId(dbUserSignInLog.getId()); // 设置更新的 ID
-        });
-
-        // 调用
-        userSignInLogService.updateUserSignInLog(updateReqVO);
-        // 校验是否更新正确
-        UserSignInLogDO userSignInLog = userSignInLogMapper.selectById(updateReqVO.getId()); // 获取最新的
-        assertPojoEquals(updateReqVO, userSignInLog);
-    }
-
-    @Test
-    public void testUpdateUserSignInLog_notExists() {
-        // 准备参数
-        UserSignInLogSaveReqVO updateReqVO = randomPojo(UserSignInLogSaveReqVO.class);
-
-        // 调用, 并断言异常
-        assertServiceException(() -> userSignInLogService.updateUserSignInLog(updateReqVO), USER_SIGN_IN_LOG_NOT_EXISTS);
-    }
-
-    @Test
-    public void testDeleteUserSignInLog_success() {
-        // mock 数据
-        UserSignInLogDO dbUserSignInLog = randomPojo(UserSignInLogDO.class);
-        userSignInLogMapper.insert(dbUserSignInLog);// @Sql: 先插入出一条存在的数据
-        // 准备参数
-        Long id = dbUserSignInLog.getId();
-
-        // 调用
-        userSignInLogService.deleteUserSignInLog(id);
-       // 校验数据不存在了
-       assertNull(userSignInLogMapper.selectById(id));
-    }
-
-    @Test
-    public void testDeleteUserSignInLog_notExists() {
-        // 准备参数
-        Long id = randomLongId();
-
-        // 调用, 并断言异常
-        assertServiceException(() -> userSignInLogService.deleteUserSignInLog(id), USER_SIGN_IN_LOG_NOT_EXISTS);
-    }
-
-    @Test
-    @Disabled  // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
-    public void testGetUserSignInLogPage() {
-       // mock 数据
-       UserSignInLogDO dbUserSignInLog = randomPojo(UserSignInLogDO.class, o -> { // 等会查询到
-           o.setUserId(null);
-           o.setRunningDays(null);
-           o.setCreateTime(null);
-       });
-       userSignInLogMapper.insert(dbUserSignInLog);
-       // 测试 userId 不匹配
-       userSignInLogMapper.insert(cloneIgnoreId(dbUserSignInLog, o -> o.setUserId(null)));
-       // 测试 runningDays 不匹配
-       userSignInLogMapper.insert(cloneIgnoreId(dbUserSignInLog, o -> o.setRunningDays(null)));
-       // 测试 createTime 不匹配
-       userSignInLogMapper.insert(cloneIgnoreId(dbUserSignInLog, o -> o.setCreateTime(null)));
-       // 准备参数
-       UserSignInLogPageReqVO reqVO = new UserSignInLogPageReqVO();
-       reqVO.setUserId(null);
-       reqVO.setRunningDays(null);
-       reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
-
-       // 调用
-       PageResult<UserSignInLogDO> pageResult = userSignInLogService.getUserSignInLogPage(reqVO);
-       // 断言
-       assertEquals(1, pageResult.getTotal());
-       assertEquals(1, pageResult.getList().size());
-       assertPojoEquals(dbUserSignInLog, pageResult.getList().get(0));
-    }
-
-}

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

@@ -100,5 +100,4 @@ public interface ErrorCodeConstants {
     ErrorCode ORDER_CALLBACK_LOGS_NOT_EXISTS = new ErrorCode(1_011_008_007, "回调日志不存在");
     ErrorCode CREATE_TRADE_ORDER_LOGS_ERROR = new ErrorCode(1_011_008_008, "创建第三方日志异常");
     ErrorCode MESSAGE_LOG_NOT_EXISTS = new ErrorCode(1_011_008_009, "微信模板消息日志不存在");
-
 }

+ 9 - 36
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/TradeOrderController.java

@@ -7,7 +7,6 @@ import cn.newfeifan.mall.framework.common.pojo.PageResult;
 import cn.newfeifan.mall.module.distri.mq.message.order.CalcMessage;
 import cn.newfeifan.mall.module.distri.mq.message.order.DistriOrderMessage;
 import cn.newfeifan.mall.module.distri.mq.message.order.OrderCalcMessage;
-import cn.newfeifan.mall.module.distri.mq.message.order.OrderItemMessage;
 import cn.newfeifan.mall.module.member.api.user.MemberUserApi;
 import cn.newfeifan.mall.module.member.api.user.dto.MemberUserRespDTO;
 import cn.newfeifan.mall.module.pay.controller.admin.order.vo.PayOrderPageItemRespVO;
@@ -50,7 +49,6 @@ import javax.validation.Valid;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
-import java.util.stream.Collectors;
 
 import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.newfeifan.mall.framework.common.pojo.CommonResult.success;
@@ -321,41 +319,16 @@ public class TradeOrderController {
 
     @GetMapping("/startCalc")
     @Operation(summary = "计算启动")
-    public CommonResult<String> startCalc(@RequestParam("orderIds") List<Long> orderIds) {
+    public CommonResult<String> startCalc() {
+        //发货七天前订单
         List<DistriOrderMessage> appTradeOrderDetailRespVos = tradeOrderQueryService.queryAllOrder();
-//        List<DistriOrderMessage> appTradeOrderDetailRespVos = tradeOrderQueryService.queryAllOrder(orderIds);
-
-
-        Map<Long, List<OrderItemMessage>> orderItemMessageGroupBy = appTradeOrderDetailRespVos.stream()
-                .map(k -> OrderItemMessage.builder().price(k.getPrice())
-                        .productCount(k.getProductCount())
-                        .costPrice(k.getCostPrice())
-                        .orderId(k.getOrderId())
-                        .count(k.getCount())
-                        .orderItemId(k.getOrderItemId())
-                        .increaseIntegral(k.getIncreaseIntegral())
-                        .ancestorIncreaseIntegral(k.getAncestorIncreaseIntegral())
-                        .totalPrice(k.getTotalPrice()).build())
-                .collect(Collectors.groupingBy(OrderItemMessage::getOrderId));
-
-
-        List<OrderCalcMessage> orderCalcMessages = appTradeOrderDetailRespVos.stream().distinct().map(k -> {
-            OrderCalcMessage orderCalcMessage = OrderCalcMessage.builder()
-                    .orderId(k.getOrderId())
-                    .name(k.getName())
-                    .nickName(k.getNickName())
-                    .no(k.getNo())
-                    .merchantId(k.getMerchantId())
-                    .productCount(k.getProductCount())
-                    .shopId(k.getShopId())
-                    .userId(k.getUserId()).build();
-            List<OrderItemMessage> orderItemMessages = orderItemMessageGroupBy.get(k.getOrderId());
-            orderCalcMessage.setOrderItemMessages(orderItemMessages);
-            return orderCalcMessage;
-        }).collect(Collectors.toList());
-
-
-        CalcMessage calcMessage = CalcMessage.builder().orderCalcMessages(orderCalcMessages).distriOrderMessages(appTradeOrderDetailRespVos).build();
+        List<OrderCalcMessage> orderCalcMessages = tradeOrderQueryService.getOrderCalcMessage(appTradeOrderDetailRespVos);
+
+        //每日订单
+        List<DistriOrderMessage> appTradeOrderDetailRespVos2 = tradeOrderQueryService.queryDailyOrder();
+        List<OrderCalcMessage> orderCalcMessages2 = tradeOrderQueryService.getOrderCalcMessage(appTradeOrderDetailRespVos2);
+
+        CalcMessage calcMessage = CalcMessage.builder().orderCalcMessages(orderCalcMessages).bonusQuotaOrderDO(orderCalcMessages2).distriOrderMessages(appTradeOrderDetailRespVos).build();
         distriOrderProducer.sendDistriOrderMessage(calcMessage);
 
         return success("success");

+ 6 - 1
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/dal/mysql/order/TradeOrderMapper.java

@@ -7,7 +7,6 @@ import cn.newfeifan.mall.framework.mybatis.core.query.MPJLambdaWrapperX;
 import cn.newfeifan.mall.module.distri.mq.message.order.DistriOrderMessage;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
 import cn.newfeifan.mall.module.trade.controller.app.order.vo.AppTradeOrderPageReqVO;
-import cn.newfeifan.mall.module.trade.dal.dataobject.aftersale.AfterSaleDO;
 import cn.newfeifan.mall.module.trade.dal.dataobject.order.TradeOrderDO;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import org.apache.ibatis.annotations.Mapper;
@@ -167,5 +166,11 @@ public interface TradeOrderMapper extends BaseMapperX<TradeOrderDO> {
 
     List<DistriOrderMessage> queryAllOrder(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end);
 
+    /**
+     * 获取每天的订单(也包括之前没有的参与结算的)
+     * @return 订单
+     */
+    List<DistriOrderMessage> queryDailyOrder();
+
     List<DistriOrderMessage> queryAllOrderByOrderIds(@Param("orderIds") List<Long> orderIds);
 }

+ 6 - 31
feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/job/order/TradeOrderAutoCalcJob.java

@@ -5,7 +5,6 @@ import cn.newfeifan.mall.framework.tenant.core.job.TenantJob;
 import cn.newfeifan.mall.module.distri.mq.message.order.CalcMessage;
 import cn.newfeifan.mall.module.distri.mq.message.order.DistriOrderMessage;
 import cn.newfeifan.mall.module.distri.mq.message.order.OrderCalcMessage;
-import cn.newfeifan.mall.module.distri.mq.message.order.OrderItemMessage;
 import cn.newfeifan.mall.module.trade.mq.producer.order.DistriOrderProducer;
 import cn.newfeifan.mall.module.trade.service.order.TradeOrderQueryService;
 import org.quartz.DisallowConcurrentExecution;
@@ -14,8 +13,6 @@ import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
 import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * 交易订单自动计算 Job
@@ -36,37 +33,15 @@ public class TradeOrderAutoCalcJob implements JobHandler {
     @Override
     @TenantJob
     public String execute(String param) {
+        //发货七天前订单
         List<DistriOrderMessage> appTradeOrderDetailRespVos = tradeOrderQueryService.queryAllOrder();
+        List<OrderCalcMessage> orderCalcMessages = tradeOrderQueryService.getOrderCalcMessage(appTradeOrderDetailRespVos);
 
-        Map<Long, List<OrderItemMessage>> orderItemMessageGroupBy = appTradeOrderDetailRespVos.stream()
-                .map(k -> OrderItemMessage.builder().price(k.getPrice())
-                        .productCount(k.getProductCount())
-                        .costPrice(k.getCostPrice())
-                        .orderId(k.getOrderId())
-                        .count(k.getCount())
-                        .orderItemId(k.getOrderItemId())
-                        .increaseIntegral(k.getIncreaseIntegral())
-                        .ancestorIncreaseIntegral(k.getAncestorIncreaseIntegral())
-                        .totalPrice(k.getTotalPrice()).build())
-                .collect(Collectors.groupingBy(OrderItemMessage::getOrderId));
+        //每日订单
+        List<DistriOrderMessage> appTradeOrderDetailRespVos2 = tradeOrderQueryService.queryDailyOrder();
+        List<OrderCalcMessage> orderCalcMessages2 = tradeOrderQueryService.getOrderCalcMessage(appTradeOrderDetailRespVos2);
 
-        List<OrderCalcMessage> orderCalcMessages = appTradeOrderDetailRespVos.stream().distinct().map(k -> {
-            OrderCalcMessage orderCalcMessage = OrderCalcMessage.builder()
-                    .orderId(k.getOrderId())
-                    .name(k.getName())
-                    .nickName(k.getNickName())
-                    .no(k.getNo())
-                    .merchantId(k.getMerchantId())
-                    .productCount(k.getProductCount())
-                    .shopId(k.getShopId())
-                    .userId(k.getUserId()).build();
-            List<OrderItemMessage> orderItemMessages = orderItemMessageGroupBy.get(k.getOrderId());
-            orderCalcMessage.setOrderItemMessages(orderItemMessages);
-            return orderCalcMessage;
-        }).collect(Collectors.toList());
-
-
-        CalcMessage calcMessage = CalcMessage.builder().orderCalcMessages(orderCalcMessages).distriOrderMessages(appTradeOrderDetailRespVos).build();
+        CalcMessage calcMessage = CalcMessage.builder().orderCalcMessages(orderCalcMessages).bonusQuotaOrderDO(orderCalcMessages2).distriOrderMessages(appTradeOrderDetailRespVos).build();
         distriOrderProducer.sendDistriOrderMessage(calcMessage);
         return "计算订单信息结束";
 

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

@@ -2,6 +2,7 @@ package cn.newfeifan.mall.module.trade.service.order;
 
 import cn.newfeifan.mall.framework.common.pojo.PageResult;
 import cn.newfeifan.mall.module.distri.mq.message.order.DistriOrderMessage;
+import cn.newfeifan.mall.module.distri.mq.message.order.OrderCalcMessage;
 import cn.newfeifan.mall.module.pay.controller.admin.order.vo.PayOrderPageItemRespVO;
 import cn.newfeifan.mall.module.trade.controller.admin.delivery.vo.expresstemplate.ShopBO;
 import cn.newfeifan.mall.module.trade.controller.admin.order.vo.TradeOrderPageReqVO;
@@ -211,6 +212,12 @@ public interface TradeOrderQueryService {
      */
     List<DistriOrderMessage> queryAllOrder();
 
+    /**
+     * 查询当天系统的所有订单
+     * @return 集合
+     */
+    List<DistriOrderMessage> queryDailyOrder();
+
     List<DistriOrderMessage> queryAllOrder(List<Long> orderIds);
 
     /**
@@ -227,4 +234,6 @@ public interface TradeOrderQueryService {
      * @return 0 是虚拟商品
      */
     Integer getSpuType(List<TradeOrderItemDO> orderItems);
+
+    List<OrderCalcMessage> getOrderCalcMessage(List<DistriOrderMessage> respVos);
 }

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

@@ -7,6 +7,8 @@ import cn.hutool.core.util.StrUtil;
 import cn.hutool.extra.spring.SpringUtil;
 import cn.newfeifan.mall.framework.common.pojo.PageResult;
 import cn.newfeifan.mall.module.distri.mq.message.order.DistriOrderMessage;
+import cn.newfeifan.mall.module.distri.mq.message.order.OrderCalcMessage;
+import cn.newfeifan.mall.module.distri.mq.message.order.OrderItemMessage;
 import cn.newfeifan.mall.module.member.api.user.MemberUserApi;
 import cn.newfeifan.mall.module.member.api.user.dto.MemberUserRespDTO;
 import cn.newfeifan.mall.module.pay.controller.admin.order.vo.PayOrderPageItemRespVO;
@@ -266,6 +268,10 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
 
     }
 
+    public List<DistriOrderMessage> queryDailyOrder(){
+        return tradeOrderMapper.queryDailyOrder();
+    }
+
     @Override
     public List<DistriOrderMessage> queryAllOrder(List<Long> orderIds) {
         // 根据orderIds获取订单
@@ -297,6 +303,36 @@ public class TradeOrderQueryServiceImpl implements TradeOrderQueryService {
         return null;
     }
 
+    @Override
+    public List<OrderCalcMessage> getOrderCalcMessage(List<DistriOrderMessage> respVos) {
+        Map<Long, List<OrderItemMessage>> orderItemMessageGroupBy = respVos.stream()
+                .map(k -> OrderItemMessage.builder().price(k.getPrice())
+                        .productCount(k.getProductCount())
+                        .costPrice(k.getCostPrice())
+                        .orderId(k.getOrderId())
+                        .count(k.getCount())
+                        .orderItemId(k.getOrderItemId())
+                        .increaseIntegral(k.getIncreaseIntegral())
+                        .ancestorIncreaseIntegral(k.getAncestorIncreaseIntegral())
+                        .totalPrice(k.getTotalPrice()).build())
+                .collect(Collectors.groupingBy(OrderItemMessage::getOrderId));
+
+        return respVos.stream().distinct().map(k -> {
+            OrderCalcMessage orderCalcMessage = OrderCalcMessage.builder()
+                    .orderId(k.getOrderId())
+                    .name(k.getName())
+                    .nickName(k.getNickName())
+                    .no(k.getNo())
+                    .merchantId(k.getMerchantId())
+                    .productCount(k.getProductCount())
+                    .shopId(k.getShopId())
+                    .userId(k.getUserId()).build();
+            List<OrderItemMessage> orderItemMessages = orderItemMessageGroupBy.get(k.getOrderId());
+            orderCalcMessage.setOrderItemMessages(orderItemMessages);
+            return orderCalcMessage;
+        }).collect(Collectors.toList());
+    }
+
     public static ShopBO getShopBO(StringRedisTemplate stringRedisTemplate, AdminUserMapper userMapper, Logger log) {
         Long loginUserId = getLoginUserId();
         String s = stringRedisTemplate.opsForValue().get("shop:" + loginUserId);

+ 32 - 1
feifan-module-mall/feifan-module-trade-biz/src/main/resources/mapper/order/BrokerageUserMapper.xml

@@ -45,8 +45,39 @@
         where tor.pay_status = 1
         and toi.distribute_benefit = 0
         and (toi.after_sale_status = 0 or toi.after_sale_status = 61)
-        and tor.receiving_time &lt; DATE_SUB(NOW(), INTERVAL 7 DAY)
+        and tor.delivery_time &lt; DATE_SUB(NOW(), INTERVAL 7 DAY)
+--           and tor.receiving_time &lt; DATE_SUB(NOW(), INTERVAL 7 DAY)
     </select>
+
+    <select id="queryDailyOrder" resultMap="BaseResultMap">
+        select tor.total_price as totalPrice,
+               ps.cost_price as costPrice,
+               ps.price as price,
+               tor.product_count as productCount,
+               tor.`no` as `no`,
+               tor.id as orderId,
+               tor.user_id as userId,
+               ps.merchant_id as merchantId,
+               ps.shop_id as shopId,
+               mu.`name` as name,
+               mu.nickname as nickname,
+               toi.count as `count`,
+               toi.id as orderItemId,
+               toi.increase_integral AS increaseIntegral,
+               toi.ancestor_increase_integral AS ancestorIncreaseIntegral
+        from trade_order tor
+                 LEFT JOIN member_user mu
+                           ON tor.user_id = mu.id
+                 LEFT JOIN trade_order_item toi
+                           on tor.id = toi.order_id
+                 LEFT JOIN product_sku ps
+                           on toi.sku_id = ps.id
+        where tor.pay_status = 1
+          and (toi.after_sale_status = 0 or toi.after_sale_status = 61)
+          and toi.transition_time is null
+          and DATE(tor.create_time) &lt; CURDATE()
+    </select>
+
     <select id="queryAllOrderByOrderIds"
             resultMap="BaseResultMap">
         select tor.total_price as totalPrice,

+ 19 - 2
sql/mysql/建空库SQL/13_20240617.sql

@@ -1,4 +1,4 @@
-CREATE TABLE `trade_daily_bill` (
+CREATE TABLE `distri_daily_bill` (
                                     `id` bigint NOT NULL AUTO_INCREMENT COMMENT '账单编号',
                                     `amount` int NOT NULL DEFAULT '0' COMMENT '金额,单位:分',
                                     `received_amount` int NOT NULL DEFAULT '0' COMMENT '确收金额,单位:分',
@@ -12,4 +12,21 @@ CREATE TABLE `trade_daily_bill` (
                                     `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                     `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                     PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='每日账单表';      --添加每日账单表
+) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='每日账单表';      --添加每日账单表
+
+CREATE TABLE `distri_daily_award_records` (
+                                              `id` bigint NOT NULL AUTO_INCREMENT COMMENT '奖励记录ID',
+                                              `user_id` bigint unsigned NOT NULL COMMENT '用户编号',
+                                              `amount` bigint NOT NULL COMMENT '合赢奖金额,必填',
+                                              `settled` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已结算,默认为未结算',
+                                              `log_id` bigint NOT NULL COMMENT '日志Id',
+                                              `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '创建者',
+                                              `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+                                              `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '更新者',
+                                              `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+                                              `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
+                                              PRIMARY KEY (`id`) USING BTREE
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='每日用户获得合赢奖记录';
+
+ALTER TABLE trade_order_item
+    ADD COLUMN transition_time datetime DEFAULT NULL COMMENT '订单项金额转换冻结的时间(合赢奖)';