From fd7b8fb7c89832c28a838b0449bbb8a392433ee2 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期二, 22 四月 2025 14:33:02 +0800 Subject: [PATCH] 将华为云短信替换成阿里云短信 --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java | 87 ++++++++++++++++++++++++++++++++++--------- 1 files changed, 69 insertions(+), 18 deletions(-) diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java index 3e95d1a..81fe08f 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java @@ -16,8 +16,11 @@ import com.ruoyi.account.util.payment.model.SinglePay; import com.ruoyi.account.util.payment.model.SinglePayCallbackResult; import com.ruoyi.account.util.payment.model.SinglePayResult; +import com.ruoyi.account.vo.WithdrawalAuth; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.web.domain.AjaxResult; +import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.system.api.model.LoginUser; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -48,6 +51,8 @@ @Resource private BalanceChangeRecordService balanceChangeRecordService; + @Resource + private TokenService tokenService; /** * 提现申请 @@ -78,27 +83,29 @@ @PostMapping("/auth") @ApiOperation(value = "提现申请审批", tags = {"后台"}) - public R auth(@RequestParam Long id,@ApiParam("2'审核通过',3'审核拒绝'") Integer auditStatus){ - WithdrawalRequests withdrawal = withdrawalRequestsService.getById(id); + public R auth(@RequestBody WithdrawalAuth withdrawalAuth){ + WithdrawalRequests withdrawal = withdrawalRequestsService.getById(withdrawalAuth.getId()); BigDecimal withdrawalAmount = withdrawal.getWithdrawalAmount(); if(withdrawal.getAuditStatus() != 1){ return R.fail("不能重复审核"); } + Integer auditStatus = withdrawalAuth.getAuditStatus(); if (auditStatus==2){ - //先检查账户余额是否充足 - AccountBalanceQueryResult accountBalanceQueryResult = TransferUtil.accountBalanceQuery(); - if(null == accountBalanceQueryResult){ - return R.fail("查询账户余额出错"); - } - Double useAbleSettAmount = accountBalanceQueryResult.getUseAbleSettAmount(); - if(useAbleSettAmount < withdrawal.getArrivalAmount().doubleValue()){ - return R.fail("账户可用余额不足,请先补充账户余额"); - } //执行转账操作 if(withdrawal.getWithdrawalMethod() == 2){ + //先检查账户余额是否充足 + AccountBalanceQueryResult accountBalanceQueryResult = TransferUtil.accountBalanceQuery(); + if(null == accountBalanceQueryResult){ + return R.fail("查询账户余额出错"); + } + Double useAbleSettAmount = accountBalanceQueryResult.getUseAbleSettAmount(); + //计算代付手续费 + if(useAbleSettAmount < (withdrawal.getArrivalAmount().doubleValue() + 1)){ + return R.fail("账户可用余额不足,请先补充账户余额"); + } //银行卡转账 SinglePay singlePay = new SinglePay(); - singlePay.setTradeMerchantNo(""); + singlePay.setTradeMerchantNo(TransferUtil.sysTradeMerchantNo); singlePay.setMerchantOrderNo(withdrawal.getId().toString()); singlePay.setReceiverAccountNoEnc(withdrawal.getBankCardNumber()); singlePay.setReceiverNameEnc(withdrawal.getAccountHolder()); @@ -109,11 +116,25 @@ singlePay.setCallbackUrl("/account/withdrawal-requests/withdrawalCallback"); SinglePayResult singlePayResult = TransferUtil.singlePay(singlePay); if(null == singlePayResult){ + LoginUser loginUserApplet = tokenService.getLoginUserApplet(); + AppUser appUser = appUserService.getById(loginUserApplet.getUserid()); + BigDecimal balance = appUser.getBalance(); + BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); + balanceChangeRecord.setAppUserId(appUser.getId()); + balanceChangeRecord.setVipId(appUser.getVipId()); +// balanceChangeRecord.setOrderId(withdrawalRequests.getId()); + balanceChangeRecord.setChangeType(2); + balanceChangeRecord.setChangeAmount(withdrawalAmount); + balanceChangeRecord.setDelFlag(0); + balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecord.setChangeDirection(-1); + balanceChangeRecordService.save(balanceChangeRecord); return R.fail("转账失败"); } withdrawal.setStatus(1); }else{ //微信转账 + return R.fail("微信转账开发中"); } } if(3 == auditStatus){ @@ -130,13 +151,13 @@ //添加变动明细 BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); balanceChangeRecord.setAppUserId(appUser.getId()); + balanceChangeRecord.setVipId(appUser.getVipId()); balanceChangeRecord.setOrderId(withdrawal.getId()); balanceChangeRecord.setChangeType(2); - balanceChangeRecord.setBeforeAmount(balance); balanceChangeRecord.setChangeAmount(withdrawalAmount); - balanceChangeRecord.setAfterAmount(appUser.getBalance()); balanceChangeRecord.setDelFlag(0); balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecord.setChangeDirection(-1); balanceChangeRecordService.save(balanceChangeRecord); } withdrawal.setAuditStatus(auditStatus); @@ -153,9 +174,9 @@ @PostMapping("/withdrawalCallback") public Object withdrawalCallback(@RequestBody SinglePayCallbackResult singlePayCallbackResult){ Integer status = singlePayCallbackResult.getStatus(); - if(203 == status){ - String merchantOrderNo = singlePayCallbackResult.getMerchantOrderNo(); - WithdrawalRequests withdrawalRequests = withdrawalRequestsService.getById(merchantOrderNo); + String merchantOrderNo = singlePayCallbackResult.getMerchantOrderNo(); + WithdrawalRequests withdrawalRequests = withdrawalRequestsService.getById(merchantOrderNo); + if(203 == status || 205 == status){ if(1 == withdrawalRequests.getStatus()){ withdrawalRequests.setStatus(2); withdrawalRequests.setArrivalTime(LocalDateTime.now()); @@ -164,8 +185,38 @@ 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.setChangeAmount(withdrawalAmount); + balanceChangeRecord.setDelFlag(0); + balanceChangeRecord.setCreateTime(LocalDateTime.now()); + balanceChangeRecord.setChangeDirection(-1); + 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(); } } -- Gitblit v1.7.1