| | |
| | | import cc.mrbird.febs.dapp.mapper.*; |
| | | import cc.mrbird.febs.dapp.service.ApiIgtOnHookPlanService; |
| | | import cc.mrbird.febs.dapp.service.DappWalletService; |
| | | import cc.mrbird.febs.rabbit.producer.UsdtUpdateProducer; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.date.DateTime; |
| | | import cn.hutool.core.date.DateUtil; |
| | |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.text.DecimalFormat; |
| | | import java.text.Format; |
| | |
| | | |
| | | @Autowired |
| | | private ApiIgtOnHookPlanService apiIgtOnHookPlanService; |
| | | |
| | | @Autowired |
| | | private DappOnHookDoneDao dappOnHookDoneDao; |
| | | |
| | | /** |
| | | * 五分钟更新一次数据 |
| | |
| | | // igtOnHookPlanOrder.setState(3); |
| | | // igtOnHookPlanOrderDao.updateById(igtOnHookPlanOrder); |
| | | // }else{ |
| | | // //获取收益率 |
| | | //获取收益率 |
| | | // DappMemberEntity dappMemberEntity = dappMemberDao.selectById(igtOnHookPlanOrder.getMemberId()); |
| | | // DataDictionaryCustom identityDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.LEVEL_MB.getType(), dappMemberEntity.getIdentity()); |
| | | // String identityDicValue = identityDic.getValue(); |
| | |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | private UsdtUpdateProducer usdtUpdateProducer; |
| | | |
| | | /** |
| | | * 挂机结束时间一到,所有挂机停止开始计算收益 |
| | | * 根据设置的会员等级对应的(收益率*挂机本金)/(挂机时长*60分钟)=每分钟的收益 |
| | | * 计算每个挂机的挂机时长*每分钟的收益 |
| | | */ |
| | | @Scheduled(cron = "0 0/1 * * * ? ") |
| | | public void endOnHookPlan(){ |
| | | Log.info("挂机结束时间到了"); |
| | | DataDictionaryCustom endTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.END_TIME.getType(), DataDictionaryEnum.END_TIME.getCode()); |
| | | DateTime date = DateUtil.date(); |
| | | DateTime endTime = DateUtil.parseDate(endTimeDic.getValue()); |
| | | if(DateUtil.compare(endTime,date)>=0){ |
| | | // |
| | | igtOnHookPlanOrderDao.updatePlanOrder(); |
| | | } |
| | | } |
| | | |
| | | // @Scheduled(cron = "0/5 * * * * ? ") |
| | | @Scheduled(cron = "0 0/1 * * * ? ") |
| | | public void updatePlanOrder(){ |
| | | Log.info("开始更新挂机主表状态"); |
| | | |
| | | List<IgtOnHookPlanOrder> igtOnHookPlanOrders = igtOnHookPlanOrderDao.selectByState(3); |
| | | if(CollUtil.isNotEmpty(igtOnHookPlanOrders)){ |
| | | for(IgtOnHookPlanOrder igtOnHookPlanOrder : igtOnHookPlanOrders){ |
| | | Long orderId = igtOnHookPlanOrder.getId(); |
| | | Long memberId = igtOnHookPlanOrder.getMemberId(); |
| | | BigDecimal planAmount = igtOnHookPlanOrder.getPlanAmount(); |
| | | BigDecimal avaAmount = igtOnHookPlanOrder.getAvaAmount(); |
| | | //总盈利 |
| | | // BigDecimal totalProfit = igtOnHookPlanOrderItemDao.selectTotalProfitByByOrderIdAndMemberIdAndState(orderId,memberId,1,2); |
| | | BigDecimal totalProfit = igtOnHookPlanOrder.getProfit(); |
| | | |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | 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); |
| | | |
| | | |
| | | //获取用户信息的是否盈利字段 |
| | | DappMemberEntity dappMember = dappMemberDao.selectById(memberId); |
| | | Integer isProfit = dappMember.getIsProfit() == null ? 1 : dappMember.getIsProfit(); |
| | | |
| | | igtOnHookPlanOrder.setState(2); |
| | | //一次挂机剩余的全部金额 |
| | | BigDecimal totalMoney = totalProfit.add(avaAmount); |
| | | if(totalMoney.compareTo(planAmount)<=0){ |
| | | igtOnHookPlanOrder.setProfitState(2); |
| | | }else{ |
| | | igtOnHookPlanOrder.setProfitState(1); |
| | | } |
| | | 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); |
| | | usdtUpdateProducer.sendOnHookEnd(igtOnHookPlanOrder.getId()); |
| | | } |
| | | } |
| | | |