bd 相关接口修改

This commit is contained in:
tianfeng 2025-10-28 17:54:49 +08:00
parent 4f728d1f5d
commit 5ca71e6a1b
5 changed files with 83 additions and 78 deletions

View File

@ -266,7 +266,7 @@ public class TeamBdRestController extends BaseController {
* @eo.request-type formdata
*/
@GetMapping("/member-bill/detail-list")
public List<TeamBdMemberBillDetailCO> queryMemberBillDetailList(@Validated TeamBdMemberBillDetailCmd cmd) {
public List<TeamBdMemberBillDetailCO> queryMemberBillDetailList(TeamBdMemberBillDetailCmd cmd) {
return teamBdBillService.queryMemberBillDetailList(cmd);
}

View File

@ -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)
};
}
}

View File

@ -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<? extends BusinessDevelopmentTeam> buildBdTeamVO(List<TeamMember> 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)
};
}
}

View File

@ -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;
}

View File

@ -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[]{"", ""};
}
}
}