From cc6370087214adf097e9ad3de5e81b3cb63bfc74 Mon Sep 17 00:00:00 2001 From: XinWei <2718030729@qq.com> Date: Wed, 25 Sep 2024 14:58:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0-=E4=BF=AE=E6=94=B9=E4=BD=99?= =?UTF-8?q?=E9=A2=9D=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/wallet/vo/wallet/PayWalletUserBalanceVo.java | 3 ++- .../module/pay/service/wallet/PayWalletServiceImpl.java | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserBalanceVo.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserBalanceVo.java index 50f61de..dc939a0 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserBalanceVo.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/vo/wallet/PayWalletUserBalanceVo.java @@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; @Schema(description = "管理后台 - 用户修改余额 Request VO") @@ -12,5 +13,5 @@ public class PayWalletUserBalanceVo { @Schema(description = "钱包编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") private Long id; @Schema(description = "余额", requiredMode = Schema.RequiredMode.REQUIRED) - private Integer balance; + private BigDecimal balance; } diff --git a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java index de7dad4..43366f4 100644 --- a/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java +++ b/yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.math.BigDecimal; import java.time.LocalDateTime; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -209,12 +210,14 @@ public class PayWalletServiceImpl implements PayWalletService { @Override public void updateWallet(PayWalletUserBalanceVo reqVo) { - if(reqVo.getBalance() == 0){ + if(reqVo.getBalance().compareTo(BigDecimal.ZERO) == 0){ return; } + BigDecimal change = new BigDecimal("100"); PayWalletDO walletDO = walletMapper.selectById(reqVo.getId()); - int totalBalance = walletDO.getBalance() + reqVo.getBalance(); - int totalRecharge = walletDO.getTotalRecharge() + reqVo.getBalance(); + int changeBalance = (reqVo.getBalance().multiply(change)).intValue(); + int totalBalance = walletDO.getBalance() + changeBalance; + int totalRecharge = walletDO.getTotalRecharge() + changeBalance; walletDO.setBalance(totalBalance); walletDO.setTotalRecharge(totalRecharge); walletMapper.updateById(walletDO);