mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-07 19:40:07 +08:00
update 会员累计充值金额
This commit is contained in:
@@ -314,6 +314,35 @@ public class MemberService {
|
||||
log.info("查询用户余额信息 service方法 start");
|
||||
MemberWalletInfoVO vo = new MemberWalletInfoVO();
|
||||
vo.setMemberId(dto.getMemberId());
|
||||
|
||||
// 查询会员钱包信息表,获取 本金余额
|
||||
MemberWalletVO memberWalletVO = memberWalletInfoService.selectMemberWalletInfo(dto.getWalletCode());
|
||||
if (memberWalletVO == null) {
|
||||
// 用户未注册小程序
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_AUTHENTICATION_ERROR);
|
||||
}
|
||||
// 本金 sql处理为空返回0
|
||||
vo.setPrincipalBalance(memberWalletVO.getPrincipalBalance());
|
||||
|
||||
// 赠金 sql处理为空返回0
|
||||
vo.setGiftBalance(memberWalletVO.getGiftBalance());
|
||||
|
||||
// 当前余额
|
||||
vo.setCurrentBalance(vo.getPrincipalBalance().add(vo.getGiftBalance()));
|
||||
|
||||
// 累计充值本金
|
||||
vo.setAccumulatedRechargePrincipal(memberWalletVO.getAccumulatedRechargePrincipal());
|
||||
|
||||
// 累计赠送金额
|
||||
vo.setAccumulatedRechargeGift(memberWalletVO.getAccumulatedRechargeGift());
|
||||
|
||||
// 累计消费金额
|
||||
vo.setTotalConsumption(memberWalletVO.getAccumulatedConsumptionAmount());
|
||||
|
||||
// 总充值
|
||||
vo.setTotalRechargeAmount(memberWalletVO.getTotalRechargeAmount());
|
||||
|
||||
// 根据日期查询会员钱包变动明细 分页
|
||||
// 获取分页信息
|
||||
long pageNum = dto.getPageNum() == 0 ? 1L : dto.getPageNum();
|
||||
long pageSize = dto.getPageSize() == 0 ? 10L : dto.getPageSize();
|
||||
@@ -330,44 +359,23 @@ public class MemberService {
|
||||
lastDay = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date);
|
||||
dto.setTradeDate(tradeDate);
|
||||
dto.setEndDate(lastDay);
|
||||
|
||||
// 查询会员钱包信息表,获取 本金余额
|
||||
MemberWalletVO memberWalletVO = memberWalletInfoService.selectMemberWalletInfo(dto.getWalletCode());
|
||||
if (memberWalletVO == null) {
|
||||
// 用户未注册小程序
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_AUTHENTICATION_ERROR);
|
||||
}
|
||||
// 本金 sql处理为空返回0
|
||||
vo.setPrincipalBalance(memberWalletVO.getPrincipalBalance());
|
||||
// 赠金 sql处理为空返回0
|
||||
vo.setGiftBalance(memberWalletVO.getGiftBalance());
|
||||
// 当前余额
|
||||
vo.setCurrentBalance(vo.getPrincipalBalance().add(vo.getGiftBalance()));
|
||||
// 累计充值本金
|
||||
vo.setAccumulatedRechargePrincipal(memberWalletVO.getAccumulatedRechargePrincipal());
|
||||
// 累计赠送金额
|
||||
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 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);
|
||||
// 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 的对应信息
|
||||
|
||||
@@ -94,11 +94,16 @@ public class MemberWalletInfoServiceImpl implements MemberWalletInfoService {
|
||||
*/
|
||||
@Override
|
||||
public MemberWalletVO selectMemberWalletInfo(String walletCode) {
|
||||
// 查询数据库,字段为null默认返回0
|
||||
MemberWalletVO memberWalletVO = memberWalletInfoMapper.selectMemberWalletInfo(walletCode);
|
||||
|
||||
// 总余额
|
||||
memberWalletVO.setTotalBalance(memberWalletVO.getPrincipalBalance().add(memberWalletVO.getGiftBalance()));
|
||||
|
||||
// 总充值金额 = 累计本金充值 + 累计赠送金额
|
||||
memberWalletVO.setTotalRechargeAmount(memberWalletVO.getAccumulatedRechargePrincipal().add(memberWalletVO.getAccumulatedRechargeGift()));
|
||||
|
||||
// 累计消费金额 = 累计充值 + 累计赠送 - 本金余额 - 赠送金余额
|
||||
// 累计消费金额 = 总充值金额 - 本金余额 - 赠送金余额
|
||||
BigDecimal accumulatedConsumptionAmount = memberWalletVO.getTotalRechargeAmount()
|
||||
.subtract(memberWalletVO.getPrincipalBalance())
|
||||
.subtract(memberWalletVO.getGiftBalance());
|
||||
|
||||
@@ -34,7 +34,7 @@ public class MemberWalletVO {
|
||||
private String merchantName;
|
||||
|
||||
/**
|
||||
* 本金金额
|
||||
* 本金余额
|
||||
*/
|
||||
private BigDecimal principalBalance;
|
||||
|
||||
@@ -43,6 +43,11 @@ public class MemberWalletVO {
|
||||
*/
|
||||
private BigDecimal giftBalance;
|
||||
|
||||
/**
|
||||
* 总余额
|
||||
*/
|
||||
private BigDecimal totalBalance;
|
||||
|
||||
/**
|
||||
* 累计本金充值
|
||||
*/
|
||||
@@ -59,7 +64,7 @@ public class MemberWalletVO {
|
||||
private BigDecimal totalRechargeAmount;
|
||||
|
||||
/**
|
||||
* 累计消费
|
||||
* 累计消费 = 总充值金额 - 本金余额 - 赠送金余额
|
||||
*/
|
||||
private BigDecimal accumulatedConsumptionAmount;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class MemberWalletInfoVO {
|
||||
/**
|
||||
* 累计消费
|
||||
*/
|
||||
private BigDecimal accumulatedConsumptionAmount;
|
||||
// private BigDecimal accumulatedConsumptionAmount;
|
||||
|
||||
/**
|
||||
* 总充值金额
|
||||
|
||||
Reference in New Issue
Block a user