Browse Source

修改计算程序

Yangzw 9 months ago
parent
commit
ec7f66dff9
16 changed files with 453 additions and 34 deletions
  1. 20 22
      feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/CaclEnum.java
  2. 1 0
      feifan-module-distri/feifan-module-distri-api/src/main/java/cn/newfeifan/mall/module/distri/enums/ErrorCodeConstants.java
  3. 3 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlog/vo/PtProfitLogSaveReqVO.java
  4. 94 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/PtProfitLogDetailsController.java
  5. 27 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/vo/PtProfitLogDetailsPageReqVO.java
  6. 29 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/vo/PtProfitLogDetailsRespVO.java
  7. 25 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/vo/PtProfitLogDetailsSaveReqVO.java
  8. 36 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/ptprofitlogdetails/PtProfitLogDetailsDO.java
  9. 8 3
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ptprofitlog/PtProfitLogMapper.java
  10. 27 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/mysql/ptprofitlogdetails/PtProfitLogDetailsMapper.java
  11. 28 6
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ordercalc/OrderCalcServiceImpl.java
  12. 5 1
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlog/PtProfitLogServiceImpl.java
  13. 59 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlogdetails/PtProfitLogDetailsService.java
  14. 77 0
      feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlogdetails/PtProfitLogDetailsServiceImpl.java
  15. 12 0
      feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/ptprofitlogdetails/PtProfitLogDetailsMapper.xml
  16. 2 2
      feifan-module-mall/feifan-module-trade-biz/src/main/java/cn/newfeifan/mall/module/trade/controller/admin/order/TradeOrderController.java

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

