New file |
| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.account.enums.WithdrawalAuditStatus; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.WithdrawalRequests; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.account.service.WalletService; |
| | | import com.ruoyi.account.service.WithdrawalRequestsService; |
| | | import com.ruoyi.account.vo.WalletVO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.VipSetting; |
| | | import com.ruoyi.other.api.feignClient.RemoteVipSettingClient; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class WalletServiceImpl implements WalletService { |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | @Resource |
| | | private RemoteVipSettingClient remoteVipSettingClient; |
| | | @Resource |
| | | private WithdrawalRequestsService withdrawalRequestsService; |
| | | |
| | | @Override |
| | | public WalletVO getWalletByUserId(Long userId) { |
| | | AppUser appUser = appUserService.getById(userId); |
| | | if (appUser == null) { |
| | | throw new RuntimeException("用户不存在"); |
| | | } |
| | | Integer vipId = appUser.getVipId(); |
| | | R<VipSetting> r = remoteVipSettingClient.getVipSettingById(vipId); |
| | | VipSetting data = r.getData(); |
| | | if (data == null) { |
| | | throw new RuntimeException("会员设置信息为空"); |
| | | } |
| | | |
| | | // 获取提现审核中的金额 |
| | | List<WithdrawalRequests> waitAuditList = withdrawalRequestsService.list(new LambdaQueryWrapper<WithdrawalRequests>() |
| | | .eq(WithdrawalRequests::getAppUserId, userId) |
| | | .eq(WithdrawalRequests::getAuditStatus, WithdrawalAuditStatus.WAIT_AUDIT)); |
| | | |
| | | WalletVO walletVO = new WalletVO(); |
| | | walletVO.setWithdrawalAmount(appUser.getWithdrawableAmount()); |
| | | walletVO.setWithdrawnAmount(appUser.getWithdrawnAmount()); |
| | | walletVO.setVipWithdrawalMinAmount(data.getVipWithdrawalMinAmount()); |
| | | walletVO.setTotalRechargeAmount(appUser.getTotalRechargeAmount()); |
| | | walletVO.setTotalRedPacketAmount(appUser.getTotalRedPacketAmount()); |
| | | walletVO.setTotalDistributionAmount(appUser.getTotalDistributionAmount()); |
| | | walletVO.setAuditAmount(waitAuditList.stream() |
| | | .map(WithdrawalRequests::getWithdrawalAmount) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | walletVO.setBalance(appUser.getBalance()); |
| | | return walletVO; |
| | | } |
| | | |
| | | } |