From 3eea5f4dec6fa56d6ac173d8c7f4015bb8bb945c Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Sun, 11 May 2025 19:55:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E5=AE=8C=E6=88=90=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E7=AB=AF=E7=9A=84=E9=A1=B9=E7=9B=AE=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../userInfo/UserMainInfoController.java | 192 +++++++++++------- .../userMainInfo/UserMainInfoAddRequest.java | 7 + .../UserMainInfoQueryRequest.java | 6 + .../UserMainInfoUpdateRequest.java | 7 + .../promotion/model/entity/UserMainInfo.java | 5 + .../model/vo/userMainInfo/UserMainInfoVO.java | 22 +- .../vo/userMainInfo/UserMemberInfoVO.java | 60 ++++++ .../model/vo/userMainInfo/UserTeamInfoVO.java | 55 +++-- 8 files changed, 238 insertions(+), 116 deletions(-) create mode 100644 src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserMemberInfoVO.java diff --git a/src/main/java/com/greenorange/promotion/controller/userInfo/UserMainInfoController.java b/src/main/java/com/greenorange/promotion/controller/userInfo/UserMainInfoController.java index 4bed5e9..b9818a4 100644 --- a/src/main/java/com/greenorange/promotion/controller/userInfo/UserMainInfoController.java +++ b/src/main/java/com/greenorange/promotion/controller/userInfo/UserMainInfoController.java @@ -1,5 +1,6 @@ package com.greenorange.promotion.controller.userInfo; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.greenorange.promotion.annotation.RequiresPermission; import com.greenorange.promotion.annotation.SysLog; import com.greenorange.promotion.common.BaseResponse; @@ -10,9 +11,13 @@ import com.greenorange.promotion.exception.ThrowUtils; import com.greenorange.promotion.model.dto.CommonBatchRequest; import com.greenorange.promotion.model.dto.userMainInfo.UserMainInfoAddRequest; import com.greenorange.promotion.model.dto.userMainInfo.UserMainInfoUpdateRequest; +import com.greenorange.promotion.model.entity.UserInfo; import com.greenorange.promotion.model.entity.UserMainInfo; import com.greenorange.promotion.model.vo.userMainInfo.UserMainInfoVO; +import com.greenorange.promotion.model.vo.userMainInfo.UserMemberInfoVO; +import com.greenorange.promotion.model.vo.userMainInfo.UserTeamInfoVO; import com.greenorange.promotion.service.common.CommonService; +import com.greenorange.promotion.service.userInfo.UserInfoService; import com.greenorange.promotion.service.userInfo.UserMainInfoService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -26,7 +31,10 @@ import jakarta.validation.Valid; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** @@ -38,6 +46,9 @@ import java.util.List; @Tag(name = "用户主要信息管理") public class UserMainInfoController { + @Resource + private UserInfoService userInfoService; + @Resource private UserMainInfoService userMainInfoService; @@ -55,86 +66,115 @@ public class UserMainInfoController { @SysLog(title = "用户主要信息管理", content = "小程序用户查询团队信息") public BaseResponse queryUserTeamInfo(HttpServletRequest request) { Long userId = (Long) request.getAttribute("userId"); + LambdaQueryWrapper userInfoLambdaQueryWrapper = new LambdaQueryWrapper<>(); + userInfoLambdaQueryWrapper.eq(UserInfo::getParentUserId, userId); + List userInfoList = userInfoService.list(userInfoLambdaQueryWrapper); + List userMainInfoList = commonService.findByFieldInTargetField(userInfoList, userMainInfoService, UserInfo::getId, "userId"); + // 封装Map集合(键:用户id,值:用户信息) + Map userInfoMap = new HashMap<>(); + for (UserInfo userInfo : userInfoList) { + userInfoMap.put(userInfo.getId(), userInfo); + } + // 封装Map集合(键:用户id,值:用户主要信息) + Map userMainInfoMap = new HashMap<>(); + for (UserMainInfo userMainInfo : userMainInfoList) { + userMainInfoMap.put(userMainInfo.getUserId(), userMainInfo); + } + List userMemberInfoVOList = new ArrayList<>(); + for (UserInfo userInfo : userInfoList) { + Long id = userInfo.getId(); + UserInfo userInformation = userInfoMap.get(id); + UserMainInfo userMainInfo = userMainInfoMap.get(id); + UserMemberInfoVO userMemberInfoVO = UserMemberInfoVO.builder() + .subUserId(id) + .nickName(userInformation.getNickName()) + .phoneNumber(userInformation.getPhoneNumber()) + .teamSize(userMainInfo.getTeamSize()) + .parentEarnings(userMainInfo.getParentEarnings()) + .registerTime(userInformation.getCreateTime()) + .build(); + userMemberInfoVOList.add(userMemberInfoVO); + } return ResultUtils.success(true); } - /** - * web端管理员添加用户主要信息 - * @param userMainInfoAddRequest 用户主要信息添加请求体 - * @return 是否添加成功 - */ - @PostMapping("add") - @Operation(summary = "web端管理员添加用户主要信息", description = "参数:用户主要信息添加请求体,权限:管理员,方法名:addUserMainInfo") - @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) - @SysLog(title = "用户主要信息管理", content = "web端管理员添加用户主要信息") - public BaseResponse addUserMainInfo(@Valid @RequestBody UserMainInfoAddRequest userMainInfoAddRequest) { - UserMainInfo userMainInfo = commonService.copyProperties(userMainInfoAddRequest, UserMainInfo.class); - userMainInfoService.save(userMainInfo); - return ResultUtils.success(true); - } - - /** - * web端管理员根据id修改用户主要信息信息 - * @param userMainInfoUpdateRequest 用户主要信息更新请求体 - * @return 是否更新成功 - */ - @PostMapping("update") - @Operation(summary = "web端管理员更新用户主要信息", description = "参数:用户主要信息更新请求体,权限:管理员,方法名:updateUserMainInfo") - @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) - @SysLog(title = "用户主要信息管理", content = "web端管理员根据id修改用户主要信息信息") - public BaseResponse updateUserMainInfo(@Valid @RequestBody UserMainInfoUpdateRequest userMainInfoUpdateRequest) { - UserMainInfo userMainInfo = commonService.copyProperties(userMainInfoUpdateRequest, UserMainInfo.class); - userMainInfoService.updateById(userMainInfo); - return ResultUtils.success(true); - } - - /** - * web端管理员根据id删除用户主要信息 - * @param commonRequest 用户主要信息删除请求体 - * @return 是否删除成功 - */ - @PostMapping("delete") - @Operation(summary = "web端管理员根据id删除用户主要信息", description = "参数:用户主要信息删除请求体,权限:管理员,方法名:delUserMainInfo") - @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) - @SysLog(title = "用户主要信息管理", content = "web端管理员根据id删除用户主要信息") - public BaseResponse delUserMainInfo(@Valid @RequestBody CommonRequest commonRequest) { - Long id = commonRequest.getId(); - userMainInfoService.removeById(id); - return ResultUtils.success(true); - } - - /** - * web端管理员批量删除用户主要信息 - * @param commonBatchRequest 用户主要信息批量删除请求体 - * @return 是否删除成功 - */ - @PostMapping("delBatch") - @Operation(summary = "web端管理员批量删除用户主要信息", description = "参数:用户主要信息批量删除请求体,权限:管理员,方法名:delBatchUserMainInfo") - @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) - @SysLog(title = "用户主要信息管理", content = "web端管理员批量删除用户主要信息") - public BaseResponse delBatchUserMainInfo(@Valid @RequestBody CommonBatchRequest commonBatchRequest) { - List ids = commonBatchRequest.getIds(); - userMainInfoService.removeByIds(ids); - return ResultUtils.success(true); - } - - /** - * web端管理员根据id查询用户主要信息 - * @param commonRequest 用户主要信息查询请求体 - * @return 用户主要信息信息 - */ - @PostMapping("queryById") - @Operation(summary = "web端管理员根据id查询用户主要信息", description = "参数:用户主要信息查询请求体,权限:管理员,方法名:queryUserMainInfoById") - @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) - @SysLog(title = "用户主要信息管理", content = "web端管理员根据id查询用户主要信息") - public BaseResponse queryUserMainInfoById(@Valid @RequestBody CommonRequest commonRequest) { - Long id = commonRequest.getId(); - UserMainInfo userMainInfo = userMainInfoService.getById(id); - ThrowUtils.throwIf(userMainInfo == null, ErrorCode.OPERATION_ERROR, "当前用户主要信息不存在"); - UserMainInfoVO userMainInfoVO = commonService.copyProperties(userMainInfo, UserMainInfoVO.class); - return ResultUtils.success(userMainInfoVO); - } +// /** +// * web端管理员添加用户主要信息 +// * @param userMainInfoAddRequest 用户主要信息添加请求体 +// * @return 是否添加成功 +// */ +// @PostMapping("add") +// @Operation(summary = "web端管理员添加用户主要信息", description = "参数:用户主要信息添加请求体,权限:管理员,方法名:addUserMainInfo") +// @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) +// @SysLog(title = "用户主要信息管理", content = "web端管理员添加用户主要信息") +// public BaseResponse addUserMainInfo(@Valid @RequestBody UserMainInfoAddRequest userMainInfoAddRequest) { +// UserMainInfo userMainInfo = commonService.copyProperties(userMainInfoAddRequest, UserMainInfo.class); +// userMainInfoService.save(userMainInfo); +// return ResultUtils.success(true); +// } +// +// /** +// * web端管理员根据id修改用户主要信息信息 +// * @param userMainInfoUpdateRequest 用户主要信息更新请求体 +// * @return 是否更新成功 +// */ +// @PostMapping("update") +// @Operation(summary = "web端管理员更新用户主要信息", description = "参数:用户主要信息更新请求体,权限:管理员,方法名:updateUserMainInfo") +// @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) +// @SysLog(title = "用户主要信息管理", content = "web端管理员根据id修改用户主要信息信息") +// public BaseResponse updateUserMainInfo(@Valid @RequestBody UserMainInfoUpdateRequest userMainInfoUpdateRequest) { +// UserMainInfo userMainInfo = commonService.copyProperties(userMainInfoUpdateRequest, UserMainInfo.class); +// userMainInfoService.updateById(userMainInfo); +// return ResultUtils.success(true); +// } +// +// /** +// * web端管理员根据id删除用户主要信息 +// * @param commonRequest 用户主要信息删除请求体 +// * @return 是否删除成功 +// */ +// @PostMapping("delete") +// @Operation(summary = "web端管理员根据id删除用户主要信息", description = "参数:用户主要信息删除请求体,权限:管理员,方法名:delUserMainInfo") +// @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) +// @SysLog(title = "用户主要信息管理", content = "web端管理员根据id删除用户主要信息") +// public BaseResponse delUserMainInfo(@Valid @RequestBody CommonRequest commonRequest) { +// Long id = commonRequest.getId(); +// userMainInfoService.removeById(id); +// return ResultUtils.success(true); +// } +// +// /** +// * web端管理员批量删除用户主要信息 +// * @param commonBatchRequest 用户主要信息批量删除请求体 +// * @return 是否删除成功 +// */ +// @PostMapping("delBatch") +// @Operation(summary = "web端管理员批量删除用户主要信息", description = "参数:用户主要信息批量删除请求体,权限:管理员,方法名:delBatchUserMainInfo") +// @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) +// @SysLog(title = "用户主要信息管理", content = "web端管理员批量删除用户主要信息") +// public BaseResponse delBatchUserMainInfo(@Valid @RequestBody CommonBatchRequest commonBatchRequest) { +// List ids = commonBatchRequest.getIds(); +// userMainInfoService.removeByIds(ids); +// return ResultUtils.success(true); +// } +// +// /** +// * web端管理员根据id查询用户主要信息 +// * @param commonRequest 用户主要信息查询请求体 +// * @return 用户主要信息信息 +// */ +// @PostMapping("queryById") +// @Operation(summary = "web端管理员根据id查询用户主要信息", description = "参数:用户主要信息查询请求体,权限:管理员,方法名:queryUserMainInfoById") +// @RequiresPermission(mustRole = UserConstant.ADMIN_ROLE) +// @SysLog(title = "用户主要信息管理", content = "web端管理员根据id查询用户主要信息") +// public BaseResponse queryUserMainInfoById(@Valid @RequestBody CommonRequest commonRequest) { +// Long id = commonRequest.getId(); +// UserMainInfo userMainInfo = userMainInfoService.getById(id); +// ThrowUtils.throwIf(userMainInfo == null, ErrorCode.OPERATION_ERROR, "当前用户主要信息不存在"); +// UserMainInfoVO userMainInfoVO = commonService.copyProperties(userMainInfo, UserMainInfoVO.class); +// return ResultUtils.success(userMainInfoVO); +// } // /** // * Web端管理员分页查询用户主要信息 diff --git a/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoAddRequest.java b/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoAddRequest.java index 09fa20b..fd6b356 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoAddRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoAddRequest.java @@ -15,6 +15,7 @@ import java.math.BigDecimal; @Data @Schema(description = "用户主要信息添加请求体", requiredProperties = { "teamSize", + "teamEarnings", "parentEarnings", "currentBalance", "withdrawalAmount", @@ -31,6 +32,12 @@ public class UserMainInfoAddRequest implements Serializable { @Schema(description = "团队人数(不包括自己)", example = "10") private Integer teamSize; + /** + * 团队收益 + */ + @Schema(description = "团队收益", example = "40.00") + private BigDecimal teamEarnings; + /** * 给上级带来的收益 */ diff --git a/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoQueryRequest.java b/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoQueryRequest.java index 361e343..f81c93e 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoQueryRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoQueryRequest.java @@ -31,6 +31,12 @@ public class UserMainInfoQueryRequest extends PageRequest implements Serializabl @Schema(description = "团队人数(不包括自己)", example = "10") private Integer teamSize; + /** + * 团队收益 + */ + @Schema(description = "团队收益", example = "40.00") + private BigDecimal teamEarnings; + /** * 给上级带来的收益 */ diff --git a/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoUpdateRequest.java b/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoUpdateRequest.java index 46ae790..67bfc59 100644 --- a/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoUpdateRequest.java +++ b/src/main/java/com/greenorange/promotion/model/dto/userMainInfo/UserMainInfoUpdateRequest.java @@ -16,6 +16,7 @@ import java.math.BigDecimal; @Schema(description = "用户主要信息更新请求体", requiredProperties = { "id", "teamSize", + "teamEarnings", "parentEarnings", "currentBalance", "withdrawalAmount", @@ -39,6 +40,12 @@ public class UserMainInfoUpdateRequest implements Serializable { @Schema(description = "团队人数(不包括自己)", example = "10") private Integer teamSize; + /** + * 团队收益 + */ + @Schema(description = "团队收益", example = "40.00") + private BigDecimal teamEarnings; + /** * 给上级带来的收益 */ diff --git a/src/main/java/com/greenorange/promotion/model/entity/UserMainInfo.java b/src/main/java/com/greenorange/promotion/model/entity/UserMainInfo.java index 23ec2ab..ed52f59 100644 --- a/src/main/java/com/greenorange/promotion/model/entity/UserMainInfo.java +++ b/src/main/java/com/greenorange/promotion/model/entity/UserMainInfo.java @@ -62,6 +62,11 @@ public class UserMainInfo implements Serializable { */ private String inviteQrCode; + /** + * 团队收益 + */ + private BigDecimal teamEarnings; + /** * 是否删除 */ diff --git a/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserMainInfoVO.java b/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserMainInfoVO.java index 3f790a8..a8e276e 100644 --- a/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserMainInfoVO.java +++ b/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserMainInfoVO.java @@ -23,49 +23,55 @@ public class UserMainInfoVO implements Serializable { /** * 团队人数(不包括自己) */ - @Schema(description = "团队人数(不包括自己)", example = "${field.example}") + @Schema(description = "团队人数(不包括自己)", example = "8") private Integer teamSize; + /** + * 团队收益 + */ + @Schema(description = "团队收益", example = "25.00") + private BigDecimal teamEarnings; + /** * 给上级带来的收益 */ - @Schema(description = "给上级带来的收益", example = "${field.example}") + @Schema(description = "给上级带来的收益", example = "8.00") private BigDecimal parentEarnings; /** * 当前余额 */ - @Schema(description = "当前余额", example = "${field.example}") + @Schema(description = "当前余额", example = "10.00") private BigDecimal currentBalance; /** * 提现中的金额 */ - @Schema(description = "提现中的金额", example = "${field.example}") + @Schema(description = "提现中的金额", example = "15.00") private BigDecimal withdrawalAmount; /** * 已提现的金额 */ - @Schema(description = "已提现的金额", example = "${field.example}") + @Schema(description = "已提现的金额", example = "20.00") private BigDecimal withdrawnAmount; /** * 累计收入 */ - @Schema(description = "累计收入", example = "${field.example}") + @Schema(description = "累计收入", example = "100.00") private BigDecimal totalIncome; /** * 用户id */ - @Schema(description = "用户id", example = "${field.example}") + @Schema(description = "用户id", example = "1") private Long userId; /** * 邀请二维码 */ - @Schema(description = "邀请二维码", example = "${field.example}") + @Schema(description = "邀请二维码", example = "3KD3H8D7") private String inviteQrCode; diff --git a/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserMemberInfoVO.java b/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserMemberInfoVO.java new file mode 100644 index 0000000..f9fceaa --- /dev/null +++ b/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserMemberInfoVO.java @@ -0,0 +1,60 @@ +package com.greenorange.promotion.model.vo.userMainInfo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serial; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class UserMemberInfoVO implements Serializable { + + /** + * 下级用户id + */ + @Schema(description = "下级用户id", example = "5") + private Long subUserId; + + /** + * 用户昵称 + */ + @Schema(description = "用户昵称", example = "chenxinzhi") + private String nickName; + + /** + * 手机号 + */ + @Schema(description = "手机号", example = "15888610253") + private String phoneNumber; + + /** + * 团队人数(不包括自己) + */ + @Schema(description = "团队人数(不包括自己)", example = "10") + private Integer teamSize; + + /** + * 给上级带来的收益 + */ + @Schema(description = "给上级带来的收益", example = "16.33") + private BigDecimal parentEarnings; + + /** + * 注册时间 + */ + @Schema(description = "注册时间", example = "2025-05-11 12:00:00") + private Date registerTime; + + + @Serial + private static final long serialVersionUID = 1L; + +} diff --git a/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserTeamInfoVO.java b/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserTeamInfoVO.java index 476040d..081980b 100644 --- a/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserTeamInfoVO.java +++ b/src/main/java/com/greenorange/promotion/model/vo/userMainInfo/UserTeamInfoVO.java @@ -1,67 +1,58 @@ package com.greenorange.promotion.model.vo.userMainInfo; import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.io.Serial; import java.io.Serializable; import java.math.BigDecimal; +import java.util.List; @Data -@Schema(description = "用户团队信息 视图对象") +@NoArgsConstructor +@AllArgsConstructor +@Builder public class UserTeamInfoVO implements Serializable { - /** - * 用户主要信息ID - */ - @Schema(description = "用户主要信息ID", example = "1") - private Long id; - /** * 团队人数(不包括自己) */ - @Schema(description = "团队人数(不包括自己)", example = "${field.example}") + @Schema(description = "团队人数(不包括自己)", example = "8") private Integer teamSize; /** - * 给上级带来的收益 + * 直接代理人数 */ - @Schema(description = "给上级带来的收益", example = "${field.example}") - private BigDecimal parentEarnings; + @Schema(description = "直接代理人数", example = "5") + private Integer directAgentSize; /** - * 当前余额 + * 团队收益 */ - @Schema(description = "当前余额", example = "${field.example}") - private BigDecimal currentBalance; + @Schema(description = "团队收益", example = "25.00") + private BigDecimal teamEarnings; /** - * 提现中的金额 + * 邀请码 */ - @Schema(description = "提现中的金额", example = "${field.example}") - private BigDecimal withdrawalAmount; - - /** - * 已提现的金额 - */ - @Schema(description = "已提现的金额", example = "${field.example}") - private BigDecimal withdrawnAmount; - - /** - * 累计收入 - */ - @Schema(description = "累计收入", example = "${field.example}") - private BigDecimal totalIncome; - + @Schema(description = "邀请码", example = "666999") + private String invitationCode; /** * 邀请二维码 */ - @Schema(description = "邀请二维码", example = "${field.example}") + @Schema(description = "邀请二维码", example = "3KD3H8D7") private String inviteQrCode; + /** + * 下级用户信息列表 + */ + @Schema(description = "下级用户信息列表") + private List userMemberInfoVOList; @Serial private static final long serialVersionUID = 1L; - }