feat(BD列表): 新增主播数量字段
This commit is contained in:
parent
2ab5782c71
commit
c5263b0adf
@ -1,12 +1,19 @@
|
|||||||
package com.red.circle.other.app.command.team.query;
|
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.asserts.ResponseAssert;
|
||||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||||
import com.red.circle.framework.dto.PageResult;
|
import com.red.circle.framework.dto.PageResult;
|
||||||
import com.red.circle.other.app.dto.clientobject.team.BdPageCO;
|
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.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.sys.AdministratorService;
|
||||||
import com.red.circle.other.infra.database.rds.service.team.BusinessDevelopmentBaseInfoService;
|
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.endpoint.user.user.UserProfileClient;
|
||||||
import com.red.circle.other.inner.model.cmd.team.bd.BdTeamPageQryCmd;
|
import com.red.circle.other.inner.model.cmd.team.bd.BdTeamPageQryCmd;
|
||||||
import com.red.circle.other.inner.model.dto.agency.bd.BdTeamInfoDTO;
|
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.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.sql.Wrapper;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@ -26,8 +34,10 @@ import java.util.stream.Stream;
|
|||||||
public class BdListQryExe {
|
public class BdListQryExe {
|
||||||
|
|
||||||
private final BusinessDevelopmentBaseInfoService businessDevelopmentBaseInfoService;
|
private final BusinessDevelopmentBaseInfoService businessDevelopmentBaseInfoService;
|
||||||
|
private final BusinessDevelopmentTeamService businessDevelopmentTeamService;
|
||||||
private final UserProfileClient userProfileClient;
|
private final UserProfileClient userProfileClient;
|
||||||
private final AdministratorService administratorService;
|
private final AdministratorService administratorService;
|
||||||
|
private final TeamProfileService teamProfileService;
|
||||||
|
|
||||||
public PageResult<BdPageCO> pageResult(BdTeamPageQryCmd qryCmd) {
|
public PageResult<BdPageCO> pageResult(BdTeamPageQryCmd qryCmd) {
|
||||||
boolean b = administratorService.existsAdmin(qryCmd.getUserId());
|
boolean b = administratorService.existsAdmin(qryCmd.getUserId());
|
||||||
@ -36,8 +46,6 @@ public class BdListQryExe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PageResult<BusinessDevelopmentBaseInfo> pageResult = businessDevelopmentBaseInfoService.query()
|
PageResult<BusinessDevelopmentBaseInfo> pageResult = businessDevelopmentBaseInfoService.query()
|
||||||
.eq(Objects.nonNull(qryCmd.getUserId()), BusinessDevelopmentBaseInfo::getUserId,
|
|
||||||
qryCmd.getUserId())
|
|
||||||
.eq(StringUtils.isNotBlank(qryCmd.getRegion()), BusinessDevelopmentBaseInfo::getRegion,
|
.eq(StringUtils.isNotBlank(qryCmd.getRegion()), BusinessDevelopmentBaseInfo::getRegion,
|
||||||
qryCmd.getRegion())
|
qryCmd.getRegion())
|
||||||
.eq(StringUtils.isNotBlank(qryCmd.getSysOrigin()),
|
.eq(StringUtils.isNotBlank(qryCmd.getSysOrigin()),
|
||||||
@ -50,13 +58,25 @@ public class BdListQryExe {
|
|||||||
.orderByDesc(BusinessDevelopmentBaseInfo::getCreateTime)
|
.orderByDesc(BusinessDevelopmentBaseInfo::getCreateTime)
|
||||||
.page(qryCmd.getPageQuery());
|
.page(qryCmd.getPageQuery());
|
||||||
|
|
||||||
if ( pageResult == null ) {
|
if ( pageResult == null || pageResult.getRecords().isEmpty() ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<Long> userIds = getUserIds(pageResult.getRecords());
|
Set<Long> userIds = getUserIds(pageResult.getRecords());
|
||||||
Map<Long, UserProfileDTO> userMap = userProfileClient.mapByUserIds(userIds).getBody();
|
Map<Long, UserProfileDTO> userMap = userProfileClient.mapByUserIds(userIds).getBody();
|
||||||
|
|
||||||
|
//主播数量
|
||||||
|
LambdaQueryWrapper<BusinessDevelopmentTeam> in = Wrappers.lambdaQuery(BusinessDevelopmentTeam.class)
|
||||||
|
.select(BusinessDevelopmentTeam::getId, BusinessDevelopmentTeam::getTeamId, BusinessDevelopmentTeam::getUserId)
|
||||||
|
.in(BusinessDevelopmentTeam::getUserId, userIds);
|
||||||
|
List<BusinessDevelopmentTeam> teamIdList = businessDevelopmentTeamService.list(in);
|
||||||
|
Map<Long, Long> teamUserIdMap = teamIdList.stream().collect(Collectors.toMap(BusinessDevelopmentTeam::getTeamId, BusinessDevelopmentTeam::getUserId, (v1, v2) -> v1));
|
||||||
|
Set<Long> teamIdSet = teamIdList.stream().map(BusinessDevelopmentTeam::getTeamId).collect(Collectors.toSet());
|
||||||
|
Map<Long, Long> 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()
|
return pageResult.convert(info -> new BdPageCO()
|
||||||
.setId(info.getId())
|
.setId(info.getId())
|
||||||
.setSysOrigin(info.getSysOrigin())
|
.setSysOrigin(info.getSysOrigin())
|
||||||
@ -64,7 +84,7 @@ public class BdListQryExe {
|
|||||||
.setUserProfile(userMap.get(info.getUserId()))
|
.setUserProfile(userMap.get(info.getUserId()))
|
||||||
.setAgentCount(info.getMemberQuantity())
|
.setAgentCount(info.getMemberQuantity())
|
||||||
.setBdLeadUserId(info.getBdLeadUserId())
|
.setBdLeadUserId(info.getBdLeadUserId())
|
||||||
.setBdLeadUserProfile(userMap.get(info.getBdLeadUserId()))
|
.setAllAnchorCount(teamMemberQuantityMap.get(info.getUserId()))
|
||||||
.setContact(info.getContact())
|
.setContact(info.getContact())
|
||||||
.setRegion(info.getRegion())
|
.setRegion(info.getRegion())
|
||||||
.setCreateTime(info.getCreateTime())
|
.setCreateTime(info.getCreateTime())
|
||||||
|
|||||||
@ -46,6 +46,12 @@ public class BdPageCO extends ClientObject {
|
|||||||
@JsonSerialize(using = ToStringSerializer.class)
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
private Long agentCount;
|
private Long agentCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理下所有主播数量
|
||||||
|
*/
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private Long allAnchorCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户基本信息.
|
* 用户基本信息.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -68,6 +68,11 @@ public interface TeamProfileService {
|
|||||||
*/
|
*/
|
||||||
TeamProfile getById(Long id);
|
TeamProfile getById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量获取团队资料
|
||||||
|
*/
|
||||||
|
List<TeamProfile> getByIds(Set<Long> ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证团队是否可用.
|
* 验证团队是否可用.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -151,6 +151,11 @@ public class TeamProfileServiceImpl implements TeamProfileService {
|
|||||||
return mongoTemplate.findOne(Query.query(Criteria.where("id").is(id)), TeamProfile.class);
|
return mongoTemplate.findOne(Query.query(Criteria.where("id").is(id)), TeamProfile.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TeamProfile> getByIds(Set<Long> id) {
|
||||||
|
return mongoTemplate.find(Query.query(Criteria.where("id").in(id)), TeamProfile.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkStatusAvailable(Long id) {
|
public boolean checkStatusAvailable(Long id) {
|
||||||
return mongoTemplate.exists(Query.query(Criteria.where("id").is(id)
|
return mongoTemplate.exists(Query.query(Criteria.where("id").is(id)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user