新增用户工资总余额查询
This commit is contained in:
parent
4488db2800
commit
c8007f3551
@ -36,6 +36,17 @@ public class SalaryAccountRestController extends BaseController {
|
||||
return salaryAccountService.getBalance(cmd.getReqUserId(), salaryType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询总余额(汇总所有工资类型).
|
||||
*
|
||||
* @param cmd 请求命令
|
||||
* @return 总余额信息
|
||||
*/
|
||||
@GetMapping("/balance/total")
|
||||
public SalaryAccountBalanceCO getTotalBalance(AppExtCommand cmd) {
|
||||
return salaryAccountService.getTotalBalance(cmd.getReqUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 发放工资.
|
||||
*
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
package com.red.circle.wallet.app.command.salary.query;
|
||||
|
||||
import com.red.circle.wallet.app.dto.clientobject.SalaryAccountBalanceCO;
|
||||
import com.red.circle.wallet.infra.database.rds.entity.salary.SalaryAccountBalance;
|
||||
import com.red.circle.wallet.infra.database.rds.service.salary.SalaryAccountBalanceService;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 查询工资账户总余额.
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class SalaryAccountBalanceTotalQryExe {
|
||||
|
||||
private final SalaryAccountBalanceService salaryAccountBalanceService;
|
||||
|
||||
public SalaryAccountBalanceCO execute(Long userId) {
|
||||
List<SalaryAccountBalance> balances = salaryAccountBalanceService.listByUserId(userId);
|
||||
|
||||
SalaryAccountBalanceCO co = new SalaryAccountBalanceCO();
|
||||
co.setUserId(userId);
|
||||
co.setEarnPoints(BigDecimal.ZERO);
|
||||
co.setConsumptionPoints(BigDecimal.ZERO);
|
||||
co.setBalance(BigDecimal.ZERO);
|
||||
co.setFrozenAmount(BigDecimal.ZERO);
|
||||
co.setAvailableBalance(BigDecimal.ZERO);
|
||||
|
||||
if (balances == null || balances.isEmpty()) {
|
||||
return co;
|
||||
}
|
||||
|
||||
for (SalaryAccountBalance balance : balances) {
|
||||
if (balance.getEarnPoints() != null) {
|
||||
co.setEarnPoints(co.getEarnPoints().add(balance.getEarnPoints()));
|
||||
}
|
||||
if (balance.getConsumptionPoints() != null) {
|
||||
co.setConsumptionPoints(co.getConsumptionPoints().add(balance.getConsumptionPoints()));
|
||||
}
|
||||
if (balance.getBalance() != null) {
|
||||
co.setBalance(co.getBalance().add(balance.getBalance()));
|
||||
}
|
||||
if (balance.getFrozenAmount() != null) {
|
||||
co.setFrozenAmount(co.getFrozenAmount().add(balance.getFrozenAmount()));
|
||||
}
|
||||
if (balance.getAvailableBalance() != null) {
|
||||
co.setAvailableBalance(co.getAvailableBalance().add(balance.getAvailableBalance()));
|
||||
}
|
||||
}
|
||||
|
||||
return co;
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ import com.red.circle.wallet.app.command.salary.SalaryIssueCmdExe;
|
||||
import com.red.circle.wallet.app.command.salary.SalaryTransferGoldCmdExe;
|
||||
import com.red.circle.wallet.app.command.salary.SalaryWithdrawRefundCmdExe;
|
||||
import com.red.circle.wallet.app.command.salary.query.SalaryAccountBalanceQryExe;
|
||||
import com.red.circle.wallet.app.command.salary.query.SalaryAccountBalanceTotalQryExe;
|
||||
import com.red.circle.wallet.app.command.salary.query.SalaryRunningWaterQryExe;
|
||||
import com.red.circle.wallet.app.command.salary.query.SalaryTotalIncomeQryExe;
|
||||
import com.red.circle.wallet.app.dto.clientobject.*;
|
||||
@ -25,6 +26,7 @@ import java.util.Objects;
|
||||
public class SalaryAccountServiceImpl implements SalaryAccountService {
|
||||
|
||||
private final SalaryAccountBalanceQryExe salaryAccountBalanceQryExe;
|
||||
private final SalaryAccountBalanceTotalQryExe salaryAccountBalanceTotalQryExe;
|
||||
private final SalaryRunningWaterQryExe salaryRunningWaterQryExe;
|
||||
private final SalaryIssueCmdExe salaryIssueCmdExe;
|
||||
private final SalaryWithdrawRefundCmdExe salaryWithdrawRefundCmdExe;
|
||||
@ -37,6 +39,11 @@ public class SalaryAccountServiceImpl implements SalaryAccountService {
|
||||
return salaryAccountBalanceQryExe.execute(userId, SalaryType.of(salaryType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public SalaryAccountBalanceCO getTotalBalance(Long userId) {
|
||||
return salaryAccountBalanceTotalQryExe.execute(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SalaryIssueResultCO issueSalary(SalaryIssueCmd cmd) {
|
||||
return salaryIssueCmdExe.execute(cmd);
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
package com.red.circle.wallet.app.dto.clientobject;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 工资账户总余额.
|
||||
*/
|
||||
@Data
|
||||
public class SalaryAccountTotalBalanceCO {
|
||||
|
||||
/**
|
||||
* 用户ID.
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 总余额.
|
||||
*/
|
||||
private BigDecimal totalBalance;
|
||||
|
||||
/**
|
||||
* 总可用余额.
|
||||
*/
|
||||
private BigDecimal totalAvailableBalance;
|
||||
|
||||
/**
|
||||
* 各类型余额明细.
|
||||
*/
|
||||
private List<SalaryAccountBalanceCO> details;
|
||||
}
|
||||
@ -47,6 +47,14 @@ public interface SalaryAccountService {
|
||||
|
||||
UserBankExchangeGoldResultCO exchangeGold(SalaryWithdrawCmd cmd);
|
||||
|
||||
/**
|
||||
* 查询总余额(汇总所有工资类型).
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 总余额信息
|
||||
*/
|
||||
SalaryAccountBalanceCO getTotalBalance(Long userId);
|
||||
|
||||
/**
|
||||
* 查询用户累计收入.
|
||||
*
|
||||
|
||||
@ -86,4 +86,9 @@ public interface SalaryAccountBalanceService extends BaseService<SalaryAccountBa
|
||||
* @return 账户信息
|
||||
*/
|
||||
SalaryAccountBalance getByUserIdAndType(Long userId, SalaryType salaryType);
|
||||
|
||||
/**
|
||||
* 查询用户所有工资类型的账户列表.
|
||||
*/
|
||||
java.util.List<SalaryAccountBalance> listByUserId(Long userId);
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import com.red.circle.wallet.infra.database.rds.dao.salary.SalaryAccountBalanceD
|
||||
import com.red.circle.wallet.infra.database.rds.entity.salary.SalaryAccountBalance;
|
||||
import com.red.circle.wallet.infra.database.rds.service.salary.SalaryAccountBalanceService;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -78,6 +79,13 @@ public class SalaryAccountBalanceServiceImpl
|
||||
return salaryAccountBalanceDAO.unfreezeAmount(userId, salaryType.getCode(), amount, version) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SalaryAccountBalance> listByUserId(Long userId) {
|
||||
LambdaQueryWrapper<SalaryAccountBalance> wrapper = Wrappers.lambdaQuery(SalaryAccountBalance.class)
|
||||
.eq(SalaryAccountBalance::getUserId, userId);
|
||||
return list(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SalaryAccountBalance getByUserIdAndType(Long userId, SalaryType salaryType) {
|
||||
LambdaQueryWrapper<SalaryAccountBalance> wrapper = Wrappers.lambdaQuery(SalaryAccountBalance.class)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user