From 9bc1b82e8d7c6bb1d2645d979e9cacc8a144dac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Tue, 10 Mar 2026 16:11:38 +0000 Subject: [PATCH] =?UTF-8?q?feat(platform-orders):=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=9B=9E=E6=89=A7=E7=95=99=E7=97=95=EF=BC=88?= =?UTF-8?q?meta.payment=5Freceipts=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/PlatformOrderController.php | 52 ++++++++++++++++ .../admin/platform_orders/show.blade.php | 61 +++++++++++++++++++ routes/web.php | 1 + 3 files changed, 114 insertions(+) diff --git a/app/Http/Controllers/Admin/PlatformOrderController.php b/app/Http/Controllers/Admin/PlatformOrderController.php index 99efe63..e2c7864 100644 --- a/app/Http/Controllers/Admin/PlatformOrderController.php +++ b/app/Http/Controllers/Admin/PlatformOrderController.php @@ -302,6 +302,24 @@ class PlatformOrderController extends Controller $order->paid_at = $order->paid_at ?: $now; $order->activated_at = $order->activated_at ?: $now; $order->paid_amount = $order->paid_amount > 0 ? $order->paid_amount : $order->payable_amount; + + // 兼容:若尚未写入“支付回执”,则自动补一条(可治理) + $meta = (array) ($order->meta ?? []); + $receipts = (array) (data_get($meta, 'payment_receipts', []) ?? []); + if (count($receipts) === 0) { + $receipts[] = [ + 'type' => 'manual_mark_paid', + 'channel' => (string) ($order->payment_channel ?? ''), + 'amount' => (float) $order->paid_amount, + 'paid_at' => $order->paid_at ? $order->paid_at->format('Y-m-d H:i:s') : $now->toDateTimeString(), + 'note' => '由【标记支付并生效】自动补记(可治理)', + 'created_at' => $now->toDateTimeString(), + 'admin_id' => $admin->id, + ]; + data_set($meta, 'payment_receipts', $receipts); + $order->meta = $meta; + } + $order->save(); // 立刻同步订阅 @@ -328,6 +346,40 @@ class PlatformOrderController extends Controller return redirect()->back()->with('success', '订单已标记支付并生效,订阅已同步:' . $subscription->subscription_no); } + public function addPaymentReceipt(Request $request, PlatformOrder $order): RedirectResponse + { + $admin = $this->ensurePlatformAdmin($request); + + $data = $request->validate([ + 'type' => ['required', 'string', 'max:30'], + 'channel' => ['nullable', 'string', 'max:30'], + 'amount' => ['required', 'numeric', 'min:0'], + 'paid_at' => ['nullable', 'date'], + 'note' => ['nullable', 'string', 'max:2000'], + ]); + + $now = now(); + + $meta = (array) ($order->meta ?? []); + $receipts = (array) (data_get($meta, 'payment_receipts', []) ?? []); + + $receipts[] = [ + 'type' => (string) $data['type'], + 'channel' => (string) ($data['channel'] ?? ''), + 'amount' => (float) $data['amount'], + 'paid_at' => $data['paid_at'] ? (string) $data['paid_at'] : null, + 'note' => (string) ($data['note'] ?? ''), + 'created_at' => $now->toDateTimeString(), + 'admin_id' => $admin->id, + ]; + + data_set($meta, 'payment_receipts', $receipts); + $order->meta = $meta; + $order->save(); + + return redirect()->back()->with('success', '已追加支付回执记录(仅用于对账留痕,不自动改状态)。'); + } + public function markActivated(Request $request, PlatformOrder $order): RedirectResponse { $admin = $this->ensurePlatformAdmin($request); diff --git a/resources/views/admin/platform_orders/show.blade.php b/resources/views/admin/platform_orders/show.blade.php index 7b5479d..4633055 100644 --- a/resources/views/admin/platform_orders/show.blade.php +++ b/resources/views/admin/platform_orders/show.blade.php @@ -86,6 +86,7 @@ $activation = data_get($order->meta, 'subscription_activation'); $activationError = data_get($order->meta, 'subscription_activation_error'); $audit = (array) (data_get($order->meta, 'audit', []) ?? []); + $paymentReceipts = (array) (data_get($order->meta, 'payment_receipts', []) ?? []); @endphp @php @@ -107,6 +108,64 @@ @endif +
+

支付回执(对账留痕)

+

用于“线下收款/转账/人工核对”的留痕记录(当前阶段先落 meta,不引入独立表)。

+ + @if(count($paymentReceipts) > 0) + @php $items = array_slice(array_reverse($paymentReceipts), 0, 20); @endphp + + + + + + + + + + + + + + @foreach($items as $r) + + + + + + + + + + @endforeach + +
类型渠道金额支付时间记录时间管理员备注
{{ data_get($r, 'type') ?: '-' }}{{ data_get($r, 'channel') ?: '-' }}¥{{ number_format((float) (data_get($r, 'amount') ?? 0), 2) }}{{ data_get($r, 'paid_at') ?: '-' }}{{ data_get($r, 'created_at') ?: '-' }}{{ data_get($r, 'admin_id') ?: '-' }}{{ data_get($r, 'note') ?: '' }}
+ @else +

暂无支付回执记录。

+ @endif + +
+ 追加一条支付回执(不自动改状态) +
+ @csrf +
+ + + +
+
+ +
+
+ +
+
+ +
+
+
+
+

订阅同步记录

@if($activation) @@ -145,6 +204,8 @@ $auditActionLabels = [ 'clear_sync_error' => '清除同步失败标记', 'batch_activate_subscription' => '批量同步订阅', + 'mark_activated' => '仅标记为已生效', + 'batch_mark_activated' => '批量仅标记为已生效', ]; @endphp diff --git a/routes/web.php b/routes/web.php index 3312d5f..025d81b 100644 --- a/routes/web.php +++ b/routes/web.php @@ -109,6 +109,7 @@ Route::prefix('admin')->group(function () { Route::get('/platform-orders/{order}', [PlatformOrderController::class, 'show']); Route::post('/platform-orders/{order}/activate-subscription', [PlatformOrderController::class, 'activateSubscription']); Route::post('/platform-orders/{order}/mark-paid-and-activate', [PlatformOrderController::class, 'markPaidAndActivate']); + Route::post('/platform-orders/{order}/add-payment-receipt', [PlatformOrderController::class, 'addPaymentReceipt']); Route::post('/platform-orders/{order}/mark-activated', [PlatformOrderController::class, 'markActivated']); Route::get('/site-subscriptions', [SiteSubscriptionController::class, 'index']);