xiaoyong931011
2022-10-27 ac397945cddd60cdc1c95d79c17bfca074e5687e
src/main/java/cc/mrbird/febs/job/OnHookPlanJob.java
@@ -18,6 +18,7 @@
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;
@@ -131,32 +132,50 @@
                String refererIds = dappMemberEntity.getRefererIds();
                List<String> refererIdList = StrUtil.split(refererIds, ",", -1, true, true);
                //生成流水佣金和盈利分成和流水记录,返回剩余盈利
                totalProfit = dappWalletService.updateLSYJYLFC(refererIdList,totalProfit);
                BigDecimal profitSharingTotal = dappWalletService.updateLSYJYLFC(refererIdList, totalProfit);
                //平台分成,返回剩余盈利
                totalProfit = dappWalletService.updatePTFC(memberId,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();
                BigDecimal totalAmount = igtOnHookPlanOrderItemDao.selectTotalAmountByByOrderIdAndMemberIdAndState(orderId,memberId,1,1);
                igtOnHookPlanOrder.setState(2);
                //一次挂机剩余的全部金额
                BigDecimal totalMoney = totalAmount.add(totalProfit).add(avaAmount);
                BigDecimal totalMoney = BigDecimal.ZERO;
                if(isProfit == 2){
                    //设置成不盈利,只返回收益加剩余挂机总金额
                    totalMoney = totalProfit.add(avaAmount);
                }else{
                    //设置成盈利,如果中奖,返回收益,如果没中奖,则返回本金,最后加上剩余总挂机金额
                    totalMoney = totalProfit.add(totalAmount).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();
                //如果中奖,返回收益,如果没中奖,则返回本金,最后加上剩余总挂机金额
                BigDecimal total = totalProfit.add(totalAmount).add(igtOnHookPlanOrder.getAvaAmount()).setScale(4, BigDecimal.ROUND_DOWN);
                BigDecimal total = BigDecimal.ZERO;
                if(isProfit == 2){
                    //设置成不盈利,只返回收益加剩余挂机总金额
                    total = totalProfit.add(igtOnHookPlanOrder.getAvaAmount()).setScale(4, BigDecimal.ROUND_DOWN);
                }else{
                    //设置成盈利,如果中奖,返回收益,如果没中奖,则返回本金,最后加上剩余总挂机金额
                    total = totalProfit.add(totalAmount).add(igtOnHookPlanOrder.getAvaAmount()).setScale(4, BigDecimal.ROUND_DOWN);
                }
                dappWalletCoinDao.addTotalAndaddAvailableById(dappWalletCoinEntity.getId(),total);
                BigDecimal add = availableAmount.add(total);
                BigDecimal subtract = add.subtract(totalAmount);
                BigDecimal subtract = add.subtract(totalProfit);
                DappAccountMoneyChangeEntity dappAccountMoneyChangeEntity = new DappAccountMoneyChangeEntity(memberId, subtract, totalProfit, add, "投注盈利", 5);
                dappAccountMoneyChangeDao.insert(dappAccountMoneyChangeEntity);
            }
@@ -175,7 +194,7 @@
    @Scheduled(cron = "0 0/1 * * * ? ")
    public void createAwardInfo(){
        Log.info("挂架开奖记录");
        Log.info("挂机开奖记录");
        /**
         * 每天跑一次,直接生成全部的记录
         * 产生中奖记录
@@ -186,31 +205,58 @@
        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(){
@@ -222,7 +268,12 @@
        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);