From d83e8e364048387bfa5c4c1fd07002940abdf63f Mon Sep 17 00:00:00 2001 From: yupeng <roc__yu@163.com> Date: 星期三, 12 二月 2025 12:07:54 +0800 Subject: [PATCH] feat:更新线下支付接口,RedisCache添加循环取锁方法,其他 --- ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/PayController.java | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/PayController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/PayController.java index 70cdda4..b095e80 100644 --- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/PayController.java +++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/PayController.java @@ -15,6 +15,7 @@ import io.swagger.annotations.ApiOperation; import org.apache.poi.ss.formula.functions.T; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -48,23 +49,26 @@ return R.ok(resp); } - + @ApiOperation(value = "线下支付") @PostMapping("offlinePay") + @Transactional(rollbackFor = Exception.class) public R offlinePay(@Validated @RequestBody OfflinePayDto dto){ List<TBill> tBills = tBillService.listByIds(dto.getBillIds()); + TBillConfirm confirm = new TBillConfirm(); + confirm.setBillId(CollectionUtil.join(dto.getBillIds(),",")); + confirm.setVoucher(dto.getVoucher()); + confirm.setPayFeesMoney(new BigDecimal(dto.getAmount()).divide(AmountConstant.b100).setScale(2, RoundingMode.HALF_DOWN).doubleValue()); + tBillConfirmService.save(confirm); for (TBill tBill : tBills) { TBill save = new TBill(); save.setId(tBill.getId()); save.setPayFeesType(2); save.setVoucher(dto.getVoucher()); save.setPayFeesStatus("2"); - tBillService.lockAndUpdateInfo(save); + save.setConfirmId(confirm.getId()); + tBillService.lockAndUpdateInfo(save,1); } - TBillConfirm confirm = new TBillConfirm(); - confirm.setBillId(CollectionUtil.join(dto.getBillIds(),",")); - confirm.setVoucher(dto.getVoucher()); - confirm.setPayFeesMoney(new BigDecimal(dto.getAmount()).divide(AmountConstant.b100).setScale(2, RoundingMode.HALF_DOWN).doubleValue()); - tBillConfirmService.save(confirm); + return R.ok(); } -- Gitblit v1.7.1