From 5ca71e6a1bb1257759276d814c710fc13a09cf11 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Tue, 28 Oct 2025 17:54:49 +0800 Subject: [PATCH] =?UTF-8?q?bd=20=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/team/TeamBdRestController.java | 2 +- .../query/TeamBdMemberBillDetailQryExe.java | 40 +------------ .../bd/query/TeamBdMemberBillListQryExe.java | 54 +++++------------ .../dto/cmd/TeamBdMemberBillDetailCmd.java | 6 +- .../service/team/TeamBillCycleUtils.java | 59 +++++++++++++++++++ 5 files changed, 83 insertions(+), 78 deletions(-) diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java index 4578c4da..03d3bcfb 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/team/TeamBdRestController.java @@ -266,7 +266,7 @@ public class TeamBdRestController extends BaseController { * @eo.request-type formdata */ @GetMapping("/member-bill/detail-list") - public List queryMemberBillDetailList(@Validated TeamBdMemberBillDetailCmd cmd) { + public List queryMemberBillDetailList(TeamBdMemberBillDetailCmd cmd) { return teamBdBillService.queryMemberBillDetailList(cmd); } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/TeamBdMemberBillDetailQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/TeamBdMemberBillDetailQryExe.java index 49dba262..45fbc6b1 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/TeamBdMemberBillDetailQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/TeamBdMemberBillDetailQryExe.java @@ -9,6 +9,7 @@ import com.red.circle.other.infra.database.mongo.dto.team.TeamBillSettleResult; 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.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.TeamProfileService; @@ -83,7 +84,7 @@ public class TeamBdMemberBillDetailQryExe { TeamBdMemberBillDetailCO co = new TeamBdMemberBillDetailCO(); // 1. 账单周期日期 - String[] dates = parseBillBelongToDateRange(billCycle.getBillBelong()); + String[] dates = TeamBillCycleUtils.parseBillBelongToDateRange(billCycle.getBillBelong()); co.setStartDate(dates[0]); co.setEndDate(dates[1]); @@ -180,7 +181,7 @@ public class TeamBdMemberBillDetailQryExe { // 薪资(totalSalary) co.setSalary(settlementResult.getTotalSalary()); // 充值(acceptGiftValue) - co.setRecharge(new BigDecimal(Optional.ofNullable(settlementResult.getAcceptGiftValue()).orElse(0L))); + co.setRecharge(BigDecimal.ZERO); } else { co.setSalary(BigDecimal.ZERO); co.setRecharge(BigDecimal.ZERO); @@ -191,39 +192,4 @@ public class TeamBdMemberBillDetailQryExe { return co; } - - /** - * 解析 billBelong 为日期范围. - * - * @param billBelong 账单归属(格式:20251001 或 20251016) - * @return 日期范围数组 [startDate, endDate],格式:yyyy.MM.dd - */ - private String[] parseBillBelongToDateRange(Integer billBelong) { - if (billBelong == null) { - return new String[]{"", ""}; - } - - String billBelongStr = String.valueOf(billBelong); - int year = Integer.parseInt(billBelongStr.substring(0, 4)); - int month = Integer.parseInt(billBelongStr.substring(4, 6)); - int day = Integer.parseInt(billBelongStr.substring(6, 8)); - - LocalDate startDate = LocalDate.of(year, month, day); - LocalDate endDate; - - if (day == 1) { - // 1-15号的账单周期 - endDate = LocalDate.of(year, month, 15); - } else { - // 16-月末的账单周期 - endDate = startDate.withDayOfMonth(startDate.lengthOfMonth()); - } - - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd"); - return new String[]{ - startDate.format(formatter), - endDate.format(formatter) - }; - } - } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/TeamBdMemberBillListQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/TeamBdMemberBillListQryExe.java index 6ce95bfd..019e6910 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/TeamBdMemberBillListQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/bd/query/TeamBdMemberBillListQryExe.java @@ -6,9 +6,11 @@ import com.red.circle.other.app.dto.cmd.TeamBdMemberBillCmd; import com.red.circle.other.domain.gateway.user.UserProfileGateway; import com.red.circle.other.infra.database.mongo.dto.team.TeamBillSettleResult; import com.red.circle.other.infra.database.mongo.entity.team.team.TeamBillCycle; +import com.red.circle.other.infra.database.mongo.entity.team.team.TeamMember; 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.TeamMemberService; import com.red.circle.other.infra.database.mongo.service.team.team.TeamProfileService; import com.red.circle.other.infra.database.rds.entity.team.BusinessDevelopmentTeam; import com.red.circle.other.infra.database.rds.service.team.BusinessDevelopmentBaseInfoService; @@ -24,6 +26,7 @@ import org.springframework.stereotype.Component; import java.math.BigDecimal; import java.time.LocalDate; +import java.time.YearMonth; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -45,6 +48,7 @@ public class TeamBdMemberBillListQryExe { private final UserProfileGateway userProfileGateway; private final UserProfileAppConvertor userProfileAppConvertor; private final BdTeamLeaderClient bdTeamLeaderClient; + private final TeamMemberService teamMemberService; /** * 执行查询. @@ -59,7 +63,7 @@ public class TeamBdMemberBillListQryExe { if (Boolean.TRUE.equals(bdLeader)) { bdTeamList.addAll(businessDevelopmentTeamService.listByUserId(cmd.getReqUserId())); } else { - bdTeamList.add(businessDevelopmentTeamService.getByAgentId(cmd.getReqUserId())); + bdTeamList.addAll(buildBdTeamVO(teamMemberService.listTeamMember(cmd.getReqUserId(), 100))); } // 1. 查询BD关联的所有代理 @@ -95,7 +99,16 @@ public class TeamBdMemberBillListQryExe { .collect(Collectors.toList()); } - /** + private Collection buildBdTeamVO(List teamMembers) { + return teamMembers.stream().map(e -> { + BusinessDevelopmentTeam businessDevelopmentTeam = new BusinessDevelopmentTeam(); + businessDevelopmentTeam.setTeamId(e.getTeamId()); + businessDevelopmentTeam.setAgentId(e.getMemberId()); + return businessDevelopmentTeam; + }).toList(); + } + + /** * 构建成员账单CO. */ private TeamBdMemberBillCO buildMemberBillCO( @@ -129,7 +142,7 @@ public class TeamBdMemberBillListQryExe { } // 账单周期日期(从 billBelong 解析) - String[] dates = parseBillBelongToDateRange(billBelong); + String[] dates = TeamBillCycleUtils.parseBillBelongToDateRange(billBelong); co.setStartDate(dates[0]); co.setEndDate(dates[1]); @@ -170,39 +183,4 @@ public class TeamBdMemberBillListQryExe { return co; } - - /** - * 解析 billBelong 为日期范围. - * - * @param billBelong 账单归属(格式:20251001 或 20251016) - * @return 日期范围数组 [startDate, endDate],格式:yyyy.MM.dd - */ - private String[] parseBillBelongToDateRange(Integer billBelong) { - if (billBelong == null) { - return new String[]{"", ""}; - } - - String billBelongStr = String.valueOf(billBelong); - int year = Integer.parseInt(billBelongStr.substring(0, 4)); - int month = Integer.parseInt(billBelongStr.substring(4, 6)); - int day = Integer.parseInt(billBelongStr.substring(6, 8)); - - LocalDate startDate = LocalDate.of(year, month, day); - LocalDate endDate; - - if (day == 1) { - // 1-15号的账单周期 - endDate = LocalDate.of(year, month, 15); - } else { - // 16-月末的账单周期 - endDate = startDate.withDayOfMonth(startDate.lengthOfMonth()); - } - - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd"); - return new String[]{ - startDate.format(formatter), - endDate.format(formatter) - }; - } - } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/TeamBdMemberBillDetailCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/TeamBdMemberBillDetailCmd.java index a2ae3704..7201fa7a 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/TeamBdMemberBillDetailCmd.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/TeamBdMemberBillDetailCmd.java @@ -15,8 +15,10 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) public class TeamBdMemberBillDetailCmd extends AppExtCommand { - @NotNull(message = "teamId不能为空") - private Long teamId; + /** + * 团队ID + */ + private Long teamId; } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/TeamBillCycleUtils.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/TeamBillCycleUtils.java index a47327f3..b78e00fb 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/TeamBillCycleUtils.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/mongo/service/team/TeamBillCycleUtils.java @@ -19,6 +19,7 @@ import org.slf4j.LoggerFactory; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; +import java.time.YearMonth; import java.time.format.DateTimeFormatter; import java.util.Comparator; import java.util.List; @@ -502,4 +503,62 @@ public final class TeamBillCycleUtils { return Integer.parseInt(billDate.format(DateTimeFormatter.ofPattern("yyyyMMdd"))); } + /** + * 解析 billBelong 为日期范围. + * 兼容两种格式: + * 1. 旧格式(6位):202510 表示整月 (2025年10月) + * 2. 新格式(8位):20251001 或 20251016 表示半月周期 + * + * @param billBelong 账单归属 + * @return 日期范围数组 [startDate, endDate],格式:yyyy.MM.dd + */ + public static String[] parseBillBelongToDateRange(Integer billBelong) { + if (billBelong == null) { + return new String[]{"", ""}; + } + + String billBelongStr = String.valueOf(billBelong); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd"); + + // 判断是旧格式(6位)还是新格式(8位) + if (billBelongStr.length() == 6) { + // 旧格式:202510 表示整月 + int year = Integer.parseInt(billBelongStr.substring(0, 4)); + int month = Integer.parseInt(billBelongStr.substring(4, 6)); + + YearMonth yearMonth = YearMonth.of(year, month); + LocalDate startDate = yearMonth.atDay(1); + LocalDate endDate = yearMonth.atEndOfMonth(); + + return new String[]{ + startDate.format(formatter), + endDate.format(formatter) + }; + } else if (billBelongStr.length() == 8) { + // 新格式:20251001 或 20251016 表示半月周期 + int year = Integer.parseInt(billBelongStr.substring(0, 4)); + int month = Integer.parseInt(billBelongStr.substring(4, 6)); + int day = Integer.parseInt(billBelongStr.substring(6, 8)); + + LocalDate startDate = LocalDate.of(year, month, day); + LocalDate endDate; + + if (day == 1) { + // 1-15号的账单周期 + endDate = LocalDate.of(year, month, 15); + } else { + // 16-月末的账单周期 + endDate = startDate.withDayOfMonth(startDate.lengthOfMonth()); + } + + return new String[]{ + startDate.format(formatter), + endDate.format(formatter) + }; + } else { + // 格式不正确,返回空字符串 + return new String[]{"", ""}; + } + } + }