| | |
| | | // private RedisUtils redisUtils; |
| | | // @Autowired |
| | | // private DappOnHookAwardDao dappOnHookAwardDao; |
| | | // @Autowired |
| | | // private DappOnHookDoneDao dappOnHookDoneDao; |
| | | @Autowired |
| | | private DappOnHookDoneDao dappOnHookDoneDao; |
| | | // @Autowired |
| | | // private DappWalletService dappWalletService; |
| | | // @Autowired |
| | |
| | | // |
| | | @Autowired |
| | | private DappWalletCoinDao dappWalletCoinDao; |
| | | // |
| | | // @Autowired |
| | | // private DappAccountMoneyChangeDao dappAccountMoneyChangeDao; |
| | | |
| | | @Autowired |
| | | private DappAccountMoneyChangeDao dappAccountMoneyChangeDao; |
| | | // |
| | | // @Autowired |
| | | // private DappMemberDao dappMemberDao; |
| | |
| | | // @Autowired |
| | | // private RedisUtils redisUtils; |
| | | // |
| | | // @Autowired |
| | | // private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | @Autowired |
| | | private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | // |
| | | // @Autowired |
| | | // private DappWalletService dappWalletService; |
| | | @Autowired |
| | | private DappWalletService dappWalletService; |
| | | // |
| | | // |
| | | // @Value("${spring.profiles.active}") |
| | |
| | | return dappMemberEntitiesNext; |
| | | } |
| | | // |
| | | // @Test |
| | | // public void testProfitSharing(){ |
| | | // Log.info("开始更新挂机主表状态"); |
| | | // long current = DateUtil.currentSeconds(); |
| | | // Log.info("开始时间"+current); |
| | | // Log.info("开始更新挂机主表状态"); |
| | | // List<IgtOnHookPlanOrder> igtOnHookPlanOrders = igtOnHookPlanOrderDao.selectByState(3); |
| | | // if(CollUtil.isNotEmpty(igtOnHookPlanOrders)){ |
| | | // List<Long> ids = igtOnHookPlanOrderDao.selectIdsByState(3); |
| | | // //更新状态避免重复查询 |
| | | // igtOnHookPlanOrderDao.updateByIds(ids); |
| | | // for(IgtOnHookPlanOrder igtOnHookPlanOrder : igtOnHookPlanOrders){ |
| | | // Long memberId = igtOnHookPlanOrder.getMemberId(); |
| | | // BigDecimal planAmount = igtOnHookPlanOrder.getPlanAmount(); |
| | | // |
| | | // DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | // //获取收益率 |
| | | // 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); |
| | | // //获取收益 |
| | | @Test |
| | | public void testProfitSharing(){ |
| | | IgtOnHookPlanOrder igtOnHookPlanOrder = igtOnHookPlanOrderDao.selectById(3004L); |
| | | 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); |
| | | // //生成流水佣金和盈利分成和流水记录,返回剩余盈利 |
| | | // BigDecimal profitSharingTotal = dappWalletService.updateLSYJYLFC(refererIdList, totalProfit); |
| | | // //平台分成,返回剩余盈利 |
| | | // BigDecimal systemTotal = dappWalletService.updatePTFC(memberId,totalProfit); |
| | | // totalProfit = totalProfit.subtract(profitSharingTotal).subtract(systemTotal); |
| | | // |
| | | // 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); |
| | | // dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity); |
| | | |
| | | 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); |
| | | // } |
| | | // } |
| | | // |
| | | // Long totalTime=DateUtil.currentSeconds()-current; |
| | | // System.out.println("======消耗时间======="+totalTime+"ms"); |
| | | // |
| | | // } |
| | | //生成流水佣金和盈利分成和流水记录,返回剩余盈利 |
| | | 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(){ |