mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
增加会员明细和导出功能
This commit is contained in:
@@ -6,6 +6,7 @@ import com.jsowell.pile.dto.PlatformTesterDTO;
|
||||
import com.jsowell.pile.dto.QueryMemberInfoDTO;
|
||||
import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO;
|
||||
import com.jsowell.pile.vo.uniapp.customer.*;
|
||||
import com.jsowell.pile.vo.web.MemberDetailsVO;
|
||||
import com.jsowell.pile.vo.web.PlatformTesterVO;
|
||||
import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO;
|
||||
|
||||
@@ -162,4 +163,10 @@ public interface MemberBasicInfoService {
|
||||
List<MemberVO> getMemberInfoByPlateNumber(String plateNumber);
|
||||
|
||||
|
||||
/**
|
||||
* 会员明细查询
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
MemberDetailsVO queryMemberDetails(UniAppQueryMemberBalanceDTO dto);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ package com.jsowell.pile.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.constant.CacheConstants;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.enums.MemberWalletEnum;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
@@ -23,12 +25,14 @@ import com.jsowell.pile.dto.QueryMemberInfoDTO;
|
||||
import com.jsowell.pile.dto.UniAppQueryMemberBalanceDTO;
|
||||
import com.jsowell.pile.mapper.MemberBasicInfoMapper;
|
||||
import com.jsowell.pile.mapper.MemberPlateNumberRelationMapper;
|
||||
import com.jsowell.pile.mapper.MemberWalletInfoMapper;
|
||||
import com.jsowell.pile.mapper.MemberWalletLogMapper;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.util.MerchantUtils;
|
||||
import com.jsowell.pile.util.UserUtils;
|
||||
import com.jsowell.pile.vo.base.MerchantInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.customer.*;
|
||||
import com.jsowell.pile.vo.web.MemberDetailsVO;
|
||||
import com.jsowell.pile.vo.web.PlatformTesterVO;
|
||||
import com.jsowell.pile.vo.web.UpdateMemberBalanceDTO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -40,6 +44,7 @@ import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -84,6 +89,9 @@ public class MemberBasicInfoServiceImpl implements MemberBasicInfoService {
|
||||
@Autowired
|
||||
private PileStationInfoService pileStationInfoService;
|
||||
|
||||
@Autowired
|
||||
private MemberWalletInfoMapper memberWalletInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询会员基础信息
|
||||
*
|
||||
@@ -679,4 +687,85 @@ public class MemberBasicInfoServiceImpl implements MemberBasicInfoService {
|
||||
return memberBasicInfoMapper.getMemberInfoByPlateNumber(plateNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员明细
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public MemberDetailsVO queryMemberDetails(UniAppQueryMemberBalanceDTO dto) {
|
||||
// 获取会员钱包信息
|
||||
List<MemberWalletInfo> memberWalletInfos = memberWalletInfoMapper.selectByMemberWalletList(dto.getMemberId());
|
||||
|
||||
// 计算总余额
|
||||
BigDecimal totalPrincipalBalance = memberWalletInfos.stream()
|
||||
.map(MemberWalletInfo::getPrincipalBalance)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal totalGiftBalance = memberWalletInfos.stream()
|
||||
.map(MemberWalletInfo::getGiftBalance)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
BigDecimal totalBalance = totalPrincipalBalance.add(totalGiftBalance);
|
||||
|
||||
// 获取会员所有钱包流水
|
||||
List<MemberWalletLogVO> allWalletLogs = memberWalletLogMapper.getMemberBalanceChanges(dto.getMemberId(), null);
|
||||
|
||||
// 计算总充值金额
|
||||
BigDecimal totalRechargeAmount = allWalletLogs.stream()
|
||||
.filter(log -> "1".equals(log.getType()) && ("10".equals(log.getSubType()) || "11".equals(log.getSubType())))
|
||||
.map(MemberWalletLogVO::getAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
// 计算总消费金额
|
||||
BigDecimal totalConsumeAmount = totalRechargeAmount.subtract(totalBalance);
|
||||
|
||||
// 获取指定时间段的钱包流水
|
||||
List<MemberWalletLogVO> walletLogs = memberWalletLogMapper.getMemberWalletDetailV2(dto);
|
||||
|
||||
// 计算时间段累计消费金额
|
||||
BigDecimal cumulativeConsumeAmount = walletLogs.stream()
|
||||
.map(MemberWalletLogVO::getOrderAmount)
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
// 计算时间段累计充值金额
|
||||
BigDecimal cumulativeRechargeAmount = walletLogs.stream()
|
||||
.filter(log -> "1".equals(log.getType()) && ("10".equals(log.getSubType()) || "11".equals(log.getSubType())))
|
||||
.map(MemberWalletLogVO::getAmount)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
// 分页查询
|
||||
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
|
||||
List<MemberWalletLogVO> pagedWalletLogs = memberWalletLogMapper.getMemberWalletDetailV2(dto);
|
||||
for (MemberWalletLogVO pagedWalletLog : pagedWalletLogs) {
|
||||
if (pagedWalletLog.getOrderAmount() != null ){
|
||||
BigDecimal orderAmount = pagedWalletLog.getOrderAmount();
|
||||
pagedWalletLog.setOrderAmount(orderAmount.negate());
|
||||
}else {
|
||||
//当没有订单金额时,就获取amount的值
|
||||
pagedWalletLog.setOrderAmount(pagedWalletLog.getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
PageInfo<MemberWalletLogVO> pageInfo = new PageInfo<>(pagedWalletLogs);
|
||||
|
||||
// 构建分页响应
|
||||
PageResponse pageResponse = PageResponse.builder()
|
||||
.pageNum(dto.getPageNum())
|
||||
.pageSize(dto.getPageSize())
|
||||
.list(pagedWalletLogs)
|
||||
.total(pageInfo.getTotal())
|
||||
.pages(pageInfo.getPages())
|
||||
.build();
|
||||
|
||||
// 构建会员明细VO
|
||||
return MemberDetailsVO.builder()
|
||||
.totalRechargeAmount(totalRechargeAmount)
|
||||
.totalConsumeAmount(totalConsumeAmount.negate())
|
||||
.totalBalance(totalBalance)
|
||||
.cumulativeRechargeAmount(cumulativeRechargeAmount)
|
||||
.cumulativeConsumeAmount(cumulativeConsumeAmount.negate())
|
||||
.pageResponse(pageResponse)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -81,4 +81,9 @@ public class MemberWalletLogVO {
|
||||
* 变动后金额
|
||||
*/
|
||||
private BigDecimal afterAmount;
|
||||
|
||||
/**
|
||||
* 操作人员
|
||||
*/
|
||||
private String createBy;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.jsowell.pile.vo.web;
|
||||
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class MemberDetailsVO {
|
||||
/**
|
||||
* 总充值金额
|
||||
*/
|
||||
private BigDecimal totalRechargeAmount;
|
||||
|
||||
/**
|
||||
* 总消费金额
|
||||
*/
|
||||
private BigDecimal totalConsumeAmount;
|
||||
|
||||
/**
|
||||
* 总余额
|
||||
*/
|
||||
private BigDecimal totalBalance;
|
||||
|
||||
/**
|
||||
* 充值金额
|
||||
*/
|
||||
private BigDecimal cumulativeRechargeAmount;
|
||||
|
||||
/**
|
||||
* 消费金额
|
||||
*/
|
||||
private BigDecimal cumulativeConsumeAmount;
|
||||
|
||||
/**
|
||||
* 分页信息
|
||||
*/
|
||||
private PageResponse pageResponse;
|
||||
}
|
||||
Reference in New Issue
Block a user