LIJU 2 miesięcy temu
rodzic
commit
61f65fd562

+ 12 - 0
src/main/java/cn/hnthyy/thmz/controller/taobao/TaobaoController.java

@@ -28,6 +28,18 @@ public class TaobaoController {
             if (StringUtils.isBlank(result)) {
                 return ResponseEntity.noContent().build();
             }
+            
+            // 将外部系统返回的 code 从 200 改为 0,以符合前端 request 函数的期望
+            try {
+                JSONObject jsonObject = new JSONObject(result);
+                if (jsonObject.has("code") && jsonObject.getInt("code") == 200) {
+                    jsonObject.put("code", 0);
+                    result = jsonObject.toString();
+                }
+            } catch (Exception e) {
+                log.warn("解析外部系统响应JSON失败,使用原始响应: {}", e.getMessage());
+            }
+            
             return ResponseEntity.ok()
                     .contentType(MediaType.APPLICATION_JSON)
                     .body(result);

+ 2 - 8
src/main/resources/static/js/yk/drug_storage.js

@@ -473,7 +473,7 @@ $(function () {
         }).then((res) => {
             hideLoading();
             
-            if (res && res.code === 200) {
+            if (res && res.code === 0) {
                 // 根据接口返回的数据结构,传递整个响应数据
                 processTraceCodes(res);
             } else {
@@ -481,13 +481,7 @@ $(function () {
             }
         }).catch((error) => {
             hideLoading();
-            
-            // 检查是否是成功的响应被当作错误处理了
-            if (error && error.code === 200) {
-                processTraceCodes(error);
-            } else {
-                errorMesageSimaple("获取追溯码失败:" + (error.message || "未知错误"));
-            }
+            errorMesageSimaple("获取追溯码失败:" + (error.message || "未知错误"));
         });
     }