| | |
| | | |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.dapp.entity.*; |
| | | import cc.mrbird.febs.dapp.enumerate.DataDictionaryEnum; |
| | | 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 cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jline.utils.Log; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | 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; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | | @Component |
| | |
| | | @Autowired |
| | | private RedisUtils redisUtils; |
| | | |
| | | @Autowired |
| | | private DataDictionaryCustomMapper dataDictionaryCustomMapper; |
| | | |
| | | @Autowired |
| | | private DappWalletService dappWalletService; |
| | | |
| | | @Autowired |
| | | private ApiIgtOnHookPlanService apiIgtOnHookPlanService; |
| | | |
| | | @Autowired |
| | | private DappOnHookDoneDao dappOnHookDoneDao; |
| | | |
| | | /** |
| | | * 五分钟更新一次数据 |
| | | * 让挂机字表的状态为1:已生效 |
| | |
| | | @Scheduled(cron = "0 0/5 * * * ? ") |
| | | public void updatePlanOrderItem(){ |
| | | Log.info("开始更新挂机子表状态"); |
| | | List<IgtOnHookPlanOrder> igtOnHookPlanOrders = igtOnHookPlanOrderDao.selectByState(1); |
| | | if(CollUtil.isEmpty(igtOnHookPlanOrders)){ |
| | | return; |
| | | } |
| | | for(IgtOnHookPlanOrder igtOnHookPlanOrder : igtOnHookPlanOrders){ |
| | | //让挂机子表的状态为1:已生效 |
| | | Long orderId = igtOnHookPlanOrder.getId(); |
| | | Long memberId = igtOnHookPlanOrder.getMemberId(); |
| | | IgtOnHookPlanOrderItem igtOnHookPlanOrderItem = igtOnHookPlanOrderItemDao.selectByOrderIdAndMemberIdAndState(orderId,memberId,2); |
| | | if(ObjectUtil.isNotEmpty(igtOnHookPlanOrderItem)){ |
| | | igtOnHookPlanOrderItem.setState(1); |
| | | igtOnHookPlanOrderItemDao.updateById(igtOnHookPlanOrderItem); |
| | | if(BigDecimal.ZERO.compareTo(igtOnHookPlanOrderItem.getProfit()) < 0){ |
| | | //增加挂机主表的挂机总收益和增加挂机剩余金额 |
| | | Integer updateCount = igtOnHookPlanOrderDao.addAvaAmountAddProfitById(igtOnHookPlanOrder.getId() |
| | | ,igtOnHookPlanOrderItem.getProfit() |
| | | ,igtOnHookPlanOrderItem.getAmount()); |
| | | }else{ |
| | | //增加挂机主表的挂机总收益和减少挂机剩余金额 |
| | | Integer updateCount = igtOnHookPlanOrderDao.updateAvaAmountById(igtOnHookPlanOrder.getId() |
| | | ,igtOnHookPlanOrderItem.getProfit() |
| | | ,igtOnHookPlanOrderItem.getAmount()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | apiIgtOnHookPlanService.updatePlanOrderItem(); |
| | | // List<IgtOnHookPlanOrder> igtOnHookPlanOrders = igtOnHookPlanOrderDao.selectByState(1); |
| | | // if(CollUtil.isEmpty(igtOnHookPlanOrders)){ |
| | | // return; |
| | | // } |
| | | // String redisKey = ""; |
| | | // if("prod".equals(active)){ |
| | | // redisKey = "on_hook_award_id"; |
| | | // }else{ |
| | | // redisKey = "on_hook_award_id_test"; |
| | | // } |
| | | // String onHookAwardRedisId = redisUtils.getString(redisKey); |
| | | // DappOnHookAward dappOnHookAward = dappOnHookAwardDao.selectById(Long.parseLong(onHookAwardRedisId)); |
| | | // Date awardTime = dappOnHookAward.getAwardTime(); |
| | | // DateTime dateTime = DateUtil.offsetMinute(awardTime, 5); |
| | | // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | // String yyyyMMddHHMM = sdf.format(dateTime); |
| | | // DappOnHookAward dappOnHookAwardNext = dappOnHookAwardDao.selectByByAwardTime(yyyyMMddHHMM); |
| | | // |
| | | // //系统挂机总次数 = 时长 * 60 / 5 |
| | | // DataDictionaryCustom maxHoursDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.MAX_HOURS.getType(), DataDictionaryEnum.MAX_HOURS.getCode()); |
| | | // Float maxHours = Float.parseFloat(maxHoursDic.getValue()); |
| | | // maxHours = maxHours * 60 / 5; |
| | | // |
| | | // for(IgtOnHookPlanOrder igtOnHookPlanOrder : igtOnHookPlanOrders){ |
| | | // BigDecimal avaAmount = igtOnHookPlanOrder.getAvaAmount(); |
| | | // if(avaAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | // /** |
| | | // * 获取下一个开奖记录 |
| | | // * 生成一条开奖字表记录 |
| | | // * 计算收益 |
| | | // */ |
| | | // |
| | | // List<IgtOnHookPlanOrderItem> igtOnHookPlanOrderItemsOld = igtOnHookPlanOrderItemDao.selectByIgtIdAndMemberId(igtOnHookPlanOrder.getId(),igtOnHookPlanOrder.getMemberId()); |
| | | // //如果没有中奖记录则是新增一条1挂机方案的挂机子表记录 |
| | | // if(CollUtil.isEmpty(igtOnHookPlanOrderItemsOld)){ |
| | | // |
| | | // IgtOnHookPlanOrderItem igtOnHookPlanOrderItem = new IgtOnHookPlanOrderItem(); |
| | | // igtOnHookPlanOrderItem.setMemberId(igtOnHookPlanOrder.getMemberId()); |
| | | // igtOnHookPlanOrderItem.setOrderId(igtOnHookPlanOrder.getId()); |
| | | // //获取挂机方案 |
| | | // DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.PLAN_A.getType(), DataDictionaryEnum.PLAN_A.getCode()); |
| | | // String dataDictionaryCustomValue = dataDictionaryCustom.getValue(); |
| | | // JSONObject levelMemberValueParse = JSONUtil.parseObj(dataDictionaryCustomValue); |
| | | // BigDecimal amountPlanA = new BigDecimal(levelMemberValueParse.get("amount").toString()) |
| | | // .multiply(new BigDecimal(igtOnHookPlanOrder.getPlanCode())).setScale(4,BigDecimal.ROUND_DOWN); |
| | | // igtOnHookPlanOrderItem.setAmount(amountPlanA); |
| | | // //获取收益率 |
| | | // DappMemberEntity dappMemberEntity = dappMemberDao.selectById(igtOnHookPlanOrder.getMemberId()); |
| | | // 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 profit = amountPlanA.multiply(hangingRevenueLevel).setScale(4,BigDecimal.ROUND_DOWN); |
| | | // igtOnHookPlanOrderItem.setProfit(profit.setScale(4,BigDecimal.ROUND_DOWN)); |
| | | // |
| | | // igtOnHookPlanOrderItem.setState(1); |
| | | // igtOnHookPlanOrderItem.setPlanCode(igtOnHookPlanOrder.getPlanCode()); |
| | | // |
| | | // Integer isGoal = dappWalletService.isGoal(dappOnHookAwardNext.getAwardNum()); |
| | | // igtOnHookPlanOrderItem.setIsGoal(isGoal); |
| | | // igtOnHookPlanOrderItem.setBelongNum(dappOnHookAwardNext.getRecordNum()); |
| | | // igtOnHookPlanOrderItem.setOrderNum(1); |
| | | // igtOnHookPlanOrderItem.setPlan(dataDictionaryCustom.getDescription()); |
| | | // igtOnHookPlanOrderItemDao.insert(igtOnHookPlanOrderItem); |
| | | // |
| | | // if(2 == igtOnHookPlanOrderItem.getIsGoal()){ |
| | | // //如果中奖,增加挂机主表的挂机总收益 |
| | | // Integer updateCount = igtOnHookPlanOrderDao.AddProfitById(igtOnHookPlanOrder.getId() |
| | | // ,igtOnHookPlanOrderItem.getProfit()); |
| | | // }else{ |
| | | // //如果不中奖,减少挂机剩余金额即减少本金 |
| | | // Integer updateCount = igtOnHookPlanOrderDao.updateAvaAmountById(igtOnHookPlanOrder.getId() |
| | | // ,igtOnHookPlanOrderItem.getAmount()); |
| | | // } |
| | | // }else if(2 == igtOnHookPlanOrderItemsOld.get(0).getIsGoal()){ |
| | | // //第一条中奖记录为中奖则是新增一条1挂机方案的挂机子表记录 |
| | | // IgtOnHookPlanOrderItem igtOnHookPlanOrderItem = new IgtOnHookPlanOrderItem(); |
| | | // igtOnHookPlanOrderItem.setMemberId(igtOnHookPlanOrder.getMemberId()); |
| | | // igtOnHookPlanOrderItem.setOrderId(igtOnHookPlanOrder.getId()); |
| | | // //获取挂机方案 |
| | | // DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.PLAN_A.getType(), DataDictionaryEnum.PLAN_A.getCode()); |
| | | // String dataDictionaryCustomValue = dataDictionaryCustom.getValue(); |
| | | // JSONObject levelMemberValueParse = JSONUtil.parseObj(dataDictionaryCustomValue); |
| | | // BigDecimal amountPlanA = new BigDecimal(levelMemberValueParse.get("amount").toString()) |
| | | // .multiply(new BigDecimal(igtOnHookPlanOrder.getPlanCode())).setScale(4,BigDecimal.ROUND_DOWN); |
| | | // //此次下注金额不足,则更新主表信息为结算中 |
| | | // //挂机次数超过系统规定的时间,则更新主表信息为结算中 |
| | | // if(avaAmount.compareTo(amountPlanA) < 0 || igtOnHookPlanOrderItemsOld.get(0).getOrderNum() >= maxHours){ |
| | | // igtOnHookPlanOrder.setState(3); |
| | | // igtOnHookPlanOrderDao.updateById(igtOnHookPlanOrder); |
| | | // }else{ |
| | | // igtOnHookPlanOrderItem.setAmount(amountPlanA); |
| | | // //获取收益率 |
| | | // DappMemberEntity dappMemberEntity = dappMemberDao.selectById(igtOnHookPlanOrder.getMemberId()); |
| | | // 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 profit = amountPlanA.multiply(hangingRevenueLevel).setScale(4,BigDecimal.ROUND_DOWN); |
| | | // igtOnHookPlanOrderItem.setProfit(profit.setScale(4,BigDecimal.ROUND_DOWN)); |
| | | // |
| | | // igtOnHookPlanOrderItem.setState(1); |
| | | // igtOnHookPlanOrderItem.setPlanCode(igtOnHookPlanOrder.getPlanCode()); |
| | | // |
| | | // Integer isGoal = dappWalletService.isGoal(dappOnHookAwardNext.getAwardNum()); |
| | | // igtOnHookPlanOrderItem.setIsGoal(isGoal); |
| | | // igtOnHookPlanOrderItem.setBelongNum(dappOnHookAwardNext.getRecordNum()); |
| | | // igtOnHookPlanOrderItem.setOrderNum(igtOnHookPlanOrderItemsOld.get(0).getOrderNum() + 1); |
| | | // igtOnHookPlanOrderItem.setPlan(dataDictionaryCustom.getDescription()); |
| | | // igtOnHookPlanOrderItemDao.insert(igtOnHookPlanOrderItem); |
| | | // |
| | | // if(2 == igtOnHookPlanOrderItem.getIsGoal()){ |
| | | // |
| | | // //如果中奖,增加挂机主表的挂机总收益 |
| | | // Integer updateCount = igtOnHookPlanOrderDao.AddProfitById(igtOnHookPlanOrder.getId() |
| | | // ,igtOnHookPlanOrderItem.getProfit()); |
| | | // }else{ |
| | | // //如果不中奖,减少挂机剩余金额即减少本金 |
| | | // Integer updateCount = igtOnHookPlanOrderDao.updateAvaAmountById(igtOnHookPlanOrder.getId() |
| | | // ,igtOnHookPlanOrderItem.getAmount()); |
| | | // } |
| | | // } |
| | | // }else{ |
| | | // //第一条没中奖则是新增一条n+1挂机方案的挂机子表记录 |
| | | // String plan = igtOnHookPlanOrderItemsOld.get(0).getPlan(); |
| | | // IgtOnHookPlanOrderItem igtOnHookPlanOrderItem = new IgtOnHookPlanOrderItem(); |
| | | // igtOnHookPlanOrderItem.setMemberId(igtOnHookPlanOrder.getMemberId()); |
| | | // igtOnHookPlanOrderItem.setOrderId(igtOnHookPlanOrder.getId()); |
| | | // //获取挂机方案 |
| | | // DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectDicDataByTypeAndCodeAndDesc( |
| | | // DataDictionaryEnum.PLAN_A.getType(), |
| | | // Integer.toString(Integer.parseInt(plan)+1)); |
| | | // if(ObjectUtil.isEmpty(dataDictionaryCustom)){ |
| | | // igtOnHookPlanOrder.setState(3); |
| | | // igtOnHookPlanOrderDao.updateById(igtOnHookPlanOrder); |
| | | // return; |
| | | // } |
| | | // String dataDictionaryCustomValue = dataDictionaryCustom.getValue(); |
| | | // JSONObject levelMemberValueParse = JSONUtil.parseObj(dataDictionaryCustomValue); |
| | | // BigDecimal amountPlanA = new BigDecimal(levelMemberValueParse.get("amount").toString()) |
| | | // .multiply(new BigDecimal(igtOnHookPlanOrder.getPlanCode())).setScale(4,BigDecimal.ROUND_DOWN); |
| | | // igtOnHookPlanOrderItem.setAmount(amountPlanA); |
| | | // //此次下注金额不足,则更新主表信息为结算中 |
| | | // if(avaAmount.compareTo(amountPlanA) < 0 || igtOnHookPlanOrderItemsOld.get(0).getOrderNum() >= maxHours){ |
| | | // 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(); |
| | | // JSONObject identityDicValueParse = JSONUtil.parseObj(identityDicValue); |
| | | // BigDecimal hangingRevenueLevel = new BigDecimal(identityDicValueParse.get("hangingRevenue").toString()) |
| | | // .multiply(new BigDecimal(0.01)).setScale(4,BigDecimal.ROUND_DOWN); |
| | | // //获取收益 |
| | | // BigDecimal profit = amountPlanA.multiply(hangingRevenueLevel).setScale(4,BigDecimal.ROUND_DOWN); |
| | | // igtOnHookPlanOrderItem.setProfit(profit.setScale(4,BigDecimal.ROUND_DOWN)); |
| | | // |
| | | // igtOnHookPlanOrderItem.setState(1); |
| | | // igtOnHookPlanOrderItem.setPlanCode(igtOnHookPlanOrder.getPlanCode()); |
| | | // |
| | | // Integer isGoal = dappWalletService.isGoal(dappOnHookAwardNext.getAwardNum()); |
| | | // igtOnHookPlanOrderItem.setIsGoal(isGoal); |
| | | // igtOnHookPlanOrderItem.setBelongNum(dappOnHookAwardNext.getRecordNum()); |
| | | // igtOnHookPlanOrderItem.setOrderNum(igtOnHookPlanOrderItemsOld.get(0).getOrderNum() + 1); |
| | | // igtOnHookPlanOrderItem.setPlan(dataDictionaryCustom.getDescription()); |
| | | // igtOnHookPlanOrderItemDao.insert(igtOnHookPlanOrderItem); |
| | | // |
| | | // if(2 == igtOnHookPlanOrderItem.getIsGoal()){ |
| | | // //返还两次中奖之间的本金 |
| | | // Date endTime = igtOnHookPlanOrderItem.getCreateTime(); |
| | | // Date startTime = null; |
| | | // //返回上次中奖的记录 |
| | | // IgtOnHookPlanOrderItem igtOld = igtOnHookPlanOrderItemDao.selectByCreateTimeAndIsgoaAndOrderId(endTime,2,igtOnHookPlanOrder.getId()); |
| | | // if(ObjectUtil.isNotEmpty(igtOld)){ |
| | | // startTime = igtOld.getCreateTime(); |
| | | // } |
| | | // BigDecimal totalAmount = igtOnHookPlanOrderItemDao.selectTotalAmountByCreateTimeAndOrderId(startTime,endTime,igtOnHookPlanOrderItem.getOrderId()); |
| | | // //如果中奖,增加挂机主表的挂机总收益,返还两次中奖之间的本金 |
| | | // igtOnHookPlanOrderDao.AddProfitById(igtOnHookPlanOrder.getId() |
| | | // ,igtOnHookPlanOrderItem.getProfit()); |
| | | // igtOnHookPlanOrderDao.addAvaAmountById(igtOnHookPlanOrder.getId() |
| | | // ,totalAmount); |
| | | // }else{ |
| | | // //如果不中奖,减少挂机剩余金额即减少本金 |
| | | // Integer updateCount = igtOnHookPlanOrderDao.updateAvaAmountById(igtOnHookPlanOrder.getId() |
| | | // ,igtOnHookPlanOrderItem.getAmount()); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | /** |
| | | * 根据订单主表获取订单主表中还在开始状态的订单 |
| | | * 查询相关关联的子表 |
| | | * 如果子表中的关联数据都已经 生效状态 1:已生效,则 |
| | | * 1、更新主表状态为结束 |
| | | * 2、计算总盈利 |
| | | * 3、更新用户的余额和总额 |
| | | * 4、生成一条资金流水记录 |
| | | * 5、TODO |
| | | * 根据会员等级计算其他的流水,比如分佣金这类操作 |
| | | */ |
| | | |
| | | @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.parseTimeToday(endTimeDic.getValue()); |
| | | |
| | | //系统开关 |
| | | DataDictionaryCustom onOff = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(DataDictionaryEnum.ON_OFF.getType(), DataDictionaryEnum.ON_OFF.getCode()); |
| | | String onOffStr = onOff.getValue() == null ? "OFF":onOff.getValue(); |
| | | if(DateUtil.compare(date,endTime)>=0 || "ON".equals(onOffStr)){ |
| | | igtOnHookPlanOrderDao.updatePlanOrder(); |
| | | } |
| | | } |
| | | |
| | | // @Scheduled(cron = "0/5 * * * * ? ") |
| | | @Scheduled(cron = "0 0/1 * * * ? ") |
| | | public void updatePlanOrder(){ |
| | | Log.info("开始更新挂机主表状态"); |
| | | |
| | | List<IgtOnHookPlanOrder> igtOnHookPlanOrders = igtOnHookPlanOrderDao.selectByState(1); |
| | | if(CollUtil.isEmpty(igtOnHookPlanOrders)){ |
| | | return; |
| | | } |
| | | for(IgtOnHookPlanOrder igtOnHookPlanOrder : igtOnHookPlanOrders){ |
| | | Long orderId = igtOnHookPlanOrder.getId(); |
| | | Long memberId = igtOnHookPlanOrder.getMemberId(); |
| | | BigDecimal planAmount = igtOnHookPlanOrder.getPlanAmount(); |
| | | BigDecimal avaAmount = igtOnHookPlanOrder.getAvaAmount(); |
| | | IgtOnHookPlanOrderItem igtOnHookPlanOrderItem = igtOnHookPlanOrderItemDao.selectByOrderIdAndMemberIdAndState(orderId,memberId,2); |
| | | if(ObjectUtil.isEmpty(igtOnHookPlanOrderItem)){ |
| | | BigDecimal totalProfit = igtOnHookPlanOrderItemDao.selectTotalProfitByByOrderIdAndMemberIdAndState(orderId,memberId,1,2); |
| | | BigDecimal totalAmount = igtOnHookPlanOrderItemDao.selectTotalAmountByByOrderIdAndMemberIdAndState(orderId,memberId,1,2); |
| | | igtOnHookPlanOrder.setState(2); |
| | | //一次挂机剩余的全部金额 |
| | | BigDecimal totalMoney = totalAmount.add(totalProfit).add(avaAmount); |
| | | if(totalMoney.compareTo(planAmount)<=0){ |
| | | igtOnHookPlanOrder.setProfitState(2); |
| | | }else{ |
| | | igtOnHookPlanOrder.setProfitState(1); |
| | | } |
| | | igtOnHookPlanOrderDao.updateById(igtOnHookPlanOrder); |
| | | |
| | | DappMemberEntity dappMemberEntity = dappMemberDao.selectById(memberId); |
| | | dappMemberEntity.setIsOnHook(3); |
| | | dappMemberDao.updateById(dappMemberEntity); |
| | | |
| | | DappWalletCoinEntity dappWalletCoinEntity = dappWalletCoinDao.selectByMemberId(memberId); |
| | | BigDecimal availableAmount = dappWalletCoinEntity.getAvailableAmount(); |
| | | //如果中奖,返回本金加收益加剩余投注金额 |
| | | BigDecimal total = totalProfit.add(totalAmount).add(igtOnHookPlanOrder.getAvaAmount()).setScale(4, BigDecimal.ROUND_DOWN); |
| | | dappWalletCoinDao.addTotalAndaddAvailableById(memberId,total); |
| | | |
| | | BigDecimal add = availableAmount.add(total); |
| | | |
| | | DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(memberId, availableAmount, total, add, "投注盈利", 5); |
| | | dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity); |
| | | List<IgtOnHookPlanOrder> igtOnHookPlanOrders = igtOnHookPlanOrderDao.selectByState(3); |
| | | if(CollUtil.isNotEmpty(igtOnHookPlanOrders)){ |
| | | for(IgtOnHookPlanOrder igtOnHookPlanOrder : igtOnHookPlanOrders){ |
| | | usdtUpdateProducer.sendOnHookEnd(igtOnHookPlanOrder.getId()); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | @Scheduled(cron = "0 0/1 * * * ? ") |
| | | public void updateMemberIsOnHook(){ |
| | |
| | | |
| | | @Scheduled(cron = "0 0/1 * * * ? ") |
| | | public void createAwardInfo(){ |
| | | Log.info("挂架开奖记录"); |
| | | Log.info("挂机开奖记录"); |
| | | /** |
| | | * 每天跑一次,直接生成全部的记录 |
| | | * 产生中奖记录 |
| | |
| | | String aWardTime = DateUtil.format(date, "yyyy-MM-dd"); |
| | | DateTime aWardTimeStart = DateUtil.parseDateTime(aWardTime + " 00:00:00"); |
| | | // DateTime dateTime = DateUtil.offsetMinute(aWardTimeStart, 5); |
| | | |
| | | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); |
| | | String yyyyMMdd = sdf.format(date); |
| | | QueryWrapper<DappOnHookAward> dappOnHookAwardQueryWrapper = new QueryWrapper(); |
| | | dappOnHookAwardQueryWrapper.like("record_num",yyyyMMdd); |
| | | Integer selectCount = dappOnHookAwardDao.selectCount(dappOnHookAwardQueryWrapper); |
| | | if(0 < selectCount){ |
| | | return; |
| | | if(0 == selectCount){ |
| | | Format formatCount = new DecimalFormat("000"); |
| | | //一般都是将累加的数字当做一些单号的一部分,format要求string |
| | | int dayMillise = (24 * 60) / 5; |
| | | for(int i= 1;i <= dayMillise;i++){ |
| | | DappOnHookAward dappOnHookAward = new DappOnHookAward(); |
| | | int randomInt = RandomUtil.randomInt(10000, 99999); |
| | | dappOnHookAward.setAwardNum(Integer.toString(randomInt)); |
| | | dappOnHookAward.setState(2); |
| | | String str = formatCount.format(i); |
| | | dappOnHookAward.setRecordNum(yyyyMMdd+str); |
| | | dappOnHookAward.setAwardTime(aWardTimeStart); |
| | | dappOnHookAwardDao.insert(dappOnHookAward); |
| | | aWardTimeStart = DateUtil.offsetMinute(aWardTimeStart, 5); |
| | | } |
| | | } |
| | | Format formatCount = new DecimalFormat("000"); |
| | | //一般都是将累加的数字当做一些单号的一部分,format要求string |
| | | int dayMillise = (24 * 60) / 5; |
| | | for(int i= 1;i <= dayMillise;i++){ |
| | | DappOnHookAward dappOnHookAward = new DappOnHookAward(); |
| | | int randomInt = RandomUtil.randomInt(10000, 99999); |
| | | dappOnHookAward.setAwardNum(Integer.toString(randomInt)); |
| | | dappOnHookAward.setState(2); |
| | | String str = formatCount.format(i); |
| | | dappOnHookAward.setRecordNum(yyyyMMdd+str); |
| | | dappOnHookAward.setAwardTime(aWardTimeStart); |
| | | dappOnHookAwardDao.insert(dappOnHookAward); |
| | | aWardTimeStart = DateUtil.offsetMinute(aWardTimeStart, 5); |
| | | |
| | | DateTime tomorrow = DateUtil.tomorrow(); |
| | | String tomorrowTime = DateUtil.format(tomorrow, "yyyy-MM-dd"); |
| | | DateTime tomorrowTimeStart = DateUtil.parseDateTime(tomorrowTime + " 00:00:00"); |
| | | // DateTime dateTime = DateUtil.offsetMinute(aWardTimeStart, 5); |
| | | String tomorrowYyyyMMdd = sdf.format(tomorrow); |
| | | QueryWrapper<DappOnHookAward> tomorrowYyyyMMddWrapper = new QueryWrapper(); |
| | | tomorrowYyyyMMddWrapper.like("record_num",tomorrowYyyyMMdd); |
| | | Integer tomorrowSelectCount = dappOnHookAwardDao.selectCount(tomorrowYyyyMMddWrapper); |
| | | if(0 == tomorrowSelectCount){ |
| | | Format formatCount = new DecimalFormat("000"); |
| | | //一般都是将累加的数字当做一些单号的一部分,format要求string |
| | | int dayMilliseT = (24 * 60) / 5; |
| | | for(int i= 1;i <= dayMilliseT;i++){ |
| | | DappOnHookAward dappOnHookAward = new DappOnHookAward(); |
| | | int randomInt = RandomUtil.randomInt(10000, 99999); |
| | | dappOnHookAward.setAwardNum(Integer.toString(randomInt)); |
| | | dappOnHookAward.setState(2); |
| | | String str = formatCount.format(i); |
| | | dappOnHookAward.setRecordNum(tomorrowYyyyMMdd+str); |
| | | dappOnHookAward.setAwardTime(tomorrowTimeStart); |
| | | dappOnHookAwardDao.insert(dappOnHookAward); |
| | | tomorrowTimeStart = DateUtil.offsetMinute(tomorrowTimeStart, 5); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Value("${spring.profiles.active}") |
| | | private String active; |
| | | |
| | | @Scheduled(cron = "0 0/5 * * * ? ") |
| | | public void updateAwardInfo(){ |
| | |
| | | DappOnHookAward dappOnHookAward = dappOnHookAwardDao.selectByByAwardTime(yyyyMMddHHMM); |
| | | dappOnHookAward.setState(1); |
| | | dappOnHookAwardDao.updateById(dappOnHookAward); |
| | | String redisKey = "on_hook_award_id"; |
| | | String redisKey = ""; |
| | | if("prod".equals(active)){ |
| | | redisKey = "on_hook_award_id"; |
| | | }else{ |
| | | redisKey = "on_hook_award_id_test"; |
| | | } |
| | | String onHookAwardRedisId = redisUtils.getString(redisKey); |
| | | if(StrUtil.isBlank(onHookAwardRedisId)){ |
| | | redisUtils.set(redisKey,dappOnHookAward.getId().toString(),0L); |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 更新用户等级的条件 |
| | | * 一天跑一次,跑完之后进行分佣,和盈利分成 |
| | | * 1、三个有效的用户等级用户 |
| | | * 2、账户余额大于51 |
| | | */ |
| | | @Scheduled(cron = "0 0 1 * * ? ") |
| | | 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()); |
| | | |
| | | //会员升级-只要下级存在某个等级,在这条线都直接升级为该等级 |
| | | updateMemberLevelUp(DataDictionaryEnum.LEVEL_IB.getCode(),LEVEL_IB); |
| | | updateMemberLevelUp(DataDictionaryEnum.LEVEL_FIB.getCode(),LEVEL_FIB); |
| | | updateMemberLevelUp(DataDictionaryEnum.LEVEL_CIB.getCode(),LEVEL_CIB); |
| | | updateMemberLevelUp(DataDictionaryEnum.LEVEL_AIB.getCode(),LEVEL_AIB); |
| | | updateMemberLevelUp(DataDictionaryEnum.LEVEL_GIB.getCode(),LEVEL_GIB); |
| | | updateMemberLevelUp(DataDictionaryEnum.LEVEL_BP.getCode(),LEVEL_BP); |
| | | updateMemberLevelUp(DataDictionaryEnum.LEVEL_SP.getCode(),LEVEL_SP); |
| | | updateMemberLevelUp(DataDictionaryEnum.LEVEL_GP.getCode(),LEVEL_GP); |
| | | } |
| | | } |
| | | |
| | | private void updateMemberLevelUp(String code,List<DappMemberEntity> dappMemberEntities){ |
| | | if(CollUtil.isNotEmpty(dappMemberEntities)){ |
| | | for(DappMemberEntity dappMemberEntity : dappMemberEntities){ |
| | | String refererIds = dappMemberEntity.getRefererIds(); |
| | | if(StrUtil.isNotEmpty(refererIds)){ |
| | | List<String> strings = StrUtil.splitTrim(refererIds, ","); |
| | | for(String inviteId : strings){ |
| | | DappMemberEntity memberEntity = dappMemberDao.selectMemberInfoByInviteId(inviteId); |
| | | if(ObjectUtil.isNotEmpty(memberEntity)){ |
| | | memberEntity.setIdentity(code); |
| | | dappMemberDao.updateById(memberEntity); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | 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); |
| | | dappMemberDao.updateIdentityByMemberId(DataDictionaryEnum.LEVEL_MB.getCode(),memberEntityId); |
| | | 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; |
| | | } |
| | | |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | |
| | | DateTime date = DateUtil.date(); |