| | |
| | | BigDecimal donateScore = amount.multiply(donateScorePercent); |
| | | dappWalletMineDao.updateBalance(donateScore,donateScore,memberId); |
| | | DappFundFlowEntity donateScoreFlow = new DappFundFlowEntity( |
| | | AccountFlowEnum.SCORE.getCode(), |
| | | memberId, |
| | | donateScore, |
| | | FundFlowEnum.DONATE_SCORE.getCode(), |
| | |
| | | BigDecimal divide = avaPackagePoor.divide(packageTotalScore, 8, BigDecimal.ROUND_DOWN); |
| | | packageScorePriceDic.setValue(divide.toString()); |
| | | dataDictionaryCustomMapper.updateById(packageScorePriceDic); |
| | | |
| | | DappFundFlowEntity packageFlow = new DappFundFlowEntity( |
| | | AccountFlowEnum.SYSTEM_PACKAGE.getCode(), |
| | | 1L, |
| | | addPoor, |
| | | FundFlowEnum.SYSTEM_ORDER_PACKAGE.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | orderId); |
| | | dappFundFlowDao.insert(packageFlow); |
| | | |
| | | DappAKlineEntity dappAKlineEntity = new DappAKlineEntity(); |
| | | dappAKlineEntity.setOpenPrice(divide); |
| | | dappAKlineEntity.setType(1); |
| | | dappAKlineMapper.insert(dappAKlineEntity); |
| | | } |
| | | |
| | | } |
| | |
| | | String inviteId = dappMemberEntity.getInviteId(); |
| | | //该用户全部的直推用户 |
| | | List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectChildMemberDirectOrNot(inviteId, 1, 1); |
| | | if(CollUtil.isEmpty(dappMemberEntities)){ |
| | | continue; |
| | | } |
| | | for(DappMemberEntity directMember : dappMemberEntities){ |
| | | if(1 != directMember.getActiveStatus()){ |
| | | return; |
| | | continue; |
| | | } |
| | | DappMemberEntity parentMember = dappMemberDao.selectMemberInfoByInviteId(directMember.getRefererId()); |
| | | if(ObjectUtil.isEmpty(parentMember)){ |
| | | continue; |
| | | } |
| | | Long directMemberId = directMember.getId(); |
| | | |
| | |
| | | DataDictionaryEnum.DIRECT_RELEASE.getCode() |
| | | ); |
| | | if(ObjectUtil.isEmpty(directReleaseDic)){ |
| | | return; |
| | | continue; |
| | | } |
| | | BigDecimal directRelease = new BigDecimal(directReleaseDic.getValue() == null ? "0" : directReleaseDic.getValue()); |
| | | if(BigDecimal.ZERO.compareTo(directRelease) >= 0){ |
| | | return; |
| | | continue; |
| | | } |
| | | DappMemberEntity parentMember = dappMemberDao.selectMemberInfoByInviteId(dappMemberEntity.getRefererId()); |
| | | /** |
| | | * 获取用户前一天的所有返利记录 |
| | | */ |
| | | List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectListByMemberIdAndTypeAndDate(directMemberId, |
| | | FundFlowEnum.STATIC_RELEASE.getCode(),DateUtil.offsetHour(DateUtil.date(),-12)); |
| | | if(CollUtil.isEmpty(dappFundFlowEntities)){ |
| | | continue; |
| | | } |
| | | for(DappFundFlowEntity dappFundFlowEntity : dappFundFlowEntities){ |
| | | BigDecimal staticReleaseAmount = dappFundFlowEntity.getAmount(); |
| | | BigDecimal directReleaseAmount = staticReleaseAmount.multiply(directRelease).setScale(2, BigDecimal.ROUND_DOWN); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void updateAchieve() { |
| | | public Set<DappMemberEntity> updateAchieve() { |
| | | /** |
| | | * 每个人预期获得的总流水 |
| | | */ |
| | | |
| | | Set<DappMemberEntity> set = new HashSet<>(); |
| | | List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectListByTypeAndDate(FundFlowEnum.ADD_AMOUNT.getCode(), DateUtil.date()); |
| | | if(CollUtil.isEmpty(dappFundFlowEntities)){ |
| | | return; |
| | | return set; |
| | | } |
| | | for(DappFundFlowEntity dappFundFlowEntity : dappFundFlowEntities){ |
| | | Long memberId = dappFundFlowEntity.getMemberId(); |
| | |
| | | BigDecimal amountMagic = amount; |
| | | List<MallAchieveRecord> mallAchieveRecords = mallAchieveRecordMapper.selectListByMemberId(memberId); |
| | | if(CollUtil.isEmpty(mallAchieveRecords)){ |
| | | return; |
| | | continue; |
| | | } |
| | | //实际获取总收益 |
| | | BigDecimal localTotalAchieve = BigDecimal.ZERO; |
| | |
| | | |
| | | //插入积分流水 |
| | | DappFundFlowEntity scoreFlow = new DappFundFlowEntity( |
| | | AccountFlowEnum.SCORE.getCode(), |
| | | memberId, |
| | | localTotalAchieve.negate(), |
| | | FundFlowEnum.REDUCE_SCORE_REAL.getCode(), |
| | |
| | | dappAccountMoneyChangeDao.insert(addAmountAMC); |
| | | //插入余额流水 |
| | | DappFundFlowEntity amountFlow = new DappFundFlowEntity( |
| | | AccountFlowEnum.AMOUNT.getCode(), |
| | | memberId, |
| | | localTotalAchieve, |
| | | FundFlowEnum.ADD_AMOUNT_REAL.getCode(), |
| | |
| | | dappWalletCoinEntity.setAvailableAmount(availableAmountRelease); |
| | | dappWalletCoinDao.updateById(dappWalletCoinEntity); |
| | | |
| | | StringBuffer content = new StringBuffer(); |
| | | if(amountMagic.compareTo(localTotalAchieve) > 0){ |
| | | content.append("今日可加速"+amountMagic.setScale(2,BigDecimal.ROUND_DOWN)+",实际加速"+localTotalAchieve.setScale(2,BigDecimal.ROUND_DOWN)+"" + |
| | | "烧伤"+amountMagic.subtract(localTotalAchieve).setScale(2,BigDecimal.ROUND_DOWN)+",原因消费金额1%加速上" + |
| | | "限,增加消费金额可获得更多收益"); |
| | | }else{ |
| | | content.append("今日可加速"+amountMagic.setScale(2,BigDecimal.ROUND_DOWN)+",实际加速"+localTotalAchieve.setScale(2,BigDecimal.ROUND_DOWN)+"" + |
| | | "烧伤"+amountMagic.subtract(localTotalAchieve).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | DappAccountMoneyChangeEntity record = new DappAccountMoneyChangeEntity( |
| | | memberId, |
| | | totalAmount, |
| | | amountMagic, |
| | | maxReleaseMember, |
| | | localTotalAchieve, |
| | | AccountFlowEnum.AMOUNT_RECORD.getCode(), |
| | | null); |
| | | content.toString()); |
| | | dappAccountMoneyChangeDao.insert(record); |
| | | |
| | | //实时更新用户等级 |
| | | chainProducer.sendAutoLevelUpTeamMsg(memberId); |
| | | } |
| | | |
| | | set.add(dappMemberEntity); |
| | | } |
| | | return set; |
| | | } |
| | | |
| | | @Override |
| | |
| | | if(DappFundFlowEntity.WITHDRAW_STATUS_ING != dappFundFlowEntity.getStatus()){ |
| | | return; |
| | | } |
| | | dappFundFlowEntity.setStatus(DappFundFlowEntity.WITHDRAW_STATUS_AGREE); |
| | | dappFundFlowDao.updateById(dappFundFlowEntity); |
| | | |
| | | BigDecimal cnt = dappFundFlowEntity.getAmount(); |
| | | Long memberId = dappFundFlowEntity.getMemberId(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getType(), |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getCode() |
| | | ); |
| | | BigDecimal packageScorePrice = new BigDecimal(ObjectUtil.isEmpty(packageScorePriceDic) ? "0" : packageScorePriceDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal packageScorePrice = new BigDecimal(ObjectUtil.isEmpty(packageScorePriceDic) ? "0" : packageScorePriceDic.getValue()).setScale(8, BigDecimal.ROUND_DOWN); |
| | | //卖出资产乘以价格获取到预期获取的总额 |
| | | BigDecimal totalAmount = cnt.multiply(packageScorePrice).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal totalAmount = cnt.multiply(packageScorePrice).setScale(4, BigDecimal.ROUND_DOWN); |
| | | //资产包卖出划入底池比例 |
| | | DataDictionaryCustom packageToPoorPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_SALE_TO_POOR_PERCENT.getType(), |
| | | DataDictionaryEnum.PACKAGE_SALE_TO_POOR_PERCENT.getCode() |
| | | ); |
| | | BigDecimal packageToPoorPercent = new BigDecimal(ObjectUtil.isEmpty(packageToPoorPercentDic) ? "0.1" : packageToPoorPercentDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal packageToPoorPercent = new BigDecimal(ObjectUtil.isEmpty(packageToPoorPercentDic) ? "0.1" : packageToPoorPercentDic.getValue()).setScale(8, BigDecimal.ROUND_DOWN); |
| | | //划入底池的金额 |
| | | BigDecimal poorAmount = totalAmount.multiply(packageToPoorPercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal poorAmount = totalAmount.multiply(packageToPoorPercent).setScale(4, BigDecimal.ROUND_DOWN); |
| | | //实际获取的金额 |
| | | BigDecimal realAmount = totalAmount.subtract(poorAmount); |
| | | //生成一条资金流水 |
| | | DappFundFlowEntity scoreFlow = new DappFundFlowEntity( |
| | | AccountFlowEnum.AMOUNT.getCode(), |
| | | memberId, |
| | | realAmount, |
| | | FundFlowEnum.SALE_PACKAGE_AMOUNT.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_ING, |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(scoreFlow); |
| | | dappWalletCoinDao.addTotalAndaddAvailableByMemberId(memberId,realAmount); |
| | | DappFundFlowEntity feeFlow = new DappFundFlowEntity( |
| | | AccountFlowEnum.AMOUNT.getCode(), |
| | | memberId, |
| | | poorAmount, |
| | | poorAmount.negate(), |
| | | FundFlowEnum.SALE_PACKAGE_AMOUNT_FEE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_ING, |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(feeFlow); |
| | | |
| | |
| | | DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getType(), |
| | | DataDictionaryEnum.PACKAGE_TOTAL_SCORE.getCode() |
| | | ); |
| | | BigDecimal packageTotalScore = new BigDecimal(ObjectUtil.isEmpty(packageTotalScoreDic) ? "21000" : packageTotalScoreDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal packageTotalScore = new BigDecimal(ObjectUtil.isEmpty(packageTotalScoreDic) ? "21000" : packageTotalScoreDic.getValue()).setScale(4, BigDecimal.ROUND_DOWN); |
| | | BigDecimal avaPackageTotalScore = packageTotalScore.subtract(cnt); |
| | | packageTotalScoreDic.setValue(avaPackageTotalScore.toString()); |
| | | dataDictionaryCustomMapper.updateById(packageTotalScoreDic); |
| | |
| | | DataDictionaryEnum.PACKAGE_POOR.getType(), |
| | | DataDictionaryEnum.PACKAGE_POOR.getCode() |
| | | ); |
| | | BigDecimal packagePoor = new BigDecimal(ObjectUtil.isEmpty(packagePoorDic) ? "0" : packagePoorDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal packagePoor = new BigDecimal(ObjectUtil.isEmpty(packagePoorDic) ? "0" : packagePoorDic.getValue()).setScale(4, BigDecimal.ROUND_DOWN); |
| | | BigDecimal avaPackagePoor = packagePoor.add(poorAmount); |
| | | packagePoorDic.setValue(avaPackagePoor.toString()); |
| | | dataDictionaryCustomMapper.updateById(packagePoorDic); |
| | | //计算当前价格 |
| | | BigDecimal divide = avaPackagePoor.divide(avaPackageTotalScore, 2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal divide = avaPackagePoor.divide(avaPackageTotalScore, 8, BigDecimal.ROUND_DOWN); |
| | | packageScorePriceDic.setValue(divide.toString()); |
| | | dataDictionaryCustomMapper.updateById(packageScorePriceDic); |
| | | |
| | | DataDictionaryCustom packageAvaCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_AVA_CNT.getType(), |
| | | DataDictionaryEnum.PACKAGE_AVA_CNT.getCode() |
| | | ); |
| | | BigDecimal packageAvaCnt = new BigDecimal(ObjectUtil.isEmpty(packageAvaCntDic) ? "0" : packageAvaCntDic.getValue()).setScale(4, BigDecimal.ROUND_DOWN); |
| | | BigDecimal packageAvaCntScore = packageAvaCnt.add(cnt); |
| | | packageAvaCntDic.setValue(packageAvaCntScore.toString()); |
| | | dataDictionaryCustomMapper.updateById(packageAvaCntDic); |
| | | |
| | | DappFundFlowEntity packageFlow = new DappFundFlowEntity( |
| | | AccountFlowEnum.SYSTEM_PACKAGE.getCode(), |
| | | memberId, |
| | | poorAmount.negate(), |
| | | FundFlowEnum.SYSTEM_SALE_PACKAGE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(packageFlow); |
| | | |
| | | DappAKlineEntity dappAKlineEntity = new DappAKlineEntity(); |
| | | dappAKlineEntity.setOpenPrice(divide); |
| | | dappAKlineEntity.setType(1); |
| | | dappAKlineMapper.insert(dappAKlineEntity); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void updatePackage(Set<DappMemberEntity> dappMemberEntities) { |
| | | DataDictionaryCustom packageTeamPerkPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_TEAM_PERK_PERCENT.getType(), |
| | | DataDictionaryEnum.PACKAGE_TEAM_PERK_PERCENT.getCode() |
| | | ); |
| | | BigDecimal packageTeamPerkPercent = new BigDecimal(ObjectUtil.isEmpty(packageTeamPerkPercentDic) ? "0.01" : packageTeamPerkPercentDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | |
| | | for(DappMemberEntity dappMemberEntity : dappMemberEntities){ |
| | | List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectListByMemberIdAndTypeAndDate(dappMemberEntity.getId() |
| | | , FundFlowEnum.ADD_AMOUNT_REAL.getCode() |
| | | , DateUtil.offsetHour(DateUtil.date(), -12)); |
| | | //总收益 |
| | | BigDecimal totalPerk = dappFundFlowEntities.stream().map(DappFundFlowEntity::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal memberPerk = totalPerk.multiply(packageTeamPerkPercent); |
| | | |
| | | DataDictionaryCustom packageTeamPerkCntDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_TEAM_PERK_CNT.getType(), |
| | | DataDictionaryEnum.PACKAGE_TEAM_PERK_CNT.getCode() |
| | | ); |
| | | |
| | | DataDictionaryCustom packageScorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getType(), |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getCode() |
| | | ); |
| | | BigDecimal packageScorePrice = new BigDecimal(ObjectUtil.isEmpty(packageScorePriceDic) ? "0" : packageScorePriceDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | |
| | | BigDecimal divide = memberPerk.divide(packageScorePrice, 4, BigDecimal.ROUND_DOWN); |
| | | if(BigDecimal.ZERO.compareTo(divide) >= 0){ |
| | | continue; |
| | | } |
| | | |
| | | BigDecimal packageTeamPerkCnt = new BigDecimal(packageTeamPerkCntDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | if(packageTeamPerkCnt.compareTo(divide) >= 0){ |
| | | BigDecimal subtract = packageTeamPerkCnt.subtract(divide); |
| | | packageTeamPerkCntDic.setValue(subtract.toString()); |
| | | dataDictionaryCustomMapper.updateById(packageTeamPerkCntDic); |
| | | } |
| | | |
| | | BigDecimal balance = dappMemberEntity.getBalance(); |
| | | balance = balance.add(divide); |
| | | dappMemberEntity.setBalance(balance); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | |
| | | //插入余额流水 |
| | | DappFundFlowEntity amountFlow = new DappFundFlowEntity( |
| | | AccountFlowEnum.AMOUNT.getCode(), |
| | | dappMemberEntity.getId(), |
| | | divide, |
| | | FundFlowEnum.PACKAGE_ADD.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(amountFlow); |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | public void shareStaticPerk(List<DappMemberEntity> dappMemberEntities, |
| | |
| | | } |
| | | //生成一条静态补贴的流水 |
| | | DappFundFlowEntity realUsdtAmountFlow = new DappFundFlowEntity( |
| | | AccountFlowEnum.AMOUNT.getCode(), |
| | | parentMember.getId(), |
| | | realScoreReduce, |
| | | fundFlowEnumType, |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | orderId); |
| | | dappFundFlowDao.insert(realUsdtAmountFlow); |
| | | //插入积分流水 |
| | | DappFundFlowEntity scoreFlow = new DappFundFlowEntity( |
| | | AccountFlowEnum.SCORE.getCode(), |
| | | parentMember.getId(), |
| | | realScoreReduce.negate(), |
| | | FundFlowEnum.REDUCE_SCORE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | orderId); |
| | | dappFundFlowDao.insert(scoreFlow); |
| | | //插入余额流水 |
| | | DappFundFlowEntity amountFlow = new DappFundFlowEntity( |
| | | AccountFlowEnum.AMOUNT.getCode(), |
| | | parentMember.getId(), |
| | | realScoreReduce, |
| | | FundFlowEnum.ADD_AMOUNT.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | orderId); |
| | | dappFundFlowDao.insert(amountFlow); |
| | | return realScoreReduce; |