|
@@ -89,7 +89,8 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
BigDecimal withdrawalServiceFee = getWithdrawalServiceFee();
|
|
|
withdrawalInfoRes.setWithdrawalServiceFee(withdrawalServiceFee);
|
|
|
//获取用户可用于提现余额
|
|
|
- withdrawalInfoRes.setAmountWithdrawal(getAmountWithdrawal(userId));
|
|
|
+ withdrawalInfoRes.setAmountWithdrawal(getAmountUsable(userId).subtract(withdrawalServiceFee)
|
|
|
+ .setScale(2, RoundingMode.HALF_UP));
|
|
|
return HttpResponseResult.succeed(withdrawalInfoRes);
|
|
|
}
|
|
|
|
|
@@ -102,7 +103,7 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
return HttpResponseResult.failed("提现金额过小");
|
|
|
}
|
|
|
//获取用户提现金额
|
|
|
- BigDecimal amountWithdrawal = getAmountWithdrawal(userId);
|
|
|
+ BigDecimal amountWithdrawal = getAmountUsable(userId);
|
|
|
//比较大小
|
|
|
if (amountWithdrawal.compareTo(withdrawalReq.getAmountWithdrawal()) < 0) {
|
|
|
return HttpResponseResult.failed("账户余额不足");
|
|
@@ -120,6 +121,7 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
userWithdrawal.getId(), "老师提现", null
|
|
|
);
|
|
|
accountRecordDto.setFrozenType(FrozenTypeEnum.FROZEN);
|
|
|
+ accountRecordDto.setSaveRecord(false);
|
|
|
HttpResponseResult<UserAccountRecord> accountChange = userAccountService.accountChange(accountRecordDto);
|
|
|
if (accountChange.getStatus()) {
|
|
|
return HttpResponseResult.succeed(true);
|
|
@@ -144,18 +146,20 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
StringBuffer buffer = new StringBuffer(data.getId().toString());
|
|
|
buffer.append(data.getUserId());
|
|
|
buffer.append(data.getAmount().setScale(2, RoundingMode.HALF_UP));
|
|
|
+ buffer.append(data.getPlantformFee().setScale(2, RoundingMode.HALF_UP));
|
|
|
buffer.append(data.getActualAmount().setScale(2, RoundingMode.HALF_UP));
|
|
|
+
|
|
|
String sign = DigestUtils.md5DigestAsHex(buffer.toString().getBytes());
|
|
|
if (!data.getSign().equals(sign)) {
|
|
|
errMsgList.add(new ErrMsg(dataReaderProperty.getRowIndex(), "验签失败"));
|
|
|
continue;
|
|
|
}
|
|
|
- if(AuthStatusEnum.PASS.equals(data.getStatus()) && StringUtil.isEmpty(data.getBankFlowNo())){
|
|
|
+ if (AuthStatusEnum.PASS.equals(data.getStatus()) && StringUtil.isEmpty(data.getBankFlowNo())) {
|
|
|
errMsgList.add(new ErrMsg(dataReaderProperty.getRowIndex(), "审核通过时,转账流水号不能为空"));
|
|
|
continue;
|
|
|
}
|
|
|
- if(!AuthStatusEnum.DOING.equals(data.getStatus())
|
|
|
- && StringUtil.isEmpty(data.getVerifyReason())){
|
|
|
+ if (!AuthStatusEnum.DOING.equals(data.getStatus())
|
|
|
+ && StringUtil.isEmpty(data.getVerifyReason())) {
|
|
|
errMsgList.add(new ErrMsg(dataReaderProperty.getRowIndex(), "审核理由不能为空"));
|
|
|
continue;
|
|
|
}
|
|
@@ -184,10 +188,34 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
private void authWithdrawalBancth(List<UserWithdrawal> userWithdrawalList) {
|
|
|
for (UserWithdrawal userWithdrawal : userWithdrawalList) {
|
|
|
UserWithdrawal old = baseMapper.selectById(userWithdrawal.getId());
|
|
|
- if(null != old && !AuthStatusEnum.PASS.equals(old.getStatus())
|
|
|
- && !old.getStatus().equals(userWithdrawal.getStatus())){
|
|
|
+ if (null == old) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!AuthStatusEnum.PASS.equals(old.getStatus())
|
|
|
+ && !old.getStatus().equals(userWithdrawal.getStatus())) {
|
|
|
baseMapper.updateById(userWithdrawal);
|
|
|
+
|
|
|
+ if (AuthStatusEnum.PASS.equals(userWithdrawal.getStatus())) {
|
|
|
+ //审核通过,账户解冻,入账户明细
|
|
|
+ UserAccountRecordDto accountRecordDto = new UserAccountRecordDto(
|
|
|
+ old.getUserId(), old.getAmount(), InOrOutEnum.OUT, AccountBizTypeEnum.WITHDRAWAL,
|
|
|
+ userWithdrawal.getId(), "老师提现", null
|
|
|
+ );
|
|
|
+ accountRecordDto.setFrozenType(FrozenTypeEnum.FROZEN_DEDUCT);
|
|
|
+ accountRecordDto.setSaveRecord(true);
|
|
|
+ userAccountService.accountChange(accountRecordDto);
|
|
|
+ } else if (AuthStatusEnum.UNPASS.equals(userWithdrawal.getStatus())) {
|
|
|
+ //审核不通过,账户解冻
|
|
|
+ UserAccountRecordDto accountRecordDto = new UserAccountRecordDto(
|
|
|
+ old.getUserId(), old.getAmount(), InOrOutEnum.OUT, AccountBizTypeEnum.WITHDRAWAL,
|
|
|
+ userWithdrawal.getId(), "老师提现", null
|
|
|
+ );
|
|
|
+ accountRecordDto.setFrozenType(FrozenTypeEnum.FROZEN_BACK);
|
|
|
+ accountRecordDto.setSaveRecord(false);
|
|
|
+ userAccountService.accountChange(accountRecordDto);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -225,13 +253,14 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
* @return: java.math.BigDecimal
|
|
|
*/
|
|
|
private BigDecimal getWithdrawalServiceFee() {
|
|
|
- BigDecimal withdrawalServiceFee = new BigDecimal(0);
|
|
|
+ BigDecimal withdrawalServiceFee;
|
|
|
try {
|
|
|
String configValue = sysConfigService.findConfigValue(SysConfigConstant.WITHDRAWAL_SERVICE_FEE);
|
|
|
withdrawalServiceFee = new BigDecimal(configValue);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
log.info("获取平台配置失败 key={}", SysConfigConstant.WITHDRAWAL_SERVICE_FEE);
|
|
|
+ withdrawalServiceFee = new BigDecimal(0);
|
|
|
}
|
|
|
return withdrawalServiceFee;
|
|
|
}
|
|
@@ -244,7 +273,7 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
* @updateTime 2022/4/7 15:02
|
|
|
* @return: java.math.BigDecimal
|
|
|
*/
|
|
|
- private BigDecimal getAmountWithdrawal(Long userId) {
|
|
|
+ private BigDecimal getAmountUsable(Long userId) {
|
|
|
//查询用户账户余额
|
|
|
UserAccountVo detail = userAccountService.detail(userId);
|
|
|
BigDecimal subtract = detail.getAmountUsable();
|