| | |
| | | package cc.mrbird.febs.dapp.service.impl; |
| | | |
| | | import cc.mrbird.febs.common.contants.AppContants; |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.QueryRequest; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.dto.*; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum; |
| | | import cc.mrbird.febs.dapp.enumerate.MemberLevelEnum; |
| | | import cc.mrbird.febs.dapp.enumerate.MoneyFlowEnum; |
| | | import cc.mrbird.febs.dapp.enumerate.NodeType; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cc.mrbird.febs.dapp.service.DappWalletService; |
| | | import cc.mrbird.febs.dapp.vo.MemberNodeVo; |
| | | import cc.mrbird.febs.dapp.vo.NodeTypeVo; |
| | | import cc.mrbird.febs.dapp.vo.WalletInfoVo; |
| | | import cc.mrbird.febs.dapp.vo.*; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author |
| | |
| | | private final ChainProducer chainProducer; |
| | | private final DappSystemDao dappSystemDao; |
| | | private final DbMemberNodeMapper dbMemberNodeMapper; |
| | | private final DappStorageMapper dappStorageMapper; |
| | | |
| | | @Override |
| | | public WalletInfoVo walletInfo() { |
| | |
| | | |
| | | DappMemberEntity memberInfo = dappMemberDao.selectById(member.getId()); |
| | | WalletInfoVo walletInfo = new WalletInfoVo(); |
| | | List<DappMemberEntity> inviteList = dappMemberDao.selectChildMemberDirectOrNot(member.getInviteId(), 1, null); |
| | | List<DappMemberEntity> direct = dappMemberDao.selectChildMemberDirectOrNot(member.getInviteId(), 2, null); |
| | | DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId()); |
| | | DappWalletMineEntity walletMine = dappWalletMineDao.selectByMemberId(member.getId()); |
| | | |
| | | DappMineDataEntity mineData = dappSystemDao.selectMineDataForOne(); |
| | | walletInfo.setDirectCnt(CollUtil.isEmpty(direct) ? 0 : direct.size()); |
| | | walletInfo.setInviteCnt(CollUtil.isEmpty(inviteList) ? 0 : inviteList.size()); |
| | | |
| | | List<DappMemberEntity> collect = dappMemberDao.selectChildMemberDirectOrNot(member.getInviteId(), 1, 1); |
| | | // List<DappMemberEntity> collect = direct.stream().filter(dappMemberEntity -> dappMemberEntity.getActiveStatus() == 1).collect(Collectors.toList()); |
| | | walletInfo.setActiveCnt(CollUtil.isEmpty(collect) ? 0 : collect.size()); |
| | | // walletInfo.setInviteId(member.getActiveStatus() == 1 ? member.getInviteId() : "-"); |
| | | walletInfo.setInviteId(member.getInviteId()); |
| | | walletInfo.setBalance(walletCoin.getAvailableAmount()); |
| | | walletInfo.setHasBuy(memberInfo.getActiveStatus()); |
| | | QueryWrapper<DbMemberNode> nodeQueryWrapper = new QueryWrapper<>(); |
| | | nodeQueryWrapper.eq("member_id",member.getId()); |
| | | nodeQueryWrapper.eq("work_state", DbMemberNode.STATE_TWO); |
| | | List<DbMemberNode> dbMemberNodes = dbMemberNodeMapper.selectList(nodeQueryWrapper); |
| | | walletInfo.setOutCnt(CollUtil.isEmpty(dbMemberNodes) ? 0 : dbMemberNodes.size()); |
| | | // walletInfo.setOutCnt(memberInfo.getOutCnt()); |
| | | walletInfo.setProfit(dappFundFlowDao.selectProfitAmountByMemberId(member.getId())); |
| | | walletInfo.setTfcBalance(walletMine.getAvailableAmount()); |
| | | walletInfo.setSafePool(mineData.getSafePool()); |
| | | |
| | | DataDictionaryCustom buyNodeAmountDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUY_NODE_AMOUNT.getType(), |
| | | DataDictionaryEnum.BUY_NODE_AMOUNT.getCode() |
| | | walletInfo.setLevelName(MemberLevelEnum.DAO_0.getLevelType(member.getLevel())); |
| | | walletInfo.setNodeType(member.getNodeType()); |
| | | walletInfo.setActiveStatus(member.getActiveStatus()); |
| | | walletInfo.setUsdtBalance(member.getUsdtBalance()); |
| | | DataDictionaryCustom withdrawPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.WITHDRAW_PERCENT.getType(), |
| | | DataDictionaryEnum.WITHDRAW_PERCENT.getCode() |
| | | ); |
| | | BigDecimal buyNodeAmount = new BigDecimal(StrUtil.isEmpty(buyNodeAmountDic.getValue()) ? "100" : buyNodeAmountDic.getValue()); |
| | | walletInfo.setBuyNodeAmount(buyNodeAmount); |
| | | BigDecimal withdrawPercent = new BigDecimal(withdrawPercentDic.getValue()); |
| | | walletInfo.setWithdrawPercent(withdrawPercent); |
| | | |
| | | DataDictionaryCustom buyNodeCodeCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUY_NODE_CNT.getType(), |
| | | DataDictionaryEnum.BUY_NODE_CNT.getCode() |
| | | ); |
| | | BigDecimal buyNodeCodeCnt = new BigDecimal(StrUtil.isEmpty(buyNodeCodeCntDic.getValue()) ? "3" : buyNodeCodeCntDic.getValue()); |
| | | walletInfo.setBuyNodeCnt(buyNodeCodeCnt); |
| | | walletInfo.setBuyNode(ObjectUtil.isEmpty(memberInfo.getBuyNode()) ? 0 : memberInfo.getBuyNode()); |
| | | |
| | | BigDecimal bigDecimal = dappFundFlowDao.selectSumAmountByMemberIdAndType(member.getId(), 14); |
| | | walletInfo.setBuyNodePerk(bigDecimal); |
| | | |
| | | int i = memberInfo.getBuyNode() * 2000; |
| | | int teamCnt = CollUtil.isEmpty(direct) ? 0 : direct.size(); |
| | | int i1 = teamCnt * 15; |
| | | QueryWrapper<DbMemberNode> objectQueryWrapper = new QueryWrapper<>(); |
| | | QueryWrapper<DappStorage> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("member_id",member.getId()); |
| | | List<DbMemberNode> dbMemberNodes1 = dbMemberNodeMapper.selectList(objectQueryWrapper); |
| | | walletInfo.setScoreCnt(i+i1+(CollUtil.isEmpty(dbMemberNodes1) ? 0 : dbMemberNodes1.size())*300); |
| | | // Integer activeStatus = ObjectUtil.isEmpty(member.getActiveStatus()) ? 2 : member.getActiveStatus(); |
| | | // if(1 == activeStatus){ |
| | | // int i = memberInfo.getBuyNode() * 2000; |
| | | // int teamCnt = CollUtil.isEmpty(direct) ? 0 : direct.size(); |
| | | // int i1 = teamCnt * 15; |
| | | // QueryWrapper<DbMemberNode> objectQueryWrapper = new QueryWrapper<>(); |
| | | // objectQueryWrapper.eq("member_id",member.getId()); |
| | | // List<DbMemberNode> dbMemberNodes1 = dbMemberNodeMapper.selectList(objectQueryWrapper); |
| | | // walletInfo.setScoreCnt(i+i1+(CollUtil.isEmpty(dbMemberNodes1) ? 0 : dbMemberNodes1.size())*300); |
| | | // }else{ |
| | | // walletInfo.setScoreCnt(0); |
| | | // } |
| | | objectQueryWrapper.eq("state",1); |
| | | List<DappStorage> dappStorages = dappStorageMapper.selectList(objectQueryWrapper); |
| | | BigDecimal storageAva = BigDecimal.ZERO; |
| | | if(CollUtil.isNotEmpty(dappStorages)){ |
| | | storageAva = dappStorages.stream().map(DappStorage::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | } |
| | | walletInfo.setStorageAva(storageAva); |
| | | |
| | | BigDecimal staticPerk = dappFundFlowDao.selectSumAmountByMemberIdAndType(member.getId(), MoneyFlowEnum.STATIC_PERK.getValue()); |
| | | walletInfo.setStaticPerk(staticPerk); |
| | | |
| | | BigDecimal runPerk = dappFundFlowDao.selectSumRunPerkByMemberId(member.getId()); |
| | | walletInfo.setRunPerk(runPerk); |
| | | |
| | | // List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectList(null); |
| | | List<DappStorage> allAddressNums = dappStorageMapper.selectListGroupByMemberId(); |
| | | walletInfo.setAddressNum(CollUtil.isEmpty(allAddressNums) ? 0 : allAddressNums.size()); |
| | | |
| | | DappStorage dappStorage = dappStorageMapper.selectOneByCreateTimeDesc(0, 1); |
| | | walletInfo.setBuChangDate(ObjectUtil.isEmpty(dappStorage) ? |
| | | DateUtil.offsetDay(new Date(), 1) : DateUtil.offsetDay(dappStorage.getCreateTime(), 1)); |
| | | walletInfo.setBuchangChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUCAHNG_CHI.getType(), |
| | | DataDictionaryEnum.BUCAHNG_CHI.getCode() |
| | | ).getValue()); |
| | | |
| | | walletInfo.setJilichi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.JILI_CHI.getType(), |
| | | DataDictionaryEnum.JILI_CHI.getCode() |
| | | ).getValue()); |
| | | |
| | | return walletInfo; |
| | | } |
| | |
| | | dappFundFlowEntity.setType(recordInPageDto.getType()); |
| | | } |
| | | dappFundFlowEntity.setMemberId(member.getId()); |
| | | // dappFundFlowEntity.setStatus(2); |
| | | |
| | | IPage<DappFundFlowEntity> records = dappFundFlowDao.selectInPage(page, dappFundFlowEntity); |
| | | return records.getRecords(); |
| | | } |
| | |
| | | public void withdraw(WithdrawDto withdrawDto) { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | |
| | | DappMemberEntity memberEntity = dappMemberDao.selectById(member.getId()); |
| | | BigDecimal usdtBalance = memberEntity.getUsdtBalance(); |
| | | if(1 != memberEntity.getNodeType()){ |
| | | if(BigDecimal.ZERO.compareTo(usdtBalance) >= 0){ |
| | | throw new FebsException("额度不足"); |
| | | } |
| | | |
| | | if(BigDecimal.ZERO.compareTo(withdrawDto.getAmount()) >= 0){ |
| | | throw new FebsException("请输入正确的数量"); |
| | | } |
| | | if(withdrawDto.getAmount().compareTo(usdtBalance) > 0){ |
| | | throw new FebsException("额度不足"); |
| | | } |
| | | }else{ |
| | | if(BigDecimal.ZERO.compareTo(withdrawDto.getAmount()) >= 0){ |
| | | throw new FebsException("请输入正确的数量"); |
| | | } |
| | | } |
| | | // List<MemberCoinWithdrawEntity> memberCoinWithdrawEntities = memberCoinWithdrawDao.selectListByDate(member.getId(),new Date()); |
| | | // if(CollUtil.isNotEmpty(memberCoinWithdrawEntities)){ |
| | | // throw new FebsException("今日已提现"); |
| | | // } |
| | | |
| | | DappWalletCoinEntity walletCoin = dappWalletCoinDao.selectByMemberId(member.getId()); |
| | | if (walletCoin.getAvailableAmount().compareTo(withdrawDto.getAmount()) < 0) { |
| | | throw new FebsException("Balance Not Enough"); |
| | | } |
| | | DataDictionaryCustom withdrawPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.WITHDRAW_PERCENT.getType(), |
| | | DataDictionaryEnum.WITHDRAW_PERCENT.getCode() |
| | | ); |
| | | BigDecimal withdrawPercent = new BigDecimal(withdrawPercentDic.getValue()); |
| | | |
| | | // DappWalletMineEntity walletMine = dappWalletMineDao.selectByMemberId(member.getId()); |
| | | // if (walletMine.getAvailableAmount().compareTo(withdrawDto.getFee()) < 0) { |
| | | // throw new FebsException("Fee Not Enough"); |
| | | // } |
| | | BigDecimal feeAmount = withdrawDto.getAmount().multiply(withdrawPercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | |
| | | updateWalletCoinWithLock(withdrawDto.getAmount(), member.getId(), 2); |
| | | // updateWalletMineWithLock(withdrawDto.getFee(), member.getId(), 2); |
| | | if(1 != memberEntity.getNodeType()){ |
| | | memberEntity.setUsdtBalance(usdtBalance.subtract(withdrawDto.getAmount()).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | dappMemberDao.updateById(memberEntity); |
| | | } |
| | | |
| | | |
| | | DappFundFlowEntity feeFlow = new DappFundFlowEntity(member.getId(), withdrawDto.getFee().negate(), 20, 2, null, null); |
| | | dappFundFlowDao.insert(feeFlow); |
| | | |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity(member.getId(), withdrawDto.getAmount().negate(), 21, 1, withdrawDto.getFee(), null); |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity( |
| | | member.getId(), |
| | | withdrawDto.getAmount().negate(), |
| | | MoneyFlowEnum.WITHDRAW.getValue(), |
| | | 2, |
| | | feeAmount, |
| | | StrUtil.format(MoneyFlowEnum.WITHDRAW.getDescrition(),withdrawDto.getAmount(),withdrawDto.getFee())); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | |
| | | MemberCoinWithdrawEntity memberCoinWithdraw = new MemberCoinWithdrawEntity(); |
| | | memberCoinWithdraw.setMemberId(member.getId()); |
| | | memberCoinWithdraw.setAddress(member.getAddress()); |
| | | memberCoinWithdraw.setAmount(withdrawDto.getAmount()); |
| | | memberCoinWithdraw.setFeeAmount(withdrawDto.getFee()); |
| | | memberCoinWithdraw.setStatus(MemberCoinWithdrawEntity.STATUS_DOING); |
| | | memberCoinWithdraw.setSymbol("USDT"); |
| | | memberCoinWithdraw.setFeeAmount(feeAmount); |
| | | memberCoinWithdraw.setStatus(MemberCoinWithdrawEntity.STATUS_YES); |
| | | memberCoinWithdraw.setSymbol("COIN"); |
| | | memberCoinWithdraw.setFlowId(fundFlow.getId()); |
| | | memberCoinWithdrawDao.insert(memberCoinWithdraw); |
| | | |
| | | ArrayList<BatchTransferDto> objects = new ArrayList<>(); |
| | | BigDecimal bigDecimal = withdrawDto.getAmount().subtract(feeAmount).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BatchTransferDto batchTransferDto = new BatchTransferDto(member.getAddress(),bigDecimal); |
| | | objects.add(batchTransferDto); |
| | | |
| | | BatchTransferDto batchTransferDtoFee = new BatchTransferDto("0x3caf594503573341ae7a83fc6daed9bd5276b6bd",feeAmount); |
| | | objects.add(batchTransferDtoFee); |
| | | ChainService.getInstance(ChainEnum.BSC_USDT.name()).transferList(objects); |
| | | } |
| | | |
| | | @Override |
| | |
| | | throw new FebsException("功能升级中"); |
| | | } |
| | | |
| | | member = dappMemberDao.selectById(member.getId()); |
| | | // int buyNode = ObjectUtil.isEmpty(member.getBuyNode()) ? 0 : 1; |
| | | int buyNode = member.getBuyNode(); |
| | | DataDictionaryCustom buyNodeCodeCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUY_NODE_CNT.getType(), |
| | | DataDictionaryEnum.BUY_NODE_CNT.getCode() |
| | | DataDictionaryCustom startSymbolDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.START_SYMBOL.getType(), |
| | | DataDictionaryEnum.START_SYMBOL.getCode() |
| | | ); |
| | | if (buyNode >= Integer.parseInt(buyNodeCodeCntDic.getValue())) { |
| | | throw new FebsException("Do not repeat purchase"); |
| | | if("STOP".equals(startSymbolDic.getValue())){ |
| | | throw new FebsException("贡献暂未开启"); |
| | | } |
| | | |
| | | DateTime startTime = DateUtil.parseDateTime("2024-07-09 17:00:00"); |
| | | if(DateUtil.compare(DateUtil.date(), startTime) < 0){ |
| | | throw new FebsException("贡献暂未开启"); |
| | | } |
| | | |
| | | BigDecimal amount = transferDto.getAmount(); |
| | | if(BigDecimal.ZERO.compareTo(amount) >= 0){ |
| | | throw new FebsException("请输入正确的存储数量"); |
| | | } |
| | | /** |
| | | * 限购总数200 |
| | | * 检查一个BigDecimal是否能被500整除 |
| | | */ |
| | | BigDecimal bigDecimal = new BigDecimal("500"); |
| | | BigDecimal remainder = amount.remainder(bigDecimal); |
| | | if(remainder.compareTo(BigDecimal.ZERO) != 0){ |
| | | throw new FebsException("存储数量必须是"+bigDecimal+"的整数倍"); |
| | | } |
| | | |
| | | DataDictionaryCustom perKNumDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PERK_NUM.getType(), |
| | | DataDictionaryEnum.PERK_NUM.getCode() |
| | | ); |
| | | int perKNum = Integer.parseInt(ObjectUtil.isEmpty(perKNumDic) ? "200" : perKNumDic.getValue()); |
| | | |
| | | List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectList(null); |
| | | if(CollUtil.isNotEmpty(dappMemberEntities)){ |
| | | int sum1 = dappMemberEntities.stream().mapToInt(DappMemberEntity::getBuyNode).sum(); |
| | | if(perKNum < sum1 + 1){ |
| | | throw new FebsException("节点已售完"); |
| | | DappStorage dappStorage = dappStorageMapper.selectAmountByAmountDesc(member.getId(),0, 1); |
| | | if(ObjectUtil.isNotEmpty(dappStorage)){ |
| | | if(amount.compareTo(dappStorage.getAmount()) < 0){ |
| | | throw new FebsException("存储数量必须大于:"+dappStorage.getAmount()); |
| | | } |
| | | } |
| | | |
| | | if (ObjectUtil.isEmpty(transferDto.getId())) { |
| | | |
| | | DappFundFlowEntity fundFlow = new DappFundFlowEntity( |
| | | member.getId(), |
| | | transferDto.getAmount().negate(), |
| | | 13, |
| | | transferDto.getAmount().abs(), |
| | | MoneyFlowEnum.CUN_CHU.getValue(), |
| | | 1, |
| | | BigDecimal.ZERO, |
| | | transferDto.getTxHash()); |
| | | StrUtil.format(MoneyFlowEnum.CUN_CHU.getDescrition(),amount)); |
| | | dappFundFlowDao.insert(fundFlow); |
| | | return fundFlow.getId(); |
| | | } else { |
| | |
| | | if ("success".equals(transferDto.getFlag())) { |
| | | flow.setFromHash(transferDto.getTxHash()); |
| | | dappFundFlowDao.updateById(flow); |
| | | |
| | | } else { |
| | | if (flow.getStatus() == 1) { |
| | | dappFundFlowDao.deleteById(transferDto.getId()); |
| | |
| | | QueryWrapper<MemberCoinWithdrawEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("flow_id",id); |
| | | MemberCoinWithdrawEntity memberCoinWithdrawEntity = memberCoinWithdrawDao.selectOne(objectQueryWrapper); |
| | | // MemberCoinWithdrawEntity memberCoinWithdrawEntity = memberCoinWithdrawDao.selectById(id); |
| | | if(ObjectUtil.isEmpty(memberCoinWithdrawEntity)){ |
| | | throw new FebsException("刷新页面重试"); |
| | | } |
| | |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(memberCoinWithdrawEntity.getFlowId()); |
| | | dappFundFlowEntity.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | |
| | | DappFundFlowEntity feeFlow = new DappFundFlowEntity(dappFundFlowEntity.getMemberId(), memberCoinWithdrawEntity.getFeeAmount().negate(), 20, 1, null, null); |
| | | dappFundFlowDao.insert(feeFlow); |
| | | |
| | | return new FebsResponse().success(); |
| | | } |
| | |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | |
| | | this.updateWalletCoinWithLock(memberCoinWithdrawEntity.getAmount(), memberCoinWithdrawEntity.getMemberId(), 1); |
| | | // this.updateWalletMineWithLock(memberCoinWithdrawEntity.getFeeAmount(), memberCoinWithdrawEntity.getMemberId(), 1); |
| | | |
| | | DappFundFlowEntity feeFlow = new DappFundFlowEntity(memberCoinWithdrawEntity.getMemberId(), memberCoinWithdrawEntity.getAmount(), 22, 2, null, null); |
| | | dappFundFlowDao.insert(feeFlow); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public ApiIndexInfoVo indexInfo() { |
| | | ApiIndexInfoVo apiIndexInfoVo = new ApiIndexInfoVo(); |
| | | apiIndexInfoVo.setTuanduiChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.TUAN_DUI_CHI.getType(), |
| | | DataDictionaryEnum.TUAN_DUI_CHI.getCode() |
| | | ).getValue()); |
| | | apiIndexInfoVo.setJilichi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.JILI_CHI.getType(), |
| | | DataDictionaryEnum.JILI_CHI.getCode() |
| | | ).getValue()); |
| | | apiIndexInfoVo.setBuchangChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.BUCAHNG_CHI.getType(), |
| | | DataDictionaryEnum.BUCAHNG_CHI.getCode() |
| | | ).getValue()); |
| | | List<DappStorage> dappStorages = dappStorageMapper.selectList(null); |
| | | BigDecimal reduce = dappStorages.stream().map(DappStorage::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal bigDecimal = reduce.multiply(new BigDecimal(AppContants.DAO_NODE_PERCENT)).setScale(2, BigDecimal.ROUND_DOWN); |
| | | apiIndexInfoVo.setJiedianChi(bigDecimal.toString()); |
| | | |
| | | // apiIndexInfoVo.setJiedianChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | // DataDictionaryEnum.JIE_DIAN_CHI.getType(), |
| | | // DataDictionaryEnum.JIE_DIAN_CHI.getCode() |
| | | // ).getValue()); |
| | | apiIndexInfoVo.setJijinghuiChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.JI_JING_HUI_CHI.getType(), |
| | | DataDictionaryEnum.JI_JING_HUI_CHI.getCode() |
| | | ).getValue()); |
| | | apiIndexInfoVo.setJishuChi(dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.JI_SHU_CHI.getType(), |
| | | DataDictionaryEnum.JI_SHU_CHI.getCode() |
| | | ).getValue()); |
| | | return apiIndexInfoVo; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiStorageInfoVo> storageIndex() { |
| | | List<ApiStorageInfoVo> apiStorageInfoVos = new ArrayList<>(); |
| | | |
| | | DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(new Date())); |
| | | DateTime perkTime = DateUtil.parseTime("17:00:00"); |
| | | String startTimeStr = null; |
| | | if(DateUtil.compare(nowTime,perkTime) >= 0){ |
| | | startTimeStr = DateUtil.formatDate(DateUtil.offsetDay(new Date(), 0)) + " 17:00:00"; |
| | | }else{ |
| | | startTimeStr = DateUtil.formatDate(DateUtil.offsetDay(new Date(), -1)) + " 17:00:00"; |
| | | } |
| | | DateTime startTime = DateUtil.parseDateTime(startTimeStr); |
| | | |
| | | List<DappStorage> dappStorages = dappStorageMapper.selectSumByAmountDescFiveToFive(startTime, 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(); |
| | | apiStorageInfoVo.setAddress(dappMemberDao.selectById(dappStorage.getMemberId()).getAddress()); |
| | | apiStorageInfoVo.setAmount(dappStorage.getAmount()); |
| | | |
| | | apiStorageInfoVos.add(apiStorageInfoVo); |
| | | } |
| | | } |
| | | |
| | | return apiStorageInfoVos; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiStorageInfoVo> directIndex() { |
| | | List<ApiStorageInfoVo> apiStorageInfoVos = new ArrayList<>(); |
| | | /** |
| | | * 存放直推业绩<上级的memberId,直推总业绩> |
| | | */ |
| | | HashMap<Long, BigDecimal> map = new HashMap<>(); |
| | | |
| | | List<DappStorage> dappStorages = dappStorageMapper.selectListByDate(new Date()); |
| | | if(CollUtil.isNotEmpty(dappStorages)){ |
| | | for(DappStorage dappStorage : dappStorages){ |
| | | DappMemberEntity member = dappMemberDao.selectById(dappStorage.getMemberId()); |
| | | 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(dappStorage.getAmount()); |
| | | map.put(id,add); |
| | | }else{ |
| | | map.put(id,dappStorage.getAmount()); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | | * 获取这个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 directAchieve = entry.getValue(); |
| | | ApiStorageInfoVo apiStorageInfoVo = new ApiStorageInfoVo(); |
| | | apiStorageInfoVo.setAddress(dappMemberDao.selectById(memberId).getAddress()); |
| | | apiStorageInfoVo.setAmount(directAchieve); |
| | | |
| | | apiStorageInfoVos.add(apiStorageInfoVo); |
| | | } |
| | | } |
| | | return apiStorageInfoVos; |
| | | } |
| | | |
| | | @Override |
| | | public List<ApiDirectInfoVo> directNumIndex() { |
| | | List<ApiDirectInfoVo> apiDirectInfoVos = new ArrayList<>(); |
| | | /** |
| | | * 存放直推人数<上级的memberId,直推人数> |
| | | */ |
| | | HashMap<Long, BigDecimal> map = new HashMap<>(); |
| | | |
| | | DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(new Date())); |
| | | DateTime perkTime = DateUtil.parseTime("17:00:00"); |
| | | String startTimeStr = null; |
| | | if(DateUtil.compare(nowTime,perkTime) >= 0){ |
| | | startTimeStr = DateUtil.formatDate(DateUtil.offsetDay(new Date(), 0)) + " 17:00:00"; |
| | | }else{ |
| | | startTimeStr = DateUtil.formatDate(DateUtil.offsetDay(new Date(), -1)) + " 17:00:00"; |
| | | } |
| | | DateTime startTime = DateUtil.parseDateTime(startTimeStr); |
| | | List<DappMemberEntity> dappMemberEntityList = dappMemberDao.selectListByDateFiveToFiver(startTime); |
| | | |
| | | // List<DappMemberEntity> dappMemberEntityList = dappMemberDao.selectListByDate(new Date()); |
| | | if(CollUtil.isNotEmpty(dappMemberEntityList)){ |
| | | for(DappMemberEntity member : dappMemberEntityList){ |
| | | |
| | | if(StrUtil.isEmpty(member.getRefererId())){ |
| | | continue; |
| | | } |
| | | if(2 == member.getActiveStatus()){ |
| | | 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) { |
| | |
| | | QueryWrapper<DbMemberNode> childQuery = new QueryWrapper<>(); |
| | | childQuery.eq("parent_node",id); |
| | | childQuery.eq("type", dbMemberNode.getType()); |
| | | childQuery.eq("work_state", DbMemberNode.STATE_ONE); |
| | | // childQuery.eq("work_state", DbMemberNode.STATE_ONE); |
| | | List<DbMemberNode> childrenNode = dbMemberNodeMapper.selectList(childQuery); |
| | | if(CollUtil.isEmpty(childrenNode)){ |
| | | return memberNodeVo; |