@@ -6,28 +6,26 @@ import lombok.Getter;
 @Getter
 @AllArgsConstructor
 public enum CaclEnum {
-    PLATFORM_TOTAL_ADD(0, "平台总收益", "平台总收益"),
-    PLATFORM_SERVICE_FEE(1, "平台服务费", "平台服务费"),
-    PLATFORM_REVENUE(2, "平台收益", "平台收益"),
-    RECOMMENDED_PERSON_QUOTA(3, "直推奖获得", "直推奖额度"),
-    DIRECT_REFERRAL_QUOTA(4, "购物获得", "用户自得额度"),
-    TOGETHER_AWARD(5, "合赢奖", "合赢奖"),
-    HIGH_QUOTA(6, "最高可以获得积分", "最高可以获得积分"),
-    SMALL_QUOTA_CRASH(7, "合赢奖获得", "小区额度分配"),
-    AFTER_CRASH_CALC_PT_TOTAL_QUOTA(8, "碰撞后计算平台总收益", "碰撞后计算平台总收益"),
-    ORDER_PAY_INTEGRAL(9, "购物使用积分进行支付", "购物使用积分进行支付"),      //购物使用积分进行支付
-    ORDER_REFUND_INTEGRAL(10, "退回退款订单项,消费者支付的积分", "退回退款订单项,购物者支付的积分"),
-    ORDER_INTEGRAL_UNFREEZE(11, "订单积分到账", "订单积分到账"),
-    AFTER_CRASH_CALC_PT_TOTAL_GROSS_QUOTA(12, "碰撞后计算平台收益", "碰撞后计算平台收益"),
-    FREEZE_CHANGE_INTEGRAL(13, "冻结积分转化成可用积分", "冻结积分变为可用积分"),
-    GROSS_PROFIT_BONUS_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT(14, "合赢奖超额", "合赢奖的获取超出最高可获取"),
-    GROSS_PROFIT_ANCESTOR_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT(15, "直推奖超额", "直推奖的获取超出最高可获取"),
-    ORDER_CANCEL_BY_USER_REFUND_INTEGRAL(16,"取消订单,退回积分","取消订单,退回积分"),
-    ORDER_CANCEL_BY_SYSTEM_REFUND_INTEGRAL(17,"订单超时未支付,退回积分","订单超时未支付,退回积分"),
-    ORDER_PAY_INTEGRAL_ANCESTER(18, "直推人购物,推荐人获得冻结积分","直推人购物,推荐人获得冻结积分(购物上级直推人获得积分)"),
-    ORDER_REFUND_INTEGRAL_CONSUMER(19,"订单退款,收回消费者获得的冻结积分","订单退款,收回消费者获得的冻结积分"),
-    ORDER_REFUND_INTEGRAL_ANCESTER(20,"订单退款,收回消费者的推荐人,获得的冻结积分","订单退款,收回消费者的推荐人,获得的冻结积分"),
-    ORDER_PAY_INTEGRAL_CONSUMER(21, "消费者购物,获得冻结积分","消费者购物,获得冻结积分"),//购物者本人 获得积分
+    PLATFORM_TOTAL_ADD(0, "平台总收益","平台总收益"),
+    PLATFORM_SERVICE_FEE(1, "平台服务费","平台服务费"),
+    PLATFORM_REVENUE(2, "平台收益","平台收益"),
+    RECOMMENDED_PERSON_QUOTA(3, "直推奖获得","直推奖获得"),           //直推奖获得可用积分
+    DIRECT_REFERRAL_QUOTA(4, "购物获得","购物获得可用积分"),       //购物用户自得额度
+    TOGETHER_AWARD(5, "合赢奖","合赢奖"),
+    HIGH_QUOTA(6, "最高可以获得积分","最高可以获得积分"),
+    SMALL_QUOTA_CRASH(7, "合赢奖获得","小区额度分配"),
+    AFTER_CRASH_CALC_PT_TOTAL_QUOTA(8, "碰撞后计算平台总收益","碰撞后计算平台总收益"),
+    ORDER_PAY_INTEGRAL(9, "购物支付","购物使用积分进行支付"),      //购物使用积分进行支付
+    ORDER_REFUND_INTEGRAL(10, "退回退款返回","退回退款订单项,消费者支付的积分"),
+    AFTER_CRASH_CALC_PT_TOTAL_GROSS_QUOTA(12, "碰撞后计算平台收益","碰撞后计算平台收益"),
+    GROSS_PROFIT_BONUS_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT(14, "合赢奖超额","合赢奖超额"),
+    GROSS_PROFIT_ANCESTOR_QUOTA_PERC_EXCEED_MAXIMUM_LIMIT(15, "直推奖超额","直推奖超额"),
+    ORDER_CANCEL_BY_USER_REFUND_INTEGRAL(16,"手动取消支付返回","取消订单,退回积分"),
+    ORDER_CANCEL_BY_SYSTEM_REFUND_INTEGRAL(17,"支付超时返回","订单超时未支付,退回积分"),
+    ORDER_PAY_INTEGRAL_ANCESTER(18, "直推奖获得","直推人购物,推荐人获得冻结积分"),//购物 上级直推人 获得积分
+    ORDER_REFUND_INTEGRAL_CONSUMER(19,"订单退款","订单退款,收回消费者获得的冻结积分"),
+    ORDER_REFUND_INTEGRAL_ANCESTER(20,"订单退款","订单退款,收回消费者的推荐人,获得的冻结积分"),
+    ORDER_PAY_INTEGRAL_CONSUMER(21, "购物获得","消费者购物,获得冻结积分"),//购物者本人 获得积分
     ;
 
     /**

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

@@ -28,5 +28,6 @@ public interface ErrorCodeConstants {
     ErrorCode SOCIAL_STATUS_CHANGE_LOG_NOT_EXISTS = new ErrorCode(1_002_030_021, "查询日志记录不存在");
     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, "平台利润记录详情不存在");
 
 }

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

@@ -53,4 +53,7 @@ public class PtProfitLogSaveReqVO {
     @Schema(description = "直推奖超出额度")
     private Long ancestorQuotaAmount;
 
+    @Schema(description = "产生积分的用户ID,例如:下订单的用户ID", example = "31502")
+    private Long generateUserId;
+
 }

+ 94 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/PtProfitLogDetailsController.java

@@ -0,0 +1,94 @@
+package cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails;
+
+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.ptprofitlogdetails.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlogdetails.PtProfitLogDetailsDO;
+import cn.newfeifan.mall.module.distri.service.ptprofitlogdetails.PtProfitLogDetailsService;
+
+@Tag(name = "管理后台 - 平台利润记录详情")
+@RestController
+@RequestMapping("/distri/pt-profit-log-details")
+@Validated
+public class PtProfitLogDetailsController {
+
+    @Resource
+    private PtProfitLogDetailsService ptProfitLogDetailsService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建平台利润记录详情")
+    @PreAuthorize("@ss.hasPermission('distri:pt-profit-log-details:create')")
+    public CommonResult<Long> createPtProfitLogDetails(@Valid @RequestBody PtProfitLogDetailsSaveReqVO createReqVO) {
+        return success(ptProfitLogDetailsService.createPtProfitLogDetails(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新平台利润记录详情")
+    @PreAuthorize("@ss.hasPermission('distri:pt-profit-log-details:update')")
+    public CommonResult<Boolean> updatePtProfitLogDetails(@Valid @RequestBody PtProfitLogDetailsSaveReqVO updateReqVO) {
+        ptProfitLogDetailsService.updatePtProfitLogDetails(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除平台利润记录详情")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('distri:pt-profit-log-details:delete')")
+    public CommonResult<Boolean> deletePtProfitLogDetails(@RequestParam("id") Long id) {
+        ptProfitLogDetailsService.deletePtProfitLogDetails(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得平台利润记录详情")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('distri:pt-profit-log-details:query')")
+    public CommonResult<PtProfitLogDetailsRespVO> getPtProfitLogDetails(@RequestParam("id") Long id) {
+        PtProfitLogDetailsDO ptProfitLogDetails = ptProfitLogDetailsService.getPtProfitLogDetails(id);
+        return success(BeanUtils.toBean(ptProfitLogDetails, PtProfitLogDetailsRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得平台利润记录详情分页")
+    @PreAuthorize("@ss.hasPermission('distri:pt-profit-log-details:query')")
+    public CommonResult<PageResult<PtProfitLogDetailsRespVO>> getPtProfitLogDetailsPage(@Valid PtProfitLogDetailsPageReqVO pageReqVO) {
+        PageResult<PtProfitLogDetailsDO> pageResult = ptProfitLogDetailsService.getPtProfitLogDetailsPage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, PtProfitLogDetailsRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出平台利润记录详情 Excel")
+    @PreAuthorize("@ss.hasPermission('distri:pt-profit-log-details:export')")
+    @OperateLog(type = EXPORT)
+    public void exportPtProfitLogDetailsExcel(@Valid PtProfitLogDetailsPageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<PtProfitLogDetailsDO> list = ptProfitLogDetailsService.getPtProfitLogDetailsPage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "平台利润记录详情.xls", "数据", PtProfitLogDetailsRespVO.class,
+                        BeanUtils.toBean(list, PtProfitLogDetailsRespVO.class));
+    }
+
+}

+ 27 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/vo/PtProfitLogDetailsPageReqVO.java

@@ -0,0 +1,27 @@
+package cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo;
+
+import lombok.*;
+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 PtProfitLogDetailsPageReqVO extends PageParam {
+
+    @Schema(description = "平台利润记录编号", example = "19955")
+    private Long distriPtProfitLogId;
+
+    @Schema(description = "订单项编号", example = "9530")
+    private Long orderItemId;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+}

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

@@ -0,0 +1,29 @@
+package cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.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 PtProfitLogDetailsRespVO {
+
+    @Schema(description = "详情编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32357")
+    @ExcelProperty("详情编号")
+    private Long id;
+
+    @Schema(description = "平台利润记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19955")
+    @ExcelProperty("平台利润记录编号")
+    private Long distriPtProfitLogId;
+
+    @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9530")
+    @ExcelProperty("订单项编号")
+    private Long orderItemId;
+
+    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+}

+ 25 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/controller/admin/ptprofitlogdetails/vo/PtProfitLogDetailsSaveReqVO.java

@@ -0,0 +1,25 @@
+package cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import javax.validation.constraints.*;
+
+@Schema(description = "管理后台 - 平台利润记录详情新增/修改 Request VO")
+@Data
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+public class PtProfitLogDetailsSaveReqVO {
+
+    @Schema(description = "详情编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "32357")
+    private Long id;
+
+    @Schema(description = "平台利润记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "19955")
+    @NotNull(message = "平台利润记录编号不能为空")
+    private Long distriPtProfitLogId;
+
+    @Schema(description = "订单项编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "9530")
+    @NotNull(message = "订单项编号不能为空")
+    private Long orderItemId;
+
+}

+ 36 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/dal/dataobject/ptprofitlogdetails/PtProfitLogDetailsDO.java

@@ -0,0 +1,36 @@
+package cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlogdetails;
+
+import lombok.*;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.newfeifan.mall.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 平台利润记录详情 DO
+ *
+ * @author 非繁人
+ */
+@TableName("distri_pt_profit_log_details")
+@KeySequence("distri_pt_profit_log_details_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class PtProfitLogDetailsDO extends BaseDO {
+
+    /**
+     * 详情编号
+     */
+    @TableId
+    private Long id;
+    /**
+     * 平台利润记录编号
+     */
+    private Long distriPtProfitLogId;
+    /**
+     * 订单项编号
+     */
+    private Long orderItemId;
+
+}

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

@@ -27,10 +27,15 @@ public interface PtProfitLogMapper extends BaseMapperX<PtProfitLogDO> {
         List<Integer> profitStatus = Arrays.asList(
                 RECOMMENDED_PERSON_QUOTA.getType(),
                 DIRECT_REFERRAL_QUOTA.getType(),
+                SMALL_QUOTA_CRASH.getType(),
                 ORDER_PAY_INTEGRAL.getType(),
-                FREEZE_CHANGE_INTEGRAL.getType(),
-                SMALL_QUOTA_CRASH.getType()
-        );
+                ORDER_REFUND_INTEGRAL.getType(),
+                ORDER_CANCEL_BY_USER_REFUND_INTEGRAL.getType(),
+                ORDER_CANCEL_BY_SYSTEM_REFUND_INTEGRAL.getType(),
+                ORDER_PAY_INTEGRAL_ANCESTER.getType(),
+                ORDER_REFUND_INTEGRAL_CONSUMER.getType(),
+                ORDER_REFUND_INTEGRAL_ANCESTER.getType(),
+                ORDER_PAY_INTEGRAL_CONSUMER.getType());
 
         if(reqVO.getUserId().equals(PT_ID)){
             profitStatus = Arrays.asList(

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

@@ -0,0 +1,27 @@
+package cn.newfeifan.mall.module.distri.dal.mysql.ptprofitlogdetails;
+
+
+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.ptprofitlogdetails.PtProfitLogDetailsDO;
+import org.apache.ibatis.annotations.Mapper;
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo.*;
+
+/**
+ * 平台利润记录详情 Mapper
+ *
+ * @author 非繁人
+ */
+@Mapper
+public interface PtProfitLogDetailsMapper extends BaseMapperX<PtProfitLogDetailsDO> {
+
+    default PageResult<PtProfitLogDetailsDO> selectPage(PtProfitLogDetailsPageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<PtProfitLogDetailsDO>()
+                .eqIfPresent(PtProfitLogDetailsDO::getDistriPtProfitLogId, reqVO.getDistriPtProfitLogId())
+                .eqIfPresent(PtProfitLogDetailsDO::getOrderItemId, reqVO.getOrderItemId())
+                .betweenIfPresent(PtProfitLogDetailsDO::getCreateTime, reqVO.getCreateTime())
+                .orderByDesc(PtProfitLogDetailsDO::getId));
+    }
+
+}

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

@@ -6,6 +6,7 @@ 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;
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo.PtProfitLogDetailsSaveReqVO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.integral.IntegralDO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.orderpercentage.OrderPercentageDO;
 import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofit.PtProfitDO;
@@ -21,6 +22,7 @@ import cn.newfeifan.mall.module.distri.service.orderpercentage.OrderPercentageSe
 import cn.newfeifan.mall.module.distri.service.partitioncrash.PartitionCrashService;
 import cn.newfeifan.mall.module.distri.service.ptprofit.PtProfitService;
 import cn.newfeifan.mall.module.distri.service.ptprofitlog.PtProfitLogService;
+import cn.newfeifan.mall.module.distri.service.ptprofitlogdetails.PtProfitLogDetailsService;
 import cn.newfeifan.mall.module.distri.service.sharepath.SharePathService;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
@@ -83,6 +85,9 @@ public class OrderCalcServiceImpl implements OrderCalcService {
     @Resource
     private PartitionCrashService partitionCrashService;
 
+    @Resource
+    private PtProfitLogDetailsService ptProfitLogDetailsService;
+
     @Override
     public Long createOrderCalc(OrderCalcSaveReqVO createReqVO) {
         // 插入
@@ -197,6 +202,9 @@ public class OrderCalcServiceImpl implements OrderCalcService {
             BigDecimal price = new BigDecimal(priceStream);
             BigDecimal costPrice = new BigDecimal(longStream);
 
+            // 添加平台利润记录详情
+            List<PtProfitLogDetailsSaveReqVO> ptProfitLogDetailsSaveReqVOS = new ArrayList<>();
+
 
             // 计算
             // 计算利润: (价格 - 成本价格) * 产品数量
@@ -211,11 +219,16 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                 profit[1] = profit[1].add(new BigDecimal(j.getIncreaseIntegral()));     //自得积分
                 profit[2] = profit[2].add(new BigDecimal(j.getAncestorIncreaseIntegral()));     //自得积分
 
+                // 遍历订单项拿到订单项编号
                 updateOrderItem(j.getOrderItemId());
+                PtProfitLogDetailsSaveReqVO ptProfitLogDetailsSaveReqVO = PtProfitLogDetailsSaveReqVO.builder()
+                        .orderItemId(j.getOrderItemId())
+                        .build();
+                ptProfitLogDetailsSaveReqVOS.add(ptProfitLogDetailsSaveReqVO);
             });
 
 
-            // 计算毛利: 利润 * 0.38
+            // 计算毛利: 利润 * 1
             BigDecimal grossProfit = profit[0].multiply(new BigDecimal(orderPercentageDO.getGrossProfitPerc())).setScale(4, RoundingMode.DOWN);
 
             // 计算平台收益
@@ -231,10 +244,10 @@ public class OrderCalcServiceImpl implements OrderCalcService {
             // 直推奖: 毛利 * 0.3 (上一级)
             BigDecimal ancestorQuota = profit[2];
 
-            // 合赢将: 毛利 * 0.08
+            // 合赢将: 毛利 * 0.12
             BigDecimal bonusQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitBonusQuotaPerc())).setScale(4, RoundingMode.DOWN);
 
-            // 平台服务费: 毛利 * 0.22
+            // 平台服务费: 毛利 * 0.05
             BigDecimal platformQuota = grossProfit.multiply(new BigDecimal(orderPercentageDO.getGrossProfitPlatformQuotaPerc())).setScale(4, RoundingMode.DOWN);
 
 
@@ -344,6 +357,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                     .amount(platformQuotaInt + grossProfitAfterBonusInt)
                     .afterAmount(ptProfitDO.getPtTotalAdd() + platformQuotaInt + grossProfitAfterBonusInt)
                     .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
                     .build();
             // 平台收益
             PtProfitLogSaveReqVO ptGrossAddLog = PtProfitLogSaveReqVO.builder()
@@ -353,6 +367,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                     .amount(grossProfitAfterBonusInt)
                     .afterAmount(ptProfitDO.getPtGrossAdd() + ptProfitSaveReqVO.getPtGrossAdd())
                     .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
                     .build();
 
             // 平台服务费
@@ -363,6 +378,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                     .amount(platformQuotaInt)
                     .afterAmount(ptProfitDO.getPtAdd() + ptProfitSaveReqVO.getPtAdd())
                     .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
                     .build();
 
 
@@ -380,6 +396,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                     .maxAvailablePointsAmount(-amount)
                     .afterMaxAvailablePointsAmount(ancestorHighQuota - amount)
                     .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
                     .build();
 
 
@@ -396,6 +413,7 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                     .maxAvailablePointsAmount(highQuotaInt)
                     .afterMaxAvailablePointsAmount(integralDO.getHighQuota())
                     .percentTemplate(percentTemplate)
+                    .generateUserId(integralDO.getUserId())
                     .build();
 
             // 合赢奖记录
@@ -405,16 +423,20 @@ public class OrderCalcServiceImpl implements OrderCalcService {
                     .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);
-            ptProfitLogSaveReqVOS.add(hyjLog);
-
 
         });
 

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

