Commit 499a054eb9f61f86d72d406c45e2a83e8d15b0a0
1 parent
79768089
trade: 分销业务后台功能:推广用户列表
Showing
3 changed files
with
72 additions
and
1 deletions
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageUserTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.enums.brokerage; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||
| 4 | +import lombok.AllArgsConstructor; | ||
| 5 | +import lombok.Getter; | ||
| 6 | + | ||
| 7 | +import java.util.Arrays; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 分销用户类型枚举 | ||
| 11 | + * | ||
| 12 | + * @author owen | ||
| 13 | + */ | ||
| 14 | +@AllArgsConstructor | ||
| 15 | +@Getter | ||
| 16 | +public enum BrokerageUserTypeEnum implements IntArrayValuable { | ||
| 17 | + | ||
| 18 | + ALL(0, "全部"), | ||
| 19 | + FIRST(1, "一级推广人"), | ||
| 20 | + SECOND(2, "二级推广人"), | ||
| 21 | + ; | ||
| 22 | + | ||
| 23 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageUserTypeEnum::getType).toArray(); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 类型 | ||
| 27 | + */ | ||
| 28 | + private final Integer type; | ||
| 29 | + /** | ||
| 30 | + * 名字 | ||
| 31 | + */ | ||
| 32 | + private final String name; | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public int[] array() { | ||
| 36 | + return ARRAYS; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | +} |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserPageReqVO.java
| 1 | package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; | 1 | package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | ||
| 5 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageUserTypeEnum; | ||
| 4 | import io.swagger.v3.oas.annotations.media.Schema; | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | import lombok.Data; | 7 | import lombok.Data; |
| 6 | import lombok.EqualsAndHashCode; | 8 | import lombok.EqualsAndHashCode; |
| @@ -27,4 +29,11 @@ public class BrokerageUserPageReqVO extends PageParam { | @@ -27,4 +29,11 @@ public class BrokerageUserPageReqVO extends PageParam { | ||
| 27 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | 29 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 28 | private LocalDateTime[] createTime; | 30 | private LocalDateTime[] createTime; |
| 29 | 31 | ||
| 32 | + @Schema(description = "用户类型") | ||
| 33 | + @InEnum(value = BrokerageUserTypeEnum.class, message = "用户类型必须是 {value}") | ||
| 34 | + private Integer userType; | ||
| 35 | + | ||
| 36 | + @Schema(description = "绑定时间") | ||
| 37 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 38 | + private LocalDateTime[] bindUserTime; | ||
| 30 | } | 39 | } |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/user/BrokerageUserMapper.java
| 1 | package cn.iocoder.yudao.module.trade.dal.mysql.brokerage.user; | 1 | package cn.iocoder.yudao.module.trade.dal.mysql.brokerage.user; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.lang.Assert; | 3 | import cn.hutool.core.lang.Assert; |
| 4 | +import cn.hutool.core.util.StrUtil; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 6 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 7 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 7 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.BrokerageUserPageReqVO; | 8 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.BrokerageUserPageReqVO; |
| 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.BrokerageUserDO; | 9 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.BrokerageUserDO; |
| 10 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageUserTypeEnum; | ||
| 11 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 9 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 12 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 10 | import org.apache.ibatis.annotations.Mapper; | 13 | import org.apache.ibatis.annotations.Mapper; |
| 11 | 14 | ||
| @@ -19,12 +22,32 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> { | @@ -19,12 +22,32 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> { | ||
| 19 | 22 | ||
| 20 | default PageResult<BrokerageUserDO> selectPage(BrokerageUserPageReqVO reqVO) { | 23 | default PageResult<BrokerageUserDO> selectPage(BrokerageUserPageReqVO reqVO) { |
| 21 | return selectPage(reqVO, new LambdaQueryWrapperX<BrokerageUserDO>() | 24 | return selectPage(reqVO, new LambdaQueryWrapperX<BrokerageUserDO>() |
| 22 | - .eqIfPresent(BrokerageUserDO::getBindUserId, reqVO.getBindUserId()) | ||
| 23 | .eqIfPresent(BrokerageUserDO::getBrokerageEnabled, reqVO.getBrokerageEnabled()) | 25 | .eqIfPresent(BrokerageUserDO::getBrokerageEnabled, reqVO.getBrokerageEnabled()) |
| 24 | .betweenIfPresent(BrokerageUserDO::getCreateTime, reqVO.getCreateTime()) | 26 | .betweenIfPresent(BrokerageUserDO::getCreateTime, reqVO.getCreateTime()) |
| 27 | + .betweenIfPresent(BrokerageUserDO::getBindUserTime, reqVO.getBindUserTime()) | ||
| 28 | + .and(reqVO.getBindUserId() != null, w -> buildBindUserCondition(reqVO, w)) | ||
| 25 | .orderByDesc(BrokerageUserDO::getId)); | 29 | .orderByDesc(BrokerageUserDO::getId)); |
| 26 | } | 30 | } |
| 27 | 31 | ||
| 32 | + static void buildBindUserCondition(BrokerageUserPageReqVO reqVO, LambdaQueryWrapper<BrokerageUserDO> wrapper) { | ||
| 33 | + if (BrokerageUserTypeEnum.FIRST.getType().equals(reqVO.getUserType())) { | ||
| 34 | + buildFirstBindUserCondition(reqVO.getBindUserId(), wrapper); | ||
| 35 | + } else if (BrokerageUserTypeEnum.SECOND.getType().equals(reqVO.getUserType())) { | ||
| 36 | + buildSecondBindUserCondition(reqVO.getBindUserId(), wrapper); | ||
| 37 | + } else { | ||
| 38 | + buildFirstBindUserCondition(reqVO.getBindUserId(), wrapper); | ||
| 39 | + buildSecondBindUserCondition(reqVO.getBindUserId(), wrapper.or()); | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + static void buildFirstBindUserCondition(Long bindUserId, LambdaQueryWrapper<BrokerageUserDO> wrapper) { | ||
| 44 | + wrapper.eq(BrokerageUserDO::getBindUserId, bindUserId); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + static void buildSecondBindUserCondition(Long bindUserId, LambdaQueryWrapper<BrokerageUserDO> w) { | ||
| 48 | + w.inSql(BrokerageUserDO::getBindUserId, StrUtil.format("SELECT id FROM trade_brokerage_user WHERE bind_user_id = {}", bindUserId)); | ||
| 49 | + } | ||
| 50 | + | ||
| 28 | /** | 51 | /** |
| 29 | * 更新用户可用佣金(增加) | 52 | * 更新用户可用佣金(增加) |
| 30 | * | 53 | * |