| | |
| | | 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); |
| | |
| | | dappFundFlowEntity.setStatus(recordInPageDto.getType()); |
| | | } |
| | | dappFundFlowEntity.setMemberId(member.getId()); |
| | | IPage<DappFundFlowEntity> records = dappFundFlowDao.selectInPage(page, dappFundFlowEntity); |
| | | 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())).setScale(2,BigDecimal.ROUND_DOWN); |
| | | BigDecimal minAmount = new BigDecimal(redisUtils.getString(DataDicEnum.GFA_BUY_MIN_AMOUNT.getValue())); |
| | | BigDecimal maxAmount = new BigDecimal(redisUtils.getString(DataDicEnum.GFA_BUY_MAX_AMOUNT.getValue())).setScale(2,BigDecimal.ROUND_DOWN); |
| | | BigDecimal gfaDays = new BigDecimal(redisUtils.getString(DataDicEnum.GFA_DAYS.getValue())).setScale(2,BigDecimal.ROUND_DOWN); |
| | | |
| | | minAmount = minAmount.divide(transferDto.getPrice(),2,BigDecimal.ROUND_DOWN); |
| | | maxAmount = maxAmount.divide(transferDto.getPrice(),2,BigDecimal.ROUND_DOWN);; |
| | | if (transferDto.getId() == null) { |
| | | if (DappFundFlowEntity.TYPE_BUY == transferDto.getType()) { |
| | | //系统开始标识 |
| | |
| | | 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("暂停质押"); |
| | |
| | | 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()); |
| | | } |
| | |
| | | } |
| | | 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(); |
| | | } |