xiaoyong931011
2023-10-27 b6cfeee9e1df352d40ee17c94bf276b7a514226d
src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java
@@ -4,6 +4,7 @@
import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum;
import cc.mrbird.febs.common.utils.MallUtils;
import cc.mrbird.febs.mall.entity.ChatGroup;
import cc.mrbird.febs.mall.entity.ChatUser;
import cc.mrbird.febs.mall.entity.MallMember;
import cc.mrbird.febs.mall.entity.MallMoneyFlow;
import cc.mrbird.febs.mall.mapper.ChatGroupMapper;
@@ -14,10 +15,12 @@
import cc.mrbird.febs.mall.service.IApiMallMemberWalletService;
import cc.mrbird.febs.mall.service.IMemberProfitService;
import cc.mrbird.febs.mall.service.impl.CommonService;
import cc.mrbird.febs.mall.vo.AdminChatRedBagVo;
import cc.mrbird.febs.rabbit.producter.AgentProducer;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
@@ -31,6 +34,7 @@
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
import java.util.Random;
/**
 * @author wzy
@@ -49,11 +53,32 @@
    @Resource
    private AgentProducer agentProducer;
    public static void main(String[] args) {
        for(int i = 0; i< 10 ;i++){
            int randomInt = RandomUtil.randomInt(1, 5);
            System.out.println(randomInt);
            try {
                Thread.sleep(randomInt * 1000L);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(i);
        }
    }
    /**
     * 代理分红
     * 自动发送红包定时器
     */
    @Scheduled(cron = "0 0/1 * * * ? ")
//    @Scheduled(cron = "0 0/1 * * * ? ")
    @Scheduled(cron = "0/20 * * * * ? ")
//    @Scheduled(cron = "0/30 * * * * ? ")
    public void profitJob() {
        int randomInt = RandomUtil.randomInt(1, 20);
        try {
            Thread.sleep(randomInt * 1000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        QueryWrapper<ChatGroup> objectQueryWrapper = new QueryWrapper<>();
        objectQueryWrapper.eq("auto_send", 1);
        List<ChatGroup> chatGroups = chatGroupMapper.selectList(objectQueryWrapper);
@@ -63,4 +88,19 @@
            }
        }
    }
    /**
     * 红包未领完,过期更新
     */
//    @Scheduled(cron = "0/2 * * * * ? ")
    @Scheduled(cron = "0 0 0/1 * * ? ")
    public void returnRedBagAmount() {
        List<AdminChatRedBagVo> adminChatRedBagVos = chatUserMapper.selectByOverDueStatueAndTime(2, DateUtil.date());
        if(CollUtil.isNotEmpty(adminChatRedBagVos)){
            for(AdminChatRedBagVo adminChatRedBagVo : adminChatRedBagVos){
                chatUserMapper.updateOverdueStatusById(1,adminChatRedBagVo.getId());
                agentProducer.sendOverdueSendMsg(adminChatRedBagVo.getId());
            }
        }
    }
}