From aeaa88a25c42febe391498ea5fd910b6ac12f943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?= <14103883+leaf-phos@user.noreply.gitee.com> Date: Sat, 16 Nov 2024 09:58:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E7=8E=B0=E9=A3=8E=E6=8E=A7debug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ss/risk/service/impl/RiskServiceImpl.java | 1 + .../impl/TransactionBillServiceImpl.java | 26 ++++++++++--------- .../app/AppTransactionBillController.java | 11 ++++++++ 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/impl/RiskServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/impl/RiskServiceImpl.java index 47b2ed3d..1c9af353 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/impl/RiskServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/risk/service/impl/RiskServiceImpl.java @@ -119,6 +119,7 @@ public class RiskServiceImpl implements RiskService risk.setUserId(userId); risk.setType(Collections.singletonList(RiskType.WITHDRAW.getType())); risk.setReason(reason); + risk.setEndTime(LocalDateTime.now().plusDays(1)); risk.setUnsealSelf(true); return this.insertRisk(risk); } diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java index 657c3386..1fd3494a 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/service/impl/TransactionBillServiceImpl.java @@ -571,18 +571,16 @@ public class TransactionBillServiceImpl implements TransactionBillService, After // 风控规则,判断用户是否有风险 boolean enabled = sysConfigService.getBoolean(ConfigKey.RISK_WITHDRAW_ENABLED); // 是否开启提现风控 - if (enabled) { - boolean hasRisk = withdrawValidator.hasRisk(bo); - if (hasRisk) { - // 累计一次风险次数 - userService.addRiskCount(userId, 1); - // 若用户风险次数已达到阈值,将用户标记为提现风险 - int riskWithdrawCount = sysConfigService.getInt(ConfigKey.RISK_WITHDRAW_COUNT); - if (user.getRiskCount() + 1 >= riskWithdrawCount) { - riskService.limitWithdraw(userId, "根据风控规则判断,您的提现具有风险"); - // 返回错误 - throw new ServiceException("提现具有风险,无法提现", ServiceCode.RISK_WITHDRAW.getCode()); - } + + // 判断是否有风险 + boolean hasRisk = enabled && withdrawValidator.hasRisk(bo); + if (hasRisk) { + // 若用户风险次数已达到阈值,将用户标记为提现风险 + int riskWithdrawCount = sysConfigService.getInt(ConfigKey.RISK_WITHDRAW_COUNT); + if (user.getRiskCount() + 1 >= riskWithdrawCount) { + riskService.limitWithdraw(userId, "根据风控规则判断,您的提现具有风险"); + // 返回错误 + throw new ServiceException("提现具有风险,无法提现", ServiceCode.RISK_WITHDRAW.getCode()); } } @@ -657,6 +655,10 @@ public class TransactionBillServiceImpl implements TransactionBillService, After // 减少余额,并判断提现金额是否超额(减少的是交易金额) userService.subtractBalance(userId, bill.getMoney(), String.format("提现申请:%s", bill.getBillNo()), RecordBalanceBstType.WITHDRAW, bill.getBillId()); + // 若本次提现具有风险,则累计一次风险次数 + if (hasRisk) { + userService.addRiskCount(userId, 1); + } return insert; }); diff --git a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppTransactionBillController.java b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppTransactionBillController.java index f0647214..4f1a1f97 100644 --- a/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppTransactionBillController.java +++ b/smart-switch-web/src/main/java/com/ruoyi/web/controller/app/AppTransactionBillController.java @@ -188,12 +188,14 @@ public class AppTransactionBillController extends BaseController return ajax; } + @Log(title = "创建订单", businessType = BusinessType.INSERT, operatorType = OperatorType.MOBILE) @ApiOperation("创建订单") @PostMapping("/recharge") public AjaxResult addRecharge(@RequestBody @Validated RechargeDTO dto) { return AjaxResult.success("操作成功", transactionBillService.addOrder(transactionBillConverter.toRechargeBO(dto))); } + @Log(title = "取消充值订单", businessType = BusinessType.OTHER, operatorType = OperatorType.MOBILE) @ApiOperation("取消充值订单") @PutMapping("/recharge/cancel/{billNo}") public AjaxResult cancelRecharge(@PathVariable @ApiParam("订单编号") String billNo) { @@ -204,6 +206,7 @@ public class AppTransactionBillController extends BaseController return AjaxResult.success(transactionBillService.cancelRecharge(billNo, TransactionBillStatus.CANCELED)); } + @Log(title = "提现申请", businessType = BusinessType.INSERT, operatorType = OperatorType.MOBILE) @ApiOperation("提现申请") @PostMapping("/withdraw") public AjaxResult withdraw(@RequestBody @Validated WithdrawDTO dto) { @@ -211,6 +214,7 @@ public class AppTransactionBillController extends BaseController return AjaxResult.success("操作成功", transactionBillService.addWithdraw(transactionBillConverter.toWithdrawBO(dto))); } + @Log(title = "查询设备充值失败列表", businessType = BusinessType.OTHER, operatorType = OperatorType.MOBILE) @ApiOperation("查询设备充值失败列表") @GetMapping("/recharge/device/fail/list") public AjaxResult selectDeviceRechargeFailList() { @@ -242,6 +246,7 @@ public class AppTransactionBillController extends BaseController return success(transactionBillService.bluetoothRechargeSuccess(billNo)); } + @Log(title = "订单退款", businessType = BusinessType.OTHER, operatorType = OperatorType.MOBILE) @ApiOperation("订单退款") @PutMapping("/refund") public AjaxResult refund(@RequestBody @Validated BillRefundDTO dto) { @@ -267,6 +272,7 @@ public class AppTransactionBillController extends BaseController return toAjax(transactionBillService.refund(dto)); } + @Log(title = "刷新支付结果", businessType = BusinessType.OTHER, operatorType = OperatorType.MOBILE) @ApiOperation("刷新支付结果") @PutMapping("/{billNo}/refreshPayResult") public AjaxResult refreshPayResult(@PathVariable String billNo ) { @@ -279,12 +285,14 @@ public class AppTransactionBillController extends BaseController return success(transactionBillService.getUserWithdrawService(getUserId(), channelId)); } + @Log(title = "支付押金", businessType = BusinessType.OTHER, operatorType = OperatorType.MOBILE) @ApiOperation("支付押金") @PutMapping("/payDeposit") public AjaxResult payDeposit(@RequestBody @Validated PayDepositDTO dto) { return success(transactionBillService.payDeposit(transactionBillConverter.toRechargePayDepositBO(dto))); } + @Log(title = "提前结束使用订单", businessType = BusinessType.OTHER, operatorType = OperatorType.MOBILE) @ApiOperation("提前结束使用订单") @PutMapping("/endUse") public AjaxResult endUse(@RequestBody @Validated EndUseDTO dto) { @@ -295,6 +303,7 @@ public class AppTransactionBillController extends BaseController return success(transactionBillService.endUse(bo, true )); } + @Log(title = "提前结束使用智能订单", businessType = BusinessType.OTHER, operatorType = OperatorType.MOBILE) @ApiOperation("提前结束使用智能订单") @PutMapping("/endSmartUse") public AjaxResult endSmartUse(@RequestBody @Validated EndUseDTO dto) { @@ -306,6 +315,7 @@ public class AppTransactionBillController extends BaseController } + @Log(title = "提前结束使用分时段订单", businessType = BusinessType.OTHER, operatorType = OperatorType.MOBILE) @ApiOperation("提前结束使用分时段订单") @PutMapping("/endTimingUse") public AjaxResult endTimingUse(@RequestBody @Validated EndUseDTO dto) { @@ -352,6 +362,7 @@ public class AppTransactionBillController extends BaseController return toAjax(transactionBillService.switchDevice(bill, open)); } + @Log(title = "支付订单", businessType = BusinessType.OTHER, operatorType = OperatorType.MOBILE) @ApiOperation("支付订单") @PutMapping("/pay") public AjaxResult pay(@RequestBody BillPayDTO dto) {