| | |
| | | ); |
| | | mallAchieveRecordMapper.insert(mallAchieveRecord); |
| | | |
| | | DappFundFlowEntity achieveFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | amount, |
| | | FundFlowEnum.ACHIEVE_ADD.getCode(), |
| | | 2, |
| | | BigDecimal.ZERO, |
| | | null, |
| | | orderId); |
| | | dappFundFlowDao.insert(achieveFlow); |
| | | /** |
| | | * 商城销售额1%-10%,可设定进入资产管理池 |
| | | * USDT_ORDER_PERCENT |
| | | */ |
| | | DataDictionaryCustom orderPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.USDT_ORDER_PERCENT.getType(), |
| | | DataDictionaryEnum.USDT_ORDER_PERCENT.getCode() |
| | | ); |
| | | if(ObjectUtil.isNotEmpty(orderPercentDic)){ |
| | | BigDecimal orderPercent = new BigDecimal(StrUtil.isEmpty(orderPercentDic.getValue()) ? "0.1" : orderPercentDic.getValue()); |
| | | BigDecimal addPoor = amount.multiply(orderPercent); |
| | | |
| | | DataDictionaryCustom packageScorePriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getType(), |
| | | DataDictionaryEnum.PACKAGE_SCORE_PRICE.getCode() |
| | | ); |
| | | DataDictionaryCustom packageTotalScoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | 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); |
| | | //更新USDT底池 |
| | | DataDictionaryCustom packagePoorDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_POOR.getType(), |
| | | DataDictionaryEnum.PACKAGE_POOR.getCode() |
| | | ); |
| | | BigDecimal packagePoor = new BigDecimal(ObjectUtil.isEmpty(packagePoorDic) ? "0" : packagePoorDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal avaPackagePoor = packagePoor.add(addPoor); |
| | | packagePoorDic.setValue(avaPackagePoor.toString()); |
| | | dataDictionaryCustomMapper.updateById(packagePoorDic); |
| | | //计算当前价格 |
| | | BigDecimal divide = avaPackagePoor.divide(packageTotalScore, 8, BigDecimal.ROUND_DOWN); |
| | | packageScorePriceDic.setValue(divide.toString()); |
| | | dataDictionaryCustomMapper.updateById(packageScorePriceDic); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | * 获取用户前一天的所有返利记录 |
| | | */ |
| | | List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectListByMemberIdAndTypeAndDate(directMemberId, |
| | | FundFlowEnum.STATIC_RELEASE.getCode(),DateUtil.offsetHour(DateUtil.date(),12)); |
| | | FundFlowEnum.STATIC_RELEASE.getCode(),DateUtil.offsetHour(DateUtil.date(),-12)); |
| | | for(DappFundFlowEntity dappFundFlowEntity : dappFundFlowEntities){ |
| | | BigDecimal staticReleaseAmount = dappFundFlowEntity.getAmount(); |
| | | BigDecimal directReleaseAmount = staticReleaseAmount.multiply(directRelease).setScale(2, BigDecimal.ROUND_DOWN); |
| | |
| | | * 获取用户前一天的所有返利记录 |
| | | */ |
| | | List<DappFundFlowEntity> dappFundFlowEntities = dappFundFlowDao.selectListByMemberIdAndTypeAndDate(memberId, |
| | | FundFlowEnum.STATIC_RELEASE.getCode(),DateUtil.offsetHour(DateUtil.date(),12)); |
| | | FundFlowEnum.STATIC_RELEASE.getCode(),DateUtil.offsetHour(DateUtil.date(),-12)); |
| | | for(DappFundFlowEntity dappFundFlowEntity : dappFundFlowEntities){ |
| | | BigDecimal staticReleaseAmount = dappFundFlowEntity.getAmount(); |
| | | BigDecimal directReleaseAmount = staticReleaseAmount.multiply(directRelease).setScale(2, BigDecimal.ROUND_DOWN); |
| | |
| | | List<DappMemberEntity> dappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V1.getType()); |
| | | shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V1.getCode()); |
| | | teamStaticPerkMemberLevel(dappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V1.getCode()); |
| | | isAllPerkMemberLevel(dappMemberEntities,MemberLevelEnum.V1.getType(),FundFlowEnum.ALL_PERK_V1.getCode()); |
| | | |
| | | List<DappMemberEntity> v2DappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V2.getType()); |
| | | shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V2.getCode()); |
| | | shareStaticPerk(v2DappMemberEntities,FundFlowEnum.SHARE_PERK_V2.getCode()); |
| | | teamStaticPerkMemberLevel(v2DappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V2.getCode()); |
| | | isAllPerkMemberLevel(v2DappMemberEntities,MemberLevelEnum.V2.getType(),FundFlowEnum.ALL_PERK_V2.getCode()); |
| | | |
| | | List<DappMemberEntity> v3DappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V3.getType()); |
| | | shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V3.getCode()); |
| | | shareStaticPerk(v3DappMemberEntities,FundFlowEnum.SHARE_PERK_V3.getCode()); |
| | | teamStaticPerkMemberLevel(v3DappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V3.getCode()); |
| | | isAllPerkMemberLevel(v3DappMemberEntities,MemberLevelEnum.V3.getType(),FundFlowEnum.ALL_PERK_V3.getCode()); |
| | | |
| | | List<DappMemberEntity> v4DappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V4.getType()); |
| | | shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V4.getCode()); |
| | | shareStaticPerk(v4DappMemberEntities,FundFlowEnum.SHARE_PERK_V4.getCode()); |
| | | teamStaticPerkMemberLevel(v4DappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V4.getCode()); |
| | | isAllPerkMemberLevel(v4DappMemberEntities,MemberLevelEnum.V4.getType(),FundFlowEnum.ALL_PERK_V4.getCode()); |
| | | |
| | | List<DappMemberEntity> v5DappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V5.getType()); |
| | | shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V5.getCode()); |
| | | shareStaticPerk(v5DappMemberEntities,FundFlowEnum.SHARE_PERK_V5.getCode()); |
| | | teamStaticPerkMemberLevel(v5DappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V5.getCode()); |
| | | isAllPerkMemberLevel(v5DappMemberEntities,MemberLevelEnum.V5.getType(),FundFlowEnum.ALL_PERK_V5.getCode()); |
| | | |
| | | List<DappMemberEntity> v6DappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V6.getType()); |
| | | shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V6.getCode()); |
| | | shareStaticPerk(v6DappMemberEntities,FundFlowEnum.SHARE_PERK_V6.getCode()); |
| | | teamStaticPerkMemberLevel(v6DappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V6.getCode()); |
| | | isAllPerkMemberLevel(v6DappMemberEntities,MemberLevelEnum.V6.getType(),FundFlowEnum.ALL_PERK_V6.getCode()); |
| | | |
| | | List<DappMemberEntity> v7DappMemberEntities = dappMemberDao.selectMemberByAccountType(MemberLevelEnum.V7.getType()); |
| | | shareStaticPerk(dappMemberEntities,FundFlowEnum.SHARE_PERK_V7.getCode()); |
| | | shareStaticPerk(v7DappMemberEntities,FundFlowEnum.SHARE_PERK_V7.getCode()); |
| | | teamStaticPerkMemberLevel(v7DappMemberEntities,teamPerkEquals,staticRelease,FundFlowEnum.TEAM_PERK_V7.getCode()); |
| | | isAllPerkMemberLevel(v7DappMemberEntities,MemberLevelEnum.V7.getType(),FundFlowEnum.ALL_PERK_V7.getCode()); |
| | | |
| | | } |
| | | |
| | |
| | | //实际获取总收益 |
| | | BigDecimal localTotalAchieve = BigDecimal.ZERO; |
| | | BigDecimal totalAchieve = mallAchieveRecords.stream().map(MallAchieveRecord::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | //用户每日获取的最大值 |
| | | DataDictionaryCustom maxReleaseDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.MAX_RELEASE.getType(), |
| | | DataDictionaryEnum.MAX_RELEASE.getCode() |
| | | ); |
| | | BigDecimal maxRelease = new BigDecimal(ObjectUtil.isEmpty(maxReleaseDic) ? "1" : maxReleaseDic.getValue()); |
| | | //用户每日获取的最大值 |
| | | BigDecimal maxReleaseMember = totalAchieve.multiply(maxRelease).setScale(2, BigDecimal.ROUND_DOWN); |
| | | if(amount.compareTo(maxReleaseMember) > 0){ |
| | | amount = maxReleaseMember; |
| | | } |
| | | //当日获取总收益大于总业绩 |
| | | if(amount.compareTo(totalAchieve) >= 0){ |
| | | for(MallAchieveRecord memberAchieve : mallAchieveRecords){ |
| | |
| | | */ |
| | | for(MallAchieveRecord memberAchieve : mallAchieveRecords){ |
| | | BigDecimal achieveAmount = memberAchieve.getAmount(); |
| | | if(amount.compareTo(achieveAmount) < 0){ |
| | | if(BigDecimal.ZERO.compareTo(amount) >= 0){ |
| | | break; |
| | | }else if(amount.compareTo(achieveAmount) < 0){ |
| | | memberAchieve.setAmount(achieveAmount.subtract(amount).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | mallAchieveRecordMapper.updateById(memberAchieve); |
| | | localTotalAchieve = localTotalAchieve.add(amount); |
| | |
| | | dappWalletCoinEntity.setAvailableAmount(availableAmountRelease); |
| | | dappWalletCoinDao.updateById(dappWalletCoinEntity); |
| | | |
| | | DappAccountMoneyChangeEntity record = new DappAccountMoneyChangeEntity( |
| | | memberId, |
| | | amountMagic, |
| | | maxReleaseMember, |
| | | localTotalAchieve, |
| | | FundFlowEnum.AMOUNT_RECORD.getCode(), |
| | | null); |
| | | dappAccountMoneyChangeDao.insert(record); |
| | | |
| | | //实时更新用户等级 |
| | | chainProducer.sendAutoLevelUpTeamMsg(memberId); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void speedSalePackageMsg(Long flowId) { |
| | | DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(flowId); |
| | | if(DappFundFlowEntity.WITHDRAW_STATUS_ING != dappFundFlowEntity.getStatus()){ |
| | | return; |
| | | } |
| | | BigDecimal cnt = dappFundFlowEntity.getAmount(); |
| | | Long memberId = dappFundFlowEntity.getMemberId(); |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | if(BigDecimal.ZERO.compareTo(cnt) >= 0){ |
| | | return; |
| | | } |
| | | 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 totalAmount = cnt.multiply(packageScorePrice).setScale(2, 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 poorAmount = totalAmount.multiply(packageToPoorPercent).setScale(2, BigDecimal.ROUND_DOWN); |
| | | //实际获取的金额 |
| | | BigDecimal realAmount = totalAmount.subtract(poorAmount); |
| | | //生成一条资金流水 |
| | | DappFundFlowEntity scoreFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | realAmount, |
| | | FundFlowEnum.SALE_PACKAGE_AMOUNT.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_ING, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(scoreFlow); |
| | | dappWalletCoinDao.addTotalAndaddAvailableByMemberId(memberId,realAmount); |
| | | DappFundFlowEntity feeFlow = new DappFundFlowEntity( |
| | | memberId, |
| | | poorAmount, |
| | | FundFlowEnum.SALE_PACKAGE_AMOUNT_FEE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_ING, |
| | | BigDecimal.ZERO); |
| | | dappFundFlowDao.insert(feeFlow); |
| | | |
| | | //卖出积分直接销毁。 |
| | | DataDictionaryCustom packageTotalScoreDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | 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 avaPackageTotalScore = packageTotalScore.subtract(cnt); |
| | | packageTotalScoreDic.setValue(avaPackageTotalScore.toString()); |
| | | dataDictionaryCustomMapper.updateById(packageTotalScoreDic); |
| | | //更新USDT底池 |
| | | DataDictionaryCustom packagePoorDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.PACKAGE_POOR.getType(), |
| | | DataDictionaryEnum.PACKAGE_POOR.getCode() |
| | | ); |
| | | BigDecimal packagePoor = new BigDecimal(ObjectUtil.isEmpty(packagePoorDic) ? "0" : packagePoorDic.getValue()).setScale(2, BigDecimal.ROUND_DOWN); |
| | | BigDecimal avaPackagePoor = packagePoor.add(poorAmount); |
| | | packagePoorDic.setValue(avaPackagePoor.toString()); |
| | | dataDictionaryCustomMapper.updateById(packagePoorDic); |
| | | //计算当前价格 |
| | | BigDecimal divide = avaPackagePoor.divide(avaPackageTotalScore, 2, BigDecimal.ROUND_DOWN); |
| | | packageScorePriceDic.setValue(divide.toString()); |
| | | dataDictionaryCustomMapper.updateById(packageScorePriceDic); |
| | | } |
| | | |
| | | public void shareStaticPerk(List<DappMemberEntity> dappMemberEntities, |
| | |
| | | sharePerk = maxSharePerk; |
| | | } |
| | | sendPerk(dappMemberEntity, sharePerk, dappMemberEntity.getId(), code); |
| | | } |
| | | } |
| | | |
| | | public void isAllPerkMemberLevel(List<DappMemberEntity> dappMemberEntities, |
| | | String level, |
| | | int code){ |
| | | if(CollUtil.isEmpty(dappMemberEntities)){ |
| | | return; |
| | | } |
| | | DataDictionaryCustom teamPerkMemberDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | "TEAM_LEVEL", level); |
| | | TeamLevelPerk adminAgentInfo = JSONObject.parseObject(teamPerkMemberDic.getValue(), TeamLevelPerk.class); |
| | | BigDecimal orderSalePercent = adminAgentInfo.getOrderSalePercent(); |
| | | if(BigDecimal.ZERO.compareTo(orderSalePercent) >= 0){ |
| | | return; |
| | | } |
| | | allPerkMemberLevel(dappMemberEntities,level,code); |
| | | |
| | | } |
| | | |
| | | public void allPerkMemberLevel(List<DappMemberEntity> dappMemberEntities, |
| | | String level, |
| | | int code) { |
| | | /** |
| | | * 全网24小时内的全部分红 |
| | | */ |
| | | Date createTime = DateUtil.offsetHour(DateUtil.date(),-24); |
| | | //下第一单之后的共享区全部业绩 |
| | | BigDecimal totalAchieve = mallAchieveRecordMapper.selectAchieveTotalByCreateTime(createTime); |
| | | if(BigDecimal.ZERO.compareTo(totalAchieve) >= 0){ |
| | | return; |
| | | } |
| | | DataDictionaryCustom teamPerkMemberDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | "TEAM_LEVEL", level); |
| | | TeamLevelPerk adminAgentInfo = JSONObject.parseObject(teamPerkMemberDic.getValue(), TeamLevelPerk.class); |
| | | BigDecimal orderSalePercent = adminAgentInfo.getOrderSalePercent(); |
| | | //每人平分数量 |
| | | BigDecimal divide = totalAchieve.multiply(orderSalePercent).divide(new BigDecimal(dappMemberEntities.size()), 2, BigDecimal.ROUND_DOWN); |
| | | |
| | | for(DappMemberEntity dappMemberEntity : dappMemberEntities){ |
| | | sendPerk(dappMemberEntity, divide, dappMemberEntity.getId(), code); |
| | | } |
| | | } |
| | | |
| | |
| | | if(BigDecimal.ZERO.compareTo(directReleaseAmount) >= 0){ |
| | | return realScoreReduce; |
| | | } |
| | | //插入积分流水 |
| | | DappFundFlowEntity scoreFlow = new DappFundFlowEntity( |
| | | parentMember.getId(), |
| | | realScoreReduce.negate(), |
| | | FundFlowEnum.REDUCE_SCORE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO, |
| | | orderId); |
| | | dappFundFlowDao.insert(scoreFlow); |
| | | //生成一条静态补贴的流水 |
| | | DappFundFlowEntity realUsdtAmountFlow = new DappFundFlowEntity( |
| | | parentMember.getId(), |
| | |
| | | BigDecimal.ZERO, |
| | | orderId); |
| | | dappFundFlowDao.insert(realUsdtAmountFlow); |
| | | //插入积分流水 |
| | | DappFundFlowEntity scoreFlow = new DappFundFlowEntity( |
| | | parentMember.getId(), |
| | | realScoreReduce.negate(), |
| | | FundFlowEnum.REDUCE_SCORE.getCode(), |
| | | DappFundFlowEntity.WITHDRAW_STATUS_AGREE, |
| | | BigDecimal.ZERO, |
| | | orderId); |
| | | dappFundFlowDao.insert(scoreFlow); |
| | | //插入余额流水 |
| | | DappFundFlowEntity amountFlow = new DappFundFlowEntity( |
| | | parentMember.getId(), |