| | |
| | | } |
| | | |
| | | @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; |
| | |
| | | |
| | | //实时更新用户等级 |
| | | chainProducer.sendAutoLevelUpTeamMsg(memberId); |
| | | } |
| | | |
| | | set.add(dappMemberEntity); |
| | | } |
| | | return set; |
| | | } |
| | | |
| | | @Override |
| | |
| | | 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( |
| | | memberId, |
| | | poorAmount, |
| | | poorAmount.negate(), |
| | | FundFlowEnum.SALE_PACKAGE_AMOUNT_FEE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_ING, |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(feeFlow); |
| | | |
| | |
| | | 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(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal packageAvaCntScore = packageAvaCnt.add(cnt); |
| | | packageAvaCntDic.setValue(packageAvaCntScore.toString()); |
| | | dataDictionaryCustomMapper.updateById(packageAvaCntDic); |
| | | } |
| | | |
| | | @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, |