Commit ad0513c87ccd21ef9fd9f2fcd8f074ab42415982
1 parent
ee15b802
分佣: 推广人列表
Showing
6 changed files
with
73 additions
and
12 deletions
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/AppBrokerageUserController.java
| @@ -33,7 +33,6 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | @@ -33,7 +33,6 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 33 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 33 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 34 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | 34 | import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; |
| 35 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | 35 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 36 | -import static java.util.Arrays.asList; | ||
| 37 | 36 | ||
| 38 | @Tag(name = "用户 APP - 分销用户") | 37 | @Tag(name = "用户 APP - 分销用户") |
| 39 | @RestController | 38 | @RestController |
| @@ -113,21 +112,14 @@ public class AppBrokerageUserController { | @@ -113,21 +112,14 @@ public class AppBrokerageUserController { | ||
| 113 | return success(BrokerageRecordConvert.INSTANCE.convertPage03(pageResult, userMap)); | 112 | return success(BrokerageRecordConvert.INSTANCE.convertPage03(pageResult, userMap)); |
| 114 | } | 113 | } |
| 115 | 114 | ||
| 116 | - // TODO 芋艿:临时 mock => | ||
| 117 | @GetMapping("/child-summary-page") | 115 | @GetMapping("/child-summary-page") |
| 118 | @Operation(summary = "获得下级分销统计分页") | 116 | @Operation(summary = "获得下级分销统计分页") |
| 119 | @PreAuthenticated | 117 | @PreAuthenticated |
| 120 | public CommonResult<PageResult<AppBrokerageUserChildSummaryRespVO>> getBrokerageUserChildSummaryPage( | 118 | public CommonResult<PageResult<AppBrokerageUserChildSummaryRespVO>> getBrokerageUserChildSummaryPage( |
| 121 | AppBrokerageUserChildSummaryPageReqVO pageReqVO) { | 119 | AppBrokerageUserChildSummaryPageReqVO pageReqVO) { |
| 122 | - AppBrokerageUserChildSummaryRespVO vo1 = new AppBrokerageUserChildSummaryRespVO() | ||
| 123 | - .setId(1L).setNickname("芋1**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg") | ||
| 124 | - .setBrokeragePrice(10).setBrokeragePrice(20).setBrokerageOrderCount(30) | ||
| 125 | - .setBrokerageTime(LocalDateTime.now()); | ||
| 126 | - AppBrokerageUserChildSummaryRespVO vo2 = new AppBrokerageUserChildSummaryRespVO() | ||
| 127 | - .setId(1L).setNickname("芋2**艿").setAvatar("http://www.iocoder.cn/images/common/wechat_mp_2017_07_31_bak.jpg") | ||
| 128 | - .setBrokeragePrice(20).setBrokeragePrice(30).setBrokerageOrderCount(40) | ||
| 129 | - .setBrokerageTime(LocalDateTime.now()); | ||
| 130 | - return success(new PageResult<>(asList(vo1, vo2), 10L)); | 120 | + // 分页查询 |
| 121 | + PageResult<AppBrokerageUserChildSummaryRespVO> pageResult = brokerageUserService.getBrokerageUserChildSummaryPage(pageReqVO, getLoginUserId()); | ||
| 122 | + return success(pageResult); | ||
| 131 | } | 123 | } |
| 132 | 124 | ||
| 133 | @GetMapping("/get-rank-by-price") | 125 | @GetMapping("/get-rank-by-price") |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/brokerage/vo/user/AppBrokerageUserChildSummaryRespVO.java
| @@ -27,7 +27,7 @@ public class AppBrokerageUserChildSummaryRespVO { | @@ -27,7 +27,7 @@ public class AppBrokerageUserChildSummaryRespVO { | ||
| 27 | @Schema(description = "分销用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") | 27 | @Schema(description = "分销用户数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "30") |
| 28 | private Integer brokerageUserCount; | 28 | private Integer brokerageUserCount; |
| 29 | 29 | ||
| 30 | - @Schema(description = "成为分销员时间", requiredMode = Schema.RequiredMode.REQUIRED) | 30 | + @Schema(description = "绑定推广员的时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 31 | private LocalDateTime brokerageTime; | 31 | private LocalDateTime brokerageTime; |
| 32 | 32 | ||
| 33 | } | 33 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java
| @@ -5,6 +5,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -5,6 +5,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; | 7 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; |
| 8 | +import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryPageReqVO; | ||
| 9 | +import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; | ||
| 8 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; | 10 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; |
| 9 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; | 11 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; |
| 10 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 12 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| @@ -138,4 +140,8 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> { | @@ -138,4 +140,8 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> { | ||
| 138 | IPage<AppBrokerageUserRankByUserCountRespVO> selectCountPageGroupByBindUserId(Page<?> page, | 140 | IPage<AppBrokerageUserRankByUserCountRespVO> selectCountPageGroupByBindUserId(Page<?> page, |
| 139 | @Param("beginTime") LocalDateTime beginTime, | 141 | @Param("beginTime") LocalDateTime beginTime, |
| 140 | @Param("endTime") LocalDateTime endTime); | 142 | @Param("endTime") LocalDateTime endTime); |
| 143 | + | ||
| 144 | + IPage<AppBrokerageUserChildSummaryRespVO> selectSummaryPageByUserId(Page<?> page, | ||
| 145 | + @Param("param") AppBrokerageUserChildSummaryPageReqVO param, | ||
| 146 | + @Param("userId") Long userId); | ||
| 141 | } | 147 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserService.java
| @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.trade.service.brokerage; | @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.trade.service.brokerage; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; | 4 | import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; |
| 5 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; | 5 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; |
| 6 | +import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; | ||
| 6 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; | 8 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; |
| 7 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; | 9 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; |
| 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; | 10 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; |
| @@ -140,4 +142,13 @@ public interface BrokerageUserService { | @@ -140,4 +142,13 @@ public interface BrokerageUserService { | ||
| 140 | * @return 推广人排行 | 142 | * @return 推广人排行 |
| 141 | */ | 143 | */ |
| 142 | PageResult<AppBrokerageUserRankByUserCountRespVO> getBrokerageUserRankPageByUserCount(AppBrokerageUserRankPageReqVO pageReqVO); | 144 | PageResult<AppBrokerageUserRankByUserCountRespVO> getBrokerageUserRankPageByUserCount(AppBrokerageUserRankPageReqVO pageReqVO); |
| 145 | + | ||
| 146 | + /** | ||
| 147 | + * 获得下级分销统计分页 | ||
| 148 | + * | ||
| 149 | + * @param pageReqVO 分页查询 | ||
| 150 | + * @param userId 用户编号 | ||
| 151 | + * @return 下级分销统计分页 | ||
| 152 | + */ | ||
| 153 | + PageResult<AppBrokerageUserChildSummaryRespVO> getBrokerageUserChildSummaryPage(AppBrokerageUserChildSummaryPageReqVO pageReqVO, Long userId); | ||
| 143 | } | 154 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java
| @@ -9,6 +9,8 @@ import cn.hutool.core.util.StrUtil; | @@ -9,6 +9,8 @@ import cn.hutool.core.util.StrUtil; | ||
| 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 9 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 10 | import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; | 10 | import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; |
| 11 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; | 11 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.vo.user.BrokerageUserPageReqVO; |
| 12 | +import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryPageReqVO; | ||
| 13 | +import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO; | ||
| 12 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; | 14 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankByUserCountRespVO; |
| 13 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; | 15 | import cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserRankPageReqVO; |
| 14 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; | 16 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.BrokerageUserDO; |
| @@ -220,6 +222,12 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { | @@ -220,6 +222,12 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { | ||
| 220 | return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); | 222 | return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); |
| 221 | } | 223 | } |
| 222 | 224 | ||
| 225 | + @Override | ||
| 226 | + public PageResult<AppBrokerageUserChildSummaryRespVO> getBrokerageUserChildSummaryPage(AppBrokerageUserChildSummaryPageReqVO pageReqVO, Long userId) { | ||
| 227 | + IPage<AppBrokerageUserChildSummaryRespVO> pageResult = brokerageUserMapper.selectSummaryPageByUserId(MyBatisUtils.buildPage(pageReqVO), pageReqVO, userId); | ||
| 228 | + return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); | ||
| 229 | + } | ||
| 230 | + | ||
| 223 | private boolean isUserCanBind(BrokerageUserDO user, Boolean isNewUser) { | 231 | private boolean isUserCanBind(BrokerageUserDO user, Boolean isNewUser) { |
| 224 | // 校验分销功能是否启用 | 232 | // 校验分销功能是否启用 |
| 225 | TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); | 233 | TradeConfigDO tradeConfig = tradeConfigService.getTradeConfig(); |
yudao-module-mall/yudao-module-trade-biz/src/main/resources/mapper/brokerage/BrokerageUserMapper.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 3 | +<mapper namespace="cn.iocoder.yudao.module.trade.dal.mysql.brokerage.BrokerageUserMapper"> | ||
| 4 | + | ||
| 5 | + <select id="selectSummaryPageByUserId" | ||
| 6 | + resultType="cn.iocoder.yudao.module.trade.controller.app.brokerage.vo.user.AppBrokerageUserChildSummaryRespVO"> | ||
| 7 | + SELECT bu.id, bu.bind_user_time AS brokerageTime, | ||
| 8 | + u.nickname, u.avatar, | ||
| 9 | + (SELECT SUM(price) FROM trade_brokerage_record r | ||
| 10 | + WHERE r.user_id = u.id AND biz_type = 1 AND r.status = 1 AND r.deleted = FALSE) AS brokeragePrice, | ||
| 11 | + (SELECT COUNT(1) FROM trade_brokerage_record r | ||
| 12 | + WHERE r.user_id = u.id AND biz_type = 1 AND r.status = 1 AND r.deleted = FALSE) AS brokerageOrderCount, | ||
| 13 | + (SELECT COUNT(1) FROM trade_brokerage_user c | ||
| 14 | + WHERE c.bind_user_id = u.id AND c.deleted = FALSE) AS brokerageUserCount | ||
| 15 | + FROM member_user AS u | ||
| 16 | + JOIN trade_brokerage_user AS bu ON bu.id = u.id | ||
| 17 | + <where> | ||
| 18 | + <if test="param.nickname != null and param.nickname != ''"> | ||
| 19 | + AND u.nickname LIKE concat('', #{param.nickname}, '') | ||
| 20 | + </if> | ||
| 21 | + <if test="param.level == 1"> | ||
| 22 | + AND bu.bind_user_id = #{userId} | ||
| 23 | + </if> | ||
| 24 | + <if test="param.level == 2"> | ||
| 25 | + AND bu.bind_user_id = (SELECT id FROM trade_brokerage_user c WHERE c.bind_user_id = | ||
| 26 | + #{userId}) | ||
| 27 | + </if> | ||
| 28 | + </where> | ||
| 29 | + <choose> | ||
| 30 | + <when test="param.sortingField.field == 'userCount'"> | ||
| 31 | + ORDER BY brokerageUserCount ${param.sortingField.order} | ||
| 32 | + </when> | ||
| 33 | + <when test="param.sortingField.field == 'orderCount'"> | ||
| 34 | + ORDER BY brokerageOrderCount ${param.sortingField.order} | ||
| 35 | + </when> | ||
| 36 | + <when test="param.sortingField.field == 'price'"> | ||
| 37 | + ORDER BY brokeragePrice ${param.sortingField.order} | ||
| 38 | + </when> | ||
| 39 | + <otherwise> | ||
| 40 | + ORDER BY bu.bind_user_time DESC | ||
| 41 | + </otherwise> | ||
| 42 | + </choose> | ||
| 43 | + </select> | ||
| 44 | +</mapper> |