新代理政策-目标初始化新增region,countryCode

This commit is contained in:
tianfeng 2026-02-03 19:20:51 +08:00
parent b5eb179a10
commit 4878c1755c
3 changed files with 25 additions and 3 deletions

View File

@ -1,7 +1,9 @@
package com.red.circle.other.infra.common.team; package com.red.circle.other.infra.common.team;
import com.red.circle.component.redis.service.RedisService; import com.red.circle.component.redis.service.RedisService;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway; import com.red.circle.other.domain.gateway.user.ability.UserRegionGateway;
import com.red.circle.other.domain.model.user.UserProfile;
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.TeamProfile; import com.red.circle.other.infra.database.mongo.entity.team.team.TeamProfile;
@ -39,6 +41,7 @@ public class TeamTargetCommon {
private final TeamMemberService teamMemberService; private final TeamMemberService teamMemberService;
private final TeamProfileService teamProfileService; private final TeamProfileService teamProfileService;
private final TeamMemberTargetService teamMemberTargetService; private final TeamMemberTargetService teamMemberTargetService;
private final UserProfileGateway userProfileGateway;
/** /**
* 累计直播时间. * 累计直播时间.
@ -121,11 +124,14 @@ public class TeamTargetCommon {
VoidCallable<TeamTargetBillRes> consumer) { VoidCallable<TeamTargetBillRes> consumer) {
TeamMember teamMember = teamMemberService.getByMemberId(userId); TeamMember teamMember = teamMemberService.getByMemberId(userId);
if (Objects.isNull(teamMember)) { TeamProfile teamProfile = teamProfileService.getById(teamMember.getTeamId());
if (Objects.isNull(teamMember) || Objects.isNull(teamProfile)) {
return TeamTargetBillRes.of((long) getCalcBillBelong(), return TeamTargetBillRes.of((long) getCalcBillBelong(),
Boolean.FALSE); Boolean.FALSE);
} }
UserProfile userProfile = userProfileGateway.getByUserId(userId);
// 成员目标单据不存在 // 成员目标单据不存在
if (Boolean.FALSE.equals(existsBillTarget(userId))) { if (Boolean.FALSE.equals(existsBillTarget(userId))) {
@ -134,7 +140,7 @@ public class TeamTargetCommon {
if (Boolean.TRUE.equals(redisService.lock(key, 5))) { if (Boolean.TRUE.equals(redisService.lock(key, 5))) {
// 单据创建完成立刻解锁 // 单据创建完成立刻解锁
teamMemberTargetService.createMemberTarget(builderTeamMemberTarget(teamMember)); teamMemberTargetService.createMemberTarget(builderTeamMemberTarget(teamMember, teamProfile.getRegion(), userProfile.getCountryCode()));
redisService.unlock(key); redisService.unlock(key);
return consumer.apply(); return consumer.apply();
} }
@ -151,7 +157,7 @@ public class TeamTargetCommon {
return consumer.apply(); return consumer.apply();
} }
private TeamMemberTarget builderTeamMemberTarget(TeamMember teamMember) { private TeamMemberTarget builderTeamMemberTarget(TeamMember teamMember, String region, String countryCode) {
return new TeamMemberTarget() return new TeamMemberTarget()
.setTimeId(IdWorkerUtils.getId()) .setTimeId(IdWorkerUtils.getId())
@ -160,6 +166,8 @@ public class TeamTargetCommon {
.setBillBelong(getCalcBillBelong()) .setBillBelong(getCalcBillBelong())
.setBillTitle(getCalcBillBelong().toString()) .setBillTitle(getCalcBillBelong().toString())
.setUserId(teamMember.getMemberId()) .setUserId(teamMember.getMemberId())
.setRegion(region)
.setCountryCode(countryCode)
.setStatus(Boolean.TRUE.equals(getOpenDailyAutoSalary(teamMember)) .setStatus(Boolean.TRUE.equals(getOpenDailyAutoSalary(teamMember))
? TeamMemberTargetStatus.AUTO : TeamMemberTargetStatus.NOT_RECORDED) ? TeamMemberTargetStatus.AUTO : TeamMemberTargetStatus.NOT_RECORDED)
.setDailyTargets(List.of( .setDailyTargets(List.of(

View File

@ -11,6 +11,8 @@ import com.red.circle.mq.business.model.event.team.TeamSalaryCountEvent;
import com.red.circle.mq.rocket.business.producer.UserMqMessageService; import com.red.circle.mq.rocket.business.producer.UserMqMessageService;
import com.red.circle.mq.rocket.business.service.MessageSenderService; import com.red.circle.mq.rocket.business.service.MessageSenderService;
import com.red.circle.mq.rocket.business.streams.TeamSalaryCountSink; import com.red.circle.mq.rocket.business.streams.TeamSalaryCountSink;
import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.model.user.UserProfile;
import com.red.circle.other.infra.convertor.team.TeamInfraConvertor; import com.red.circle.other.infra.convertor.team.TeamInfraConvertor;
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamApplicationProcessApproval; import com.red.circle.other.infra.database.mongo.entity.team.team.TeamApplicationProcessApproval;
import com.red.circle.other.infra.database.mongo.entity.team.team.TeamImportanceLog; import com.red.circle.other.infra.database.mongo.entity.team.team.TeamImportanceLog;
@ -66,6 +68,7 @@ public class UpdateMemberTeamDecay {
private final TeamInfraConvertor teamInfraConvertor; private final TeamInfraConvertor teamInfraConvertor;
private final TeamProfileService teamProfileService; private final TeamProfileService teamProfileService;
private final TeamMemberAddDecay teamMemberAddDecay; private final TeamMemberAddDecay teamMemberAddDecay;
private final UserProfileGateway userProfileGateway;
private final SysRegionConfigService sysRegionConfigService; private final SysRegionConfigService sysRegionConfigService;
private final TeamMemberTargetService teamMemberTargetService; private final TeamMemberTargetService teamMemberTargetService;
private final TeamImportanceLogService teamImportanceLogService; private final TeamImportanceLogService teamImportanceLogService;
@ -94,6 +97,9 @@ public class UpdateMemberTeamDecay {
TeamProfile teamProfile = teamProfileService.getById(teamMember.getTeamId()); TeamProfile teamProfile = teamProfileService.getById(teamMember.getTeamId());
ResponseAssert.notNull(TeamErrorCode.USER_NOT_TEAM_MEMBER, teamProfile); ResponseAssert.notNull(TeamErrorCode.USER_NOT_TEAM_MEMBER, teamProfile);
UserProfile userProfile = userProfileGateway.getByUserId(param.getMemberUserId());
ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, userProfile);
// 移除成员 // 移除成员
TeamMember removeTeamMember = processRemoveTeamMember(teamMember.getSortId()); TeamMember removeTeamMember = processRemoveTeamMember(teamMember.getSortId());
if (Objects.isNull(removeTeamMember)) { if (Objects.isNull(removeTeamMember)) {
@ -161,6 +167,8 @@ public class UpdateMemberTeamDecay {
.setBillBelong(ZonedDateTimeAsiaRiyadhUtils.nowYearMonthToInt()) .setBillBelong(ZonedDateTimeAsiaRiyadhUtils.nowYearMonthToInt())
.setBillTitle(ZonedDateTimeAsiaRiyadhUtils.nowFormat(DateFormatConstant.MM_SLASH_YYYY)) .setBillTitle(ZonedDateTimeAsiaRiyadhUtils.nowFormat(DateFormatConstant.MM_SLASH_YYYY))
.setUserId(param.getMemberUserId()) .setUserId(param.getMemberUserId())
.setRegion(newTeamProfile.getRegion())
.setCountryCode(userProfile.getCountryCode())
.setStatus(Boolean.TRUE.equals(isOpenAutoSalary) ? TeamMemberTargetStatus.AUTO .setStatus(Boolean.TRUE.equals(isOpenAutoSalary) ? TeamMemberTargetStatus.AUTO
: TeamMemberTargetStatus.NOT_RECORDED) : TeamMemberTargetStatus.NOT_RECORDED)
.setDailyTargets(List.of( .setDailyTargets(List.of(

View File

@ -11,6 +11,7 @@ import com.red.circle.mq.rocket.business.streams.TeamSalaryCountSink;
import com.red.circle.other.app.inner.convertor.user.UserProfileInnerConvertor; import com.red.circle.other.app.inner.convertor.user.UserProfileInnerConvertor;
import com.red.circle.other.app.inner.service.team.TeamBillCycleClientService; import com.red.circle.other.app.inner.service.team.TeamBillCycleClientService;
import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.domain.gateway.user.UserProfileGateway;
import com.red.circle.other.domain.model.user.UserProfile;
import com.red.circle.other.infra.convertor.team.TeamInfraConvertor; import com.red.circle.other.infra.convertor.team.TeamInfraConvertor;
import com.red.circle.other.infra.database.mongo.dto.team.TeamBillMemberTarget; 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.TeamBillCycle;
@ -333,6 +334,9 @@ public class TeamBillCycleClientServiceImpl implements TeamBillCycleClientServic
teamProfileService.getById(teamMember.getTeamId()); teamProfileService.getById(teamMember.getTeamId());
ResponseAssert.notNull(TeamErrorCode.TEAM_NOT_FOUND, teamProfile); ResponseAssert.notNull(TeamErrorCode.TEAM_NOT_FOUND, teamProfile);
UserProfile userProfile = userProfileGateway.getByUserId(teamMember.getMemberId());
ResponseAssert.notNull(UserErrorCode.USER_INFO_NOT_FOUND, userProfile);
Boolean isOpenAutoSalary = isOpenDailyAutoSalary(teamProfile.getRegion()); Boolean isOpenAutoSalary = isOpenDailyAutoSalary(teamProfile.getRegion());
Integer billBelong = ZonedDateTimeAsiaRiyadhUtils.nowYearMonthToInt(); Integer billBelong = ZonedDateTimeAsiaRiyadhUtils.nowYearMonthToInt();
@ -363,6 +367,8 @@ public class TeamBillCycleClientServiceImpl implements TeamBillCycleClientServic
.setStatus(Boolean.TRUE.equals(isOpenAutoSalary) ? TeamMemberTargetStatus.AUTO .setStatus(Boolean.TRUE.equals(isOpenAutoSalary) ? TeamMemberTargetStatus.AUTO
: TeamMemberTargetStatus.NOT_RECORDED) : TeamMemberTargetStatus.NOT_RECORDED)
.setUserId(teamMember.getMemberId()) .setUserId(teamMember.getMemberId())
.setRegion(teamProfile.getRegion())
.setCountryCode(userProfile.getCountryCode())
.setDailyTargets(List.of(new TeamMemberTargetIndex() .setDailyTargets(List.of(new TeamMemberTargetIndex()
.setOwnOnlineTime(0L) .setOwnOnlineTime(0L)
.setOtherOnlineTime(0L) .setOtherOnlineTime(0L)