| | |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.dto.*; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum; |
| | |
| | | if (walletCoin.getAvailableAmount().compareTo(withdrawDto.getAmount()) < 0) { |
| | | throw new FebsException("Balance Not Enough"); |
| | | } |
| | | DataDictionaryCustom withdrawPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.WITHDRAW_PERCENT.getType(), |
| | | DataDictionaryEnum.WITHDRAW_PERCENT.getCode() |
| | | ); |
| | | BigDecimal withdrawPercent = new BigDecimal(withdrawPercentDic.getValue()); |
| | | |
| | | BigDecimal feeAmount = withdrawDto.getAmount().multiply(withdrawPercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | |
| | | updateWalletCoinWithLock(withdrawDto.getAmount(), member.getId(), 2); |
| | | |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity( |
| | | member.getId(), |
| | | withdrawDto.getAmount().negate(), |
| | | 21, |
| | | 1, |
| | | withdrawDto.getFee(), |
| | | null); |
| | | MoneyFlowEnum.WITHDRAW.getValue(), |
| | | 2, |
| | | feeAmount, |
| | | StrUtil.format(MoneyFlowEnum.WITHDRAW.getDescrition(),withdrawDto.getAmount(),withdrawDto.getFee())); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | |
| | | MemberCoinWithdrawEntity memberCoinWithdraw = new MemberCoinWithdrawEntity(); |
| | | memberCoinWithdraw.setMemberId(member.getId()); |
| | | memberCoinWithdraw.setAddress(member.getAddress()); |
| | | memberCoinWithdraw.setAmount(withdrawDto.getAmount()); |
| | | memberCoinWithdraw.setFeeAmount(withdrawDto.getFee()); |
| | | memberCoinWithdraw.setStatus(MemberCoinWithdrawEntity.STATUS_DOING); |
| | | memberCoinWithdraw.setSymbol("USDT"); |
| | | memberCoinWithdraw.setFeeAmount(feeAmount); |
| | | memberCoinWithdraw.setStatus(MemberCoinWithdrawEntity.STATUS_YES); |
| | | memberCoinWithdraw.setSymbol("COIN"); |
| | | memberCoinWithdraw.setFlowId(fundFlow.getId()); |
| | | memberCoinWithdrawDao.insert(memberCoinWithdraw); |
| | | |
| | | ArrayList<BatchTransferDto> objects = new ArrayList<>(); |
| | | BigDecimal bigDecimal = withdrawDto.getAmount().subtract(feeAmount).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BatchTransferDto batchTransferDto = new BatchTransferDto(member.getAddress(),bigDecimal); |
| | | objects.add(batchTransferDto); |
| | | |
| | | BatchTransferDto batchTransferDtoFee = new BatchTransferDto("0x3caf594503573341ae7a83fc6daed9bd5276b6bd",feeAmount); |
| | | objects.add(batchTransferDtoFee); |
| | | ChainService.getInstance(ChainEnum.BSC_USDT.name()).transferList(objects); |
| | | } |
| | | |
| | | @Override |