| | |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | walletInfo.setTzCoin(tzCoin); |
| | | |
| | | BigDecimal hdCoinGeren = dappFundFlowDao.selectAmountTotalByTypeAndMemberIdAndDate(member.getId(), FlowTypeEnum.HUA_DIAN_GEREN.getValue(),null); |
| | | BigDecimal hdCoinTuandui = dappFundFlowDao.selectAmountTotalByTypeAndMemberIdAndDate(member.getId(), FlowTypeEnum.HUA_DIAN_TUANDUI.getValue(),null); |
| | | walletInfo.setHdCoin(hdCoinGeren.add(hdCoinTuandui)); |
| | | BigDecimal hdCoinTuandui = dappFundFlowDao.selectAmountTotalByTypeAndMemberIdAndDate(member.getId(), FlowTypeEnum.HUA_DIAN_TUANDUI_DAIBI.getValue(),null); |
| | | BigDecimal hdCoinTuanduiUSDT = dappFundFlowDao.selectAmountTotalByTypeAndMemberIdAndDate(member.getId(), FlowTypeEnum.HUA_DIAN_TUANDUI_USDT.getValue(),null); |
| | | walletInfo.setHdCoin(hdCoinGeren.add(hdCoinTuandui).add(hdCoinTuanduiUSDT)); |
| | | |
| | | BigDecimal zyTotal = dappFundFlowDao.selectAmountTotalByTypeAndMemberIdAndDate(member.getId(), FlowTypeEnum.ZHI_YA.getValue(),null).negate(); |
| | | walletInfo.setZyTotal(zyTotal); |
| | |
| | | if (recordInPageDto.getType() != null && recordInPageDto.getType() != 0) { |
| | | dappFundFlowEntity.setStatus(recordInPageDto.getType()); |
| | | } |
| | | if (recordInPageDto.getState() != null && recordInPageDto.getState() != 0) { |
| | | dappFundFlowEntity.setType(recordInPageDto.getState()); |
| | | } |
| | | dappFundFlowEntity.setMemberId(member.getId()); |
| | | IPage<DappFundFlowEntity> records = dappFundFlowDao.selectInPages(page, dappFundFlowEntity); |
| | | return records.getRecords(); |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long transfer(TransferDto transferDto) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | // QueryWrapper<DappFundFlowEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | // objectQueryWrapper.eq("type" ,FlowTypeEnum.ZHI_YA.getValue()); |
| | | // objectQueryWrapper.eq("status" ,DappFundFlowEntity.WITHDRAW_STATUS_AGREE); |
| | | // objectQueryWrapper.eq("member_id" ,member.getId()); |
| | | // List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectList(objectQueryWrapper); |
| | | |
| | | List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectAmountTotalByTypeAndMemberIdAndDateAndState( |
| | | member.getId(), |
| | | FlowTypeEnum.ZHI_YA.getValue(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | new Date()); |
| | | BigDecimal zhiyaAmount = new BigDecimal(redisUtils.getString(DataDicEnum.MEMBER_ZHIYA_AMOUNT.getValue())); |
| | | |
| | | Integer zhiyaTime = Integer.parseInt(redisUtils.getString(DataDicEnum.MEMBER_ZHIYA_TIME.getValue())); |
| | | if(CollUtil.isNotEmpty(dappFundFlowEntities)){ |
| | | if(dappFundFlowEntities.size() >= zhiyaTime){ |
| | | throw new FebsException("今日暂停质押"); |
| | | } |
| | | BigDecimal teamAchieveMemberSum = dappFundFlowEntities.stream().map(DappFundFlowEntity::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add).negate(); |
| | | if(zhiyaAmount.compareTo(teamAchieveMemberSum.add(transferDto.getAmount())) < 0){ |
| | | throw new FebsException("今日最多质押"+zhiyaAmount.subtract(teamAchieveMemberSum).setScale(4,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | } |
| | | |
| | | |
| | | String hasStart = redisUtils.getString(DataDicEnum.SYSTEM_START_FLAG.getValue()); |
| | | BigDecimal minAmount = new BigDecimal(redisUtils.getString(DataDicEnum.GFA_BUY_MIN_AMOUNT.getValue())); |
| | |
| | | if (transferDto.getAmount().compareTo(minAmount) < 0) { |
| | | throw new FebsException("超过购买限制"); |
| | | } |
| | | if (BigDecimal.ZERO.compareTo(gfaDays) >= 0) { |
| | | throw new FebsException("今日暂停质押"); |
| | | } |
| | | if (transferDto.getAmount().compareTo(gfaDays) > 0) { |
| | | throw new FebsException("今日最多质押"+gfaDays); |
| | | // if (BigDecimal.ZERO.compareTo(gfaDays) >= 0) { |
| | | // throw new FebsException("今日暂停质押"); |
| | | // } |
| | | if (transferDto.getAmount().compareTo(zhiyaAmount) > 0) { |
| | | throw new FebsException("今日最多质押"+zhiyaAmount); |
| | | } |
| | | } else { |
| | | throw new FebsException("暂停质押"); |
| | |
| | | //新增一条用户质押记录 |
| | | DappAchieve dappAchieve = new DappAchieve(); |
| | | dappAchieve.setMemberId(memberId); |
| | | dappAchieve.setPrice(transferDto.getPrice()); |
| | | dappAchieve.setAmount(amount); |
| | | BigDecimal achieveReleasePercent = new BigDecimal("0.01").multiply( |
| | | new BigDecimal(redisUtils.getString(DataDicEnum.GFA_ACHIEVE_RELEASE.getValue())).setScale(2,BigDecimal.ROUND_DOWN) |
| | |
| | | asyncCjService.insertTeamPerk(flow.getId(), dappAchieve.getId()); |
| | | |
| | | //发送一个延时队列消息。24小时之后产生第一次的质押产出 |
| | | chainProducer.sendZhiYaDelayMsg(dappAchieve.getId(), 24 * 60 * 60 * 1000L); |
| | | // chainProducer.sendZhiYaDelayMsg(dappAchieve.getId(), 24 * 60 * 60 * 1000L); |
| | | } else { |
| | | dappFundFlowDao.deleteById(transferDto.getId()); |
| | | } |
| | |
| | | @Override |
| | | public IPage<DappAchieve> dappAchieveInPage(DappAchieve dappAchieve, QueryRequest request) { |
| | | Page<DappAchieve> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return dappAchieveMapper.selectInPage(page, dappAchieve); |
| | | IPage<DappAchieve> dappAchieveIPage = dappAchieveMapper.selectInPage(page, dappAchieve); |
| | | List<DappAchieve> records = dappAchieveIPage.getRecords(); |
| | | if(CollUtil.isNotEmpty(records)){ |
| | | for(DappAchieve dappAchieve1 : records){ |
| | | dappAchieve1.setUsdtAmount(dappAchieve1.getAmount().multiply(dappAchieve1.getPrice()).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | } |
| | | return dappAchieveIPage; |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | flowType = FlowTypeEnum.DAI_BI_OUT.getValue(); |
| | | flowDes = FlowTypeEnum.DAI_BI_OUT.getDescrition(); |
| | | |
| | | dappMemberEntity.setBalance(balance.subtract(amount).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | dappMemberDao.updateBalanceWithVersion(dappMemberEntity); |
| | | }else{ |
| | | if(new BigDecimal("100").compareTo(amount) > 0){ |
| | | throw new FebsException("最小数量为100"); |
| | |
| | | } |
| | | flowType = FlowTypeEnum.USDT_OUT.getValue(); |
| | | flowDes = FlowTypeEnum.USDT_OUT.getDescrition(); |
| | | |
| | | dappMemberEntity.setUsdtBalance(usdtBalance.subtract(amount).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | dappMemberDao.updateUsdtBalanceWithVersion(dappMemberEntity); |
| | | } |
| | | |
| | | DappFundFlowEntity fundFlowTuiJian = new DappFundFlowEntity( |
| | |
| | | dappMemberEntity.getAddress()); |
| | | dappFundFlowDao.insert(fundFlowTuiJian); |
| | | |
| | | dappMemberEntity.setBalance(balance.subtract(amount).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | dappMemberEntity.setUsdtBalance(usdtBalance.subtract(amount).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | dappMemberDao.updateBalanceAndUsdtBalanceWithVersion(dappMemberEntity); |
| | | // dappMemberEntity.setBalance(balance.subtract(amount).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | // dappMemberEntity.setUsdtBalance(usdtBalance.subtract(amount).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | // dappMemberDao.updateBalanceAndUsdtBalanceWithVersion(dappMemberEntity); |
| | | |
| | | return new FebsResponse().success(); |
| | | } |