From 23527c71f374d93f82f39ac651f8481e72bde7ad Mon Sep 17 00:00:00 2001 From: gaofeng <1212121@qq.com> Date: Tue, 11 Aug 2026 11:06:09 +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/Order.php | 15 ++++++++++ app/miniapi/service/Order/OrderService.php | 35 ++++++++++++++++++++++ route/app.php | 1 + 3 files changed, 51 insertions(+) diff --git a/app/miniapi/controller/Order.php b/app/miniapi/controller/Order.php index a8b01ad..b414299 100644 --- a/app/miniapi/controller/Order.php +++ b/app/miniapi/controller/Order.php @@ -25,6 +25,21 @@ class Order extends Base return $this->ok($result['data'] ?? []); } + public function latestEvus() + { + $userId = $this->requireLogin(); + if (!is_int($userId)) { + return $userId; + } + + $result = (new OrderService())->latestEvus($userId); + if (intval($result['code'] ?? 0) !== 1) { + return $this->fail((string)($result['msg'] ?? '操作失败')); + } + + return $this->ok($result['data'] ?? null); + } + public function detail() { $userId = $this->requireLogin(); diff --git a/app/miniapi/service/Order/OrderService.php b/app/miniapi/service/Order/OrderService.php index 8c9224e..1cd576a 100644 --- a/app/miniapi/service/Order/OrderService.php +++ b/app/miniapi/service/Order/OrderService.php @@ -80,6 +80,41 @@ class OrderService return ['code' => 1, 'msg' => 'ok', 'data' => $data]; } + public function latestEvus(int $userId): array + { + $orders = []; + foreach (['pay', 'nopay'] as $payStatus) { + $result = $this->lists('evus', $payStatus, $userId); + foreach ((array)($result['data'] ?? []) as $order) { + if (is_array($order)) { + $order['pay_status_group'] = $payStatus; + $orders[] = $order; + } + } + } + + if (empty($orders)) { + return ['code' => 1, 'msg' => 'ok', 'data' => null]; + } + + usort($orders, static fn(array $left, array $right): int => (int)($right['id'] ?? 0) <=> (int)($left['id'] ?? 0)); + $latest = $orders[0]; + $orderSn = trim((string)($latest['order_sn'] ?? $latest['order_no'] ?? $latest['ordersn'] ?? '')); + if ($orderSn === '') { + return ['code' => 1, 'msg' => 'ok', 'data' => null]; + } + + $detail = $this->detail('evus', $orderSn, $userId); + if (intval($detail['code'] ?? 0) === 1 && is_array($detail['data'] ?? null)) { + $latest = array_replace($latest, $detail['data']); + } + $latest['order_sn'] = $orderSn; + $latest['business'] = 'evus'; + $latest['business_text'] = 'EVUS'; + + return ['code' => 1, 'msg' => 'ok', 'data' => $latest]; + } + public function payMoney(array $detail): string { $scopes = [$detail]; diff --git a/route/app.php b/route/app.php index d458a95..fb26de0 100644 --- a/route/app.php +++ b/route/app.php @@ -29,6 +29,7 @@ Route::group('miniapi', function () { Route::get('help/faqs', 'Help/faqs'); Route::get('order/lists', 'Order/lists'); + Route::get('order/latest-evus', 'Order/latestEvus'); Route::get('order/detail', 'Order/detail'); Route::post('order/pay', 'Order/pay'); Route::post('order/addInvoice', 'Order/addInvoice');