diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/BdTeamRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/BdTeamRestController.java new file mode 100644 index 00000000..ff6098d7 --- /dev/null +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/BdTeamRestController.java @@ -0,0 +1,34 @@ +package com.red.circle.other.adapter.app; + +import com.red.circle.other.app.dto.clientobject.BdTeamOverviewCO; +import com.red.circle.other.app.dto.cmd.BdTeamQueryCmd; +import com.red.circle.other.app.service.BdTeamService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * BD团队控制器 + */ +@RestController +@RequestMapping("/bd/team") +@RequiredArgsConstructor +public class BdTeamRestController { + + private final BdTeamService bdTeamService; + + /** + * 查询BD团队概览 + * BD Leader Teams列表 + * BD Teams + * 查询Agency Teams + *
+ */ + @PostMapping("/overview") + public BdTeamOverviewCO queryTeamOverview(@RequestBody BdTeamQueryCmd cmd) { + BdTeamOverviewCO result = bdTeamService.queryTeamOverview(cmd); + return result; + } +} diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/BdTeamQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/BdTeamQryExe.java new file mode 100644 index 00000000..d16cbcca --- /dev/null +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/BdTeamQryExe.java @@ -0,0 +1,392 @@ +package com.red.circle.other.app.command.bd.query; + +import com.red.circle.other.app.convertor.user.UserProfileAppConvertor; +import com.red.circle.other.app.dto.clientobject.BdTeamMemberCO; +import com.red.circle.other.app.dto.clientobject.BdTeamOverviewCO; +import com.red.circle.other.app.dto.cmd.BdTeamQueryCmd; +import com.red.circle.other.domain.gateway.user.UserProfileGateway; +import com.red.circle.other.infra.database.mongo.dto.team.TeamBillMemberTarget; +import com.red.circle.other.infra.database.mongo.entity.team.team.TeamBillCycle; +import com.red.circle.other.infra.database.mongo.entity.team.team.TeamMemberTarget; +import com.red.circle.other.infra.database.mongo.entity.team.team.TeamPolicyManager; +import com.red.circle.other.infra.database.mongo.entity.team.team.TeamProfile; +import com.red.circle.other.infra.database.mongo.service.team.TeamBillCycleUtils; +import com.red.circle.other.infra.database.mongo.service.team.team.TeamBillCycleService; +import com.red.circle.other.infra.database.mongo.service.team.team.TeamMemberTargetService; +import com.red.circle.other.infra.database.mongo.service.team.team.TeamPolicyManagerService; +import com.red.circle.other.infra.database.mongo.service.team.team.TeamProfileService; +import com.red.circle.other.infra.database.rds.entity.team.BusinessDevelopmentBaseInfo; +import com.red.circle.other.infra.database.rds.entity.team.BusinessDevelopmentTeam; +import com.red.circle.other.infra.database.rds.entity.team.RoomBdLead; +import com.red.circle.other.infra.database.rds.service.team.BusinessDevelopmentBaseInfoService; +import com.red.circle.other.infra.database.rds.service.team.BusinessDevelopmentTeamService; +import com.red.circle.other.infra.database.rds.service.team.RoomBdLeadService; +import com.red.circle.other.inner.enums.team.TeamBillCycleStatus; +import com.red.circle.other.inner.model.dto.user.UserProfileDTO; +import com.alibaba.fastjson.JSON; +import com.red.circle.component.redis.service.RedisService; +import com.red.circle.tool.core.collection.CollectionUtils; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * BD团队查询执行器 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class BdTeamQryExe { + + private final BusinessDevelopmentTeamService businessDevelopmentTeamService; + private final BusinessDevelopmentBaseInfoService businessDevelopmentBaseInfoService; + private final TeamBillCycleService teamBillCycleService; + private final TeamProfileService teamProfileService; + private final TeamMemberTargetService teamMemberTargetService; + private final TeamPolicyManagerService teamPolicyManagerService; + private final UserProfileGateway userProfileGateway; + private final UserProfileAppConvertor userProfileAppConvertor; + private final RoomBdLeadService roomBdLeadService; + private final RedisService redisService; + + /** + * 执行查询 + */ + public BdTeamOverviewCO execute(BdTeamQueryCmd cmd) { + Long currentUserId = cmd.getReqUserId(); + String type = cmd.getType(); + + // 缓存查询 + String cacheKey = "bdteam:" + type + ":"+currentUserId; + BdTeamOverviewCO cached = redisService.getStringToObject(cacheKey, BdTeamOverviewCO.class); + if (cached != null) { + return cached; + } + + // 查询数据 + BdTeamOverviewCO result = queryTeamList(currentUserId, type); + + // 缓存结果 + redisService.setString(cacheKey, JSON.toJSONString(result), 2, TimeUnit.MINUTES); + + return result; + } + + /** + * 查询团队列表 + */ + private BdTeamOverviewCO queryTeamList(Long userId, String type) { + BdTeamOverviewCO overview = new BdTeamOverviewCO(); + + // 获取当前账单周期 + Integer currentBillBelong = TeamBillCycleUtils.getCalcBillBelong(); + + List+ * 按半月周期统计的收入信息 + * 上半月:1-15日 + * 下半月:16-31日 + *
+ */ +@Data +public class BdIncomeDetailCO { + + /** + * 结算周期 + * 格式:yyyy.MM.dd-yyyy.MM.dd + * 示例:2025.10.01-2025.10.15 + */ + private String settlementPeriod; + + /** + * 周期状态 + * In Progress: 进行中 + * Completed: 已完成 + */ + private String status; + + /** + * 下级成员数量 + * BD_LEADER: Agency数量 + * BD: Host数量 + * AGENCY: Host数量 + */ + private Integer memberCount; + + /** + * 团队总收入 + */ + private BigDecimal teamTotalIncome; +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/BdTeamMemberCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/BdTeamMemberCO.java new file mode 100644 index 00000000..a6108c94 --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/BdTeamMemberCO.java @@ -0,0 +1,53 @@ +package com.red.circle.other.app.dto.clientobject; + +import lombok.Data; + +import java.math.BigDecimal; +import java.util.List; + +/** + * BD团队成员 + *+ * 表示团队列表中的一个成员(BD/Agency/Host) + * 包含基本信息和收入汇总 + *
+ */ +@Data +public class BdTeamMemberCO { + + /** + * 用户ID + */ + private Long userId; + + /** + * 用户名 + */ + private String userName; + + private String account; + + /** + * 头像 + */ + private String avatar; + + /** + * 下级数量 + * BD_LEADER视角:Agency数量 + * BD视角:Host数量 + * AGENCY视角:Host数量 + */ + private Integer subMemberCount; + + /** + * 总收入 + */ + private BigDecimal totalIncome; + + /** + * 收入明细列表(点击More后显示) + * 按半月周期分组 + */ + private List+ * 包含用户自己的收入汇总和团队成员列表 + * 适用于三种角色类型:BD_LEADER、BD、AGENCY + *
+ */ +@Data +public class BdTeamOverviewCO { + + /** + * 当前用户总收入 + */ + private BigDecimal totalIncome; + + /** + * 上期收入 + */ + private BigDecimal previousPeriodIncome; + + /** + * 团队成员数量 + * BD_LEADER: BD数量 + * BD: Agency数量 + * AGENCY: Host数量 + */ + private Integer memberCount; + + /** + * 团队总收入(所有下级的收入总和) + */ + private BigDecimal teamTotalIncome; + + /** + * 团队成员列表 + */ + private List+ * 用于查询BD Leader、BD、Agency的团队列表和收入详情 + * 支持列表查询和单个成员详情查询 + *
+ */ +@Data +@EqualsAndHashCode(callSuper = true) +public class BdTeamQueryCmd extends AppExtCommand { + + /** + * 团队类型 + * BD_LEADER: BD Leader团队(查看下级BD) + * BD: BD团队(查看下级Agency) + * AGENCY: Agency团队(查看下级Host) + */ + @NotNull(message = "团队类型不能为空") + private String type; + +} diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/BdTeamService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/BdTeamService.java new file mode 100644 index 00000000..0e579df0 --- /dev/null +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/BdTeamService.java @@ -0,0 +1,23 @@ +package com.red.circle.other.app.service; + +import com.red.circle.other.app.dto.clientobject.BdTeamOverviewCO; +import com.red.circle.other.app.dto.cmd.BdTeamQueryCmd; + +/** + * BD团队服务 + */ +public interface BdTeamService { + + /** + * 查询BD团队概览 + *+ * 支持三种场景: + * 1. 列表查询:不传targetUserId,返回当前用户的团队成员列表 + * 2. 详情查询:传targetUserId,返回指定成员的收入明细 + *
+ * + * @param cmd 查询命令 + * @return 团队概览信息 + */ + BdTeamOverviewCO queryTeamOverview(BdTeamQueryCmd cmd); +} diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/team/RoomBdLeadService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/team/RoomBdLeadService.java index cd46a037..acc66d4c 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/team/RoomBdLeadService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/team/RoomBdLeadService.java @@ -3,6 +3,9 @@ package com.red.circle.other.infra.database.rds.service.team; import com.red.circle.framework.mybatis.service.BaseService; import com.red.circle.other.infra.database.rds.entity.team.RoomBdLead; +import java.util.List; +import java.util.Set; + /** *
* BD Lead.
@@ -19,4 +22,6 @@ public interface RoomBdLeadService extends BaseService