Просмотр исходного кода

bugfix:举报用户,ai接口修改

刘云鑫 8 часов назад
Родитель
Сommit
9e88b9844d

+ 6 - 0
alien-second/src/main/java/shop/alien/second/service/impl/SecondGoodsReportingServiceImpl.java

@@ -207,6 +207,12 @@ public class SecondGoodsReportingServiceImpl implements SecondGoodsReportingServ
 //                SecondGoodsRecord goodsRecord = secondGoodsRecordMapper.selectOne(goodsWrapper);
 //                if (null != goodsRecord) lifeuserViolation.setBusinessId(goodsRecord.getId());
 //            }
+            List<String> imgList = lifeuserViolation.getImgUrl();
+            String imgStr = "";
+            if (imgList != null && !imgList.isEmpty()) {
+                imgStr = StringUtils.join(imgList, ",");
+            }
+            lifeuserViolation.setReportEvidenceImg(imgStr);
             int result = lifeUserViolationMapper.insert(lifeuserViolation);
             if (result > 0) {
 

+ 49 - 39
alien-second/src/main/java/shop/alien/second/util/AiUserViolationUtils.java

@@ -49,7 +49,7 @@ public class AiUserViolationUtils {
     @Value("${third-party-pass-word.base-url:123456}")
     private String passWord;
 
-    @Value("${third-party-ai.report-review.base-url}")
+    @Value("${third-party-ai.reportuser-review.base-url}")
     private String userComplaintRecordUrl;
 
     @Value("${third-party-ai.report-review.base-url}")
@@ -115,36 +115,40 @@ public class AiUserViolationUtils {
         analyzeHeaders.set("Authorization", "Bearer " + accessToken);
 
         Map<String, Object> analyzeRequest = new HashedMap<>();
-//        // 对应参数
-//        if (1 == lifeuserViolation.getDictId()){
-//            analyzeRequest.put("complaint_type", "用户违规");
-//        } else if (2 == lifeuserViolation.getDictId()){
-//            analyzeRequest.put("complaint_type", "色情低俗");
-//        } else if (3 == lifeuserViolation.getDictId()){
-//            analyzeRequest.put("complaint_type", "违法违规");
-//        } else if (4 == lifeuserViolation.getDictId()){
-//            analyzeRequest.put("complaint_type", "谩骂嘲讽、煽动对立");
-//        } else if (5 == lifeuserViolation.getDictId()){
-//            analyzeRequest.put("complaint_type", "涉嫌诈骗");
-//        } else if (6 == lifeuserViolation.getDictId()){
-//            analyzeRequest.put("complaint_type", "人身攻击");
-//        } else if (7 == lifeuserViolation.getDictId()){
-//            analyzeRequest.put("complaint_type", "种族歧视");
-//        } else if (8 == lifeuserViolation.getDictId()){
-//            analyzeRequest.put("complaint_type", "政治敏感");
-//        } else if (9 == lifeuserViolation.getDictId()){
-//            analyzeRequest.put("complaint_type", "虚假、不实内容");
-//        } else if (10 == lifeuserViolation.getDictId()){
-//            analyzeRequest.put("complaint_type", "违反公德秩序");
-//        } else if (11 == lifeuserViolation.getDictId()){
-//            analyzeRequest.put("complaint_type", "危害人身安全");
-//        } else if (12 == lifeuserViolation.getDictId()){
-//            analyzeRequest.put("complaint_type", "网络暴力");
-//        } else {
-//            analyzeRequest.put("complaint_type", "其他");
-//        }
-        analyzeRequest.put("id", lifeuserViolation.getId());
-        analyzeRequest.put("type", lifeuserViolation.getReportContextType());
+        // 对应参数举报类型
+        if (1 == lifeuserViolation.getDictId()){
+            analyzeRequest.put("complaint_type", "用户违规");
+        } else if (2 == lifeuserViolation.getDictId()){
+            analyzeRequest.put("complaint_type", "色情低俗");
+        } else if (3 == lifeuserViolation.getDictId()){
+            analyzeRequest.put("complaint_type", "违法违规");
+        } else if (4 == lifeuserViolation.getDictId()){
+            analyzeRequest.put("complaint_type", "谩骂嘲讽、煽动对立");
+        } else if (5 == lifeuserViolation.getDictId()){
+            analyzeRequest.put("complaint_type", "涉嫌诈骗");
+        } else if (6 == lifeuserViolation.getDictId()){
+            analyzeRequest.put("complaint_type", "人身攻击");
+        } else if (7 == lifeuserViolation.getDictId()){
+            analyzeRequest.put("complaint_type", "种族歧视");
+        } else if (8 == lifeuserViolation.getDictId()){
+            analyzeRequest.put("complaint_type", "政治敏感");
+        } else if (9 == lifeuserViolation.getDictId()){
+            analyzeRequest.put("complaint_type", "虚假、不实内容");
+        } else if (10 == lifeuserViolation.getDictId()){
+            analyzeRequest.put("complaint_type", "违反公德秩序");
+        } else if (11 == lifeuserViolation.getDictId()){
+            analyzeRequest.put("complaint_type", "危害人身安全");
+        } else if (12 == lifeuserViolation.getDictId()){
+            analyzeRequest.put("complaint_type", "网络暴力");
+        } else {
+            analyzeRequest.put("complaint_type", "其他");
+        }
+        // 设置举报补充
+        analyzeRequest.put("complaint_text",lifeuserViolation.getOtherReasonContent());
+        // 举报凭证
+        analyzeRequest.put("evidence_urls",((SecondUserViolationVo) lifeuserViolation).getImgUrl());
+//        analyzeRequest.put("id", lifeuserViolation.getId());
+//        analyzeRequest.put("type", lifeuserViolation.getReportContextType());
 
         //举报人
         String reporterUserId = lifeuserViolation.getReportingUserId();
@@ -167,8 +171,10 @@ public class AiUserViolationUtils {
         List<LifeMessage> chatMessages = getRecentChatMessages(userReporterUserById, userReportedUserById);
 
         // 将聊天记录转换为文本格式
-        String text = convertMessagesToText(chatMessages);
-        analyzeRequest.put("conversation_context", StringUtils.hasText(text) ? text : "");
+        String text = convertMessagesToText(chatMessages,userReporterUserById);
+        analyzeRequest.put("chat_records", StringUtils.hasText(text) ? text : "");
+        analyzeRequest.put("reporter_user_id", reporterUserId);
+        analyzeRequest.put("reported_user_id", reportedUserId);
 
 //        analyzeRequest.put("text", StringUtils.hasText(text) ? text : "");
 //        analyzeRequest.put("img_urls", img_urls);
@@ -206,7 +212,7 @@ public class AiUserViolationUtils {
                 R.fail("提交用户投诉审核任务返回record_id为空");
                 return  null;
             }
-            // 解析AI审核结果
+          /*  // 解析AI审核结果
             String processingStatus = JSONObject.parseObject(analyzeResp.getBody()).getJSONObject("data").getJSONObject("result").getString("processing_status");
             boolean success = "1".equals(processingStatus);
 
@@ -215,7 +221,7 @@ public class AiUserViolationUtils {
             // 更新举报处理状态
             lifeUserViolation.setProcessingStatus(processingStatus);
             lifeUserViolation.setProcessingTime(new Date());
-            lifeUserViolationMapper.updateById(lifeUserViolation);
+            lifeUserViolationMapper.updateById(lifeUserViolation);*/
             return taskId;
         } else {
             if (analyzeResp != null) {
@@ -409,7 +415,7 @@ public class AiUserViolationUtils {
      * @param messages 聊天消息列表
      * @return 格式化后的文本字符串
      */
-    private String convertMessagesToText(List<LifeMessage> messages) {
+    private String convertMessagesToText(List<LifeMessage> messages, String userReporterUserById) {
         if (messages == null || messages.isEmpty()) {
             return "";
         }
@@ -419,9 +425,13 @@ public class AiUserViolationUtils {
         for (int i = messages.size() - 1; i >= 0; i--) {
             LifeMessage message = messages.get(i);
             // 格式:[时间] 发送者ID: 消息内容
-            sb.append("[").append(formatTime(message.getCreatedTime())).append("] ")
-                    .append(message.getSenderId()).append(": ")
-                    .append(message.getContent()).append("\n");
+            sb.append("[").append(formatTime(message.getCreatedTime())).append("] ");
+            if( message.getSenderId().equals(userReporterUserById) ) {
+                sb.append("0: ");
+            } else {
+                sb.append("1: ");
+            }
+            sb.append(message.getContent()).append("\n");
         }
 
         return sb.toString().trim();