feat(金币代理): 新增金币代理列表统计接口
This commit is contained in:
parent
c5263b0adf
commit
15d93eacec
@ -42,4 +42,16 @@ public interface UserMonthlyRechargeClientApi {
|
||||
@GetMapping("/listThisMonth")
|
||||
ResultResponse<List<UserMonthlyRechargeDTO>> listThisMonth(@RequestParam("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 批量获取用户本月充值.
|
||||
*/
|
||||
@GetMapping("/listThisMonthByIds")
|
||||
ResultResponse<List<UserMonthlyRechargeDTO>> listThisMonthByIds(@RequestParam("userIds") List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 批量获取用户本月充值.
|
||||
*/
|
||||
@GetMapping("/listLastMonthByIds")
|
||||
ResultResponse<List<UserMonthlyRechargeDTO>> listLastMonthByIds(@RequestParam("userIds") List<Long> userIds);
|
||||
|
||||
}
|
||||
|
||||
@ -58,4 +58,14 @@ public interface UserMonthlyRechargeService extends BaseService<UserMonthlyRecha
|
||||
*/
|
||||
List<UserMonthlyRecharge> listThisMonth(Long userId);
|
||||
|
||||
/**
|
||||
* 批量获取用户本月充值.
|
||||
*/
|
||||
List<UserMonthlyRecharge> listThisMonthByIds(List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 批量获取用户上月充值.
|
||||
*/
|
||||
List<UserMonthlyRecharge> listLastMonthByIds(List<Long> userIds);
|
||||
|
||||
}
|
||||
|
||||
@ -11,6 +11,8 @@ import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
import com.red.circle.tool.core.date.LocalDateUtils;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -160,9 +162,30 @@ public class UserMonthlyRechargeServiceImpl extends
|
||||
.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserMonthlyRecharge> listThisMonthByIds(List<Long> userIds) {
|
||||
return query()
|
||||
.in(UserMonthlyRecharge::getUserId, userIds)
|
||||
.eq(UserMonthlyRecharge::getRechargeDate, nowThisMonth())
|
||||
.orderByAsc(UserMonthlyRecharge::getType)
|
||||
.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserMonthlyRecharge> listLastMonthByIds(List<Long> userIds) {
|
||||
return query()
|
||||
.in(UserMonthlyRecharge::getUserId, userIds)
|
||||
.eq(UserMonthlyRecharge::getRechargeDate, lastMonth())
|
||||
.orderByAsc(UserMonthlyRecharge::getType)
|
||||
.list();
|
||||
}
|
||||
|
||||
private int nowThisMonth() {
|
||||
return LocalDateUtils.nowThisMonthToInteger();
|
||||
}
|
||||
|
||||
private String lastMonth() {
|
||||
return LocalDate.now().minusMonths(1).format(DateTimeFormatter.ofPattern("yyyy-MM"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -52,4 +52,18 @@ public class UserMonthlyRechargeClientEndpoint implements UserMonthlyRechargeCli
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultResponse<List<UserMonthlyRechargeDTO>> listThisMonthByIds(List<Long> userIds) {
|
||||
return ResultResponse.success(
|
||||
userMonthlyRechargeClientService.listThisMonthByIds(userIds)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultResponse<List<UserMonthlyRechargeDTO>> listLastMonthByIds(List<Long> userIds) {
|
||||
return ResultResponse.success(
|
||||
userMonthlyRechargeClientService.listLastMonthByIds(userIds)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,4 +29,14 @@ public interface UserMonthlyRechargeClientService {
|
||||
*/
|
||||
List<UserMonthlyRechargeDTO> listThisMonth(Long userId);
|
||||
|
||||
/**
|
||||
* 批量获取用户本月充值.
|
||||
*/
|
||||
List<UserMonthlyRechargeDTO> listThisMonthByIds(List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 批量获取用户上月充值.
|
||||
*/
|
||||
List<UserMonthlyRechargeDTO> listLastMonthByIds(List<Long> userIds);
|
||||
|
||||
}
|
||||
|
||||
@ -46,4 +46,18 @@ public class UserMonthlyRechargeClientServiceImpl implements UserMonthlyRecharge
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserMonthlyRechargeDTO> listThisMonthByIds(List<Long> userIds) {
|
||||
return userMonthlyRechargeInnerConvertor.toListUserMonthlyRechargeDTO(
|
||||
userMonthlyRechargeService.listThisMonthByIds(userIds)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserMonthlyRechargeDTO> listLastMonthByIds(List<Long> userIds) {
|
||||
return userMonthlyRechargeInnerConvertor.toListUserMonthlyRechargeDTO(
|
||||
userMonthlyRechargeService.listLastMonthByIds(userIds)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,17 @@
|
||||
package com.red.circle.other.adapter.app.h5;
|
||||
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.common.business.dto.cmd.PageUserIdCmd;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.framework.web.controller.BaseController;
|
||||
import com.red.circle.order.inner.endpoint.UserFreightRechargeRecordClient;
|
||||
import com.red.circle.order.inner.endpoint.UserMonthlyRechargeClient;
|
||||
import com.red.circle.order.inner.endpoint.api.UserMonthlyRechargeClientApi;
|
||||
import com.red.circle.other.app.dto.h5.MemberActiveDTO;
|
||||
import com.red.circle.other.app.dto.h5.RechargePageVO;
|
||||
import com.red.circle.other.app.dto.h5.UserIdentityVO;
|
||||
import com.red.circle.other.app.service.h5.MemberActiveService;
|
||||
import com.red.circle.other.app.service.recharge.RechargeUserService;
|
||||
import com.red.circle.other.app.service.user.user.UserCountService;
|
||||
import com.red.circle.other.app.service.user.user.UserIdentityService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -18,6 +25,7 @@ public class MemberActiveController extends BaseController {
|
||||
|
||||
private final MemberActiveService memberActiveService;
|
||||
private final UserIdentityService userIdentityService;
|
||||
private final RechargeUserService rechargeUserService;
|
||||
|
||||
/**
|
||||
* 工会裂变活动列表、
|
||||
@ -46,4 +54,12 @@ public class MemberActiveController extends BaseController {
|
||||
return userIdentityService.getUserIdentity(cmd.getReqUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 货运代理分页列表
|
||||
*/
|
||||
@GetMapping("/recharge-page")
|
||||
public PageResult<RechargePageVO> rechargePage(PageUserIdCmd page, AppExtCommand cmd) {
|
||||
return rechargeUserService.getRechargePage(page, cmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ public class TeamBdRestController extends BaseController {
|
||||
/**
|
||||
* BD 列表接口
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@GetMapping("/page2")
|
||||
public PageResult<BdPageCO> bdPage(BdTeamPageQryCmd qryCmd) {
|
||||
return teamBdService.bdPage(qryCmd);
|
||||
}
|
||||
|
||||
@ -0,0 +1,102 @@
|
||||
package com.red.circle.other.app.service.user.user;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.common.business.dto.cmd.PageUserIdCmd;
|
||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||
import com.red.circle.framework.dto.PageQuery;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.framework.dto.ResultResponse;
|
||||
import com.red.circle.order.inner.endpoint.UserMonthlyRechargeClient;
|
||||
import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
||||
import com.red.circle.other.app.dto.h5.RechargePageVO;
|
||||
import com.red.circle.other.app.dto.h5.RechargeVO;
|
||||
import com.red.circle.other.app.service.recharge.RechargeUserService;
|
||||
import com.red.circle.other.infra.database.rds.service.sys.AdministratorService;
|
||||
import com.red.circle.other.inner.endpoint.user.user.UserProfileClient;
|
||||
import com.red.circle.other.inner.model.dto.user.UserProfileDTO;
|
||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
import com.red.circle.tool.core.date.LocalDateUtils;
|
||||
import com.red.circle.wallet.inner.endpoint.freight.FreightGoldClient;
|
||||
import com.red.circle.wallet.inner.model.cmd.UserFreightBalancePageQryCmd;
|
||||
import com.red.circle.wallet.inner.model.dto.UserFreightBalanceDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RechargeUserServiceImpl implements RechargeUserService {
|
||||
|
||||
private final UserMonthlyRechargeClient userMonthlyRechargeClient;
|
||||
private final FreightGoldClient freightGoldClient;
|
||||
private final UserProfileClient userProfileClient;
|
||||
private final AdministratorService administratorService;
|
||||
|
||||
@Override
|
||||
public PageResult<RechargePageVO> getRechargePage(PageUserIdCmd page, AppExtCommand cmd) {
|
||||
boolean b = administratorService.existsAdmin(cmd.getReqUserId());
|
||||
if(!b) {
|
||||
ResponseAssert.failure(CommonErrorCode.OPERATING_FAILURE);
|
||||
}
|
||||
|
||||
UserFreightBalancePageQryCmd qryCmd = new UserFreightBalancePageQryCmd();
|
||||
qryCmd.setClose(false);
|
||||
qryCmd.setDisplay(false);
|
||||
qryCmd.setSysOrigin(cmd.getReqSysOrigin().getOrigin());
|
||||
qryCmd.setPageQuery(page.getPageQuery());
|
||||
PageResult<UserFreightBalanceDTO> pageResult = freightGoldClient.pageFreight(qryCmd).getBody();
|
||||
|
||||
|
||||
if (pageResult == null || pageResult.getRecords().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Long> collect = pageResult.getRecords().stream().map(UserFreightBalanceDTO::getUserId).toList();
|
||||
Map<Long, BigDecimal> userMonthlyAmountMap = getThisMonthRechargeAmount(collect);
|
||||
Map<Long, BigDecimal> userLastMonthAmountMap = getLastMonthRechargeAmount(collect);
|
||||
|
||||
return pageResult.convert(e -> {
|
||||
UserProfileDTO body = userProfileClient.getByUserId(e.getUserId()).getBody();
|
||||
|
||||
return new RechargePageVO()
|
||||
.setUserId(e.getUserId())
|
||||
.setAccount(body.getAccount())
|
||||
.setUserNickname(body.getUserNickname())
|
||||
.setUserAvatar(body.getUserAvatar())
|
||||
.setThisMonth(userMonthlyAmountMap.get(e.getUserId()))
|
||||
.setLastMonth(userLastMonthAmountMap.get(e.getUserId()));
|
||||
});
|
||||
}
|
||||
|
||||
private Map<Long, BigDecimal> getThisMonthRechargeAmount(List<Long> collect) {
|
||||
List<UserMonthlyRechargeDTO> recharges = userMonthlyRechargeClient.listThisMonthByIds(collect).getBody();
|
||||
return getLongBigDecimalMap(recharges);
|
||||
}
|
||||
|
||||
private Map<Long, BigDecimal> getLastMonthRechargeAmount(List<Long> collect) {
|
||||
List<UserMonthlyRechargeDTO> recharges = userMonthlyRechargeClient.listLastMonthByIds(collect).getBody();
|
||||
return getLongBigDecimalMap(recharges);
|
||||
}
|
||||
|
||||
private static Map<Long, BigDecimal> getLongBigDecimalMap(List<UserMonthlyRechargeDTO> recharges) {
|
||||
Map<Long, List<UserMonthlyRechargeDTO>> userMonthlyMap = recharges.stream()
|
||||
.collect(Collectors.groupingBy(UserMonthlyRechargeDTO::getUserId));
|
||||
|
||||
return userMonthlyMap.entrySet().stream()
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
entry -> entry.getValue().stream()
|
||||
.map(UserMonthlyRechargeDTO::getAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add)
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.red.circle.other.app.dto.h5;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class RechargePageVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 账号.
|
||||
*/
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 头像.
|
||||
*/
|
||||
private String userAvatar;
|
||||
|
||||
/**
|
||||
* 用户昵称.
|
||||
*/
|
||||
private String userNickname;
|
||||
|
||||
/**
|
||||
* 这个月金额
|
||||
*/
|
||||
private BigDecimal thisMonth;
|
||||
|
||||
/**
|
||||
* 上个月金额
|
||||
*/
|
||||
private BigDecimal lastMonth;
|
||||
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package com.red.circle.other.app.dto.h5;
|
||||
|
||||
import com.red.circle.framework.dto.ClientObject;
|
||||
import com.red.circle.order.inner.model.dto.UserMonthlyRechargeDTO;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 累计用户每月充值
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RechargeVO extends ClientObject {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 充值信息.
|
||||
*/
|
||||
private List<UserMonthlyRechargeDTO> recharges;
|
||||
|
||||
/**
|
||||
* 总额.
|
||||
*/
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/**
|
||||
* 充值年月(yyyyMM).
|
||||
*/
|
||||
private Integer rechargeDate;
|
||||
|
||||
/**
|
||||
* 创建时间.
|
||||
*/
|
||||
private Timestamp createTime;
|
||||
|
||||
/**
|
||||
* 修改时间.
|
||||
*/
|
||||
private Timestamp updateTime;
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package com.red.circle.other.app.service.recharge;
|
||||
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.common.business.dto.cmd.PageUserIdCmd;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.other.app.dto.h5.RechargePageVO;
|
||||
|
||||
public interface RechargeUserService {
|
||||
|
||||
/**
|
||||
* 货运代理用户列表
|
||||
*/
|
||||
PageResult<RechargePageVO> getRechargePage(PageUserIdCmd page, AppExtCommand cmd);
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user