浏览代码

feat(store): 更新门店OCR识别接口参数

- 将接口参数从 storeUserId 替换为 merchantName
- 调整参数校验逻辑,确保门店名称与图片URL均不为空
- 修改服务层方法签名以匹配新的参数需求
- 移除旧的数据库查询逻辑,直接使用传入的商户名称
- 优化日志记录内容,适配新参数结构
Lhaibo 1 周之前
父节点
当前提交
276c348fb1

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

@@ -897,19 +897,19 @@ public class StoreInfoController {
     @ApiOperation(value = "AI服务-门头识别")
     @ApiOperationSupport(order = 16)
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "storeUserId", value = "门店用户id", dataType = "String", paramType = "query", required = true),
-            @ApiImplicitParam(name = "imageUrl", value = "图片URL", dataType = "String", paramType = "query", required = true)
+            @ApiImplicitParam(name = "imageUrl", value = "图片URL", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "merchantName", value = "门店名称", dataType = "String", paramType = "query", required = true)
     })
     @GetMapping("/getStoreOcrData")
-    public R<Map<String, Object>> getStoreOcrData(@RequestParam("storeUserId") String storeUserId,
-                                             @RequestParam("imageUrl") String imageUrl) {
-        log.info("StoreInfoController.getStoreOcrData?storeId={},imageUrl={}", storeUserId, imageUrl);
-        if (storeUserId == null || storeUserId.trim().isEmpty() || imageUrl == null || imageUrl.trim().isEmpty()) {
-            return R.fail("门店ID与图片URL不能为空");
+    public R<Map<String, Object>> getStoreOcrData(@RequestParam("imageUrl") String imageUrl,
+                                                  @RequestParam("merchantName") String merchantName) {
+        log.info("StoreInfoController.getStoreOcrData?imageUrl={},merchantName{}", imageUrl, merchantName);
+        if (merchantName == null || merchantName.trim().isEmpty() || imageUrl == null || imageUrl.trim().isEmpty()) {
+            return R.fail("门店名称与图片URL不能为空");
         }
         Map<String, Object> ocrData = null;
         try {
-            ocrData = storeInfoService.getStoreOcrData(storeUserId, imageUrl);
+            ocrData = storeInfoService.getStoreOcrData(imageUrl, merchantName);
         } catch (Exception e) {
             return R.fail("未查询到OCR识别数据");
         }

+ 1 - 2
alien-store/src/main/java/shop/alien/store/service/StoreInfoService.java

@@ -331,11 +331,10 @@ public interface StoreInfoService extends IService<StoreInfo> {
     /**
      * 根据门店及图片地址查询最新OCR识别数据
      *
-     * @param storeUserId  门店ID
      * @param imageUrl 图片URL
      * @return OCR识别记录
      */
-    Map<String, Object> getStoreOcrData(String storeUserId, String imageUrl);
+    Map<String, Object> getStoreOcrData(String imageUrl, String merchantName);
 
     /**
      * 查询四种类型店铺(酒吧、ktv、洗浴汗蒸、按摩足浴)并按距离筛选

+ 2 - 11
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -3863,15 +3863,8 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
     }
 
     @Override
-    public Map<String, Object> getStoreOcrData(String storeUserId, String imageUrl) {
+    public Map<String, Object> getStoreOcrData(String imageUrl, String merchantName) {
         Map<String, Object> map = new HashMap<>();
-        LambdaQueryWrapper<OcrImageUpload> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(OcrImageUpload::getStoreUserId, storeUserId)
-                .eq(OcrImageUpload::getOcrType, OcrTypeEnum.BUSINESS_LICENSE.getCode());
-        OcrImageUpload ocrImageUploads = ocrImageUploadMapper.selectOne(queryWrapper);
-        if(ocrImageUploads== null){
-            throw new RuntimeException("未找到OCI识别数据!");
-        }
         String accessToken = aiAuthTokenUtil.getAccessToken();
 
         HttpHeaders aiHeaders = new HttpHeaders();
@@ -3881,9 +3874,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         List<String> imageUrls = new ArrayList<>();
         imageUrls.add(imageUrl);
         jsonBody.put("image_urls", imageUrls);
-        String ocrResult = ocrImageUploads.getOcrResult();
-        JSONObject jsonObject = JSONObject.parseObject(ocrResult);
-        jsonBody.put("merchant_name", jsonObject.get("companyName"));
+        jsonBody.put("merchant_name", merchantName);
 
         HttpEntity<Map<String, Object>> request = new HttpEntity<>(jsonBody, aiHeaders);
         ResponseEntity<String> response = null;