| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void endOnHookMessage(Long orderId) { |
| | | IgtOnHookPlanOrder igtOnHookPlanOrder = igtOnHookPlanOrderDao.selectById(orderId); |
| | | 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 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,igtOnHookPlanOrder.getId()); |
| | | //平台分成,返回剩余盈利 |
| | | BigDecimal systemTotal = dappWalletService.updatePTFC(memberId,totalProfit,igtOnHookPlanOrder.getId()); |
| | | 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,igtOnHookPlanOrder.getId()); |
| | | dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity); |
| | | |
| | | } |
| | | |
| | | private String getProfitCase(String identity,BigDecimal balance){ |
| | | //匹配会员等级获取对应的收益率 |
| | | List<DataDictionaryCustom> dataDictionaryCustoms = dataDictionaryCustomMapper.selectDicByType(DataDictionaryEnum.LEVEL_MB.getType()); |