diff --git a/rc-service/rc-inner-api/wallet-inner/wallet-inner-api/src/main/java/com/red/circle/wallet/inner/endpoint/salary/api/UserSalaryAccountClientApi.java b/rc-service/rc-inner-api/wallet-inner/wallet-inner-api/src/main/java/com/red/circle/wallet/inner/endpoint/salary/api/UserSalaryAccountClientApi.java index 221be203..6fae657b 100644 --- a/rc-service/rc-inner-api/wallet-inner/wallet-inner-api/src/main/java/com/red/circle/wallet/inner/endpoint/salary/api/UserSalaryAccountClientApi.java +++ b/rc-service/rc-inner-api/wallet-inner/wallet-inner-api/src/main/java/com/red/circle/wallet/inner/endpoint/salary/api/UserSalaryAccountClientApi.java @@ -51,6 +51,9 @@ public interface UserSalaryAccountClientApi { * 查询用户累计收入. */ @GetMapping("/total-income") - ResultResponse getTotalIncome(@RequestParam("userId") Long userId, @RequestParam("salaryType") String salaryType); + ResultResponse getTotalIncome(@RequestParam("userId") Long userId, + @RequestParam("salaryType") String salaryType, + @RequestParam(value = "startTime", required = false) String startTime, + @RequestParam(value = "endTime", required = false) String endTime); } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/user/RechargeUserServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/user/RechargeUserServiceImpl.java index b236f156..3de6856a 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/user/RechargeUserServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/user/user/RechargeUserServiceImpl.java @@ -12,6 +12,7 @@ import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO; import com.red.circle.other.app.dto.h5.RechargePageVO; import com.red.circle.other.app.dto.h5.RechargeSummaryVO; import com.red.circle.other.app.service.recharge.RechargeUserService; +import com.red.circle.other.infra.database.mongo.service.team.TeamBillCycleUtils; import com.red.circle.other.infra.database.rds.entity.team.AdminRechargeAgentRelation; import com.red.circle.other.infra.database.rds.service.sys.AdministratorService; import com.red.circle.other.infra.database.rds.service.team.AdminRechargeAgentRelationService; @@ -90,6 +91,7 @@ public class RechargeUserServiceImpl implements RechargeUserService { @Override public RechargeSummaryVO getRechargeSummary(AppExtCommand cmd) { + Page objectPage = new Page<>(); objectPage.setCurrent(1L); objectPage.setSize(3000L); @@ -102,18 +104,29 @@ public class RechargeUserServiceImpl implements RechargeUserService { List relations = pagedRechargeAgency.getRecords(); + Integer currentBillBelong = TeamBillCycleUtils.getCalcBillBelong(); + LocalDateTime startTime = TeamBillCycleUtils.getBillBelongStartTime(currentBillBelong); + LocalDateTime endTime = TeamBillCycleUtils.getBillBelongEndTime(currentBillBelong); BigDecimal currentMonthRecharge = BigDecimal.ZERO; for (AdminRechargeAgentRelation relation : relations) { - String monthStart = relation.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); - String monthEnd = YearMonth.now().atEndOfMonth().atTime(23, 59, 59).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + String monthStart = relation.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); + String monthEnd = YearMonth.now().atEndOfMonth().atTime(23, 59, 59).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); +// LocalDateTime actualStartTime = relation.getCreateTime().isAfter(startTime) +// ? relation.getCreateTime() +// : startTime; +// +// String monthStart = actualStartTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); +// String monthEnd = endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); BigDecimal monthRecharge = freightGoldClient.getTotalAmountByCondition(relation.getUserId(), monthStart, monthEnd, RECHARGE_TYPE).getBody(); currentMonthRecharge = currentMonthRecharge.add(monthRecharge != null ? monthRecharge : BigDecimal.ZERO); } return new RechargeSummaryVO() - .setTotalIncome(userSalaryAccountClient.getTotalIncome(cmd.getReqUserId(), "ADMIN_SALARY").getBody()) + .setTotalIncome(userSalaryAccountClient.getTotalIncome(cmd.getReqUserId(), "ADMIN_SALARY", + startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")), + endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))).getBody()) .setCurrentMonthRecharge(currentMonthRecharge) .setCount(pagedRechargeAgency.getRecords().size()); } diff --git a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/salary/query/SalaryTotalIncomeQryExe.java b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/salary/query/SalaryTotalIncomeQryExe.java index a424225c..1b5a31b5 100644 --- a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/salary/query/SalaryTotalIncomeQryExe.java +++ b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/command/salary/query/SalaryTotalIncomeQryExe.java @@ -1,11 +1,13 @@ package com.red.circle.wallet.app.command.salary.query; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.red.circle.framework.mybatis.entity.TimestampBaseEntity; import com.red.circle.wallet.inner.model.enums.SalaryType; import com.red.circle.wallet.infra.database.rds.entity.salary.SalaryAccountRunningWater; import com.red.circle.wallet.infra.database.rds.service.salary.SalaryAccountRunningWaterService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; import java.math.BigDecimal; import java.util.List; @@ -19,11 +21,14 @@ public class SalaryTotalIncomeQryExe { private final SalaryAccountRunningWaterService salaryAccountRunningWaterService; - public BigDecimal execute(Long userId, SalaryType salaryType) { + public BigDecimal execute(Long userId, SalaryType salaryType, String startTime, String endTime) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SalaryAccountRunningWater::getUserId, userId) .eq(SalaryAccountRunningWater::getSalaryType, salaryType.getCode()) - .eq(SalaryAccountRunningWater::getType, 0); + .eq(SalaryAccountRunningWater::getType, 0) + .gt(StringUtils.hasText(startTime), TimestampBaseEntity::getCreateTime, startTime) + .lt(StringUtils.hasText(endTime), TimestampBaseEntity::getCreateTime, endTime); + ; List records = salaryAccountRunningWaterService.list(wrapper); diff --git a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/service/SalaryAccountServiceImpl.java b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/service/SalaryAccountServiceImpl.java index b7e72312..9578b76d 100644 --- a/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/service/SalaryAccountServiceImpl.java +++ b/rc-service/rc-service-wallet/wallet-application/src/main/java/com/red/circle/wallet/app/service/SalaryAccountServiceImpl.java @@ -63,7 +63,7 @@ public class SalaryAccountServiceImpl implements SalaryAccountService { } @Override - public BigDecimal getTotalIncome(Long userId, String salaryType) { - return salaryTotalIncomeQryExe.execute(userId, Objects.requireNonNull(SalaryType.of(salaryType))); + public BigDecimal getTotalIncome(Long userId, String salaryType, String startTime, String endTime) { + return salaryTotalIncomeQryExe.execute(userId, Objects.requireNonNull(SalaryType.of(salaryType)), startTime, endTime); } } diff --git a/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/service/SalaryAccountService.java b/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/service/SalaryAccountService.java index c87de516..b959abcc 100644 --- a/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/service/SalaryAccountService.java +++ b/rc-service/rc-service-wallet/wallet-client/src/main/java/com/red/circle/wallet/app/service/SalaryAccountService.java @@ -54,5 +54,5 @@ public interface SalaryAccountService { * @param salaryType 工资类型 * @return 累计收入 */ - BigDecimal getTotalIncome(Long userId, String salaryType); + BigDecimal getTotalIncome(Long userId, String salaryType, String startTime, String endTime); } diff --git a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/endpoint/salary/UserSalaryAccountClientEndpoint.java b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/endpoint/salary/UserSalaryAccountClientEndpoint.java index 6267f269..9eaec30f 100644 --- a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/endpoint/salary/UserSalaryAccountClientEndpoint.java +++ b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/endpoint/salary/UserSalaryAccountClientEndpoint.java @@ -52,7 +52,7 @@ public class UserSalaryAccountClientEndpoint implements UserSalaryAccountClientA } @Override - public ResultResponse getTotalIncome(Long userId, String salaryType) { - return ResultResponse.success(userSalaryAccountClientService.getTotalIncome(userId, salaryType)); + public ResultResponse getTotalIncome(Long userId, String salaryType, String startTime, String endTime) { + return ResultResponse.success(userSalaryAccountClientService.getTotalIncome(userId, salaryType, startTime, endTime)); } } diff --git a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/UserSalaryAccountClientService.java b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/UserSalaryAccountClientService.java index 0a29701b..fb4afa4f 100644 --- a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/UserSalaryAccountClientService.java +++ b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/UserSalaryAccountClientService.java @@ -38,5 +38,5 @@ public interface UserSalaryAccountClientService { /** * 查询用户累计收入. */ - BigDecimal getTotalIncome(Long userId, String salaryType); + BigDecimal getTotalIncome(Long userId, String salaryType, String startTime, String endTime); } diff --git a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/impl/UserSalaryAccountClientServiceImpl.java b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/impl/UserSalaryAccountClientServiceImpl.java index c2c3ff39..bd78b04f 100644 --- a/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/impl/UserSalaryAccountClientServiceImpl.java +++ b/rc-service/rc-service-wallet/wallet-inner-endpoint/src/main/java/com/red/circle/wallet/inner/service/salary/impl/UserSalaryAccountClientServiceImpl.java @@ -70,8 +70,8 @@ public class UserSalaryAccountClientServiceImpl implements UserSalaryAccountClie } @Override - public BigDecimal getTotalIncome(Long userId, String salaryType) { - BigDecimal totalIncome = salaryAccountService.getTotalIncome(userId, salaryType); + public BigDecimal getTotalIncome(Long userId, String salaryType, String startTime, String endTime) { + BigDecimal totalIncome = salaryAccountService.getTotalIncome(userId, salaryType, startTime, endTime); return totalIncome != null ? totalIncome : BigDecimal.ZERO; } }