账户管理

This commit is contained in:
gaowdong 2025-05-28 14:11:44 +08:00
parent b3e5e86c69
commit 3c08b4b234
10 changed files with 32 additions and 32 deletions

View File

@ -142,10 +142,10 @@ public class AccWalletInfoBusiness {
accTradeWalletDetail.setTradeType(operation.getTradeType());
accTradeWalletDetail.setAmount(operation.getAmount());
accTradeWalletDetail.setWalletType(operation.getWalletType());
BigDecimal walletBalByWalletId = walletInfoList.stream().filter((item) -> {
BigDecimal walletBalByWalletType = walletInfoList.stream().filter((item) -> {
return item.getWalletType().equals(operation.getWalletType());
}).map(AccWalletInfo::getWalletBal).filter(ObjectUtil::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add);
accTradeWalletDetail.setWalletBal(walletBalByWalletId);
accTradeWalletDetail.setWalletBal(walletBalByWalletType);
accTradeWalletDetail.setTradeTime(DateUtils.getNowDate());
accTradeWalletDetail.setCreateBy(StringUtils.isBlank(operation.getOperationUser()) ?
SecurityUtils.getUsername() : operation.getOperationUser());
@ -156,8 +156,8 @@ public class AccWalletInfoBusiness {
accountTrade.setTradeState(AccTradeStateEnum.TAKE_EFFECT.getKey());
accountTrade.setUpdateBy(StringUtils.isBlank(operation.getOperationUser()) ?
SecurityUtils.getUsername() : operation.getOperationUser());
accountTrade.setWalletBalTotal(walletBalByWalletId);
accountTrade.setAccountAllBal(walletBalByWalletId);
accountTrade.setWalletBalTotal(walletBalByWalletType);
accountTrade.setAccountAllBal(walletBalByWalletType);
accountTrade.setMachineSn(operation.getDeviceSn());
this.accTradeService.updateAccTrade(accountTrade);
}catch (Exception ex) {
@ -181,7 +181,7 @@ public class AccWalletInfoBusiness {
}
private void reduceAccWalletInfo(WalletBalanceOperation operation) {
AccWalletInfo walletInfo = selectAccWalletInfoByUserIdAndWalletId(operation.getUserId(),
AccWalletInfo walletInfo = selectAccWalletInfoByUserIdAndWalletType(operation.getUserId(),
operation.getWalletType());
if(Objects.isNull(walletInfo)
|| walletInfo.getWalletBal().compareTo(BigDecimal.ZERO) < 0
@ -233,7 +233,7 @@ public class AccWalletInfoBusiness {
return accWalletInfoMapper.selectAccWalletInfoByUserId(userId);
}
public AccWalletInfo selectAccWalletInfoByUserIdAndWalletId(Long userId, Integer walletType) {
return accWalletInfoMapper.selectAccWalletInfoByUserIdAndWalletId(userId, walletType);
public AccWalletInfo selectAccWalletInfoByUserIdAndWalletType(Long userId, Integer walletType) {
return accWalletInfoMapper.selectAccWalletInfoByUserIdAndWalletType(userId, walletType);
}
}

View File

@ -40,11 +40,11 @@ public enum AccWalletTypeEnum {
return Arrays.asList(WALLET.getKey(), SUBSIDY.getKey());
}
public static String getAllWalletId() {
return StringUtils.join(getAllWalletIdList(), ",");
public static String getAllWalletType() {
return StringUtils.join(getAllWalletTypeList(), ",");
}
public static List<Integer> getAllWalletIdList() {
public static List<Integer> getAllWalletTypeList() {
return Arrays.stream(values())
.map(AccWalletTypeEnum::getKey)
.collect(Collectors.toList());

View File

@ -12,17 +12,17 @@ public class AccInfoVo {
/** 账户id 主键自增 */
@Excel(name = "账户id")
@ApiModelProperty(value = "账户id")
private Long accId;
private Long accountId;
/** 人员id */
@Excel(name = "人员id")
@ApiModelProperty(value = "人员id")
private Long userId;
@ApiModelProperty("账户状态 1正常 2冻结 3销户 4过期")
private Integer accStatus;
private Integer accountStatus;
@ApiModelProperty("账户可用总余额(不包括冻结金额)")
private BigDecimal accBalTotal;
private BigDecimal accountBalTotal;
@ApiModelProperty("账户总余额(包含冻结金额)")
private BigDecimal accAllBal;
private BigDecimal accountAllBal;
@ApiModelProperty("个人钱包(可用)余额/分")
private BigDecimal walletBal;
@ApiModelProperty("补贴钱包(可用)余额/分")

View File

@ -18,26 +18,26 @@ public class WalletBalanceVO {
@ApiModelProperty("补贴钱包冻结金额")
private BigDecimal subFreezeBal;
@ApiModelProperty("冻结金额")
private BigDecimal accFreezeBalTotal;
private BigDecimal accountFreezeBalTotal;
@ApiModelProperty("账户总余额(包含冻结金额)")
private BigDecimal accAllBal;
private BigDecimal accountAllBal;
@ApiModelProperty("账户可用余额总余额(不包括冻结金额)")
private BigDecimal accBalTotal;
private BigDecimal accountBalTotal;
@ApiModelProperty("账户状态 1正常 2冻结 3销户 4过期")
private Integer accStatus;
private Integer accountStatus;
public static WalletBalanceVO of(AccInfoVo accInfoVo) {
WalletBalanceVO walletBalanceVO = new WalletBalanceVO();
//walletBalanceVO.setAccBalTotal(accInfoVo.getAccBalTotal());
walletBalanceVO.setAccAllBal(accInfoVo.getAccAllBal());
walletBalanceVO.setAccountAllBal(accInfoVo.getAccountAllBal());
walletBalanceVO.setWalletBal(accInfoVo.getWalletBal());
walletBalanceVO.setSubsidyBal(accInfoVo.getSubsidyBal());
//walletBalanceVO.setRedEnvelope(accInfoVo.getRedEnvelope());
//walletBalanceVO.setWalletFreezeBal(accInfoVo.getWalletFreezeBal());
//walletBalanceVO.setSubFreezeBal(accInfoVo.getSubFreezeBal());
//walletBalanceVO.setAccFreezeBalTotal(accInfoVo.getAccFreezeBalTotal());
walletBalanceVO.setAccStatus(accInfoVo.getAccStatus());
walletBalanceVO.setAccountStatus(accInfoVo.getAccountStatus());
return walletBalanceVO;
}
}

View File

@ -22,7 +22,7 @@ public interface AccWalletInfoMapper {
* @return 钱包详情信息
*/
public List<AccWalletInfo> selectAccWalletInfoByUserId(Long userId);
public AccWalletInfo selectAccWalletInfoByUserIdAndWalletId(@Param("userId") Long userId, @Param("walletType") Integer walletType);
public AccWalletInfo selectAccWalletInfoByUserIdAndWalletType(@Param("userId") Long userId, @Param("walletType") Integer walletType);
List<AccWalletInfoVO> selectAccWalletInfoByUserIds(@Param("userIds") List<Long> userIds);

View File

@ -22,7 +22,7 @@ public interface IAccWalletInfoService {
* @return 钱包详情信息
*/
public List<AccWalletInfo> selectAccWalletInfoByUserId(Long userId);
public AccWalletInfo selectAccWalletInfoByUserIdAndWalletId(Long userId, Integer walletId);
public AccWalletInfo selectAccWalletInfoByUserIdAndWalletType(Long userId, Integer walletType);
/**
* 查询钱包详情信息列表
@ -60,7 +60,7 @@ public interface IAccWalletInfoService {
Map<Long, List<AccWalletInfoVO>> selectAccWalletInfoByUserIds(List<Long> userIds);
void updateMinBalance(List<Long> userIds, Integer walletId, BigDecimal minBalance);
void updateMinBalance(List<Long> userIds, Integer walletType, BigDecimal minBalance);
void addAccWalletBalance(WalletUpdateDTO walletUpdateDTO);

View File

@ -340,7 +340,7 @@ public class AccInfoServiceImpl implements IAccInfoService {
throw new ServiceException("账户不存在");
} else {
AccWalletInfo accWalletInfo = new AccWalletInfo();
accWalletInfo.setAccountId(accInfoVO.getAccId());
accWalletInfo.setAccountId(accInfoVO.getAccountId());
List<AccWalletInfo> walletInfoList = this.accWalletInfoService.selectAccWalletInfoList(accWalletInfo);
this.setAccInfoVODetailList(accInfoVO, walletInfoList);
log.info("获取账户(钱包)信息,出参={}", JSONUtil.toJsonStr(accInfoVO));
@ -377,11 +377,11 @@ public class AccInfoServiceImpl implements IAccInfoService {
protected void setAccInfoVODetailList(AccInfoVo accInfoVo, List<AccWalletInfo> walletInfoList) {
if (ObjectUtil.isNotEmpty(walletInfoList)) {
accInfoVo.setWalletBal(walletInfoList.stream().filter(o -> o.getWalletId().intValue() == AccWalletTypeEnum.WALLET.getKey())
accInfoVo.setWalletBal(walletInfoList.stream().filter(o -> o.getWalletType().intValue() == AccWalletTypeEnum.WALLET.getKey())
.map(AccWalletInfo::getWalletBal).reduce(BigDecimal.ZERO, BigDecimal::add));
accInfoVo.setSubsidyBal(walletInfoList.stream().filter(o -> o.getWalletId().intValue() == AccWalletTypeEnum.SUBSIDY.getKey())
accInfoVo.setSubsidyBal(walletInfoList.stream().filter(o -> o.getWalletType().intValue() == AccWalletTypeEnum.SUBSIDY.getKey())
.map(AccWalletInfo::getWalletBal).reduce(BigDecimal.ZERO, BigDecimal::add));
accInfoVo.setAccAllBal(accInfoVo.getWalletBal().add(accInfoVo.getSubsidyBal()));
accInfoVo.setAccountAllBal(accInfoVo.getWalletBal().add(accInfoVo.getSubsidyBal()));
}
}
@Transactional(

View File

@ -121,7 +121,7 @@ public class AccSubServiceImpl implements AccSubService {
// }
private void clearAllAccSubsidyHandler(AccInfoDetailsVO accInfoVO, AccSubsidyClearParam param) {
AccWalletInfo walletInfo = accWalletInfoService.selectAccWalletInfoByUserIdAndWalletId(accInfoVO.getUserId(), AccWalletTypeEnum.SUBSIDY.getKey());
AccWalletInfo walletInfo = accWalletInfoService.selectAccWalletInfoByUserIdAndWalletType(accInfoVO.getUserId(), AccWalletTypeEnum.SUBSIDY.getKey());
if(Objects.isNull(walletInfo)) {
throw new ServiceException("补贴钱包不存在");
}
@ -287,7 +287,7 @@ public class AccSubServiceImpl implements AccSubService {
for (AccInfoDetailsVO accInfo : accInfoVOList) {
try {
checkAccount(accInfo);
AccWalletInfo walletInfo = accWalletInfoService.selectAccWalletInfoByUserIdAndWalletId(accInfo.getUserId(), AccWalletTypeEnum.SUBSIDY.getKey());
AccWalletInfo walletInfo = accWalletInfoService.selectAccWalletInfoByUserIdAndWalletType(accInfo.getUserId(), AccWalletTypeEnum.SUBSIDY.getKey());
if(Objects.isNull(walletInfo)) {
throw new ServiceException("补贴钱包不存在");
}

View File

@ -56,8 +56,8 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
}
@Override
public AccWalletInfo selectAccWalletInfoByUserIdAndWalletId(Long userId, Integer walletType) {
return accWalletInfoMapper.selectAccWalletInfoByUserIdAndWalletId(userId, walletType);
public AccWalletInfo selectAccWalletInfoByUserIdAndWalletType(Long userId, Integer walletType) {
return accWalletInfoMapper.selectAccWalletInfoByUserIdAndWalletType(userId, walletType);
}
/**

View File

@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where user_id = #{userId}
</select>
<select id="selectAccWalletInfoByUserIdAndWalletId" resultMap="AccWalletInfoResult">
<select id="selectAccWalletInfoByUserIdAndWalletType" resultMap="AccWalletInfoResult">
<include refid="selectAccWalletInfoVo"/>
where user_id = #{userId} and wallet_type = #{walletType}
</select>