| | |
| | | @PostMapping("/withdrawalCallback") |
| | | public Object withdrawalCallback(@RequestBody SinglePayCallbackResult singlePayCallbackResult){ |
| | | Integer status = singlePayCallbackResult.getStatus(); |
| | | String merchantOrderNo = singlePayCallbackResult.getMerchantOrderNo(); |
| | | WithdrawalRequests withdrawalRequests = withdrawalRequestsService.getById(merchantOrderNo); |
| | | if(203 == status || 205 == status){ |
| | | String merchantOrderNo = singlePayCallbackResult.getMerchantOrderNo(); |
| | | WithdrawalRequests withdrawalRequests = withdrawalRequestsService.getById(merchantOrderNo); |
| | | if(1 == withdrawalRequests.getStatus()){ |
| | | withdrawalRequests.setStatus(2); |
| | | withdrawalRequests.setArrivalTime(LocalDateTime.now()); |
| | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("statusCode", 2001); |
| | | return jsonObject; |
| | | }else{ |
| | | //回退扣除的金额,添加明细记录 |
| | | //修改用户的可提现金额 |
| | | BigDecimal withdrawalAmount = withdrawalRequests.getWithdrawalAmount(); |
| | | AppUser appUser = appUserService.getById(withdrawalRequests.getAppUserId()); |
| | | BigDecimal withdrawableAmount = appUser.getWithdrawableAmount(); |
| | | BigDecimal withdrawnAmount = appUser.getWithdrawnAmount(); |
| | | BigDecimal balance = appUser.getBalance(); |
| | | appUser.setWithdrawableAmount(withdrawableAmount.add(withdrawalAmount).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUser.setWithdrawnAmount(withdrawnAmount.subtract(withdrawalAmount).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUser.setBalance(appUser.getBalance().add(withdrawalAmount).setScale(2, RoundingMode.HALF_EVEN)); |
| | | appUserService.updateById(appUser); |
| | | //添加变动明细 |
| | | BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); |
| | | balanceChangeRecord.setAppUserId(appUser.getId()); |
| | | balanceChangeRecord.setVipId(appUser.getVipId()); |
| | | balanceChangeRecord.setOrderId(withdrawalRequests.getId()); |
| | | balanceChangeRecord.setChangeType(2); |
| | | balanceChangeRecord.setBeforeAmount(balance); |
| | | balanceChangeRecord.setChangeAmount(withdrawalAmount); |
| | | balanceChangeRecord.setAfterAmount(appUser.getBalance()); |
| | | balanceChangeRecord.setDelFlag(0); |
| | | balanceChangeRecord.setCreateTime(LocalDateTime.now()); |
| | | balanceChangeRecordService.save(balanceChangeRecord); |
| | | |
| | | withdrawalRequests.setStatus(3); |
| | | withdrawalRequests.setRemark(singlePayCallbackResult.getErrorCodeDesc()); |
| | | withdrawalRequestsService.updateById(withdrawalRequests); |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("statusCode", 2001); |
| | | return jsonObject; |
| | | } |
| | | return new JSONObject(); |
| | | } |
| | | } |
| | | |