Эх сурвалжийг харах

bugfix:举报添加ai审核,举报管理中台添加人工复核

刘云鑫 2 сар өмнө
parent
commit
b44b62ed7a

+ 4 - 9
alien-store/src/main/java/shop/alien/store/controller/AiSearchController.java

@@ -20,22 +20,15 @@ import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.client.RestTemplate;
 import shop.alien.entity.result.R;
 import shop.alien.entity.store.StoreImg;
-import shop.alien.entity.store.StoreUser;
 import shop.alien.entity.store.vo.StoreInfoVo;
+import shop.alien.mapper.LifeBlacklistMapper;
 import shop.alien.mapper.StoreImgMapper;
-import shop.alien.mapper.StoreUserMapper;
 import shop.alien.store.annotation.TrackEvent;
 import shop.alien.store.service.CommonRatingService;
-import shop.alien.store.service.CommonRatingService;
 import shop.alien.store.service.StoreImgService;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
-import java.util.Comparator;
 
 
 @Slf4j
@@ -59,6 +52,8 @@ public class AiSearchController {
     private final StoreImgService storeImgService;
     private final CommonRatingService commonRatingService;
 
+    private final LifeBlacklistMapper lifeBlacklistMapper;
+
     @TrackEvent(
             eventType = "SEARCH",
             eventCategory = "TRAFFIC",

+ 20 - 1
alien-store/src/main/java/shop/alien/store/controller/StoreInfoController.java

@@ -24,7 +24,6 @@ import shop.alien.entity.store.vo.*;
 import shop.alien.entity.storePlatform.StoreLicenseHistory;
 import shop.alien.mapper.*;
 import shop.alien.mapper.storePlantform.StoreLicenseHistoryMapper;
-import shop.alien.store.annotation.TrackEvent;
 import shop.alien.store.config.BaseRedisService;
 import shop.alien.store.service.StoreInfoService;
 import shop.alien.store.service.StoreQualificationService;
@@ -494,6 +493,26 @@ public class StoreInfoController {
         }
     }
 
+    @ApiOperation(value = "web端人工复核举报")
+    @ApiImplicitParams({@ApiImplicitParam(name = "reportId", value = "举报ID", dataType = "int", paramType = "query"),
+            @ApiImplicitParam(name = "type", value = "类型(状态(0:待处理,1:已通过,2:已驳回))", dataType = "int", paramType = "query")})
+    @GetMapping("/manualReviewReport")
+    public R<Boolean> manualReviewReport(@RequestParam("reportId") Integer reportId, @RequestParam("type") Integer type) {
+        log.info("StoreInfoController.manualReviewReport?reportId={}&type={}", reportId, type);
+        try {
+            boolean success = storeInfoService.manualReviewReport(reportId,type);
+            if (success) {
+                return R.success("人工复核保存成功");
+            }
+            return R.fail("人工复核保存失败");
+        } catch (IllegalArgumentException e) {
+            return R.fail(e.getMessage());
+        } catch (Exception e) {
+            log.error("StoreInfoController.manualReview ERROR", e);
+            return R.fail("人工复核失败");
+        }
+    }
+
     @ApiOperation(value = "中台web端获取店铺明细详情")
     @ApiOperationSupport(order = 21)
     @GetMapping("/getNewStoreDetail")

+ 7 - 0
alien-store/src/main/java/shop/alien/store/service/StoreInfoService.java

@@ -578,4 +578,11 @@ public interface StoreInfoService extends IService<StoreInfo> {
      * @param headImgStatus 审核状态 1-审核通过,2-审核不通过
      */
     void updateHeadImgStatus(Integer storeId, Integer headImgStatus);
+    /**
+     * 人工复核举报
+     *
+     * @param reportId 举报ID
+     * @return 复核结果 true-复核通过,false-复核不通过
+     */
+    boolean manualReviewReport(Integer reportId, Integer type);
 }

+ 7 - 2
alien-store/src/main/java/shop/alien/store/service/impl/LifeUserViolationServiceImpl.java

@@ -30,6 +30,7 @@ import shop.alien.store.config.WebSocketProcess;
 import shop.alien.store.service.*;
 import shop.alien.store.util.AiUserViolationUtils;
 import shop.alien.store.util.FunctionMagic;
+import shop.alien.store.util.ai.AiReportReviewUtil;
 import shop.alien.util.ali.AliOSSUtil;
 import shop.alien.util.common.EnumUtil;
 
@@ -87,6 +88,9 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
 
     private final AiUserViolationUtils aiUserViolationUtils;
     private final CommonCommentMapper commonCommentMapper;
+    private final AiReportReviewUtil aiReportReviewUtil;
+
+
 
     @Autowired
     private SecondUserViolationMapper mapper;
@@ -110,6 +114,7 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
                 if (null != goodsRecord) lifeuserViolation.setBusinessId(goodsRecord.getId());
             }
             int result = lifeUserViolationMapper.insert(lifeuserViolation);
