Browse Source

fix:数据

super-yimizi 3 weeks ago
parent
commit
fdfc536c04
1 changed files with 12 additions and 11 deletions
  1. 12 11
      application/api/controller/AiMeasurement.php

+ 12 - 11
application/api/controller/AiMeasurement.php

@@ -291,9 +291,9 @@ class AiMeasurement extends Api
             $this->error('档案ID不能为空');
         }
 
-        if (empty($params['photos']) || !is_array($params['photos'])) {
-            $this->error('请上传身体照片');
-        }
+        // if (empty($params['photos']) || !is_array($params['photos'])) {
+        //     $this->error('请上传身体照片');
+        // }
 
         // try {
             // 验证档案归属
@@ -306,17 +306,19 @@ class AiMeasurement extends Api
             }
 
             // 验证照片格式
-            $requiredPhotos = ['front', 'side', 'back'];
-            foreach ($requiredPhotos as $angle) {
-                if (empty($params['photos'][$angle])) {
-                    $this->error("请上传{$angle}角度的身体照片");
-                }
-            }
+            // $requiredPhotos = ['front', 'side', 'back'];
+            // foreach ($requiredPhotos as $angle) {
+            //     if (empty($params['photos'][$angle])) {
+            //         $this->error("请上传{$angle}角度的身体照片");
+            //     }
+            // }
+            // 直接使用档案的  body_photos  字段转json
+            $photos = json_decode($profile->body_photos, true);
 
             // 安全调用第三方AI服务 - 确保身高为数字格式
             $heightCm = is_numeric($profile->height) ? floatval($profile->height) : 0;
             $measurements = $this->safeCallThirdPartyAiService(
-                $params['photos'],
+                $photos,
                 $heightCm
             );
             // echo "<pre>";
@@ -359,7 +361,6 @@ class AiMeasurement extends Api
             $requestData = [
                 'height' => $heightValue
             ];
-            
             // 处理照片数据 - 转换为base64格式
             if (isset($photos['front'])) {
                 $requestData['image1'] = $this->convertImageToBase64($photos['front']);