diff --git a/app/miniapi/controller/CustomerCenter.php b/app/miniapi/controller/CustomerCenter.php index d8f1f57..5d43487 100644 --- a/app/miniapi/controller/CustomerCenter.php +++ b/app/miniapi/controller/CustomerCenter.php @@ -41,6 +41,31 @@ final class CustomerCenter extends Base return $this->ok((array)($result['data'] ?? [])); } + public function orders() + { + $userId = $this->requireLogin(); + if (!is_int($userId)) { + return $userId; + } + + $payStatus = strtolower(trim((string)$this->request->param('pay_status', 'pay'))); + if (!in_array($payStatus, ['pay', 'nopay', 'all'], true)) { + return $this->fail('支付状态参数错误'); + } + + $result = (new CustomerCenterService())->orders( + $userId, + $payStatus, + (int)$this->request->param('page', 1), + (int)$this->request->param('page_size', 20) + ); + if ((int)($result['code'] ?? 0) !== 1) { + return $this->fail((string)($result['msg'] ?? '服务异常,请稍后重试')); + } + + return $this->ok((array)($result['data'] ?? [])); + } + public function applicant() { $userId = $this->requireLogin(); diff --git a/app/miniapi/service/CustomerCenter/CustomerCenterService.php b/app/miniapi/service/CustomerCenter/CustomerCenterService.php index 9d0eae7..24ae3be 100644 --- a/app/miniapi/service/CustomerCenter/CustomerCenterService.php +++ b/app/miniapi/service/CustomerCenter/CustomerCenterService.php @@ -21,6 +21,15 @@ final class CustomerCenterService ]); } + public function orders(int $userId, string $payStatus, int $page, int $pageSize): array + { + return $this->request('orders', $userId, [ + 'pay_status' => $payStatus, + 'page' => max(1, $page), + 'page_size' => max(1, min(50, $pageSize)), + ]); + } + public function applicant(int $userId, int $applicantId): array { return $this->request('applicant', $userId, ['applicant_id' => $applicantId]); @@ -62,6 +71,7 @@ final class CustomerCenterService if (!in_array($action, [ 'applicants', 'applications', + 'orders', 'applicant', 'saveApplicant', 'removeApplicant', diff --git a/route/app.php b/route/app.php index 9e9a343..e58da31 100644 --- a/route/app.php +++ b/route/app.php @@ -36,6 +36,7 @@ Route::group('miniapi', function () { Route::get('customer-center/applicants', 'CustomerCenter/applicants'); Route::get('customer-center/applications', 'CustomerCenter/applications'); + Route::get('customer-center/orders', 'CustomerCenter/orders'); Route::post('customer-center/applicant', 'CustomerCenter/applicant'); Route::post('customer-center/applicant/save', 'CustomerCenter/saveApplicant'); Route::post('customer-center/applicant/remove', 'CustomerCenter/removeApplicant'); diff --git a/tests/customer_center_proxy_self_check.php b/tests/customer_center_proxy_self_check.php index 1e1936a..1e20291 100644 --- a/tests/customer_center_proxy_self_check.php +++ b/tests/customer_center_proxy_self_check.php @@ -29,6 +29,11 @@ customerCenterProxyAssertSame( $service->endpoint('https://uniuser.jzvisa.com/home/users/userLogin/', 'applicants'), 'The proxy endpoint must accept the trailing slash used by the site configuration' ); +customerCenterProxyAssertSame( + 'https://uniuser.jzvisa.com/home/customer_center/orders', + $service->endpoint('https://uniuser.jzvisa.com/home/users/userLogin', 'orders'), + 'Unified customer orders must use the customer center endpoint' +); customerCenterProxyAssertSame( '', $service->endpoint('https://example.com/unexpected', 'applications'),