Forráskód Böngészése

优化举报接口

zhangchen 3 hete
szülő
commit
38e26ce6cd

+ 3 - 3
alien-entity/src/main/java/shop/alien/entity/store/LawyerUserViolation.java

@@ -56,9 +56,9 @@ public class LawyerUserViolation extends Model<LawyerUserViolation> {
     @TableField("report_context_type")
     private String reportContextType;
 
-    @ApiModelProperty(value = "1:用户违规,2:色情低俗,3:违法违规,4:谩骂嘲讽、煽动对立,5:涉嫌诈骗,6:人身攻击,7:种族歧视,8:政治敏感,9:虚假、不实内容,违反公德秩序,10:危害人身安全,11:网络暴力,12:其他原因")
-    @TableField("violation_type")
-    private String violationType;
+    @ApiModelProperty(value = "举报原因")
+    @TableField("violation_reason")
+    private String violationReason;
 
     @ApiModelProperty(value = "其他原因具体内容")
     @TableField("other_reason_content")

+ 51 - 8
alien-lawyer/src/main/java/shop/alien/lawyer/controller/LawyerUserViolationController.java

@@ -31,16 +31,59 @@ public class LawyerUserViolationController {
 
     private final LawyerUserViolationService lawyerUserViolationService;
 
-    @ApiOperation("举报")
+    /**
+     * 用户举报接口
+     * <p>
+     * 用于律师用户提交举报信息,包括被举报用户信息、举报类型、举报内容等
+     * </p>
+     *
+     * @param lawyerUserViolation 举报信息对象,包含以下必填字段:
+     *                            <ul>
+     *                            <li>reportedUserId: 被举报用户ID</li>
+     *                            <li>reportingUserId: 举报用户ID</li>
+     *                            <li>violationType: 违规类型(1-12)</li>
+     *                            <li>reportContextType: 举报内容分类</li>
+     *                            </ul>
+     * @return 统一响应结果,成功返回"举报成功",失败返回"举报失败"
+     * @author system
+     * @since 2025-01-XX
+     */
+    @ApiOperation(value = "用户举报", notes = "提交用户举报信息,系统将自动发送通知消息")
     @ApiOperationSupport(order = 1)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "reportedUserId", value = "被举报用户ID", required = true, dataType = "String", paramType = "body"),
+            @ApiImplicitParam(name = "reportingUserId", value = "举报用户ID", required = true, dataType = "String", paramType = "body"),
+            @ApiImplicitParam(name = "violationType", value = "违规类型:1-用户违规,2-色情低俗,3-违法违规,4-谩骂嘲讽、煽动对立,5-涉嫌诈骗,6-人身攻击,7-种族歧视,8-政治敏感,9-虚假、不实内容,违反公德秩序,10-危害人身安全,11-网络暴力,12-其他原因", required = true, dataType = "String", paramType = "body"),
+            @ApiImplicitParam(name = "reportContextType", value = "举报内容分类", required = true, dataType = "String", paramType = "body"),
+            @ApiImplicitParam(name = "otherReasonContent", value = "其他原因具体内容(当violationType为12时必填)", required = false, dataType = "String", paramType = "body"),
+            @ApiImplicitParam(name = "reportEvidenceImg", value = "举报凭证图片", required = false, dataType = "String", paramType = "body")
+    })
     @PostMapping("/userReporting")
