ruoyi-api/ruoyi-api-goods/src/main/java/com/ruoyi/goods/api/domain/LotteryEventQuestionsAnswers.java
@@ -29,8 +29,8 @@ /** * 答案 */ @TableField(value = "answer") private String answer; @TableField(value = "answers") private String answers; /** * 是否是正确答案(0=否,1=是) */ ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/miniapp/AppLotteryEventController.java
@@ -146,7 +146,7 @@ List<Map<String, String>> options = list.stream().map(item -> { Map<String, String> map = new HashMap<>(); map.put("id", item.getId()); map.put("name", item.getAnswer()); map.put("name", item.getAnswers()); return map; }).collect(Collectors.toList()); vo.setOptions(options); @@ -174,13 +174,13 @@ List<Map<String, String>> options = list1.stream().map(item -> { Map<String, String> map = new HashMap<>(); map.put("id", item.getId()); map.put("name", item.getAnswer()); map.put("name", item.getAnswers()); return map; }).collect(Collectors.toList()); if (-1 == dto.getStepOrDown()) { UserLotteryEventQuestionsAnswers one = userLotteryEventQuestionsAnswersService.getOne(new QueryWrapper<UserLotteryEventQuestionsAnswers>().eq("lottery_event_id", dto.getId()).eq("user_id", userId).orderByDesc("create_time").last(" limit 0, 1")); if (null != one) { vo.setAnswer(lotteryEventQuestionsAnswersService.getById(one.getLotteryEventQuestionsAnswersId()).getAnswer()); vo.setAnswer(lotteryEventQuestionsAnswersService.getById(one.getLotteryEventQuestionsAnswersId()).getAnswers()); } } vo.setOptions(options); @@ -195,7 +195,7 @@ List<LotteryEventQuestions> list = lotteryEventServiceQuestionsService.list(new QueryWrapper<LotteryEventQuestions>().eq("lottery_event_id", dto.getId()).orderByAsc("sort")); LotteryEventQuestions lotteryEventQuestions = list.get(dto.getCurrent()); List<LotteryEventQuestionsAnswers> list1 = lotteryEventQuestionsAnswersService.list(new QueryWrapper<LotteryEventQuestionsAnswers>().eq("lottery_event_questions_id", lotteryEventQuestions.getId())); LotteryEventQuestionsAnswers lotteryEventQuestionsAnswers = list1.stream().filter(item -> item.getAnswer().equals(dto.getAnswer())).findAny().orElse(null); LotteryEventQuestionsAnswers lotteryEventQuestionsAnswers = list1.stream().filter(item -> item.getAnswers().equals(dto.getAnswer())).findAny().orElse(null); //构建答题数据 Long userId = SecurityUtils.getUserId(); UserLotteryEventQuestions questionsServiceOne = userLotteryEventQuestionsService.getOne(new QueryWrapper<UserLotteryEventQuestions>().eq("lottery_event_id", dto.getId()).eq("user_id", userId)); ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/domain/dto/MgtLotteryEventQuestionAnswersDTO.java
@@ -10,7 +10,7 @@ * 选项 */ @ApiModelProperty("选项") private String answer; private String answers; /** * 是否是正确答案(0=否,1=是) */ ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/service/impl/lottery/LotteryEventServiceImpl.java
@@ -353,7 +353,7 @@ answer.setId(IdUtils.simpleUUID()); answer.setLotteryEventId(finalLotteryEvent.getId()); answer.setLotteryEventQuestionsId(question.getId()); answer.setAnswer(answersDTO.getAnswer()); answer.setAnswers(answersDTO.getAnswers()); answer.setIsRight(answersDTO.getIsRight()); return answer; }).collect(Collectors.toList()); @@ -366,9 +366,10 @@ @Override public List<MgtLotteryEventPageVo> pageMgtLotteryEvent(Page<MgtLotteryEventPageVo> page, MgtLotteryEventPageDto dto) { Map<Long,Shop> map; List<Shop> shopList; if (dto.getCreateObject()!=null){ //根据 条件-创建对象 模糊查找门店集合 List<Shop> shopList=remoteShopService.getShopListByShopName(dto.getCreateObject()); shopList=remoteShopService.getShopListByShopName(dto.getCreateObject()); if (null != shopList && !shopList.isEmpty()) { List<Long> shopIds = shopList.stream().map(Shop::getShopId).collect(Collectors.toList()); dto.setShopIds(shopIds); @@ -384,6 +385,7 @@ } else { map = new HashMap<>(); } //获取分页信息 List<MgtLotteryEventPageVo> voList = this.baseMapper.pageMgtLotteryEvent(page, dto); //填充创建对象 @@ -392,7 +394,15 @@ x.setCreateObject("平台创建"); }else { //线下抽奖,获取门店名称 x.setCreateObject(map.get(Long.valueOf(x.getShopId())).getShopName()); if(map.containsKey(Long.valueOf(x.getShopId()))){ x.setCreateObject(map.get(Long.valueOf(x.getShopId())).getShopName()); }else { Shop shop = remoteShopService.getShop(Long.valueOf(x.getShopId())).getData(); if (null != shop){ x.setCreateObject(shop.getShopName()); } } } }); @@ -407,12 +417,14 @@ } MgtLotteryEventDetailVO vo = new MgtLotteryEventDetailVO(); BeanUtils.copyProperties(lotteryEvent, vo); if (lotteryEvent.getActivityType()==6){ if (lotteryEvent.getActivityType()==6) { //线下抽奖 取商户名称 Shop data = remoteShopService.getShop(Long.valueOf(lotteryEvent.getShopId())).getData(); if (null != data){ if (null != data) { vo.setShopName(data.getShopName()); } } if(lotteryEvent.getActivityType()==5){ //题干数据 List<LotteryEventQuestions> questionsList = lotteryEventQuestionsService.getBaseMapper().selectList(new LambdaQueryWrapper<LotteryEventQuestions>().eq(LotteryEventQuestions::getLotteryEventId, lotteryEvent.getId())); @@ -422,7 +434,7 @@ //答案选项数据 List<LotteryEventQuestionsAnswers> answersList = lotteryEventQuestionsAnswersService.getBaseMapper().selectList(new LambdaQueryWrapper<LotteryEventQuestionsAnswers>() .eq(LotteryEventQuestionsAnswers::getLotteryEventId, lotteryEvent.getId()) .eq(LotteryEventQuestionsAnswers::getLotteryEventQuestionsId, questionVO.getLotteryEventId())); .eq(LotteryEventQuestionsAnswers::getLotteryEventQuestionsId, questionVO.getId())); questionVO.setAnswersVOList(answersList); return questionVO; }).collect(Collectors.toList()); ruoyi-modules/ruoyi-goods/src/main/resources/mapper/lottery/LotteryEventMapper.xml
@@ -81,28 +81,22 @@ <if test="null != dto.activityType and dto.activityType!=0 "> activity_type = #{dto.activityType} </if> <choose> <when test="dto.shopIds != null and dto.shopIds.size() > 0"> <choose> <when test="dto.flag != null and dto.flag == 1"> AND (shop_id IN <foreach collection="dto.shopIds" item="shopId" open="(" separator="," close=")"> #{shopId} </foreach> OR shop_id IS NULL) </when> <otherwise> AND shop_id IN <foreach collection="dto.shopIds" item="shopId" open="(" separator="," close=")"> #{shopId} </foreach> </otherwise> </choose> </when> <when test="dto.flag != null and dto.flag == 1"> AND shop_id IS NULL </when> </choose> <if test="dto.shopIds != null and dto.shopIds.size() > 0"> <choose> <when test="dto.flag != null and dto.flag == 1"> AND (shop_id IN <foreach collection="dto.shopIds" item="shopId" open="(" separator="," close=")"> #{shopId} </foreach> OR shop_id IS NULL) </when> <otherwise> AND shop_id IN <foreach collection="dto.shopIds" item="shopId" open="(" separator="," close=")"> #{shopId} </foreach> </otherwise> </choose> </if> </select> </mapper>