新增 用户累计充值接口

This commit is contained in:
tianfeng 2025-11-10 19:51:52 +08:00
parent be98952463
commit 5864254890

View File

@ -1,9 +1,15 @@
package com.red.circle.other.adapter.app.user.user;
import com.red.circle.common.business.dto.cmd.UserIdCmd;
import com.red.circle.order.inner.endpoint.TotalRechargeClient;
import com.red.circle.order.inner.model.dto.UserTotalRechargeDTO;
import com.red.circle.other.app.dto.clientobject.user.user.UserGuardCountCO;
import com.red.circle.other.app.service.user.user.UserCountService;
import java.util.List;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
@ -25,6 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
public class UserCountRestController {
private final UserCountService userCountService;
private final TotalRechargeClient totalRechargeClient;
/**
* 守护列表.
@ -40,4 +47,20 @@ public class UserCountRestController {
return userCountService.listUserGuardCountTop(cmd);
}
/**
* 用户累计充值
*/
@GetMapping("/total-recharge")
public BigDecimal getTotalRecharge(UserIdCmd cmd) {
Set<Long> uIdSet = new HashSet<>();
uIdSet.add(cmd.getReqUserId());
Map<Long, List<UserTotalRechargeDTO>> userTotalRechargeMap = totalRechargeClient.mapGroup(uIdSet).getBody();
return Optional.ofNullable(userTotalRechargeMap.get(cmd.getReqUserId()))
.map(totalRecharges -> totalRecharges.stream().map(UserTotalRechargeDTO::getAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add)
.setScale(2, RoundingMode.DOWN))
.orElse(BigDecimal.ZERO);
}
}