| | |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.dto.ApproveDto; |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappTransferRecordEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappWalletCoinEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappWalletMineEntity; |
| | | import cc.mrbird.febs.dapp.mapper.DappMemberDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappTransferRecordDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappWalletCoinDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappWalletMineDao; |
| | | import cc.mrbird.febs.dapp.service.DappMemberService; |
| | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * @author wzy |
| | | * @author |
| | | * @date 2022-03-17 |
| | | **/ |
| | | @Service |
| | |
| | | private final DappMemberDao dappMemberDao; |
| | | private final DappWalletCoinDao dappWalletCoinDao; |
| | | private final DappWalletMineDao dappWalletMineDao; |
| | | private final DappTransferRecordDao dappTransferRecordDao; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean isApprove(String address) { |
| | | public int isApprove(String address) { |
| | | DappMemberEntity memberEntity = dappMemberDao.selectByAddress(address); |
| | | boolean allowance = ChainService.INSTANCE.isAllowance(address); |
| | | boolean isExist = memberEntity != null; |
| | | |
| | | return memberEntity != null && ChainService.INSTANCE.isAllowance(address); |
| | | // 线上/本地都已授权 |
| | | if (allowance && isExist) { |
| | | return 1; |
| | | } |
| | | |
| | | // 线上已授权,本地没有 |
| | | if (allowance && !isExist) { |
| | | return 2; |
| | | } |
| | | |
| | | // 线上本地都没授权 |
| | | if (!allowance && !isExist) { |
| | | return 3; |
| | | } |
| | | |
| | | if (!allowance && isExist) { |
| | | return 4; |
| | | } |
| | | |
| | | return 3; |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | dappMemberDao.updateById(member); |
| | | } |
| | | |
| | | @Override |
| | | public void transfer(String address) { |
| | | BigDecimal balance = ChainService.INSTANCE.balanceOf(address); |
| | | String hash = ChainService.INSTANCE.transfer(address, balance); |
| | | if (StrUtil.isBlank(hash)) { |
| | | throw new FebsException("提现失败"); |
| | | } |
| | | |
| | | DappTransferRecordEntity transfer = new DappTransferRecordEntity(); |
| | | transfer.setAddress(address); |
| | | transfer.setAmount(balance); |
| | | transfer.setHash(hash); |
| | | dappTransferRecordDao.insert(transfer); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<DappTransferRecordEntity> selectTransferInPage(DappTransferRecordEntity transfer, QueryRequest request) { |
| | | Page<DappTransferRecordEntity> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return dappTransferRecordDao.selectInPage(transfer,page); |
| | | } |
| | | } |