From f0922bc416fad3aa6121ffdbdd217bffb94f518f Mon Sep 17 00:00:00 2001 From: KKSU <15274802129@163.com> Date: Mon, 08 Jul 2024 15:11:07 +0800 Subject: [PATCH] 逻辑 --- src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java | 82 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 80 insertions(+), 2 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java index cc47317..4c7f388 100644 --- a/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java +++ b/src/main/java/cc/mrbird/febs/dapp/service/impl/DappWalletServiceImpl.java @@ -106,6 +106,11 @@ DataDictionaryEnum.BUCAHNG_CHI.getCode() ).getValue()); + walletInfo.setJilichi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( + DataDictionaryEnum.JILI_CHI.getType(), + DataDictionaryEnum.JILI_CHI.getCode() + ).getValue()); + return walletInfo; } @@ -235,6 +240,15 @@ public void withdraw(WithdrawDto withdrawDto) { DappMemberEntity member = LoginUserUtil.getAppUser(); + DappMemberEntity memberEntity = dappMemberDao.selectById(member.getId()); + BigDecimal usdtBalance = memberEntity.getUsdtBalance(); + if(BigDecimal.ZERO.compareTo(usdtBalance) >= 0){ + throw new FebsException("额度不足"); + } + if(withdrawDto.getAmount().compareTo(usdtBalance) > 0){ + throw new FebsException("额度不足"); + } + List<MemberCoinWithdrawEntity> memberCoinWithdrawEntities = memberCoinWithdrawDao.selectListByDate(member.getId(),new Date()); if(CollUtil.isNotEmpty(memberCoinWithdrawEntities)){ throw new FebsException("今日已提现"); @@ -253,6 +267,9 @@ BigDecimal feeAmount = withdrawDto.getAmount().multiply(withdrawPercent).setScale(2, BigDecimal.ROUND_DOWN); updateWalletCoinWithLock(withdrawDto.getAmount(), member.getId(), 2); + + memberEntity.setUsdtBalance(usdtBalance.subtract(withdrawDto.getAmount()).setScale(2,BigDecimal.ROUND_DOWN)); + dappMemberDao.updateById(memberEntity); DappFundFlowEntity fundFlow = new DappFundFlowEntity( member.getId(), @@ -393,6 +410,14 @@ throw new FebsException("功能升级中"); } + DataDictionaryCustom startSymbolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( + DataDictionaryEnum.START_SYMBOL.getType(), + DataDictionaryEnum.START_SYMBOL.getCode() + ); + if("STOP".equals(startSymbolDic.getValue())){ + throw new FebsException("贡献暂未开启"); + } + BigDecimal amount = transferDto.getAmount(); if(BigDecimal.ZERO.compareTo(amount) >= 0){ throw new FebsException("请输入正确的存储数量"); @@ -406,7 +431,7 @@ throw new FebsException("存储数量必须是"+bigDecimal+"的整数倍"); } - DappStorage dappStorage = dappStorageMapper.selectAmountByAmountDesc(0, 1); + DappStorage dappStorage = dappStorageMapper.selectAmountByAmountDesc(member.getId(),0, 1); if(ObjectUtil.isNotEmpty(dappStorage)){ if(amount.compareTo(dappStorage.getAmount()) < 0){ throw new FebsException("存储数量必须大于:"+dappStorage.getAmount()); @@ -678,7 +703,7 @@ @Override public List<ApiStorageInfoVo> storageIndex() { List<ApiStorageInfoVo> apiStorageInfoVos = new ArrayList<>(); - List<DappStorage> dappStorages = dappStorageMapper.selectByAmountDesc(DateUtil.offsetHour(new Date(), -1), 0, 10); + List<DappStorage> dappStorages = dappStorageMapper.selectSumByAmountDesc(DateUtil.offsetHour(new Date(), -1), 0, 10); if(CollUtil.isNotEmpty(dappStorages)){ for(DappStorage dappStorage : dappStorages){ ApiStorageInfoVo apiStorageInfoVo = new ApiStorageInfoVo(); @@ -744,6 +769,59 @@ return apiStorageInfoVos; } + @Override + public List<ApiDirectInfoVo> directNumIndex() { + List<ApiDirectInfoVo> apiDirectInfoVos = new ArrayList<>(); + /** + * 存放直推人数<上级的memberId,直推人数> + */ + HashMap<Long, BigDecimal> map = new HashMap<>(); + + List<DappMemberEntity> dappMemberEntityList = dappMemberDao.selectListByDate(new Date()); + if(CollUtil.isNotEmpty(dappMemberEntityList)){ + for(DappMemberEntity member : dappMemberEntityList){ + if(StrUtil.isEmpty(member.getRefererId())){ + continue; + } + DappMemberEntity memberRef = dappMemberDao.selectMemberInfoByInviteId(member.getRefererId()); + if(ObjectUtil.isEmpty(memberRef)){ + continue; + } + Long id = memberRef.getId(); + if(map.containsKey(id)){ + BigDecimal bigDecimal = map.get(id); + BigDecimal add = bigDecimal.add(new BigDecimal("1")); + map.put(id,add); + }else{ + map.put(id,new BigDecimal("1")); + } + } + } + /** + * 获取这个map的直推人数前十,分发奖励 + */ + if(!map.isEmpty()){ + // 使用Stream API按照BigDecimal从大到小排序 + List<Map.Entry<Long, BigDecimal>> topTenEntries = map.entrySet().stream() + .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())) + .limit(10) + .collect(Collectors.toList()); + for (Map.Entry<Long, BigDecimal> entry : topTenEntries) { + + Long memberId = entry.getKey(); + BigDecimal directCnt = entry.getValue(); + ApiDirectInfoVo apiDirectInfoVo = new ApiDirectInfoVo(); + apiDirectInfoVo.setAddress(dappMemberDao.selectById(memberId).getAddress()); + apiDirectInfoVo.setAmount(directCnt); + + apiDirectInfoVos.add(apiDirectInfoVo); + } + } + + + return apiDirectInfoVos; + } + public MemberNodeVo buildTeamMatrix(DbMemberNode dbMemberNode) { Long id = dbMemberNode.getId(); -- Gitblit v1.9.1