From 3156be749dfc93764850b27f7cc2b4514a3ae4d0 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 30 Oct 2023 16:36:54 +0800
Subject: [PATCH] 用户收益列表

---
 src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java |  112 +++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 66 insertions(+), 46 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java b/src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java
index 77ff326..7dbf688 100644
--- a/src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java
+++ b/src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java
@@ -3,28 +3,38 @@
 import cc.mrbird.febs.common.enumerates.AgentLevelEnum;
 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;
+import cc.mrbird.febs.mall.mapper.ChatUserMapper;
 import cc.mrbird.febs.mall.mapper.MallMemberMapper;
 import cc.mrbird.febs.mall.mapper.MallMoneyFlowMapper;
 import cc.mrbird.febs.mall.service.IApiMallMemberService;
 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;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.Date;
 import java.util.List;
+import java.util.Random;
 
 /**
  * @author wzy
@@ -34,53 +44,63 @@
 @Component
 public class ProfitJob {
 
-    @Autowired
-    private IMemberProfitService memberProfitService;
+    @Resource
+    private ChatUserMapper chatUserMapper;
+
+    @Resource
+    private ChatGroupMapper chatGroupMapper;
+
+    @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 30 0 * * ?")
-//    public void profitJob() {
-//        memberProfitService.agentProfit(null);
-//    }
-//
-//    @Scheduled(cron = "0 30 1 * * ?")
-//    public void storeAndDirectorJob() {
-//        memberProfitService.storeAndDirectorProfit(null);
-//    }
-//
-//    /**
-//     * 感恩奖
-//     */
-//    @Scheduled(cron = "0 0 1 * * ?")
-//    public void thankfulJob() {
-//        memberProfitService.thankfulProfit(null);
-//    }
-//
-//
-//    /**
-//     * 静态分红
-//     */
-////    @Scheduled(cron = "0 0 0 * * ?")
-////    public void staticProfitJob() {
-////        memberProfitService.staticProfit(null);
-////    }
-//
-//    /**
-//     * 排名奖 每月1号
-//     */
-//    @Scheduled(cron = "0 30 0 1 * ?")
-//    public void rankJob() {
-//        memberProfitService.rankProfit();
-//    }
-//
-//    /**
-//     * 积分池,所有消费拿出10%放到积分池,然后按1%每天释放加权平分
-//     */
-//    @Scheduled(cron = "0 0 2 * * ?")
-////    @Scheduled(cron = "0 0/5 * * * ? ")
-//    public void scorePool() {
-//        memberProfitService.scorePool();
-//    }
+//    @Scheduled(cron = "0 0/1 * * * ? ")
+    @Scheduled(cron = "0/1 * * * * ? ")
+//    @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);
+        if(CollUtil.isNotEmpty(chatGroups)){
+            for(ChatGroup chatGroup : chatGroups){
+                agentProducer.sendAutoSendMsg(chatGroup.getId());
+            }
+        }
+    }
+
+    /**
+     * 红包未领完,过期更新
+     */
+//    @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());
+            }
+        }
+    }
 }

--
Gitblit v1.9.1