'upgrade'] ); $ipReviewStatus = CloudBillingPresentationCatalog::status( 'fulfillment', 'review', ['purpose' => 'ip_change'] ); $provisionRefundStatus = CloudBillingPresentationCatalog::status( 'fulfillment', 'refunded', ['purpose' => 'provision'] ); $assert($upgradeStatus['label'] === '升级中' && $upgradeStatus['tone'] === 'info' && $ipReviewStatus['label'] === '待人工核对' && $ipReviewStatus['tone'] === 'warning' && $provisionRefundStatus['label'] === '开通失败,已退款' && $provisionRefundStatus['tone'] === 'danger' && CloudBillingPresentationCatalog::status( 'financial', 'void' )['label'] === '已作废', 'Purpose-aware status semantics escaped the shared catalog.'); $row = [ 'id' => '9', 'purpose' => 'backup_addon', 'amount' => '12.50', 'currency' => 'EUR', 'financial_status' => 'paid', 'fulfillment_status' => null, 'payment_method' => 'paytaro', 'created_at' => 1761984000, 'updated_at' => 1761984000, 'due_at' => 1762070400, ]; $page = CloudAdminBillingPresentation::page('invoices', [ 'items' => [$row], 'summary' => [ 'total_records' => 1, 'total_amount' => '12.50', 'currency_count' => 1, 'currency' => 'EUR', 'mixed_currency' => false, ], ]); $display = $page['items'][0]['presentation']; $assert($display['purpose_label'] === '自动备份开通' && $display['provider_label'] === 'Paytaro · 支付宝' && $display['amount_display'] === '12.50 EUR' && $display['financial_status']['label'] === '已支付' && $display['created_display'] === CloudBillingPresentationCatalog::timestamp(1761984000) && ($page['items'][0]['financial_status'] ?? null) === 'paid', 'Administrator adapter changed machine fields or diverged from the catalog.'); $assert($page['summary']['presentation']['total_amount_display'] === '12.50 EUR' && $page['summary']['presentation']['mixed_currency'] === false, 'Single-currency administrator summary ignored its frozen currency.'); $mixed = CloudAdminBillingPresentation::page('payments', [ 'items' => [], 'summary' => [ 'total_records' => 2, 'total_amount' => null, 'paid_invoice_amount' => null, 'credited_balance_amount' => null, 'currency_count' => 2, 'currency' => null, 'mixed_currency' => true, ], ]); $assert($mixed['summary']['presentation']['total_amount_display'] === '多币种' && $mixed['summary']['presentation']['paid_invoice_amount_display'] === '多币种' && $mixed['summary']['presentation']['mixed_currency'] === true, 'Mixed-currency administrator summary fabricated a combined amount.'); $user = CloudInvoicePresentation::detail([ 'invoice' => [ 'id' => '9', 'purpose' => 'backup_addon', 'amount' => '12.50', 'currency' => 'EUR', 'status' => 'paid', 'created_at' => 1761984000, 'paid_via' => 'paytaro', ], ]); $facts = array_column($user['facts'], null, 'label_key'); $assert($user['title_key'] === 'billing.purpose.backup_addon' && $user['amount_display'] === $display['amount_display'] && ($facts['billing.fact.payment_method']['value_key'] ?? null) === 'billing.payment.provider.paytaro', 'User projection stopped exposing stable copy keys for shared billing semantics.'); $voidUser = CloudInvoicePresentation::summaries([[ 'id' => '10', 'purpose' => 'recharge', 'amount' => '1.00', 'currency' => 'USD', 'status' => 'void', 'created_at' => 1761984000, ]])[0]; $assert($voidUser['status_key'] === 'billing.status.financial.void' && $voidUser['status_class'] === 'other', 'User adapter overrode the catalog financial code or tone.'); $options = $page['presentation']['catalog']; $find = static function (array $options, string $value): ?string { foreach ($options as $option) { if (($option['value'] ?? null) === $value) { return $option['label'] ?? null; } } return null; }; $assert($find($options['purpose'], 'backup_addon') === '自动备份开通' && $find($options['provider'], 'paytaro') === 'Paytaro · 支付宝' && $find($options['fulfillment'], 'queued') === null && $find($options['fulfillment'], 'review') === null, 'Server filter options diverged from row presentation labels.'); $userSource = file_get_contents( dirname(__DIR__) . '/app/Services/Cloud/CloudInvoicePresentation.php' ); $assert(is_string($userSource) && str_contains($userSource, "CloudBillingPresentationCatalog::status(\n 'financial'") && str_contains($userSource, "CloudBillingPresentationCatalog::status(\n 'fulfillment'") && !str_contains($userSource, 'match (strtolower($status))'), 'User invoice adapter rebuilt status labels outside the shared catalog.'); } finally { date_default_timezone_set($previousTimezone); } echo "Shared billing presentation catalog and administrator adapter checks passed.\n";