| | |
| | | package cc.mrbird.febs; |
| | | |
| | | import cc.mrbird.febs.common.contants.AppContants; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.dto.BatchTransferDto; |
| | | import cc.mrbird.febs.dapp.entity.DappMemberEntity; |
| | | import cc.mrbird.febs.dapp.entity.DappStorage; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum; |
| | | import cc.mrbird.febs.dapp.enumerate.MemberLevelEnum; |
| | | import cc.mrbird.febs.dapp.mapper.DappMemberDao; |
| | | import cc.mrbird.febs.dapp.mapper.DappStorageMapper; |
| | | import cc.mrbird.febs.dapp.enumerate.MoneyFlowEnum; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | @Resource |
| | | private DappStorageMapper dappStorageMapper; |
| | | // |
| | | // @Resource |
| | | // private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | @Resource |
| | | private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | // |
| | | @Resource |
| | | private DappMemberDao dappMemberDao; |
| | | @Resource |
| | | private DappFundFlowDao dappFundFlowDao; |
| | | @Resource |
| | | private DappWalletCoinDao dappWalletCoinDao; |
| | | |
| | | |
| | | @Test |
| | | public void profitDailyJobOne() { |
| | | |
| | | Date date = new Date(); |
| | | DappStorage dappStorageLast = dappStorageMapper.selectOneByCreateTimeDesc(0, 1); |
| | | DateTime dateTime1 = DateUtil.offsetHour(dappStorageLast.getCreateTime(), 24); |
| | | int compare = DateUtil.compare(dateTime1, date); |
| | | if(compare > 0){ |
| | | System.out.println("时间未到"); |
| | | } |
| | | } |
| | | |
| | | @Test |
| | | public void returnDate() {//注册 |
| | | |
| | | QueryWrapper<DappFundFlowEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("type", MoneyFlowEnum.BU_CHANG_PERK.getValue()); |
| | | List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectList(objectQueryWrapper); |
| | | if(CollUtil.isNotEmpty(dappFundFlowEntities)){ |
| | | for(DappFundFlowEntity dappFundFlowEntity : dappFundFlowEntities){ |
| | | BigDecimal amount = dappFundFlowEntity.getAmount(); |
| | | Long memberId = dappFundFlowEntity.getMemberId(); |
| | | |
| | | DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(memberId); |
| | | BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount(); |
| | | BigDecimal totalAmount = dappWalletCoinEntity.getTotalAmount(); |
| | | if(dappWalletCoinEntity.getAvailableAmount().compareTo(amount) >= 0){ |
| | | dappWalletCoinEntity.setAvailableAmount(availableAmount.subtract(amount)); |
| | | dappWalletCoinEntity.setTotalAmount(totalAmount.subtract(amount)); |
| | | dappWalletCoinDao.updateWithLock(dappWalletCoinEntity); |
| | | } |
| | | dappFundFlowDao.deleteById(dappFundFlowEntity); |
| | | } |
| | | } |
| | | |
| | | List<DappStorage> dappStorages = dappStorageMapper.selectList(null); |
| | | BigDecimal reduce = dappStorages.stream().map(DappStorage::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal bigDecimal = reduce.multiply(new BigDecimal(AppContants.DAO_BU_CHANG_PERCENT)).setScale(2, BigDecimal.ROUND_DOWN); |
| | | dataDictionaryCustomMapper.updateDicValueByTypeAndCode( |
| | | DataDictionaryEnum.BUCAHNG_CHI.getType(), |
| | | DataDictionaryEnum.BUCAHNG_CHI.getCode(),bigDecimal.toString() |
| | | ); |
| | | |
| | | } |
| | | |
| | | @Test |
| | | public void withdraw() {//注册 |
| | | |
| | | ArrayList<BatchTransferDto> objects = new ArrayList<>(); |
| | | BatchTransferDto batchTransferDto = new BatchTransferDto("0x677696d67c2b9e87aecf60bc17b116f5b25e2927",new BigDecimal("38.8")); |
| | | BatchTransferDto batchTransferDto = new BatchTransferDto("0x4b1e48d0c2fb8a80afa2ac1f8028fd25004d59b1",new BigDecimal("282.6")); |
| | | objects.add(batchTransferDto); |
| | | |
| | | BatchTransferDto batchTransferDtoFee = new BatchTransferDto("0x3caf594503573341ae7a83fc6daed9bd5276b6bd",new BigDecimal("1.2")); |
| | | objects.add(batchTransferDtoFee); |
| | | BatchTransferDto batchTransferDtoFee1 = new BatchTransferDto("0xe457e3e1413750c7810681ca5e080951b819d91c",new BigDecimal("423")); |
| | | objects.add(batchTransferDtoFee1); |
| | | |
| | | BatchTransferDto batchTransferDtoFee2 = new BatchTransferDto("0x96d21a1aadf6156be9a79c5b18aaf9373cdbc8c2",new BigDecimal("295")); |
| | | objects.add(batchTransferDtoFee2); |
| | | |
| | | BatchTransferDto batchTransferDtoFee3 = new BatchTransferDto("0x86bdeb5d597aeffedc80f6b63c410c71da606b8a",new BigDecimal("149")); |
| | | objects.add(batchTransferDtoFee3); |
| | | ChainService.getInstance(ChainEnum.BSC_USDT.name()).transferList(objects); |
| | | } |
| | | // |