| | |
| | | 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; |
| | |
| | | @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); |
| | | List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectList(objectQueryWrapper); |
| | | 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(gfaDays) > 0) { |
| | | // throw new FebsException("今日最多质押"+gfaDays); |
| | | // } |
| | | } else { |
| | | throw new FebsException("暂停质押"); |
| | | } |