西格玛许 пре 2 дана
родитељ
комит
bce27dbd9b

+ 8 - 2
ruoyi-modules/ruoyi-main/src/main/java/org/dromara/main/service/IMainMessageService.java

@@ -31,7 +31,13 @@ public interface IMainMessageService {
 
     Boolean markRead(Long id);
 
-
-
+    /**
+     * 给学员发送通知消息(isRead=0 未读)
+     * @param studentId 学员ID
+     * @param title 消息标题
+     * @param content 消息内容
+     * @param positionId 关联岗位ID(可为null)
+     */
+    void sendNotification(Long studentId, String title, String content, Long positionId);
 
 }

+ 12 - 0
ruoyi-modules/ruoyi-main/src/main/java/org/dromara/main/service/impl/CsOrderCardServiceImpl.java

@@ -25,6 +25,7 @@ import org.dromara.main.mapper.MainPositionMapper;
 import org.dromara.main.mapper.MainStudentMapper;
 import org.dromara.main.service.ICsOrderCardService;
 import org.dromara.main.service.ICsSessionService;
+import org.dromara.main.service.IMainMessageService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -42,6 +43,7 @@ public class CsOrderCardServiceImpl implements ICsOrderCardService {
     private final CsOrderCardMapper baseMapper;
     private final CsMessageMapper messageMapper;
     private final ICsSessionService sessionService;
+    private final IMainMessageService mainMessageService;
     private final Converter converter;
     private final SimpMessagingTemplate messagingTemplate;
     private final MainOrderMapper orderMapper;
@@ -337,6 +339,16 @@ public class CsOrderCardServiceImpl implements ICsOrderCardService {
 
             log.info("支付成功处理完成,订单号:{},结算单ID:{}", orderNo, orderCard.getId());
         }
+
+        // 支付成功后给学员发送通知消息
+        if (mainOrder.getBuyerId() != null && mainOrder.getBuyerType() != null && mainOrder.getBuyerType() == 2) {
+            try {
+                String orderName = (orderCard != null && orderCard.getOrderName() != null) ? orderCard.getOrderName() : "测评服务";
+                mainMessageService.sendNotification(mainOrder.getBuyerId(), "支付成功", "您已成功支付:" + orderName, null);
+            } catch (Exception e) {
+                log.warn("支付成功后发送通知消息失败: {}", e.getMessage());
+            }
+        }
     }
 
 

+ 26 - 2
ruoyi-modules/ruoyi-main/src/main/java/org/dromara/main/service/impl/MainBackCandidateServiceImpl.java

@@ -13,6 +13,7 @@ import org.dromara.main.mapper.MainBackCandidateMapper;
 import org.dromara.main.mapper.MainPositionMapper;
 import org.dromara.main.mapper.MainStudentMapper;
 import org.dromara.main.service.IMainBackCandidateService;
+import org.dromara.main.service.IMainMessageService;
 import org.dromara.system.domain.SysUser;
 import org.dromara.system.domain.bo.SysUserBo;
 import org.dromara.system.domain.SysTenant;
@@ -43,6 +44,7 @@ public class MainBackCandidateServiceImpl implements IMainBackCandidateService {
     private final SysUserMapper sysUserMapper;
     private final ISysUserService sysUserService;
     private final OssService ossService;
+    private final IMainMessageService mainMessageService;
 
     @Override
     public List<Map<String, Object>> getStudentOfferList(Long studentId) {
@@ -138,6 +140,8 @@ public class MainBackCandidateServiceImpl implements IMainBackCandidateService {
                 log.warn("接受Offer后添加企业员工失败,candidateId={}, error={}", id, e.getMessage(), e);
                 // 不影响Offer接受的主流程
             }
+            // 发送通知消息
+            sendCandidateNotification(candidate, "投递进度更新", "您已接受Offer");
         }
 
         return updated;
@@ -223,7 +227,11 @@ public class MainBackCandidateServiceImpl implements IMainBackCandidateService {
         // 同时更新旧status字段保持兼容
         update.setStatus("rejected");
 
-        return mainBackCandidateMapper.updateById(update) > 0;
+        boolean rejected = mainBackCandidateMapper.updateById(update) > 0;
+        if (rejected) {
+            sendCandidateNotification(candidate, "投递进度更新", "您已拒绝Offer");
+        }
+        return rejected;
     }
 
 
@@ -255,6 +263,22 @@ public class MainBackCandidateServiceImpl implements IMainBackCandidateService {
         candidate.setStudentStatus("pending");
         candidate.setStatus("pending");
 
-        return mainBackCandidateMapper.insert(candidate) > 0;
+        boolean applied = mainBackCandidateMapper.insert(candidate) > 0;
+        if (applied) {
+            sendCandidateNotification(candidate, "投递进度更新", "您已成功投递岗位:" + position.getPostName());
+        }
+        return applied;
+    }
+
+    /**
+     * 投递进度变化时发送通知消息给学员
+     */
+    private void sendCandidateNotification(MainBackCandidate candidate, String title, String content) {
+        try {
+            if (candidate == null || candidate.getStudentId() == null) return;
+            mainMessageService.sendNotification(candidate.getStudentId(), title, content, candidate.getPostId());
+        } catch (Exception e) {
+            log.warn("投递进度变化发送通知消息失败,candidateId={}, error={}", candidate != null ? candidate.getId() : null, e.getMessage());
+        }
     }
 }

