update 获取累计充值金额

This commit is contained in:
2024-03-04 16:34:55 +08:00
parent b88fdb0467
commit 7c6b7eab72
5 changed files with 60 additions and 8 deletions

View File

@@ -332,26 +332,40 @@ public class MemberService {
// 查询会员钱包信息表,获取 本金余额
// MemberWalletInfo memberWalletInfo = memberWalletInfoService.selectByMemberId(dto.getMemberId(), null);
MemberWalletInfo memberWalletInfo = memberWalletInfoService.selectByWalletCode(dto.getWalletCode());
if (memberWalletInfo == null) {
MemberWalletVO memberWalletVO = memberWalletInfoService.selectMemberWalletInfo(dto.getWalletCode());
// MemberWalletInfo memberWalletInfo = memberWalletInfoService.selectByWalletCode(dto.getWalletCode());
if (memberWalletVO == null) {
// 用户未注册小程序
throw new BusinessException(ReturnCodeEnum.CODE_AUTHENTICATION_ERROR);
}
// 当前余额
vo.setCurrentBalance(memberWalletInfo.getPrincipalBalance().add(memberWalletInfo.getGiftBalance()));
vo.setCurrentBalance(memberWalletVO.getPrincipalBalance().add(memberWalletVO.getGiftBalance()));
// 累计充值金额
vo.setAccumulatedRechargeAmount(memberWalletVO.getAccumulatedRechargeAmount());
// 累计赠送金额
vo.setAccumulatedRechargeGift(memberWalletVO.getAccumulatedRechargeGift());
// 累计消费金额
vo.setAccumulatedConsumptionAmount(memberWalletVO.getAccumulatedConsumptionAmount());
// 根据日期查询会员钱包变动明细
// 分页
// PageHelper.startPage(pageNum, pageSize);
List<MemberWalletLogVO> list = memberBasicInfoService.getMemberWalletDetail(dto);
// 总支出
BigDecimal totalConsumption = list.stream()
.map(MemberWalletLogVO::getOrderAmount)
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setTotalConsumption(totalConsumption);
// 总充值
BigDecimal totalRechargeAmount = list.stream()
.filter(x -> StringUtils.equals(x.getType(), "1"))
.filter(x -> StringUtils.equals(x.getSubType(), "10") || StringUtils.equals(x.getSubType(), "11"))
.map(MemberWalletLogVO::getAmount)
.reduce(BigDecimal.ZERO, BigDecimal::add);
vo.setTotalRechargeAmount(totalRechargeAmount);
// PageInfo<MemberWalletLogVO> pageInfo = new PageInfo<>(list);
// 获取 type 和 subType 的对应信息
for (MemberWalletLogVO walletLogVO : list) {
@@ -382,7 +396,6 @@ public class MemberService {
.build();
vo.setPageResponse(pageResponse);
// log.info("查询用户余额信息 service方法 end");
return vo;
}