|
@@ -199,7 +199,7 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
List<Long> ids = Arrays.asList(StringUtil.toLongArray(StringPool.COMMA, authOperaReq.getId()));
|
|
|
|
|
|
//先判断三方余额是否充足
|
|
|
- if (authOperaReq.getPass()) {
|
|
|
+ if (authOperaReq.getPass() && "ONLINE".equals(authOperaReq.getType())) {
|
|
|
List<UserWithdrawal> userWithdrawals = baseMapper.selectList(Wrappers.<UserWithdrawal>lambdaQuery()
|
|
|
.in(UserWithdrawal::getId, ids)
|
|
|
.eq(UserWithdrawal::getAuthStatus, AuthStatusEnum.DOING));
|
|
@@ -225,6 +225,7 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
param.setReason(authOperaReq.getReason());
|
|
|
param.setPass(authOperaReq.getPass());
|
|
|
param.setUserId(sysUser.getId());
|
|
|
+ param.setType(authOperaReq.getType());
|
|
|
try {
|
|
|
HttpResponseResult<UserWithdrawalVo> res = DistributedLock.of(redissonClient)
|
|
|
.runIfLockToFunction(CacheNameEnum.LOCK_WITHDRAWAL.getRedisKey(id.toString())
|
|
@@ -258,10 +259,16 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
build.setAuthUserId(authOperaReq.getUserId());
|
|
|
build.setUpdateTime(new Date());
|
|
|
build.setAuthTime(new Date());
|
|
|
+ build.setType(authOperaReq.getType());
|
|
|
|
|
|
SysUser withdrawalUser = sysUserService.findUserById(build.getUserId());
|
|
|
HttpResponseResult res = HttpResponseResult.succeed(build);
|
|
|
if (authOperaReq.getPass()) {
|
|
|
+ if (authOperaReq.getType().equals("OFFLINE")) {
|
|
|
+ //线下审核通过,不调用三方
|
|
|
+ withdrawalSuccess(null, build);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
//交易流水号生成
|
|
|
Long transNo = idGeneratorService.generatorId("withdrawNo");
|
|
|
|
|
@@ -350,19 +357,9 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
if (!TradeStatusEnum.pending.equals(detail.getTradeStatus())) {
|
|
|
return;
|
|
|
}
|
|
|
+ detail.setCallbackJson(jsonStr);
|
|
|
if ("1".equals(callback.getStatus())) {
|
|
|
- //交易成功
|
|
|
- detail.setTradeStatus(TradeStatusEnum.succeeded);
|
|
|
- detail.setTradeNo(callback.getOrderNo());
|
|
|
- BigDecimal actualAmount = new BigDecimal(callback.getActualAmount());
|
|
|
- detail.setActualAmount(actualAmount.divide(new BigDecimal("100")));
|
|
|
- detail.setTransferTime(callback.getEndTime());
|
|
|
-
|
|
|
- //结算成功,账户解冻,入账户明细
|
|
|
- UserAccountRecordVo recordVo = accountRecordService.detail(null, AccountBizTypeEnum.WITHDRAWAL, detail.getId());
|
|
|
- userAccountService.accountChange(recordVo, PostStatusEnum.RECORDED);
|
|
|
- //发生结算成功通知
|
|
|
- successSend(detail.getUserId(), detail.getPhone());
|
|
|
+ withdrawalSuccess(callback, detail);
|
|
|
} else if ("2".equals(callback.getStatus())) {
|
|
|
//交易失败
|
|
|
detail.setTradeStatus(TradeStatusEnum.failed);
|
|
@@ -373,14 +370,33 @@ public class UserWithdrawalServiceImpl extends ServiceImpl<UserWithdrawalDao, Us
|
|
|
//结算失败,账户解冻
|
|
|
UserAccountRecordVo recordVo = accountRecordService.detail(null, AccountBizTypeEnum.WITHDRAWAL, detail.getId());
|
|
|
userAccountService.accountChange(recordVo, PostStatusEnum.CANCEL);
|
|
|
+ updateById(detail);
|
|
|
|
|
|
//发生结算失败通知
|
|
|
unpassSend(detail.getUserId(), detail.getPhone(), callback.getErrorMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void withdrawalSuccess(UserWithdrawalCallback callback, UserWithdrawalVo detail) {
|
|
|
+ //交易成功
|
|
|
+ detail.setTradeStatus(TradeStatusEnum.succeeded);
|
|
|
+ if (callback !=null) {
|
|
|
+ detail.setTradeNo(callback.getOrderNo());
|
|
|
+ BigDecimal actualAmount = new BigDecimal(callback.getActualAmount());
|
|
|
+ detail.setActualAmount(actualAmount.divide(new BigDecimal("100")));
|
|
|
+ detail.setTransferTime(callback.getEndTime());
|
|
|
} else {
|
|
|
- return;
|
|
|
+ detail.setTradeNo("");
|
|
|
+ detail.setActualAmount(detail.getActualAmount());
|
|
|
+ detail.setTransferTime(new Date());
|
|
|
}
|
|
|
- detail.setCallbackJson(jsonStr);
|
|
|
+
|
|
|
+ //结算成功,账户解冻,入账户明细
|
|
|
+ UserAccountRecordVo recordVo = accountRecordService.detail(null, AccountBizTypeEnum.WITHDRAWAL, detail.getId());
|
|
|
+ userAccountService.accountChange(recordVo, PostStatusEnum.RECORDED);
|
|
|
updateById(detail);
|
|
|
+ //发生结算成功通知
|
|
|
+ successSend(detail.getUserId(), detail.getPhone());
|
|
|
}
|
|
|
|
|
|
@Override
|