From 4f6f15b818704079ff2e4e4719b798f48d68a335 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期五, 11 九月 2026 13:52:19 +0800
Subject: [PATCH] update
---
backend/src/main/java/com/tourguide/modules/review/service/OrderReviewService.java | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/backend/src/main/java/com/tourguide/modules/review/service/OrderReviewService.java b/backend/src/main/java/com/tourguide/modules/review/service/OrderReviewService.java
index 625a7b4..783def8 100644
--- a/backend/src/main/java/com/tourguide/modules/review/service/OrderReviewService.java
+++ b/backend/src/main/java/com/tourguide/modules/review/service/OrderReviewService.java
@@ -1,6 +1,7 @@
package com.tourguide.modules.review.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tourguide.common.api.PageResponse;
import com.tourguide.common.exception.BusinessException;
@@ -16,6 +17,8 @@
import com.tourguide.modules.user.entity.GuideUser;
import com.tourguide.modules.user.mapper.GuideUserMapper;
import com.tourguide.modules.user.service.GuideAutoDisableService;
+import com.tourguide.modules.system.service.GuideNotificationService;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
@@ -34,14 +37,34 @@
private final TourOrderMapper orderMapper;
private final GuideUserMapper guideUserMapper;
private final GuideAutoDisableService autoDisableService;
+ private final ObjectMapper objectMapper;
+ private final GuideNotificationService notificationService;
public OrderReviewService(OrderReviewMapper reviewMapper, TourOrderMapper orderMapper,
GuideUserMapper guideUserMapper,
GuideAutoDisableService autoDisableService) {
+ this(reviewMapper, orderMapper, guideUserMapper, autoDisableService, new ObjectMapper(), null);
+ }
+
+ public OrderReviewService(OrderReviewMapper reviewMapper, TourOrderMapper orderMapper,
+ GuideUserMapper guideUserMapper,
+ GuideAutoDisableService autoDisableService,
+ ObjectMapper objectMapper) {
+ this(reviewMapper, orderMapper, guideUserMapper, autoDisableService, objectMapper, null);
+ }
+
+ @Autowired
+ public OrderReviewService(OrderReviewMapper reviewMapper, TourOrderMapper orderMapper,
+ GuideUserMapper guideUserMapper,
+ GuideAutoDisableService autoDisableService,
+ ObjectMapper objectMapper,
+ GuideNotificationService notificationService) {
this.reviewMapper = reviewMapper;
this.orderMapper = orderMapper;
this.guideUserMapper = guideUserMapper;
this.autoDisableService = autoDisableService;
+ this.objectMapper = objectMapper;
+ this.notificationService = notificationService;
}
public PageResponse<OrderReviewResponse> page(long page, long size, String keyword, Long visitorId, Integer status,
@@ -125,11 +148,15 @@
review.setScenicName(order.getScenicName());
review.setScore(request.getScore());
review.setContent(request.getContent());
+ review.setImageUrls(serializeImages(request.getImages()));
review.setReviewedAt(LocalDateTime.now());
review.setStatus(1);
review.setDeleted(0);
reviewMapper.insert(review);
refreshGuideRating(order.getGuideId());
+ if (notificationService != null) {
+ notificationService.notifyOrderReviewed(order);
+ }
return new OrderReviewResponse(review);
}
@@ -167,6 +194,21 @@
autoDisableService.disableGuideIfEligible(guideId);
}
+ private String serializeImages(List<String> images) {
+ if (images == null || images.isEmpty()) return null;
+ List<String> normalized = images.stream()
+ .filter(StringUtils::hasText)
+ .map(String::trim)
+ .limit(3)
+ .collect(Collectors.toList());
+ if (normalized.isEmpty()) return null;
+ try {
+ return objectMapper.writeValueAsString(normalized);
+ } catch (Exception exception) {
+ throw new BusinessException(400, "评价图片格式不正确");
+ }
+ }
+
private String generateReviewNo() {
String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
return "RV" + time + UUID.randomUUID().toString().replace("-", "").substring(0, 8).toUpperCase();
--
Gitblit v1.7.1