From e9e42b621afdf6ac94f5327ee843b32b10a401b4 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期二, 04 八月 2026 17:45:14 +0800
Subject: [PATCH] update
---
backend/src/main/java/com/tourguide/modules/system/service/GuideNotificationService.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 48 insertions(+), 6 deletions(-)
diff --git a/backend/src/main/java/com/tourguide/modules/system/service/GuideNotificationService.java b/backend/src/main/java/com/tourguide/modules/system/service/GuideNotificationService.java
index b0907da..750d035 100644
--- a/backend/src/main/java/com/tourguide/modules/system/service/GuideNotificationService.java
+++ b/backend/src/main/java/com/tourguide/modules/system/service/GuideNotificationService.java
@@ -2,6 +2,7 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tourguide.common.exception.BusinessException;
+import com.tourguide.modules.order.entity.TourOrder;
import com.tourguide.modules.system.dto.GuideNotificationResponse;
import com.tourguide.modules.system.entity.GuideNoticeRead;
import com.tourguide.modules.system.entity.GuideNotification;
@@ -9,6 +10,7 @@
import com.tourguide.modules.system.mapper.GuideNotificationMapper;
import com.tourguide.modules.system.mapper.GuideNoticeReadMapper;
import com.tourguide.modules.system.mapper.SystemNoticeMapper;
+import com.tourguide.modules.user.service.GuidePushDeviceService;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
@@ -23,12 +25,15 @@
private final SystemNoticeMapper noticeMapper;
private final GuideNoticeReadMapper readMapper;
private final GuideNotificationMapper guideNotificationMapper;
+ private final GuidePushDeviceService pushDeviceService;
public GuideNotificationService(SystemNoticeMapper noticeMapper, GuideNoticeReadMapper readMapper,
- GuideNotificationMapper guideNotificationMapper) {
+ GuideNotificationMapper guideNotificationMapper,
+ GuidePushDeviceService pushDeviceService) {
this.noticeMapper = noticeMapper;
this.readMapper = readMapper;
this.guideNotificationMapper = guideNotificationMapper;
+ this.pushDeviceService = pushDeviceService;
}
public long unreadCount(Long guideId) {
@@ -79,16 +84,40 @@
readMapper.insert(read);
}
- public void notifyOrderAssigned(com.tourguide.modules.order.entity.TourOrder order) {
+ public void notifyOrderAssigned(TourOrder order) {
if (order == null || order.getGuideId() == null) return;
- create(order.getGuideId(), "ORDER_ASSIGNED", "接单提醒", "您有一个新的讲解订单,请查看",
- order.getId(), "/pages/order-detail/index?id=" + order.getId());
+ String title = "您有新的讲解订单";
+ String content = "景区:" + valueOrUnknown(order.getScenicName())
+ + ";汇合点:" + valueOrUnknown(order.getMeetingPointName())
+ + ";服务类型:" + valueOrUnknown(order.getPackageName(), order.getOrderType())
+ + ";人数:" + (order.getPeopleCount() == null ? 0 : order.getPeopleCount())
+ + "。请及时接单。";
+ String targetUrl = orderTargetUrl(order.getId());
+ create(order.getGuideId(), "ORDER_ASSIGNED", title, content, order.getId(), targetUrl);
+ pushDeviceService.push(order.getGuideId(), title, content, targetUrl);
}
- public void notifyOrderCancelled(com.tourguide.modules.order.entity.TourOrder order) {
+ public void notifyVisitorCancelledOrder(TourOrder order) {
+ if (order == null || order.getGuideId() == null) return;
+ String title = "订单已取消";
+ String content = "游客已取消订单,该订单无需再前往服务。";
+ String targetUrl = orderTargetUrl(order.getId());
+ create(order.getGuideId(), "ORDER_CANCELLED", title, content, order.getId(), targetUrl);
+ pushDeviceService.push(order.getGuideId(), title, content, targetUrl);
+ }
+
+ public void notifyOrderCancelled(TourOrder order) {
if (order == null || order.getGuideId() == null) return;
create(order.getGuideId(), "ORDER_CANCELLED", "取消提醒", "您有一个被取消的讲解订单,请查看",
- order.getId(), "/pages/order-detail/index?id=" + order.getId());
+ order.getId(), orderTargetUrl(order.getId()));
+ }
+
+ public boolean pushServiceReminder(TourOrder order) {
+ if (order == null || order.getGuideId() == null) return false;
+ String title = "请准备前往汇合点";
+ String content = "您的讲解服务即将开始,请提前到达 "
+ + valueOrUnknown(order.getMeetingPointName()) + "。";
+ return pushDeviceService.push(order.getGuideId(), title, content, orderTargetUrl(order.getId()));
}
public void notifyAuditResult(Long guideId, boolean approved) {
@@ -110,6 +139,19 @@
guideNotificationMapper.insert(notification);
}
+ private String orderTargetUrl(Long orderId) {
+ return orderId == null ? null : "/pages/order-detail/index?id=" + orderId;
+ }
+
+ private String valueOrUnknown(String primary, String fallback) {
+ if (primary != null && !primary.trim().isEmpty()) return primary;
+ return valueOrUnknown(fallback);
+ }
+
+ private String valueOrUnknown(String value) {
+ return value == null || value.trim().isEmpty() ? "未知" : value;
+ }
+
private void markPersonalRead(Long guideId, Long notificationId) {
GuideNotification notification = guideNotificationMapper.selectOne(new LambdaQueryWrapper<GuideNotification>()
.eq(GuideNotification::getId, notificationId)
--
Gitblit v1.7.1