计算金额 类型问题

This commit is contained in:
wangw 2025-10-27 21:21:30 +08:00
parent b4cba628d4
commit 316b618e24
2 changed files with 26 additions and 24 deletions

View File

@ -13,28 +13,29 @@ public class DistributionCenterTopVO {
/** /**
* 总收益 * 总收益
*/ */
private String totalIncome; private Double totalIncome;
/** /**
* 待入账 * 待入账
*/ */
private String pendingIncome; private Double pendingIncome;
/** /**
* 已提现 * 已提现
*/ */
private String cashOutAmount; private Double cashOutAmount;
public String getTotalIncome() { public Double getTotalIncome() {
return totalIncome == null ? "0" : totalIncome; return totalIncome == null ? 0.0 : totalIncome;
}
public String getPendingIncome() {
return pendingIncome == null ? "0" : pendingIncome;
} }
public String getCashOutAmount() { public Double getPendingIncome() {
return cashOutAmount == null ? "0" : cashOutAmount; return pendingIncome == null ? 0.0 : pendingIncome;
} }
public String getUnCashOutAmount() { public Double getCashOutAmount() {
return new BigDecimal(getTotalIncome()).subtract(new BigDecimal(getPendingIncome())).subtract(new BigDecimal(getCashOutAmount())).toString(); return cashOutAmount == null ? 0.0 : cashOutAmount;
}
public Double getUnCashOutAmount() {
return getTotalIncome() - getPendingIncome() - getCashOutAmount();
} }
} }

View File

@ -92,20 +92,21 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
@Override @Override
public Map<String, Object> centerUser(Long userId) { public Map<String, Object> centerUser(Long userId) {
// QueryWrapper totalIncomeSumQueryWrapper = new QueryWrapper(); DistributionCenterTopVO centerTopVO = null;
// totalIncomeSumQueryWrapper.select("sum(total_income) as totalIncome,sum(pending_income) as pendingIncome,sum(withdrawn_income) as cashOutAmount"); try {
// totalIncomeSumQueryWrapper.eq(MkDistributionUser::getUserId, userId); QueryWrapper totalIncomeSumQueryWrapper = new QueryWrapper();
// totalIncomeSumQueryWrapper.eq(MkDistributionUser::getIsDel, 0); totalIncomeSumQueryWrapper.select("sum(total_income) as totalIncome,sum(pending_income) as pendingIncome,sum(withdrawn_income) as cashOutAmount");
// DistributionCenterTopVO centerTopVO = getObjAs(totalIncomeSumQueryWrapper, DistributionCenterTopVO.class); totalIncomeSumQueryWrapper.eq(MkDistributionUser::getUserId, userId);
totalIncomeSumQueryWrapper.eq(MkDistributionUser::getIsDel, 0);
centerTopVO = getObjAs(totalIncomeSumQueryWrapper, DistributionCenterTopVO.class);
}catch (Exception e){
log.error("查询用户中心数据失败", e);
}
// 封装顶部收益数据 // 封装顶部收益数据
Map<String, Object> result = new HashMap<>(5); Map<String, Object> result = new HashMap<>(5);
// result.put("totalIncome", centerTopVO == null ? BigDecimal.ZERO : centerTopVO.getTotalIncome()); result.put("totalIncome", centerTopVO == null ? 0.0 : centerTopVO.getTotalIncome());
// result.put("pendingIncome", centerTopVO == null ? BigDecimal.ZERO : centerTopVO.getPendingIncome()); result.put("pendingIncome", centerTopVO == null ? 0.0 : centerTopVO.getPendingIncome());
// result.put("cashOutAmount", centerTopVO == null ? BigDecimal.ZERO : centerTopVO.getUnCashOutAmount()); result.put("cashOutAmount", centerTopVO == null ? 0.0 : centerTopVO.getCashOutAmount());
result.put("totalIncome", 0);
result.put("pendingIncome", 0);
result.put("cashOutAmount", 0);
result.put("activates", activates(userId, 1, 5)); result.put("activates", activates(userId, 1, 5));
result.put("unActivates", unActivates(userId, 1, 3)); result.put("unActivates", unActivates(userId, 1, 3));