From c5263b0adf420594fb5ba39da3590f22ae96d7ef Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Tue, 9 Sep 2025 11:37:26 +0800 Subject: [PATCH] =?UTF-8?q?feat(BD=E5=88=97=E8=A1=A8):=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E4=B8=BB=E6=92=AD=E6=95=B0=E9=87=8F=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/command/team/query/BdListQryExe.java | 28 ++++++++++++++++--- .../app/dto/clientobject/team/BdPageCO.java | 6 ++++ .../service/team/team/TeamProfileService.java | 5 ++++ .../team/impl/TeamProfileServiceImpl.java | 5 ++++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/query/BdListQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/query/BdListQryExe.java index b54fba37..d949adef 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/query/BdListQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/team/query/BdListQryExe.java @@ -1,12 +1,19 @@ package com.red.circle.other.app.command.team.query; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.red.circle.framework.core.asserts.ResponseAssert; import com.red.circle.framework.core.response.CommonErrorCode; import com.red.circle.framework.dto.PageResult; import com.red.circle.other.app.dto.clientobject.team.BdPageCO; +import com.red.circle.other.infra.database.mongo.entity.team.team.TeamProfile; +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.service.sys.AdministratorService; 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.inner.endpoint.team.target.TeamProfileClient; import com.red.circle.other.inner.endpoint.user.user.UserProfileClient; import com.red.circle.other.inner.model.cmd.team.bd.BdTeamPageQryCmd; import com.red.circle.other.inner.model.dto.agency.bd.BdTeamInfoDTO; @@ -17,6 +24,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; +import java.sql.Wrapper; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -26,8 +34,10 @@ import java.util.stream.Stream; public class BdListQryExe { private final BusinessDevelopmentBaseInfoService businessDevelopmentBaseInfoService; + private final BusinessDevelopmentTeamService businessDevelopmentTeamService; private final UserProfileClient userProfileClient; private final AdministratorService administratorService; + private final TeamProfileService teamProfileService; public PageResult pageResult(BdTeamPageQryCmd qryCmd) { boolean b = administratorService.existsAdmin(qryCmd.getUserId()); @@ -36,8 +46,6 @@ public class BdListQryExe { } PageResult pageResult = businessDevelopmentBaseInfoService.query() - .eq(Objects.nonNull(qryCmd.getUserId()), BusinessDevelopmentBaseInfo::getUserId, - qryCmd.getUserId()) .eq(StringUtils.isNotBlank(qryCmd.getRegion()), BusinessDevelopmentBaseInfo::getRegion, qryCmd.getRegion()) .eq(StringUtils.isNotBlank(qryCmd.getSysOrigin()), @@ -50,13 +58,25 @@ public class BdListQryExe { .orderByDesc(BusinessDevelopmentBaseInfo::getCreateTime) .page(qryCmd.getPageQuery()); - if ( pageResult == null ) { + if ( pageResult == null || pageResult.getRecords().isEmpty() ) { return null; } Set userIds = getUserIds(pageResult.getRecords()); Map userMap = userProfileClient.mapByUserIds(userIds).getBody(); + //主播数量 + LambdaQueryWrapper in = Wrappers.lambdaQuery(BusinessDevelopmentTeam.class) + .select(BusinessDevelopmentTeam::getId, BusinessDevelopmentTeam::getTeamId, BusinessDevelopmentTeam::getUserId) + .in(BusinessDevelopmentTeam::getUserId, userIds); + List teamIdList = businessDevelopmentTeamService.list(in); + Map teamUserIdMap = teamIdList.stream().collect(Collectors.toMap(BusinessDevelopmentTeam::getTeamId, BusinessDevelopmentTeam::getUserId, (v1, v2) -> v1)); + Set teamIdSet = teamIdList.stream().map(BusinessDevelopmentTeam::getTeamId).collect(Collectors.toSet()); + Map teamMemberQuantityMap = teamProfileService.getByIds(teamIdSet).stream() + .collect(Collectors.toMap(key -> teamUserIdMap.get(key.getId()), + e -> e.getCounter().getMemberQuantity(), + Long::sum)); + return pageResult.convert(info -> new BdPageCO() .setId(info.getId()) .setSysOrigin(info.getSysOrigin()) @@ -64,7 +84,7 @@ public class BdListQryExe { .setUserProfile(userMap.get(info.getUserId())) .setAgentCount(info.getMemberQuantity()) .setBdLeadUserId(info.getBdLeadUserId()) - .setBdLeadUserProfile(userMap.get(info.getBdLeadUserId())) + .setAllAnchorCount(teamMemberQuantityMap.get(info.getUserId())) .setContact(info.getContact()) .setRegion(info.getRegion()) .setCreateTime(info.getCreateTime()) diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/team/BdPageCO.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/team/BdPageCO.java index a694f408..6befc545 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/team/BdPageCO.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/clientobject/team/BdPageCO.java @@ -46,6 +46,12 @@ public class BdPageCO extends ClientObject { @JsonSerialize(using = ToStringSerializer.class) private Long agentCount; + /** + * 代理下所有主播数量 + */ + @JsonSerialize(using = ToStringSerializer.class) + private Long allAnchorCount; + /** * 用户基本信息. */ diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/team/TeamProfileService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/team/TeamProfileService.java index d7532621..a1eccc37 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/team/TeamProfileService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/team/TeamProfileService.java @@ -68,6 +68,11 @@ public interface TeamProfileService { */ TeamProfile getById(Long id); + /** + * 批量获取团队资料 + */ + List getByIds(Set ids); + /** * 验证团队是否可用. */ diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/team/impl/TeamProfileServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/team/impl/TeamProfileServiceImpl.java index 94d32ff3..1e6814c6 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/team/impl/TeamProfileServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/team/impl/TeamProfileServiceImpl.java @@ -151,6 +151,11 @@ public class TeamProfileServiceImpl implements TeamProfileService { return mongoTemplate.findOne(Query.query(Criteria.where("id").is(id)), TeamProfile.class); } + @Override + public List getByIds(Set id) { + return mongoTemplate.find(Query.query(Criteria.where("id").in(id)), TeamProfile.class); + } + @Override public boolean checkStatusAvailable(Long id) { return mongoTemplate.exists(Query.query(Criteria.where("id").is(id)