| | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * @author |
| | | * @author |
| | | * @date 2022-03-24 |
| | | **/ |
| | | @Slf4j |
| | |
| | | |
| | | @Override |
| | | public Map<String, Object> findTotalInComeAndList() { |
| | | List<DappMemberEntity> addresses = dappMemberDao.selectList(null); |
| | | DappMemberEntity mineAddress = dappMemberDao.selectByAddress(ChainEnum.BSC_TFC.getAddress(), null); |
| | | BigDecimal coinCnt = dappMemberDao.selectAllBalance("normal"); |
| | | // List<DappMemberEntity> addresses = dappMemberDao.selectList(null); |
| | | // DappMemberEntity mineAddress = dappMemberDao.selectByAddress(ChainEnum.BSC_TFC.getAddress(), null); |
| | | // BigDecimal coinCnt = dappMemberDao.selectAllBalance("normal"); |
| | | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("total", mineAddress.getBalance()); |
| | | result.put("addreessCnt", addresses.size()); |
| | | result.put("coinCnt", coinCnt); |
| | | result.put("sourceTFC", ChainService.getInstance(ChainEnum.BSC_TFC.name()).balanceOf(ChainEnum.BSC_TFC_SOURCE.getAddress())); |
| | | result.put("sourceUSDT", ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(ChainEnum.BSC_USDT_SOURCE.getAddress())); |
| | | List<DappIdoAssetsEntity> hasAssets = dappIdoAssetsDao.selectListHasAssets(); |
| | | if (CollUtil.isNotEmpty(hasAssets)) { |
| | | result.put("buyCnt", hasAssets.size()); |
| | | } else { |
| | | result.put("buyCnt", 0); |
| | | } |
| | | // result.put("addreessCnt", addresses.size()); |
| | | // result.put("coinCnt", coinCnt); |
| | | // result.put("sourceTFC", ChainService.getInstance(ChainEnum.BSC_TFC.name()).balanceOf(ChainEnum.BSC_TFC_SOURCE.getAddress())); |
| | | // result.put("sourceUSDT", ChainService.getInstance(ChainEnum.BSC_USDT.name()).balanceOf(ChainEnum.BSC_USDT_SOURCE.getAddress())); |
| | | return result; |
| | | } |
| | | |
| | |
| | | parents = new ArrayList<>(); |
| | | } else { |
| | | List<String> inviteIds = StrUtil.split(member.getRefererId(), ','); |
| | | parents = dappMemberDao.selectParentsList(inviteIds, 6);; |
| | | parents = dappMemberDao.selectParentsList(inviteIds, 6); |
| | | ; |
| | | } |
| | | |
| | | DataDictionaryCustom miniHoldCoin = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(AppContants.DIC_TYPE_SYSTEM_SETTING, AppContants.DIC_VALUE_MINI_HOLD_COIN_LIMIT); |
| | |
| | | |
| | | Object o = redisUtils.get(AppContants.REDIS_KEY_TRANSFER_POOL_VOL); |
| | | if (o == null) { |
| | | RedisTransferPoolVo transferPool= new RedisTransferPoolVo(); |
| | | RedisTransferPoolVo transferPool = new RedisTransferPoolVo(); |
| | | BigDecimal total = basicVol.multiply(volProp.divide(BigDecimal.valueOf(100), 4, RoundingMode.HALF_UP)); |
| | | transferPool.setTodayVol(total); |
| | | transferPool.setTodayProp(volProp); |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void idoBuy(DappMemberEntity member, BigDecimal amount) { |
| | | DappMemberEntity parent = dappMemberDao.selectMemberInfoByInviteId(member.getRefererId()); |
| | | |
| | | int box = 0; |
| | | Object parentRecommend = redisUtils.hget(AppContants.IDO_MEMBER_RECOMMEND_CNT, parent.getAddress()); |
| | | if (parentRecommend == null) { |
| | | redisUtils.hset(AppContants.IDO_MEMBER_RECOMMEND_CNT, parent.getAddress(), 1); |
| | | } else { |
| | | int i = (int) parentRecommend; |
| | | |
| | | // 如果超过10个,则新增一个盲盒,并重置推荐人数 |
| | | if (++i == 10) { |
| | | box = 1; |
| | | redisUtils.hset(AppContants.IDO_MEMBER_RECOMMEND_CNT, parent.getAddress(), 1); |
| | | } else { |
| | | redisUtils.hset(AppContants.IDO_MEMBER_RECOMMEND_CNT, parent.getAddress(), i); |
| | | } |
| | | } |
| | | |
| | | if (box > 0) { |
| | | DappFundFlowEntity boxFundFlow = new DappFundFlowEntity(parent.getId(), new BigDecimal(box), 5, 2, BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(boxFundFlow); |
| | | } |
| | | |
| | | DappIdoAssetsEntity idoAssets = dappIdoAssetsDao.selectByMemberId(member.getId()); |
| | | boolean isFirst = false; |
| | | if (idoAssets.getCoinAmount().compareTo(BigDecimal.ZERO) == 0) { |
| | | isFirst = true; |
| | | } |
| | | |
| | | BigDecimal count = amount.divide(new BigDecimal(50), 0, RoundingMode.HALF_UP); |
| | | BigDecimal coinAmount = new BigDecimal(1000).multiply(count); |
| | | idoAssets.setBoxCnt(idoAssets.getBoxCnt() + box); |
| | | idoAssets.setCoinAmount(idoAssets.getCoinAmount().add(coinAmount)); |
| | | idoAssets.setUsdtAmount(idoAssets.getUsdtAmount().add(amount)); |
| | | dappIdoAssetsDao.updateById(idoAssets); |
| | | |
| | | DappMemberEntity parent = dappMemberDao.selectMemberInfoByInviteId(member.getRefererId()); |
| | | if (parent == null) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | int box = 0; |
| | | // 需要第一次购买,才在推荐中加1 |
| | | if (isFirst) { |
| | | Object parentRecommend = redisUtils.hget(AppContants.IDO_MEMBER_RECOMMEND_CNT, parent.getAddress()); |
| | | if (parentRecommend == null) { |
| | | redisUtils.hset(AppContants.IDO_MEMBER_RECOMMEND_CNT, parent.getAddress(), 1); |
| | | } else { |
| | | int i = (int) parentRecommend; |
| | | |
| | | // 如果超过10个,则新增一个盲盒,并重置推荐人数 |
| | | if (++i == 10) { |
| | | box = 1; |
| | | redisUtils.hset(AppContants.IDO_MEMBER_RECOMMEND_CNT, parent.getAddress(), 0); |
| | | } else { |
| | | redisUtils.hset(AppContants.IDO_MEMBER_RECOMMEND_CNT, parent.getAddress(), i); |
| | | } |
| | | } |
| | | |
| | | if (box > 0) { |
| | | DappFundFlowEntity boxFundFlow = new DappFundFlowEntity(parent.getId(), new BigDecimal(box), 5, 2, BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(boxFundFlow); |
| | | } |
| | | } |
| | | |
| | | BigDecimal returnCoin = coinAmount.multiply(new BigDecimal(5).divide(new BigDecimal(100), 2, RoundingMode.UP)); |
| | | DappIdoAssetsEntity parentIdoAssets = dappIdoAssetsDao.selectByMemberId(parent.getId()); |
| | | parentIdoAssets.setBoxCnt(parentIdoAssets.getBoxCnt() + box); |
| | | parentIdoAssets.setCoinAmount(parentIdoAssets.getCoinAmount().add(returnCoin)); |
| | | dappIdoAssetsDao.updateById(parentIdoAssets); |
| | | |
| | | DappFundFlowEntity returnFundFlow = new DappFundFlowEntity(parent.getId(), returnCoin, 4, 2, BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(returnFundFlow); |
| | | } |
| | | } |