|
@@ -331,8 +331,8 @@ public class AssetServiceImpl extends ServiceImpl<AssetMapper, Asset> implements
|
|
|
if(withdraw == null){
|
|
|
return;
|
|
|
}
|
|
|
- Integer transferStatus = withdraw.getStatus();
|
|
|
- if(transferStatus != 0){
|
|
|
+ final Integer[] transferStatus = {withdraw.getStatus()};
|
|
|
+ if(transferStatus[0] != 0){
|
|
|
return;
|
|
|
}
|
|
|
String withdrawAmount = responseData.getString("withdrawAmount");
|
|
@@ -342,33 +342,35 @@ public class AssetServiceImpl extends ServiceImpl<AssetMapper, Asset> implements
|
|
|
return;
|
|
|
}
|
|
|
String withdrawStatus = responseData.getString("withdrawStatus");
|
|
|
- BigDecimal procedureAmount = BigDecimal.ZERO;
|
|
|
+ final BigDecimal[] procedureAmount = {BigDecimal.ZERO};
|
|
|
String receivedAmount = responseData.getString("receivedAmount");
|
|
|
BigDecimal realAmount = new BigDecimal(receivedAmount == null ? "0" : receivedAmount)
|
|
|
.divide(new BigDecimal("100"), 2, RoundingMode.UP);
|
|
|
if("SUCCESS".equals(withdrawStatus)){
|
|
|
- transferStatus = 1;
|
|
|
- procedureAmount = amount.subtract(realAmount);
|
|
|
+ transferStatus[0] = 1;
|
|
|
+ procedureAmount[0] = amount.subtract(realAmount);
|
|
|
} else if("FAIL".equals(withdrawStatus)){
|
|
|
- transferStatus = 2;
|
|
|
+ transferStatus[0] = 2;
|
|
|
} else {
|
|
|
return;
|
|
|
}
|
|
|
String errorMessage = responseData.getString("errorMessage");
|
|
|
- //更新提现订单状态和外部订单号
|
|
|
- int i = transferWithdrawService.updateByNotify(id, "", transferStatus, errorMessage, procedureAmount);
|
|
|
- if(i == 1){
|
|
|
- if(transferStatus == 2){
|
|
|
- //失败解冻金额
|
|
|
- baseMapper.backFrozen(amount, withdraw.getUserId(), withdraw.getType(), LocalDateTime.now());
|
|
|
- } else {
|
|
|
- baseMapper.deductFrozen(amount, withdraw.getUserId(), withdraw.getType(), LocalDateTime.now());
|
|
|
- BigDecimal total = queryTotal(withdraw.getUserId(), withdraw.getType());
|
|
|
- //记录平台抽成余额明细
|
|
|
- balanceDetailService.recordFlow(id, withdraw.getType(), withdraw.getUserId(), amount, procedureAmount,
|
|
|
- realAmount, total, 1, 4, withdraw.getUserId());
|
|
|
+ DatabaseContextHolder.transactional((Executor) () -> {
|
|
|
+ //更新提现订单状态和外部订单号
|
|
|
+ int i = transferWithdrawService.updateByNotify(id, "", transferStatus[0], errorMessage, procedureAmount[0]);
|
|
|
+ if(i == 1){
|
|
|
+ if(transferStatus[0] == 2){
|
|
|
+ //失败解冻金额
|
|
|
+ baseMapper.backFrozen(amount, withdraw.getUserId(), withdraw.getType(), LocalDateTime.now());
|
|
|
+ } else {
|
|
|
+ baseMapper.deductFrozen(amount, withdraw.getUserId(), withdraw.getType(), LocalDateTime.now());
|
|
|
+ BigDecimal total = queryTotal(withdraw.getUserId(), withdraw.getType());
|
|
|
+ //记录平台抽成余额明细
|
|
|
+ balanceDetailService.recordFlow(id, withdraw.getType(), withdraw.getUserId(), amount, procedureAmount[0],
|
|
|
+ realAmount, total, 1, 4, withdraw.getUserId());
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -389,8 +391,8 @@ public class AssetServiceImpl extends ServiceImpl<AssetMapper, Asset> implements
|
|
|
if(transfer == null){
|
|
|
return;
|
|
|
}
|
|
|
- Integer transferStatus = transfer.getStatus();
|
|
|
- if(transferStatus != 0){
|
|
|
+ final Integer[] transferStatus = {transfer.getStatus()};
|
|
|
+ if(transferStatus[0] != 0){
|
|
|
return;
|
|
|
}
|
|
|
String transferAmount = responseData.getString("amount");
|
|
@@ -401,41 +403,43 @@ public class AssetServiceImpl extends ServiceImpl<AssetMapper, Asset> implements
|
|
|
}
|
|
|
String transferResultStatus = responseData.getString("status");
|
|
|
if("SUCCESS".equals(transferResultStatus)){
|
|
|
- transferStatus = 1;
|
|
|
+ transferStatus[0] = 1;
|
|
|
} else if("CANCEL".equals(transferResultStatus)){
|
|
|
- transferStatus = 3;
|
|
|
+ transferStatus[0] = 3;
|
|
|
} else if("FAILED".equals(transferResultStatus)){
|
|
|
- transferStatus = 2;
|
|
|
+ transferStatus[0] = 2;
|
|
|
} else {
|
|
|
return;
|
|
|
}
|
|
|
String errorMessage = responseData.getString("errorMessage");
|
|
|
- //更新转账订单状态和外部订单号
|
|
|
- int i = transferWithdrawService.updateByNotify(id, null, transferStatus, errorMessage, BigDecimal.ZERO);
|
|
|
- if(i == 1){
|
|
|
- if(transferStatus == 2){
|
|
|
- //失败平台解冻金额
|
|
|
- baseMapper.backFrozen(amount, 0L, 0, LocalDateTime.now());
|
|
|
- } else {
|
|
|
- Integer type = transfer.getType();
|
|
|
- //平台扣除冻结金额
|
|
|
- baseMapper.deductFrozen(amount, 0L, 0, LocalDateTime.now());
|
|
|
- BigDecimal platformTotal = queryTotal(0L, 0);
|
|
|
- //记录平台转账余额明细
|
|
|
- balanceDetailService.recordFlow(id, 0, 0L, amount, BigDecimal.ZERO,
|
|
|
- amount, platformTotal, 1, 7, transfer.getUserId());
|
|
|
- String remark = responseData.getString("remark");
|
|
|
- if(type == 1 && "0".equals(remark)){
|
|
|
- //用户第一次转账
|
|
|
- return;
|
|
|
+ DatabaseContextHolder.transactional((Executor) () -> {
|
|
|
+ //更新转账订单状态和外部订单号
|
|
|
+ int i = transferWithdrawService.updateByNotify(id, null, transferStatus[0], errorMessage, BigDecimal.ZERO);
|
|
|
+ if(i == 1){
|
|
|
+ if(transferStatus[0] == 2){
|
|
|
+ //失败平台解冻金额
|
|
|
+ baseMapper.backFrozen(amount, 0L, 0, LocalDateTime.now());
|
|
|
+ } else {
|
|
|
+ Integer type = transfer.getType();
|
|
|
+ //平台扣除冻结金额
|
|
|
+ baseMapper.deductFrozen(amount, 0L, 0, LocalDateTime.now());
|
|
|
+ BigDecimal platformTotal = queryTotal(0L, 0);
|
|
|
+ //记录平台转账余额明细
|
|
|
+ balanceDetailService.recordFlow(id, 0, 0L, amount, BigDecimal.ZERO,
|
|
|
+ amount, platformTotal, 1, 7, transfer.getUserId());
|
|
|
+ String remark = responseData.getString("remark");
|
|
|
+ if(type == 1 && "0".equals(remark)){
|
|
|
+ //用户第一次转账
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //转账-更新余额
|
|
|
+ baseMapper.addAmount(transfer.getUserId(), type, amount, LocalDateTime.now());
|
|
|
+ BigDecimal merchantTotal = queryTotal(transfer.getUserId(), transfer.getType());
|
|
|
+ //记录余额明细
|
|
|
+ balanceDetailService.recordFlow(id, type, transfer.getUserId(), amount, BigDecimal.ZERO,
|
|
|
+ amount, merchantTotal, 0, 7, 0L);
|
|
|
}
|
|
|
- //转账-更新余额
|
|
|
- baseMapper.addAmount(transfer.getUserId(), type, amount, LocalDateTime.now());
|
|
|
- BigDecimal merchantTotal = queryTotal(transfer.getUserId(), transfer.getType());
|
|
|
- //记录余额明细
|
|
|
- balanceDetailService.recordFlow(id, type, transfer.getUserId(), amount, BigDecimal.ZERO,
|
|
|
- amount, merchantTotal, 0, 7, 0L);
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
}
|