| | |
| | | // System.out.println(active); |
| | | // } |
| | | // |
| | | @Test |
| | | public void updateMemberLevel(){ |
| | | Log.info("更新用户代理等级"); |
| | | DateTime date = DateUtil.date(); |
| | | //查询账户总金额大于51的有效用户 |
| | | List<DappMemberEntity> dappMemberEntities = dappWalletCoinDao.selectByIdentity(); |
| | | // List<DappMemberEntity> dappMemberEntities = dappWalletCoinDao.selectTotalAmount(); |
| | | if(CollUtil.isEmpty(dappMemberEntities)){ |
| | | //没有账户金额大于51,则全部为会员 |
| | | dappMemberDao.updateIdentity(); |
| | | }else{ |
| | | List<DappMemberEntity> LEVEL_IB = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_MB.getCode(), DataDictionaryEnum.LEVEL_IB.getCode()); |
| | | List<DappMemberEntity> LEVEL_FIB = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_IB.getCode(), DataDictionaryEnum.LEVEL_FIB.getCode()); |
| | | List<DappMemberEntity> LEVEL_CIB = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_FIB.getCode(), DataDictionaryEnum.LEVEL_CIB.getCode()); |
| | | List<DappMemberEntity> LEVEL_AIB = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_CIB.getCode(), DataDictionaryEnum.LEVEL_AIB.getCode()); |
| | | List<DappMemberEntity> LEVEL_GIB = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_AIB.getCode(), DataDictionaryEnum.LEVEL_GIB.getCode()); |
| | | List<DappMemberEntity> LEVEL_BP = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_GIB.getCode(), DataDictionaryEnum.LEVEL_BP.getCode()); |
| | | List<DappMemberEntity> LEVEL_SP = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_BP.getCode(), DataDictionaryEnum.LEVEL_SP.getCode()); |
| | | List<DappMemberEntity> LEVEL_GP = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_SP.getCode(), DataDictionaryEnum.LEVEL_GP.getCode()); |
| | | } |
| | | } |
| | | |
| | | private List<DappMemberEntity> getMemberLevelList(List<DappMemberEntity> dappMemberEntities,String identity,String identityNext){ |
| | | List<DappMemberEntity> dappMemberEntitiesNext = new ArrayList<>(); |
| | | if(CollUtil.isNotEmpty(dappMemberEntities)){ |
| | | for(DappMemberEntity dappMemberEntity : dappMemberEntities){ |
| | | if(ObjectUtil.isEmpty(dappMemberEntity)){ |
| | | continue; |
| | | } |
| | | Long memberEntityId = dappMemberEntity.getId(); |
| | | String refererId = dappMemberEntity.getRefererId(); |
| | | String inviteId = dappMemberEntity.getInviteId(); |
| | | //是否存在三条以上的推广线路,存在才能升级,不满足则 |
| | | List<DappMemberEntity> levelMbMembers = dappMemberDao.selectTotalMemberByRefererIdAndIdentity(inviteId); |
| | | if(3 > levelMbMembers.size()){ |
| | | dappMemberEntity.setIdentity(DataDictionaryEnum.LEVEL_MB.getCode()); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | continue; |
| | | } |
| | | int identityDown = 0; |
| | | for(DappMemberEntity dappMemberDown : levelMbMembers){ |
| | | //下级是否存在账户总金额大于51的会员,并且代理等级为identity |
| | | List<DappMemberEntity> levelMbMembersDown = dappMemberDao.selectTotalAmountByRefererIdAndIdentity(dappMemberDown.getInviteId(),identity); |
| | | if(CollUtil.isNotEmpty(levelMbMembersDown)){ |
| | | identityDown = identityDown + 1; |
| | | } |
| | | |
| | | } |
| | | if(identityDown >= 3){ |
| | | //设置identityNext级别 |
| | | dappMemberDao.updateIdentityByMemberId(identityNext,memberEntityId); |
| | | } |
| | | } |
| | | } |
| | | return dappMemberEntitiesNext; |
| | | } |
| | | // @Test |
| | | // public void updateMemberLevel(){ |
| | | // Log.info("更新用户代理等级"); |
| | | // DateTime date = DateUtil.date(); |
| | | // //查询账户总金额大于51的有效用户 |
| | | // List<DappMemberEntity> dappMemberEntities = dappWalletCoinDao.selectByIdentity(); |
| | | //// List<DappMemberEntity> dappMemberEntities = dappWalletCoinDao.selectTotalAmount(); |
| | | // if(CollUtil.isEmpty(dappMemberEntities)){ |
| | | // //没有账户金额大于51,则全部为会员 |
| | | // dappMemberDao.updateIdentity(); |
| | | // }else{ |
| | | // List<DappMemberEntity> LEVEL_IB = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_MB.getCode(), DataDictionaryEnum.LEVEL_IB.getCode()); |
| | | // List<DappMemberEntity> LEVEL_FIB = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_IB.getCode(), DataDictionaryEnum.LEVEL_FIB.getCode()); |
| | | // List<DappMemberEntity> LEVEL_CIB = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_FIB.getCode(), DataDictionaryEnum.LEVEL_CIB.getCode()); |
| | | // List<DappMemberEntity> LEVEL_AIB = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_CIB.getCode(), DataDictionaryEnum.LEVEL_AIB.getCode()); |
| | | // List<DappMemberEntity> LEVEL_GIB = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_AIB.getCode(), DataDictionaryEnum.LEVEL_GIB.getCode()); |
| | | // List<DappMemberEntity> LEVEL_BP = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_GIB.getCode(), DataDictionaryEnum.LEVEL_BP.getCode()); |
| | | // List<DappMemberEntity> LEVEL_SP = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_BP.getCode(), DataDictionaryEnum.LEVEL_SP.getCode()); |
| | | // List<DappMemberEntity> LEVEL_GP = getMemberLevelList(dappMemberEntities, DataDictionaryEnum.LEVEL_SP.getCode(), DataDictionaryEnum.LEVEL_GP.getCode()); |
| | | // } |
| | | // } |
| | | // |
| | | @Test |
| | | public void testProfitSharing(){ |
| | | IgtOnHookPlanOrder igtOnHookPlanOrder = igtOnHookPlanOrderDao.selectById(3220L); |
| | | if(ObjectUtil.isEmpty(igtOnHookPlanOrder)){ |
| | | return; |
| | | } |
| | | Long memberId = igtOnHookPlanOrder.getMemberId(); |
| | | BigDecimal planAmount = igtOnHookPlanOrder.getPlanAmount(); |
| | | |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | if(ObjectUtil.isEmpty(dappMemberEntity)){ |
| | | return; |
| | | } |
| | | //避免重复 |
| | | QueryWrapper<DappOnHookDone> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("order_id",igtOnHookPlanOrder.getId()); |
| | | List<DappOnHookDone> dappOnHookDones = dappOnHookDoneDao.selectList(objectQueryWrapper); |
| | | if(CollUtil.isNotEmpty(dappOnHookDones)){ |
| | | return; |
| | | } |
| | | //生成记录 |
| | | DappOnHookDone dappOnHookDone = new DappOnHookDone(dappMemberEntity.getId(), igtOnHookPlanOrder.getId()); |
| | | dappOnHookDoneDao.insert(dappOnHookDone); |
| | | //获取收益率 |
| | | DataDictionaryCustom identityDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.LEVEL_MB.getType(), dappMemberEntity.getIdentity()); |
| | | String identityDicValue = identityDic.getValue(); |
| | | JSONObject identityDicValueParse = JSONUtil.parseObj(identityDicValue); |
| | | BigDecimal hangingRevenueLevel = new BigDecimal(identityDicValueParse.get("hangingRevenue").toString()) |
| | | .multiply(new BigDecimal(0.01)).setScale(4,BigDecimal.ROUND_DOWN); |
| | | //获取收益 |
| | | //获取当前用户每分钟应该获取的收益 |
| | | BigDecimal multiply = hangingRevenueLevel.multiply(planAmount); |
| | | DataDictionaryCustom maxHoursDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MAX_HOURS.getType(), DataDictionaryEnum.MAX_HOURS.getCode()); |
| | | //挂机总时长(分钟) |
| | | BigDecimal maxHours = new BigDecimal(maxHoursDic.getValue()).multiply(new BigDecimal(60)); |
| | | //得到每分钟的收益 |
| | | BigDecimal minuteProfit = multiply.divide(maxHours, 4, BigDecimal.ROUND_DOWN); |
| | | //获取挂机开始时间到现在的总时长(分钟数) |
| | | Date startTime = igtOnHookPlanOrder.getStartTime(); |
| | | long between = DateUtil.between(startTime, DateUtil.date(), DateUnit.MINUTE); |
| | | //获得总收益 |
| | | BigDecimal totalProfit = minuteProfit.multiply(new BigDecimal(between)).setScale(4,BigDecimal.ROUND_DOWN); |
| | | // BigDecimal totalProfit = planAmount.multiply(hangingRevenueLevel).setScale(4,BigDecimal.ROUND_DOWN); |
| | | |
| | | String refererIds = dappMemberEntity.getRefererIds(); |
| | | List<String> refererIdList = StrUtil.split(refererIds, ",", -1, true, true); |
| | | //只有上级用户金额大于51U才能得到对应的佣金 |
| | | // ArrayList<String> refererIdLisstUp = new ArrayList<>(); |
| | | // for(String inviteId : refererIdList){ |
| | | // DappMemberEntity dappMemberUp = dappMemberDao.selectMemberInfoByInviteId(inviteId); |
| | | // if(ObjectUtil.isNotEmpty(dappMemberUp)){ |
| | | // DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberUp.getId()); |
| | | // if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0){ |
| | | // refererIdLisstUp.add(inviteId); |
| | | // private List<DappMemberEntity> getMemberLevelList(List<DappMemberEntity> dappMemberEntities,String identity,String identityNext){ |
| | | // List<DappMemberEntity> dappMemberEntitiesNext = new ArrayList<>(); |
| | | // if(CollUtil.isNotEmpty(dappMemberEntities)){ |
| | | // for(DappMemberEntity dappMemberEntity : dappMemberEntities){ |
| | | // if(ObjectUtil.isEmpty(dappMemberEntity)){ |
| | | // continue; |
| | | // } |
| | | // Long memberEntityId = dappMemberEntity.getId(); |
| | | // String refererId = dappMemberEntity.getRefererId(); |
| | | // String inviteId = dappMemberEntity.getInviteId(); |
| | | // //是否存在三条以上的推广线路,存在才能升级,不满足则 |
| | | // List<DappMemberEntity> levelMbMembers = dappMemberDao.selectTotalMemberByRefererIdAndIdentity(inviteId); |
| | | // if(3 > levelMbMembers.size()){ |
| | | // dappMemberEntity.setIdentity(DataDictionaryEnum.LEVEL_MB.getCode()); |
| | | // dappMemberDao.updateById(dappMemberEntity); |
| | | // continue; |
| | | // } |
| | | // int identityDown = 0; |
| | | // for(DappMemberEntity dappMemberDown : levelMbMembers){ |
| | | // //下级是否存在账户总金额大于51的会员,并且代理等级为identity |
| | | // List<DappMemberEntity> levelMbMembersDown = dappMemberDao.selectTotalAmountByRefererIdAndIdentity(dappMemberDown.getInviteId(),identity); |
| | | // if(CollUtil.isNotEmpty(levelMbMembersDown)){ |
| | | // identityDown = identityDown + 1; |
| | | // } |
| | | // |
| | | // } |
| | | // if(identityDown >= 3){ |
| | | // //设置identityNext级别 |
| | | // dappMemberDao.updateIdentityByMemberId(identityNext,memberEntityId); |
| | | // } |
| | | // } |
| | | // } |
| | | //生成流水佣金和盈利分成和流水记录,返回剩余盈利 |
| | | BigDecimal profitSharingTotal = dappWalletService.updateLSYJYLFC(refererIdList, totalProfit,igtOnHookPlanOrder.getId()); |
| | | //平台分成 |
| | | //平台拿走35%盈利分成和流水佣金剩下的全部 |
| | | BigDecimal systemAdd = totalProfit.multiply(new BigDecimal(0.4)).subtract(profitSharingTotal); |
| | | BigDecimal systemTotal = dappWalletService.updatePTFC(memberId,systemAdd,igtOnHookPlanOrder.getId()); |
| | | //个人固定拿走60% |
| | | totalProfit = totalProfit.multiply(new BigDecimal(0.6)); |
| | | igtOnHookPlanOrder.setState(2); |
| | | //一次挂机剩余的全部金额 |
| | | BigDecimal totalMoney = totalProfit.add(planAmount); |
| | | |
| | | igtOnHookPlanOrder.setProfit(totalProfit); |
| | | igtOnHookPlanOrderDao.updateById(igtOnHookPlanOrder); |
| | | dappMemberEntity.setIsOnHook(3); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | |
| | | DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(memberId); |
| | | BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount(); |
| | | dappWalletCoinDao.addTotalAndaddAvailableById(dappWalletCoinEntity.getId(),totalMoney); |
| | | |
| | | BigDecimal add = availableAmount.add(totalMoney); |
| | | BigDecimal subtract = add.subtract(totalProfit); |
| | | DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(memberId, subtract, totalProfit, add, "投注盈利", 5,igtOnHookPlanOrder.getId()); |
| | | dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity); |
| | | |
| | | } |
| | | // return dappMemberEntitiesNext; |
| | | // } |
| | | //// |
| | | // @Test |
| | | // public void testProfitSharing(){ |
| | | // IgtOnHookPlanOrder igtOnHookPlanOrder = igtOnHookPlanOrderDao.selectById(3220L); |
| | | // if(ObjectUtil.isEmpty(igtOnHookPlanOrder)){ |
| | | // return; |
| | | // } |
| | | // Long memberId = igtOnHookPlanOrder.getMemberId(); |
| | | // BigDecimal planAmount = igtOnHookPlanOrder.getPlanAmount(); |
| | | // |
| | | // DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | // if(ObjectUtil.isEmpty(dappMemberEntity)){ |
| | | // return; |
| | | // } |
| | | // //避免重复 |
| | | // QueryWrapper<DappOnHookDone> objectQueryWrapper = new QueryWrapper<>(); |
| | | // objectQueryWrapper.eq("order_id",igtOnHookPlanOrder.getId()); |
| | | // List<DappOnHookDone> dappOnHookDones = dappOnHookDoneDao.selectList(objectQueryWrapper); |
| | | // if(CollUtil.isNotEmpty(dappOnHookDones)){ |
| | | // return; |
| | | // } |
| | | // //生成记录 |
| | | // DappOnHookDone dappOnHookDone = new DappOnHookDone(dappMemberEntity.getId(), igtOnHookPlanOrder.getId()); |
| | | // dappOnHookDoneDao.insert(dappOnHookDone); |
| | | // //获取收益率 |
| | | // DataDictionaryCustom identityDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.LEVEL_MB.getType(), dappMemberEntity.getIdentity()); |
| | | // String identityDicValue = identityDic.getValue(); |
| | | // JSONObject identityDicValueParse = JSONUtil.parseObj(identityDicValue); |
| | | // BigDecimal hangingRevenueLevel = new BigDecimal(identityDicValueParse.get("hangingRevenue").toString()) |
| | | // .multiply(new BigDecimal(0.01)).setScale(4,BigDecimal.ROUND_DOWN); |
| | | // //获取收益 |
| | | // //获取当前用户每分钟应该获取的收益 |
| | | // BigDecimal multiply = hangingRevenueLevel.multiply(planAmount); |
| | | // DataDictionaryCustom maxHoursDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MAX_HOURS.getType(), DataDictionaryEnum.MAX_HOURS.getCode()); |
| | | // //挂机总时长(分钟) |
| | | // BigDecimal maxHours = new BigDecimal(maxHoursDic.getValue()).multiply(new BigDecimal(60)); |
| | | // //得到每分钟的收益 |
| | | // BigDecimal minuteProfit = multiply.divide(maxHours, 4, BigDecimal.ROUND_DOWN); |
| | | // //获取挂机开始时间到现在的总时长(分钟数) |
| | | // Date startTime = igtOnHookPlanOrder.getStartTime(); |
| | | // long between = DateUtil.between(startTime, DateUtil.date(), DateUnit.MINUTE); |
| | | // //获得总收益 |
| | | // BigDecimal totalProfit = minuteProfit.multiply(new BigDecimal(between)).setScale(4,BigDecimal.ROUND_DOWN); |
| | | //// BigDecimal totalProfit = planAmount.multiply(hangingRevenueLevel).setScale(4,BigDecimal.ROUND_DOWN); |
| | | // |
| | | // String refererIds = dappMemberEntity.getRefererIds(); |
| | | // List<String> refererIdList = StrUtil.split(refererIds, ",", -1, true, true); |
| | | // //只有上级用户金额大于51U才能得到对应的佣金 |
| | | //// ArrayList<String> refererIdLisstUp = new ArrayList<>(); |
| | | //// for(String inviteId : refererIdList){ |
| | | //// DappMemberEntity dappMemberUp = dappMemberDao.selectMemberInfoByInviteId(inviteId); |
| | | //// if(ObjectUtil.isNotEmpty(dappMemberUp)){ |
| | | //// DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(dappMemberUp.getId()); |
| | | //// if(AppContants.ONHOOK_BASIC_AMOUNT.compareTo(dappWalletCoinEntity.getAvailableAmount())<=0){ |
| | | //// refererIdLisstUp.add(inviteId); |
| | | //// } |
| | | //// } |
| | | //// } |
| | | // //生成流水佣金和盈利分成和流水记录,返回剩余盈利 |
| | | // BigDecimal profitSharingTotal = dappWalletService.updateLSYJYLFC(refererIdList, totalProfit,igtOnHookPlanOrder.getId()); |
| | | // //平台分成 |
| | | // //平台拿走35%盈利分成和流水佣金剩下的全部 |
| | | // BigDecimal systemAdd = totalProfit.multiply(new BigDecimal(0.4)).subtract(profitSharingTotal); |
| | | // BigDecimal systemTotal = dappWalletService.updatePTFC(memberId,systemAdd,igtOnHookPlanOrder.getId()); |
| | | // //个人固定拿走60% |
| | | // totalProfit = totalProfit.multiply(new BigDecimal(0.6)); |
| | | // igtOnHookPlanOrder.setState(2); |
| | | // //一次挂机剩余的全部金额 |
| | | // BigDecimal totalMoney = totalProfit.add(planAmount); |
| | | // |
| | | // igtOnHookPlanOrder.setProfit(totalProfit); |
| | | // igtOnHookPlanOrderDao.updateById(igtOnHookPlanOrder); |
| | | // dappMemberEntity.setIsOnHook(3); |
| | | // dappMemberDao.updateById(dappMemberEntity); |
| | | // |
| | | // DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(memberId); |
| | | // BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount(); |
| | | // dappWalletCoinDao.addTotalAndaddAvailableById(dappWalletCoinEntity.getId(),totalMoney); |
| | | // |
| | | // BigDecimal add = availableAmount.add(totalMoney); |
| | | // BigDecimal subtract = add.subtract(totalProfit); |
| | | // DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(memberId, subtract, totalProfit, add, "投注盈利", 5,igtOnHookPlanOrder.getId()); |
| | | // dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity); |
| | | // |
| | | // } |
| | | // |
| | | // @Test |
| | | // public void createAwardInfo(){ |