管理员总收入修改i

This commit is contained in:
tianfeng 2025-12-16 17:09:47 +08:00
parent ce4529ea5c
commit 5fe5405dbb
8 changed files with 35 additions and 14 deletions

View File

@ -51,6 +51,9 @@ public interface UserSalaryAccountClientApi {
* 查询用户累计收入.
*/
@GetMapping("/total-income")
ResultResponse<BigDecimal> getTotalIncome(@RequestParam("userId") Long userId, @RequestParam("salaryType") String salaryType);
ResultResponse<BigDecimal> getTotalIncome(@RequestParam("userId") Long userId,
@RequestParam("salaryType") String salaryType,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime);
}

View File

@ -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<AdminRechargeAgentRelation> objectPage = new Page<>();
objectPage.setCurrent(1L);
objectPage.setSize(3000L);
@ -102,18 +104,29 @@ public class RechargeUserServiceImpl implements RechargeUserService {
List<AdminRechargeAgentRelation> 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());
}

View File

@ -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<SalaryAccountRunningWater> 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<SalaryAccountRunningWater> records = salaryAccountRunningWaterService.list(wrapper);

View File

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

View File

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

View File

@ -52,7 +52,7 @@ public class UserSalaryAccountClientEndpoint implements UserSalaryAccountClientA
}
@Override
public ResultResponse<BigDecimal> getTotalIncome(Long userId, String salaryType) {
return ResultResponse.success(userSalaryAccountClientService.getTotalIncome(userId, salaryType));
public ResultResponse<BigDecimal> getTotalIncome(Long userId, String salaryType, String startTime, String endTime) {
return ResultResponse.success(userSalaryAccountClientService.getTotalIncome(userId, salaryType, startTime, endTime));
}
}

View File

@ -38,5 +38,5 @@ public interface UserSalaryAccountClientService {
/**
* 查询用户累计收入.
*/
BigDecimal getTotalIncome(Long userId, String salaryType);
BigDecimal getTotalIncome(Long userId, String salaryType, String startTime, String endTime);
}

View File

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