From c42c20b9c71c25ed119884ffe130ac013afb7f07 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 19 六月 2025 09:02:34 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/lottery/LotteryEventServiceImpl.java |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/lottery/LotteryEventServiceImpl.java b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/lottery/LotteryEventServiceImpl.java
index 01fc373..ccc6a70 100644
--- a/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/lottery/LotteryEventServiceImpl.java
+++ b/ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/lottery/LotteryEventServiceImpl.java
@@ -10,7 +10,9 @@
 import com.ruoyi.common.core.utils.uuid.IdUtils;
 import com.ruoyi.common.security.utils.SecurityUtils;
 import com.ruoyi.goods.api.domain.*;
-import com.ruoyi.goods.domain.dto.*;
+import com.ruoyi.goods.domain.dto.MgtLotteryEventEditDTO;
+import com.ruoyi.goods.domain.dto.MgtLotteryEventPageDto;
+import com.ruoyi.goods.domain.dto.MgtLotteryEventQuestionDTO;
 import com.ruoyi.goods.domain.vo.*;
 import com.ruoyi.goods.mapper.lottery.LotteryEventMapper;
 import com.ruoyi.goods.service.lottery.*;
@@ -26,7 +28,6 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import javax.annotation.Resources;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.util.*;
@@ -255,7 +256,7 @@
 
 	@Override
 	@Transactional
-	public R<ShopLotteryDrawVo> editLotteryEvent(MgtLotteryEventEditDTO dto) {
+	public R editLotteryEvent(MgtLotteryEventEditDTO dto) {
 		//先检查开始-结束时间范围内,系统中是否有该活动
 		List<LotteryEvent> lotteryEvents = this.baseMapper.selectList(new LambdaQueryWrapper<LotteryEvent>()
 				.eq(LotteryEvent::getDelFlag, 0)//未删除的
@@ -306,6 +307,7 @@
 		//新增
 		BeanUtils.copyProperties(dto, lotteryEvent);
 		if (dto.getId() == null) {
+			lotteryEvent.setId(IdUtils.simpleUUID());
 			lotteryEvent.setCreateTime(LocalDateTime.now());
 			lotteryEvent.setCreateUserId(dto.getUserId());
 		}else {
@@ -319,6 +321,7 @@
 		List<LotteryEventPrize> prizeList = dto.getMgtLotteryEventPrizeDTOList().stream()
 				.map(prizeDTO -> {
 					LotteryEventPrize prize = new LotteryEventPrize();
+					prize.setId(IdUtils.simpleUUID());
 					prize.setLotteryEventId(finalLotteryEvent.getId());
 					prize.setPrizeType(prizeDTO.getPrizeType());
 					if (null != prizeDTO.getObjectId()){
@@ -335,6 +338,7 @@
 			//保存题干数据
 			for (MgtLotteryEventQuestionDTO questionDTO : dto.getMgtLotteryQuestionDTOList()) {
 				LotteryEventQuestions question = new LotteryEventQuestions();
+				question.setId(IdUtils.simpleUUID());
 				question.setLotteryEventId(finalLotteryEvent.getId());
 				question.setName(questionDTO.getName());
 				question.setSort(questionDTO.getSort());
@@ -343,6 +347,7 @@
 				List<LotteryEventQuestionsAnswers> answersList = questionDTO.getAnswersDTOList().stream()
 						.map(answersDTO -> {
 							LotteryEventQuestionsAnswers answer = new LotteryEventQuestionsAnswers();
+							answer.setId(IdUtils.simpleUUID());
 							answer.setLotteryEventId(finalLotteryEvent.getId());
 							answer.setLotteryEventQuestionsId(question.getId());
 							answer.setAnswer(answersDTO.getAnswer());
@@ -470,7 +475,7 @@
 			return R.fail("该抽奖活动不存在");
 		}
 		LocalDateTime now = LocalDateTime.now();
-		if (!now.isBefore(lotteryEvent.getStartTime()) && !now.isAfter(lotteryEvent.getEndTime())) {
+		if (now.isBefore(lotteryEvent.getStartTime()) && now.isAfter(lotteryEvent.getEndTime())) {
 			return R.fail("该抽奖活动不在活动时间范围内");
 		}
 		lotteryEvent.setEndTime(now);//将结束时间设置为当前时间

--
Gitblit v1.7.1