1
zj
2024-12-02 a9384606526161453415f8fcb972468f24f3d9b4
src/main/java/com/nq/service/impl/UserWithdrawServiceImpl.java
@@ -330,6 +330,7 @@
    }
    @Transactional
    public ServerResponse updateState(Integer withId, Integer state, String authMsg) throws Exception {
        UserWithdraw userWithdraw = this.userWithdrawMapper.selectByPrimaryKey(withId);
        SiteSetting siteSetting = siteSettingService.getSiteSetting();
@@ -353,9 +354,19 @@
            return ServerResponse.createByErrorMsg("用户资金账户不存在");
        }
        if (state == 3) {
            userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(userWithdraw.getWithAmt()));
            userAssets.setFreezeMoney(userAssets.getFreezeMoney().subtract(userWithdraw.getWithAmt()));
            if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){
                BigDecimal subtract = userWithdraw.getWithAmt().subtract(userAssets.getAmountToBeCovered());
                if(subtract.compareTo(BigDecimal.ZERO) > 0){
                    userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(subtract));
                    userAssets.setFreezeMoney(userAssets.getFreezeMoney().subtract(subtract));
                    userAssets.setAmountToBeCovered(BigDecimal.ZERO);
                }else{
                    userAssets.setAmountToBeCovered(userAssets.getAmountToBeCovered().subtract(userWithdraw.getWithAmt()));
                }
            }else{
                userAssets.setAvailableBalance(userAssets.getAvailableBalance().add(userWithdraw.getWithAmt()));
                userAssets.setFreezeMoney(userAssets.getFreezeMoney().subtract(userWithdraw.getWithAmt()));
            }
            int updateCount = userAssetsMapper.updateById(userAssets);
            if (updateCount > 0) {
                log.info("提现失败,返还用户资金成功!");