From 5864254890bc4463724f7bcf1929dec69dcd286f Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 10 Nov 2025 19:51:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=B4=AF=E8=AE=A1=E5=85=85=E5=80=BC=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/user/UserCountRestController.java | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/user/user/UserCountRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/user/user/UserCountRestController.java index 3c02021b..6c0de8c0 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/user/user/UserCountRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/user/user/UserCountRestController.java @@ -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 uIdSet = new HashSet<>(); + uIdSet.add(cmd.getReqUserId()); + Map> 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); + } + }