update 会员钱包明细

This commit is contained in:
Lemon
2023-07-22 15:23:31 +08:00
parent 42f2b18b99
commit a17412968c
11 changed files with 175 additions and 15 deletions

View File

@@ -22,6 +22,7 @@ import com.jsowell.common.enums.ykc.ScenarioEnum;
import com.jsowell.common.enums.ykc.StartModeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.AdapayUtil;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.JWTUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.id.IdUtils;
@@ -48,10 +49,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
@Service
@@ -292,6 +290,54 @@ public class MemberService {
return pageResponse;
}
/**
* 获取会员钱包明细
* @return
*/
public PageResponse getMemberWalletLog (UniAppQueryMemberBalanceDTO dto) throws ParseException {
// 获取分页信息以及memberId
int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum();
int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize();
String tradeDate = dto.getTradeDate();
// 获取年、月
String[] split = StringUtils.split(tradeDate, "-");
int year = Integer.parseInt(split[0]);
int month = Integer.parseInt(split[1]);
// 根据年月获取当月第一天和最后一天
tradeDate = DateUtils.getFirstDay(year, month, DateUtils.YYYY_MM_DD);
String lastDay = DateUtils.getLastDay(year, month, DateUtils.YYYY_MM_DD);
// sql语句查询日期需要多加一天
Date date = DateUtils.addDays(DateUtils.parseDate(lastDay, DateUtils.YYYY_MM_DD), 1);
lastDay = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date);
dto.setTradeDate(tradeDate);
dto.setEndDate(lastDay);
// 根据日期查询会员钱包变动明细
// 分页
PageHelper.startPage(pageNum, pageSize);
List<MemberWalletLogVO> list = memberBasicInfoService.getMemberWalletDetail(dto);
PageInfo<MemberWalletLogVO> pageInfo = new PageInfo<>(list);
// 获取 type 和 subType 的对应信息
for (MemberWalletLogVO walletLogVO : pageInfo.getList()) {
// 将负数转为正数
walletLogVO.setAmount(BigDecimal.valueOf(Math.abs(walletLogVO.getAmount().doubleValue())).setScale(2, BigDecimal.ROUND_HALF_UP));
String subType = walletLogVO.getSubType();
String subTypeValue = BalanceChangesEnum.getValueByCode(subType);
if (StringUtils.isNotBlank(subTypeValue)) {
walletLogVO.setSubType(subTypeValue);
}
// walletLogVO.setTotalAccountAmount(walletLogVO.getPrincipalBalance().add(walletLogVO.getGiftBalance()));
}
PageResponse pageResponse = PageResponse.builder()
.pageSize(pageSize)
.pageNum(pageNum)
.list(pageInfo.getList())
.pages(pageInfo.getPages())
.total(pageInfo.getTotal())
.build();
return pageResponse;
}
/**
* 用户绑定车牌号
* @param dto

View File

@@ -333,7 +333,7 @@ public class PileService {
}
List<String> adminList = relationList.stream()
.filter(x -> x.getType().equals("1"))
.filter(x -> x.getType().equals(Constants.ONE)) // 1-管理员用户
.map(PileMemberRelation::getMemberId)
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(adminList)) {
@@ -341,13 +341,13 @@ public class PileService {
}
// 校验身份
if (!adminList.contains(dto.getMemberId())) {
// 如果为空,说明此用户身份有误,不是管理员,抛出异常
if (adminList.contains(dto.getMemberId())) {
// 如果为空,说明被分享的用户是管理员,抛出异常
throw new BusinessException(ReturnCodeEnum.CODE_AUTHENTICATION_ERROR);
}
List<String> userList = relationList.stream()
.filter(x -> !x.getType().equals("1"))
.filter(x -> !x.getType().equals(Constants.TWO)) // 2-普通用户
.map(PileMemberRelation::getMemberId)
.collect(Collectors.toList());