From 21b32e11c1f70d4073490be626362abcd0730ba8 Mon Sep 17 00:00:00 2001 From: gaofeng <1212121@qq.com> Date: Wed, 12 Aug 2026 17:58:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/miniapi/controller/CustomerCenter.php | 6 +++++- app/miniapi/controller/Upload.php | 17 +++++++++++++++-- .../CustomerCenter/CustomerCenterService.php | 7 +++++-- tests/customer_center_proxy_self_check.php | 5 +++++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/app/miniapi/controller/CustomerCenter.php b/app/miniapi/controller/CustomerCenter.php index e09032e..b6c5f21 100644 --- a/app/miniapi/controller/CustomerCenter.php +++ b/app/miniapi/controller/CustomerCenter.php @@ -77,7 +77,11 @@ final class CustomerCenter extends Base if ($applicantId <= 0) { return $this->fail('参数错误'); } - $result = (new CustomerCenterService())->applicant($userId, $applicantId); + $result = (new CustomerCenterService())->applicant( + $userId, + $applicantId, + (bool)$this->request->param('include_materials', false) + ); if ((int)($result['code'] ?? 0) !== 1) { return $this->fail((string)($result['msg'] ?? '服务异常,请稍后重试')); } diff --git a/app/miniapi/controller/Upload.php b/app/miniapi/controller/Upload.php index ff242ec..1b2817b 100644 --- a/app/miniapi/controller/Upload.php +++ b/app/miniapi/controller/Upload.php @@ -9,6 +9,16 @@ class Upload extends Base { public function image() { + $scene = strtolower(trim((string)$this->request->post('scene', ''))); + $contactUserId = 0; + if (in_array($scene, ['passport', 'id_card'], true)) { + $login = $this->requireLogin(); + if (!is_int($login)) { + return $login; + } + $contactUserId = $login; + } + $file = request()->file('file'); if (!$file) { return $this->fail('请上传图片'); @@ -45,6 +55,9 @@ class Upload extends Base } $fileName = date('YmdHis') . uniqid('', true) . '.' . $ext; + $objectKey = $contactUserId > 0 + ? 'contact/' . $contactUserId . '/' . $fileName + : $fileName; try { $client = SwooleService::getInstance(); @@ -52,7 +65,7 @@ class Upload extends Base 'type' => 'upload_ali', 'data' => [ 'Bucket' => BUCKET, - 'Key' => $fileName, + 'Key' => $objectKey, 'file_content' => base64_encode($content), ], ]); @@ -62,7 +75,7 @@ class Upload extends Base return $this->fail('上传失败,请重试'); } - $url = OSS_URL . $fileName; + $url = OSS_URL . $objectKey; return $this->ok([ 'path' => $url, 'url' => $url, diff --git a/app/miniapi/service/CustomerCenter/CustomerCenterService.php b/app/miniapi/service/CustomerCenter/CustomerCenterService.php index 24ae3be..aba9e24 100644 --- a/app/miniapi/service/CustomerCenter/CustomerCenterService.php +++ b/app/miniapi/service/CustomerCenter/CustomerCenterService.php @@ -30,9 +30,12 @@ final class CustomerCenterService ]); } - public function applicant(int $userId, int $applicantId): array + public function applicant(int $userId, int $applicantId, bool $includeMaterials = false): array { - return $this->request('applicant', $userId, ['applicant_id' => $applicantId]); + return $this->request('applicant', $userId, [ + 'applicant_id' => $applicantId, + 'include_materials' => $includeMaterials ? 1 : 0, + ]); } public function saveApplicant(int $userId, array $params): array diff --git a/tests/customer_center_proxy_self_check.php b/tests/customer_center_proxy_self_check.php index 1e20291..58ca757 100644 --- a/tests/customer_center_proxy_self_check.php +++ b/tests/customer_center_proxy_self_check.php @@ -19,6 +19,11 @@ customerCenterProxyAssertSame([ 'user_id' => 42, 'page' => 2, ], $service->payload(42, ['page' => 2]), 'The proxy request must use the original unsigned parameter style'); +$materialsJson = '[{"material_type":"passport","oss_url":"https://files.jzvisa.com/jnevus/contact/42/passport.jpg"}]'; +customerCenterProxyAssertSame([ + 'user_id' => 42, + 'materials_json' => $materialsJson, +], $service->payload(42, ['materials_json' => $materialsJson]), 'The proxy must preserve the compact material JSON payload'); customerCenterProxyAssertSame( 'https://uniuser.jzvisa.com/home/customer_center/applications', $service->endpoint('https://uniuser.jzvisa.com/home/users/userLogin', 'applications'),