From 2004f3c1957834a169a1fd9149285fc3c351548f Mon Sep 17 00:00:00 2001 From: 13233904609 <13233904609@163.cm> Date: Mon, 22 Jul 2024 14:16:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=A5=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../trade/api/order/TradeOrderItemApi.java | 4 + .../module/member/api/user/MemberUserApi.java | 8 + .../member/enums/ErrorCodeConstants.java | 4 +- .../member/api/user/MemberUserApiImpl.java | 5 + .../DistributionConfigController.java | 125 ++++++++++ .../vo/DistributionConfigPageReqVO.java | 30 +++ .../vo/DistributionConfigRespVO.java | 43 ++++ .../vo/DistributionConfigSaveReqVO.java | 28 +++ .../DistributionLogController.java | 108 +++++++++ .../vo/DistributionLogPageReqVO.java | 46 ++++ .../vo/DistributionLogRespVO.java | 67 ++++++ .../vo/DistributionLogSaveReqVO.java | 39 +++ .../DistributionStatisticsController.java | 124 ++++++++++ .../vo/DistributionStatisticsPageReqVO.java | 37 +++ .../vo/DistributionStatisticsRespVO.java | 70 ++++++ .../vo/DistributionStatisticsSaveReqVO.java | 30 +++ .../DistributionConfigConvert.java | 40 +++ .../DistributionLogConvert.java | 36 +++ .../DistributionStatisticsConvert.java | 42 ++++ .../DistributionConfigDO.java | 43 ++++ .../DistributionMebConfigDO.java | 43 ++++ .../distributionlog/DistributionLogDO.java | 63 +++++ .../DistributionStatisticsDO.java | 51 ++++ .../DistributionConfigMapper.java | 28 +++ .../DistributionMebConfigMapper.java | 28 +++ .../DistributionLogMapper.java | 34 +++ .../DistributionStatisticsMapper.java | 55 +++++ .../DistributionConfigService.java | 66 +++++ .../DistributionConfigServiceImpl.java | 112 +++++++++ .../DistributionLogService.java | 55 +++++ .../DistributionLogServiceImpl.java | 74 ++++++ .../DistributionStatisticsService.java | 68 ++++++ .../DistributionStatisticsServiceImpl.java | 96 ++++++++ .../service/user/MemberUserService.java | 9 + .../service/user/MemberUserServiceImpl.java | 227 ++++++++++++++---- .../DistributionConfigServiceImplTest.java | 138 +++++++++++ .../DistributionLogServiceImplTest.java | 162 +++++++++++++ ...DistributionStatisticsServiceImplTest.java | 150 ++++++++++++ .../admin/notify/PayNotifyController.java | 1 + .../pay/dal/mysql/order/PayOrderMapper.java | 3 + .../service/order/PayOrderServiceImpl.java | 7 + 41 files changed, 2347 insertions(+), 52 deletions(-) create mode 100644 ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderItemApi.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/DistributionConfigController.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigPageReqVO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigRespVO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigSaveReqVO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/DistributionLogController.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogPageReqVO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogRespVO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogSaveReqVO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/DistributionStatisticsController.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsPageReqVO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsRespVO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsSaveReqVO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionconfig/DistributionConfigConvert.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionlog/DistributionLogConvert.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionstatistics/DistributionStatisticsConvert.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionConfigDO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionMebConfigDO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionlog/DistributionLogDO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionstatistics/DistributionStatisticsDO.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionConfigMapper.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionMebConfigMapper.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionlog/DistributionLogMapper.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionstatistics/DistributionStatisticsMapper.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigService.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImpl.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogService.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImpl.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsService.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImpl.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImplTest.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImplTest.java create mode 100644 ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImplTest.java diff --git a/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderItemApi.java b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderItemApi.java new file mode 100644 index 0000000..25e27ee --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/TradeOrderItemApi.java @@ -0,0 +1,4 @@ +package cn.iocoder.yudao.module.trade.api.order; + +public interface TradeOrderItemApi { +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java index 386b57f..31402d7 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApi.java @@ -72,4 +72,12 @@ public interface MemberUserApi { * @return 更新结果 */ void updateUserUpgradesLevel(Long userId); + + /** + * 商品回调 + * + * @param orderId 订单id + * @return 更新结果 + */ + void updateUserUpgradesLevelcallback(Long orderId); } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java index ee970a5..7cb63de 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java @@ -54,5 +54,7 @@ public interface ErrorCodeConstants { //========== 用户分组 1-004-012-000 ========== ErrorCode GROUP_NOT_EXISTS = new ErrorCode(1_004_012_000, "用户分组不存在"); ErrorCode GROUP_HAS_USER = new ErrorCode(1_004_012_001, "用户分组下存在用户,无法删除"); - + ErrorCode DISTRIBUTION_CONFIG_NOT_EXISTS = new ErrorCode(1_004_012_002, "分销配置不存在"); + ErrorCode DISTRIBUTION_LOG_NOT_EXISTS = new ErrorCode(1_004_012_003, "分销记录不存在"); + ErrorCode DISTRIBUTION_STATISTICS_NOT_EXISTS = new ErrorCode(1_004_012_004, "分销统计不存在"); } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java index a38703d..1d092a1 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/api/user/MemberUserApiImpl.java @@ -54,5 +54,10 @@ public class MemberUserApiImpl implements MemberUserApi { userService.updateUserUpgradesLevel(userId); } + @Override + public void updateUserUpgradesLevelcallback(Long orderId) { + userService.updateUserUpgradesLevelcallback(orderId); + } + } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/DistributionConfigController.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/DistributionConfigController.java new file mode 100644 index 0000000..7c90453 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/DistributionConfigController.java @@ -0,0 +1,125 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionconfig; + +import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.convert.distributionconfig.DistributionConfigConvert; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO; +import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; +import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; +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.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; + +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.member.service.distributionconfig.DistributionConfigService; + +@Tag(name = "管理后台 - 分销配置") +@RestController +@RequestMapping("/member/distribution-config") +@Validated +public class DistributionConfigController { + + @Resource + private DistributionConfigService distributionConfigService; + + @Resource + private MemberLevelApi memberLevelApi; + + @Resource + private ProductSpuApi spuApi; + + @PostMapping("/create") + @Operation(summary = "创建分销配置") + @PreAuthorize("@ss.hasPermission('member:distribution-config:create')") + public CommonResult createDistributionConfig(@Valid @RequestBody DistributionConfigSaveReqVO createReqVO) { + return success(distributionConfigService.createDistributionConfig(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新分销配置") + @PreAuthorize("@ss.hasPermission('member:distribution-config:update')") + public CommonResult updateDistributionConfig(@Valid @RequestBody DistributionConfigSaveReqVO updateReqVO) { + distributionConfigService.updateDistributionConfig(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除分销配置") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('member:distribution-config:delete')") + public CommonResult deleteDistributionConfig(@RequestParam("id") Long id) { + distributionConfigService.deleteDistributionConfig(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得分销配置") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('member:distribution-config:query')") + public CommonResult getDistributionConfig(@RequestParam("id") Long id) { + DistributionConfigDO distributionConfig = distributionConfigService.getDistributionConfig(id); + return success(BeanUtils.toBean(distributionConfig, DistributionConfigRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得分销配置分页") + @PreAuthorize("@ss.hasPermission('member:distribution-config:query')") + public CommonResult> getDistributionConfigPage(@Valid DistributionConfigPageReqVO pageReqVO) { + PageResult pageResult = distributionConfigService.getDistributionConfigPage(pageReqVO); + // 处理用户级别返显 + List levels = memberLevelApi.getLevelList( + convertSet(pageResult.getList(), DistributionConfigDO::getLevelId)); + // 拼接数据 + List spuList = spuApi.getSpuList(convertList(pageResult.getList(), DistributionConfigDO::getProductId)); + return success(DistributionConfigConvert.INSTANCE.convertPage(pageResult, levels,spuList)); +// return success(BeanUtils.toBean(pageResult, DistributionConfigRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出分销配置 Excel") + @PreAuthorize("@ss.hasPermission('member:distribution-config:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportDistributionConfigExcel(@Valid DistributionConfigPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = distributionConfigService.getDistributionConfigPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "分销配置.xls", "数据", DistributionConfigRespVO.class, + BeanUtils.toBean(list, DistributionConfigRespVO.class)); + } + + // ==================== 子表(分销配置关联会员等级) ==================== + + @GetMapping("/distribution-meb-config/list-by-config-id") + @Operation(summary = "获得分销配置关联会员等级列表") + @Parameter(name = "configId", description = "分销配置id") + @PreAuthorize("@ss.hasPermission('member:distribution-config:query')") + public CommonResult> getDistributionMebConfigListByConfigId(@RequestParam("configId") Long configId) { + return success(distributionConfigService.getDistributionMebConfigListByConfigId(configId)); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigPageReqVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigPageReqVO.java new file mode 100644 index 0000000..9ffa72f --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigPageReqVO.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.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 DistributionConfigPageReqVO extends PageParam { + + @Schema(description = "分销商品id", example = "18678") + private Long productId; + @Schema(description = "购买人提升会员等级", example = "18678") + private Long levelId; + + @Schema(description = "启用状态", example = "2") + private String status; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigRespVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigRespVO.java new file mode 100644 index 0000000..541f6db --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigRespVO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +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 DistributionConfigRespVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16387") + @ExcelProperty("id主键") + private Long id; + + @Schema(description = "分销商品id", example = "18678") + @ExcelProperty("分销商品id") + private Long productId; + + @Schema(description = "购买人提升会员等级", example = "18678") + @ExcelProperty("购买人提升会员等级") + private Long levelId; + + @Schema(description = "启用状态", example = "2") + @ExcelProperty("启用状态") + private String status; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "购买人提升会员等级", example = "18678") + @ExcelProperty("购买人提升会员等级") + private String levelName; + + @Schema(description = "商品名称", example = "18678") + @ExcelProperty("商品名称") + private String supName; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigSaveReqVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigSaveReqVO.java new file mode 100644 index 0000000..2d424d9 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionconfig/vo/DistributionConfigSaveReqVO.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo; + +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 分销配置新增/修改 Request VO") +@Data +public class DistributionConfigSaveReqVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16387") + private Long id; + + @Schema(description = "分销商品id", example = "18678") + private Long productId; + + @Schema(description = "购买人提升会员等级", example = "18678") + private Long levelId; + + @Schema(description = "启用状态", example = "2") + private String status; + + @Schema(description = "分销配置关联会员等级列表") + private List distributionMebConfigs; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/DistributionLogController.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/DistributionLogController.java new file mode 100644 index 0000000..28845d3 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/DistributionLogController.java @@ -0,0 +1,108 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionlog; + +import cn.iocoder.yudao.module.member.convert.distributionlog.DistributionLogConvert; +import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert; +import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; +import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; +import cn.iocoder.yudao.module.member.service.user.MemberUserService; +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.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; + +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.module.member.service.distributionlog.DistributionLogService; + +@Tag(name = "管理后台 - 分销记录") +@RestController +@RequestMapping("/member/distribution-log") +@Validated +public class DistributionLogController { + + @Resource + private DistributionLogService distributionLogService; + + @Resource + private MemberUserService memberUserService; + + @PostMapping("/create") + @Operation(summary = "创建分销记录") + @PreAuthorize("@ss.hasPermission('member:distribution-log:create')") + public CommonResult createDistributionLog(@Valid @RequestBody DistributionLogSaveReqVO createReqVO) { + return success(distributionLogService.createDistributionLog(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新分销记录") + @PreAuthorize("@ss.hasPermission('member:distribution-log:update')") + public CommonResult updateDistributionLog(@Valid @RequestBody DistributionLogSaveReqVO updateReqVO) { + distributionLogService.updateDistributionLog(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除分销记录") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('member:distribution-log:delete')") + public CommonResult deleteDistributionLog(@RequestParam("id") Long id) { + distributionLogService.deleteDistributionLog(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得分销记录") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('member:distribution-log:query')") + public CommonResult getDistributionLog(@RequestParam("id") Long id) { + DistributionLogDO distributionLog = distributionLogService.getDistributionLog(id); + return success(BeanUtils.toBean(distributionLog, DistributionLogRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得分销记录分页") + @PreAuthorize("@ss.hasPermission('member:distribution-log:query')") + public CommonResult> getDistributionLogPage(@Valid DistributionLogPageReqVO pageReqVO) { + pageReqVO.setGameStatus("0"); + PageResult pageResult = distributionLogService.getDistributionLogPage(pageReqVO); + // 拼接结果返回 + List users = memberUserService.getUserList( + convertSet(pageResult.getList(), DistributionLogDO::getMebId)); + return success(DistributionLogConvert.INSTANCE.convertPage(pageResult, users)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出分销记录 Excel") + @PreAuthorize("@ss.hasPermission('member:distribution-log:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportDistributionLogExcel(@Valid DistributionLogPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = distributionLogService.getDistributionLogPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "分销记录.xls", "数据", DistributionLogRespVO.class, + BeanUtils.toBean(list, DistributionLogRespVO.class)); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogPageReqVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogPageReqVO.java new file mode 100644 index 0000000..b16eb32 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogPageReqVO.java @@ -0,0 +1,46 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.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 DistributionLogPageReqVO extends PageParam { + + @Schema(description = "推荐人id", example = "5267") + private Long referrerId; + + @Schema(description = "推荐人id(便于回溯)", example = "23906") + private Long oldReferrerId; + + @Schema(description = "购买人id", example = "6637") + private Long mebId; + + @Schema(description = "佣金") + private Integer brokerage; + + @Schema(description = "分佣结算核销状态", example = "2") + private String status; + + @Schema(description = "游戏状态", example = "2") + private String gameStatus; + + @Schema(description = "游戏兑换状态", example = "1") + private String convertStatus; + + @Schema(description = "推荐人会员等级id", example = "10242") + private Long levelId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogRespVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogRespVO.java new file mode 100644 index 0000000..9f5d504 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogRespVO.java @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +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 DistributionLogRespVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4693") + @ExcelProperty("id主键") + private Long id; + + @Schema(description = "推荐人id", example = "5267") + @ExcelProperty("推荐人id") + private Long referrerId; + + @Schema(description = "推荐人id(便于回溯)", example = "23906") + @ExcelProperty("推荐人id(便于回溯)") + private Long oldReferrerId; + + @Schema(description = "购买人id", example = "6637") + @ExcelProperty("购买人id") + private Long mebId; + + @Schema(description = "佣金") + @ExcelProperty("佣金") + private Integer brokerage; + + @Schema(description = "分佣结算核销状态", example = "2") + @ExcelProperty("分佣结算核销状态") + private String status; + + @Schema(description = "游戏状态", example = "2") + @ExcelProperty("游戏状态") + private String gameStatus; + + @Schema(description = "游戏兑换状态", example = "1") + @ExcelProperty("游戏兑换状态") + private String convertStatus; + + @Schema(description = "推荐人会员等级id", example = "10242") + @ExcelProperty("推荐人会员等级id") + private Long levelId; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "用户昵称", example = "2") + @ExcelProperty("用户昵称") + private String nickname; + + @Schema(description = "用户名称", example = "2") + @ExcelProperty("用户名称") + private String userName; + + @Schema(description = "手机号", example = "2") + @ExcelProperty("手机号") + private String phone; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogSaveReqVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogSaveReqVO.java new file mode 100644 index 0000000..2e0635b --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionlog/vo/DistributionLogSaveReqVO.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionlog.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 DistributionLogSaveReqVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4693") + private Long id; + + @Schema(description = "推荐人id", example = "5267") + private Long referrerId; + + @Schema(description = "推荐人id(便于回溯)", example = "23906") + private Long oldReferrerId; + + @Schema(description = "购买人id", example = "6637") + private Long mebId; + + @Schema(description = "佣金") + private Integer brokerage; + + @Schema(description = "分佣结算核销状态", example = "2") + private String status; + + @Schema(description = "游戏状态", example = "2") + private String gameStatus; + + @Schema(description = "游戏兑换状态", example = "1") + private String convertStatus; + + @Schema(description = "推荐人会员等级id", example = "10242") + private Long levelId; + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/DistributionStatisticsController.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/DistributionStatisticsController.java new file mode 100644 index 0000000..bc6ea0c --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/DistributionStatisticsController.java @@ -0,0 +1,124 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionstatistics; + +import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.convert.distributionlog.DistributionLogConvert; +import cn.iocoder.yudao.module.member.convert.distributionstatistics.DistributionStatisticsConvert; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; +import cn.iocoder.yudao.module.member.service.user.MemberUserService; +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.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; + +import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; +import cn.iocoder.yudao.module.member.service.distributionstatistics.DistributionStatisticsService; + +@Tag(name = "管理后台 - 分销统计") +@RestController +@RequestMapping("/member/distribution-statistics") +@Validated +public class DistributionStatisticsController { + + @Resource + private DistributionStatisticsService distributionStatisticsService; + + @Resource + private MemberUserService memberUserService; + + @Resource + private MemberLevelApi memberLevelApi; + + @PostMapping("/create") + @Operation(summary = "创建分销统计") + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:create')") + public CommonResult createDistributionStatistics(@Valid @RequestBody DistributionStatisticsSaveReqVO createReqVO) { + return success(distributionStatisticsService.createDistributionStatistics(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新分销统计") + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:update')") + public CommonResult updateDistributionStatistics(@Valid @RequestBody DistributionStatisticsSaveReqVO updateReqVO) { + distributionStatisticsService.updateDistributionStatistics(updateReqVO); + return success(true); + } + + @PutMapping("/updateAlready") + @Operation(summary = "结算分销统计") + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:update')") + public CommonResult updateAlready(@Valid @RequestBody DistributionStatisticsSaveReqVO updateReqVO) { + distributionStatisticsService.updateAlready(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除分销统计") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:delete')") + public CommonResult deleteDistributionStatistics(@RequestParam("id") Long id) { + distributionStatisticsService.deleteDistributionStatistics(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得分销统计") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:query')") + public CommonResult getDistributionStatistics(@RequestParam("id") Long id) { + DistributionStatisticsDO distributionStatistics = distributionStatisticsService.getDistributionStatistics(id); + return success(BeanUtils.toBean(distributionStatistics, DistributionStatisticsRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得分销统计分页") + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:query')") + public CommonResult> getDistributionStatisticsPage(@Valid DistributionStatisticsPageReqVO pageReqVO) { + PageResult pageResult = distributionStatisticsService.getDistributionStatisticsPage1(pageReqVO); + // 拼接结果返回 + // 处理用户级别返显 + List levels = memberLevelApi.getLevelList( + convertSet(pageResult.getList(), DistributionStatisticsRespVO::getLevelId)); + List users = memberUserService.getUserList( + convertSet(pageResult.getList(), DistributionStatisticsRespVO::getMebId)); + return success(DistributionStatisticsConvert.INSTANCE.convertPage(pageResult, users,levels)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出分销统计 Excel") + @PreAuthorize("@ss.hasPermission('member:distribution-statistics:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportDistributionStatisticsExcel(@Valid DistributionStatisticsPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = distributionStatisticsService.getDistributionStatisticsPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "分销统计.xls", "数据", DistributionStatisticsRespVO.class, + BeanUtils.toBean(list, DistributionStatisticsRespVO.class)); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsPageReqVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsPageReqVO.java new file mode 100644 index 0000000..5afd5d0 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsPageReqVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.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 DistributionStatisticsPageReqVO extends PageParam { + + @Schema(description = "会员等级id", example = "19012") + private Long levelId; + + @Schema(description = "会员id", example = "10495") + private Long mebId; + + @Schema(description = "推荐记录id", example = "5711") + private Long logId; + + @Schema(description = "推荐人id", example = "2750") + private Long referrerId; + + @Schema(description = "分佣结算核销状态", example = "1") + private String status; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsRespVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsRespVO.java new file mode 100644 index 0000000..cdd1f86 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsRespVO.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +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 DistributionStatisticsRespVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25196") + @ExcelProperty("id主键") + private Long id; + + @Schema(description = "会员等级id", example = "19012") + @ExcelProperty("会员等级id") + private Long levelId; + + @Schema(description = "会员id", example = "10495") + @ExcelProperty("会员id") + private Long mebId; + + @Schema(description = "推荐记录id", example = "5711") + @ExcelProperty("推荐记录id") + private Long logId; + + @Schema(description = "推荐人id", example = "2750") + @ExcelProperty("推荐人id") + private Long referrerId; + + @Schema(description = "分佣结算核销状态", example = "1") + @ExcelProperty("分佣结算核销状态") + private String status; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + + @Schema(description = "用户昵称", example = "2") + @ExcelProperty("用户昵称") + private String nickname; + + @Schema(description = "用户名称", example = "2") + @ExcelProperty("用户名称") + private String userName; + + @Schema(description = "手机号", example = "2") + @ExcelProperty("手机号") + private String phone; + + @Schema(description = "会员等级", example = "2") + @ExcelProperty("会员等级") + private String levelName; + + @Schema(description = "已结算", example = "2") + @ExcelProperty("已结算") + private Integer haveAlready; + + @Schema(description = "未结算", example = "2") + @ExcelProperty("未结算") + private Integer unAlready; + + + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsSaveReqVO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsSaveReqVO.java new file mode 100644 index 0000000..39231c5 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/admin/distributionstatistics/vo/DistributionStatisticsSaveReqVO.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.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 DistributionStatisticsSaveReqVO { + + @Schema(description = "id主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25196") + private Long id; + + @Schema(description = "会员等级id", example = "19012") + private Long levelId; + + @Schema(description = "会员id", example = "10495") + private Long mebId; + + @Schema(description = "推荐记录id", example = "5711") + private Long logId; + + @Schema(description = "推荐人id", example = "2750") + private Long referrerId; + + @Schema(description = "分佣结算核销状态", example = "1") + private String status; + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionconfig/DistributionConfigConvert.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionconfig/DistributionConfigConvert.java new file mode 100644 index 0000000..747c5ca --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionconfig/DistributionConfigConvert.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.member.convert.distributionconfig; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.DistributionConfigRespVO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; + +@Mapper +public interface DistributionConfigConvert { + DistributionConfigConvert INSTANCE = Mappers.getMapper(DistributionConfigConvert.class); + + default PageResult convertPage(PageResult page, + List levels + , List spuList) { + PageResult pageResult = convertPage(page); + Map levelMap = convertMap(levels, MemberLevelRespDTO::getId, MemberLevelRespDTO::getName); + // 拼接关联属性 + Map spuMap = convertMap(spuList, ProductSpuRespDTO::getId); + // 拼接数据 + pageResult.getList().forEach(record ->{ + findAndThen(spuMap, record.getProductId(), spu -> { + record.setSupName(spu.getName()); + }); + MapUtils.findAndThen(levelMap, record.getLevelId(), + level -> record.setLevelName(levelMap.get(record.getLevelId()))); + }); + return pageResult; + } + PageResult convertPage(PageResult page); +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionlog/DistributionLogConvert.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionlog/DistributionLogConvert.java new file mode 100644 index 0000000..1e62cc3 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionlog/DistributionLogConvert.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.member.convert.distributionlog; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.DistributionConfigRespVO; +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.DistributionLogRespVO; +import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordRespVO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; +import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; +import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; + +@Mapper +public interface DistributionLogConvert { + DistributionLogConvert INSTANCE = Mappers.getMapper(DistributionLogConvert.class); + + default PageResult convertPage(PageResult pageResult, List users) { + PageResult voPageResult = convertPage(pageResult); + // user 拼接 + Map userMap = convertMap(users, MemberUserDO::getId); + voPageResult.getList().forEach(record -> MapUtils.findAndThen(userMap, record.getMebId(), + memberUserRespDTO -> record.setNickname(memberUserRespDTO.getNickname()).setUserName(memberUserRespDTO.getName()).setPhone(memberUserRespDTO.getMobile()))); + return voPageResult; + } + PageResult convertPage(PageResult page); +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionstatistics/DistributionStatisticsConvert.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionstatistics/DistributionStatisticsConvert.java new file mode 100644 index 0000000..dacb5c2 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/distributionstatistics/DistributionStatisticsConvert.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.member.convert.distributionstatistics; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; +import cn.iocoder.yudao.module.member.api.level.dto.MemberLevelRespDTO; +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.DistributionConfigRespVO; +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.DistributionLogRespVO; +import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.DistributionStatisticsRespVO; +import cn.iocoder.yudao.module.member.convert.distributionlog.DistributionLogConvert; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; +import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; +import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; +import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; + +@Mapper +public interface DistributionStatisticsConvert { + DistributionStatisticsConvert INSTANCE = Mappers.getMapper(DistributionStatisticsConvert.class); + + default PageResult convertPage(PageResult pageResult, List users,List levels) { + PageResult voPageResult = convertPage(pageResult); + // user 拼接 + Map userMap = convertMap(users, MemberUserDO::getId); + Map levelMap = convertMap(levels, MemberLevelRespDTO::getId, MemberLevelRespDTO::getName); + voPageResult.getList().forEach(record -> { + MapUtils.findAndThen(userMap, record.getMebId(), + memberUserRespDTO -> record.setNickname(memberUserRespDTO.getNickname()).setUserName(memberUserRespDTO.getName()).setPhone(memberUserRespDTO.getMobile())); + MapUtils.findAndThen(levelMap, record.getLevelId(), + level -> record.setLevelName(levelMap.get(record.getLevelId()))); + }); + return voPageResult; + } + PageResult convertPage(PageResult page); +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionConfigDO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionConfigDO.java new file mode 100644 index 0000000..fe8710e --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionConfigDO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 分销配置 DO + * + * @author 芋道源码 + */ +@TableName("member_distribution_config") +@KeySequence("member_distribution_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DistributionConfigDO extends BaseDO { + + /** + * id主键 + */ + @TableId + private Long id; + /** + * 分销商品id + */ + private Long productId; + /** + * 启用状态 + */ + private String status; + /** + * 购买人提升会员等级 + */ + private Long levelId; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionMebConfigDO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionMebConfigDO.java new file mode 100644 index 0000000..696e490 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionconfig/DistributionMebConfigDO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 分销配置关联会员等级 DO + * + * @author 芋道源码 + */ +@TableName("member_distribution_meb_config") +@KeySequence("member_distribution_meb_config_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DistributionMebConfigDO extends BaseDO { + + /** + * id主键 + */ + @TableId + private Long id; + /** + * 分销配置id + */ + private Long configId; + /** + * 会员等级 + */ + private Long levelId; + /** + * 佣金 + */ + private Integer brokerage; + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionlog/DistributionLogDO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionlog/DistributionLogDO.java new file mode 100644 index 0000000..3dcb22e --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionlog/DistributionLogDO.java @@ -0,0 +1,63 @@ +package cn.iocoder.yudao.module.member.dal.dataobject.distributionlog; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 分销记录 DO + * + * @author 芋道源码 + */ +@TableName("member_distribution_log") +@KeySequence("member_distribution_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DistributionLogDO extends BaseDO { + + /** + * id主键 + */ + @TableId + private Long id; + /** + * 推荐人id + */ + private Long referrerId; + /** + * 推荐人id(便于回溯) + */ + private Long oldReferrerId; + /** + * 购买人id + */ + private Long mebId; + /** + * 佣金 + */ + private Integer brokerage; + /** + * 分佣结算核销状态 + */ + private String status; + /** + * 游戏状态 + */ + private String gameStatus; + /** + * 游戏兑换状态 + */ + private String convertStatus; + /** + * 推荐人会员等级id + */ + private Long levelId; + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionstatistics/DistributionStatisticsDO.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionstatistics/DistributionStatisticsDO.java new file mode 100644 index 0000000..0b1c8e7 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/distributionstatistics/DistributionStatisticsDO.java @@ -0,0 +1,51 @@ +package cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 分销统计 DO + * + * @author 芋道源码 + */ +@TableName("member_distribution_statistics") +@KeySequence("member_distribution_statistics_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DistributionStatisticsDO extends BaseDO { + + /** + * id主键 + */ + @TableId + private Long id; + /** + * 会员等级id + */ + private Long levelId; + /** + * 会员id + */ + private Long mebId; + /** + * 推荐记录id + */ + private Long logId; + /** + * 推荐人id + */ + private Long referrerId; + /** + * 分佣结算核销状态 + */ + private String status; + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionConfigMapper.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionConfigMapper.java new file mode 100644 index 0000000..6193d03 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionConfigMapper.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.member.dal.mysql.distributionconfig; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*; + +/** + * 分销配置 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface DistributionConfigMapper extends BaseMapperX { + + default PageResult selectPage(DistributionConfigPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(DistributionConfigDO::getProductId, reqVO.getProductId()) + .eqIfPresent(DistributionConfigDO::getStatus, reqVO.getStatus()) + .betweenIfPresent(DistributionConfigDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(DistributionConfigDO::getId)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionMebConfigMapper.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionMebConfigMapper.java new file mode 100644 index 0000000..5d1f7d7 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionconfig/DistributionMebConfigMapper.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.member.dal.mysql.distributionconfig; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 分销配置关联会员等级 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface DistributionMebConfigMapper extends BaseMapperX { + + default List selectListByConfigId(Long configId) { + return selectList(DistributionMebConfigDO::getConfigId, configId); + } + + default int deleteByConfigId(Long configId) { + return delete(DistributionMebConfigDO::getConfigId, configId); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionlog/DistributionLogMapper.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionlog/DistributionLogMapper.java new file mode 100644 index 0000000..ea5c7c2 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionlog/DistributionLogMapper.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.member.dal.mysql.distributionlog; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*; + +/** + * 分销记录 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface DistributionLogMapper extends BaseMapperX { + + default PageResult selectPage(DistributionLogPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(DistributionLogDO::getReferrerId, reqVO.getReferrerId()) + .eqIfPresent(DistributionLogDO::getOldReferrerId, reqVO.getOldReferrerId()) + .eqIfPresent(DistributionLogDO::getMebId, reqVO.getMebId()) + .eqIfPresent(DistributionLogDO::getBrokerage, reqVO.getBrokerage()) + .eqIfPresent(DistributionLogDO::getStatus, reqVO.getStatus()) + .eqIfPresent(DistributionLogDO::getGameStatus, reqVO.getGameStatus()) + .eqIfPresent(DistributionLogDO::getConvertStatus, reqVO.getConvertStatus()) + .eqIfPresent(DistributionLogDO::getLevelId, reqVO.getLevelId()) + .betweenIfPresent(DistributionLogDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(DistributionLogDO::getId)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionstatistics/DistributionStatisticsMapper.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionstatistics/DistributionStatisticsMapper.java new file mode 100644 index 0000000..24fea50 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/distributionstatistics/DistributionStatisticsMapper.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.member.dal.mysql.distributionstatistics; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.yulichang.wrapper.MPJLambdaWrapper; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +/** + * 分销统计 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface DistributionStatisticsMapper extends BaseMapperX { + + default PageResult selectPage(DistributionStatisticsPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(DistributionStatisticsDO::getLevelId, reqVO.getLevelId()) + .eqIfPresent(DistributionStatisticsDO::getMebId, reqVO.getMebId()) + .eqIfPresent(DistributionStatisticsDO::getLogId, reqVO.getLogId()) + .eqIfPresent(DistributionStatisticsDO::getReferrerId, reqVO.getReferrerId()) + .eqIfPresent(DistributionStatisticsDO::getStatus, reqVO.getStatus()) + .betweenIfPresent(DistributionStatisticsDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(DistributionStatisticsDO::getId)); + } + @Select({""}) + IPage selectPage1(IPage page, @Param("status") String status); + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigService.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigService.java new file mode 100644 index 0000000..cd98e17 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigService.java @@ -0,0 +1,66 @@ +package cn.iocoder.yudao.module.member.service.distributionconfig; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO; + +/** + * 分销配置 Service 接口 + * + * @author 芋道源码 + */ +public interface DistributionConfigService { + + /** + * 创建分销配置 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createDistributionConfig(@Valid DistributionConfigSaveReqVO createReqVO); + + /** + * 更新分销配置 + * + * @param updateReqVO 更新信息 + */ + void updateDistributionConfig(@Valid DistributionConfigSaveReqVO updateReqVO); + + /** + * 删除分销配置 + * + * @param id 编号 + */ + void deleteDistributionConfig(Long id); + + /** + * 获得分销配置 + * + * @param id 编号 + * @return 分销配置 + */ + DistributionConfigDO getDistributionConfig(Long id); + + /** + * 获得分销配置分页 + * + * @param pageReqVO 分页查询 + * @return 分销配置分页 + */ + PageResult getDistributionConfigPage(DistributionConfigPageReqVO pageReqVO); + + // ==================== 子表(分销配置关联会员等级) ==================== + + /** + * 获得分销配置关联会员等级列表 + * + * @param configId 分销配置id + * @return 分销配置关联会员等级列表 + */ + List getDistributionMebConfigListByConfigId(Long configId); + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImpl.java new file mode 100644 index 0000000..49fb2fb --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImpl.java @@ -0,0 +1,112 @@ +package cn.iocoder.yudao.module.member.service.distributionconfig; + +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO; +import cn.iocoder.yudao.module.member.dal.mysql.distributionconfig.DistributionMebConfigMapper; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.member.dal.mysql.distributionconfig.DistributionConfigMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; + +/** + * 分销配置 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class DistributionConfigServiceImpl implements DistributionConfigService { + + @Resource + private DistributionConfigMapper distributionConfigMapper; + @Resource + private DistributionMebConfigMapper distributionMebConfigMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public Long createDistributionConfig(DistributionConfigSaveReqVO createReqVO) { + // 插入 + DistributionConfigDO distributionConfig = BeanUtils.toBean(createReqVO, DistributionConfigDO.class); + distributionConfigMapper.insert(distributionConfig); + + // 插入子表 + createDistributionMebConfigList(distributionConfig.getId(), createReqVO.getDistributionMebConfigs()); + // 返回 + return distributionConfig.getId(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updateDistributionConfig(DistributionConfigSaveReqVO updateReqVO) { + // 校验存在 + validateDistributionConfigExists(updateReqVO.getId()); + // 更新 + DistributionConfigDO updateObj = BeanUtils.toBean(updateReqVO, DistributionConfigDO.class); + distributionConfigMapper.updateById(updateObj); + + // 更新子表 + updateDistributionMebConfigList(updateReqVO.getId(), updateReqVO.getDistributionMebConfigs()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteDistributionConfig(Long id) { + // 校验存在 + validateDistributionConfigExists(id); + // 删除 + distributionConfigMapper.deleteById(id); + + // 删除子表 + deleteDistributionMebConfigByConfigId(id); + } + + private void validateDistributionConfigExists(Long id) { + if (distributionConfigMapper.selectById(id) == null) { + throw exception(DISTRIBUTION_CONFIG_NOT_EXISTS); + } + } + + @Override + public DistributionConfigDO getDistributionConfig(Long id) { + return distributionConfigMapper.selectById(id); + } + + @Override + public PageResult getDistributionConfigPage(DistributionConfigPageReqVO pageReqVO) { + return distributionConfigMapper.selectPage(pageReqVO); + } + + // ==================== 子表(分销配置关联会员等级) ==================== + + @Override + public List getDistributionMebConfigListByConfigId(Long configId) { + return distributionMebConfigMapper.selectListByConfigId(configId); + } + + private void createDistributionMebConfigList(Long configId, List list) { + list.forEach(o -> o.setConfigId(configId)); + distributionMebConfigMapper.insertBatch(list); + } + + private void updateDistributionMebConfigList(Long configId, List list) { + deleteDistributionMebConfigByConfigId(configId); + list.forEach(o -> o.setId(null).setUpdater(null).setUpdateTime(null)); // 解决更新情况下:1)id 冲突;2)updateTime 不更新 + createDistributionMebConfigList(configId, list); + } + + private void deleteDistributionMebConfigByConfigId(Long configId) { + distributionMebConfigMapper.deleteByConfigId(configId); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogService.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogService.java new file mode 100644 index 0000000..598c6ec --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogService.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.member.service.distributionlog; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 分销记录 Service 接口 + * + * @author 芋道源码 + */ +public interface DistributionLogService { + + /** + * 创建分销记录 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createDistributionLog(@Valid DistributionLogSaveReqVO createReqVO); + + /** + * 更新分销记录 + * + * @param updateReqVO 更新信息 + */ + void updateDistributionLog(@Valid DistributionLogSaveReqVO updateReqVO); + + /** + * 删除分销记录 + * + * @param id 编号 + */ + void deleteDistributionLog(Long id); + + /** + * 获得分销记录 + * + * @param id 编号 + * @return 分销记录 + */ + DistributionLogDO getDistributionLog(Long id); + + /** + * 获得分销记录分页 + * + * @param pageReqVO 分页查询 + * @return 分销记录分页 + */ + PageResult getDistributionLogPage(DistributionLogPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImpl.java new file mode 100644 index 0000000..b0d2283 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImpl.java @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.member.service.distributionlog; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.member.dal.mysql.distributionlog.DistributionLogMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; + +/** + * 分销记录 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class DistributionLogServiceImpl implements DistributionLogService { + + @Resource + private DistributionLogMapper distributionLogMapper; + + @Override + public Long createDistributionLog(DistributionLogSaveReqVO createReqVO) { + // 插入 + DistributionLogDO distributionLog = BeanUtils.toBean(createReqVO, DistributionLogDO.class); + distributionLogMapper.insert(distributionLog); + // 返回 + return distributionLog.getId(); + } + + @Override + public void updateDistributionLog(DistributionLogSaveReqVO updateReqVO) { + // 校验存在 + validateDistributionLogExists(updateReqVO.getId()); + // 更新 + DistributionLogDO updateObj = BeanUtils.toBean(updateReqVO, DistributionLogDO.class); + distributionLogMapper.updateById(updateObj); + } + + @Override + public void deleteDistributionLog(Long id) { + // 校验存在 + validateDistributionLogExists(id); + // 删除 + distributionLogMapper.deleteById(id); + } + + private void validateDistributionLogExists(Long id) { + if (distributionLogMapper.selectById(id) == null) { + throw exception(DISTRIBUTION_LOG_NOT_EXISTS); + } + } + + @Override + public DistributionLogDO getDistributionLog(Long id) { + return distributionLogMapper.selectById(id); + } + + @Override + public PageResult getDistributionLogPage(DistributionLogPageReqVO pageReqVO) { + return distributionLogMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsService.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsService.java new file mode 100644 index 0000000..3c72f2a --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsService.java @@ -0,0 +1,68 @@ +package cn.iocoder.yudao.module.member.service.distributionstatistics; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 分销统计 Service 接口 + * + * @author 芋道源码 + */ +public interface DistributionStatisticsService { + + /** + * 创建分销统计 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createDistributionStatistics(@Valid DistributionStatisticsSaveReqVO createReqVO); + + /** + * 更新分销统计 + * + * @param updateReqVO 更新信息 + */ + void updateDistributionStatistics(@Valid DistributionStatisticsSaveReqVO updateReqVO); + /** + * 更新分销统计 + * + * @param updateReqVO 更新信息 + */ + void updateAlready(@Valid DistributionStatisticsSaveReqVO updateReqVO); + + /** + * 删除分销统计 + * + * @param id 编号 + */ + void deleteDistributionStatistics(Long id); + + /** + * 获得分销统计 + * + * @param id 编号 + * @return 分销统计 + */ + DistributionStatisticsDO getDistributionStatistics(Long id); + + /** + * 获得分销统计分页 + * + * @param pageReqVO 分页查询 + * @return 分销统计分页 + */ + PageResult getDistributionStatisticsPage(DistributionStatisticsPageReqVO pageReqVO); + /** + * 获得分销统计分页 + * + * @param pageReqVO 分页查询 + * @return 分销统计分页 + */ + PageResult getDistributionStatisticsPage1(DistributionStatisticsPageReqVO pageReqVO); + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImpl.java new file mode 100644 index 0000000..8d474e6 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImpl.java @@ -0,0 +1,96 @@ +package cn.iocoder.yudao.module.member.service.distributionstatistics; + +import cn.hutool.core.util.ArrayUtil; +import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; +import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByPriceRespVO; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.member.dal.mysql.distributionstatistics.DistributionStatisticsMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; + +/** + * 分销统计 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class DistributionStatisticsServiceImpl implements DistributionStatisticsService { + + @Resource + private DistributionStatisticsMapper distributionStatisticsMapper; + + @Override + public Long createDistributionStatistics(DistributionStatisticsSaveReqVO createReqVO) { + // 插入 + DistributionStatisticsDO distributionStatistics = BeanUtils.toBean(createReqVO, DistributionStatisticsDO.class); + distributionStatisticsMapper.insert(distributionStatistics); + // 返回 + return distributionStatistics.getId(); + } + + @Override + public void updateDistributionStatistics(DistributionStatisticsSaveReqVO updateReqVO) { + // 校验存在 + validateDistributionStatisticsExists(updateReqVO.getId()); + // 更新 + DistributionStatisticsDO updateObj = BeanUtils.toBean(updateReqVO, DistributionStatisticsDO.class); + distributionStatisticsMapper.updateById(updateObj); + } + + @Override + public void updateAlready(DistributionStatisticsSaveReqVO updateReqVO) { + // 结算 + distributionStatisticsMapper.update(new UpdateWrapper().lambda().set(DistributionStatisticsDO::getStatus,0).eq(DistributionStatisticsDO::getMebId,updateReqVO.getMebId()).eq(DistributionStatisticsDO::getLevelId,updateReqVO.getLevelId())); + } + + @Override + public void deleteDistributionStatistics(Long id) { + // 校验存在 + validateDistributionStatisticsExists(id); + // 删除 + distributionStatisticsMapper.deleteById(id); + } + + private void validateDistributionStatisticsExists(Long id) { + if (distributionStatisticsMapper.selectById(id) == null) { + throw exception(DISTRIBUTION_STATISTICS_NOT_EXISTS); + } + } + + @Override + public DistributionStatisticsDO getDistributionStatistics(Long id) { + return distributionStatisticsMapper.selectById(id); + } + + @Override + public PageResult getDistributionStatisticsPage(DistributionStatisticsPageReqVO pageReqVO) { + return distributionStatisticsMapper.selectPage(pageReqVO); + } + + @Override + public PageResult getDistributionStatisticsPage1(DistributionStatisticsPageReqVO pageReqVO) { + IPage pageResult = distributionStatisticsMapper.selectPage1( + MyBatisUtils.buildPage(pageReqVO), + pageReqVO.getStatus()); + return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); +// return distributionStatisticsMapper.selectPage1(pageReqVO); + } + +} diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java index 23aeaf8..3f22993 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserService.java @@ -200,5 +200,14 @@ public interface MemberUserService { * @return 更新结果 */ void updateUserUpgradesLevel(Long userId); + /** + * 商品回调 + * + * @param userId 用户编号 + * @param orderId 订单id + * @param productId 商品id + * @return 更新结果 + */ + void updateUserUpgradesLevelcallback(Long orderId); } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java index 189cd8e..f47e8bb 100644 --- a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/user/MemberUserServiceImpl.java @@ -14,8 +14,16 @@ import cn.iocoder.yudao.module.member.controller.admin.user.vo.MemberUserUpdateR import cn.iocoder.yudao.module.member.controller.app.user.vo.*; import cn.iocoder.yudao.module.member.convert.auth.AuthConvert; import cn.iocoder.yudao.module.member.convert.user.MemberUserConvert; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionMebConfigDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; import cn.iocoder.yudao.module.member.dal.dataobject.level.MemberLevelDO; import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO; +import cn.iocoder.yudao.module.member.dal.mysql.distributionconfig.DistributionConfigMapper; +import cn.iocoder.yudao.module.member.dal.mysql.distributionconfig.DistributionMebConfigMapper; +import cn.iocoder.yudao.module.member.dal.mysql.distributionlog.DistributionLogMapper; +import cn.iocoder.yudao.module.member.dal.mysql.distributionstatistics.DistributionStatisticsMapper; import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelMapper; import cn.iocoder.yudao.module.member.dal.mysql.level.MemberLevelRecordMapper; import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper; @@ -25,11 +33,17 @@ import cn.iocoder.yudao.module.system.api.sms.dto.code.SmsCodeUseReqDTO; import cn.iocoder.yudao.module.system.api.social.SocialClientApi; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxPhoneNumberInfoRespDTO; import cn.iocoder.yudao.module.system.enums.sms.SmsSceneEnum; +import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; +import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageRecordDO; import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; +import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; +import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageRecordMapper; import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageUserMapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; import com.google.common.annotations.VisibleForTesting; import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Lazy; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -40,6 +54,7 @@ import javax.annotation.Resource; import javax.validation.Valid; import java.time.LocalDateTime; import java.util.Collection; +import java.util.Date; import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -79,6 +94,24 @@ public class MemberUserServiceImpl implements MemberUserService { @Resource private BrokerageUserMapper brokerageUserMapper; + @Resource + private TradeOrderItemMapper tradeOrderItemMapper; + + @Resource + @Lazy + private TradeOrderApi tradeOrderApi; + + @Resource + private DistributionConfigMapper distributionConfigMapper; + + @Resource + private BrokerageRecordMapper brokerageRecordMapper; + @Resource + private DistributionMebConfigMapper distributionMebConfigMapper; + @Resource + private DistributionLogMapper distributionLogMapper; + @Resource + private DistributionStatisticsMapper distributionStatisticsMapper; @Override public MemberUserDO getUserByMobile(String mobile) { @@ -353,15 +386,140 @@ public class MemberUserServiceImpl implements MemberUserService { } @Override public void updateUserUpgradesLevel(Long userId) { - recursionMemberLevel(userId); -// if(i>0){ -// return true; -// } } - private void recursionMemberLevel(Long userId){ + @Override + public void updateUserUpgradesLevelcallback(Long orderId) { + //查询订单信息 + Long productId = null; + List tradeOrderItemDOS = tradeOrderItemMapper.selectListByOrderId(orderId); + if(ObjectUtil.isNotEmpty(tradeOrderItemDOS)){ + productId = tradeOrderItemDOS.get(0).getSpuId(); + } + TradeOrderRespDTO order = tradeOrderApi.getOrder(orderId); + Long userId = order.getUserId(); + + //判断订单是否已支付 + //根据商品id查询配置规则 + List distributionConfigDOS = distributionConfigMapper.selectList(new LambdaQueryWrapperX() + .eq(DistributionConfigDO::getProductId, productId) + .eq(DistributionConfigDO::getDeleted, 0) + .eq(DistributionConfigDO::getStatus, 0) + .orderByDesc(DistributionConfigDO::getCreateTime)); + if(ObjectUtil.isNotEmpty(distributionConfigDOS)){ + DistributionConfigDO distributionConfigDO = distributionConfigDOS.get(0); + //查询会员当前等级 + MemberUserDO user = memberUserMapper.selectById(userId); + MemberLevelDO memberLevelDO = memberLevelMapper.selectById(user.getLevelId()); + //查询推广员配置信息 + MemberLevelDO configLevelDO = memberLevelMapper.selectById(distributionConfigDO.getLevelId()); + if(ObjectUtil.isEmpty(memberLevelDO)){ + //修改购买人会员等级 + int i = memberUserMapper.updateById(new MemberUserDO() + .setId(userId) + .setLevelId(distributionConfigDO.getLevelId()) + ); + brokerageUserMapper.updateById(new BrokerageUserDO() + .setId(userId) + .setLevel(configLevelDO.getLevel()) + ); + }else{ + if(memberLevelDO.getLevel() distributionMebConfigDOS = distributionMebConfigMapper.selectList(new LambdaQueryWrapperX() + .eq(DistributionMebConfigDO::getConfigId, distributionConfigDO.getId()) + .eq(DistributionMebConfigDO::getDeleted, 0) + .orderByAsc(DistributionMebConfigDO::getLevelId)); + //添加5占一 + if(ObjectUtil.isNotEmpty(distributionMebConfigDOS)){ + //添加5占一游戏 + DistributionLogDO distributionLogDO = new DistributionLogDO(); + distributionLogDO.setMebId(userId); + distributionLogDO.setStatus("1"); +// distributionLogDO.setBrokerage(); + distributionLogDO.setGameStatus("1"); + distributionLogDO.setConvertStatus("1"); + distributionLogMapper.insert(distributionLogDO); + //查询5占一总数 + List distributionLogDOS = distributionLogMapper.selectList(new LambdaQueryWrapperX() + .orderByAsc(DistributionLogDO::getCreateTime)); + int i1 = distributionLogDOS.size() % 5; + if(i1 == 0){ +// DistributionLogDO vo = distributionLogDOS.get((distributionLogDOS.size()/5)-1); +// vo.setGameStatus("0"); +// distributionLogMapper.updateById(vo); + List distributionLogDOS1 = distributionLogDOS.subList(0, (distributionLogDOS.size() / 5)); + for (DistributionLogDO dt:distributionLogDOS1) { + dt.setGameStatus("0"); + } + distributionLogMapper.updateBatch(distributionLogDOS1); +// distributionLogMapper.up + } + } + + //发放直销奖励 + //查询推广员 + BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId); + if(ObjectUtil.isNotEmpty(brokerageUserDO)){ + if(ObjectUtil.isNotEmpty(brokerageUserDO.getBindUserId())){ + //查询推广员会员信息 + MemberUserDO memberUserDO = memberUserMapper.selectById(brokerageUserDO.getBindUserId()); + if(ObjectUtil.isNotEmpty(memberUserDO)){ + if(ObjectUtil.isNotEmpty(distributionMebConfigDOS)){ + for (DistributionMebConfigDO eg :distributionMebConfigDOS) { + if(eg.getLevelId() == memberUserDO.getLevelId()){ + //添加佣金记录 + BrokerageRecordDO brokerageRecordDO = new BrokerageRecordDO(); + brokerageRecordDO.setUserId(memberUserDO.getId()); + brokerageRecordDO.setBizType(1); + brokerageRecordDO.setTitle("分销直推佣金"); + brokerageRecordDO.setPrice(eg.getBrokerage()*100); + //查询当前总佣金 + Integer totalPrice = 0; + List brokerageRecordDOS = brokerageRecordMapper.selectList(new LambdaQueryWrapperX() + .eq(BrokerageRecordDO::getUserId, memberUserDO.getId()) + .eq(BrokerageRecordDO::getDeleted, 0) + .orderByDesc(BrokerageRecordDO::getCreateTime)); + if(ObjectUtil.isNotEmpty(brokerageRecordDOS)){ + totalPrice = brokerageRecordDOS.get(0).getTotalPrice(); + } + brokerageRecordDO.setTotalPrice(totalPrice+eg.getBrokerage()*100);//当前总佣金 + brokerageRecordDO.setStatus(1); + brokerageRecordDO.setSourceUserLevel(configLevelDO.getLevel()); + brokerageRecordDO.setSourceUserId(userId); + brokerageRecordMapper.insert(brokerageRecordDO); + break; + } + } + } + recursionMemberLevel(brokerageUserDO.getId(),orderId); + } + } + } + } + } + + private void recursionMemberLevel(Long userId,Long orderId){ //查询会员信息 MemberUserDO memberUserDO = memberUserMapper.selectById(userId); + DistributionStatisticsDO distributionStatisticsDO = new DistributionStatisticsDO(); + distributionStatisticsDO.setLevelId(memberUserDO.getLevelId()); + distributionStatisticsDO.setMebId(memberUserDO.getId()); + distributionStatisticsDO.setLogId(orderId); + distributionStatisticsDO.setStatus("1"); + distributionStatisticsMapper.insert(distributionStatisticsDO); //查询会员当前等级 MemberLevelDO memberLevelDO = memberLevelMapper.selectById(memberUserDO.getLevelId()); if(ObjectUtil.isNotEmpty(memberLevelDO)){ @@ -372,28 +530,14 @@ public class MemberUserServiceImpl implements MemberUserService { .eq(MemberLevelDO::getLevel, (memberLevelDO.getLevel()+1)) .orderByAsc(MemberLevelDO::getLevel)); if(ObjectUtil.isNotEmpty(upLevelDO)){ - if(ObjectUtil.equal(memberLevelDO.getLevel(),1)){//帮扶人升级帮扶员 - //添加分润 - //升级会员 - //修改会员等级 - memberUserMapper.updateById(new MemberUserDO() - .setId(userId) - .setLevelId(upLevelDO.getId()) - ); - //修改邀请记录等级 - brokerageUserMapper.updateById(new BrokerageUserDO() - .setId(userId) - .setLevel(upLevelDO.getLevel()) - ); - //判断上级会员是否升级 - BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId); - recursionMemberLevel(brokerageUserDO.getBindUserId()); + if(ObjectUtil.equal(memberLevelDO.getLevel(),1)){//帮扶人不升级 + //添加推荐统计 } - if(ObjectUtil.equal(memberLevelDO.getLevel(),2)){//帮扶员升级帮扶大使 + if(ObjectUtil.equal(memberLevelDO.getLevel(),2)){//帮扶员升级帮扶驿站 //查询会员邀请记录下级会员 List brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX() .eq(BrokerageUserDO::getBindUserId, userId) - .eq(BrokerageUserDO::getLevel, memberLevelDO.getLevel()) + .ge(BrokerageUserDO::getLevel, memberLevelDO.getLevel()) .eq(BrokerageUserDO::getDeleted, 0) ); if(ObjectUtil.isNotEmpty(brokerageUserDOS)){ @@ -411,41 +555,23 @@ public class MemberUserServiceImpl implements MemberUserService { } //判断上级会员是否升级 BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId); - recursionMemberLevel(brokerageUserDO.getBindUserId()); + recursionMemberLevel(brokerageUserDO.getBindUserId(),orderId); } - if(ObjectUtil.equal(memberLevelDO.getLevel(),3)){//帮扶大使升级帮扶中心 + if(ObjectUtil.equal(memberLevelDO.getLevel(),3)){//帮扶驿站升级帮扶中心 //查询会员邀请记录下级会员 List brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX() .eq(BrokerageUserDO::getBindUserId, userId) - .eq(BrokerageUserDO::getLevel, memberLevelDO.getLevel()) + .ge(BrokerageUserDO::getLevel, memberLevelDO.getLevel()) .eq(BrokerageUserDO::getDeleted, 0) ); - if(ObjectUtil.isNotEmpty(brokerageUserDOS)){ - if(brokerageUserDOS.size()>=5){ - //升级会员 - memberUserMapper.updateById(new MemberUserDO() - .setId(userId) - .setLevelId(upLevelDO.getId()) - ); - brokerageUserMapper.updateById(new BrokerageUserDO() - .setId(userId) - .setLevel(upLevelDO.getLevel()) - ); - } - } - //判断上级会员是否升级 - BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId); - recursionMemberLevel(brokerageUserDO.getBindUserId()); - } - if(ObjectUtil.equal(memberLevelDO.getLevel(),4)){//帮扶中心升级帮扶驿站 //查询会员邀请记录下级会员 - List brokerageUserDOS = brokerageUserMapper.selectList(new LambdaQueryWrapperX() + List brokerageUserDOS1 = brokerageUserMapper.selectList(new LambdaQueryWrapperX() .eq(BrokerageUserDO::getBindUserId, userId) - .eq(BrokerageUserDO::getLevel, memberLevelDO.getLevel()) + .ge(BrokerageUserDO::getLevel, 2) .eq(BrokerageUserDO::getDeleted, 0) ); if(ObjectUtil.isNotEmpty(brokerageUserDOS)){ - if(brokerageUserDOS.size()>=10){ + if(brokerageUserDOS.size()>=10 || brokerageUserDOS1.size()>=300){ //升级会员 memberUserMapper.updateById(new MemberUserDO() .setId(userId) @@ -459,10 +585,9 @@ public class MemberUserServiceImpl implements MemberUserService { } //判断上级会员是否升级 BrokerageUserDO brokerageUserDO = brokerageUserMapper.selectById(userId); - recursionMemberLevel(brokerageUserDO.getBindUserId()); + recursionMemberLevel(brokerageUserDO.getBindUserId(),orderId); } - if(ObjectUtil.equal(memberLevelDO.getLevel(),5)){//帮扶驿站---最终级别 - + if(ObjectUtil.equal(memberLevelDO.getLevel(),4)){//帮扶中心不做升级 } } } diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImplTest.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImplTest.java new file mode 100644 index 0000000..cad400e --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionconfig/DistributionConfigServiceImplTest.java @@ -0,0 +1,138 @@ +package cn.iocoder.yudao.module.member.service.distributionconfig; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.member.controller.admin.distributionconfig.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionconfig.DistributionConfigDO; +import cn.iocoder.yudao.module.member.dal.mysql.distributionconfig.DistributionConfigMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link DistributionConfigServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(DistributionConfigServiceImpl.class) +public class DistributionConfigServiceImplTest extends BaseDbUnitTest { + + @Resource + private DistributionConfigServiceImpl distributionConfigService; + + @Resource + private DistributionConfigMapper distributionConfigMapper; + + @Test + public void testCreateDistributionConfig_success() { + // 准备参数 + DistributionConfigSaveReqVO createReqVO = randomPojo(DistributionConfigSaveReqVO.class).setId(null); + + // 调用 + Long distributionConfigId = distributionConfigService.createDistributionConfig(createReqVO); + // 断言 + assertNotNull(distributionConfigId); + // 校验记录的属性是否正确 + DistributionConfigDO distributionConfig = distributionConfigMapper.selectById(distributionConfigId); + assertPojoEquals(createReqVO, distributionConfig, "id"); + } + + @Test + public void testUpdateDistributionConfig_success() { + // mock 数据 + DistributionConfigDO dbDistributionConfig = randomPojo(DistributionConfigDO.class); + distributionConfigMapper.insert(dbDistributionConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + DistributionConfigSaveReqVO updateReqVO = randomPojo(DistributionConfigSaveReqVO.class, o -> { + o.setId(dbDistributionConfig.getId()); // 设置更新的 ID + }); + + // 调用 + distributionConfigService.updateDistributionConfig(updateReqVO); + // 校验是否更新正确 + DistributionConfigDO distributionConfig = distributionConfigMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, distributionConfig); + } + + @Test + public void testUpdateDistributionConfig_notExists() { + // 准备参数 + DistributionConfigSaveReqVO updateReqVO = randomPojo(DistributionConfigSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> distributionConfigService.updateDistributionConfig(updateReqVO), DISTRIBUTION_CONFIG_NOT_EXISTS); + } + + @Test + public void testDeleteDistributionConfig_success() { + // mock 数据 + DistributionConfigDO dbDistributionConfig = randomPojo(DistributionConfigDO.class); + distributionConfigMapper.insert(dbDistributionConfig);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbDistributionConfig.getId(); + + // 调用 + distributionConfigService.deleteDistributionConfig(id); + // 校验数据不存在了 + assertNull(distributionConfigMapper.selectById(id)); + } + + @Test + public void testDeleteDistributionConfig_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> distributionConfigService.deleteDistributionConfig(id), DISTRIBUTION_CONFIG_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetDistributionConfigPage() { + // mock 数据 + DistributionConfigDO dbDistributionConfig = randomPojo(DistributionConfigDO.class, o -> { // 等会查询到 + o.setProductId(null); + o.setStatus(null); + o.setCreateTime(null); + }); + distributionConfigMapper.insert(dbDistributionConfig); + // 测试 productId 不匹配 + distributionConfigMapper.insert(cloneIgnoreId(dbDistributionConfig, o -> o.setProductId(null))); + // 测试 status 不匹配 + distributionConfigMapper.insert(cloneIgnoreId(dbDistributionConfig, o -> o.setStatus(null))); + // 测试 createTime 不匹配 + distributionConfigMapper.insert(cloneIgnoreId(dbDistributionConfig, o -> o.setCreateTime(null))); + // 准备参数 + DistributionConfigPageReqVO reqVO = new DistributionConfigPageReqVO(); + reqVO.setProductId(null); + reqVO.setStatus(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = distributionConfigService.getDistributionConfigPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbDistributionConfig, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImplTest.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImplTest.java new file mode 100644 index 0000000..1ce9387 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionlog/DistributionLogServiceImplTest.java @@ -0,0 +1,162 @@ +package cn.iocoder.yudao.module.member.service.distributionlog; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.member.controller.admin.distributionlog.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionlog.DistributionLogDO; +import cn.iocoder.yudao.module.member.dal.mysql.distributionlog.DistributionLogMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link DistributionLogServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(DistributionLogServiceImpl.class) +public class DistributionLogServiceImplTest extends BaseDbUnitTest { + + @Resource + private DistributionLogServiceImpl distributionLogService; + + @Resource + private DistributionLogMapper distributionLogMapper; + + @Test + public void testCreateDistributionLog_success() { + // 准备参数 + DistributionLogSaveReqVO createReqVO = randomPojo(DistributionLogSaveReqVO.class).setId(null); + + // 调用 + Long distributionLogId = distributionLogService.createDistributionLog(createReqVO); + // 断言 + assertNotNull(distributionLogId); + // 校验记录的属性是否正确 + DistributionLogDO distributionLog = distributionLogMapper.selectById(distributionLogId); + assertPojoEquals(createReqVO, distributionLog, "id"); + } + + @Test + public void testUpdateDistributionLog_success() { + // mock 数据 + DistributionLogDO dbDistributionLog = randomPojo(DistributionLogDO.class); + distributionLogMapper.insert(dbDistributionLog);// @Sql: 先插入出一条存在的数据 + // 准备参数 + DistributionLogSaveReqVO updateReqVO = randomPojo(DistributionLogSaveReqVO.class, o -> { + o.setId(dbDistributionLog.getId()); // 设置更新的 ID + }); + + // 调用 + distributionLogService.updateDistributionLog(updateReqVO); + // 校验是否更新正确 + DistributionLogDO distributionLog = distributionLogMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, distributionLog); + } + + @Test + public void testUpdateDistributionLog_notExists() { + // 准备参数 + DistributionLogSaveReqVO updateReqVO = randomPojo(DistributionLogSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> distributionLogService.updateDistributionLog(updateReqVO), DISTRIBUTION_LOG_NOT_EXISTS); + } + + @Test + public void testDeleteDistributionLog_success() { + // mock 数据 + DistributionLogDO dbDistributionLog = randomPojo(DistributionLogDO.class); + distributionLogMapper.insert(dbDistributionLog);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbDistributionLog.getId(); + + // 调用 + distributionLogService.deleteDistributionLog(id); + // 校验数据不存在了 + assertNull(distributionLogMapper.selectById(id)); + } + + @Test + public void testDeleteDistributionLog_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> distributionLogService.deleteDistributionLog(id), DISTRIBUTION_LOG_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetDistributionLogPage() { + // mock 数据 + DistributionLogDO dbDistributionLog = randomPojo(DistributionLogDO.class, o -> { // 等会查询到 + o.setReferrerId(null); + o.setOldReferrerId(null); + o.setMebId(null); + o.setBrokerage(null); + o.setStatus(null); + o.setGameStatus(null); + o.setConvertStatus(null); + o.setLevelId(null); + o.setCreateTime(null); + }); + distributionLogMapper.insert(dbDistributionLog); + // 测试 referrerId 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setReferrerId(null))); + // 测试 oldReferrerId 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setOldReferrerId(null))); + // 测试 mebId 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setMebId(null))); + // 测试 brokerage 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setBrokerage(null))); + // 测试 status 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setStatus(null))); + // 测试 gameStatus 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setGameStatus(null))); + // 测试 convertStatus 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setConvertStatus(null))); + // 测试 levelId 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setLevelId(null))); + // 测试 createTime 不匹配 + distributionLogMapper.insert(cloneIgnoreId(dbDistributionLog, o -> o.setCreateTime(null))); + // 准备参数 + DistributionLogPageReqVO reqVO = new DistributionLogPageReqVO(); + reqVO.setReferrerId(null); + reqVO.setOldReferrerId(null); + reqVO.setMebId(null); + reqVO.setBrokerage(null); + reqVO.setStatus(null); + reqVO.setGameStatus(null); + reqVO.setConvertStatus(null); + reqVO.setLevelId(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = distributionLogService.getDistributionLogPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbDistributionLog, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImplTest.java b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImplTest.java new file mode 100644 index 0000000..8e92974 --- /dev/null +++ b/ruoyi-vue-pro-master/yudao-module-member/yudao-module-member-biz/src/test/java/cn/iocoder/yudao/module/member/service/distributionstatistics/DistributionStatisticsServiceImplTest.java @@ -0,0 +1,150 @@ +package cn.iocoder.yudao.module.member.service.distributionstatistics; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.member.controller.admin.distributionstatistics.vo.*; +import cn.iocoder.yudao.module.member.dal.dataobject.distributionstatistics.DistributionStatisticsDO; +import cn.iocoder.yudao.module.member.dal.mysql.distributionstatistics.DistributionStatisticsMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link DistributionStatisticsServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(DistributionStatisticsServiceImpl.class) +public class DistributionStatisticsServiceImplTest extends BaseDbUnitTest { + + @Resource + private DistributionStatisticsServiceImpl distributionStatisticsService; + + @Resource + private DistributionStatisticsMapper distributionStatisticsMapper; + + @Test + public void testCreateDistributionStatistics_success() { + // 准备参数 + DistributionStatisticsSaveReqVO createReqVO = randomPojo(DistributionStatisticsSaveReqVO.class).setId(null); + + // 调用 + Long distributionStatisticsId = distributionStatisticsService.createDistributionStatistics(createReqVO); + // 断言 + assertNotNull(distributionStatisticsId); + // 校验记录的属性是否正确 + DistributionStatisticsDO distributionStatistics = distributionStatisticsMapper.selectById(distributionStatisticsId); + assertPojoEquals(createReqVO, distributionStatistics, "id"); + } + + @Test + public void testUpdateDistributionStatistics_success() { + // mock 数据 + DistributionStatisticsDO dbDistributionStatistics = randomPojo(DistributionStatisticsDO.class); + distributionStatisticsMapper.insert(dbDistributionStatistics);// @Sql: 先插入出一条存在的数据 + // 准备参数 + DistributionStatisticsSaveReqVO updateReqVO = randomPojo(DistributionStatisticsSaveReqVO.class, o -> { + o.setId(dbDistributionStatistics.getId()); // 设置更新的 ID + }); + + // 调用 + distributionStatisticsService.updateDistributionStatistics(updateReqVO); + // 校验是否更新正确 + DistributionStatisticsDO distributionStatistics = distributionStatisticsMapper.selectById(updateReqVO.getId()); // 获取最新的 + assertPojoEquals(updateReqVO, distributionStatistics); + } + + @Test + public void testUpdateDistributionStatistics_notExists() { + // 准备参数 + DistributionStatisticsSaveReqVO updateReqVO = randomPojo(DistributionStatisticsSaveReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> distributionStatisticsService.updateDistributionStatistics(updateReqVO), DISTRIBUTION_STATISTICS_NOT_EXISTS); + } + + @Test + public void testDeleteDistributionStatistics_success() { + // mock 数据 + DistributionStatisticsDO dbDistributionStatistics = randomPojo(DistributionStatisticsDO.class); + distributionStatisticsMapper.insert(dbDistributionStatistics);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbDistributionStatistics.getId(); + + // 调用 + distributionStatisticsService.deleteDistributionStatistics(id); + // 校验数据不存在了 + assertNull(distributionStatisticsMapper.selectById(id)); + } + + @Test + public void testDeleteDistributionStatistics_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> distributionStatisticsService.deleteDistributionStatistics(id), DISTRIBUTION_STATISTICS_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetDistributionStatisticsPage() { + // mock 数据 + DistributionStatisticsDO dbDistributionStatistics = randomPojo(DistributionStatisticsDO.class, o -> { // 等会查询到 + o.setLevelId(null); + o.setMebId(null); + o.setLogId(null); + o.setReferrerId(null); + o.setStatus(null); + o.setCreateTime(null); + }); + distributionStatisticsMapper.insert(dbDistributionStatistics); + // 测试 levelId 不匹配 + distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setLevelId(null))); + // 测试 mebId 不匹配 + distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setMebId(null))); + // 测试 logId 不匹配 + distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setLogId(null))); + // 测试 referrerId 不匹配 + distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setReferrerId(null))); + // 测试 status 不匹配 + distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setStatus(null))); + // 测试 createTime 不匹配 + distributionStatisticsMapper.insert(cloneIgnoreId(dbDistributionStatistics, o -> o.setCreateTime(null))); + // 准备参数 + DistributionStatisticsPageReqVO reqVO = new DistributionStatisticsPageReqVO(); + reqVO.setLevelId(null); + reqVO.setMebId(null); + reqVO.setLogId(null); + reqVO.setReferrerId(null); + reqVO.setStatus(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + + // 调用 + PageResult pageResult = distributionStatisticsService.getDistributionStatisticsPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbDistributionStatistics, pageResult.getList().get(0)); + } + +} \ No newline at end of file diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java index b66a71e..69328df 100644 --- a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/notify/PayNotifyController.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.pay.core.client.PayClient; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.refund.PayRefundRespDTO; +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskDetailRespVO; import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskPageReqVO; import cn.iocoder.yudao.module.pay.controller.admin.notify.vo.PayNotifyTaskRespVO; diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java index 95510d5..96c46c9 100644 --- a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/order/PayOrderMapper.java @@ -58,5 +58,8 @@ public interface PayOrderMapper extends BaseMapperX { .eq(PayOrderDO::getStatus, status) .lt(PayOrderDO::getExpireTime, expireTime)); } + default PayOrderDO selectPayOrderDOById(Long id) { + return selectById(id); + } } diff --git a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java index a058b95..fe9d7ec 100644 --- a/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java +++ b/ruoyi-vue-pro-master/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/order/PayOrderServiceImpl.java @@ -12,6 +12,7 @@ import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderRespDTO; import cn.iocoder.yudao.framework.pay.core.client.dto.order.PayOrderUnifiedReqDTO; import cn.iocoder.yudao.framework.pay.core.enums.order.PayOrderStatusRespEnum; import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils; +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderExportReqVO; import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderPageReqVO; @@ -75,6 +76,9 @@ public class PayOrderServiceImpl implements PayOrderService { @Resource private PayNotifyService notifyService; + @Resource + private MemberUserApi memberUserApi; + @Override public PayOrderDO getOrder(Long id) { return orderMapper.selectById(id); @@ -268,6 +272,9 @@ public class PayOrderServiceImpl implements PayOrderService { // 情况一:支付成功的回调 if (PayOrderStatusRespEnum.isSuccess(notify.getStatus())) { notifyOrderSuccess(channel, notify); + PayOrderExtensionDO orderExtension = updateOrderSuccess(notify); + PayOrderDO payOrderDO = orderMapper.selectPayOrderDOById(orderExtension.getOrderId()); + memberUserApi.updateUserUpgradesLevelcallback(Long.valueOf(payOrderDO.getMerchantOrderId())); return; } // 情况二:支付失败的回调