From 82a8bc62d5b9d5d607f6952329952b17eda2f0a0 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期一, 14 九月 2026 15:44:34 +0800
Subject: [PATCH] update
---
backend/src/main/java/com/tourguide/modules/system/service/GuideNotificationService.java | 69 +++++++++++++++++++++++++++++-----
1 files changed, 59 insertions(+), 10 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..983bda7 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,17 +25,19 @@
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) {
List<SystemNotice> notices = publishedNotices();
- if (notices.isEmpty()) return 0L;
Set<Long> readIds = readNoticeIds(guideId, notices);
long systemUnread = notices.stream().filter(notice -> !readIds.contains(notice.getId())).count();
Long personalUnread = guideNotificationMapper.selectCount(new LambdaQueryWrapper<GuideNotification>()
@@ -79,21 +83,53 @@
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 = "您有一个新的讲解订单,请查看";
+ 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;
- create(order.getGuideId(), "ORDER_CANCELLED", "取消提醒", "您有一个被取消的讲解订单,请查看",
- order.getId(), "/pages/order-detail/index?id=" + order.getId());
+ 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;
+ 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 notifyOrderReviewed(TourOrder order) {
+ if (order == null || order.getGuideId() == null) return;
+ String title = "评价提醒";
+ String content = "您有一条新的订单评价,请查看";
+ String targetUrl = "/pages/rating/index";
+ create(order.getGuideId(), "ORDER_REVIEWED", title, content, order.getId(), targetUrl);
+ pushDeviceService.push(order.getGuideId(), title, content, targetUrl);
+ }
+
+ 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) {
- create(guideId, approved ? "AUDIT_APPROVED" : "AUDIT_REJECTED", "【名导精讲】",
- approved ? "您的资料审核已通过,请前往应用查看。" : "您的资料审核未通过,请前往应用更新提交。",
+ create(guideId, approved ? "AUDIT_APPROVED" : "AUDIT_REJECTED", "系统提醒",
+ approved ? "您的资料审核已通过" : "您的资料审核未通过",
null, null);
}
@@ -110,6 +146,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