-    public R<String> userReporting(@RequestBody LawyerUserViolation lawyerUserViolation) throws Exception  {
-        log.info("LawyerUserViolationController.userReporting?lawyerUserViolation={}", lawyerUserViolation.toString());
-        int reporting = lawyerUserViolationService.userReporting(lawyerUserViolation);
-        if (0 == reporting) {
-            return R.fail("举报失败");
-        } else {
-            return R.data("举报成功");
+    public R<String> userReporting(@RequestBody LawyerUserViolation lawyerUserViolation) {
+        log.info("用户举报请求,被举报用户ID:{},举报用户ID:{},违规类型:{}",
+                lawyerUserViolation.getReportedUserId(),
+                lawyerUserViolation.getReportingUserId(),
+                lawyerUserViolation.getViolationType());
+
+        try {
+            int result = lawyerUserViolationService.userReporting(lawyerUserViolation);
+            if (result > 0) {
+                log.info("用户举报成功,被举报用户ID:{},举报用户ID:{}",
+                        lawyerUserViolation.getReportedUserId(),
+                        lawyerUserViolation.getReportingUserId());
+                return R.success("举报成功");
+            } else {
+                log.warn("用户举报失败,被举报用户ID:{},举报用户ID:{}",
+                        lawyerUserViolation.getReportedUserId(),
+                        lawyerUserViolation.getReportingUserId());
+                return R.fail("举报失败");
+            }
+        } catch (Exception e) {
+            log.error("用户举报异常,被举报用户ID:{},举报用户ID:{},异常信息:{}",
+                    lawyerUserViolation.getReportedUserId(),
+                    lawyerUserViolation.getReportingUserId(),
+                    e.getMessage(), e);
+            return R.fail("举报处理异常,请稍后重试");
         }
     }
 

+ 7 - 1
alien-lawyer/src/main/java/shop/alien/lawyer/service/LawyerUserViolationService.java

@@ -19,7 +19,13 @@ import java.util.Map;
  */
 public interface LawyerUserViolationService extends IService<LawyerUserViolation> {
 
-    int userReporting(LawyerUserViolation lawyerUserViolation) throws Exception ;
+    /**
+     * 用户举报处理
+     *
+     * @param lawyerUserViolation 举报信息对象
+     * @return 插入成功的记录数,失败返回0
+     */
+    int userReporting(LawyerUserViolation lawyerUserViolation);
 
     Map<String, Object> reportListByUserId(String userId);
 

+ 379 - 108
alien-lawyer/src/main/java/shop/alien/lawyer/service/impl/LawyerUserViolationServiceImpl.java

@@ -11,7 +11,6 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import shop.alien.entity.store.*;
 import shop.alien.entity.store.dto.LawyerUserViolationDto;
@@ -55,147 +54,419 @@ public class LawyerUserViolationServiceImpl extends ServiceImpl<LawyerUserViolat
 
     private final WebSocketProcess webSocketProcess;
 
+    /**
+     * 用户举报处理
+     * <p>
+     * 处理用户举报信息,包括:
+     * 1. 保存举报记录到数据库
+     * 2. 向举报人发送受理通知
+     * 3. 根据举报内容类型,向被举报人发送通知(如需要)
+     * </p>
+     *
+     * @param lawyerUserViolation 举报信息对象,不能为null
+     * @return 插入成功的记录数,失败返回0
+     * @throws RuntimeException 当数据库操作失败或业务逻辑处理异常时抛出
+     * @author system
+     * @since 2025-01-XX
+     */
     @Override
-    public int userReporting(LawyerUserViolation lawyerUserViolation) throws Exception {
+    public int userReporting(LawyerUserViolation lawyerUserViolation) {
+        // 参数校验
+        if (lawyerUserViolation == null) {
+            log.warn("用户举报参数为空");
+            return 0;
+        }
+
+        log.info("开始处理用户举报,被举报用户ID:{},举报用户ID:{},违规类型:{}",
+                lawyerUserViolation.getReportedUserId(),
+                lawyerUserViolation.getReportingUserId(),
+                lawyerUserViolation.getViolationType());
+
         try {
+            // 保存举报记录
             int result = lawyerUserViolationMapper.insert(lawyerUserViolation);
-            if (result > 0) {
-                // 举报人消息
-                LifeNotice lifeNotice = getLifeNotice(lawyerUserViolation);
-                lifeNoticeMapper.insert(lifeNotice);
-                WebSocketVo websocketVo = new WebSocketVo();
-                websocketVo.setSenderId("system");
-                websocketVo.setReceiverId(lifeNotice.getReceiverId());
-                websocketVo.setCategory("notice");
-                websocketVo.setNoticeType("1");
-                websocketVo.setIsRead(0);
-                websocketVo.setText(JSONObject.from(lifeNotice).toJSONString());
-                webSocketProcess.sendMessage(lifeNotice.getReceiverId(), com.alibaba.fastjson2.JSONObject.from(websocketVo).toJSONString());
-
-                // 被举报人消息
-                if(StringUtils.isNotEmpty(lawyerUserViolation.getReportContextType()) && "6".contains(lawyerUserViolation.getReportContextType())){
-                    LifeNotice lifeNoticeReported = getLifeReportedNotice(lawyerUserViolation);
-                    if (lifeNoticeReported != null) {
-                        lifeNoticeMapper.insert(lifeNoticeReported);
-                        WebSocketVo websocketVoReported = new WebSocketVo();
-                        websocketVoReported.setSenderId("system");
-                        websocketVoReported.setReceiverId(lifeNoticeReported.getReceiverId());
-                        websocketVoReported.setCategory("notice");
-                        websocketVoReported.setNoticeType("1");
-                        websocketVoReported.setIsRead(0);
-                        websocketVoReported.setText(com.alibaba.fastjson2.JSONObject.from(lifeNoticeReported).toJSONString());
-                        webSocketProcess.sendMessage(lifeNoticeReported.getReceiverId(), com.alibaba.fastjson2.JSONObject.from(websocketVoReported).toJSONString());
-                    }
-                }
-                return result;
+            if (result <= 0) {
+                log.warn("用户举报记录保存失败,被举报用户ID:{},举报用户ID:{}",
+                        lawyerUserViolation.getReportedUserId(),
+                        lawyerUserViolation.getReportingUserId());
+                return 0;
+            }
+
+            log.info("用户举报记录保存成功,举报ID:{}", lawyerUserViolation.getId());
+
+            // 向举报人发送受理通知
+            sendReportNoticeToReporter(lawyerUserViolation);
+
+            // 根据举报内容类型,向被举报人发送通知
+            String reportContextType = lawyerUserViolation.getReportContextType();
+            if (StringUtils.isNotEmpty(reportContextType) && reportContextType.contains("6")) {
+                sendReportNoticeToReported(lawyerUserViolation);
+            }
+
+            log.info("用户举报处理完成,举报ID:{}", lawyerUserViolation.getId());
+            return result;
+
+        } catch (Exception e) {
+            log.error("用户举报处理异常,被举报用户ID:{},举报用户ID:{},异常信息:{}",
+                    lawyerUserViolation.getReportedUserId(),
+                    lawyerUserViolation.getReportingUserId(),
+                    e.getMessage(), e);
+            throw new RuntimeException("用户举报处理失败:" + e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 向举报人发送受理通知
+     *
+     * @param lawyerUserViolation 举报信息对象
+     */
+    private void sendReportNoticeToReporter(LawyerUserViolation lawyerUserViolation) {
+        try {
+            LifeNotice lifeNotice = getLifeNotice(lawyerUserViolation);
+            if (lifeNotice == null) {
+                log.warn("生成举报人通知失败,举报ID:{}", lawyerUserViolation.getId());
+                return;
+            }
+
+            int noticeResult = lifeNoticeMapper.insert(lifeNotice);
+            if (noticeResult <= 0) {
+                log.warn("保存举报人通知失败,举报ID:{}", lawyerUserViolation.getId());
+                return;
+            }
+
+            // 发送WebSocket消息
+            WebSocketVo webSocketVo = buildWebSocketVo(lifeNotice);
+            webSocketProcess.sendMessage(lifeNotice.getReceiverId(),
+                    com.alibaba.fastjson2.JSONObject.from(webSocketVo).toJSONString());
+
+            log.info("举报人通知发送成功,接收人ID:{}", lifeNotice.getReceiverId());
+
+        } catch (Exception e) {
+            log.error("向举报人发送通知异常,举报ID:{},异常信息:{}",
+                    lawyerUserViolation.getId(), e.getMessage(), e);
+        }
+    }
+
+    /**
+     * 向被举报人发送通知
+     *
+     * @param lawyerUserViolation 举报信息对象
+     */
+    private void sendReportNoticeToReported(LawyerUserViolation lawyerUserViolation) {
+        try {
+            LifeNotice lifeNoticeReported = getLifeReportedNotice(lawyerUserViolation);
+            if (lifeNoticeReported == null) {
+                log.debug("无需向被举报人发送通知,举报ID:{}", lawyerUserViolation.getId());
+                return;
+            }
+
+            int noticeResult = lifeNoticeMapper.insert(lifeNoticeReported);
+            if (noticeResult <= 0) {
+                log.warn("保存被举报人通知失败,举报ID:{}", lawyerUserViolation.getId());
+                return;
             }
+
+            // 发送WebSocket消息
+            WebSocketVo webSocketVo = buildWebSocketVo(lifeNoticeReported);
+            webSocketProcess.sendMessage(lifeNoticeReported.getReceiverId(),
+                    com.alibaba.fastjson2.JSONObject.from(webSocketVo).toJSONString());
+
+            log.info("被举报人通知发送成功,接收人ID:{}", lifeNoticeReported.getReceiverId());
+
         } catch (Exception e) {
-            log.error("LawyerUserViolationServiceImpl_reporting Error Stack={}", e.getMessage());
-            throw new Exception(e);
+            log.error("向被举报人发送通知异常,举报ID:{},异常信息:{}",
+                    lawyerUserViolation.getId(), e.getMessage(), e);
         }
-        return 0;
     }
 
+    /**
+     * 构建WebSocket消息对象
+     *
+     * @param lifeNotice 通知对象
+     * @return WebSocketVo对象
+     */
+    private WebSocketVo buildWebSocketVo(LifeNotice lifeNotice) {
+        WebSocketVo webSocketVo = new WebSocketVo();
+        webSocketVo.setSenderId("system");
+        webSocketVo.setReceiverId(lifeNotice.getReceiverId());
+        webSocketVo.setCategory("notice");
+        webSocketVo.setNoticeType("1");
+        webSocketVo.setIsRead(0);
+        webSocketVo.setText(com.alibaba.fastjson2.JSONObject.from(lifeNotice).toJSONString());
+        return webSocketVo;
+    }
+
+    /**
+     * 生成举报人通知消息
+     *
+     * @param lawyerUserViolation 举报信息对象
+     * @return 通知对象,如果生成失败返回null
+     */
     private LifeNotice getLifeNotice(LawyerUserViolation lawyerUserViolation) {
-        String phoneId = null;
+        if (lawyerUserViolation == null) {
+            log.warn("生成举报人通知失败,举报信息对象为空");
+            return null;
+        }
 
-        LifeNotice lifeNotice = new LifeNotice();
-        lifeNotice.setSenderId("system");
-        lifeNotice.setBusinessId(lawyerUserViolation.getId());
-        lifeNotice.setTitle("举报通知");
-        JSONObject jsonObject = new JSONObject();
-        String message = "平台已受理,感谢您的反馈!";
+        try {
+            LifeNotice lifeNotice = new LifeNotice();
+            lifeNotice.setSenderId("system");
+            lifeNotice.setBusinessId(lawyerUserViolation.getId());
+            lifeNotice.setTitle("举报通知");
+
+            // 获取举报人接收ID
+            String receiverId = getReporterReceiverId(lawyerUserViolation);
+            if (StringUtils.isEmpty(receiverId)) {
+                log.warn("获取举报人接收ID失败,举报ID:{}", lawyerUserViolation.getId());
+                return null;
+            }
+            lifeNotice.setReceiverId(receiverId);
 
-        String reportContextType = lawyerUserViolation.getReportContextType();
-        String reportUserId = lawyerUserViolation.getReportingUserId();
-
-        if ("3".equals(lawyerUserViolation.getReportingUserType())) {
-            LawyerUser lawyerUser = lawyerUserMapper.selectById(reportUserId);
-            phoneId = "lawyer_"+lawyerUser.getPhone();
-        } else if ("1".equals(lawyerUserViolation.getReportingUserType())) {
-            StoreUser storeUsers = storeUserMapper.selectById(reportUserId);
-            phoneId = "store_"+storeUsers.getPhone();
+            // 构建通知消息内容
+            String message = buildReporterMessage(lawyerUserViolation);
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("title", "平台已受理");
+            jsonObject.put("message", message);
+            lifeNotice.setContext(jsonObject.toJSONString());
+            lifeNotice.setNoticeType(1);
+
+            return lifeNotice;
+
+        } catch (Exception e) {
+            log.error("生成举报人通知异常,举报ID:{},异常信息:{}",
+                    lawyerUserViolation.getId(), e.getMessage(), e);
+            return null;
+        }
+    }
+
+    /**
+     * 获取举报人接收ID
+     *
+     * @param lawyerUserViolation 举报信息对象
+     * @return 接收人ID,格式:lawyer_/store_/user_ + 手机号
+     */
+    private String getReporterReceiverId(LawyerUserViolation lawyerUserViolation) {
+        String reportingUserType = lawyerUserViolation.getReportingUserType();
+        String reportingUserId = lawyerUserViolation.getReportingUserId();
+
+        if (StringUtils.isEmpty(reportingUserId)) {
+            log.warn("举报用户ID为空");
+            return null;
+        }
+
+        String phone = null;
+        if ("3".equals(reportingUserType)) {
+            LawyerUser lawyerUser = lawyerUserMapper.selectById(reportingUserId);
+            if (lawyerUser != null && StringUtils.isNotEmpty(lawyerUser.getPhone())) {
+                phone = lawyerUser.getPhone();
+                return "lawyer_" + phone;
+            }
+        } else if ("1".equals(reportingUserType)) {
+            StoreUser storeUser = storeUserMapper.selectById(reportingUserId);
+            if (storeUser != null && StringUtils.isNotEmpty(storeUser.getPhone())) {
+                phone = storeUser.getPhone();
+                return "store_" + phone;
+            }
         } else {
-            LifeUser lifeUsers = lifeUserMapper.selectById(reportUserId);
-            phoneId = "user_"+lifeUsers.getUserPhone();
+            LifeUser lifeUser = lifeUserMapper.selectById(reportingUserId);
+            if (lifeUser != null && StringUtils.isNotEmpty(lifeUser.getUserPhone())) {
+                phone = lifeUser.getUserPhone();
+                return "user_" + phone;
+            }
         }
 
-        lifeNotice.setReceiverId(phoneId);
+        log.warn("获取举报人手机号失败,用户类型:{},用户ID:{}", reportingUserType, reportingUserId);
+        return null;
+    }
+
+    /**
+     * 构建举报人通知消息内容
+     *
+     * @param lawyerUserViolation 举报信息对象
+     * @return 消息内容
+     */
+    private String buildReporterMessage(LawyerUserViolation lawyerUserViolation) {
+        String reportContextType = lawyerUserViolation.getReportContextType();
+        String defaultMessage = "平台已受理,感谢您的反馈!";
 
-        if(StringUtils.isNotEmpty(reportContextType) && "6".contains(reportContextType)){
-            String violationType = StringUtils.isNotEmpty(lawyerUserViolation.getViolationType())?lawyerUserViolation.getViolationType():"13";
+        // 如果举报内容类型包含"6",需要构建详细消息
+        if (StringUtils.isEmpty(reportContextType) || !reportContextType.contains("6")) {
+            return defaultMessage;
+        }
+
+        try {
+            // 获取违规类型文本
+            String violationType = StringUtils.isNotEmpty(lawyerUserViolation.getViolationType())
+                    ? lawyerUserViolation.getViolationType() : "13";
             String violationText = EnumUtil.getStatusValue(Integer.parseInt(violationType));
 
-            String reportedUserName = "";
-            // 查询被举报用户信息
-            String reportedUserId = lawyerUserViolation.getReportedUserId();
-            if ("3".equals(lawyerUserViolation.getReportedUserType())) {
-                LawyerUser lawyerUser = lawyerUserMapper.selectById(reportedUserId);
-                reportedUserName = lawyerUser.getName();
-            } else if ("1".equals(lawyerUserViolation.getReportedUserType())) {
-                StoreUser storeUser = storeUserMapper.selectById(reportedUserId);
-                reportedUserName = storeUser.getNickName();
-            } else {
-                LifeUser lifeUser = lifeUserMapper.selectById(reportedUserId);
-                reportedUserName = lifeUser.getUserName();
+            // 获取被举报用户名称
+            String reportedUserName = getReportedUserName(lawyerUserViolation);
+            if (StringUtils.isEmpty(reportedUserName)) {
+                log.warn("获取被举报用户名称失败,使用默认消息");
+                return defaultMessage;
             }
 
-            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-            String storeDate = simpleDateFormat.format(new Date());
-            message = "您在" + storeDate + "举报用户" + reportedUserName + ",涉嫌"+violationText+",已提交至平台审核,1-3个工作日会将审核结果发送到您应用内的消息-通知中,请注意查收。";
+            // 格式化时间
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String reportDate = dateFormat.format(new Date());
 
-        }
+            return String.format("您在%s举报用户%s,涉嫌%s,已提交至平台审核,1-3个工作日会将审核结果发送到您应用内的消息-通知中,请注意查收。",
+                    reportDate, reportedUserName, violationText);
 
-        jsonObject.put("title", "平台已受理");
-        jsonObject.put("message", message);
-        lifeNotice.setContext(jsonObject.toJSONString());
-        lifeNotice.setNoticeType(1);
-        return lifeNotice;
+        } catch (Exception e) {
+            log.error("构建举报人消息异常,使用默认消息,异常信息:{}", e.getMessage(), e);
+            return defaultMessage;
+        }
     }
 
-    private LifeNotice getLifeReportedNotice(LawyerUserViolation lawyerUserViolation) throws Exception {
-
-        // 查询被举报用户信息
-        String reportUserId = lawyerUserViolation.getReportedUserId();
-        String phoneId = "";
-        LifeNotice lifeNotice = new LifeNotice();
+    /**
+     * 获取被举报用户名称
+     *
+     * @param lawyerUserViolation 举报信息对象
+     * @return 被举报用户名称
+     */
+    private String getReportedUserName(LawyerUserViolation lawyerUserViolation) {
+        String reportedUserType = lawyerUserViolation.getReportedUserType();
+        String reportedUserId = lawyerUserViolation.getReportedUserId();
+
+        if (StringUtils.isEmpty(reportedUserId)) {
+            return null;
+        }
 
-        if ("3".equals(lawyerUserViolation.getReportedUserType())) {
-            LawyerUser lawyerUser = lawyerUserMapper.selectById(reportUserId);
-            phoneId = lawyerUser.getPhone();
-            lifeNotice.setReceiverId("lawyer_" + phoneId);
-        } else if ("1".equals(lawyerUserViolation.getReportedUserType())) {
-            StoreUser storeUser = storeUserMapper.selectById(reportUserId);
-            phoneId = storeUser.getPhone();
-            lifeNotice.setReceiverId("store_" + phoneId);
+        if ("3".equals(reportedUserType)) {
+            LawyerUser lawyerUser = lawyerUserMapper.selectById(reportedUserId);
+            return lawyerUser != null ? lawyerUser.getName() : null;
+        } else if ("1".equals(reportedUserType)) {
+            StoreUser storeUser = storeUserMapper.selectById(reportedUserId);
+            return storeUser != null ? storeUser.getNickName() : null;
         } else {
-            LifeUser lifeUser = lifeUserMapper.selectById(reportUserId);
-            phoneId = lifeUser.getUserPhone();
-            lifeNotice.setReceiverId("user_" + phoneId);
+            LifeUser lifeUser = lifeUserMapper.selectById(reportedUserId);
+            return lifeUser != null ? lifeUser.getUserName() : null;
         }
-        if (StringUtils.isEmpty(phoneId)){
+    }
+
+    /**
+     * 生成被举报人通知消息
+     *
+     * @param lawyerUserViolation 举报信息对象
+     * @return 通知对象,如果不需要发送或生成失败返回null
+     */
+    private LifeNotice getLifeReportedNotice(LawyerUserViolation lawyerUserViolation) {
+        if (lawyerUserViolation == null) {
+            log.warn("生成被举报人通知失败,举报信息对象为空");
             return null;
         }
-        String violationText = EnumUtil.getStatusValue(Integer.parseInt(lawyerUserViolation.getViolationType()));
 
-        lifeNotice.setSenderId("system");
-        lifeNotice.setBusinessId(lawyerUserViolation.getId());
-        lifeNotice.setTitle("举报通知");
-        JSONObject jsonObject = new JSONObject();
-        String message = "";
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        String storeDate = simpleDateFormat.format(new Date());
+        // 只有举报内容类型为"1"时才需要向被举报人发送通知
         String reportContextType = lawyerUserViolation.getReportContextType();
+        if (!"1".equals(reportContextType)) {
+            return null;
+        }
+
+        try {
+            // 获取被举报人接收ID
+            String receiverId = getReportedReceiverId(lawyerUserViolation);
+            if (StringUtils.isEmpty(receiverId)) {
+                log.warn("获取被举报人接收ID失败,举报ID:{}", lawyerUserViolation.getId());
+                return null;
+            }
+
+            // 构建通知消息
+            LifeNotice lifeNotice = new LifeNotice();
+            lifeNotice.setSenderId("system");
+            lifeNotice.setBusinessId(lawyerUserViolation.getId());
+            lifeNotice.setTitle("举报通知");
+            lifeNotice.setReceiverId(receiverId);
+
+            // 构建消息内容
+            String message = buildReportedMessage(lawyerUserViolation);
+            if (StringUtils.isEmpty(message)) {
+                return null;
+            }
 
-        if(StringUtils.isNotEmpty(reportContextType) && reportContextType.equals("1")){
-            message = "您在" + storeDate + "被举报涉嫌"+violationText+",平台将会进行核实。如确实存在违规行为,平台将禁用您的账号**天,到期后账号可恢复使用,应用内的环境需要我们共同维护。";
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("message", message);
+            lifeNotice.setContext(jsonObject.toJSONString());
+            lifeNotice.setNoticeType(1);
+
+            return lifeNotice;
+
+        } catch (Exception e) {
+            log.error("生成被举报人通知异常,举报ID:{},异常信息:{}",
+                    lawyerUserViolation.getId(), e.getMessage(), e);
+            return null;
+        }
+    }
+
+    /**
+     * 获取被举报人接收ID
+     *
+     * @param lawyerUserViolation 举报信息对象
+     * @return 接收人ID,格式:lawyer_/store_/user_ + 手机号
+     */
+    private String getReportedReceiverId(LawyerUserViolation lawyerUserViolation) {
+        String reportedUserType = lawyerUserViolation.getReportedUserType();
+        String reportedUserId = lawyerUserViolation.getReportedUserId();
+
+        if (StringUtils.isEmpty(reportedUserId)) {
+            log.warn("被举报用户ID为空");
+            return null;
+        }
+
+        String phone = null;
+        if ("3".equals(reportedUserType)) {
+            LawyerUser lawyerUser = lawyerUserMapper.selectById(reportedUserId);
+            if (lawyerUser != null && StringUtils.isNotEmpty(lawyerUser.getPhone())) {
+                phone = lawyerUser.getPhone();
+                return "lawyer_" + phone;
+            }
+        } else if ("1".equals(reportedUserType)) {
+            StoreUser storeUser = storeUserMapper.selectById(reportedUserId);
+            if (storeUser != null && StringUtils.isNotEmpty(storeUser.getPhone())) {
+                phone = storeUser.getPhone();
+                return "store_" + phone;
+            }
         } else {
+            LifeUser lifeUser = lifeUserMapper.selectById(reportedUserId);
+            if (lifeUser != null && StringUtils.isNotEmpty(lifeUser.getUserPhone())) {
+                phone = lifeUser.getUserPhone();
+                return "user_" + phone;
+            }
+        }
+
+        log.warn("获取被举报人手机号失败,用户类型:{},用户ID:{}", reportedUserType, reportedUserId);
+        return null;
+    }
+
+    /**
+     * 构建被举报人通知消息内容
+     *
+     * @param lawyerUserViolation 举报信息对象
+     * @return 消息内容
+     */
+    private String buildReportedMessage(LawyerUserViolation lawyerUserViolation) {
+        try {
+            // 获取违规类型文本
+            String violationType = lawyerUserViolation.getViolationType();
+            if (StringUtils.isEmpty(violationType)) {
+                log.warn("违规类型为空,无法构建被举报人消息");
+                return null;
+            }
+
+            String violationText = EnumUtil.getStatusValue(Integer.parseInt(violationType));
+
+            // 格式化时间
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String reportDate = dateFormat.format(new Date());
+
+            return String.format("您在%s被举报涉嫌%s,平台将会进行核实。如确实存在违规行为,平台将禁用您的账号**天,到期后账号可恢复使用,应用内的环境需要我们共同维护。",
+                    reportDate, violationText);
+
+        } catch (Exception e) {
+            log.error("构建被举报人消息异常,异常信息:{}", e.getMessage(), e);
             return null;
         }
-        jsonObject.put("message", message);
-        lifeNotice.setContext(jsonObject.toJSONString());
-        lifeNotice.setNoticeType(1);
-        return lifeNotice;
     }
 
     @Override