| | |
| | | |
| | | import cc.mrbird.febs.common.configure.i18n.MessageSourceUtils; |
| | | 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.FebsUtil; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.common.utils.ShareCodeUtil; |
| | | import cc.mrbird.febs.common.utils.*; |
| | | import cc.mrbird.febs.dapp.chain.ChainEnum; |
| | | import cc.mrbird.febs.dapp.chain.ChainService; |
| | | import cc.mrbird.febs.dapp.chain.ContractChainService; |
| | | import cc.mrbird.febs.dapp.dto.ApproveDto; |
| | | import cc.mrbird.febs.dapp.dto.ConnectDto; |
| | | import cc.mrbird.febs.dapp.dto.PriceSettingDto; |
| | | import cc.mrbird.febs.dapp.dto.TeamListDto; |
| | | 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.PoolEnum; |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cc.mrbird.febs.dapp.service.DappMemberService; |
| | | import cc.mrbird.febs.dapp.vo.AdminSystemFeeVo; |
| | | import cc.mrbird.febs.dapp.vo.ApiRunListInfoVo; |
| | | import cc.mrbird.febs.dapp.vo.TeamListVo; |
| | | import cc.mrbird.febs.dapp.vo.*; |
| | | import cc.mrbird.febs.rabbit.producer.ChainProducer; |
| | | import cc.mrbird.febs.system.entity.User; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | 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.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author |
| | |
| | | private final DappAchieveMemberTreeDao dappAchieveMemberTreeDao; |
| | | private final DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | private final DappSystemProfitDao dappSystemProfitDao; |
| | | private final ChainProducer chainProducer; |
| | | private final DappFundFlowDao dappFundFlowDao; |
| | | |
| | | private final DappNodeOrderMapper dappNodeOrderMapper; |
| | | private final DappMemberNodeMapper dappMemberNodeMapper; |
| | | private final DappAKlineMapper dappAKlineMapper; |
| | | private final DappUsdtPerkEntityMapper dappUsdtPerkEntityMapper; |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | DappMemberEntity member = dappMemberDao.selectByAddress(connectDto.getAddress(), null); |
| | | |
| | | if (member == null) { |
| | | String referenceID = null; |
| | | if (!"asdf4321".equals(connectDto.getInviteId())) { |
| | | DappMemberEntity parent = dappMemberDao.selectMemberInfoByInviteId(connectDto.getInviteId()); |
| | | // DappMemberEntity parent = dappMemberDao.selectMemberInfoByInviteId(connectDto.getInviteId()); |
| | | DappMemberEntity parent = dappMemberDao.selectByAddress(connectDto.getInviteId(), null); |
| | | if (parent == null) { |
| | | throw new FebsException("recommender is not exist"); |
| | | } |
| | | referenceID = parent.getInviteId(); |
| | | |
| | | // List<DappMemberEntity> child = dappMemberDao.selectChildMemberDirectOrNot(connectDto.getInviteId(), 1, null); |
| | | // if (child.size() == 6) { |
| | |
| | | } else { |
| | | connectDto.setInviteId(null); |
| | | } |
| | | member = insertMember(connectDto.getAddress(), connectDto.getInviteId()); |
| | | member = insertMember(connectDto.getAddress(), referenceID); |
| | | //升级用户的代理等级 |
| | | // DappMemberEntity dappMemberEntity = dappMemberDao.selectMemberInfoByInviteId(connectDto.getInviteId()); |
| | | // chainProducer.sendAgentUpMsg(dappMemberEntity.getId()); |
| | | } |
| | | |
| | | String key = LoginUserUtil.getLoginKey(connectDto.getAddress(), connectDto.getNonce(), connectDto.getSign()); |
| | |
| | | return 3; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | } |
| | | |
| | | @Override |
| | | public IPage<DappMemberEntity> selectInPage(DappMemberEntity member, QueryRequest request) { |
| | | Page<DappMemberEntity> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | |
| | | if (currentUser.getDeptId() == null) { |
| | | member.setCurrentUser(currentUser.getUserId()); |
| | | } |
| | | return dappMemberDao.selectInPage(member, page); |
| | | IPage<DappMemberEntity> dappMemberEntityIPage = dappMemberDao.selectInPage(member, page); |
| | | List<DappMemberEntity> records = dappMemberEntityIPage.getRecords(); |
| | | if(CollUtil.isNotEmpty(records)){ |
| | | for(DappMemberEntity memberEntity : records){ |
| | | Long memberId = memberEntity.getId(); |
| | | //直推收益 |
| | | BigDecimal directProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,3,2); |
| | | memberEntity.setDirectProfit(directProfit); |
| | | //购买节点数量 |
| | | List<DappMemberNodeVo> dappMemberNodeVos = dappMemberNodeMapper.selectListByMemberId(memberId); |
| | | memberEntity.setMemberNodeCnt(CollUtil.isEmpty(dappMemberNodeVos) ? 0 : dappMemberNodeVos.size()); |
| | | |
| | | BigDecimal memberNodeSumPrice = BigDecimal.ZERO; |
| | | if(CollUtil.isNotEmpty(dappMemberNodeVos)){ |
| | | for(DappMemberNodeVo dappMemberNodeVo : dappMemberNodeVos){ |
| | | BigDecimal nodePrice = dappMemberNodeVo.getNodePrice(); |
| | | memberNodeSumPrice = memberNodeSumPrice.add(nodePrice); |
| | | } |
| | | } |
| | | memberEntity.setMemberNodeSumPrice(memberNodeSumPrice.setScale(8,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | } |
| | | return dappMemberEntityIPage; |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Override |
| | | public TeamListVo findTeamList() { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | //如果没有加入动能即返回null |
| | | DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectByMemberIdAndState(member.getId(), DappSystemProfit.STATE_IN); |
| | | if(ObjectUtil.isEmpty(dappSystemProfit)){ |
| | | return null; |
| | | TeamListVo teamListVo = new TeamListVo(); |
| | | List<DappMemberEntity> childs = dappMemberDao.selectMemberInfoByRefererId(member.getInviteId()); |
| | | teamListVo.setDirectCnt(CollUtil.isEmpty(childs) ? 0 : childs.size()); |
| | | //团队业绩 |
| | | BigDecimal teamIncomeMax = BigDecimal.ZERO; |
| | | if(CollUtil.isNotEmpty(childs)){ |
| | | // 直推用户 |
| | | List<String> childsInviteIds = childs.stream().map(DappMemberEntity::getInviteId).collect(Collectors.toList()); |
| | | for(String inviteId : childsInviteIds){ |
| | | BigDecimal totalIncomeMember = dappMemberDao.selectAllAchieveByInviteId(inviteId); |
| | | teamIncomeMax = teamIncomeMax.add(totalIncomeMember); |
| | | } |
| | | teamIncomeMax = teamIncomeMax.setScale(4,BigDecimal.ROUND_DOWN); |
| | | } |
| | | return buildTeamMatrix(member.getId()); |
| | | teamListVo.setAchieve(teamIncomeMax); |
| | | return teamListVo; |
| | | } |
| | | |
| | | @Override |
| | |
| | | DataDictionaryCustom symbolPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.SYMBOL_PRICE.getType(), DataDictionaryEnum.SYMBOL_PRICE.getCode()); |
| | | symbolPriceDic.setValue(symbolPrice); |
| | | dataDictionaryCustomMapper.updateById(symbolPriceDic); |
| | | |
| | | String directProfit = adminSystemFeeVo.getDirectProfit(); |
| | | DataDictionaryCustom directProfitDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.DIRECT_PROFIT.getType(), DataDictionaryEnum.DIRECT_PROFIT.getCode()); |
| | | directProfitDic.setValue(directProfit); |
| | | dataDictionaryCustomMapper.updateById(directProfitDic); |
| | | } |
| | | |
| | | @Override |
| | |
| | | String memberOutCount = redisUtils.getString(redisKey); |
| | | DataDictionaryCustom queueCountSet = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.QUEUE_COUNT.getType(), DataDictionaryEnum.QUEUE_COUNT.getCode()); |
| | | String queueCount = queueCountSet.getValue(); |
| | | if(StrUtil.isBlank(memberOutCount)){ |
| | | if(StrUtil.isBlank(memberOutCount)|| !queueCount.equals(memberOutCount)){ |
| | | redisUtils.set(redisKey,queueCount,0L); |
| | | memberOutCount = queueCount; |
| | | } |
| | |
| | | objectQueryWrapper.eq("state",DappSystemProfit.STATE_IN); |
| | | //实际投资人数 |
| | | Integer selectCount = dappSystemProfitDao.selectCount(objectQueryWrapper); |
| | | int runPercentNum = memberCount - selectCount; |
| | | runPercentNum = 5-runPercentNum > 0 ? 5-runPercentNum : 1; |
| | | apiRunListInfoVo.setRunPercent(new BigDecimal(runPercentNum).multiply(new BigDecimal(0.4)).setScale(BigDecimal.ROUND_DOWN,1)); |
| | | // BigDecimal runPercent = new BigDecimal(selectCount).divide(new BigDecimal(memberCount), 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(100)); |
| | | // apiRunListInfoVo.setRunPercent(runPercent); |
| | | //实际投资人数小于出局条件人数 |
| | | //符合则出局 实际投资人数等于出局条件人数 |
| | | DappSystemProfit dappSystemProfitIn = dappSystemProfitDao.selectSystemProfitInByState(DappSystemProfit.STATE_IN); |
| | | apiRunListInfoVo.setLuckyMemberNext(dappSystemProfitIn.getId()); |
| | | apiRunListInfoVo.setLuckyMemberNext(ObjectUtil.isEmpty(dappSystemProfitIn) ? 0L : dappSystemProfitIn.getId()); |
| | | DappSystemProfit dappSystemProfitOut = dappSystemProfitDao.selectSystemProfitOutByState(DappSystemProfit.STATE_OUT); |
| | | apiRunListInfoVo.setLuckyMember(dappSystemProfitOut.getId()); |
| | | apiRunListInfoVo.setLuckyMember(ObjectUtil.isEmpty(dappSystemProfitOut) ? 0L : dappSystemProfitOut.getId()); |
| | | return apiRunListInfoVo; |
| | | } |
| | | |
| | | public TeamListVo buildTeamMatrix(Long memberId) { |
| | | DappMemberEntity member = dappMemberDao.selectById(memberId); |
| | | TeamListVo teamListVo = new TeamListVo(); |
| | | teamListVo.setAddress(member.getAddress()); |
| | | teamListVo.setAccountType(member.getAccountType()); |
| | | teamListVo.setActiveStatus(member.getActiveStatus()); |
| | | List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectMemberInfoByRefererId(member.getInviteId()); |
| | | teamListVo.setDirectCnt(dappMemberEntities.size()); |
| | | |
| | | if (CollUtil.isEmpty(dappMemberEntities)) { |
| | | return teamListVo; |
| | | } |
| | | |
| | | List<TeamListVo> list = new ArrayList<>(); |
| | | for (DappMemberEntity childNode : dappMemberEntities) { |
| | | list.add(buildTeamMatrix(childNode.getId())); |
| | | } |
| | | teamListVo.setChildren(list); |
| | | return teamListVo; |
| | | @Override |
| | | public IPage<AdminDappSystemProfitVo> selectSystemProfitInPage(DappSystemProfit dappSystemProfit, QueryRequest request) { |
| | | Page<AdminDappSystemProfitVo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return dappSystemProfitDao.selectSystemProfitInPage(dappSystemProfit, page); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<AdminSystemProfitFlowListVo> getSystemProfitFlowList(DappSystemProfit dappSystemProfit, QueryRequest request) { |
| | | Page<AdminSystemProfitFlowListVo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return dappSystemProfitDao.selectSystemProfitFlowListInPage(dappSystemProfit, page); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<AdminTeamInfoVo> getTeamInfo(DappMemberEntity dappMemberEntity, QueryRequest request) { |
| | | Page<AdminTeamInfoVo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | dappMemberEntity = this.baseMapper.selectById(dappMemberEntity.getId()); |
| | | IPage<AdminTeamInfoVo> adminTeamInfoVoIPage = this.baseMapper.findTeamInfoListInPage(page, dappMemberEntity); |
| | | List<AdminTeamInfoVo> records = adminTeamInfoVoIPage.getRecords(); |
| | | if(CollUtil.isNotEmpty(records)){ |
| | | for(AdminTeamInfoVo adminTeamInfoVo : records){ |
| | | Long memberId = adminTeamInfoVo.getId(); |
| | | List<DappMemberEntity> direct = dappMemberDao.selectChildMemberDirectOrNot(adminTeamInfoVo.getInviteId(), 1, 1); |
| | | adminTeamInfoVo.setDirectCnt(direct.size()); |
| | | DappSystemProfit dappSystemProfit = dappSystemProfitDao.selectByMemberIdAndState(memberId,DappSystemProfit.STATE_IN); |
| | | adminTeamInfoVo.setSystemProfitId(ObjectUtil.isEmpty(dappSystemProfit) ? 0L : dappSystemProfit.getId()); |
| | | BigDecimal directProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,3,2); |
| | | adminTeamInfoVo.setDirectProfit(directProfit); |
| | | BigDecimal levelProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,4,2); |
| | | adminTeamInfoVo.setLevelProfit(levelProfit); |
| | | BigDecimal luckyProfit = dappFundFlowDao.selectSumAmountByMemberIdAndTypeAndStatus(memberId,7,2); |
| | | adminTeamInfoVo.setLuckyProfit(luckyProfit); |
| | | } |
| | | } |
| | | return adminTeamInfoVoIPage; |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse getNodeInfo() { |
| | | List<DappNodeOrderVo> dappNodeOrderVos = dappNodeOrderMapper.selectNodeOrderList(); |
| | | return new FebsResponse().success().data(dappNodeOrderVos); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse getMemberNode() { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | List<DappMemberNodeVo> dappMemberNodeVos = dappMemberNodeMapper.selectListByMemberId(member.getId()); |
| | | return new FebsResponse().success().data(dappMemberNodeVos); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse getMemberInfo() { |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | DappMemberInfoVo dappMemberInfoVo = dappMemberDao.selectByMemberId(member.getId()); |
| | | |
| | | DataDictionaryCustom ausdPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.TRANSFER_A_AUSD_PERCENT.getType(), |
| | | PoolEnum.TRANSFER_A_AUSD_PERCENT.getCode() |
| | | ); |
| | | BigDecimal ausdPercent = new BigDecimal(ausdPercentDic.getValue()); |
| | | dappMemberInfoVo.setAusdtFee(ausdPercent); |
| | | |
| | | DataDictionaryCustom aroundFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.ANDAO_MEMBER_TO_MENBER_PERCENT.getType(), |
| | | PoolEnum.ANDAO_MEMBER_TO_MENBER_PERCENT.getCode() |
| | | ); |
| | | BigDecimal aroundFee = new BigDecimal(aroundFeeDic.getValue()); |
| | | dappMemberInfoVo.setAroundFee(aroundFee); |
| | | //ausd价格 |
| | | DataDictionaryCustom ausdPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.TRANSFER_A_AUSD_PRICE.getType(), |
| | | PoolEnum.TRANSFER_A_AUSD_PRICE.getCode() |
| | | ); |
| | | dappMemberInfoVo.setAusdPrice(ObjectUtil.isEmpty(ausdPriceDic) ? new BigDecimal("1") : new BigDecimal(ausdPriceDic.getValue()).setScale(4,BigDecimal.ROUND_DOWN)); |
| | | //资产到闪兑的手续费比例 |
| | | DataDictionaryCustom mineToCoinFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.WALLET_MINE_TO_COIN_PERCENT.getType(), |
| | | PoolEnum.WALLET_MINE_TO_COIN_PERCENT.getCode() |
| | | ); |
| | | dappMemberInfoVo.setMineToCoinFee(ObjectUtil.isEmpty(mineToCoinFeeDic) ? new BigDecimal("0.03") : new BigDecimal(mineToCoinFeeDic.getValue())); |
| | | //提现手续费比例 |
| | | DataDictionaryCustom coinOutFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.WALLET_COIN_TO_USDT_PERCENT.getType(), |
| | | PoolEnum.WALLET_COIN_TO_USDT_PERCENT.getCode() |
| | | ); |
| | | dappMemberInfoVo.setCoinOutFee(ObjectUtil.isEmpty(coinOutFeeDic) ? new BigDecimal("0.01") : new BigDecimal(coinOutFeeDic.getValue())); |
| | | //A币的价格 |
| | | DataDictionaryCustom coinAPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | PoolEnum.COIN_A_PRICE.getType(), |
| | | PoolEnum.COIN_A_PRICE.getCode() |
| | | ); |
| | | dappMemberInfoVo.setCoinAPrice(ObjectUtil.isEmpty(coinAPriceDic) ? new BigDecimal("1") : new BigDecimal(coinAPriceDic.getValue())); |
| | | return new FebsResponse().success().data(dappMemberInfoVo); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<DappMemberNodeVo> getMemberNodeInfo(DappMemberEntity dappMemberEntity, QueryRequest request) { |
| | | Page<DappMemberNodeVo> page = new Page<>(request.getPageNum(), request.getPageSize()); |
| | | return dappMemberNodeMapper.findMemberNodeInPage(page, dappMemberEntity); |
| | | } |
| | | |
| | | @Override |
| | | public String aKLine(AKLineDto aKLineDto) { |
| | | int type = aKLineDto.getType(); |
| | | String redisKey = null; |
| | | if(1 == type){ |
| | | redisKey = AppContants.K_LINE_HOUR; |
| | | }else if(2 == type){ |
| | | redisKey = AppContants.K_LINE_DAY; |
| | | }else if(3 == type){ |
| | | redisKey = AppContants.K_LINE_WEEK; |
| | | }else if(4 == type){ |
| | | redisKey = AppContants.K_LINE_MONTH; |
| | | }else{ |
| | | redisKey = AppContants.K_LINE_HOUR; |
| | | } |
| | | Object o = redisUtils.get(redisKey); |
| | | if(ObjectUtil.isNotEmpty(o)){ |
| | | return redisUtils.get(redisKey).toString(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public MyInviteInfoVo findInviteInfo() { |
| | | MyInviteInfoVo myInviteInfoVo = new MyInviteInfoVo(); |
| | | |
| | | DappMemberEntity member = LoginUserUtil.getAppUser(); |
| | | Long memberId = member.getId(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | myInviteInfoVo.setMemberAddress(dappMemberEntity.getAddress()); |
| | | DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberId); |
| | | if(ObjectUtil.isEmpty(dappUsdtPerkEntity)){ |
| | | dappUsdtPerkEntity = new DappUsdtPerkEntity(); |
| | | dappUsdtPerkEntity.setMemberId(memberId); |
| | | dappUsdtPerkEntityMapper.insert(dappUsdtPerkEntity); |
| | | } |
| | | myInviteInfoVo.setMemberAchieve(dappUsdtPerkEntity.getAchieveAmount()); |
| | | String refererId = dappMemberEntity.getRefererId(); |
| | | DappMemberEntity parentMember = dappMemberDao.selectMemberInfoByInviteId(refererId); |
| | | myInviteInfoVo.setReferenceAddress(parentMember.getAddress()); |
| | | HashMap<String, BigDecimal> maxMinAchieve = getMaxMinAchieve(memberId); |
| | | myInviteInfoVo.setMaxAchieve(maxMinAchieve.get(AppContants.MAXACHIEVE)); |
| | | myInviteInfoVo.setMinAchieve(maxMinAchieve.get(AppContants.MINACHIEVE)); |
| | | |
| | | List<MyInviteChildInfoVo> myInviteChildInfoVos = new ArrayList<>(); |
| | | List<DappMemberEntity> childs = dappMemberDao.selectMemberInfoByRefererId(member.getInviteId()); |
| | | if(CollUtil.isNotEmpty(childs)){ |
| | | for(DappMemberEntity child : childs){ |
| | | MyInviteChildInfoVo myInviteChildInfoVo = new MyInviteChildInfoVo(); |
| | | myInviteChildInfoVo.setAddress(child.getAddress()); |
| | | myInviteChildInfoVo.setAccountType(child.getAccountType()); |
| | | DappUsdtPerkEntity childUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(child.getId()); |
| | | if(ObjectUtil.isEmpty(dappUsdtPerkEntity)){ |
| | | dappUsdtPerkEntity = new DappUsdtPerkEntity(); |
| | | dappUsdtPerkEntity.setMemberId(child.getId()); |
| | | dappUsdtPerkEntityMapper.insert(dappUsdtPerkEntity); |
| | | } |
| | | myInviteChildInfoVo.setMemberAchieve(childUsdtPerkEntity.getAchieveAmount()); |
| | | HashMap<String, BigDecimal> childMaxMinAchieve = getMaxMinAchieve(child.getId()); |
| | | myInviteChildInfoVo.setMaxAchieve(childMaxMinAchieve.get(AppContants.MAXACHIEVE)); |
| | | myInviteChildInfoVo.setMinAchieve(childMaxMinAchieve.get(AppContants.MINACHIEVE)); |
| | | myInviteChildInfoVos.add(myInviteChildInfoVo); |
| | | } |
| | | } |
| | | |
| | | myInviteInfoVo.setMyInviteChildInfoVos(myInviteChildInfoVos); |
| | | return myInviteInfoVo; |
| | | } |
| | | |
| | | /** |
| | | * 获取用户的大小区业绩 |
| | | * @param memberId |
| | | * @return |
| | | */ |
| | | private HashMap<String,BigDecimal> getMaxMinAchieve(Long memberId) { |
| | | //业绩集合 |
| | | List<BigDecimal> list = new ArrayList<>(); |
| | | //总业绩 |
| | | BigDecimal teamIncomeMax = BigDecimal.ZERO; |
| | | //所有直推团队,就是这个会员的所有区域的业绩。 |
| | | DappMemberEntity member = dappMemberDao.selectById(memberId); |
| | | // 直推用户 |
| | | List<DappMemberEntity> childs = dappMemberDao.selectMemberInfoByRefererId(member.getInviteId()); |
| | | List<String> childsInviteIds = childs.stream().map(DappMemberEntity::getInviteId).collect(Collectors.toList()); |
| | | for(String inviteId : childsInviteIds){ |
| | | BigDecimal totalIncomeMember = dappMemberDao.selectAllAchieveByInviteId(inviteId); |
| | | teamIncomeMax = teamIncomeMax.add(totalIncomeMember); |
| | | list.add(totalIncomeMember); |
| | | } |
| | | HashMap<String, BigDecimal> objectObjectHashMap = new HashMap<>(); |
| | | if(CollUtil.isNotEmpty(list)){ |
| | | //最大区的业绩 |
| | | BigDecimal maxAchieve = list.stream().max(BigDecimal::compareTo).get(); |
| | | BigDecimal minAchieve = teamIncomeMax.subtract(maxAchieve); |
| | | objectObjectHashMap.put(AppContants.MAXACHIEVE,maxAchieve); |
| | | objectObjectHashMap.put(AppContants.MINACHIEVE,minAchieve); |
| | | }else{ |
| | | objectObjectHashMap.put(AppContants.MAXACHIEVE,BigDecimal.ZERO); |
| | | objectObjectHashMap.put(AppContants.MINACHIEVE,BigDecimal.ZERO); |
| | | } |
| | | return objectObjectHashMap; |
| | | } |
| | | // public TeamListVo buildTeamMatrix(Long memberId) { |
| | | // DappMemberEntity member = dappMemberDao.selectById(memberId); |
| | | // TeamListVo teamListVo = new TeamListVo(); |
| | | // teamListVo.setAddress(member.getAddress()); |
| | | // teamListVo.setAccountType(member.getAccountType()); |
| | | // List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectMemberInfoByRefererId(member.getInviteId()); |
| | | // teamListVo.setDirectCnt(dappMemberEntities.size()); |
| | | // DappUsdtPerkEntity dappUsdtPerkEntity = dappUsdtPerkEntityMapper.selectByMemberId(memberId); |
| | | // teamListVo.setAchieve(ObjectUtil.isEmpty(dappUsdtPerkEntity) ? BigDecimal.ZERO : dappUsdtPerkEntity.getAchieveAmount()); |
| | | // |
| | | // if (CollUtil.isEmpty(dappMemberEntities)) { |
| | | // return teamListVo; |
| | | // } |
| | | // |
| | | // List<TeamListVo> list = new ArrayList<>(); |
| | | // for (DappMemberEntity childNode : dappMemberEntities) { |
| | | // list.add(buildTeamMatrix(childNode.getId())); |
| | | // } |
| | | // teamListVo.setChildren(list); |
| | | // return teamListVo; |
| | | // } |
| | | } |