| | |
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public Result usdtToGusd(BigDecimal balance, Integer transfertype) {
|
| | | //获取用户ID
|
| | | Long memberId = LoginUserUtils.getAppLoginUser().getId();
|
| | | if (balance.compareTo(BigDecimal.ZERO) <= 0) {
|
| | | return Result.fail(MessageSourceUtils.getString("member_service_0004"));
|
| | | }
|
| | |
|
| | | // 扣币
|
| | | String walletCode = MemberWalletCoinEnum.WALLETCOINCODE.getValue();
|
| | | MemberWalletCoinEntity memberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, walletCode);
|
| | | BigDecimal availableBalance = memberWalletCoinEntity.getAvailableBalance();
|
| | | BigDecimal totalBalance = memberWalletCoinEntity.getTotalBalance();
|
| | |
|
| | | BigDecimal available = availableBalance.subtract(balance);
|
| | | if (available.compareTo(BigDecimal.ZERO) < 0) {
|
| | | return Result.fail(MessageSourceUtils.getString("member_service_0008"));
|
| | | }
|
| | | BigDecimal total = totalBalance.subtract(balance);
|
| | | if (total.compareTo(BigDecimal.ZERO) < 0) {
|
| | | return Result.fail(MessageSourceUtils.getString("member_service_0008"));
|
| | | }
|
| | |
|
| | | memberWalletCoinEntity.setAvailableBalance(available);
|
| | | memberWalletCoinEntity.setTotalBalance(total);
|
| | | int i = memberWalletCoinDao.updateById(memberWalletCoinEntity);
|
| | | if (i < 1) {
|
| | | return Result.fail(MessageSourceUtils.getString("member_service_0095"));
|
| | | }
|
| | | //添加资金划转历史记录
|
| | | MemberAccountMoneyChange memberAccountRecord = new MemberAccountMoneyChange();
|
| | | //获取usdt兑换gusd的兑换比例
|
| | | String gusdName = CoinTypeEnum.GUSD.name();
|
| | | MemberWalletCoinEntity gusdMemberWalletCoinEntity = memberWalletCoinDao.selectWalletCoinBymIdAndCode(memberId, gusdName);
|
| | | BigDecimal gusdAvailableBalance = gusdMemberWalletCoinEntity.getAvailableBalance();
|
| | | BigDecimal gusdTotalBalance = gusdMemberWalletCoinEntity.getTotalBalance();
|
| | | gusdMemberWalletCoinEntity.setAvailableBalance(gusdAvailableBalance.add(balance));
|
| | | gusdMemberWalletCoinEntity.setTotalBalance(gusdTotalBalance.add(balance));
|
| | |
|
| | | int updateById = memberWalletCoinDao.updateById(gusdMemberWalletCoinEntity);
|
| | | if (updateById < 1) {
|
| | | return Result.fail(MessageSourceUtils.getString("member_service_0095"));
|
| | | }
|
| | |
|
| | | //添加资金划转历史记录
|
| | | memberAccountRecord.setMemberId(memberId);
|
| | | memberAccountRecord.setStatus(MemberAccountMoneyChange.STATUS_SUCCESS_INTEGER);
|
| | | memberAccountRecord.setSymbol(walletCode);
|
| | | memberAccountRecord.setContent(MemberWalletCoinEnum.ZHIYATOGUSD.getValue());
|
| | | memberAccountRecord.setType(MemberAccountMoneyChange.TYPE_WALLET_COIN);
|
| | | memberAccountRecord.setAmount(balance);
|
| | | memberAccountMoneyChangeDao.insert(memberAccountRecord);
|
| | |
|
| | | return Result.ok(MessageSourceUtils.getString("member_service_0006"));
|
| | | }
|
| | |
|
| | | }
|