@@ -19,6 +19,7 @@ import cn.newfeifan.mall.framework.common.util.object.BeanUtils;
 import cn.newfeifan.mall.module.distri.dal.mysql.ptprofitlog.PtProfitLogMapper;
 
 import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.newfeifan.mall.module.distri.enums.CaclEnum.*;
 import static cn.newfeifan.mall.module.distri.enums.ErrorCodeConstants.*;
 
 /**
@@ -94,12 +95,15 @@ public class PtProfitLogServiceImpl implements PtProfitLogService {
                 .afterAmount(afterAmount)
                 .amount(amount)
                 .percentTemplate(percentTemplate)
-                .userId(userId)
                 .profitStatus(caclEnum.getType())
                 .accumulatedQuotaAmount(accumulatedQuotAmount)
                 .maxAvailablePointsAmount(maxAvailablePointsAmount)
                 .afterMaxAvailablePointsAmount(afterMaxAvailablePointsAmount)
+                .generateUserId(userId)
                 .build();
+        if(caclEnum.getType().equals(SMALL_QUOTA_CRASH.getType())){
+            ptProfitLog.setUserId(userId);
+        }
         ptProfitLogMapper.insert(BeanUtils.toBean(ptProfitLog, PtProfitLogDO.class));
         // todo 发送通知
         // todo 发短信

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

@@ -0,0 +1,59 @@
+package cn.newfeifan.mall.module.distri.service.ptprofitlogdetails;
+
+import java.util.*;
+import javax.validation.*;
+import cn.newfeifan.mall.module.distri.controller.admin.ptprofitlogdetails.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlogdetails.PtProfitLogDetailsDO;
+import cn.newfeifan.mall.framework.common.pojo.PageResult;
+
+/**
+ * 平台利润记录详情 Service 接口
+ *
+ * @author 非繁人
+ */
+public interface PtProfitLogDetailsService {
+
+    /**
+     * 创建平台利润记录详情
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createPtProfitLogDetails(@Valid PtProfitLogDetailsSaveReqVO createReqVO);
+
+    /**
+     * 更新平台利润记录详情
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updatePtProfitLogDetails(@Valid PtProfitLogDetailsSaveReqVO updateReqVO);
+
+    /**
+     * 删除平台利润记录详情
+     *
+     * @param id 编号
+     */
+    void deletePtProfitLogDetails(Long id);
+
+    /**
+     * 获得平台利润记录详情
+     *
+     * @param id 编号
+     * @return 平台利润记录详情
+     */
+    PtProfitLogDetailsDO getPtProfitLogDetails(Long id);
+
+    /**
+     * 获得平台利润记录详情分页
+     *
+     * @param pageReqVO 分页查询
+     * @return 平台利润记录详情分页
+     */
+    PageResult<PtProfitLogDetailsDO> getPtProfitLogDetailsPage(PtProfitLogDetailsPageReqVO pageReqVO);
+
+    /**
+     * 批量创建
+     * @param ptProfitLogDetailsSaveReqVOS 对象集
+     */
+    void saveBatch(List<PtProfitLogDetailsSaveReqVO> ptProfitLogDetailsSaveReqVOS);
+}

