From 70d2a5d0f9c6951b2d4cac954041ed73582ff7eb Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期一, 09 六月 2025 11:54:00 +0800
Subject: [PATCH] 6.9新增登录失败冻结逻辑

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActRaffleServiceImpl.java |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActRaffleServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActRaffleServiceImpl.java
index 6b3735d..08139d6 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActRaffleServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActRaffleServiceImpl.java
@@ -1,5 +1,7 @@
 package com.panzhihua.service_community.service.impl;
 
+import cn.hutool.core.date.DateUnit;
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -15,7 +17,9 @@
 import com.panzhihua.service_community.entity.ComActRaffleRecord;
 import com.panzhihua.service_community.service.ComActRaffleService;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.BeanUtils;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -39,6 +43,8 @@
     private ComActRafflePrizeDao comActRafflePrizeDao;
     @Resource
     private ComActRaffleRecordDao comActRaffleRecordDao;
+    @Resource
+    private RabbitTemplate rabbitTemplate;
     @Override
     public R pageList(CommonPage commonPage) {
         return R.ok(this.baseMapper.pageList(new Page(commonPage.getPage(),commonPage.getSize()),commonPage));
@@ -53,6 +59,10 @@
         comActRaffle.setStatus(0);
         int count= this.baseMapper.insert(comActRaffle);
         if(count>0){
+            rabbitTemplate.convertAndSend("raffle.exchange", "raffle.key", comActRaffle, message -> {
+                message.getMessageProperties().setHeader("x-delay", dateToSecond(comActRaffle.getStartTime()));
+                return message;
+            });
             if(!CollectionUtils.isEmpty(comActRaffleVO.getComActRafflePrizeVOList())){
                 comActRaffleVO.getComActRafflePrizeVOList().forEach(comActRafflePrizeVO -> {
                     ComActRafflePrize comActRafflePrize=new ComActRafflePrize();
@@ -112,8 +122,20 @@
           ComActRaffleRecordVO comActRaffleRecordVO=comActRaffleRecordDao.selectByUserId(userId,id);
           if(comActRaffleRecordVO!=null){
               comActRaffleVO.setComActRaffleRecordVO(comActRaffleRecordVO);
+              comActRaffleVO.setJoinStatus(0);
+          }
+          else {
+              if(comActRaffleVO.getStatus()==1){
+                  comActRaffleVO.setJoinStatus(1);
+              }
+              else {
+                  comActRaffleVO.setJoinStatus(0);
+              }
           }
         }
         return R.ok(comActRaffleVO);
     }
+    private Long dateToSecond(Date expireTime){
+        return DateUtil.between(new Date(),expireTime, DateUnit.MS);
+    }
 }

--
Gitblit v1.7.1