Browse Source

fix_营业执照错误提示

Ethan 1 month ago
parent
commit
e7f2f40bac

+ 18 - 1
app/controller/account_controller.go

@@ -1,6 +1,8 @@
 package controller
 
 import (
+	"encoding/json"
+	"fmt"
 	"github.com/gin-gonic/gin"
 	"github.com/sirupsen/logrus"
 	"youngee_b_api/app/dao"
@@ -23,8 +25,23 @@ func (t AccountController) OCRIdentify(c *gin.Context) {
 	reviewService := review_service.GetConfig()
 	resultMap, err := reviewService.CheckBusinessLicense(param)
 	if err != nil {
+		type ErrorResponse struct {
+			StatusCode                  int    `json:"status_code"`
+			RequestID                   string `json:"request_id"`
+			ErrorCode                   string `json:"error_code"`
+			ErrorMessage                string `json:"error_message"`
+			EncodedAuthorizationMessage string `json:"encoded_authorization_message"`
+		}
+		var errorResp ErrorResponse
+		// 解析 JSON 字符串
+		err1 := json.Unmarshal([]byte(err.Error()), &errorResp)
+		if err1 != nil {
+			fmt.Printf("Error parsing JSON: %v\n", err)
+			returnError(c, 40000, err.Error())
+			return
+		}
 		logrus.Errorf("[OCRIdentify] call Show err:%+v\n", err)
-		returnError(c, 40000, err.Error())
+		returnError(c, 40000, errorResp.ErrorMessage)
 		return
 	}
 	returnSuccess(c, 20000, resultMap)

+ 0 - 3
app/service/review_service/business_license_check.go

@@ -14,9 +14,6 @@ func (c *Config) CheckBusinessLicense(param *vo.IdentifyParam) (map[string]strin
 	}
 	response, err := c.OcrClient.RecognizeBusinessLicense(request)
 	if err != nil {
-		//if err.StatusCode == 400 {
-		//	return "false", err
-		//}
 		return nil, err
 	}
 	result := response.Result