From ddb8dee34c54a57b0893a952c8ceb0bbf472d0fc Mon Sep 17 00:00:00 2001
From: huanghongfa <huanghongfa123456>
Date: 星期一, 07 三月 2022 22:13:44 +0800
Subject: [PATCH] 修改bug
---
springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/ComActRaffleServiceImpl.java | 13 +++++++++++++
1 files changed, 13 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 8bac9fe..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();
@@ -125,4 +135,7 @@
}
return R.ok(comActRaffleVO);
}
+ private Long dateToSecond(Date expireTime){
+ return DateUtil.between(new Date(),expireTime, DateUnit.MS);
+ }
}
--
Gitblit v1.7.1