团队账单总和数据结构修改
This commit is contained in:
parent
6c9132d55e
commit
860ebd5a21
@ -7,20 +7,7 @@ import com.red.circle.common.business.dto.cmd.app.AppIdStringCmd;
|
|||||||
import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd;
|
import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd;
|
||||||
import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
|
import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
|
||||||
import com.red.circle.framework.web.controller.BaseController;
|
import com.red.circle.framework.web.controller.BaseController;
|
||||||
import com.red.circle.other.app.dto.clientobject.team.AnchorWorkStatisticsCO;
|
import com.red.circle.other.app.dto.clientobject.team.*;
|
||||||
import com.red.circle.other.app.dto.clientobject.team.MemberEntryTeamCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamBillCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamBillMemberWorkCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamMemberCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamMemberQuitAskCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamMemberTargetSettlementResultCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamMemberWorkCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamOwnMemberCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamPolicyManagerCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamProfileSearchResCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamQuitApplyInfoCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamUserApplyRecordCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamWaitApplyMessageCO;
|
|
||||||
import com.red.circle.other.app.dto.cmd.team.DateTypeQryCmd;
|
import com.red.circle.other.app.dto.cmd.team.DateTypeQryCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.team.TeamHandleUserApplyCmd;
|
import com.red.circle.other.app.dto.cmd.team.TeamHandleUserApplyCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.team.TeamMemberRoleChangeCmd;
|
import com.red.circle.other.app.dto.cmd.team.TeamMemberRoleChangeCmd;
|
||||||
@ -108,7 +95,7 @@ public class TeamRestController extends BaseController {
|
|||||||
* 成员数量
|
* 成员数量
|
||||||
*/
|
*/
|
||||||
@GetMapping("/members/count")
|
@GetMapping("/members/count")
|
||||||
public Integer countTeamMember(@Validated AppIdLongCmd cmd) {
|
public TeamMemberCountResultCO countTeamMember(@Validated AppIdLongCmd cmd) {
|
||||||
return teamService.countTeamMember(cmd);
|
return teamService.countTeamMember(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,11 +4,17 @@ import com.google.common.collect.Lists;
|
|||||||
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
|
import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
|
||||||
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
import com.red.circle.other.app.convertor.user.UserProfileAppConvertor;
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamMemberCO;
|
import com.red.circle.other.app.dto.clientobject.team.TeamMemberCO;
|
||||||
|
import com.red.circle.other.app.dto.clientobject.team.TeamMemberCountResultCO;
|
||||||
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
|
||||||
|
import com.red.circle.other.infra.database.mongo.dto.team.TeamPolicy;
|
||||||
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamMember;
|
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamMember;
|
||||||
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamMemberTarget;
|
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.team.TeamMemberService;
|
import com.red.circle.other.infra.database.mongo.service.team.team.TeamMemberService;
|
||||||
import com.red.circle.other.infra.database.mongo.service.team.team.TeamMemberTargetService;
|
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.inner.model.dto.user.UserProfileDTO;
|
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
||||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||||
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
||||||
@ -34,6 +40,8 @@ public class TeamMemberListQryExe {
|
|||||||
private final UserProfileGateway userProfileGateway;
|
private final UserProfileGateway userProfileGateway;
|
||||||
private final UserProfileAppConvertor userProfileAppConvertor;
|
private final UserProfileAppConvertor userProfileAppConvertor;
|
||||||
private final TeamMemberTargetService teamMemberTargetService;
|
private final TeamMemberTargetService teamMemberTargetService;
|
||||||
|
private final TeamPolicyManagerService teamPolicyManagerService;
|
||||||
|
private final TeamProfileService teamProfileService;
|
||||||
|
|
||||||
public List<TeamMemberCO> execute(AppIdLongCmd cmd) {
|
public List<TeamMemberCO> execute(AppIdLongCmd cmd) {
|
||||||
|
|
||||||
@ -75,10 +83,82 @@ public class TeamMemberListQryExe {
|
|||||||
return teamMemberCOs;
|
return teamMemberCOs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer executeCount(AppIdLongCmd cmd) {
|
public TeamMemberCountResultCO executeCount(AppIdLongCmd cmd) {
|
||||||
List<TeamMember> teamMembers = teamMemberService.listTeamMember(cmd.getId(),
|
List<TeamMember> teamMembers = teamMemberService.listTeamMember(cmd.getId(),
|
||||||
3000);
|
3000);
|
||||||
return teamMembers.size();
|
|
||||||
|
if (CollectionUtils.isEmpty(teamMembers)) {
|
||||||
|
return new TeamMemberCountResultCO()
|
||||||
|
.setMemberQuantity(0)
|
||||||
|
.setLevel(null)
|
||||||
|
.setTargetFormatSum("0")
|
||||||
|
.setTargetSum(0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取团队信息和政策管理器
|
||||||
|
TeamProfile teamProfile = teamProfileService.getById(cmd.getId());
|
||||||
|
if (teamProfile == null) {
|
||||||
|
return new TeamMemberCountResultCO()
|
||||||
|
.setMemberQuantity(teamMembers.size())
|
||||||
|
.setLevel(null)
|
||||||
|
.setTargetFormatSum("0")
|
||||||
|
.setTargetSum(0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
TeamPolicyManager teamPolicyManager = teamPolicyManagerService.getReleaseByRegionAndType(
|
||||||
|
teamProfile.getSysOrigin(), teamProfile.getRegion());
|
||||||
|
|
||||||
|
if (teamPolicyManager == null || CollectionUtils.isEmpty(teamPolicyManager.getPolicy())) {
|
||||||
|
return new TeamMemberCountResultCO()
|
||||||
|
.setMemberQuantity(teamMembers.size())
|
||||||
|
.setLevel(null)
|
||||||
|
.setTargetFormatSum("0")
|
||||||
|
.setTargetSum(0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取团队成员的目标总和
|
||||||
|
Set<Long> memberUserIds = teamMembers.stream().map(TeamMember::getMemberId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
Map<Long, TeamMemberTarget> teamMemberTargetMap = teamMemberTargetService.mapMemberBillTarget(
|
||||||
|
cmd.getId(), memberUserIds, ZonedDateTimeAsiaRiyadhUtils.nowYearMonthToInt());
|
||||||
|
|
||||||
|
// 计算目标总和
|
||||||
|
Long targetSum = teamMemberTargetMap.values().stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.mapToLong(target -> Optional.ofNullable(target.sumAcceptGiftValue()).orElse(0L))
|
||||||
|
.sum();
|
||||||
|
|
||||||
|
// 根据团队目标总和匹配对应的TeamPolicy返回对应的挡位
|
||||||
|
Integer matchedLevel = findMatchedLevel(teamPolicyManager.getPolicy(), targetSum);
|
||||||
|
|
||||||
|
return new TeamMemberCountResultCO()
|
||||||
|
.setMemberQuantity(teamMembers.size())
|
||||||
|
.setLevel(matchedLevel)
|
||||||
|
.setTargetFormatSum(NumUtils.formatLong(targetSum))
|
||||||
|
.setTargetSum(targetSum);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据目标总和查找匹配的等级.
|
||||||
|
* 逻辑:从高等级到低等级遍历,找到第一个满足条件的等级
|
||||||
|
*
|
||||||
|
* @param policies 政策列表
|
||||||
|
* @param targetSum 目标总和
|
||||||
|
* @return 匹配的等级,如果没有匹配则返回null
|
||||||
|
*/
|
||||||
|
private Integer findMatchedLevel(List<TeamPolicy> policies, Long targetSum) {
|
||||||
|
if (CollectionUtils.isEmpty(policies) || targetSum == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按等级降序排列,从高等级到低等级匹配
|
||||||
|
return policies.stream()
|
||||||
|
.sorted((p1, p2) -> Integer.compare(p2.getLevel(), p1.getLevel()))
|
||||||
|
.filter(policy -> targetSum >= Optional.ofNullable(policy.getTarget()).orElse(0L))
|
||||||
|
.findFirst()
|
||||||
|
.map(TeamPolicy::getLevel)
|
||||||
|
.orElse(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,20 +8,7 @@ import com.red.circle.common.business.dto.cmd.app.AppIdStringCmd;
|
|||||||
import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd;
|
import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd;
|
||||||
import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
|
import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
|
||||||
import com.red.circle.other.app.command.team.TeamHandleUserApplyExe;
|
import com.red.circle.other.app.command.team.TeamHandleUserApplyExe;
|
||||||
import com.red.circle.other.app.dto.clientobject.team.AnchorWorkStatisticsCO;
|
import com.red.circle.other.app.dto.clientobject.team.*;
|
||||||
import com.red.circle.other.app.dto.clientobject.team.MemberEntryTeamCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamBillCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamBillMemberWorkCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamMemberCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamMemberQuitAskCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamMemberTargetSettlementResultCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamMemberWorkCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamOwnMemberCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamPolicyManagerCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamProfileSearchResCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamQuitApplyInfoCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamUserApplyRecordCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamWaitApplyMessageCO;
|
|
||||||
import com.red.circle.other.app.dto.cmd.team.DateTypeQryCmd;
|
import com.red.circle.other.app.dto.cmd.team.DateTypeQryCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.team.TeamHandleUserApplyCmd;
|
import com.red.circle.other.app.dto.cmd.team.TeamHandleUserApplyCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.team.TeamMemberRoleChangeCmd;
|
import com.red.circle.other.app.dto.cmd.team.TeamMemberRoleChangeCmd;
|
||||||
@ -129,7 +116,7 @@ public class TeamServiceImpl implements TeamService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer countTeamMember(AppIdLongCmd cmd) {
|
public TeamMemberCountResultCO countTeamMember(AppIdLongCmd cmd) {
|
||||||
return teamMemberListQryExe.executeCount(cmd);
|
return teamMemberListQryExe.executeCount(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,41 @@
|
|||||||
|
package com.red.circle.other.app.dto.clientobject.team;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
|
import com.red.circle.framework.dto.ClientObject;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 团队成员统计结果.
|
||||||
|
*
|
||||||
|
* @author system
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class TeamMemberCountResultCO extends ClientObject {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成员数量.
|
||||||
|
*/
|
||||||
|
private Integer memberQuantity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 等级(挡位).
|
||||||
|
*/
|
||||||
|
private Integer level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 目标总和格式化.
|
||||||
|
*/
|
||||||
|
private String targetFormatSum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 目标总和原始值.
|
||||||
|
*/
|
||||||
|
@JsonSerialize(using = ToStringSerializer.class)
|
||||||
|
private Long targetSum;
|
||||||
|
|
||||||
|
}
|
||||||
@ -7,20 +7,7 @@ import com.red.circle.common.business.dto.cmd.app.AppIdLongCmd;
|
|||||||
import com.red.circle.common.business.dto.cmd.app.AppIdStringCmd;
|
import com.red.circle.common.business.dto.cmd.app.AppIdStringCmd;
|
||||||
import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd;
|
import com.red.circle.common.business.dto.cmd.app.AppRoomIdCmd;
|
||||||
import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
|
import com.red.circle.common.business.dto.cmd.app.AppUserIdCmd;
|
||||||
import com.red.circle.other.app.dto.clientobject.team.AnchorWorkStatisticsCO;
|
import com.red.circle.other.app.dto.clientobject.team.*;
|
||||||
import com.red.circle.other.app.dto.clientobject.team.MemberEntryTeamCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamBillCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamBillMemberWorkCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamMemberCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamMemberQuitAskCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamMemberTargetSettlementResultCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamMemberWorkCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamOwnMemberCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamPolicyManagerCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamProfileSearchResCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamQuitApplyInfoCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamUserApplyRecordCO;
|
|
||||||
import com.red.circle.other.app.dto.clientobject.team.TeamWaitApplyMessageCO;
|
|
||||||
import com.red.circle.other.app.dto.cmd.team.DateTypeQryCmd;
|
import com.red.circle.other.app.dto.cmd.team.DateTypeQryCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.team.TeamHandleUserApplyCmd;
|
import com.red.circle.other.app.dto.cmd.team.TeamHandleUserApplyCmd;
|
||||||
import com.red.circle.other.app.dto.cmd.team.TeamMemberRoleChangeCmd;
|
import com.red.circle.other.app.dto.cmd.team.TeamMemberRoleChangeCmd;
|
||||||
@ -63,7 +50,7 @@ public interface TeamService {
|
|||||||
/**
|
/**
|
||||||
* 团队成员数量
|
* 团队成员数量
|
||||||
*/
|
*/
|
||||||
Integer countTeamMember(AppIdLongCmd cmd);
|
TeamMemberCountResultCO countTeamMember(AppIdLongCmd cmd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取我的团队成员.
|
* 获取我的团队成员.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user