+            aiReportReviewUtil.reviewReport(lifeuserViolation.getId(), lifeuserViolation.getReportContextType());
             if (result > 0) {
                 // AI审核
                 //登录获取token
@@ -126,7 +131,7 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
 
                 //String phoneId = Objects.requireNonNull(JwtUtil.getCurrentUserInfo()).getString("userType") + "_" + JwtUtil.getCurrentUserInfo().getString("phone");
                     // 举报人消息
-                    LifeNotice lifeNotice = getLifeNotice(lifeuserViolation);
+                  /*  LifeNotice lifeNotice = getLifeNotice(lifeuserViolation);
                     lifeNoticeMapper.insert(lifeNotice);
                     WebSocketVo websocketVo = new WebSocketVo();
                     websocketVo.setSenderId("system");
@@ -151,7 +156,7 @@ public class LifeUserViolationServiceImpl extends ServiceImpl<LifeUserViolationM
                             websocketVoReported.setText(com.alibaba.fastjson2.JSONObject.from(lifeNoticeReported).toJSONString());
                             webSocketProcess.sendMessage(lifeNoticeReported.getReceiverId(), com.alibaba.fastjson2.JSONObject.from(websocketVoReported).toJSONString());
                         }
-                    }
+                    }*/
                 return result;
             }
         } catch (Exception e) {

+ 10 - 0
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -178,6 +178,8 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
     @Resource
     private StoreIncomeDetailsRecordService storeIncomeDetailsRecordService;
 
+    private final LifeUserViolationMapper lifeUserViolationMapper;
+
 
     @Value("${spring.web.resources.excel-path}")
     private String excelPath;
@@ -3416,6 +3418,14 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         log.info("更新门店头图审核状态,storeId={}, headImgStatus={}", storeId, headImgStatus);
     }
 
+    @Override
+    public boolean manualReviewReport(Integer reportId, Integer type) {
+        LifeUserViolation lifeUserViolation = lifeUserViolationMapper.selectById(reportId);
+        lifeUserViolation.setProcessingStatus(type.toString());
+        int i = lifeUserViolationMapper.updateById(lifeUserViolation);
+        return i > 0 ;
+    }
+
     /**
      * 获取活动banner图
      * 关联查询 store_img 和 store_operational_activity 表

+ 71 - 0
alien-store/src/main/java/shop/alien/store/util/ai/AiReportReviewUtil.java

@@ -0,0 +1,71 @@
+package shop.alien.store.util.ai;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+import org.springframework.web.client.RestTemplate;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * AI 举报审核(举报评论,举报动态)工具类
+ *
+ * @author system
+ * @since 2025-01-XX
+ */
+
+@Slf4j
+@Component
+@RefreshScope
+@RequiredArgsConstructor
+public class AiReportReviewUtil {
+
+    private final AiAuthTokenUtil aiAuthTokenUtil;
+    private final RestTemplate restTemplate;
+
+    @Value("${third-party-ai.report-review.base-url:http://124.93.18.180:9000/ai/auto-review/api/v1/merchant_dynamic_violation_audit_task/submit}")
+    private String aiReportReviewUrl;
+
+    @Async("taskExecutor")
+    public void reviewReport(Integer reportId, String reportType) {
+
+        if(!StringUtils.hasText(reportId.toString())){
+            throw new IllegalArgumentException("reportId 不能为空");
+        }
+
+        if(!StringUtils.hasText(reportType)){
+            throw new IllegalArgumentException("reportType 不能为空");
+        }
+
+
+        // 1. 登录 AI 服务,获取 token
+        String accessToken = aiAuthTokenUtil.getAccessToken();
+        if(!StringUtils.hasText(accessToken)){
+            throw new IllegalArgumentException("accessToken 不能为空");
+        }
+
+        // 构建请求体
+        Map<String, Object> requestBody = new HashMap<>();
+        requestBody.put("id", reportId);
+        requestBody.put("type", reportType);
+        // 构建请求头,添加Authorization
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.APPLICATION_JSON);
+        headers.set("Authorization", "Bearer " + accessToken);
+        HttpEntity<Map<String, Object>> request = new HttpEntity<>(requestBody, headers);
+        log.info("调用ai举报接口URL:{},requestBody: {}", aiReportReviewUrl, requestBody);
+        ResponseEntity<String> response = restTemplate.postForEntity(aiReportReviewUrl, request, String.class);
+        if(response.getStatusCode().isError()){
+            log.error("调用ai举报接口失败,URL:{},requestBody: {},response: {}", aiReportReviewUrl, requestBody, response);
+        }
+    }
+}