+ 12 - 0
ruoyi-modules/ruoyi-main/src/main/java/org/dromara/main/service/impl/MainMessageServiceImpl.java

@@ -117,5 +117,17 @@ public class MainMessageServiceImpl implements IMainMessageService {
         ) > 0;
     }
 
+    @Override
+    public void sendNotification(Long studentId, String title, String content, Long positionId) {
+        if (studentId == null) return;
+        MainMessage message = new MainMessage();
+        message.setStudentId(studentId);
+        message.setTitle(title);
+        message.setContent(content);
+        message.setPositionId(positionId != null ? positionId.toString() : null);
+        message.setIsRead(0);
+        baseMapper.insert(message);
+    }
+
 
 }

+ 30 - 2
ruoyi-modules/ruoyi-main/src/main/java/org/dromara/main/service/impl/MainPostCandidateServiceImpl.java

@@ -1,9 +1,11 @@
 package org.dromara.main.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import jakarta.servlet.http.HttpServletResponse;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.dromara.common.core.exception.ServiceException;
 import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -15,6 +17,7 @@ import org.dromara.main.domain.bo.MainPostCandidateStatusBo;
 import org.dromara.main.domain.vo.MainPostCandidateVo;
 import org.dromara.main.mapper.MainBackCandidateMapper;
 import org.dromara.main.mapper.MainStudentMapper;
+import org.dromara.main.service.IMainMessageService;
 import org.dromara.main.service.IMainPostCandidateService;
 import org.dromara.system.service.ISysOssService;
 import org.springframework.stereotype.Service;
@@ -23,6 +26,7 @@ import java.io.IOException;
 import java.time.LocalDateTime;
 import java.util.List;
 
+@Slf4j
 @RequiredArgsConstructor
 @Service
 public class MainPostCandidateServiceImpl implements IMainPostCandidateService {
@@ -34,6 +38,7 @@ public class MainPostCandidateServiceImpl implements IMainPostCandidateService {
     private final MainBackCandidateMapper mainBackCandidateMapper;
     private final MainStudentMapper mainStudentMapper;
     private final ISysOssService sysOssService;
+    private final IMainMessageService mainMessageService;
 
     @Override
     public TableDataInfo<MainPostCandidateVo> queryPageList(MainPostCandidateQueryBo bo, PageQuery pageQuery) {
@@ -66,7 +71,12 @@ public class MainPostCandidateServiceImpl implements IMainPostCandidateService {
         entity.setRemark(bo.getRemark());
         entity.setOfferFileUrl(bo.getOfferAttachment());
         entity.setOfferTime(LocalDateTime.now());
-        return mainBackCandidateMapper.updateById(entity) > 0;
+        boolean hired = mainBackCandidateMapper.updateById(entity) > 0;
+        if (hired) {
+            MainBackCandidate candidate = mainBackCandidateMapper.selectById(bo.getId());
+            sendCandidateNotification(candidate, "投递进度更新", "企业已发送Offer,请及时查看");
+        }
+        return hired;
     }
 
     @Override
@@ -85,7 +95,13 @@ public class MainPostCandidateServiceImpl implements IMainPostCandidateService {
         entity.setId(bo.getId());
         entity.setEnterpriseStatus(normalizedStatus);
         entity.setRemark(bo.getRemark());
-        return mainBackCandidateMapper.updateById(entity) > 0;
+        boolean updated = mainBackCandidateMapper.updateById(entity) > 0;
+        if (updated) {
+            MainBackCandidate candidate = mainBackCandidateMapper.selectById(bo.getId());
+            String msgContent = ENTERPRISE_STATUS_ADOPTED.equals(normalizedStatus) ? "企业已录用" : "企业已拒绝";
+            sendCandidateNotification(candidate, "投递进度更新", msgContent);
+        }
+        return updated;
     }
 
     private String normalizeStatus(String status) {
@@ -115,4 +131,16 @@ public class MainPostCandidateServiceImpl implements IMainPostCandidateService {
         }
         sysOssService.download(student.getResumeFile(), response);
     }
+
+    /**
+     * 投递进度变化时发送通知消息给学员
+     */
+    private void sendCandidateNotification(MainBackCandidate candidate, String title, String content) {
+        try {
+            if (candidate == null || candidate.getStudentId() == null) return;
+            mainMessageService.sendNotification(candidate.getStudentId(), title, content, candidate.getPostId());
+        } catch (Exception e) {
+            log.warn("投递进度变化发送通知消息失败,candidateId={}, error={}", candidate != null ? candidate.getId() : null, e.getMessage());
+        }
+    }
 }