|
|
@@ -259,17 +259,23 @@ public class SysAmountAuditingServiceImpl extends ServiceImpl<SysAmountAuditingM
|
|
|
|
|
|
@Override
|
|
|
public Boolean applyWithdraw(ApplyWithdrawParam applyWithdrawParam) {
|
|
|
-
|
|
|
+ String userName = baseController.getUserName();
|
|
|
+ String userId = baseController.getUserId();
|
|
|
+ log.info("业务员提交提现申请:userName=[{}],userId=[{}],applyWithdrawParam=[{}]",userId, userName, JSONUtil.toJsonStr(applyWithdrawParam));
|
|
|
if(applyWithdrawParam.getWithdrawAmount().compareTo(BigDecimal.ZERO) <= 0){
|
|
|
throw new SystemException("提现金额错误,请重新输入");
|
|
|
}
|
|
|
-
|
|
|
- SysUserAccount sysUserAccount = userAccountService.queryByUserId(baseController.getUserId());
|
|
|
+ SysUserAccount sysUserAccount = userAccountService.queryByUserId(userId);
|
|
|
AssertionUtils.isFail(Objects.isNull(sysUserAccount),"找不到用户");
|
|
|
|
|
|
+ // sys_amount_auditing 表中的 balance_amount 字段,表示冻结的金额, 避免重复提现
|
|
|
+ // 查询处于提现进程中的申请记录。 汇总其中的冻结金额
|
|
|
+ List<SysAmountAuditing> amountAuditings = baseMapper.queryPaymentByUserId(userId,0);
|
|
|
+ BigDecimal freezAmount = amountAuditings.stream()
|
|
|
+ .filter(action-> action.getAuditingStatus() != null && 0 == action.getAuditingStatus())
|
|
|
+ .map(SysAmountAuditing::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
// 当前用户的余额
|
|
|
- BigDecimal sumAmount = sysUserAccount.getSumAmount();
|
|
|
-
|
|
|
+ BigDecimal sumAmount =freezAmount.add(sysUserAccount.getSumAmount());
|
|
|
if(sumAmount.compareTo(applyWithdrawParam.getWithdrawAmount()) < 0){
|
|
|
throw new SystemException("无法提现,请检查当前账户余额");
|
|
|
}
|