package cc.mrbird.febs.dapp.utils; import cc.mrbird.febs.common.utils.SpringContextUtil; import cc.mrbird.febs.dapp.entity.DappFundFlowEntity; import cc.mrbird.febs.dapp.entity.DappOnlineTransferEntity; import cc.mrbird.febs.dapp.entity.DappTransferRecordEntity; import cc.mrbird.febs.dapp.mapper.DappFundFlowDao; import cc.mrbird.febs.dapp.mapper.DappOnlineTransferDao; import cc.mrbird.febs.dapp.mapper.DappTransferRecordDao; import java.math.BigDecimal; public class OnlineTransferUtil { private static final DappOnlineTransferDao dappOnlineTransferDao = SpringContextUtil.getBean(DappOnlineTransferDao.class); private static final DappTransferRecordDao dappTransferRecordDao = SpringContextUtil.getBean(DappTransferRecordDao.class); public static void addTransfer(String address, BigDecimal amount, Integer type, Integer targetType, String fromType, String symbol, String batchNo) { addTransfer(address, amount, type, targetType, fromType, symbol, "BSC", batchNo); } public static void addTransfer(String address, BigDecimal amount, Integer type, Integer targetType, String fromType, String symbol, String chain, String batchNo) { DappOnlineTransferEntity transfer = new DappOnlineTransferEntity(); transfer.setAddress(address); transfer.setAmount(amount); transfer.setType(type); transfer.setTargetType(targetType); transfer.setFromType(fromType); transfer.setSymbol(symbol); transfer.setChain(chain); transfer.setBatchNo(batchNo); transfer.setHasFinish(2); dappOnlineTransferDao.insert(transfer); } public static void addTransferRecord(String fromAddress, String toAddress, BigDecimal amount, String hash, String chainType, String sourceFlag, String symbol) { DappTransferRecordEntity record = dappTransferRecordDao.selectByHash(hash); if (record != null) { return; } record = new DappTransferRecordEntity(); record.setFromAddress(fromAddress); record.setToAddress(toAddress); record.setAmount(amount); record.setHash(hash); record.setChainType(chainType); record.setSourceFlag(sourceFlag); record.setSymbol(symbol); dappTransferRecordDao.insert(record); } public static void addTransferRecord(String fromAddress, String toAddress, BigDecimal amount, String hash, String sourceFlag, String symbol) { addTransferRecord(fromAddress, toAddress, amount, hash, "BSC", sourceFlag, symbol); } }