新增 用户累计充值接口
This commit is contained in:
parent
be98952463
commit
5864254890
@ -1,9 +1,15 @@
|
|||||||
package com.red.circle.other.adapter.app.user.user;
|
package com.red.circle.other.adapter.app.user.user;
|
||||||
|
|
||||||
import com.red.circle.common.business.dto.cmd.UserIdCmd;
|
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.dto.clientobject.user.user.UserGuardCountCO;
|
||||||
import com.red.circle.other.app.service.user.user.UserCountService;
|
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 lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -25,6 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
public class UserCountRestController {
|
public class UserCountRestController {
|
||||||
|
|
||||||
private final UserCountService userCountService;
|
private final UserCountService userCountService;
|
||||||
|
private final TotalRechargeClient totalRechargeClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 守护列表.
|
* 守护列表.
|
||||||
@ -40,4 +47,20 @@ public class UserCountRestController {
|
|||||||
return userCountService.listUserGuardCountTop(cmd);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user