diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/dto/BillRefundDTO.java b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/dto/BillRefundDTO.java index 1a70fa82..a39f9ef9 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/dto/BillRefundDTO.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/transactionBill/domain/dto/BillRefundDTO.java @@ -3,6 +3,7 @@ package com.ruoyi.ss.transactionBill.domain.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import javax.validation.constraints.DecimalMin; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; import java.math.BigDecimal; @@ -21,7 +22,7 @@ public class BillRefundDTO { @ApiModelProperty("退款金额") @NotNull(message = "退款金额不允许为空") - @Min(value = 0, message = "退款金额不允许小于0") + @DecimalMin(value = "0.01", message = "退款金额不允许小于0.01") private BigDecimal refundAmount; @ApiModelProperty("退款操作人类型") 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 4f3dad69..1547a22c 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 @@ -162,7 +162,6 @@ public class TransactionBillServiceImpl implements TransactionBillService { * @return 结果 */ @Override - @Transactional public int insertSmTransactionBill(TransactionBill transactionBill) { transactionBill.setCreateTime(DateUtils.getNowDate()); @@ -217,7 +216,6 @@ public class TransactionBillServiceImpl implements TransactionBillService { } @Override - @Transactional(rollbackFor = Exception.class) public String addOrder(TransactionBill data) { // 下单 TransactionBill order = parseToOrder(data); @@ -225,11 +223,17 @@ public class TransactionBillServiceImpl implements TransactionBillService { // 服务费处理 this.handleService(order); - // 插入数据库 - ServiceUtil.assertion(this.insertSmTransactionBill(order) != 1, "下单失败"); + transactionTemplate.execute(status -> { + // 插入数据库 + int insert = this.insertSmTransactionBill(order); + ServiceUtil.assertion(insert != 1, "下单失败"); + return insert; + }); // 若订单金额为0元,则直接充值成功 if (order.getMoney().compareTo(BigDecimal.ZERO) == 0) { + TransactionBillVo bill = this.selectSmTransactionBillByBillNo(order.getBillNo()); + this.paying(bill.getBillId()); this.rechargeSuccess(order.getBillNo(), DateUtils.getNowDate()); } @@ -589,11 +593,13 @@ public class TransactionBillServiceImpl implements TransactionBillService { } @Override - @Transactional public void paying(Long billId) { ServiceUtil.assertion(billId == null, "订单id不允许为空"); - int updateCount = transactionBillMapper.paying(billId); - ServiceUtil.assertion(updateCount != 1, "订单状态发生变化,请刷新后重试"); + transactionTemplate.execute(status -> { + int updateCount = transactionBillMapper.paying(billId); + ServiceUtil.assertion(updateCount != 1, "订单状态发生变化,请刷新后重试"); + return updateCount; + }); } /** diff --git a/smart-switch-service/src/main/java/com/ruoyi/ss/wxPay/service/WxPayService.java b/smart-switch-service/src/main/java/com/ruoyi/ss/wxPay/service/WxPayService.java index f7277d32..93ef462d 100644 --- a/smart-switch-service/src/main/java/com/ruoyi/ss/wxPay/service/WxPayService.java +++ b/smart-switch-service/src/main/java/com/ruoyi/ss/wxPay/service/WxPayService.java @@ -126,7 +126,6 @@ public class WxPayService implements IWxPayService { PrepayWithRequestPaymentResponse res = this.prepayWithRequestPayment(bill); - // 支付中 try { // 支付中 transactionBillService.paying(bill.getBillId());