Selaa lähdekoodia

add:OCR初版(未做存储)

lyx 3 viikkoa sitten
vanhempi
commit
f4cc39bf66

+ 44 - 0
alien-store/src/main/java/shop/alien/store/controller/AliController.java

@@ -315,6 +315,29 @@ public class AliController {
     }
 
     /**
+     * 支付宝OCR识别
+     *
+     * @param imageId 图片id
+     * @param ocrType OCR识别类型
+     * @return OCR识别结果
+     * @throws Exception 识别异常
+     */
+    @ApiOperation("支付宝OCR识别方式一")
+    @ApiOperationSupport(order = 14)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "imageId", value = "图片id", dataType = "String", paramType = "query", required = true),
+            @ApiImplicitParam(name = "ocrType", value = "OCR识别类型", dataType = "String", paramType = "query", required = true)
+    })
+    @GetMapping("/ocrRequest")
+    public R<JSONObject> ocrRequest(@RequestParam(value = "imageId") String imageId, @RequestParam(value = "ocrType") String ocrType) {
+        try {
+            return aliApi.ocrRequest(imageId, ocrType);
+        } catch (Exception e) {
+            return R.fail("OCR识别异常:"+e.getMessage());
+        }
+    }
+
+    /**
      * 二手委托人识别(底层调用IDcard识别)
      */
     @ApiOperation("二手委托人识别(底层调用IDcard识别)")
@@ -334,4 +357,25 @@ public class AliController {
             return R.fail(e.getMessage());
         }
     }
+
+    /**
+     * 支付宝OCR识别
+     *
+     * @return OCR识别结果
+     * @throws Exception 识别异常
+     */
+    @ApiOperation("支付宝OCR识别方式二")
+    @ApiOperationSupport(order = 15)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "ocrType", value = "OCR识别类型", dataType = "String", paramType = "query", required = true)
+    })
+    @PostMapping("/ocrRequestByBase64")
+    public R ocrRequestByBase64(MultipartFile imageFile,
+                                @RequestParam("ocrType") String ocrType) {
+        try {
+            return aliApi.ocrRequestByBase64(imageFile, ocrType);
+        } catch (Exception e) {
+            return R.fail("OCR识别异常:"+e.getMessage());
+        }
+    }
 }

+ 2 - 2
alien-store/src/main/java/shop/alien/store/util/ali/AliApi.java

@@ -212,7 +212,7 @@ public class AliApi {
                 // 保存退款信息进入到退款记录表
                 JSONObject responseBody = JSONObject.parseObject(response.getBody());
                 JSONObject refundResponse = responseBody.getJSONObject("alipay_trade_refund_response");
-
+                
                 StoreAliPayRefundLog refundLog = new StoreAliPayRefundLog();
                 // 响应基本信息
                 refundLog.setResponseCode(refundResponse.getString("code"));
@@ -254,7 +254,7 @@ public class AliApi {
                 // 标准字段
                 refundLog.setDeleteFlag(0);
                 refundLog.setCreatedTime(new Date());
-
+                
                 storeAliPayRefundLogService.save(refundLog);
 
             } else {