+ 77 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/java/cn/newfeifan/mall/module/distri/service/ptprofitlogdetails/PtProfitLogDetailsServiceImpl.java

@@ -0,0 +1,77 @@
+package cn.newfeifan.mall.module.distri.service.ptprofitlogdetails;
+
+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.ptprofitlogdetails.vo.*;
+import cn.newfeifan.mall.module.distri.dal.dataobject.ptprofitlogdetails.PtProfitLogDetailsDO;
+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.ptprofitlogdetails.PtProfitLogDetailsMapper;
+
+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 PtProfitLogDetailsServiceImpl implements PtProfitLogDetailsService {
+
+    @Resource
+    private PtProfitLogDetailsMapper ptProfitLogDetailsMapper;
+
+    @Override
+    public Long createPtProfitLogDetails(PtProfitLogDetailsSaveReqVO createReqVO) {
+        // 插入
+        PtProfitLogDetailsDO ptProfitLogDetails = BeanUtils.toBean(createReqVO, PtProfitLogDetailsDO.class);
+        ptProfitLogDetailsMapper.insert(ptProfitLogDetails);
+        // 返回
+        return ptProfitLogDetails.getId();
+    }
+
+    @Override
+    public void updatePtProfitLogDetails(PtProfitLogDetailsSaveReqVO updateReqVO) {
+        // 校验存在
+        validatePtProfitLogDetailsExists(updateReqVO.getId());
+        // 更新
+        PtProfitLogDetailsDO updateObj = BeanUtils.toBean(updateReqVO, PtProfitLogDetailsDO.class);
+        ptProfitLogDetailsMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deletePtProfitLogDetails(Long id) {
+        // 校验存在
+        validatePtProfitLogDetailsExists(id);
+        // 删除
+        ptProfitLogDetailsMapper.deleteById(id);
+    }
+
+    private void validatePtProfitLogDetailsExists(Long id) {
+        if (ptProfitLogDetailsMapper.selectById(id) == null) {
+            throw exception(PT_PROFIT_LOG_DETAILS_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public PtProfitLogDetailsDO getPtProfitLogDetails(Long id) {
+        return ptProfitLogDetailsMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<PtProfitLogDetailsDO> getPtProfitLogDetailsPage(PtProfitLogDetailsPageReqVO pageReqVO) {
+        return ptProfitLogDetailsMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public void saveBatch(List<PtProfitLogDetailsSaveReqVO> ptProfitLogDetailsSaveReqVOS) {
+        List<PtProfitLogDetailsDO> ptProfitLogDetailsDOList = BeanUtils.toBean(ptProfitLogDetailsSaveReqVOS, PtProfitLogDetailsDO.class);
+        ptProfitLogDetailsMapper.insertBatch(ptProfitLogDetailsDOList);
+    }
+
+}

+ 12 - 0
feifan-module-distri/feifan-module-distri-biz/src/main/resources/mapper/ptprofitlogdetails/PtProfitLogDetailsMapper.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.ptprofitlogdetails.PtProfitLogDetailsMapper">
+
+    <!--
+        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
+        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
+        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
+        文档可见:https://www.zhongxing.cn/MyBatis/x-plugins/
+     -->
+
+</mapper>

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

@@ -316,8 +316,8 @@ public class TradeOrderController {
     @GetMapping("/startCalc")
     @Operation(summary = "计算启动")
     public CommonResult<String> startCalc(@RequestParam("orderIds") List<Long> orderIds) {
-//        List<DistriOrderMessage> appTradeOrderDetailRespVos = tradeOrderQueryService.queryAllOrder();
-        List<DistriOrderMessage> appTradeOrderDetailRespVos = tradeOrderQueryService.queryAllOrder(orderIds);
+        List<DistriOrderMessage> appTradeOrderDetailRespVos = tradeOrderQueryService.queryAllOrder();
+//        List<DistriOrderMessage> appTradeOrderDetailRespVos = tradeOrderQueryService.queryAllOrder(orderIds);
 
 
         Map<Long, List<OrderItemMessage>> orderItemMessageGroupBy = appTradeOrderDetailRespVos.stream()