| | |
| | | * * 21-25代奖励4% |
| | | * * 26-30代奖励7% |
| | | */ |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(id); |
| | | if(ObjectUtil.isEmpty(dappFundFlowEntity)){ |
| | | // DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(id); |
| | | // if(ObjectUtil.isEmpty(dappFundFlowEntity)){ |
| | | // return; |
| | | // } |
| | | // if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE != dappFundFlowEntity.getStatus()){ |
| | | // return; |
| | | // } |
| | | DappStorage dappStorage = dappStorageMapper.selectById(id); |
| | | |
| | | if(ObjectUtil.isEmpty(dappStorage)){ |
| | | return; |
| | | } |
| | | if(DappFundFlowEntity.WITHDRAW_STATUS_AGREE != dappFundFlowEntity.getStatus()){ |
| | | return; |
| | | } |
| | | BigDecimal amount = dappFundFlowEntity.getAmount().abs(); |
| | | BigDecimal amount = dappStorage.getReleaseAmount().abs(); |
| | | /** |
| | | * 往上循环30层,判断每一层是否有见点奖 |
| | | */ |
| | | Long memberId = dappFundFlowEntity.getMemberId(); |
| | | Long memberId = dappStorage.getMemberId(); |
| | | for(int i = 1;i <= 30;i++){ |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | String refererId = dappMemberEntity.getRefererId(); |
| | |
| | | if(1 != activeStatus){ |
| | | continue; |
| | | } |
| | | //获取上级全部的直推 |
| | | //获取上级全部的激活直推 |
| | | String inviteId = dappMemberEntityRef.getInviteId(); |
| | | QueryWrapper<DappMemberEntity> memberInviteQuery = new QueryWrapper<>(); |
| | | memberInviteQuery.eq("referer_id",inviteId); |
| | | memberInviteQuery.eq("active_status",1); |
| | | List<DappMemberEntity> memberInviteList = dappMemberDao.selectList(memberInviteQuery); |
| | | |
| | | //如果没有直推,则跳过 |
| | |
| | | BigDecimal perkPercent = new BigDecimal(rule.getPerkPercent()).multiply(new BigDecimal("0.01")); |
| | | BigDecimal perkAmount = perkPercent.multiply(amount); |
| | | Long perkMemberId = dappMemberEntityRef.getId(); |
| | | //生成一条流水 |
| | | DappFundFlowEntity rePutInFlow = new DappFundFlowEntity( |
| | | perkMemberId, |
| | | |
| | | this.updateBalanceInsertFlow( |
| | | perkAmount, |
| | | 15, |
| | | 2, |
| | | null, |
| | | null); |
| | | dappFundFlowDao.insert(rePutInFlow); |
| | | //更新用户的金额 |
| | | dappWalletService.updateWalletCoinWithLock(perkAmount, perkMemberId, 1); |
| | | perkMemberId, |
| | | MoneyFlowEnum.DYNAMIC_PERK.getValue(), |
| | | StrUtil.format(MoneyFlowEnum.DYNAMIC_PERK.getDescrition(),amount,memberInviteList.size(),perkAmount)); |
| | | } |
| | | } |
| | | |
| | |
| | | dataDictionaryCustomMapper.updateById(buchangChiDic); |
| | | |
| | | /** |
| | | * 团队 5 %加权分红(people数量) |
| | | */ |
| | | // BigDecimal tuanDuiAmount = amount.multiply(new BigDecimal(AppContants.DAO_TEAM_PERK_PERCENT)); |
| | | // DataDictionaryCustom tuanDuiChiDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | // DataDictionaryEnum.TUAN_DUI_CHI.getType(), |
| | | // DataDictionaryEnum.TUAN_DUI_CHI.getCode() |
| | | // ); |
| | | // BigDecimal tuanDuiChi = new BigDecimal(tuanDuiChiDic.getValue()).add(tuanDuiAmount).setScale(2,BigDecimal.ROUND_DOWN); |
| | | // tuanDuiChiDic.setValue(tuanDuiChi.toString()); |
| | | // dataDictionaryCustomMapper.updateById(tuanDuiChiDic); |
| | | |
| | | /** |
| | | * 技术 2 %加权分红(people数量) |
| | | */ |
| | | BigDecimal jiShuAmount = amount.multiply(new BigDecimal(AppContants.DAO_JI_SHU_PERCENT)); |
| | | DataDictionaryCustom jiShuChiDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.JI_SHU_CHI.getType(), |
| | | DataDictionaryEnum.JI_SHU_CHI.getCode() |
| | | ); |
| | | BigDecimal jiShuChi = new BigDecimal(jiShuChiDic.getValue()).add(jiShuAmount).setScale(2,BigDecimal.ROUND_DOWN); |
| | | jiShuChiDic.setValue(jiShuChi.toString()); |
| | | dataDictionaryCustomMapper.updateById(jiShuChiDic); |
| | | |
| | | /** |
| | | * 基金会 3 %加权分红(people数量) |
| | | */ |
| | | BigDecimal jiJingHuiAmount = amount.multiply(new BigDecimal(AppContants.DAO_JI_JING_HUI_PERCENT)); |
| | | DataDictionaryCustom jiJingHuiChiDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.JI_JING_HUI_CHI.getType(), |
| | | DataDictionaryEnum.JI_JING_HUI_CHI.getCode() |
| | | ); |
| | | BigDecimal jiJingHuiChi = new BigDecimal(jiJingHuiChiDic.getValue()).add(jiJingHuiAmount).setScale(2,BigDecimal.ROUND_DOWN); |
| | | jiJingHuiChiDic.setValue(jiJingHuiChi.toString()); |
| | | dataDictionaryCustomMapper.updateById(jiJingHuiChiDic); |
| | | |
| | | /** |
| | | * DAO联盟委员会 : 5% |
| | | */ |
| | | BigDecimal daoNodeAmountTotal = new BigDecimal(AppContants.DAO_NODE_PERCENT).multiply(amount); |
| | | //沉淀剩余 |
| | | BigDecimal daoNodeAmountAva = BigDecimal.ZERO; |
| | | |
| | | QueryWrapper<DappMemberEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("node_type",1); |
| | | List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectList(objectQueryWrapper); |
| | | if(CollUtil.isEmpty(dappMemberEntities)){ |
| | | return; |
| | | if(CollUtil.isNotEmpty(dappMemberEntities)){ |
| | | BigDecimal daoNodeAmount = daoNodeAmountTotal.divide(new BigDecimal(dappMemberEntities.size()),2,BigDecimal.ROUND_DOWN); |
| | | for(DappMemberEntity nodeMember : dappMemberEntities){ |
| | | //生成一条流水 |
| | | DappFundFlowEntity rePutInFlow = new DappFundFlowEntity( |
| | | nodeMember.getId(), |
| | | daoNodeAmount, |
| | | MoneyFlowEnum.NODE_PERK.getValue(), |
| | | 2, |
| | | null, |
| | | StrUtil.format(MoneyFlowEnum.NODE_PERK.getDescrition(),amount,dappMemberEntities.size(),daoNodeAmount)); |
| | | dappFundFlowDao.insert(rePutInFlow); |
| | | //更新用户的金额 |
| | | dappWalletService.updateWalletCoinWithLock(daoNodeAmount, nodeMember.getId(), 1); |
| | | } |
| | | }else{ |
| | | daoNodeAmountAva = daoNodeAmountTotal; |
| | | } |
| | | BigDecimal daoNodeAmount = daoNodeAmountTotal.divide(new BigDecimal(dappMemberEntities.size()),2,BigDecimal.ROUND_DOWN); |
| | | for(DappMemberEntity nodeMember : dappMemberEntities){ |
| | | this.updateBalanceInsertFlow( |
| | | daoNodeAmount, |
| | | nodeMember.getId(), |
| | | MoneyFlowEnum.NODE_PERK.getValue(), |
| | | StrUtil.format(MoneyFlowEnum.NODE_PERK.getDescrition(),amount,dappMemberEntities.size(),daoNodeAmount)); |
| | | |
| | | if(BigDecimal.ZERO.compareTo(daoNodeAmountAva) < 0){ |
| | | DataDictionaryCustom jieDianChiDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.JIE_DIAN_CHI.getType(), |
| | | DataDictionaryEnum.JIE_DIAN_CHI.getCode() |
| | | ); |
| | | BigDecimal jieDianChi = new BigDecimal(jieDianChiDic.getValue()).add(daoNodeAmountAva).setScale(2,BigDecimal.ROUND_DOWN); |
| | | jieDianChiDic.setValue(jieDianChi.toString()); |
| | | dataDictionaryCustomMapper.updateById(jieDianChiDic); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //减少用户的总额度 |
| | | BigDecimal usdtBalance = dappMemberEntity.getUsdtBalance(); |
| | | if(BigDecimal.ZERO.compareTo(usdtBalance) >= 0){ |
| | | return; |
| | | } |
| | | if(daoNodeAmount.compareTo(usdtBalance) >= 0){ |
| | | daoNodeAmount = usdtBalance; |
| | | usdtBalance = BigDecimal.ZERO; |
| | | }else{ |
| | | usdtBalance = usdtBalance.subtract(daoNodeAmount); |
| | | } |
| | | // BigDecimal usdtBalance = dappMemberEntity.getUsdtBalance(); |
| | | // if(BigDecimal.ZERO.compareTo(usdtBalance) >= 0){ |
| | | // return; |
| | | // } |
| | | // if(daoNodeAmount.compareTo(usdtBalance) >= 0){ |
| | | // daoNodeAmount = usdtBalance; |
| | | // usdtBalance = BigDecimal.ZERO; |
| | | // }else{ |
| | | // usdtBalance = usdtBalance.subtract(daoNodeAmount); |
| | | // } |
| | | |
| | | //总额度为0,用户变成未激活 |
| | | if(BigDecimal.ZERO.compareTo(usdtBalance) >= 0){ |
| | | dappMemberEntity.setActiveStatus(2); |
| | | //更新用户所有的业绩为已失效 |
| | | QueryWrapper<DappStorage> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("member_id",memberId); |
| | | objectQueryWrapper.eq("state",1); |
| | | List<DappStorage> dappStorages = dappStorageMapper.selectList(objectQueryWrapper); |
| | | if(CollUtil.isNotEmpty(dappStorages)){ |
| | | for(DappStorage dappStorage : dappStorages){ |
| | | dappStorage.setState(2); |
| | | dappStorageMapper.updateById(dappStorage); |
| | | } |
| | | } |
| | | } |
| | | dappMemberEntity.setUsdtBalance(usdtBalance); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | // if(BigDecimal.ZERO.compareTo(usdtBalance) >= 0){ |
| | | // dappMemberEntity.setActiveStatus(2); |
| | | // //更新用户所有的业绩为已失效 |
| | | // QueryWrapper<DappStorage> objectQueryWrapper = new QueryWrapper<>(); |
| | | // objectQueryWrapper.eq("member_id",memberId); |
| | | // objectQueryWrapper.eq("state",1); |
| | | // List<DappStorage> dappStorages = dappStorageMapper.selectList(objectQueryWrapper); |
| | | // if(CollUtil.isNotEmpty(dappStorages)){ |
| | | // for(DappStorage dappStorage : dappStorages){ |
| | | // dappStorage.setState(2); |
| | | // dappStorageMapper.updateById(dappStorage); |
| | | // } |
| | | // } |
| | | // } |
| | | // dappMemberEntity.setUsdtBalance(usdtBalance); |
| | | // dappMemberDao.updateById(dappMemberEntity); |
| | | |
| | | dappWalletService.updateWalletCoinWithLock(daoNodeAmount, memberId, 1); |
| | | DappFundFlowEntity nodeFlow = new DappFundFlowEntity( |
| | |
| | | @Override |
| | | public void teamPerk(Long id) { |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(id); |
| | | if(ObjectUtil.isEmpty(dappFundFlowEntity)){ |
| | | return; |
| | | } |
| | | |
| | | if(MoneyFlowEnum.CUN_CHU.getValue() != dappFundFlowEntity.getType()){ |
| | | return; |
| | |
| | | //5%加权分红(people数量) |
| | | BigDecimal totalAmount = amount.multiply(new BigDecimal(AppContants.DAO_TEAM_PERK_PERCENT)).setScale(2, BigDecimal.ROUND_DOWN); |
| | | |
| | | |
| | | //沉淀数量 |
| | | BigDecimal tuanDuiAva = BigDecimal.ZERO; |
| | | |
| | | QueryWrapper<DappMemberEntity> daoOneQuery = new QueryWrapper<>(); |
| | | daoOneQuery.eq("level", MemberLevelEnum.DAO_1.getCode()); |
| | | List<DappMemberEntity> daoOnes = dappMemberDao.selectList(daoOneQuery); |
| | | if(CollUtil.isNotEmpty(daoOnes)){ |
| | | BigDecimal bigDecimal = totalAmount.multiply(new BigDecimal("0.5")).setScale(2, BigDecimal.ROUND_DOWN); |
| | | tuanDuiAva = tuanDuiAva.add(bigDecimal); |
| | | //每人平分数量 |
| | | BigDecimal divide = bigDecimal.divide(new BigDecimal(daoOnes.size()), 2, BigDecimal.ROUND_DOWN); |
| | | for(DappMemberEntity memberEntity : daoOnes){ |
| | |
| | | List<DappMemberEntity> daoTwos = dappMemberDao.selectList(daoTwoQuery); |
| | | if(CollUtil.isNotEmpty(daoTwos)){ |
| | | BigDecimal bigDecimal = totalAmount.multiply(new BigDecimal("0.3")).setScale(2, BigDecimal.ROUND_DOWN); |
| | | tuanDuiAva = tuanDuiAva.add(bigDecimal); |
| | | //每人平分数量 |
| | | BigDecimal divide = bigDecimal.divide(new BigDecimal(daoTwos.size()), 2, BigDecimal.ROUND_DOWN); |
| | | for(DappMemberEntity memberEntity : daoTwos){ |
| | |
| | | } |
| | | |
| | | QueryWrapper<DappMemberEntity> daoThreeQuery = new QueryWrapper<>(); |
| | | daoThreeQuery.eq("level", MemberLevelEnum.DAO_2.getCode()); |
| | | daoThreeQuery.eq("level", MemberLevelEnum.DAO_3.getCode()); |
| | | List<DappMemberEntity> daoThrees = dappMemberDao.selectList(daoThreeQuery); |
| | | if(CollUtil.isNotEmpty(daoThrees)){ |
| | | BigDecimal bigDecimal = totalAmount.multiply(new BigDecimal("0.2")).setScale(2, BigDecimal.ROUND_DOWN); |
| | | tuanDuiAva = tuanDuiAva.add(bigDecimal); |
| | | //每人平分数量 |
| | | BigDecimal divide = bigDecimal.divide(new BigDecimal(daoThrees.size()), 2, BigDecimal.ROUND_DOWN); |
| | | for(DappMemberEntity memberEntity : daoThrees){ |
| | |
| | | MoneyFlowEnum.TEAM_THREE_PERK.getValue(), |
| | | StrUtil.format(MoneyFlowEnum.TEAM_THREE_PERK.getDescrition(),divide)); |
| | | } |
| | | } |
| | | |
| | | DataDictionaryCustom tuanDuiChiDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.TUAN_DUI_CHI.getType(), |
| | | DataDictionaryEnum.TUAN_DUI_CHI.getCode() |
| | | ); |
| | | BigDecimal tuanDuiAvaTotal = totalAmount.subtract(tuanDuiAva).setScale(2, BigDecimal.ROUND_DOWN); |
| | | if(BigDecimal.ZERO.compareTo(tuanDuiAvaTotal) < 0){ |
| | | BigDecimal tuanDuiChi = new BigDecimal(tuanDuiChiDic.getValue()).add(tuanDuiAvaTotal).setScale(2,BigDecimal.ROUND_DOWN); |
| | | tuanDuiChiDic.setValue(tuanDuiChi.toString()); |
| | | dataDictionaryCustomMapper.updateById(tuanDuiChiDic); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | //获取全部上级 |
| | | ArrayList<DappMemberEntity> activeMembers = new ArrayList<>(); |
| | | List<String> refererIds = Arrays.asList(StrUtil.split(",", dappMemberEntity.getRefererIds())); |
| | | List<String> refererIds = Arrays.asList(StrUtil.split(dappMemberEntity.getRefererIds(),",")); |
| | | for(String inviteId : refererIds){ |
| | | DappMemberEntity memberEntity = dappMemberDao.selectMemberInfoByInviteId(inviteId); |
| | | if(ObjectUtil.isNotEmpty(memberEntity)){ |
| | |
| | | List<Long> collect = direct.stream().map(DappMemberEntity::getId).collect(Collectors.toList()); |
| | | QueryWrapper<DappStorage> storageQueryWrapper = new QueryWrapper<>(); |
| | | storageQueryWrapper.in("member_id",collect); |
| | | storageQueryWrapper.eq("state",1); |
| | | // storageQueryWrapper.eq("state",1); |
| | | List<DappStorage> dappStorages = dappStorageMapper.selectList(storageQueryWrapper); |
| | | if(CollUtil.isEmpty(dappStorages)){ |
| | | continue; |