账户管理
This commit is contained in:
parent
b3e5e86c69
commit
3c08b4b234
|
|
@ -142,10 +142,10 @@ public class AccWalletInfoBusiness {
|
||||||
accTradeWalletDetail.setTradeType(operation.getTradeType());
|
accTradeWalletDetail.setTradeType(operation.getTradeType());
|
||||||
accTradeWalletDetail.setAmount(operation.getAmount());
|
accTradeWalletDetail.setAmount(operation.getAmount());
|
||||||
accTradeWalletDetail.setWalletType(operation.getWalletType());
|
accTradeWalletDetail.setWalletType(operation.getWalletType());
|
||||||
BigDecimal walletBalByWalletId = walletInfoList.stream().filter((item) -> {
|
BigDecimal walletBalByWalletType = walletInfoList.stream().filter((item) -> {
|
||||||
return item.getWalletType().equals(operation.getWalletType());
|
return item.getWalletType().equals(operation.getWalletType());
|
||||||
}).map(AccWalletInfo::getWalletBal).filter(ObjectUtil::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
}).map(AccWalletInfo::getWalletBal).filter(ObjectUtil::isNotNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
accTradeWalletDetail.setWalletBal(walletBalByWalletId);
|
accTradeWalletDetail.setWalletBal(walletBalByWalletType);
|
||||||
accTradeWalletDetail.setTradeTime(DateUtils.getNowDate());
|
accTradeWalletDetail.setTradeTime(DateUtils.getNowDate());
|
||||||
accTradeWalletDetail.setCreateBy(StringUtils.isBlank(operation.getOperationUser()) ?
|
accTradeWalletDetail.setCreateBy(StringUtils.isBlank(operation.getOperationUser()) ?
|
||||||
SecurityUtils.getUsername() : operation.getOperationUser());
|
SecurityUtils.getUsername() : operation.getOperationUser());
|
||||||
|
|
@ -156,8 +156,8 @@ public class AccWalletInfoBusiness {
|
||||||
accountTrade.setTradeState(AccTradeStateEnum.TAKE_EFFECT.getKey());
|
accountTrade.setTradeState(AccTradeStateEnum.TAKE_EFFECT.getKey());
|
||||||
accountTrade.setUpdateBy(StringUtils.isBlank(operation.getOperationUser()) ?
|
accountTrade.setUpdateBy(StringUtils.isBlank(operation.getOperationUser()) ?
|
||||||
SecurityUtils.getUsername() : operation.getOperationUser());
|
SecurityUtils.getUsername() : operation.getOperationUser());
|
||||||
accountTrade.setWalletBalTotal(walletBalByWalletId);
|
accountTrade.setWalletBalTotal(walletBalByWalletType);
|
||||||
accountTrade.setAccountAllBal(walletBalByWalletId);
|
accountTrade.setAccountAllBal(walletBalByWalletType);
|
||||||
accountTrade.setMachineSn(operation.getDeviceSn());
|
accountTrade.setMachineSn(operation.getDeviceSn());
|
||||||
this.accTradeService.updateAccTrade(accountTrade);
|
this.accTradeService.updateAccTrade(accountTrade);
|
||||||
}catch (Exception ex) {
|
}catch (Exception ex) {
|
||||||
|
|
@ -181,7 +181,7 @@ public class AccWalletInfoBusiness {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reduceAccWalletInfo(WalletBalanceOperation operation) {
|
private void reduceAccWalletInfo(WalletBalanceOperation operation) {
|
||||||
AccWalletInfo walletInfo = selectAccWalletInfoByUserIdAndWalletId(operation.getUserId(),
|
AccWalletInfo walletInfo = selectAccWalletInfoByUserIdAndWalletType(operation.getUserId(),
|
||||||
operation.getWalletType());
|
operation.getWalletType());
|
||||||
if(Objects.isNull(walletInfo)
|
if(Objects.isNull(walletInfo)
|
||||||
|| walletInfo.getWalletBal().compareTo(BigDecimal.ZERO) < 0
|
|| walletInfo.getWalletBal().compareTo(BigDecimal.ZERO) < 0
|
||||||
|
|
@ -233,7 +233,7 @@ public class AccWalletInfoBusiness {
|
||||||
return accWalletInfoMapper.selectAccWalletInfoByUserId(userId);
|
return accWalletInfoMapper.selectAccWalletInfoByUserId(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccWalletInfo selectAccWalletInfoByUserIdAndWalletId(Long userId, Integer walletType) {
|
public AccWalletInfo selectAccWalletInfoByUserIdAndWalletType(Long userId, Integer walletType) {
|
||||||
return accWalletInfoMapper.selectAccWalletInfoByUserIdAndWalletId(userId, walletType);
|
return accWalletInfoMapper.selectAccWalletInfoByUserIdAndWalletType(userId, walletType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,11 @@ public enum AccWalletTypeEnum {
|
||||||
return Arrays.asList(WALLET.getKey(), SUBSIDY.getKey());
|
return Arrays.asList(WALLET.getKey(), SUBSIDY.getKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAllWalletId() {
|
public static String getAllWalletType() {
|
||||||
return StringUtils.join(getAllWalletIdList(), ",");
|
return StringUtils.join(getAllWalletTypeList(), ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Integer> getAllWalletIdList() {
|
public static List<Integer> getAllWalletTypeList() {
|
||||||
return Arrays.stream(values())
|
return Arrays.stream(values())
|
||||||
.map(AccWalletTypeEnum::getKey)
|
.map(AccWalletTypeEnum::getKey)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
|
||||||
|
|
@ -12,17 +12,17 @@ public class AccInfoVo {
|
||||||
/** 账户id 主键自增 */
|
/** 账户id 主键自增 */
|
||||||
@Excel(name = "账户id")
|
@Excel(name = "账户id")
|
||||||
@ApiModelProperty(value = "账户id")
|
@ApiModelProperty(value = "账户id")
|
||||||
private Long accId;
|
private Long accountId;
|
||||||
/** 人员id */
|
/** 人员id */
|
||||||
@Excel(name = "人员id")
|
@Excel(name = "人员id")
|
||||||
@ApiModelProperty(value = "人员id")
|
@ApiModelProperty(value = "人员id")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
@ApiModelProperty("账户状态 1正常 2冻结 3销户 4过期")
|
@ApiModelProperty("账户状态 1正常 2冻结 3销户 4过期")
|
||||||
private Integer accStatus;
|
private Integer accountStatus;
|
||||||
@ApiModelProperty("账户可用总余额(不包括冻结金额)")
|
@ApiModelProperty("账户可用总余额(不包括冻结金额)")
|
||||||
private BigDecimal accBalTotal;
|
private BigDecimal accountBalTotal;
|
||||||
@ApiModelProperty("账户总余额(包含冻结金额)")
|
@ApiModelProperty("账户总余额(包含冻结金额)")
|
||||||
private BigDecimal accAllBal;
|
private BigDecimal accountAllBal;
|
||||||
@ApiModelProperty("个人钱包(可用)余额/分")
|
@ApiModelProperty("个人钱包(可用)余额/分")
|
||||||
private BigDecimal walletBal;
|
private BigDecimal walletBal;
|
||||||
@ApiModelProperty("补贴钱包(可用)余额/分")
|
@ApiModelProperty("补贴钱包(可用)余额/分")
|
||||||
|
|
|
||||||
|
|
@ -18,26 +18,26 @@ public class WalletBalanceVO {
|
||||||
@ApiModelProperty("补贴钱包冻结金额")
|
@ApiModelProperty("补贴钱包冻结金额")
|
||||||
private BigDecimal subFreezeBal;
|
private BigDecimal subFreezeBal;
|
||||||
@ApiModelProperty("冻结金额")
|
@ApiModelProperty("冻结金额")
|
||||||
private BigDecimal accFreezeBalTotal;
|
private BigDecimal accountFreezeBalTotal;
|
||||||
@ApiModelProperty("账户总余额(包含冻结金额)")
|
@ApiModelProperty("账户总余额(包含冻结金额)")
|
||||||
private BigDecimal accAllBal;
|
private BigDecimal accountAllBal;
|
||||||
@ApiModelProperty("账户可用余额总余额(不包括冻结金额)")
|
@ApiModelProperty("账户可用余额总余额(不包括冻结金额)")
|
||||||
private BigDecimal accBalTotal;
|
private BigDecimal accountBalTotal;
|
||||||
@ApiModelProperty("账户状态 1正常 2冻结 3销户 4过期")
|
@ApiModelProperty("账户状态 1正常 2冻结 3销户 4过期")
|
||||||
private Integer accStatus;
|
private Integer accountStatus;
|
||||||
|
|
||||||
|
|
||||||
public static WalletBalanceVO of(AccInfoVo accInfoVo) {
|
public static WalletBalanceVO of(AccInfoVo accInfoVo) {
|
||||||
WalletBalanceVO walletBalanceVO = new WalletBalanceVO();
|
WalletBalanceVO walletBalanceVO = new WalletBalanceVO();
|
||||||
//walletBalanceVO.setAccBalTotal(accInfoVo.getAccBalTotal());
|
//walletBalanceVO.setAccBalTotal(accInfoVo.getAccBalTotal());
|
||||||
walletBalanceVO.setAccAllBal(accInfoVo.getAccAllBal());
|
walletBalanceVO.setAccountAllBal(accInfoVo.getAccountAllBal());
|
||||||
walletBalanceVO.setWalletBal(accInfoVo.getWalletBal());
|
walletBalanceVO.setWalletBal(accInfoVo.getWalletBal());
|
||||||
walletBalanceVO.setSubsidyBal(accInfoVo.getSubsidyBal());
|
walletBalanceVO.setSubsidyBal(accInfoVo.getSubsidyBal());
|
||||||
//walletBalanceVO.setRedEnvelope(accInfoVo.getRedEnvelope());
|
//walletBalanceVO.setRedEnvelope(accInfoVo.getRedEnvelope());
|
||||||
//walletBalanceVO.setWalletFreezeBal(accInfoVo.getWalletFreezeBal());
|
//walletBalanceVO.setWalletFreezeBal(accInfoVo.getWalletFreezeBal());
|
||||||
//walletBalanceVO.setSubFreezeBal(accInfoVo.getSubFreezeBal());
|
//walletBalanceVO.setSubFreezeBal(accInfoVo.getSubFreezeBal());
|
||||||
//walletBalanceVO.setAccFreezeBalTotal(accInfoVo.getAccFreezeBalTotal());
|
//walletBalanceVO.setAccFreezeBalTotal(accInfoVo.getAccFreezeBalTotal());
|
||||||
walletBalanceVO.setAccStatus(accInfoVo.getAccStatus());
|
walletBalanceVO.setAccountStatus(accInfoVo.getAccountStatus());
|
||||||
return walletBalanceVO;
|
return walletBalanceVO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ public interface AccWalletInfoMapper {
|
||||||
* @return 钱包详情信息
|
* @return 钱包详情信息
|
||||||
*/
|
*/
|
||||||
public List<AccWalletInfo> selectAccWalletInfoByUserId(Long userId);
|
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);
|
List<AccWalletInfoVO> selectAccWalletInfoByUserIds(@Param("userIds") List<Long> userIds);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ public interface IAccWalletInfoService {
|
||||||
* @return 钱包详情信息
|
* @return 钱包详情信息
|
||||||
*/
|
*/
|
||||||
public List<AccWalletInfo> selectAccWalletInfoByUserId(Long userId);
|
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);
|
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);
|
void addAccWalletBalance(WalletUpdateDTO walletUpdateDTO);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ public class AccInfoServiceImpl implements IAccInfoService {
|
||||||
throw new ServiceException("账户不存在");
|
throw new ServiceException("账户不存在");
|
||||||
} else {
|
} else {
|
||||||
AccWalletInfo accWalletInfo = new AccWalletInfo();
|
AccWalletInfo accWalletInfo = new AccWalletInfo();
|
||||||
accWalletInfo.setAccountId(accInfoVO.getAccId());
|
accWalletInfo.setAccountId(accInfoVO.getAccountId());
|
||||||
List<AccWalletInfo> walletInfoList = this.accWalletInfoService.selectAccWalletInfoList(accWalletInfo);
|
List<AccWalletInfo> walletInfoList = this.accWalletInfoService.selectAccWalletInfoList(accWalletInfo);
|
||||||
this.setAccInfoVODetailList(accInfoVO, walletInfoList);
|
this.setAccInfoVODetailList(accInfoVO, walletInfoList);
|
||||||
log.info("获取账户(钱包)信息,出参={}", JSONUtil.toJsonStr(accInfoVO));
|
log.info("获取账户(钱包)信息,出参={}", JSONUtil.toJsonStr(accInfoVO));
|
||||||
|
|
@ -377,11 +377,11 @@ public class AccInfoServiceImpl implements IAccInfoService {
|
||||||
|
|
||||||
protected void setAccInfoVODetailList(AccInfoVo accInfoVo, List<AccWalletInfo> walletInfoList) {
|
protected void setAccInfoVODetailList(AccInfoVo accInfoVo, List<AccWalletInfo> walletInfoList) {
|
||||||
if (ObjectUtil.isNotEmpty(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));
|
.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));
|
.map(AccWalletInfo::getWalletBal).reduce(BigDecimal.ZERO, BigDecimal::add));
|
||||||
accInfoVo.setAccAllBal(accInfoVo.getWalletBal().add(accInfoVo.getSubsidyBal()));
|
accInfoVo.setAccountAllBal(accInfoVo.getWalletBal().add(accInfoVo.getSubsidyBal()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Transactional(
|
@Transactional(
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ public class AccSubServiceImpl implements AccSubService {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private void clearAllAccSubsidyHandler(AccInfoDetailsVO accInfoVO, AccSubsidyClearParam param) {
|
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)) {
|
if(Objects.isNull(walletInfo)) {
|
||||||
throw new ServiceException("补贴钱包不存在");
|
throw new ServiceException("补贴钱包不存在");
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +287,7 @@ public class AccSubServiceImpl implements AccSubService {
|
||||||
for (AccInfoDetailsVO accInfo : accInfoVOList) {
|
for (AccInfoDetailsVO accInfo : accInfoVOList) {
|
||||||
try {
|
try {
|
||||||
checkAccount(accInfo);
|
checkAccount(accInfo);
|
||||||
AccWalletInfo walletInfo = accWalletInfoService.selectAccWalletInfoByUserIdAndWalletId(accInfo.getUserId(), AccWalletTypeEnum.SUBSIDY.getKey());
|
AccWalletInfo walletInfo = accWalletInfoService.selectAccWalletInfoByUserIdAndWalletType(accInfo.getUserId(), AccWalletTypeEnum.SUBSIDY.getKey());
|
||||||
if(Objects.isNull(walletInfo)) {
|
if(Objects.isNull(walletInfo)) {
|
||||||
throw new ServiceException("补贴钱包不存在");
|
throw new ServiceException("补贴钱包不存在");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ public class AccWalletInfoServiceImpl implements IAccWalletInfoService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AccWalletInfo selectAccWalletInfoByUserIdAndWalletId(Long userId, Integer walletType) {
|
public AccWalletInfo selectAccWalletInfoByUserIdAndWalletType(Long userId, Integer walletType) {
|
||||||
return accWalletInfoMapper.selectAccWalletInfoByUserIdAndWalletId(userId, walletType);
|
return accWalletInfoMapper.selectAccWalletInfoByUserIdAndWalletType(userId, walletType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectAccWalletInfoByUserIdAndWalletId" resultMap="AccWalletInfoResult">
|
<select id="selectAccWalletInfoByUserIdAndWalletType" resultMap="AccWalletInfoResult">
|
||||||
<include refid="selectAccWalletInfoVo"/>
|
<include refid="selectAccWalletInfoVo"/>
|
||||||
where user_id = #{userId} and wallet_type = #{walletType}
|
where user_id = #{userId} and wallet_type = #{walletType}
|
||||||
</select>
|
</select>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue