| | |
| | | import cc.mrbird.febs.dapp.chain.ContractChainService; |
| | | import cc.mrbird.febs.dapp.dto.*; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cc.mrbird.febs.dapp.service.DappWalletService; |
| | | import cc.mrbird.febs.dapp.utils.BoxUtil; |
| | |
| | | private final RedisUtils redisUtils; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | private final DappNftActivationDao dappNftActivationDao; |
| | | private final MemberCoinWithdrawDao memberCoinWithdrawDao; |
| | | |
| | | private final ChainProducer chainProducer; |
| | | private final DappSystemDao dappSystemDao; |
| | |
| | | |
| | | DappMemberEntity memberInfo = dappMemberDao.selectById(member.getId()); |
| | | WalletInfoVo walletInfo = new WalletInfoVo(); |
| | | List<DappMemberEntity> direct = dappMemberDao.selectChildMemberDirectOrNot(member.getInviteId(), 1, null); |
| | | List<DappMemberEntity> direct = dappMemberDao.selectChildMemberDirectOrNot(member.getInviteId(), 1, 1); |
| | | DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId()); |
| | | DappWalletMineEntity walletMine = dappWalletMineDao.selectByMemberId(member.getId()); |
| | | |
| | |
| | | dappFundFlowEntity.setType(recordInPageDto.getType()); |
| | | } |
| | | dappFundFlowEntity.setMemberId(member.getId()); |
| | | dappFundFlowEntity.setStatus(2); |
| | | // dappFundFlowEntity.setStatus(2); |
| | | |
| | | IPage<DappFundFlowEntity> records = dappFundFlowDao.selectInPage(page, dappFundFlowEntity); |
| | | return records.getRecords(); |
| | |
| | | |
| | | @Override |
| | | public BigDecimal calPrice(PriceDto priceDto) { |
| | | String priceStr = redisUtils.getString(AppContants.REDIS_KEY_TFC_NEW_PRICE); |
| | | // String priceStr = redisUtils.getString(AppContants.REDIS_KEY_TFC_NEW_PRICE); |
| | | DataDictionaryCustom symbolPrice = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode()); |
| | | DataDictionaryCustom serviceFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getType(), DataDictionaryEnum.WITHDRAW_SERVICE_FEE.getCode()); |
| | | |
| | | BigDecimal amount = priceDto.getAmount(); |
| | | if (priceDto.getAmount() == null) { |
| | | amount = BigDecimal.ZERO; |
| | | } |
| | | return amount.multiply(new BigDecimal("0.1")).divide(new BigDecimal(priceStr), 2, RoundingMode.HALF_UP); |
| | | return amount.multiply(new BigDecimal(serviceFeeDic.getValue()).divide(BigDecimal.valueOf(100), 8, RoundingMode.HALF_DOWN)).multiply(new BigDecimal(symbolPrice.getValue())); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | DappWalletMineEntity walletMine = dappWalletMineDao.selectByMemberId(member.getId()); |
| | | if (walletMine.getAvailableAmount().compareTo(withdrawDto.getFee()) < 0) { |
| | | throw new FebsException("TFC Not Enough"); |
| | | throw new FebsException("DMD Not Enough"); |
| | | } |
| | | |
| | | updateWalletCoinWithLock(withdrawDto.getAmount(), member.getId(), 2); |
| | | updateWalletMineWithLock(withdrawDto.getFee(), member.getId(), 2); |
| | | |
| | | |
| | | DappFundFlowEntity feeFlow = new DappFundFlowEntity(member.getId(), withdrawDto.getFee().negate(), 7, 2, null, null); |
| | | dappFundFlowDao.insert(feeFlow); |
| | |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(member.getId(), withdrawDto.getAmount().negate(), 5, 2, withdrawDto.getFee(), null); |
| | | 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_YES); |
| | | memberCoinWithdraw.setSymbol("USDT"); |
| | | memberCoinWithdraw.setFlowId(fundFlow.getId()); |
| | | memberCoinWithdrawDao.insert(memberCoinWithdraw); |
| | | |
| | | String hash = ChainService.getInstance(ChainEnum.BSC_USDT.name()).transfer(member.getAddress(), withdrawDto.getAmount()); |
| | | fundFlow.setToHash(hash); |
| | | dappFundFlowDao.updateById(fundFlow); |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("fee", withdrawDto.getFee()); |
| | | map.put("address", ChainEnum.BSC_TFC_FEE.getAddress()); |
| | | map.put("flow", feeFlow.getId()); |
| | | chainProducer.sendTfcFee(JSONObject.toJSONString(map)); |
| | | chainProducer.sendFeeDistributeMsg(fundFlow.getId()); |
| | | // Map<String, Object> map = new HashMap<>(); |
| | | // map.put("fee", withdrawDto.getFee()); |
| | | // map.put("address", ChainEnum.BSC_TFC_FEE.getAddress()); |
| | | // map.put("flow", feeFlow.getId()); |
| | | // chainProducer.sendTfcFee(JSONObject.toJSONString(map)); |
| | | } |
| | | |
| | | @Override |
| | |
| | | walletMine.setAvailableAmount(walletMine.getAvailableAmount().add(amount)); |
| | | } else { |
| | | if (amount.compareTo(walletMine.getAvailableAmount()) > 0) { |
| | | throw new FebsException("TFC Not Enough"); |
| | | throw new FebsException("DMD Not Enough"); |
| | | } |
| | | walletMine.setTotalAmount(walletMine.getTotalAmount().subtract(amount)); |
| | | walletMine.setAvailableAmount(walletMine.getAvailableAmount().subtract(amount)); |