feat(i18n): migrate billing pages

go
codex 2 weeks ago
parent efa0eea5d4
commit e4e0f0a10a

@ -43,41 +43,45 @@ final class CloudInvoicePresentation
? $payload['invoice'] : [];
$purpose = self::purpose($invoice);
$currency = self::currency($invoice['currency'] ?? null);
[$statusLabel, $statusClass] = self::invoiceStatus(
[$statusKey, $statusClass] = self::invoiceStatus(
(string) ($invoice['display_status'] ?? $invoice['status'] ?? '')
);
$created = self::formatTimestamp(
$invoice['created_at'] ?? null,
'时间未记录'
''
);
$facts = [
['label' => '账单编号', 'value' => '#' . (string) ($invoice['id'] ?? '—')],
self::timestampFact('创建时间', $invoice['created_at'] ?? null,
'时间未记录'),
['label_key' => 'billing.fact.invoice_number',
'value' => '#' . (string) ($invoice['id'] ?? '—')],
self::timestampFact('billing.fact.created_at',
$invoice['created_at'] ?? null, ''),
];
if ($purpose === 'provision') {
$facts[] = self::timestampFact('支付截止',
$facts[] = self::timestampFact('billing.fact.payment_deadline',
$invoice['payment_deadline_at'] ?? $invoice['due_at'] ?? null);
} elseif ($purpose === 'renewal') {
$facts[] = self::timestampFact('实例到期',
$facts[] = self::timestampFact('billing.fact.instance_expiry',
$invoice['renews_expires_at'] ?? $invoice['due_at'] ?? null);
if (($invoice['deletion_at'] ?? null) !== null) {
$facts[] = self::timestampFact('最晚支付',
$facts[] = self::timestampFact('billing.fact.latest_payment',
$invoice['deletion_at']);
}
} elseif (($invoice['payment_deadline_at'] ?? null) !== null) {
$facts[] = self::timestampFact('支付截止',
$facts[] = self::timestampFact('billing.fact.payment_deadline',
$invoice['payment_deadline_at']);
}
if (($invoice['paid_at'] ?? null) !== null) {
$facts[] = self::timestampFact('支付时间',
$facts[] = self::timestampFact('billing.fact.paid_at',
$invoice['paid_at']);
}
if (trim((string) ($invoice['paid_via'] ?? '')) !== '') {
$provider = strtolower(trim((string) $invoice['paid_via']));
$facts[] = [
'label' => '支付方式',
'value' => self::paymentLabel((string) $invoice['paid_via']),
'label_key' => 'billing.fact.payment_method',
'value' => self::providerKey($provider) === ''
? $provider : '',
'value_key' => self::providerKey($provider),
];
}
@ -89,7 +93,11 @@ final class CloudInvoicePresentation
}
$label = trim((string) ($item['label'] ?? ''));
$lineItems[] = [
'label' => $label !== '' ? $label : '费用项目',
'label' => $label,
'label_key' => self::lineItemKey(
(string) ($item['code'] ?? ''),
$purpose
),
'amount_display' => self::formatMoney(
$item['amount'],
self::currency($item['currency'] ?? $currency)
@ -103,18 +111,15 @@ final class CloudInvoicePresentation
return [
'id' => (string) ($invoice['id'] ?? ''),
'title' => self::invoiceTitle($invoice, $purpose),
'number_text' => '账单 #' . (string) ($invoice['id'] ?? '—'),
'title_key' => self::invoiceTitleKey($purpose),
'number_parameters' => ['id' => (string) ($invoice['id'] ?? '—')],
'created_at' => self::timestampValue($invoice['created_at'] ?? null),
'created_text' => '创建于 ' . $created,
'subtitle' => '账单 #' . (string) ($invoice['id'] ?? '—')
. ' · ' . $created,
'created_display' => $created,
'amount_display' => self::formatMoney(
$invoice['amount'] ?? null,
$currency
),
'status_label' => $statusLabel,
'status_key' => $statusKey,
'status_class' => $statusClass,
'facts' => $facts,
'show_line_items' => $lineItems !== [],
@ -122,16 +127,18 @@ final class CloudInvoicePresentation
'show_specification' => $specification !== [],
'specification' => $specification,
'show_payment' => $payment['show_payment'],
'payment_title' => $payment['payment_title'],
'payment_description' => $payment['payment_description'],
'active_payment_message' => $payment['active_payment_message'],
'payment_title_key' => $payment['payment_title_key'],
'payment_description_key' => $payment['payment_description_key'],
'active_payment_key' => $payment['active_payment_key'],
'active_payment_class' => $payment['active_payment_class'],
'payment_methods' => $payment['payment_methods'],
'show_fulfillment' => $fulfillment['show_fulfillment'],
'fulfillment_title' => $fulfillment['fulfillment_title'],
'fulfillment_description' => $fulfillment['fulfillment_description'],
'fulfillment_message' => $fulfillment['fulfillment_message'],
'fulfillment_label' => $fulfillment['fulfillment_label'],
'fulfillment_title_key' => $fulfillment['fulfillment_title_key'],
'fulfillment_description_key' =>
$fulfillment['fulfillment_description_key'],
'fulfillment_message_key' =>
$fulfillment['fulfillment_message_key'],
'fulfillment_key' => $fulfillment['fulfillment_key'],
'fulfillment_class' => $fulfillment['fulfillment_class'],
'fulfillment_failed' => $fulfillment['fulfillment_failed'],
'task_id' => $fulfillment['task_id'],
@ -162,7 +169,7 @@ final class CloudInvoicePresentation
$invoice = is_array($payload['invoice'] ?? null)
? $payload['invoice'] : $payload;
$purpose = self::purpose($invoice);
[$statusLabel, $statusClass] = self::invoiceStatus(
[$statusKey, $statusClass] = self::invoiceStatus(
(string) ($invoice['display_status'] ?? $invoice['status'] ?? '')
);
$fulfillment = self::fulfillmentProjection($invoice, $purpose);
@ -194,13 +201,13 @@ final class CloudInvoicePresentation
'status' => [
'code' => (string) ($invoice['display_status']
?? $invoice['status'] ?? ''),
'label' => $statusLabel,
'copy_key' => $statusKey,
'class' => $statusClass,
],
'payment' => [
'payable' => ($invoice['payable'] ?? false) === true,
'active' => $activePayment,
'message' => $activePaymentMessage,
'message_key' => $activePaymentMessage,
'message_class' => $activePaymentClass,
],
'fulfillment' => $fulfillment,
@ -237,7 +244,7 @@ final class CloudInvoicePresentation
{
$purpose = self::purpose($invoice);
$status = strtolower((string) ($invoice['status'] ?? ''));
[$statusLabel, $statusClass] = self::invoiceStatus(
[$statusKey, $statusClass] = self::invoiceStatus(
(string) ($invoice['display_status'] ?? $invoice['status'] ?? '')
);
$fulfillmentStatus = strtolower((string) (
@ -246,23 +253,23 @@ final class CloudInvoicePresentation
?? $invoice['order_status']
?? ''
));
[$fulfillmentLabel, $fulfillmentClass] = self::invoiceFulfillmentStatus(
[$fulfillmentKey, $fulfillmentClass] = self::invoiceFulfillmentStatus(
$fulfillmentStatus,
$purpose
);
$invoice['title'] = self::invoiceTitle($invoice, $purpose);
$invoice['title_key'] = self::invoiceTitleKey($purpose);
$invoice['created_display'] = self::formatTimestamp(
$invoice['created_at'] ?? null,
'时间未记录'
''
);
$invoice['amount_display'] = self::formatMoney(
$invoice['amount'] ?? null,
self::currency($invoice['currency'] ?? null)
);
$invoice['status_label'] = $statusLabel;
$invoice['status_key'] = $statusKey;
$invoice['status_class'] = $statusClass;
$invoice['fulfillment_label'] = $fulfillmentLabel;
$invoice['fulfillment_key'] = $fulfillmentKey;
$invoice['fulfillment_class'] = $fulfillmentClass;
$invoice['show_fulfillment'] = (($purpose === 'provision'
&& in_array($status, ['paid', 'refunded'], true))
@ -272,8 +279,7 @@ final class CloudInvoicePresentation
$invoice['job_status'] ?? null,
$invoice['fulfillment_status'] ?? null
) !== ''))
&& $fulfillmentLabel !== '';
$invoice['context_display'] = self::context($invoice, $purpose, $status);
&& $fulfillmentKey !== '';
$invoice['context_segments'] = self::contextSegments(
$invoice, $purpose, $status
);
@ -284,57 +290,27 @@ final class CloudInvoicePresentation
}
/** @param array<string, mixed> $invoice */
private static function context(array $invoice, string $purpose,
string $status): string
{
if ($purpose === 'renewal') {
$context = '对应实例到期 ' . self::formatTimestamp(
$invoice['renews_expires_at'] ?? $invoice['due_at'] ?? null,
'时间未记录'
);
if (in_array($status, ['open', 'overdue'], true)) {
$context .= ' · 最晚支付 ' . self::formatTimestamp(
$invoice['payment_deadline_at'] ?? null,
'时间未记录'
);
}
return $context;
}
if ($purpose === 'provision') {
return '支付截止 ' . self::formatTimestamp(
$invoice['payment_deadline_at'] ?? $invoice['due_at'] ?? null,
'时间未记录'
);
}
if (in_array($purpose, ['upgrade', 'ip_change', 'backup_addon'], true)) {
$target = self::firstText($invoice['instance_name'] ?? null);
if ($target === '' && ($invoice['instance_id'] ?? null) !== null) {
$target = '#' . (string) $invoice['instance_id'];
}
return '目标实例 ' . ($target !== '' ? $target : '实例');
}
return '';
}
/**
* Preserve the server-owned context vocabulary while exposing canonical
* timestamps for browser-local formatting.
*
* @param array<string, mixed> $invoice
* @return array<int, array{kind: string, value: int|string}>
* @return array<int, array<string, mixed>>
*/
private static function contextSegments(array $invoice, string $purpose,
string $status): array
{
if ($purpose === 'renewal') {
$segments = [
['kind' => 'text', 'value' => '对应实例到期 '],
['kind' => 'copy',
'key' => 'billing.context.renewal_expiry'],
['kind' => 'timestamp', 'value' => self::timestampValue(
$invoice['renews_expires_at'] ?? $invoice['due_at'] ?? null
) ?? 0],
];
if (in_array($status, ['open', 'overdue'], true)) {
$segments[] = ['kind' => 'text', 'value' => ' · 最晚支付 '];
$segments[] = ['kind' => 'copy',
'key' => 'billing.context.latest_payment'];
$segments[] = ['kind' => 'timestamp', 'value' =>
self::timestampValue($invoice['payment_deadline_at'] ?? null)
?? 0];
@ -343,7 +319,8 @@ final class CloudInvoicePresentation
}
if ($purpose === 'provision') {
return [
['kind' => 'text', 'value' => '支付截止 '],
['kind' => 'copy',
'key' => 'billing.context.payment_deadline'],
['kind' => 'timestamp', 'value' => self::timestampValue(
$invoice['payment_deadline_at'] ?? $invoice['due_at'] ?? null
) ?? 0],
@ -354,8 +331,13 @@ final class CloudInvoicePresentation
if ($target === '' && ($invoice['instance_id'] ?? null) !== null) {
$target = '#' . (string) $invoice['instance_id'];
}
return [['kind' => 'text', 'value' => '目标实例 '
. ($target !== '' ? $target : '实例')]];
return [[
'kind' => 'copy',
'key' => 'billing.context.target_instance',
'parameters' => [
'name' => $target !== '' ? $target : '—',
],
]];
}
return [];
}
@ -374,11 +356,14 @@ final class CloudInvoicePresentation
if ($payable && $balancePaymentAllowed) {
$paymentMethods[] = [
'id' => 'balance',
'name' => '账户余额',
'description' => '可用余额 ' . self::formatMoney(
$payload['balance'] ?? null,
$currency
),
'name_key' => 'billing.payment.balance.name',
'description_key' => 'billing.payment.balance.description',
'description_parameters' => [
'amount' => self::formatMoney(
$payload['balance'] ?? null,
$currency
),
],
'selected' => true,
];
}
@ -388,12 +373,17 @@ final class CloudInvoicePresentation
if (!is_array($method) || !isset($method['id'], $method['name'])) {
continue;
}
$methodId = (string) $method['id'];
$paymentMethods[] = [
'id' => (string) $method['id'],
'id' => $methodId,
'name' => (string) $method['name'],
'name_key' => self::providerKey($methodId),
'description' => trim((string) (
$method['description'] ?? $method['label'] ?? ''
)) ?: '在线支付',
)),
'description_key' => trim((string) (
$method['description'] ?? $method['label'] ?? ''
)) === '' ? 'billing.payment.online_fallback' : '',
'selected' => false,
];
}
@ -414,14 +404,15 @@ final class CloudInvoicePresentation
return [
'show_payment' => $hasActivePayment
|| ($payable && $paymentMethods !== []),
'payment_title' => $payable && $paymentMethods !== []
? '选择支付方式' : '当前支付状态',
'payment_description' => $hasActivePayment && $payable
? '已有未完成支付订单;任一订单先到账即结清账单,后续到账款项将计入账户余额。'
'payment_title_key' => $payable && $paymentMethods !== []
? 'billing.payment.select_title'
: 'billing.payment.status_title',
'payment_description_key' => $hasActivePayment && $payable
? 'billing.payment.description.active'
: ($payable
? '选择支付方式后,点击“立即支付”将直接发起支付,请勿重复点击。'
: '该账单当前不可创建新的支付订单。'),
'active_payment_message' => $activePaymentMessage,
? 'billing.payment.description.choose'
: 'billing.payment.description.unavailable'),
'active_payment_key' => $activePaymentMessage,
'active_payment_class' => $activePaymentClass,
'payment_methods' => $paymentMethods,
];
@ -435,9 +426,9 @@ final class CloudInvoicePresentation
{
$status = strtolower((string) ($activePayment['status'] ?? ''));
$message = match ($status) {
'creating' => '上一笔支付订单正在创建;您仍可选择其他支付方式。',
'pending' => '已有待支付订单;可继续原订单或选择其他支付方式。',
'review' => '上一笔支付订单结果待核对;可选择其他支付方式,原订单若随后到账将计入账户余额。',
'creating' => 'billing.payment.active.creating',
'pending' => 'billing.payment.active.pending',
'review' => 'billing.payment.active.review',
default => '',
};
return [
@ -463,7 +454,7 @@ final class CloudInvoicePresentation
$fulfillment['order_status'] ?? null,
$invoice['order_status'] ?? null
));
[$label, $class] = self::invoiceFulfillmentStatus(
[$labelKey, $class] = self::invoiceFulfillmentStatus(
$fulfillmentStatus,
$purpose
);
@ -474,36 +465,36 @@ final class CloudInvoicePresentation
$fulfillment['task_id'] ?? null,
$invoice['task_id'] ?? null
) !== '');
$error = self::firstText(
$hasError = self::firstText(
$fulfillment['error'] ?? null,
$invoice['error'] ?? null
);
$message = $error;
if ($message === '') {
$message = $label !== '' ? $label : match ($purpose) {
'upgrade' => '等待升级',
'ip_change' => '等待更换公网 IPv4',
default => '等待创建',
};
}
) !== '';
$messageKey = $labelKey !== '' ? $labelKey : match ($purpose) {
'upgrade' => 'billing.fulfillment.waiting.upgrade',
'ip_change' => 'billing.fulfillment.waiting.ip_change',
'provision' => 'billing.fulfillment.waiting.provision',
default => 'billing.fulfillment.waiting.generic',
};
return [
'show_fulfillment' => $show,
'fulfillment_title' => match ($purpose) {
'upgrade' => '实例升级进度',
'ip_change' => '公网 IPv4 更换进度',
default => '实例创建进度',
'fulfillment_title_key' => match ($purpose) {
'upgrade' => 'billing.fulfillment.title.upgrade',
'ip_change' => 'billing.fulfillment.title.ip_change',
'provision' => 'billing.fulfillment.title.provision',
default => 'billing.fulfillment.title.generic',
},
'fulfillment_description' => match ($purpose) {
'upgrade' => '账单扣款后,系统会在后台升级实例;关闭页面不会取消任务。',
'ip_change' => '账单扣款后,系统会在后台更换公网 IPv4;公网 IPv6 保持不变,关闭页面不会取消任务。',
default => '账单付款后,系统会在后台创建实例;关闭页面不会取消任务。',
'fulfillment_description_key' => match ($purpose) {
'upgrade' => 'billing.fulfillment.description.upgrade',
'ip_change' => 'billing.fulfillment.description.ip_change',
'provision' => 'billing.fulfillment.description.provision',
default => 'billing.fulfillment.description.generic',
},
'fulfillment_message' => $message,
'fulfillment_label' => $label,
'fulfillment_message_key' => $messageKey,
'fulfillment_key' => $labelKey,
'fulfillment_class' => $class,
'fulfillment_failed' => $message !== ''
&& ($error !== '' || in_array(
'fulfillment_failed' => $messageKey !== ''
&& ($hasError || in_array(
$fulfillmentStatus,
['failed', 'refunded', 'cancelled'],
true
@ -544,7 +535,7 @@ final class CloudInvoicePresentation
/**
* @param array<string, mixed> $invoice
* @param array<string, mixed> $fulfillment
* @return array{message: string, tone: string}|null
* @return array{copy_key: string, tone: string}|null
*/
private static function completionNotice(array $invoice, string $purpose,
array $fulfillment): ?array
@ -555,10 +546,11 @@ final class CloudInvoicePresentation
if ($purpose === 'upgrade') {
return match ($taskStatus) {
'succeeded', 'completed' => [
'message' => '实例升级完成。', 'tone' => 'success',
'copy_key' => 'billing.notice.upgrade_succeeded',
'tone' => 'success',
],
'failed', 'cancelled', 'canceled' => [
'message' => '实例升级未完成,请在账单详情查看任务状态。',
'copy_key' => 'billing.notice.upgrade_failed',
'tone' => 'error',
],
default => null,
@ -567,15 +559,15 @@ final class CloudInvoicePresentation
if ($purpose === 'ip_change') {
return match ($taskStatus) {
'succeeded', 'completed' => [
'message' => '公网 IPv4 已更换;公网 IPv6 保持不变。',
'copy_key' => 'billing.notice.ip_change_succeeded',
'tone' => 'success',
],
'review' => [
'message' => '公网 IPv4 更换结果待人工核对,请勿重复提交。',
'copy_key' => 'billing.notice.ip_change_review',
'tone' => 'error',
],
'failed', 'cancelled', 'canceled' => [
'message' => '公网 IPv4 更换未完成,请在账单详情查看任务状态。',
'copy_key' => 'billing.notice.ip_change_failed',
'tone' => 'error',
],
default => null,
@ -584,44 +576,45 @@ final class CloudInvoicePresentation
if ($purpose === 'provision') {
return match ($taskStatus) {
'succeeded', 'completed' => [
'message' => '实例已创建完成。', 'tone' => 'success',
'copy_key' => 'billing.notice.provision_succeeded',
'tone' => 'success',
],
'refunded' => [
'message' => '实例创建失败,款项已退回账户余额。',
'copy_key' => 'billing.notice.provision_refunded',
'tone' => 'error',
],
'failed', 'expired', 'cancelled', 'canceled' => [
'message' => '实例开通未完成,请在账单详情查看任务状态。',
'copy_key' => 'billing.notice.provision_failed',
'tone' => 'error',
],
default => null,
};
}
return [
'message' => $purpose === 'renewal'
? '账单支付成功,服务期限已延长。' : '账单支付成功。',
'copy_key' => $purpose === 'renewal'
? 'billing.notice.renewal_paid' : 'billing.notice.paid',
'tone' => 'success',
];
}
if (in_array($status, ['void', 'expired'], true)) {
return [
'message' => '账单已失效,到账金额会保留在账户余额中。',
'copy_key' => 'billing.notice.expired',
'tone' => 'error',
];
}
if ($status === 'refunded') {
return [
'message' => '实例创建失败,款项已退回账户余额。',
'copy_key' => 'billing.notice.refunded',
'tone' => 'error',
];
}
if (($invoice['payable'] ?? false) !== true
&& in_array($status, ['open', 'overdue'], true)) {
return [
'message' => match ($purpose) {
'provision' => '开通账单已超过支付截止时间。',
'renewal' => '续费宽限期已经结束,到账金额会保留在账户余额中。',
default => '账单已超过支付截止时间。',
'copy_key' => match ($purpose) {
'provision' => 'billing.notice.provision_deadline',
'renewal' => 'billing.notice.renewal_deadline',
default => 'billing.notice.deadline',
},
'tone' => 'error',
];
@ -631,7 +624,7 @@ final class CloudInvoicePresentation
/**
* @param array<string, mixed> $invoice
* @return array<int, array{label: string, value: string}>
* @return array<int, array<string, mixed>>
*/
private static function specification(array $invoice, string $purpose): array
{
@ -642,53 +635,81 @@ final class CloudInvoicePresentation
$invoice['instance_name'] ?? null
);
$specification[] = [
'label' => '实例',
'label_key' => 'billing.spec.instance',
'value' => $subject !== ''
? $subject
: ($purpose === 'provision' ? '待创建实例' : '实例'),
: '',
'value_key' => $subject !== '' ? ''
: ($purpose === 'provision'
? 'billing.spec.pending_instance'
: 'billing.spec.instance_fallback'),
];
$planName = trim((string) ($invoice['plan_name'] ?? ''));
$specification[] = [
'label' => '套餐',
'value' => $planName !== '' ? $planName : '云服务器套餐',
'label_key' => 'billing.spec.plan',
'value' => $planName,
'value_key' => $planName !== '' ? ''
: 'billing.spec.plan_fallback',
];
if (($invoice['cpu_cores'] ?? null) !== null) {
$specification[] = [
'label' => 'CPU',
'value' => (string) $invoice['cpu_cores'] . ' 核',
'label_key' => 'billing.spec.cpu',
'value_key' => 'billing.spec.cpu_value',
'value_parameters' => [
'value' => (float) $invoice['cpu_cores'],
],
];
}
if (($invoice['memory_mib'] ?? null) !== null) {
$specification[] = [
'label' => '内存',
'value' => self::formatMemory((int) $invoice['memory_mib']),
'label_key' => 'billing.spec.memory',
'value_key' => 'billing.spec.memory_value',
'value_parameters' => [
'value' => self::formatMemory(
(int) $invoice['memory_mib']
),
],
];
}
if (($invoice['disk_gib'] ?? null) !== null) {
$specification[] = [
'label' => '系统盘',
'value' => (string) $invoice['disk_gib'] . ' GB',
'label_key' => 'billing.spec.disk',
'value_key' => 'billing.spec.disk_value',
'value_parameters' => [
'value' => (float) $invoice['disk_gib'],
],
];
}
if (($invoice['bandwidth_mbps'] ?? null) !== null) {
$specification[] = [
'label' => '带宽',
'value' => (string) $invoice['bandwidth_mbps'] . ' Mbps',
'label_key' => 'billing.spec.bandwidth',
'value_key' => 'billing.spec.bandwidth_value',
'value_parameters' => [
'value' => (float) $invoice['bandwidth_mbps'],
],
];
}
if ($purpose !== 'upgrade') {
$specification[] = [
'label' => '服务周期',
'value' => max(0, (int) ($invoice['validity_days'] ?? 0)) . ' 天',
'label_key' => 'billing.spec.service_period',
'value_key' => 'billing.spec.days_value',
'value_parameters' => [
'value' => max(0,
(int) ($invoice['validity_days'] ?? 0)),
],
];
}
$specification[] = [
'label' => $purpose === 'upgrade'
? '目标周期流量' : '周期流量',
'value' => self::formatBytes(
max(0, (int) ($invoice['traffic_quota_bytes'] ?? 0)),
true
),
'label_key' => $purpose === 'upgrade'
? 'billing.spec.target_period_traffic'
: 'billing.spec.period_traffic',
'value' => max(0,
(int) ($invoice['traffic_quota_bytes'] ?? 0)) === 0
? '' : self::formatBytes(max(0,
(int) ($invoice['traffic_quota_bytes'] ?? 0))),
'value_key' => max(0,
(int) ($invoice['traffic_quota_bytes'] ?? 0)) === 0
? 'billing.spec.unlimited_traffic' : '',
];
} elseif (in_array($purpose, ['ip_change', 'backup_addon'], true)) {
$subject = self::firstText($invoice['instance_name'] ?? null);
@ -696,13 +717,16 @@ final class CloudInvoicePresentation
$subject = '#' . (string) $invoice['instance_id'];
}
$specification[] = [
'label' => '实例',
'value' => $subject !== '' ? $subject : '实例',
'label_key' => 'billing.spec.instance',
'value' => $subject,
'value_key' => $subject !== '' ? ''
: 'billing.spec.instance_fallback',
];
$specification[] = [
'label' => '服务内容',
'value' => $purpose === 'ip_change'
? '更换公网 IPv4' : '自动备份开通',
'label_key' => 'billing.spec.service_content',
'value_key' => $purpose === 'ip_change'
? 'billing.spec.ip_change'
: 'billing.spec.backup_addon',
];
}
return $specification;
@ -716,15 +740,12 @@ final class CloudInvoicePresentation
);
}
/** @param array<string, mixed> $invoice */
private static function invoiceTitle(array $invoice, string $purpose): string
private static function invoiceTitleKey(string $purpose): string
{
$known = CloudBillingPresentationCatalog::knownPurposeLabel($purpose);
return $known !== '' ? $known : self::firstText(
$invoice['title'] ?? null,
$invoice['type_label'] ?? null,
'账单'
);
return in_array($purpose, [
'provision', 'renewal', 'upgrade', 'ip_change',
'backup_addon', 'recharge',
], true) ? 'billing.purpose.' . $purpose : 'billing.purpose.invoice';
}
/** @return array{0: string, 1: string} */
@ -733,8 +754,16 @@ final class CloudInvoicePresentation
$entry = CloudBillingPresentationCatalog::status(
'financial', $status
);
$known = [
'open', 'renewal_grace', 'overdue', 'paid', 'refunded',
'expired', 'void', 'deleting', 'purge_deleting',
'purge_pending', 'purge_stopping', 'purge_force_required',
'delete_failed', 'purge_stop_failed', 'purge_failed',
];
return [
$entry['code'] === '' ? '未知' : $entry['label'],
in_array($entry['code'], $known, true)
? 'billing.status.financial.' . $entry['code']
: 'billing.status.financial.unknown',
self::userStatusClass($entry['tone']),
];
}
@ -749,7 +778,46 @@ final class CloudInvoicePresentation
if ($entry['code'] === '') {
return ['', ''];
}
return [$entry['label'], self::userStatusClass($entry['tone'])];
$code = $entry['code'];
$inProgress = in_array($code,
['queued', 'pending', 'provisioning', 'running', 'active'], true);
$succeeded = in_array($code, ['completed', 'succeeded'], true);
$key = match (true) {
$purpose === 'renewal' && $succeeded =>
'billing.status.fulfillment.renewal_succeeded',
$purpose === 'upgrade' && $inProgress =>
'billing.status.fulfillment.upgrade_running',
$purpose === 'upgrade' && $succeeded =>
'billing.status.fulfillment.upgrade_succeeded',
$purpose === 'upgrade' && $code === 'failed' =>
'billing.status.fulfillment.upgrade_failed',
$purpose === 'ip_change' && $inProgress =>
'billing.status.fulfillment.ip_change_running',
$purpose === 'ip_change' && $succeeded =>
'billing.status.fulfillment.ip_change_succeeded',
$purpose === 'ip_change' && $code === 'failed' =>
'billing.status.fulfillment.ip_change_failed',
$purpose === 'provision' && $inProgress =>
'billing.status.fulfillment.provision_running',
$purpose === 'provision' && $succeeded =>
'billing.status.fulfillment.provision_succeeded',
$purpose === 'provision' && $code === 'failed' =>
'billing.status.fulfillment.provision_failed',
$purpose === 'provision' && $code === 'refunded' =>
'billing.status.fulfillment.provision_refunded',
in_array($code, ['awaiting_payment', 'payment_pending', 'draft'], true)
=> 'billing.status.fulfillment.awaiting_payment',
$inProgress => 'billing.status.fulfillment.running',
$succeeded => 'billing.status.fulfillment.succeeded',
$code === 'review' => 'billing.status.fulfillment.review',
$code === 'failed' => 'billing.status.fulfillment.failed',
$code === 'expired' => 'billing.status.fulfillment.expired',
$code === 'refunded' => 'billing.status.fulfillment.refunded',
in_array($code, ['cancelled', 'canceled'], true) =>
'billing.status.fulfillment.cancelled',
default => 'billing.status.fulfillment.none',
};
return [$key, self::userStatusClass($entry['tone'])];
}
private static function userStatusClass(string $tone): string
@ -763,24 +831,45 @@ final class CloudInvoicePresentation
}
private static function formatTimestamp($value,
string $fallback = '暂未提供'): string
string $fallback = ''): string
{
return CloudBillingPresentationCatalog::timestamp(
$value, $fallback, 'Y/m/d H:i:s'
);
}
/** @return array{label: string, value: string, timestamp: int|null} */
private static function timestampFact(string $label, $value,
string $fallback = '暂未提供'): array
/** @return array{label_key: string, value: string, value_key: string, timestamp: int|null} */
private static function timestampFact(string $labelKey, $value,
string $fallback = ''): array
{
$timestamp = self::timestampValue($value);
return [
'label' => $label,
'label_key' => $labelKey,
'value' => self::formatTimestamp($value, $fallback),
'timestamp' => self::timestampValue($value),
'value_key' => $timestamp === null
? 'billing.value.time_missing' : '',
'timestamp' => $timestamp,
];
}
private static function lineItemKey(string $code, string $purpose): string
{
return match (strtolower(trim($code))) {
'base', 'plan', 'instance', 'provision' => $purpose === 'renewal'
? 'billing.line_items.renewal_plan'
: 'billing.line_items.plan',
'renewal', 'plan_renewal', 'base_renewal' =>
'billing.line_items.renewal_plan',
'backup', 'automatic_backup' => $purpose === 'renewal'
? 'billing.line_items.backup_renewal'
: 'billing.line_items.backup',
'backup_renewal' => 'billing.line_items.backup_renewal',
'backup_addon', 'automatic_backup_activation' =>
'billing.line_items.backup_addon',
default => '',
};
}
private static function timestampValue($value): ?int
{
return is_numeric($value) && (int) $value > 0 ? (int) $value : null;
@ -794,15 +883,11 @@ final class CloudInvoicePresentation
$memoryGiB === floor($memoryGiB) ? 0 : 1,
'.',
','
) . ' GB';
);
}
private static function formatBytes(int $bytes,
bool $unlimitedZero = false): string
private static function formatBytes(int $bytes): string
{
if ($bytes === 0 && $unlimitedZero) {
return '不限流量';
}
$units = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'];
$amount = (float) $bytes;
$unit = 0;
@ -814,9 +899,13 @@ final class CloudInvoicePresentation
return number_format($amount, $precision, '.', '') . ' ' . $units[$unit];
}
private static function paymentLabel(string $paidVia): string
private static function providerKey(string $paidVia): string
{
return CloudBillingPresentationCatalog::providerLabel($paidVia, '');
$code = strtolower(trim($paidVia));
return in_array($code, [
'balance', 'usdt', 'yipay_alipay', 'yipay_wxpay', 'paytaro',
'stripe_card', 'stripe_alipay',
], true) ? 'billing.payment.provider.' . $code : '';
}
private static function currency($value): string

@ -12,8 +12,10 @@ const [toastModule, taskObserver] = await Promise.all([
import(versionedModuleUrl('./task-observer.js')),
]);
const { toast } = toastModule;
const i18n = globalThis.VenixUserCopy;
const t = (key, parameters = {}) => i18n.text(key, parameters);
const {
announceTaskAccepted, observeTask, recoveryTaskFailureNotice,
announceTaskAccepted, observeTask,
taskSucceededWithoutRecovery, taskUrl,
} = taskObserver;
@ -72,14 +74,12 @@ function firstText(...values) {
}
function terminalTaskProblem(task, fallback) {
const recoveryNotice = recoveryTaskFailureNotice(task);
if (recoveryNotice) return recoveryNotice;
const message = firstText(task?.error, fallback);
const message = fallback;
if (task?.effect_may_have_applied === true) {
return `${message} 操作效果可能已经发生,请勿再次提交,并联系管理员核查。`;
return t('billing.error.terminal_effect_unknown', { message });
}
return task?.safe_to_resubmit === false
? `${message} 相关资源保持安全锁定,请勿再次提交,并联系管理员核查。`
? t('billing.error.terminal_locked', { message })
: message;
}
@ -99,15 +99,15 @@ function showError(id, message) {
function readInvoiceDetailBootstrap() {
const source = byId('invoice-detail-bootstrap');
if (!source) throw new Error('账单首屏数据缺失,请刷新页面后重试。');
if (!source) throw new Error(t('billing.error.bootstrap_missing'));
let payload;
try {
payload = JSON.parse(source.textContent || '{}');
} catch {
throw new Error('账单首屏数据无效,请刷新页面后重试。');
throw new Error(t('billing.error.bootstrap_invalid'));
}
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
throw new Error('账单首屏数据无效,请刷新页面后重试。');
throw new Error(t('billing.error.bootstrap_invalid'));
}
return payload;
}
@ -115,7 +115,7 @@ function readInvoiceDetailBootstrap() {
function requireSecureTransport() {
if (location.protocol !== 'https:'
&& !['localhost', '127.0.0.1', '[::1]'].includes(location.hostname)) {
throw new Error('请通过 HTTPS 使用账单支付功能。');
throw new Error(t('billing.error.secure_transport'));
}
}
@ -155,30 +155,29 @@ async function api(path, options = {}) {
try {
payload = await response.json();
} catch {
throw new Error('服务返回了非 JSON 数据,请检查 PHP 及反代配置。');
throw new Error(t('billing.error.non_json'));
}
}
if (response.status === 401) {
location.assign('/auth/login');
throw new Error('登录已过期。');
throw new Error(t('billing.error.login_expired'));
}
if (!response.ok || payload?.ret === 0) {
const detail = Array.isArray(payload?.detail)
? payload.detail.map(item => item.msg || '输入错误').join(';')
: payload?.detail;
const error = new Error(String(detail || payload?.message || payload?.msg
|| payload?.error || `请求失败 (${response.status})`));
const error = new Error(response.status === 422
? t('billing.error.invalid_input')
: t('billing.error.request', { status: response.status }));
error.status = response.status;
throw error;
}
return payload;
} catch (error) {
if (error?.name === 'AbortError') {
const aborted = new Error(timedOut ? '请求超时,请稍后重试。' : '请求已取消。');
const aborted = new Error(timedOut
? t('billing.error.timeout') : t('billing.error.cancelled'));
aborted.code = timedOut ? 'REQUEST_TIMEOUT' : 'REQUEST_ABORTED';
throw aborted;
}
if (error instanceof TypeError) throw new Error('网络请求失败,请检查连接后重试。');
if (error instanceof TypeError) throw new Error(t('billing.error.network'));
throw error;
} finally {
clearTimeout(timeout);
@ -191,11 +190,12 @@ function applySession(payload) {
const csrfToken = String(payload?.csrf_token ?? nested.csrf_token ?? '');
const userId = String(payload?.user_id ?? nested.user_id ?? nested.id ?? '');
if (!/^[a-f0-9]{64}$/.test(csrfToken) || !/^[1-9]\d*$/.test(userId)) {
throw new Error('账单会话信息不完整,请重新登录。');
throw new Error(t('billing.error.session'));
}
state.csrfToken = csrfToken;
state.userId = userId;
state.username = firstText(payload?.username, nested.username, nested.name, state.username, '用户');
state.username = firstText(payload?.username, nested.username, nested.name,
state.username, t('common.shell.account.fallback'));
state.admin = payload?.admin === true || Number(payload?.admin) === 1
|| nested.admin === true || Number(nested.admin) === 1;
text('current-username', state.username);
@ -216,12 +216,11 @@ function serviceTimestamp(value) {
return Number.isFinite(parsed) ? parsed : null;
}
function browserTime(value, fallback = '时间未记录') {
function browserTime(value, fallback = t('billing.value.time_missing')) {
const timestamp = serviceTimestamp(value);
if (timestamp === null) return fallback;
const date = new Date(timestamp);
return Number.isFinite(date.getTime())
? date.toLocaleString('zh-CN', { hour12: false }) : fallback;
return Number.isFinite(date.getTime()) ? i18n.date(date) : fallback;
}
function invoiceCanPay(invoice) {
@ -250,7 +249,9 @@ function renderInvoiceLineItems(presentation) {
const row = makeElement('div', 'invoice-line-item');
row.setAttribute('role', 'listitem');
row.append(
makeElement('span', '', firstText(item.label, '费用项目')),
makeElement('span', '', item.label_key
? t(item.label_key) : firstText(item.label,
t('billing.line_items.fallback'))),
makeElement('strong', '', firstText(item.amount_display, '$—')),
);
return [row];
@ -266,7 +267,8 @@ function renderInvoiceSpecification(presentation) {
const facts = (Array.isArray(presentation?.specification)
? presentation.specification : []).flatMap(item => (
item && typeof item === 'object' && !Array.isArray(item)
? [invoiceFact(item.label, item.value)] : []
? [invoiceFact(t(item.label_key), item.value_key
? t(item.value_key, item.value_parameters || {}) : item.value)] : []
));
container.replaceChildren(...facts);
panel.hidden = presentation?.show_specification !== true || facts.length === 0;
@ -322,7 +324,7 @@ async function copyText(value) {
document.body.append(area);
area.select();
try {
if (!document.execCommand('copy')) throw new Error('浏览器无法复制,请手动选择文本。');
if (!document.execCommand('copy')) throw new Error(t('billing.error.copy'));
} finally {
area.value = '';
area.remove();
@ -367,7 +369,7 @@ function loadQrCode() {
if (version) url.searchParams.set('v', version);
const timer = setTimeout(() => {
script.remove();
reject(new Error('二维码组件加载超时'));
reject(new Error(t('billing.error.qr_timeout')));
}, 10_000);
script.src = url.href;
script.async = true;
@ -375,12 +377,12 @@ function loadQrCode() {
script.onload = () => {
clearTimeout(timer);
if (typeof window.QRCode === 'function') resolve(window.QRCode);
else reject(new Error('二维码组件不可用'));
else reject(new Error(t('billing.error.qr_unavailable')));
};
script.onerror = () => {
clearTimeout(timer);
script.remove();
reject(new Error('二维码组件加载失败'));
reject(new Error(t('billing.error.qr_load')));
};
document.head.append(script);
}).catch(error => {
@ -394,8 +396,8 @@ async function appendPaymentQr(container, value, generation) {
if (!value) return false;
const qr = makeElement('div', 'cloud-payment-qr cloud-payment-qr-loading');
qr.setAttribute('role', 'status');
qr.setAttribute('aria-label', '正在生成支付二维码');
qr.append(makeElement('span', '', '二维码生成中…'));
qr.setAttribute('aria-label', t('billing.qr.loading_aria'));
qr.append(makeElement('span', '', t('billing.qr.loading')));
container.append(qr);
try {
const QRCode = await loadQrCode();
@ -415,16 +417,16 @@ async function appendPaymentQr(container, value, generation) {
height: 196,
correctLevel: String(value).length > 1200 ? levels.L : levels.M,
});
if (!qr.children.length) throw new Error('二维码组件未生成内容');
if (!qr.children.length) throw new Error(t('billing.error.qr_empty'));
return true;
} catch {
if (container.isConnected && qr.isConnected && state.onlinePaymentPending
&& generation === state.paymentRenderGeneration) {
qr.className = 'cloud-payment-qr cloud-payment-qr-error';
qr.setAttribute('role', 'status');
qr.setAttribute('aria-label', '支付二维码暂时无法显示');
qr.setAttribute('aria-label', t('billing.qr.failed_aria'));
qr.replaceChildren(makeElement('span', 'cloud-payment-qr-note',
'二维码暂时无法显示,请使用支付按钮或复制支付信息。'));
t('billing.qr.failed')));
} else {
qr.remove();
}
@ -505,8 +507,8 @@ function expireOnlinePaymentInstructions(generation = state.paymentRenderGenerat
const notice = makeElement('div',
'cloud-payment-instructions cloud-payment-expired');
notice.append(
makeElement('strong', '', '支付订单已过期'),
makeElement('small', '', '请重新选择支付方式并确认,以生成新的支付订单。'),
makeElement('strong', '', t('billing.payment.expired.title')),
makeElement('small', '', t('billing.payment.expired.body')),
);
result.replaceChildren(notice);
}
@ -582,15 +584,15 @@ function mergePresentationPatch(current, patch) {
const next = patch && typeof patch === 'object' ? patch : {};
const merged = { ...presentation };
if (next.status && typeof next.status === 'object') {
merged.status_label = firstText(next.status.label,
presentation.status_label, '未知');
merged.status_key = firstText(next.status.copy_key,
presentation.status_key, 'billing.status.financial.unknown');
merged.status_class = firstText(next.status.class,
presentation.status_class, 'other');
}
if (next.payment && typeof next.payment === 'object') {
merged.show_payment = next.payment.payable === true
|| Boolean(next.payment.active);
merged.active_payment_message = firstText(next.payment.message);
merged.active_payment_key = firstText(next.payment.message_key);
merged.active_payment_class = firstText(
next.payment.message_class, 'invoice-payment-note',
);
@ -666,11 +668,12 @@ async function pollInvoiceStatus(generation) {
resetProvisioningPollWindow();
}
const completion = patch?.completion_notice;
if (completion?.message) {
if (completion?.copy_key) {
stopInvoicePoll();
const refreshed = await refreshInvoiceDetail(nextInvoice.id);
if (refreshed !== null) {
toast(String(completion.message), firstText(completion.tone, 'success'));
toast(t(String(completion.copy_key)),
firstText(completion.tone, 'success'));
} else {
renderInvoiceDetail(nextPresentation);
}
@ -747,39 +750,44 @@ function renderOnlinePayment(container, payment) {
if (payment.payment_kind === 'usdt') {
qrValue = payment.receive_address || '';
box.append(
makeElement('strong', '', `请支付 ${payment.actual_amount} USDT(TRC20)`),
makeElement('code', '', qrValue || '收款地址不可用'),
makeElement('small', '', '支付订单具有时效;链上确认后自动结清账单。'),
makeElement('strong', '', t('billing.payment.usdt.amount', {
amount: String(payment.actual_amount ?? '—'),
})),
makeElement('code', '', qrValue || t('billing.payment.address_unavailable')),
makeElement('small', '', t('billing.payment.usdt.notice')),
);
box.append(actionButton('复制收款地址', async () => {
box.append(actionButton(t('billing.payment.copy_address'), async () => {
try {
await copyText(qrValue);
} catch (error) {
toast(error.message, 'error');
toast(t('billing.error.copy'), 'error');
}
}));
} else {
qrValue = payment.payment_value || '';
const url = validPaymentUrl(qrValue);
box.append(makeElement('strong', '', `${payment.label || '在线支付'}订单已生成`));
box.append(makeElement('strong', '', t('billing.payment.order_created', {
label: payment.label || t('billing.payment.online_fallback'),
})));
if (url) {
const link = makeElement('a', 'button button-primary small', '前往支付');
const link = makeElement('a', 'button button-primary small',
t('billing.payment.open'));
link.href = url;
link.target = '_blank';
link.rel = 'noopener noreferrer';
box.append(link);
} else {
box.append(makeElement('code', '', qrValue || '支付信息暂不可用'));
box.append(actionButton('复制支付信息', async () => {
box.append(makeElement('code', '', qrValue
|| t('billing.payment.info_unavailable')));
box.append(actionButton(t('billing.payment.copy_info'), async () => {
try {
await copyText(qrValue);
} catch (error) {
toast(error.message, 'error');
toast(t('billing.error.copy'), 'error');
}
}));
}
box.append(makeElement('small', '',
'完成付款后本页会在有限时间内刷新账单状态。请勿同时使用多个渠道重复付款。'));
box.append(makeElement('small', '', t('billing.payment.poll_notice')));
}
void appendPaymentQr(box, qrValue, generation);
scheduleOnlinePaymentExpiry(generation);
@ -790,7 +798,7 @@ function renderOnlinePayment(container, payment) {
async function payInvoiceBalance(invoice, container) {
if (!invoiceCanPay(invoice)) {
toast('账单当前不可支付,请刷新后重试。', 'error');
toast(t('billing.payment.unpayable'), 'error');
return;
}
if (state.mutationBusy) return;
@ -805,18 +813,20 @@ async function payInvoiceBalance(invoice, container) {
timeoutMs: 20_000,
});
if (taskUrl(result)) {
announceTaskAccepted(result, { title: '创建实例' });
toast('付款已完成,实例创建任务已接收,可在任务中心查看结果。',
announceTaskAccepted(result, {
title: t('billing.fulfillment.task_title.provision'),
});
toast(t('billing.fulfillment.task_accepted.provision'),
'success');
observeTask(result, {
onTerminal: task => {
void (async () => {
await refreshInvoiceDetail(invoice.id);
if (taskSucceededWithoutRecovery(task)) {
toast('实例创建完成。', 'success');
toast(t('billing.fulfillment.completed.provision'), 'success');
} else {
toast(terminalTaskProblem(task,
'实例创建任务未能安全完成,请在任务中心查看详情。'), 'error');
t('billing.fulfillment.failed.provision')), 'error');
}
})();
},
@ -836,12 +846,15 @@ async function payInvoiceBalance(invoice, container) {
state.selectedInvoice = paid;
await refreshInvoiceDetail(invoice.id);
const notice = state.presentation?.completion_notice;
toast(firstText(notice?.message, startsProvisioning
? '账单已支付,实例已进入创建队列。' : '账单已支付。'),
toast(notice?.copy_key ? t(notice.copy_key) : t(startsProvisioning
? 'billing.fulfillment.paid.provision'
: 'billing.fulfillment.paid.generic'),
firstText(notice?.tone, 'success'));
if (startsProvisioning) resumeInvoicePolling();
} catch (error) {
toast(error.message, 'error');
toast(t('billing.error.request', {
status: Number(error.status || 0) || 0,
}), 'error');
if ([403, 409].includes(Number(error.status || 0))) {
await refreshInvoiceDetail(invoice.id);
}
@ -854,7 +867,7 @@ async function payInvoiceBalance(invoice, container) {
async function createInvoicePayment(invoice, method, container, paymentResult) {
if (!invoiceCanPay(invoice)) {
toast('账单当前不可创建支付订单,请刷新后重试。', 'error');
toast(t('billing.payment.create_unavailable'), 'error');
return;
}
if (state.mutationBusy) return;
@ -870,14 +883,14 @@ async function createInvoicePayment(invoice, method, container, paymentResult) {
timeoutMs: 20_000,
});
if (!taskUrl(result)) {
throw new Error(
'支付创建请求已送达,但任务回执协议无效。请勿再次提交,并联系管理员核查。'
);
const error = new Error(t('billing.payment.receipt_invalid'));
error.code = 'INVALID_TASK_RECEIPT';
throw error;
}
announceTaskAccepted(result, { title: '创建支付订单' });
announceTaskAccepted(result, { title: t('billing.payment.task_title') });
paymentResult.replaceChildren(makeElement('p', 'invoice-payment-note',
'支付订单创建任务已接收,可在任务中心查看结果。'));
toast('支付订单创建任务已接收。', 'success');
t('billing.payment.task_accepted')));
toast(t('billing.payment.task_accepted_short'), 'success');
const observer = observeTask(result, {
onTerminal: task => {
if (taskSucceededWithoutRecovery(task) && task?.result?.payment) {
@ -897,11 +910,9 @@ async function createInvoicePayment(invoice, method, container, paymentResult) {
if (task.safe_to_resubmit === true) {
clearInvoicePaymentKey(invoice.id, method.id);
}
const recoveryNotice = recoveryTaskFailureNotice(task);
const warning = !recoveryNotice && task.effect_may_have_applied
? ' 原支付订单可能已由网关创建;可选择其他支付方式,原订单若随后到账将计入账户余额。'
: '';
const failure = recoveryNotice || task.error || '支付订单创建失败。';
const warning = task.effect_may_have_applied
? ` ${t('billing.payment.effect_unknown_suffix')}` : '';
const failure = t('billing.payment.task_failed');
paymentResult.replaceChildren(makeElement('p',
'invoice-payment-error', `${failure}${warning}`));
toast(`${failure}${warning}`, 'error');
@ -915,13 +926,15 @@ async function createInvoicePayment(invoice, method, container, paymentResult) {
} catch (error) {
const status = Number(error.status || 0);
const ambiguousHttpFailure = [408, 425, 429].includes(status);
const creationStillInProgress = String(error.message).includes('正在创建');
const creationStillInProgress = status === 409;
if (status >= 400 && status < 500 && !ambiguousHttpFailure
&& !creationStillInProgress) {
clearInvoicePaymentKey(invoice.id, method.id);
}
toast(error.message, 'error');
if ([403, 409].includes(status) && !creationStillInProgress) {
toast(error.code === 'INVALID_TASK_RECEIPT'
? t('billing.payment.receipt_invalid')
: t('billing.error.request', { status: status || 0 }), 'error');
if ([403, 409].includes(status)) {
await refreshInvoiceDetail(invoice.id);
}
} finally {
@ -940,9 +953,11 @@ function renderActiveInvoicePayment(activePayment, presentation, result) {
}
clearOnlinePaymentState();
const taskId = firstText(activePayment?.task_id);
const prefix = taskId ? `任务 #${taskId} · ` : '';
const message = firstText(presentation?.active_payment_message,
'支付订单状态正在核对,请稍后刷新。');
const prefix = taskId
? t('billing.fulfillment.task_prefix', { id: taskId }) : '';
const message = presentation?.active_payment_key
? t(presentation.active_payment_key)
: t('billing.payment.status_reconciling');
result.replaceChildren(makeElement('p', firstText(
presentation?.active_payment_class, 'invoice-payment-note',
), `${prefix}${message}`));
@ -954,12 +969,13 @@ function renderInvoicePaymentMethods(invoice, presentation, activePayment) {
const result = byId('invoice-payment-result');
if (!panel || !container || !result) return;
const hasActivePayment = activePayment && typeof activePayment === 'object';
text('invoice-payment-title', firstText(
presentation?.payment_title, '当前支付状态',
));
text('invoice-payment-description', firstText(
presentation?.payment_description, '账单支付状态由服务端确认。',
));
text('invoice-payment-title', t(firstText(
presentation?.payment_title_key, 'billing.payment.status_title',
)));
text('invoice-payment-description', t(firstText(
presentation?.payment_description_key,
'billing.payment.status_description',
)));
if (hasActivePayment) {
renderActiveInvoicePayment(activePayment, presentation, result);
}
@ -983,7 +999,7 @@ function renderInvoicePaymentMethods(invoice, presentation, activePayment) {
const choices = (Array.isArray(presentation?.payment_methods)
? presentation.payment_methods : []).flatMap(method => {
if (method?.id === null || method?.id === undefined
|| !firstText(method.name)) return [];
|| (!firstText(method.name) && !firstText(method.name_key))) return [];
const id = String(method.id);
return [{ ...method, id, kind: id === 'balance' ? 'balance' : 'online' }];
});
@ -1017,8 +1033,11 @@ function renderInvoicePaymentMethods(invoice, presentation, activePayment) {
card.setAttribute('aria-pressed', String(selected));
card.setAttribute('aria-checked', String(selected));
card.append(
makeElement('strong', '', choice.name),
makeElement('small', '', firstText(choice.description, '在线支付')),
makeElement('strong', '', choice.name_key
? t(choice.name_key) : choice.name),
makeElement('small', '', choice.description_key
? t(choice.description_key, choice.description_parameters || {})
: firstText(choice.description, t('billing.payment.online_fallback'))),
makeElement('span', 'invoice-payment-method-check', '✓'),
);
card.addEventListener('click', () => selectInvoicePaymentMethod(choice.id));
@ -1033,7 +1052,7 @@ function renderInvoicePaymentMethods(invoice, presentation, activePayment) {
showError('invoice-payment-error', '');
const choice = choices.find(item => String(item.id) === state.selectedInvoicePaymentMethod);
if (!choice) {
showError('invoice-payment-error', '请选择支付方式。');
showError('invoice-payment-error', t('billing.payment.select_required'));
return;
}
if (choice.kind === 'balance') await payInvoiceBalance(invoice, panel);
@ -1042,16 +1061,16 @@ function renderInvoicePaymentMethods(invoice, presentation, activePayment) {
}
function appendProvisionInvoiceActions(invoice, presentation, detail, actions) {
if (firstText(presentation?.fulfillment_label)) {
if (firstText(presentation?.fulfillment_key)) {
actions.append(makeElement('span', `state-pill ${firstText(
presentation.fulfillment_class, 'other',
)}`, presentation.fulfillment_label));
)}`, t(presentation.fulfillment_key)));
}
const taskId = firstText(presentation?.task_id);
if (taskId) {
actions.append(actionButton('刷新账单状态', async () => {
actions.append(actionButton(t('billing.payment.refresh_status'), async () => {
if (state.refreshPromise) {
toast('账单正在刷新,请稍候。');
toast(t('billing.payment.refreshing'), 'info');
return;
}
let progress = detail.querySelector('.cloud-order-progress');
@ -1067,7 +1086,7 @@ function appendProvisionInvoiceActions(invoice, presentation, detail, actions) {
const patch = result?.presentation_patch;
const update = patch?.invoice ?? result?.invoice;
if (!update?.id || String(update.id) !== String(invoice.id)) {
throw new Error('创建进度与当前账单不匹配,请刷新后重试。');
throw new Error(t('billing.error.fulfillment_mismatch'));
}
if (readSequence < state.appliedReadSequence) return;
state.appliedReadSequence = readSequence;
@ -1076,10 +1095,10 @@ function appendProvisionInvoiceActions(invoice, presentation, detail, actions) {
const nextPresentation = mergePresentationPatch(state.presentation, patch);
state.selectedInvoice = nextInvoice;
state.presentation = nextPresentation;
if (patch?.completion_notice?.message) {
if (patch?.completion_notice?.copy_key) {
const refreshed = await refreshInvoiceDetail(invoice.id);
if (refreshed !== null) {
toast(String(patch.completion_notice.message), firstText(
toast(t(String(patch.completion_notice.copy_key)), firstText(
patch.completion_notice.tone, 'success',
));
} else {
@ -1091,13 +1110,14 @@ function appendProvisionInvoiceActions(invoice, presentation, detail, actions) {
} catch (error) {
if (readSequence < state.appliedReadSequence) return;
progress.className = 'cloud-order-progress form-error';
progress.textContent = error.message;
progress.textContent = t('billing.error.refresh');
}
}));
}
const instanceId = firstText(presentation?.instance_id);
if (instanceId) {
const link = makeElement('a', 'row-button', '查看实例');
const link = makeElement('a', 'row-button',
t('billing.fulfillment.view_instance'));
link.href = `/user/cloud/instances/${encodeURIComponent(instanceId)}`;
actions.append(link);
}
@ -1115,17 +1135,21 @@ function renderInvoiceFulfillment(invoice, presentation) {
const detail = makeElement('div', 'invoice-fulfillment-detail');
const actions = makeElement('div', 'cloud-order-actions invoice-fulfillment-actions');
text('invoice-fulfillment-title', firstText(
presentation?.fulfillment_title, '任务进度',
));
text('invoice-fulfillment-description', firstText(
presentation?.fulfillment_description, '任务由系统在后台执行。',
));
text('invoice-fulfillment-title', t(firstText(
presentation?.fulfillment_title_key,
'billing.fulfillment.title.generic',
)));
text('invoice-fulfillment-description', t(firstText(
presentation?.fulfillment_description_key,
'billing.fulfillment.description.generic',
)));
const taskId = firstText(presentation?.task_id);
const prefix = taskId ? `任务 #${taskId} · ` : '';
const prefix = taskId
? t('billing.fulfillment.task_prefix', { id: taskId }) : '';
const progress = makeElement('p', `cloud-order-progress ${
presentation?.fulfillment_failed === true ? 'form-error' : 'muted'
}`, `${prefix}${firstText(presentation?.fulfillment_message, '等待任务状态')}`);
}`, `${prefix}${t(firstText(presentation?.fulfillment_message_key,
'billing.fulfillment.waiting.generic'))}`);
detail.append(progress);
appendProvisionInvoiceActions(invoice, presentation, detail, actions);
content.replaceChildren(detail, actions);
@ -1140,24 +1164,28 @@ function renderInvoiceDetail(presentation) {
state.presentation = presentation;
const created = browserTime(
presentation?.created_at,
firstText(presentation?.created_display, '时间未记录'),
firstText(presentation?.created_display, t('billing.value.time_missing')),
);
text('invoice-detail-kind', firstText(presentation?.title, '账单'));
text('invoice-detail-number', firstText(presentation?.number_text, '账单'));
text('invoice-detail-created', `创建于 ${created}`);
text('invoice-detail-subtitle', `${firstText(
presentation?.number_text, '账单',
)} · ${created}`);
text('invoice-detail-kind', t(firstText(
presentation?.title_key, 'billing.purpose.invoice')));
const invoiceId = String(presentation?.id || '—');
text('invoice-detail-number', t('billing.detail.number', { id: invoiceId }));
text('invoice-detail-created', t('billing.detail.created', { time: created }));
text('invoice-detail-subtitle', t('billing.detail.subtitle', {
id: invoiceId, time: created,
}));
text('invoice-detail-amount', firstText(presentation?.amount_display, '$—'));
const status = byId('invoice-detail-status');
if (status) {
status.className = `state-pill ${firstText(presentation?.status_class, 'other')}`;
status.textContent = firstText(presentation?.status_label, '未知');
status.textContent = t(firstText(presentation?.status_key,
'billing.status.financial.unknown'));
}
const facts = (Array.isArray(presentation?.facts) ? presentation.facts : [])
.flatMap(item => item && typeof item === 'object' && !Array.isArray(item)
? [invoiceFact(item.label, item.value, item.timestamp)] : []);
? [invoiceFact(t(item.label_key), item.value_key
? t(item.value_key) : item.value, item.timestamp)] : []);
byId('invoice-detail-facts')?.replaceChildren(...facts);
renderInvoiceLineItems(presentation);
@ -1168,16 +1196,16 @@ function renderInvoiceDetail(presentation) {
function hydrateInvoiceDetail(payload, expectedInvoiceId = document.body.dataset.invoiceId) {
if (!payload?.invoice || typeof payload.invoice !== 'object') {
throw new Error('账单信息不完整,请刷新页面后重试。');
throw new Error(t('billing.error.invoice_incomplete'));
}
if (!payload?.presentation || typeof payload.presentation !== 'object'
|| Array.isArray(payload.presentation)) {
throw new Error('账单展示信息不完整,请刷新页面后重试。');
throw new Error(t('billing.error.presentation_incomplete'));
}
const expected = String(expectedInvoiceId || '');
if (!/^[1-9]\d*$/.test(expected)
|| String(payload.invoice.id || '') !== expected) {
throw new Error('账单初始数据与当前地址不匹配,请返回账单列表重试。');
throw new Error(t('billing.error.invoice_mismatch'));
}
const previousInvoice = state.selectedInvoice;
const wasAwaitingOnlinePayment = state.onlinePaymentPending;
@ -1226,7 +1254,7 @@ function hydrateInvoiceDetail(payload, expectedInvoiceId = document.body.dataset
async function refreshInvoiceDetail(invoiceId = document.body.dataset.invoiceId) {
const id = String(invoiceId || '');
if (!/^[1-9]\d*$/.test(id)) {
showError('cloud-page-error', '账单编号无效。');
showError('cloud-page-error', t('billing.error.invoice_invalid'));
return null;
}
if (state.refreshPromise) return state.refreshPromise;
@ -1256,7 +1284,7 @@ async function refreshInvoiceDetail(invoiceId = document.body.dataset.invoiceId)
return hydrateInvoiceDetail(payload, id);
} catch (error) {
if (error?.code !== 'REQUEST_ABORTED') {
showError('cloud-page-error', error.message || '账单刷新失败,请稍后重试。');
showError('cloud-page-error', t('billing.error.refresh'));
}
return null;
} finally {

@ -12,6 +12,7 @@ const {
state,
stopInvoicePoll,
} = await import(runtimeUrl.href);
const i18n = globalThis.VenixUserCopy;
export function initialize() {
try {
@ -20,7 +21,9 @@ export function initialize() {
byId('logout-button')?.addEventListener('click', () => location.assign('/user/logout'));
const invoiceId = String(document.body.dataset.invoiceId || '');
if (!/^[1-9]\d*$/.test(invoiceId)) throw new Error('账单编号无效。');
if (!/^[1-9]\d*$/.test(invoiceId)) {
throw new Error(i18n.text('billing.error.invoice_invalid'));
}
const bootstrap = readInvoiceDetailBootstrap();
hydrateInvoiceDetail(bootstrap, invoiceId);
@ -36,7 +39,7 @@ export function initialize() {
if (document.hidden) stopInvoicePoll();
else resumeInvoicePolling();
});
} catch (error) {
showError('cloud-page-error', error?.message || '账单详情初始化失败,请刷新后重试。');
} catch {
showError('cloud-page-error', i18n.text('billing.error.initialize'));
}
}

@ -2,6 +2,8 @@
// This module deliberately avoids the all-feature cloud runtime and session
// endpoint, leaving only pagination and conditional refresh work to JS.
const byId = id => document.getElementById(id);
const i18n = globalThis.VenixUserCopy;
const t = (key, parameters = {}) => i18n.text(key, parameters);
const state = {
invoices: [], page: 1,
filters: { purpose: 'all', status: 'all', keyword: '' },
@ -56,16 +58,15 @@ async function api(path, signal) {
credentials: 'same-origin', cache: 'no-store', signal });
let payload;
try { payload = await response.json(); }
catch { throw new Error('服务返回了非 JSON 数据,请检查 PHP 及反代配置。'); }
catch { throw new Error(t('billing.error.non_json')); }
if (response.status === 401) {
location.assign('/auth/login');
throw new Error('登录已过期。');
throw new Error(t('billing.error.login_expired'));
}
if (!response.ok || payload?.ret === 0) {
const detail = Array.isArray(payload?.detail)
? payload.detail.map(item => item.msg || '输入错误').join(';') : payload?.detail;
throw new Error(String(detail || payload?.message || payload?.msg || payload?.error
|| `请求失败 (${response.status})`));
throw new Error(response.status === 422
? t('billing.error.invalid_input')
: t('billing.error.request', { status: response.status }));
}
return payload;
}
@ -81,12 +82,11 @@ function invoiceNeedsPolling(invoice) {
return invoice?.polling_required === true;
}
function browserTime(value, fallback = '时间未记录') {
function browserTime(value, fallback = t('billing.value.time_missing')) {
const numeric = Number(value);
if (!Number.isFinite(numeric) || numeric <= 0) return fallback;
const date = new Date(numeric * (numeric < 1e12 ? 1000 : 1));
return Number.isFinite(date.getTime())
? date.toLocaleString('zh-CN', { hour12: false }) : fallback;
return Number.isFinite(date.getTime()) ? i18n.date(date) : fallback;
}
function presentationSegmentsText(invoice) {
@ -96,7 +96,8 @@ function presentationSegmentsText(invoice) {
return segments.map(segment => {
if (!segment || typeof segment !== 'object' || Array.isArray(segment)) return '';
if (segment.kind === 'timestamp') return browserTime(segment.value);
return segment.kind === 'text' ? String(segment.value || '') : '';
if (segment.kind !== 'copy') return '';
return t(String(segment.key || ''), segment.parameters || {});
}).join('').trim();
}
@ -105,33 +106,35 @@ function renderInvoices() {
if (!container) return;
container.replaceChildren();
if (!state.invoices.length) {
container.append(makeElement('p', 'muted',
'暂无账单。部署实例后会先生成开通账单;续费账单会在实例到期前 7 天自动生成。'));
container.append(makeElement('p', 'muted', t('billing.list.empty')));
return;
}
for (const invoice of state.invoices) {
const row = makeElement('article', 'cloud-order cloud-invoice cloud-invoice-list-row');
const detail = makeElement('div', 'cloud-order-detail cloud-invoice-list-copy');
detail.append(makeElement('strong', '', String(invoice?.title || '账单')),
makeElement('p', 'muted', `账单 #${invoice.id} · ${String(
browserTime(invoice?.created_at, invoice?.created_display || '时间未记录'),
)}`));
detail.append(makeElement('strong', '', t(String(
invoice?.title_key || 'billing.purpose.invoice'))),
makeElement('p', 'muted', t('billing.list.invoice_meta', {
id: String(invoice.id || '—'),
time: browserTime(invoice?.created_at,
invoice?.created_display || t('billing.value.time_missing')),
})));
const context = presentationSegmentsText(invoice);
if (context) detail.append(makeElement('p', 'muted cloud-invoice-context', context));
const actions = makeElement('div', 'cloud-order-actions cloud-invoice-list-actions');
actions.append(makeElement('span', `state-pill ${String(
invoice?.status_class || 'other',
)}`, String(invoice?.status_label || '未知')));
if (invoice?.show_fulfillment === true && String(invoice?.fulfillment_label || '').trim()) {
)}`, t(String(invoice?.status_key || 'billing.status.financial.unknown'))));
if (invoice?.show_fulfillment === true && String(invoice?.fulfillment_key || '').trim()) {
actions.append(makeElement('span', `state-pill ${String(
invoice?.fulfillment_class || 'other',
)}`, String(invoice.fulfillment_label)));
)}`, t(String(invoice.fulfillment_key))));
}
const link = makeElement('a', 'row-button', '账单详情');
const link = makeElement('a', 'row-button', t('billing.list.detail'));
link.href = `/user/cloud/invoices/${encodeURIComponent(String(invoice.id))}`;
actions.append(link);
const amount = makeElement('div', 'cloud-invoice-list-amount');
amount.append(makeElement('span', '', '金额'),
amount.append(makeElement('span', '', t('billing.list.amount')),
makeElement('strong', '', String(invoice?.amount_display || '$—')));
row.append(detail, actions, amount);
container.append(row);
@ -158,7 +161,11 @@ function renderPagination() {
const total = Math.max(0, Number(state.pagination.total) || 0);
navigation.hidden = total === 0;
navigation.setAttribute('aria-busy', String(state.loading));
if (byId('invoices-page-label')) byId('invoices-page-label').textContent = `第 ${page} / ${totalPages} 页 · 共 ${total} 条`;
if (byId('invoices-page-label')) {
byId('invoices-page-label').textContent = t('billing.pagination.label', {
page, pages: totalPages, total,
});
}
if (byId('invoices-previous')) byId('invoices-previous').disabled = state.loading || !state.pagination.has_previous;
if (byId('invoices-next')) byId('invoices-next').disabled = state.loading || !state.pagination.has_next;
if (byId('invoices-refresh')) {
@ -236,7 +243,7 @@ async function loadInvoices(page = state.page, updateUrl = true, resetBudget = f
showError();
} catch (error) {
if (error?.name === 'AbortError' || sequence !== state.readSequence) return;
showError(error?.message || '账单加载失败,请稍后重试。');
showError(t('billing.error.load'));
} finally {
if (sequence !== state.readSequence) return;
state.readController = null;

@ -0,0 +1,250 @@
<?php
$entry = require dirname(__DIR__) . '/entry.php';
return [
$entry('billing.list.eyebrow', 'billing', 'cloud.invoices', '账单'),
$entry('billing.list.title', 'billing', 'cloud.invoices', '账单信息', 'title'),
$entry('billing.list.description', 'billing', 'cloud.invoices', '部署实例时先生成开通账单,支付完成后才开始创建;实例到期前 7 天会自动生成续费账单。实例到期后立即停用网络,到期满 3 天仍未续费,实例及系统盘将被永久删除。', 'description'),
$entry('billing.refresh', 'billing', 'cloud.invoices', '刷新', 'button'),
$entry('billing.balance.label', 'billing', 'cloud.invoices', '当前账户余额'),
$entry('billing.balance.hint', 'billing', 'cloud.invoices', '可用于支付未结清账单', 'help'),
$entry('billing.balance.recharge', 'billing', 'cloud.invoices', '余额充值', 'button'),
$entry('billing.balance.drawer_description', 'billing', 'cloud.invoices', '选择充值金额和可用支付方式', 'description'),
$entry('billing.filter.purpose.label', 'billing', 'cloud.invoices', '账单类型'),
$entry('billing.filter.purpose.aria', 'billing', 'cloud.invoices', '按账单类型筛选', 'aria_label'),
$entry('billing.filter.purpose.all', 'billing', 'cloud.invoices', '全部账单'),
$entry('billing.filter.status.label', 'billing', 'cloud.invoices', '账单状态'),
$entry('billing.filter.status.all', 'billing', 'cloud.invoices', '全部状态'),
$entry('billing.filter.status.pending', 'billing', 'cloud.invoices', '待支付'),
$entry('billing.filter.status.paid', 'billing', 'cloud.invoices', '已支付'),
$entry('billing.filter.status.closed', 'billing', 'cloud.invoices', '已关闭'),
$entry('billing.filter.keyword.label', 'billing', 'cloud.invoices', '账单或实例'),
$entry('billing.filter.keyword.placeholder', 'billing', 'cloud.invoices', '账单编号或实例名称', 'placeholder'),
$entry('billing.filter.apply', 'billing', 'cloud.invoices', '筛选', 'button'),
$entry('billing.filter.clear', 'billing', 'cloud.invoices', '清除', 'button'),
$entry('billing.list.empty', 'billing', 'cloud.invoices', '暂无账单。部署实例后会先生成开通账单;续费账单会在实例到期前 7 天自动生成。', 'empty_state'),
$entry('billing.list.invoice_meta', 'billing', 'cloud.invoices', '账单 #{id} · {time}', 'description', ['id' => 'string', 'time' => 'string']),
$entry('billing.list.invoice_meta_time_missing', 'billing', 'cloud.invoices', '账单 #{id} · 时间未记录', 'description', ['id' => 'string']),
$entry('billing.list.detail', 'billing', 'cloud.invoices', '账单详情', 'navigation'),
$entry('billing.list.amount', 'billing', 'cloud.invoices', '金额'),
$entry('billing.pagination.aria', 'billing', 'cloud.invoices', '账单分页', 'aria_label'),
$entry('billing.pagination.previous', 'billing', 'cloud.invoices', '上一页', 'button'),
$entry('billing.pagination.next', 'billing', 'cloud.invoices', '下一页', 'button'),
$entry('billing.pagination.label', 'billing', 'cloud.invoices', '第 {page} / {pages} 页 · 共 {total} 条', 'status', ['page' => 'integer', 'pages' => 'integer', 'total' => 'integer']),
$entry('billing.value.time_missing', 'billing', 'cloud.invoices', '时间未记录'),
$entry('billing.value.unknown', 'billing', 'cloud.invoices', '未知'),
$entry('billing.value.unavailable', 'billing', 'cloud.invoices', '暂未提供'),
$entry('billing.value.invoice', 'billing', 'cloud.invoices', '账单'),
$entry('billing.error.non_json', 'billing', 'cloud.invoices', '服务返回了无效数据,请稍后重试。', 'warning'),
$entry('billing.error.login_expired', 'billing', 'cloud.invoices', '登录已过期,请重新登录。', 'warning'),
$entry('billing.error.invalid_input', 'billing', 'cloud.invoices', '输入内容无效,请检查后重试。', 'warning'),
$entry('billing.error.request', 'billing', 'cloud.invoices', '账单请求失败(状态码 {status}),请稍后重试。', 'warning', ['status' => 'integer']),
$entry('billing.error.load', 'billing', 'cloud.invoices', '账单加载失败,请稍后重试。', 'warning'),
$entry('billing.purpose.invoice', 'billing', 'cloud.invoices', '账单'),
$entry('billing.purpose.provision', 'billing', 'cloud.invoices', '实例开通'),
$entry('billing.purpose.renewal', 'billing', 'cloud.invoices', '实例续费'),
$entry('billing.purpose.upgrade', 'billing', 'cloud.invoices', '实例升级'),
$entry('billing.purpose.ip_change', 'billing', 'cloud.invoices', '更换公网 IPv4'),
$entry('billing.purpose.backup_addon', 'billing', 'cloud.invoices', '自动备份开通'),
$entry('billing.purpose.recharge', 'billing', 'cloud.invoices', '余额充值'),
$entry('billing.context.renewal_expiry', 'billing', 'cloud.invoices', '对应实例到期 '),
$entry('billing.context.latest_payment', 'billing', 'cloud.invoices', ' · 最晚支付 '),
$entry('billing.context.payment_deadline', 'billing', 'cloud.invoices', '支付截止 '),
$entry('billing.context.target_instance', 'billing', 'cloud.invoices', '目标实例 {name}', 'description', ['name' => 'string']),
$entry('billing.status.financial.unknown', 'billing', 'cloud.invoices', '未知', 'status'),
$entry('billing.status.financial.open', 'billing', 'cloud.invoices', '待支付', 'status'),
$entry('billing.status.financial.renewal_grace', 'billing', 'cloud.invoices', '已到期,宽限期内可续费', 'status'),
$entry('billing.status.financial.overdue', 'billing', 'cloud.invoices', '已逾期', 'status'),
$entry('billing.status.financial.paid', 'billing', 'cloud.invoices', '已支付', 'status'),
$entry('billing.status.financial.refunded', 'billing', 'cloud.invoices', '已退款', 'status'),
$entry('billing.status.financial.expired', 'billing', 'cloud.invoices', '已失效', 'status'),
$entry('billing.status.financial.void', 'billing', 'cloud.invoices', '已作废', 'status'),
$entry('billing.status.financial.deleting', 'billing', 'cloud.invoices', '实例删除中', 'status'),
$entry('billing.status.financial.purge_deleting', 'billing', 'cloud.invoices', '实例删除中', 'status'),
$entry('billing.status.financial.purge_pending', 'billing', 'cloud.invoices', '等待永久删除', 'status'),
$entry('billing.status.financial.purge_stopping', 'billing', 'cloud.invoices', '删除前正在关机', 'status'),
$entry('billing.status.financial.purge_force_required', 'billing', 'cloud.invoices', '等待管理员确认强制删除', 'status'),
$entry('billing.status.financial.delete_failed', 'billing', 'cloud.invoices', '自动删除失败', 'status'),
$entry('billing.status.financial.purge_stop_failed', 'billing', 'cloud.invoices', '删除前关机失败', 'status'),
$entry('billing.status.financial.purge_failed', 'billing', 'cloud.invoices', '自动删除失败', 'status'),
$entry('billing.status.fulfillment.none', 'billing', 'cloud.invoices', '不适用', 'status'),
$entry('billing.status.fulfillment.awaiting_payment', 'billing', 'cloud.invoices', '等待支付', 'status'),
$entry('billing.status.fulfillment.running', 'billing', 'cloud.invoices', '执行中', 'status'),
$entry('billing.status.fulfillment.succeeded', 'billing', 'cloud.invoices', '已成功', 'status'),
$entry('billing.status.fulfillment.review', 'billing', 'cloud.invoices', '待人工核对', 'status'),
$entry('billing.status.fulfillment.failed', 'billing', 'cloud.invoices', '已失败', 'status'),
$entry('billing.status.fulfillment.expired', 'billing', 'cloud.invoices', '已失效', 'status'),
$entry('billing.status.fulfillment.refunded', 'billing', 'cloud.invoices', '已退款', 'status'),
$entry('billing.status.fulfillment.cancelled', 'billing', 'cloud.invoices', '已取消', 'status'),
$entry('billing.status.fulfillment.renewal_succeeded', 'billing', 'cloud.invoices', '已续费', 'status'),
$entry('billing.status.fulfillment.upgrade_running', 'billing', 'cloud.invoices', '升级中', 'status'),
$entry('billing.status.fulfillment.upgrade_succeeded', 'billing', 'cloud.invoices', '已升级', 'status'),
$entry('billing.status.fulfillment.upgrade_failed', 'billing', 'cloud.invoices', '升级失败', 'status'),
$entry('billing.status.fulfillment.ip_change_running', 'billing', 'cloud.invoices', '更换中', 'status'),
$entry('billing.status.fulfillment.ip_change_succeeded', 'billing', 'cloud.invoices', '已更换', 'status'),
$entry('billing.status.fulfillment.ip_change_failed', 'billing', 'cloud.invoices', '更换失败', 'status'),
$entry('billing.status.fulfillment.provision_running', 'billing', 'cloud.invoices', '创建中', 'status'),
$entry('billing.status.fulfillment.provision_succeeded', 'billing', 'cloud.invoices', '已开通', 'status'),
$entry('billing.status.fulfillment.provision_failed', 'billing', 'cloud.invoices', '创建失败', 'status'),
$entry('billing.status.fulfillment.provision_refunded', 'billing', 'cloud.invoices', '开通失败,已退款', 'status'),
$entry('billing.detail.back', 'billing', 'cloud.invoice_detail', '← 返回账单信息', 'navigation'),
$entry('billing.detail.eyebrow', 'billing', 'cloud.invoice_detail', '账单详情'),
$entry('billing.detail.title', 'billing', 'cloud.invoice_detail', '账单详情', 'title'),
$entry('billing.detail.subtitle', 'billing', 'cloud.invoice_detail', '账单 #{id} · {time}', 'description', ['id' => 'string', 'time' => 'string']),
$entry('billing.detail.subtitle_time_missing', 'billing', 'cloud.invoice_detail', '账单 #{id} · 时间未记录', 'description', ['id' => 'string']),
$entry('billing.detail.number', 'billing', 'cloud.invoice_detail', '账单 #{id}', 'label', ['id' => 'string']),
$entry('billing.detail.created', 'billing', 'cloud.invoice_detail', '创建于 {time}', 'description', ['time' => 'string']),
$entry('billing.detail.created_time_missing', 'billing', 'cloud.invoice_detail', '创建时间未记录', 'description'),
$entry('billing.detail.amount_due', 'billing', 'cloud.invoice_detail', '应付金额'),
$entry('billing.fact.invoice_number', 'billing', 'cloud.invoice_detail', '账单编号'),
$entry('billing.fact.created_at', 'billing', 'cloud.invoice_detail', '创建时间'),
$entry('billing.fact.payment_deadline', 'billing', 'cloud.invoice_detail', '支付截止'),
$entry('billing.fact.instance_expiry', 'billing', 'cloud.invoice_detail', '实例到期'),
$entry('billing.fact.latest_payment', 'billing', 'cloud.invoice_detail', '最晚支付'),
$entry('billing.fact.paid_at', 'billing', 'cloud.invoice_detail', '支付时间'),
$entry('billing.fact.payment_method', 'billing', 'cloud.invoice_detail', '支付方式'),
$entry('billing.line_items.title', 'billing', 'cloud.invoice_detail', '费用明细', 'title'),
$entry('billing.line_items.description', 'billing', 'cloud.invoice_detail', '以下项目来自账单生成时冻结的费用快照。', 'description'),
$entry('billing.line_items.fallback', 'billing', 'cloud.invoice_detail', '费用项目'),
$entry('billing.line_items.plan', 'billing', 'cloud.invoice_detail', '实例套餐'),
$entry('billing.line_items.renewal_plan', 'billing', 'cloud.invoice_detail', '实例套餐续费'),
$entry('billing.line_items.backup', 'billing', 'cloud.invoice_detail', '自动备份'),
$entry('billing.line_items.backup_renewal', 'billing', 'cloud.invoice_detail', '自动备份续费'),
$entry('billing.line_items.backup_addon', 'billing', 'cloud.invoice_detail', '自动备份服务开通'),
$entry('billing.spec.title', 'billing', 'cloud.invoice_detail', '套餐与服务', 'title'),
$entry('billing.spec.description', 'billing', 'cloud.invoice_detail', '该账单对应的实例规格、服务周期与流量额度。', 'description'),
$entry('billing.spec.instance', 'billing', 'cloud.invoice_detail', '实例'),
$entry('billing.spec.plan', 'billing', 'cloud.invoice_detail', '套餐'),
$entry('billing.spec.cpu', 'billing', 'cloud.invoice_detail', 'CPU'),
$entry('billing.spec.memory', 'billing', 'cloud.invoice_detail', '内存'),
$entry('billing.spec.disk', 'billing', 'cloud.invoice_detail', '系统盘'),
$entry('billing.spec.bandwidth', 'billing', 'cloud.invoice_detail', '带宽'),
$entry('billing.spec.service_period', 'billing', 'cloud.invoice_detail', '服务周期'),
$entry('billing.spec.period_traffic', 'billing', 'cloud.invoice_detail', '周期流量'),
$entry('billing.spec.target_period_traffic', 'billing', 'cloud.invoice_detail', '目标周期流量'),
$entry('billing.spec.service_content', 'billing', 'cloud.invoice_detail', '服务内容'),
$entry('billing.spec.pending_instance', 'billing', 'cloud.invoice_detail', '待创建实例'),
$entry('billing.spec.instance_fallback', 'billing', 'cloud.invoice_detail', '实例'),
$entry('billing.spec.plan_fallback', 'billing', 'cloud.invoice_detail', '云服务器套餐'),
$entry('billing.spec.cpu_value', 'billing', 'cloud.invoice_detail', '{value} 核', 'label', ['value' => 'number']),
$entry('billing.spec.memory_value', 'billing', 'cloud.invoice_detail', '{value} GiB', 'label', ['value' => 'string']),
$entry('billing.spec.disk_value', 'billing', 'cloud.invoice_detail', '{value} GB', 'label', ['value' => 'number']),
$entry('billing.spec.bandwidth_value', 'billing', 'cloud.invoice_detail', '{value} Mbps', 'label', ['value' => 'number']),
$entry('billing.spec.days_value', 'billing', 'cloud.invoice_detail', '{value} 天', 'label', ['value' => 'integer']),
$entry('billing.spec.unlimited_traffic', 'billing', 'cloud.invoice_detail', '不限流量'),
$entry('billing.spec.ip_change', 'billing', 'cloud.invoice_detail', '更换公网 IPv4'),
$entry('billing.spec.backup_addon', 'billing', 'cloud.invoice_detail', '自动备份开通'),
$entry('billing.payment.methods_aria', 'billing', 'cloud.invoice_detail', '账单支付方式', 'aria_label'),
$entry('billing.payment.select_title', 'billing', 'cloud.invoice_detail', '选择支付方式', 'title'),
$entry('billing.payment.status_title', 'billing', 'cloud.invoice_detail', '当前支付状态', 'title'),
$entry('billing.payment.description.choose', 'billing', 'cloud.invoice_detail', '选择支付方式后,点击“立即支付”将直接发起支付,请勿重复点击。', 'description'),
$entry('billing.payment.description.active', 'billing', 'cloud.invoice_detail', '已有未完成支付订单;任一订单先到账即结清账单,后续到账款项将计入账户余额。', 'description'),
$entry('billing.payment.description.unavailable', 'billing', 'cloud.invoice_detail', '该账单当前不可创建新的支付订单。', 'description'),
$entry('billing.payment.pay_now', 'billing', 'cloud.invoice_detail', '立即支付', 'button'),
$entry('billing.payment.balance.name', 'billing', 'cloud.invoice_detail', '账户余额'),
$entry('billing.payment.balance.description', 'billing', 'cloud.invoice_detail', '可用余额 {amount}', 'description', ['amount' => 'currency']),
$entry('billing.payment.online_fallback', 'billing', 'cloud.invoice_detail', '在线支付'),
$entry('billing.payment.provider.balance', 'billing', 'cloud.invoice_detail', '账户余额'),
$entry('billing.payment.provider.usdt', 'billing', 'cloud.invoice_detail', 'USDT-TRC20'),
$entry('billing.payment.provider.yipay_alipay', 'billing', 'cloud.invoice_detail', '易支付 · 支付宝'),
$entry('billing.payment.provider.yipay_wxpay', 'billing', 'cloud.invoice_detail', '易支付 · 微信'),
$entry('billing.payment.provider.paytaro', 'billing', 'cloud.invoice_detail', 'Paytaro · 支付宝'),
$entry('billing.payment.provider.stripe_card', 'billing', 'cloud.invoice_detail', 'Stripe · 银行卡'),
$entry('billing.payment.provider.stripe_alipay', 'billing', 'cloud.invoice_detail', 'Stripe · 支付宝'),
$entry('billing.payment.active.creating', 'billing', 'cloud.invoice_detail', '上一笔支付订单正在创建;您仍可选择其他支付方式。', 'status'),
$entry('billing.payment.active.pending', 'billing', 'cloud.invoice_detail', '已有待支付订单;可继续原订单或选择其他支付方式。', 'status'),
$entry('billing.payment.active.review', 'billing', 'cloud.invoice_detail', '上一笔支付订单结果待核对;可选择其他支付方式,原订单若随后到账将计入账户余额。', 'warning'),
$entry('billing.payment.expired.title', 'billing', 'cloud.invoice_detail', '支付订单已过期', 'title'),
$entry('billing.payment.expired.body', 'billing', 'cloud.invoice_detail', '请重新选择支付方式并确认,以生成新的支付订单。', 'description'),
$entry('billing.payment.usdt.amount', 'billing', 'cloud.invoice_detail', '请支付 {amount} USDT(TRC20)', 'label', ['amount' => 'string']),
$entry('billing.payment.address_unavailable', 'billing', 'cloud.invoice_detail', '收款地址不可用'),
$entry('billing.payment.usdt.notice', 'billing', 'cloud.invoice_detail', '支付订单具有时效;链上确认后自动结清账单。', 'description'),
$entry('billing.payment.copy_address', 'billing', 'cloud.invoice_detail', '复制收款地址', 'button'),
$entry('billing.payment.order_created', 'billing', 'cloud.invoice_detail', '{label}订单已生成', 'status', ['label' => 'string']),
$entry('billing.payment.open', 'billing', 'cloud.invoice_detail', '前往支付', 'button'),
$entry('billing.payment.info_unavailable', 'billing', 'cloud.invoice_detail', '支付信息暂不可用'),
$entry('billing.payment.copy_info', 'billing', 'cloud.invoice_detail', '复制支付信息', 'button'),
$entry('billing.payment.poll_notice', 'billing', 'cloud.invoice_detail', '完成付款后本页会在有限时间内刷新账单状态。请勿同时使用多个渠道重复付款。', 'description'),
$entry('billing.payment.select_required', 'billing', 'cloud.invoice_detail', '请选择支付方式。', 'warning'),
$entry('billing.payment.refresh_status', 'billing', 'cloud.invoice_detail', '刷新账单状态', 'button'),
$entry('billing.payment.refreshing', 'billing', 'cloud.invoice_detail', '账单正在刷新,请稍候。', 'notice'),
$entry('billing.payment.unpayable', 'billing', 'cloud.invoice_detail', '账单当前不可支付,请刷新后重试。', 'warning'),
$entry('billing.payment.create_unavailable', 'billing', 'cloud.invoice_detail', '账单当前不可创建支付订单,请刷新后重试。', 'warning'),
$entry('billing.payment.receipt_invalid', 'billing', 'cloud.invoice_detail', '支付创建请求已送达,但任务回执协议无效。请勿再次提交,并联系管理员核查。', 'warning', [], 'critical'),
$entry('billing.payment.task_title', 'billing', 'cloud.invoice_detail', '创建支付订单', 'title'),
$entry('billing.payment.task_accepted', 'billing', 'cloud.invoice_detail', '支付订单创建任务已接收,可在任务中心查看结果。', 'status'),
$entry('billing.payment.task_accepted_short', 'billing', 'cloud.invoice_detail', '支付订单创建任务已接收。', 'status'),
$entry('billing.payment.task_failed', 'billing', 'cloud.invoice_detail', '支付订单创建失败。', 'warning'),
$entry('billing.payment.effect_unknown_suffix', 'billing', 'cloud.invoice_detail', '原支付订单可能已由网关创建;可选择其他支付方式,原订单若随后到账将计入账户余额。', 'warning'),
$entry('billing.payment.status_reconciling', 'billing', 'cloud.invoice_detail', '支付订单状态正在核对,请稍后刷新。', 'status'),
$entry('billing.payment.status_description', 'billing', 'cloud.invoice_detail', '账单支付状态由服务端确认。', 'description'),
$entry('billing.qr.loading_aria', 'billing', 'cloud.invoice_detail', '正在生成支付二维码', 'aria_label'),
$entry('billing.qr.loading', 'billing', 'cloud.invoice_detail', '二维码生成中…', 'status'),
$entry('billing.qr.failed_aria', 'billing', 'cloud.invoice_detail', '支付二维码暂时无法显示', 'aria_label'),
$entry('billing.qr.failed', 'billing', 'cloud.invoice_detail', '二维码暂时无法显示,请使用支付按钮或复制支付信息。', 'warning'),
$entry('billing.error.qr_timeout', 'billing', 'cloud.invoice_detail', '二维码组件加载超时', 'warning'),
$entry('billing.error.qr_unavailable', 'billing', 'cloud.invoice_detail', '二维码组件不可用', 'warning'),
$entry('billing.error.qr_load', 'billing', 'cloud.invoice_detail', '二维码组件加载失败', 'warning'),
$entry('billing.error.qr_empty', 'billing', 'cloud.invoice_detail', '二维码组件未生成内容', 'warning'),
$entry('billing.error.copy', 'billing', 'cloud.invoice_detail', '浏览器无法复制,请手动选择文本。', 'warning'),
$entry('billing.error.timeout', 'billing', 'cloud.invoice_detail', '请求超时,请稍后重试。', 'warning'),
$entry('billing.error.cancelled', 'billing', 'cloud.invoice_detail', '请求已取消。', 'warning'),
$entry('billing.error.network', 'billing', 'cloud.invoice_detail', '网络请求失败,请检查连接后重试。', 'warning'),
$entry('billing.error.session', 'billing', 'cloud.invoice_detail', '账单会话信息不完整,请重新登录。', 'warning'),
$entry('billing.error.bootstrap_missing', 'billing', 'cloud.invoice_detail', '账单首屏数据缺失,请刷新页面后重试。', 'warning'),
$entry('billing.error.bootstrap_invalid', 'billing', 'cloud.invoice_detail', '账单首屏数据无效,请刷新页面后重试。', 'warning'),
$entry('billing.error.secure_transport', 'billing', 'cloud.invoice_detail', '请通过 HTTPS 使用账单支付功能。', 'warning'),
$entry('billing.error.invoice_invalid', 'billing', 'cloud.invoice_detail', '账单编号无效。', 'warning'),
$entry('billing.error.invoice_incomplete', 'billing', 'cloud.invoice_detail', '账单信息不完整,请刷新页面后重试。', 'warning'),
$entry('billing.error.presentation_incomplete', 'billing', 'cloud.invoice_detail', '账单展示信息不完整,请刷新页面后重试。', 'warning'),
$entry('billing.error.invoice_mismatch', 'billing', 'cloud.invoice_detail', '账单初始数据与当前地址不匹配,请返回账单列表重试。', 'warning'),
$entry('billing.error.initialize', 'billing', 'cloud.invoice_detail', '账单详情初始化失败,请刷新后重试。', 'warning'),
$entry('billing.error.refresh', 'billing', 'cloud.invoice_detail', '账单刷新失败,请稍后重试。', 'warning'),
$entry('billing.error.fulfillment_mismatch', 'billing', 'cloud.invoice_detail', '创建进度与当前账单不匹配,请刷新后重试。', 'warning'),
$entry('billing.error.terminal_effect_unknown', 'billing', 'cloud.invoice_detail', '{message} 操作效果可能已经发生,请勿再次提交,并联系管理员核查。', 'warning', ['message' => 'string'], 'critical'),
$entry('billing.error.terminal_locked', 'billing', 'cloud.invoice_detail', '{message} 相关资源保持安全锁定,请勿再次提交,并联系管理员核查。', 'warning', ['message' => 'string'], 'critical'),
$entry('billing.fulfillment.task_title.provision', 'billing', 'cloud.invoice_detail', '创建实例', 'title'),
$entry('billing.fulfillment.task_accepted.provision', 'billing', 'cloud.invoice_detail', '付款已完成,实例创建任务已接收,可在任务中心查看结果。', 'status'),
$entry('billing.fulfillment.completed.provision', 'billing', 'cloud.invoice_detail', '实例创建完成。', 'status'),
$entry('billing.fulfillment.failed.provision', 'billing', 'cloud.invoice_detail', '实例创建任务未能安全完成,请在任务中心查看详情。', 'warning'),
$entry('billing.fulfillment.paid.provision', 'billing', 'cloud.invoice_detail', '账单已支付,实例已进入创建队列。', 'status'),
$entry('billing.fulfillment.paid.generic', 'billing', 'cloud.invoice_detail', '账单已支付。', 'status'),
$entry('billing.fulfillment.title.provision', 'billing', 'cloud.invoice_detail', '实例创建进度', 'title'),
$entry('billing.fulfillment.title.upgrade', 'billing', 'cloud.invoice_detail', '实例升级进度', 'title'),
$entry('billing.fulfillment.title.ip_change', 'billing', 'cloud.invoice_detail', '公网 IPv4 更换进度', 'title'),
$entry('billing.fulfillment.title.generic', 'billing', 'cloud.invoice_detail', '任务进度', 'title'),
$entry('billing.fulfillment.description.provision', 'billing', 'cloud.invoice_detail', '账单付款后,系统会在后台创建实例;关闭页面不会取消任务。', 'description'),
$entry('billing.fulfillment.description.upgrade', 'billing', 'cloud.invoice_detail', '账单扣款后,系统会在后台升级实例;关闭页面不会取消任务。', 'description'),
$entry('billing.fulfillment.description.ip_change', 'billing', 'cloud.invoice_detail', '账单扣款后,系统会在后台更换公网 IPv4;公网 IPv6 保持不变,关闭页面不会取消任务。', 'description'),
$entry('billing.fulfillment.description.generic', 'billing', 'cloud.invoice_detail', '任务由系统在后台执行。', 'description'),
$entry('billing.fulfillment.waiting.provision', 'billing', 'cloud.invoice_detail', '等待创建', 'status'),
$entry('billing.fulfillment.waiting.upgrade', 'billing', 'cloud.invoice_detail', '等待升级', 'status'),
$entry('billing.fulfillment.waiting.ip_change', 'billing', 'cloud.invoice_detail', '等待更换公网 IPv4', 'status'),
$entry('billing.fulfillment.waiting.generic', 'billing', 'cloud.invoice_detail', '等待任务状态', 'status'),
$entry('billing.fulfillment.view_instance', 'billing', 'cloud.invoice_detail', '查看实例', 'navigation'),
$entry('billing.fulfillment.task_prefix', 'billing', 'cloud.invoice_detail', '任务 #{id} · ', 'status', ['id' => 'string']),
$entry('billing.notice.upgrade_succeeded', 'billing', 'cloud.invoice_detail', '实例升级完成。', 'status'),
$entry('billing.notice.upgrade_failed', 'billing', 'cloud.invoice_detail', '实例升级未完成,请在账单详情查看任务状态。', 'warning'),
$entry('billing.notice.ip_change_succeeded', 'billing', 'cloud.invoice_detail', '公网 IPv4 已更换;公网 IPv6 保持不变。', 'status'),
$entry('billing.notice.ip_change_review', 'billing', 'cloud.invoice_detail', '公网 IPv4 更换结果待人工核对,请勿重复提交。', 'warning', [], 'critical'),
$entry('billing.notice.ip_change_failed', 'billing', 'cloud.invoice_detail', '公网 IPv4 更换未完成,请在账单详情查看任务状态。', 'warning'),
$entry('billing.notice.provision_succeeded', 'billing', 'cloud.invoice_detail', '实例已创建完成。', 'status'),
$entry('billing.notice.provision_refunded', 'billing', 'cloud.invoice_detail', '实例创建失败,款项已退回账户余额。', 'warning'),
$entry('billing.notice.provision_failed', 'billing', 'cloud.invoice_detail', '实例开通未完成,请在账单详情查看任务状态。', 'warning'),
$entry('billing.notice.renewal_paid', 'billing', 'cloud.invoice_detail', '账单支付成功,服务期限已延长。', 'status'),
$entry('billing.notice.paid', 'billing', 'cloud.invoice_detail', '账单支付成功。', 'status'),
$entry('billing.notice.expired', 'billing', 'cloud.invoice_detail', '账单已失效,到账金额会保留在账户余额中。', 'warning'),
$entry('billing.notice.refunded', 'billing', 'cloud.invoice_detail', '实例创建失败,款项已退回账户余额。', 'warning'),
$entry('billing.notice.provision_deadline', 'billing', 'cloud.invoice_detail', '开通账单已超过支付截止时间。', 'warning'),
$entry('billing.notice.renewal_deadline', 'billing', 'cloud.invoice_detail', '续费宽限期已经结束,到账金额会保留在账户余额中。', 'warning'),
$entry('billing.notice.deadline', 'billing', 'cloud.invoice_detail', '账单已超过支付截止时间。', 'warning'),
];

@ -1,44 +1,44 @@
<section id="invoice-detail-workspace" class="invoice-detail-workspace" aria-labelledby="invoice-detail-title">
<a class="button button-ghost workspace-form-back" href="/user/cloud/invoices">← 返回账单信息</a>
<a class="button button-ghost workspace-form-back" href="/user/cloud/invoices">{user_copy key='billing.detail.back'}</a>
<div class="page-heading invoice-detail-heading">
<div>
<span class="eyebrow">BILL DETAIL</span>
<h1 id="invoice-detail-title" tabindex="-1">账单详情</h1>
<p id="invoice-detail-subtitle">账单 #{$cloud_invoice_detail_view.id|default:'—'|escape:"html"} · {$cloud_invoice_detail_view.created_display|default:'时间未记录'|escape:"html"}</p>
<span class="eyebrow">{user_copy key='billing.detail.eyebrow'}</span>
<h1 id="invoice-detail-title" tabindex="-1">{user_copy key='billing.detail.title'}</h1>
<p id="invoice-detail-subtitle">{if $cloud_invoice_detail_view.created_display|default:'' != ''}{user_copy key='billing.detail.subtitle' id=$cloud_invoice_detail_view.id|default:'—' time=$cloud_invoice_detail_view.created_display}{else}{user_copy key='billing.detail.subtitle_time_missing' id=$cloud_invoice_detail_view.id|default:'—'}{/if}</p>
</div>
<button id="invoice-detail-refresh" class="button button-outline" type="button">刷新</button>
<button id="invoice-detail-refresh" class="button button-outline" type="button">{user_copy key='billing.refresh'}</button>
</div>
<div id="invoice-detail-content" aria-live="polite">
<article class="inventory-panel invoice-detail-card">
<header class="invoice-detail-hero">
<div>
<span id="invoice-detail-kind" class="invoice-detail-kind">{$cloud_invoice_detail_view.title|default:'账单'|escape:"html"}</span>
<strong id="invoice-detail-number">账单 #{$cloud_invoice_detail_view.id|default:'—'|escape:"html"}</strong>
<small id="invoice-detail-created">创建于 {$cloud_invoice_detail_view.created_display|default:'时间未记录'|escape:"html"}</small>
<span id="invoice-detail-kind" class="invoice-detail-kind">{user_copy key=$cloud_invoice_detail_view.title_key|default:'billing.purpose.invoice'}</span>
<strong id="invoice-detail-number">{user_copy key='billing.detail.number' id=$cloud_invoice_detail_view.id|default:'—'}</strong>
<small id="invoice-detail-created">{if $cloud_invoice_detail_view.created_display|default:'' != ''}{user_copy key='billing.detail.created' time=$cloud_invoice_detail_view.created_display}{else}{user_copy key='billing.detail.created_time_missing'}{/if}</small>
</div>
<div class="invoice-detail-total">
<span>应付金额</span>
<span>{user_copy key='billing.detail.amount_due'}</span>
<strong id="invoice-detail-amount">{$cloud_invoice_detail_view.amount_display|default:'$—'|escape:"html"}</strong>
<span id="invoice-detail-status" class="state-pill {$cloud_invoice_detail_view.status_class|default:'other'|escape:"html"}">{$cloud_invoice_detail_view.status_label|default:'未知'|escape:"html"}</span>
<span id="invoice-detail-status" class="state-pill {$cloud_invoice_detail_view.status_class|default:'other'|escape:"html"}">{user_copy key=$cloud_invoice_detail_view.status_key|default:'billing.status.financial.unknown'}</span>
</div>
</header>
<dl id="invoice-detail-facts" class="invoice-detail-facts">
{foreach $cloud_invoice_detail_view.facts as $fact}
<div class="invoice-detail-fact">
<dt>{$fact.label|escape:"html"}</dt>
<dd>{$fact.value|default:'—'|escape:"html"}</dd>
<dt>{user_copy key=$fact.label_key}</dt>
<dd>{if $fact.value_key|default:'' != ''}{user_copy key=$fact.value_key}{else}{$fact.value|default:'—'|escape:"html"}{/if}</dd>
</div>
{/foreach}
</dl>
</article>
<article id="invoice-line-items-panel" class="inventory-panel invoice-detail-section"{if !$cloud_invoice_detail_view.show_line_items|default:false} hidden{/if}>
<div class="invoice-detail-section-heading"><div><h2>费用明细</h2><p>以下项目来自账单生成时冻结的费用快照。</p></div></div>
<div class="invoice-detail-section-heading"><div><h2>{user_copy key='billing.line_items.title'}</h2><p>{user_copy key='billing.line_items.description'}</p></div></div>
<div id="invoice-line-items" class="invoice-line-items" role="list">
{foreach $cloud_invoice_detail_view.line_items as $item}
<div class="invoice-line-item" role="listitem">
<span>{$item.label|escape:"html"}</span>
<span>{if $item.label_key|default:'' != ''}{user_copy key=$item.label_key}{elseif $item.label|default:'' != ''}{$item.label|escape:"html"}{else}{user_copy key='billing.line_items.fallback'}{/if}</span>
<strong>{$item.amount_display|escape:"html"}</strong>
</div>
{/foreach}
@ -46,46 +46,46 @@
</article>
<article id="invoice-specification-panel" class="inventory-panel invoice-detail-section"{if !$cloud_invoice_detail_view.show_specification|default:false} hidden{/if}>
<div class="invoice-detail-section-heading"><div><h2>套餐与服务</h2><p>该账单对应的实例规格、服务周期与流量额度。</p></div></div>
<div class="invoice-detail-section-heading"><div><h2>{user_copy key='billing.spec.title'}</h2><p>{user_copy key='billing.spec.description'}</p></div></div>
<dl id="invoice-specification" class="invoice-specification-grid">
{foreach $cloud_invoice_detail_view.specification as $fact}
<div class="invoice-detail-fact">
<dt>{$fact.label|escape:"html"}</dt>
<dd>{$fact.value|default:'—'|escape:"html"}</dd>
<dt>{user_copy key=$fact.label_key}</dt>
<dd>{if $fact.value_key|default:'' != ''}{if !empty($fact.value_parameters)}{user_copy key=$fact.value_key value=$fact.value_parameters.value}{else}{user_copy key=$fact.value_key}{/if}{else}{$fact.value|default:'—'|escape:"html"}{/if}</dd>
</div>
{/foreach}
</dl>
</article>
<article id="invoice-payment-panel" class="inventory-panel invoice-detail-section"{if !$cloud_invoice_detail_view.show_payment|default:false} hidden{/if}>
<div class="invoice-detail-section-heading"><div><h2 id="invoice-payment-title">{$cloud_invoice_detail_view.payment_title|default:'选择支付方式'|escape:"html"}</h2><p id="invoice-payment-description">{$cloud_invoice_detail_view.payment_description|default:'选择支付方式后,点击“立即支付”将直接发起支付,请勿重复点击。'|escape:"html"}</p></div></div>
<div id="invoice-payment-methods" class="invoice-payment-method-grid" role="radiogroup" aria-label="账单支付方式">
<div class="invoice-detail-section-heading"><div><h2 id="invoice-payment-title">{user_copy key=$cloud_invoice_detail_view.payment_title_key|default:'billing.payment.select_title'}</h2><p id="invoice-payment-description">{user_copy key=$cloud_invoice_detail_view.payment_description_key|default:'billing.payment.description.choose'}</p></div></div>
<div id="invoice-payment-methods" class="invoice-payment-method-grid" role="radiogroup" aria-label="{user_copy key='billing.payment.methods_aria'}">
{foreach $cloud_invoice_detail_view.payment_methods as $method}
<button class="invoice-payment-method-card" type="button" data-method-id="{$method.id|escape:"html"}" role="radio" aria-pressed="{if $method.selected}true{else}false{/if}" aria-checked="{if $method.selected}true{else}false{/if}">
<strong>{$method.name|escape:"html"}</strong>
<small>{$method.description|escape:"html"}</small>
<strong>{if $method.name_key|default:'' != ''}{user_copy key=$method.name_key}{else}{$method.name|escape:"html"}{/if}</strong>
<small>{if $method.description_key|default:'' == 'billing.payment.balance.description'}{user_copy key=$method.description_key amount=$method.description_parameters.amount}{elseif $method.description_key|default:'' != ''}{user_copy key=$method.description_key}{else}{$method.description|escape:"html"}{/if}</small>
<span class="invoice-payment-method-check">✓</span>
</button>
{/foreach}
</div>
<p id="invoice-payment-error" class="form-error" role="alert" hidden></p>
<div class="invoice-payment-actions"><button id="invoice-payment-submit" class="button button-primary" type="button" disabled>立即支付</button></div>
<div id="invoice-payment-result" class="invoice-payment-result" aria-live="polite">{if $cloud_invoice_detail_view.active_payment_message|default:'' != ''}<p class="{$cloud_invoice_detail_view.active_payment_class|default:'invoice-payment-note'|escape:"html"}">{$cloud_invoice_detail_view.active_payment_message|escape:"html"}</p>{/if}</div>
<div class="invoice-payment-actions"><button id="invoice-payment-submit" class="button button-primary" type="button" disabled>{user_copy key='billing.payment.pay_now'}</button></div>
<div id="invoice-payment-result" class="invoice-payment-result" aria-live="polite">{if $cloud_invoice_detail_view.active_payment_key|default:'' != ''}<p class="{$cloud_invoice_detail_view.active_payment_class|default:'invoice-payment-note'|escape:"html"}">{user_copy key=$cloud_invoice_detail_view.active_payment_key}</p>{/if}</div>
</article>
<article id="invoice-fulfillment-panel" class="inventory-panel invoice-detail-section"{if !$cloud_invoice_detail_view.show_fulfillment|default:false} hidden{/if}>
<div class="invoice-detail-section-heading"><div><h2 id="invoice-fulfillment-title">{$cloud_invoice_detail_view.fulfillment_title|default:'实例创建进度'|escape:"html"}</h2><p id="invoice-fulfillment-description">{$cloud_invoice_detail_view.fulfillment_description|default:'账单付款后,系统会在后台创建实例;关闭页面不会取消任务。'|escape:"html"}</p></div></div>
<div class="invoice-detail-section-heading"><div><h2 id="invoice-fulfillment-title">{user_copy key=$cloud_invoice_detail_view.fulfillment_title_key|default:'billing.fulfillment.title.generic'}</h2><p id="invoice-fulfillment-description">{user_copy key=$cloud_invoice_detail_view.fulfillment_description_key|default:'billing.fulfillment.description.generic'}</p></div></div>
<div id="invoice-fulfillment-content" class="invoice-fulfillment-content">
{if $cloud_invoice_detail_view.show_fulfillment|default:false}
<div class="invoice-fulfillment-detail">
<p class="cloud-order-progress {if $cloud_invoice_detail_view.fulfillment_failed}form-error{else}muted{/if}">{$cloud_invoice_detail_view.fulfillment_message|default:'等待创建'|escape:"html"}</p>
<p class="cloud-order-progress {if $cloud_invoice_detail_view.fulfillment_failed}form-error{else}muted{/if}">{user_copy key=$cloud_invoice_detail_view.fulfillment_message_key|default:'billing.fulfillment.waiting.generic'}</p>
</div>
<div class="cloud-order-actions invoice-fulfillment-actions">
{if $cloud_invoice_detail_view.fulfillment_label != ''}
<span class="state-pill {$cloud_invoice_detail_view.fulfillment_class|default:'warning'|escape:"html"}">{$cloud_invoice_detail_view.fulfillment_label|escape:"html"}</span>
{if $cloud_invoice_detail_view.fulfillment_key|default:'' != ''}
<span class="state-pill {$cloud_invoice_detail_view.fulfillment_class|default:'warning'|escape:"html"}">{user_copy key=$cloud_invoice_detail_view.fulfillment_key}</span>
{/if}
{if $cloud_invoice_detail_view.instance_id != ''}
<a class="row-button" href="/user/cloud/instances/{$cloud_invoice_detail_view.instance_id|escape:"url"}">查看实例</a>
<a class="row-button" href="/user/cloud/instances/{$cloud_invoice_detail_view.instance_id|escape:"url"}">{user_copy key='billing.fulfillment.view_instance'}</a>
{/if}
</div>
{/if}

@ -1,70 +1,70 @@
<section id="invoices-workspace">
<div class="page-heading"><div><span class="eyebrow">BILLING</span><h1>账单信息</h1><p>部署实例时先生成开通账单,支付完成后才开始创建;实例到期前 7 天会自动生成续费账单。实例到期后立即停用网络,到期满 3 天仍未续费,实例及系统盘将被永久删除。</p></div><button id="invoices-refresh" class="button button-outline" type="button">刷新</button></div>
<div class="page-heading"><div><span class="eyebrow">{user_copy key='billing.list.eyebrow'}</span><h1>{user_copy key='billing.list.title'}</h1><p>{user_copy key='billing.list.description'}</p></div><button id="invoices-refresh" class="button button-outline" type="button">{user_copy key='billing.refresh'}</button></div>
<div class="invoice-balance-card">
<div class="invoice-balance-summary">
<span class="invoice-balance-label">当前账户余额</span>
<span class="invoice-balance-label">{user_copy key='billing.balance.label'}</span>
<strong id="invoices-balance">{$cloud_invoice_balance|escape:"html"}</strong>
<small class="invoice-balance-hint">可用于支付未结清账单</small>
<small class="invoice-balance-hint">{user_copy key='billing.balance.hint'}</small>
</div>
<button class="button button-outline small" type="button" data-account-drawer-open="balance" data-drawer-title="余额充值" data-drawer-description="选择充值金额和可用支付方式">余额充值</button>
<button class="button button-outline small" type="button" data-account-drawer-open="balance" data-drawer-title="{user_copy key='billing.balance.recharge'}" data-drawer-description="{user_copy key='billing.balance.drawer_description'}">{user_copy key='billing.balance.recharge'}</button>
</div>
<form id="invoices-filter-form" class="invoice-filter-bar" method="get" action="/user/cloud/invoices">
<label class="invoice-filter-field" for="invoices-purpose-filter">
<span>账单类型</span>
<select id="invoices-purpose-filter" name="purpose" aria-label="按账单类型筛选">
<option value="all"{if $cloud_invoice_filter == 'all'} selected{/if}>全部账单</option>
<option value="renewal"{if $cloud_invoice_filter == 'renewal'} selected{/if}>续费账单</option>
<option value="provision"{if $cloud_invoice_filter == 'provision'} selected{/if}>开通账单</option>
<option value="upgrade"{if $cloud_invoice_filter == 'upgrade'} selected{/if}>升级账单</option>
<option value="ip_change"{if $cloud_invoice_filter == 'ip_change'} selected{/if}>更换公网 IPv4</option>
<option value="backup_addon"{if $cloud_invoice_filter == 'backup_addon'} selected{/if}>自动备份开通</option>
<span>{user_copy key='billing.filter.purpose.label'}</span>
<select id="invoices-purpose-filter" name="purpose" aria-label="{user_copy key='billing.filter.purpose.aria'}">
<option value="all"{if $cloud_invoice_filter == 'all'} selected{/if}>{user_copy key='billing.filter.purpose.all'}</option>
<option value="renewal"{if $cloud_invoice_filter == 'renewal'} selected{/if}>{user_copy key='billing.purpose.renewal'}</option>
<option value="provision"{if $cloud_invoice_filter == 'provision'} selected{/if}>{user_copy key='billing.purpose.provision'}</option>
<option value="upgrade"{if $cloud_invoice_filter == 'upgrade'} selected{/if}>{user_copy key='billing.purpose.upgrade'}</option>
<option value="ip_change"{if $cloud_invoice_filter == 'ip_change'} selected{/if}>{user_copy key='billing.purpose.ip_change'}</option>
<option value="backup_addon"{if $cloud_invoice_filter == 'backup_addon'} selected{/if}>{user_copy key='billing.purpose.backup_addon'}</option>
</select>
</label>
<label class="invoice-filter-field" for="invoices-status-filter">
<span>账单状态</span>
<span>{user_copy key='billing.filter.status.label'}</span>
<select id="invoices-status-filter" name="status">
<option value="all"{if $cloud_invoice_filters.status == 'all'} selected{/if}>全部状态</option>
<option value="pending"{if $cloud_invoice_filters.status == 'pending'} selected{/if}>待支付</option>
<option value="paid"{if $cloud_invoice_filters.status == 'paid'} selected{/if}>已支付</option>
<option value="closed"{if $cloud_invoice_filters.status == 'closed'} selected{/if}>已关闭</option>
<option value="all"{if $cloud_invoice_filters.status == 'all'} selected{/if}>{user_copy key='billing.filter.status.all'}</option>
<option value="pending"{if $cloud_invoice_filters.status == 'pending'} selected{/if}>{user_copy key='billing.filter.status.pending'}</option>
<option value="paid"{if $cloud_invoice_filters.status == 'paid'} selected{/if}>{user_copy key='billing.filter.status.paid'}</option>
<option value="closed"{if $cloud_invoice_filters.status == 'closed'} selected{/if}>{user_copy key='billing.filter.status.closed'}</option>
</select>
</label>
<label class="invoice-filter-field invoice-filter-keyword" for="invoices-keyword-filter">
<span>账单或实例</span>
<input id="invoices-keyword-filter" name="keyword" type="search" maxlength="100" value="{$cloud_invoice_filters.keyword|default:''|escape:"html"}" placeholder="账单编号或实例名称">
<span>{user_copy key='billing.filter.keyword.label'}</span>
<input id="invoices-keyword-filter" name="keyword" type="search" maxlength="100" value="{$cloud_invoice_filters.keyword|default:''|escape:"html"}" placeholder="{user_copy key='billing.filter.keyword.placeholder'}">
</label>
<div class="invoice-filter-actions">
<button id="invoices-filter-submit" class="button button-primary small" type="submit">筛选</button>
<button id="invoices-filter-reset" class="button button-ghost small" type="button">清除</button>
<button id="invoices-filter-submit" class="button button-primary small" type="submit">{user_copy key='billing.filter.apply'}</button>
<button id="invoices-filter-reset" class="button button-ghost small" type="button">{user_copy key='billing.filter.clear'}</button>
</div>
</form>
<div id="invoices-list" class="inventory-panel cloud-orders cloud-invoices" aria-live="polite">
{if empty($cloud_invoice_rows)}
<p class="muted">暂无账单。部署实例后会先生成开通账单;续费账单会在实例到期前 7 天自动生成。</p>
<p class="muted">{user_copy key='billing.list.empty'}</p>
{else}
{foreach $cloud_invoice_rows as $invoice}
<article class="cloud-order cloud-invoice cloud-invoice-list-row">
<div class="cloud-order-detail cloud-invoice-list-copy">
<strong>{$invoice.title|escape:"html"}</strong>
<p class="muted">账单 #{$invoice.id|escape:"html"} · {$invoice.created_display|escape:"html"}</p>
{if $invoice.context_display}<p class="muted cloud-invoice-context">{$invoice.context_display|escape:"html"}</p>{/if}
<strong>{user_copy key=$invoice.title_key}</strong>
<p class="muted">{if $invoice.created_display|default:'' != ''}{user_copy key='billing.list.invoice_meta' id=$invoice.id time=$invoice.created_display}{else}{user_copy key='billing.list.invoice_meta_time_missing' id=$invoice.id}{/if}</p>
{if !empty($invoice.context_segments)}<p class="muted cloud-invoice-context">{foreach $invoice.context_segments as $segment}{if $segment.kind == 'timestamp'}{if $segment.value > 0}{$segment.value|date_format:'%Y/%m/%d %H:%M:%S'|escape:"html"}{else}{user_copy key='billing.value.time_missing'}{/if}{elseif $segment.key == 'billing.context.target_instance'}{user_copy key=$segment.key name=$segment.parameters.name}{else}{user_copy key=$segment.key}{/if}{/foreach}</p>{/if}
</div>
<div class="cloud-order-actions cloud-invoice-list-actions">
<span class="state-pill {$invoice.status_class|escape:"html"}">{$invoice.status_label|escape:"html"}</span>
<span class="state-pill {$invoice.status_class|escape:"html"}">{user_copy key=$invoice.status_key}</span>
{if $invoice.show_fulfillment}
<span class="state-pill {$invoice.fulfillment_class|escape:"html"}">{$invoice.fulfillment_label|escape:"html"}</span>
<span class="state-pill {$invoice.fulfillment_class|escape:"html"}">{user_copy key=$invoice.fulfillment_key}</span>
{/if}
<a class="row-button" href="/user/cloud/invoices/{$invoice.id|escape:"url"}">账单详情</a>
<a class="row-button" href="/user/cloud/invoices/{$invoice.id|escape:"url"}">{user_copy key='billing.list.detail'}</a>
</div>
<div class="cloud-invoice-list-amount"><span>金额</span><strong>{$invoice.amount_display|escape:"html"}</strong></div>
<div class="cloud-invoice-list-amount"><span>{user_copy key='billing.list.amount'}</span><strong>{$invoice.amount_display|escape:"html"}</strong></div>
</article>
{/foreach}
{/if}
</div>
<nav id="invoices-pagination" class="invoice-pagination" aria-label="账单分页"{if $cloud_invoice_pagination.total == 0} hidden{/if}>
<button id="invoices-previous" class="button button-outline small" type="button"{if !$cloud_invoice_pagination.has_previous} disabled{/if}>上一页</button>
<span id="invoices-page-label" aria-live="polite">第 {$cloud_invoice_pagination.page|escape:"html"} / {$cloud_invoice_pagination.total_pages|escape:"html"} 页 · 共 {$cloud_invoice_pagination.total|escape:"html"} 条</span>
<button id="invoices-next" class="button button-outline small" type="button"{if !$cloud_invoice_pagination.has_next} disabled{/if}>下一页</button>
<nav id="invoices-pagination" class="invoice-pagination" aria-label="{user_copy key='billing.pagination.aria'}"{if $cloud_invoice_pagination.total == 0} hidden{/if}>
<button id="invoices-previous" class="button button-outline small" type="button"{if !$cloud_invoice_pagination.has_previous} disabled{/if}>{user_copy key='billing.pagination.previous'}</button>
<span id="invoices-page-label" aria-live="polite">{user_copy key='billing.pagination.label' page=$cloud_invoice_pagination.page pages=$cloud_invoice_pagination.total_pages total=$cloud_invoice_pagination.total}</span>
<button id="invoices-next" class="button button-outline small" type="button"{if !$cloud_invoice_pagination.has_next} disabled{/if}>{user_copy key='billing.pagination.next'}</button>
</nav>
<script id="invoices-bootstrap" type="application/json">{$cloud_invoice_bootstrap_json nofilter}</script>
</section>

@ -27,10 +27,11 @@ $assert(str_contains($pageService, "'backup_addon'")
&& str_contains($catalog, "'backup_addon' => '自动备份开通'"),
'Automatic-backup bills are not recognized by user invoice services.');
$assert(str_contains($listTemplate, 'value="backup_addon"')
&& str_contains($listRuntime, 'invoice?.title')
&& str_contains($listRuntime, 'invoice?.title_key')
&& str_contains($detailRuntime, 'payload?.presentation')
&& str_contains($presentation,
'CloudBillingPresentationCatalog::knownPurposeLabel($purpose)')
"'backup_addon', 'recharge'")
&& str_contains($presentation, "'billing.purpose.' . \$purpose")
&& str_contains($catalog, "'backup_addon' => '自动备份开通'")
&& str_contains($detailRuntime, '/user/cloud/instances/'),
'User invoice UI hides the add-on type or its linked instance.');

@ -99,22 +99,20 @@ try {
'created_at' => 1761984000, 'paid_via' => 'paytaro',
],
]);
$facts = array_column($user['facts'], 'value', 'label');
$assert($user['title'] === $display['purpose_label']
$facts = array_column($user['facts'], null, 'label_key');
$assert($user['title_key'] === 'billing.purpose.backup_addon'
&& $user['amount_display'] === $display['amount_display']
&& ($facts['支付方式'] ?? null) === $display['provider_label'],
'User and administrator presentation stopped sharing billing vocabulary.');
&& ($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_label']
=== CloudBillingPresentationCatalog::status(
'financial', 'void'
)['label']
$assert($voidUser['status_key'] === 'billing.status.financial.void'
&& $voidUser['status_class'] === 'other',
'User adapter overrode the catalog financial label or tone.');
'User adapter overrode the catalog financial code or tone.');
$options = $page['presentation']['catalog'];
$find = static function (array $options, string $value): ?string {

@ -97,7 +97,7 @@ $assert(str_contains($pageController, 'JSON_HEX_TAG')
$assert(str_contains($invoiceDetailTemplate, 'id="invoice-detail-bootstrap"')
&& str_contains($invoiceDetailTemplate, '$cloud_invoice_detail_bootstrap_json nofilter')
&& str_contains($invoiceDetailTemplate, '$cloud_invoice_detail_view.amount_display')
&& str_contains($invoiceDetailTemplate, '$cloud_invoice_detail_view.status_label')
&& str_contains($invoiceDetailTemplate, '$cloud_invoice_detail_view.status_key')
&& str_contains($invoiceDetailTemplate, '{foreach $cloud_invoice_detail_view.facts as $fact}')
&& str_contains($invoiceDetailTemplate,
'{foreach $cloud_invoice_detail_view.specification as $fact}')
@ -127,7 +127,7 @@ $assert(str_contains($lineItemRuntime, "byId('invoice-line-items-panel')")
$assert(str_contains($invoiceDetailTemplate, 'id="invoice-payment-title"')
&& str_contains($invoiceDetailTemplate, 'id="invoice-payment-description"')
&& str_contains($invoiceDetailTemplate,
'$cloud_invoice_detail_view.active_payment_message')
'$cloud_invoice_detail_view.active_payment_key')
&& str_contains($invoiceDetailRuntime, 'activePayment: null')
&& str_contains($invoiceDetailRuntime,
'function renderActiveInvoicePayment(')
@ -210,7 +210,8 @@ $assert(str_contains($statusApiMethod, 'CloudInvoiceDetailPageService::statusFor
$assert(!str_contains($invoiceDetailRuntime, '/api/v1/jobs/')
&& substr_count($invoiceDetailRuntime,
'/api/v1/invoices/${encodeURIComponent(invoice.id)}/status') === 1
&& str_contains($invoiceDetailRuntime, "actionButton('刷新账单状态'")
&& str_contains($invoiceDetailRuntime,
"actionButton(t('billing.payment.refresh_status')")
&& str_contains($invoiceDetailRuntime,
'const nextPresentation = mergePresentationPatch(state.presentation, patch);'),
'Manual creation-progress refresh must use one invoice-scoped lightweight request.');
@ -299,7 +300,8 @@ $assert(!str_contains($invoiceDetailRuntime, 'function hasPendingInvoicePaymentK
&& str_contains($paymentExpiry, 'function onlinePaymentHasExpired(')
&& str_contains($paymentExpiry, 'function expireOnlinePaymentInstructions(')
&& str_contains($paymentExpiry, 'clearOnlinePaymentState(true);')
&& str_contains($paymentExpiry, "makeElement('strong', '', '支付订单已过期')")
&& str_contains($paymentExpiry,
"makeElement('strong', '', t('billing.payment.expired.title'))")
&& str_contains($paymentExpiry, 'void refreshInvoiceDetail(invoiceId);')
&& str_contains($onlinePaymentRender, 'paymentExpiresAt === null')
&& str_contains($onlinePaymentRender,
@ -402,9 +404,9 @@ $providerIdempotency = strpos($providerPayment,
$providerRequest = strpos($providerPayment,
'api(`/api/v1/invoices/${encodeURIComponent(invoice.id)}/payments`');
$assert(str_contains($providerPayment,
"const creationStillInProgress = String(error.message).includes('正在创建');")
'const creationStillInProgress = status === 409;')
&& str_contains($providerPayment,
'if ([403, 409].includes(status) && !creationStillInProgress)')
'if ([403, 409].includes(status))')
&& str_contains($providerPayment, 'await refreshInvoiceDetail(invoice.id);'),
'A deterministic provider-payment rejection must refresh server payable state.');
$assert(!str_contains($providerPayment, 'confirm(')
@ -483,8 +485,8 @@ $assert(!str_contains($cleanup, 'toastTimer')
&& str_contains($cleanup, 'if (element) element.hidden = true;'),
'BFCache cleanup must hide the shared toast region without retaining obsolete local timer state.');
$assert(str_contains($invoiceDetailTemplate,
'选择支付方式后,点击“立即支付”将直接发起支付,请勿重复点击。')
&& str_contains($invoiceDetailTemplate, '>立即支付</button>')
"billing.payment.description.choose")
&& str_contains($invoiceDetailTemplate, "billing.payment.pay_now")
&& !str_contains($invoiceDetailTemplate, '再确认支付本账单')
&& !str_contains($invoiceDetailTemplate, '>确认支付</button>'),
'Invoice payment copy must describe immediate execution without stale confirmation text.');
@ -521,8 +523,9 @@ $assert(str_contains($billingCatalog, "'recharge' => '余额充值'")
&& str_contains($billingCatalog, "'provision' => '实例开通'")
&& str_contains($billingCatalog, "'renewal' => '实例续费'")
&& str_contains($invoicePresentation,
'CloudBillingPresentationCatalog::knownPurposeLabel($purpose)')
&& str_contains($invoicePresentation, "'title' => self::invoiceTitle("),
'private static function invoiceTitleKey(string $purpose)')
&& str_contains($invoicePresentation,
"? 'billing.purpose.' . \$purpose : 'billing.purpose.invoice'"),
'Invoice purpose labels are incomplete.');
$assert(!str_contains($displayMethod, "'invoice_no' =>"),
'The internal invoice number is still exposed to users.');

@ -37,20 +37,20 @@ class Node {
}
const invoice = id => ({
id: String(id), purpose: 'renewal', title: '实例续费', amount: '999.00',
id: String(id), purpose: 'renewal', title_key: 'billing.purpose.renewal', amount: '999.00',
status: 'void', created_at: 1,
renews_expires_at: 2_000_100_000,
created_display: `服务端时间-${id}`,
amount_display: `$10.0${id}`,
status_label: `服务端状态-${id}`,
status_key: `test.status.${id}`,
status_class: 'warning',
context_display: `服务端上下文-${id}`,
context_segments: [
{ kind: 'text', value: '对应实例到期 ' },
{ kind: 'copy', key: 'billing.context.renewal_expiry' },
{ kind: 'timestamp', value: 2_000_100_000 },
],
show_fulfillment: true,
fulfillment_label: `服务端履约-${id}`,
fulfillment_key: `test.fulfillment.${id}`,
fulfillment_class: 'running',
polling_required: false,
});
@ -102,9 +102,31 @@ async function setup() {
location.href = new URL(next, location.href).href;
},
};
const copy = {
text(key, parameters = {}) {
if (key === 'billing.purpose.renewal') return '实例续费';
if (key === 'billing.context.renewal_expiry') return '对应实例到期 ';
if (key === 'billing.list.invoice_meta') {
return `账单 #${parameters.id} · ${parameters.time}`;
}
if (key === 'billing.list.detail') return '账单详情';
if (key === 'billing.list.amount') return '金额';
if (key === 'billing.list.empty') return '暂无账单。';
if (key === 'billing.pagination.label') {
return `第 ${parameters.page} / ${parameters.pages} 页 · 共 ${parameters.total} 条`;
}
if (key === 'billing.value.time_missing') return '时间未记录';
if (key.startsWith('test.status.')) return `服务端状态-${key.split('.').at(-1)}`;
if (key.startsWith('test.fulfillment.')) return `服务端履约-${key.split('.').at(-1)}`;
return key;
},
date(value) {
return value.toLocaleString('zh-CN', { hour12: false });
},
};
const context = vm.createContext({
AbortController, URL, URLSearchParams, console, document, fetch, history,
location, window, Date, Error,
location, window, Date, Error, VenixUserCopy: copy,
});
vm.runInContext(
source.replace('export async function initialize()', 'async function initialize()')

@ -59,7 +59,7 @@ $assert(str_contains($template, 'id="invoices-bootstrap"')
&& str_contains($template, 'value="renewal"')
&& !str_contains($template, 'href="/user/cloud/invoices?purpose=renewal"')
&& str_contains($template, 'cloud-invoice-context')
&& str_contains($presentation, "'对应实例到期 '")
&& str_contains($presentation, "'billing.context.renewal_expiry'")
&& !str_contains($template, '正在加载…'),
'Invoice HTML must contain the first records instead of a client-only loading placeholder.');
$assert(!str_contains($module, '/cloud/runtime.js')
@ -74,10 +74,10 @@ $assert(!str_contains($module, '/cloud/runtime.js')
&& str_contains($module, "addEventListener('submit'")
&& str_contains($module, 'invoice?.created_display')
&& str_contains($module, 'invoice?.amount_display')
&& str_contains($module, 'invoice?.status_label')
&& str_contains($module, 'invoice?.status_key')
&& str_contains($module, 'invoice?.status_class')
&& str_contains($module, 'invoice?.context_display')
&& str_contains($module, 'invoice?.fulfillment_label')
&& str_contains($module, 'invoice?.context_segments')
&& str_contains($module, 'invoice?.fulfillment_key')
&& str_contains($module, 'invoice?.polling_required === true')
&& str_contains($module, 'state.invoices.some(invoiceNeedsPolling)')
&& !str_contains($module, 'function formatDate(')

@ -189,7 +189,7 @@ $assert($renewals['purpose'] === 'renewal'
&& ($invoice['purpose'] ?? null) === 'renewal'
&& ($invoice['currency'] ?? null) === 'USD'
&& ($invoice['amount_display'] ?? null) === '$10.00'
&& ($invoice['status_label'] ?? null) === '已支付'
&& ($invoice['status_key'] ?? null) === 'billing.status.financial.paid'
&& ($invoice['polling_required'] ?? null) === false
&& ($invoice['renews_expires_at'] ?? null) === $expiry
&& ($invoice['payment_deadline_at'] ?? null)

@ -174,10 +174,8 @@ $assert(($creating['active_payment']['status'] ?? null) === 'creating'
&& $creating['payment_methods'] === []
&& $creating['balance_payment_allowed'] === true
&& ($creating['presentation']['show_payment'] ?? false) === true
&& str_contains(
(string) ($creating['presentation']['active_payment_message'] ?? ''),
'仍可选择其他支付方式'
),
&& ($creating['presentation']['active_payment_key'] ?? null)
=== 'billing.payment.active.creating',
'A durable payment-create task blocked a new payment choice.');
Capsule::table('cloud_jobs')->where('id', 31)->update([
@ -229,8 +227,8 @@ $assert(($pendingStatus['invoice']['id'] ?? null) === '21'
&& ($pendingStatus['active_payment']['status'] ?? null) === 'pending'
&& ($pendingStatus['active_payment']['payment']['payment_value'] ?? null)
=== 'https://checkout.stripe.test/resume-safe'
&& ($pendingStatus['presentation_patch']['payment']['message'] ?? null)
=== '已有待支付订单;可继续原订单或选择其他支付方式。'
&& ($pendingStatus['presentation_patch']['payment']['message_key'] ?? null)
=== 'billing.payment.active.pending'
&& ($pendingStatus['presentation_patch']['polling']['required'] ?? false)
=== true,
'Lightweight invoice polling omitted the active provider payment.');

@ -103,6 +103,29 @@ try {
const page = await browser.newPage();
await page.goto(`http://127.0.0.1:${address.port}/`);
await page.evaluate(() => {
const messages = {
'test.invoice.title': '服务端账单标题',
'test.invoice.status': '服务端待支付',
'test.invoice.poll_status': '服务端轮询状态',
'test.invoice.stale_status': '过期轮询状态不应显示',
'test.fact.label': '服务端事实',
'test.payment.title': '服务端支付标题',
'test.payment.description': '服务端支付说明',
'test.payment.active': '服务端待支付订单',
'test.payment.stale': '过期支付状态',
'billing.payment.usdt.amount': '请支付 {amount} USDT(TRC20)',
'billing.payment.task_accepted': '支付订单创建任务已接收。',
'billing.payment.task_accepted_short': '支付订单创建任务已接收。',
};
window.VenixUserCopy = {
text(key, parameters = {}) {
return String(messages[key] || key).replace(
/\{([a-z_][a-z0-9_]*)\}/gi,
(_match, name) => String(parameters[name] ?? ''),
);
},
date(value) { return value.toLocaleString('zh-CN', { hour12: false }); },
};
const jsonResponse = (status, payload) => new Response(
JSON.stringify(payload),
{ status, headers: { 'Content-Type': 'application/json' } },
@ -156,32 +179,29 @@ try {
};
const presentation = {
id: '21',
title: '服务端账单标题',
number_text: '服务端账单编号',
created_text: '服务端创建时间',
subtitle: '服务端账单副标题',
title_key: 'test.invoice.title',
amount_display: '$10.00',
status_label: '服务端待支付',
status_key: 'test.invoice.status',
status_class: 'warning',
facts: [{ label: '服务端事实', value: '服务端事实值' }],
facts: [{ label_key: 'test.fact.label', value: '服务端事实值' }],
show_line_items: false,
line_items: [],
show_specification: false,
specification: [],
show_payment: true,
payment_title: '服务端支付标题',
payment_description: '服务端支付说明',
active_payment_message: '服务端待支付订单',
payment_title_key: 'test.payment.title',
payment_description_key: 'test.payment.description',
active_payment_key: 'test.payment.active',
active_payment_class: 'invoice-payment-note',
payment_methods: [
{ id: 'stripe_card', name: 'Stripe Card', description: 'Card', selected: true },
{ id: 'usdt', name: 'USDT', description: 'USDT', selected: false },
],
show_fulfillment: false,
fulfillment_title: '',
fulfillment_description: '',
fulfillment_message: '',
fulfillment_label: '',
fulfillment_title_key: 'billing.fulfillment.title.generic',
fulfillment_description_key: 'billing.fulfillment.description.generic',
fulfillment_message_key: 'billing.fulfillment.waiting.generic',
fulfillment_key: '',
fulfillment_class: 'other',
fulfillment_failed: false,
task_id: '',
@ -266,15 +286,17 @@ try {
active_payment: {
status: 'pending', task_id: null, payment: oldPayment, can_submit: true,
},
status: { code: 'open', label: '服务端轮询状态', class: 'warning' },
status: { code: 'open', copy_key: 'test.invoice.poll_status', class: 'warning' },
payment: {
payable: true, active: { status: 'pending' },
message: '服务端待支付订单', message_class: 'invoice-payment-note',
message_key: 'test.payment.active', message_class: 'invoice-payment-note',
},
fulfillment: {
show_fulfillment: false, fulfillment_title: '',
fulfillment_description: '', fulfillment_message: '',
fulfillment_label: '', fulfillment_class: 'other',
show_fulfillment: false,
fulfillment_title_key: 'billing.fulfillment.title.generic',
fulfillment_description_key: 'billing.fulfillment.description.generic',
fulfillment_message_key: 'billing.fulfillment.waiting.generic',
fulfillment_key: '', fulfillment_class: 'other',
fulfillment_failed: false, task_id: '', instance_id: '', status_code: '',
},
polling: { required: true, task_id: '', job_status: '' },
@ -314,15 +336,17 @@ try {
active_payment: {
status: 'pending', task_id: null, payment: oldPayment, can_submit: true,
},
status: { code: 'open', label: '过期轮询状态不应显示', class: 'failed' },
status: { code: 'open', copy_key: 'test.invoice.stale_status', class: 'failed' },
payment: {
payable: true, active: { status: 'pending' },
message: '过期支付状态', message_class: 'invoice-payment-error',
message_key: 'test.payment.stale', message_class: 'invoice-payment-error',
},
fulfillment: {
show_fulfillment: false, fulfillment_title: '',
fulfillment_description: '', fulfillment_message: '',
fulfillment_label: '', fulfillment_class: 'other',
show_fulfillment: false,
fulfillment_title_key: 'billing.fulfillment.title.generic',
fulfillment_description_key: 'billing.fulfillment.description.generic',
fulfillment_message_key: 'billing.fulfillment.waiting.generic',
fulfillment_key: '', fulfillment_class: 'other',
fulfillment_failed: false, task_id: '', instance_id: '', status_code: '',
},
polling: { required: true, task_id: '', job_status: '' },

@ -45,19 +45,22 @@ $renewal = [
$rows = CloudInvoicePresentation::summaries([$renewal]);
$assert(count($rows) === 1
&& $rows[0]['status_label'] === '已到期,宽限期内可续费'
&& $rows[0]['status_key'] === 'billing.status.financial.renewal_grace'
&& $rows[0]['status_class'] === 'warning'
&& $rows[0]['amount_display'] === '$12.51'
&& $rows[0]['polling_required'] === true
&& str_contains($rows[0]['context_display'], '最晚支付')
&& ($rows[0]['context_segments'][0]['key'] ?? null)
=== 'billing.context.renewal_expiry'
&& ($rows[0]['context_segments'][1]['value'] ?? null) === 2_000_100_000
&& ($rows[0]['context_segments'][2]['key'] ?? null)
=== 'billing.context.latest_payment'
&& ($rows[0]['context_segments'][3]['value'] ?? null) === 2_000_359_200,
'Renewal grace summary did not preserve its canonical status and deadline.');
$wrongLegacyTitle = $renewal;
$wrongLegacyTitle['title'] = '旧调用方错误标题';
$assert(CloudInvoicePresentation::summaries([$wrongLegacyTitle])[0]['title']
=== '实例续费',
$assert(CloudInvoicePresentation::summaries([$wrongLegacyTitle])[0]['title_key']
=== 'billing.purpose.renewal',
'Known invoice title was still controlled by a legacy caller mapping.');
$detail = CloudInvoicePresentation::detail([
@ -67,18 +70,22 @@ $detail = CloudInvoicePresentation::detail([
]);
$assert($detail['show_line_items'] === true
&& $detail['line_items'] === [
['label' => '实例套餐续费', 'amount_display' => '$10.00'],
[
'label' => '实例套餐续费',
'label_key' => 'billing.line_items.renewal_plan',
'amount_display' => '$10.00',
],
[
'label' => '<img src=x onerror=alert(1)>自动备份',
'label_key' => 'billing.line_items.backup_renewal',
'amount_display' => '$2.50',
],
]
&& $detail['amount_display'] === '$12.51'
&& $detail['number_text'] === '账单 #17'
&& $detail['number_parameters'] === ['id' => '17']
&& $detail['created_at'] === 2_000_000_000
&& ($detail['facts'][1]['timestamp'] ?? null) === 2_000_000_000
&& ($detail['facts'][2]['timestamp'] ?? null) === 2_000_100_000
&& str_starts_with($detail['created_text'], '创建于 ')
&& $detail['polling_required'] === false,
'Detail projection changed frozen line-item labels or authoritative total.');
@ -98,8 +105,8 @@ $switchable = CloudInvoicePresentation::detail([
],
]);
$assert($switchable['show_payment'] === true
&& $switchable['payment_title'] === '选择支付方式'
&& str_contains($switchable['active_payment_message'], '可选择其他支付方式')
&& $switchable['payment_title_key'] === 'billing.payment.select_title'
&& $switchable['active_payment_key'] === 'billing.payment.active.review'
&& count($switchable['payment_methods']) === 2
&& $switchable['payment_methods'][0]['id'] === 'balance'
&& $switchable['payment_methods'][0]['selected'] === true
@ -127,16 +134,20 @@ $ipChange = [
$ipView = CloudInvoicePresentation::detail(['invoice' => $ipChange]);
$ipRow = CloudInvoicePresentation::summaries([$ipChange])[0];
$assert($ipView['show_fulfillment'] === true
&& $ipView['title'] === '更换公网 IPv4'
&& $ipView['fulfillment_title'] === '公网 IPv4 更换进度'
&& $ipView['fulfillment_label'] === '待人工核对'
&& $ipView['title_key'] === 'billing.purpose.ip_change'
&& $ipView['fulfillment_title_key']
=== 'billing.fulfillment.title.ip_change'
&& $ipView['fulfillment_key'] === 'billing.status.fulfillment.review'
&& $ipView['fulfillment_class'] === 'warning'
&& $ipView['instance_id'] === '41'
&& $ipRow['show_fulfillment'] === true
&& $ipRow['fulfillment_label'] === '待人工核对'
&& $ipRow['context_display'] === '目标实例 vm-audit'
&& ($ipView['completion_notice']['message'] ?? null)
=== '公网 IPv4 更换结果待人工核对,请勿重复提交。',
&& $ipRow['fulfillment_key'] === 'billing.status.fulfillment.review'
&& ($ipRow['context_segments'][0]['key'] ?? null)
=== 'billing.context.target_instance'
&& ($ipRow['context_segments'][0]['parameters']['name'] ?? null)
=== 'vm-audit'
&& ($ipView['completion_notice']['copy_key'] ?? null)
=== 'billing.notice.ip_change_review',
'IP-change presentation lost its target or review-only fulfillment state.');
$unknown = CloudInvoicePresentation::summaries([[
@ -147,11 +158,11 @@ $unknown = CloudInvoicePresentation::summaries([[
'status' => 'provider_unknown',
'created_at' => 0,
]])[0];
$assert($unknown['title'] === '账单'
&& $unknown['status_label'] === 'provider_unknown'
$assert($unknown['title_key'] === 'billing.purpose.invoice'
&& $unknown['status_key'] === 'billing.status.financial.unknown'
&& $unknown['status_class'] === 'other'
&& $unknown['amount_display'] === '7.25 XTS'
&& $unknown['created_display'] === '时间未记录',
&& $unknown['created_display'] === '',
'Unknown status or currency did not degrade to a safe display.');
$patch = CloudInvoicePresentation::statusPatch([
@ -168,11 +179,11 @@ $patch = CloudInvoicePresentation::statusPatch([
],
]);
$assert($patch['status']['code'] === 'paid'
&& $patch['status']['label'] === '已支付'
&& $patch['status']['copy_key'] === 'billing.status.financial.paid'
&& $patch['status']['class'] === 'running'
&& $patch['payment']['message']
=== '已有待支付订单;可继续原订单或选择其他支付方式。'
&& $patch['fulfillment']['fulfillment_label'] === '待人工核对'
&& $patch['payment']['message_key'] === 'billing.payment.active.pending'
&& $patch['fulfillment']['fulfillment_key']
=== 'billing.status.fulfillment.review'
&& $patch['polling']['task_id'] === '82'
&& $patch['polling']['required'] === false
&& $patch['polling']['job_attempts'] === 2

@ -52,9 +52,14 @@ $assert(($view['created_at'] ?? null) === 2_000_000_000
&& ($view['facts'][2]['timestamp'] ?? null) === 2_000_100_000,
'Invoice presentation did not preserve canonical timestamps for browser-local display.');
$assert(($view['line_items'] ?? null) === [
['label' => '实例套餐续费', 'amount_display' => '$10.00'],
[
'label' => '实例套餐续费',
'label_key' => 'billing.line_items.renewal_plan',
'amount_display' => '$10.00',
],
[
'label' => '<img src=x onerror=alert(1)>自动备份',
'label_key' => 'billing.line_items.backup_renewal',
'amount_display' => '$2.50',
],
], 'Invoice line-item projection changed labels or frozen amounts.');
@ -77,11 +82,10 @@ $resumePayload['active_payment'] = [
];
$resumeView = CloudInvoicePresentation::detail($resumePayload);
$assert(($resumeView['show_payment'] ?? false) === true
&& ($resumeView['payment_title'] ?? null) === '选择支付方式'
&& str_contains(
(string) ($resumeView['active_payment_message'] ?? ''),
'可选择其他支付方式'
)
&& ($resumeView['payment_title_key'] ?? null)
=== 'billing.payment.select_title'
&& ($resumeView['active_payment_key'] ?? null)
=== 'billing.payment.active.review'
&& count($resumeView['payment_methods'] ?? []) === 2,
'Invoice first paint did not allow switching from an unfinished payment.');
@ -90,7 +94,8 @@ $gracePayload['invoice']['status'] = 'overdue';
$gracePayload['invoice']['display_status'] = 'renewal_grace';
$gracePayload['invoice']['payable'] = true;
$graceView = CloudInvoicePresentation::detail($gracePayload);
$assert(($graceView['status_label'] ?? null) === '已到期,宽限期内可续费'
$assert(($graceView['status_key'] ?? null)
=== 'billing.status.financial.renewal_grace'
&& ($graceView['status_class'] ?? null) === 'warning',
'Payable renewal grace was presented as a failed overdue invoice.');
@ -120,14 +125,20 @@ $ipChangeRow = CloudInvoicePresentation::summaries([
$ipChangePayload['invoice'],
])[0];
$assert(($ipChangeView['show_fulfillment'] ?? false) === true
&& ($ipChangeView['title'] ?? null) === '更换公网 IPv4'
&& ($ipChangeView['fulfillment_title'] ?? null) === '公网 IPv4 更换进度'
&& ($ipChangeView['fulfillment_label'] ?? null) === '待人工核对'
&& ($ipChangeView['title_key'] ?? null) === 'billing.purpose.ip_change'
&& ($ipChangeView['fulfillment_title_key'] ?? null)
=== 'billing.fulfillment.title.ip_change'
&& ($ipChangeView['fulfillment_key'] ?? null)
=== 'billing.status.fulfillment.review'
&& ($ipChangeView['fulfillment_class'] ?? null) === 'warning'
&& ($ipChangeView['instance_id'] ?? null) === '41'
&& ($ipChangeRow['show_fulfillment'] ?? false) === true
&& ($ipChangeRow['fulfillment_label'] ?? null) === '待人工核对'
&& ($ipChangeRow['context_display'] ?? null) === '目标实例 vm-audit',
&& ($ipChangeRow['fulfillment_key'] ?? null)
=== 'billing.status.fulfillment.review'
&& ($ipChangeRow['context_segments'][0]['key'] ?? null)
=== 'billing.context.target_instance'
&& ($ipChangeRow['context_segments'][0]['parameters']['name'] ?? null)
=== 'vm-audit',
'IP-change invoice did not preserve its target and review-only task state.');
$detailRuntime = file_get_contents(
@ -149,12 +160,12 @@ $invoiceService = file_get_contents(
$assert(is_string($detailRuntime) && is_string($listRuntime)
&& str_contains($detailRuntime, 'payload.presentation')
&& str_contains($detailRuntime, 'result?.presentation_patch')
&& str_contains($detailRuntime, 'presentation?.status_label')
&& str_contains($detailRuntime, 'presentation?.status_key')
&& str_contains($detailRuntime, 'presentation?.status_class')
&& str_contains($detailRuntime, 'presentation?.fulfillment_label')
&& str_contains($detailRuntime, 'presentation?.fulfillment_key')
&& str_contains($detailRuntime, 'presentation?.polling_required')
&& str_contains($detailRuntime, 'function renderInvoiceDetail(presentation)')
&& str_contains($detailRuntime, "toLocaleString('zh-CN'")
&& str_contains($detailRuntime, 'i18n.date(date)')
&& !str_contains($detailRuntime,
'function renderInvoiceDetail(invoice, presentation)')
&& !str_contains($detailRuntime, 'function invoiceTitle(')
@ -165,18 +176,22 @@ $assert(is_string($detailRuntime) && is_string($listRuntime)
&& !str_contains($detailRuntime, 'function ipChangeStatusInfo(')
&& !str_contains($detailRuntime,
"renewal_grace: ['已到期,宽限期内可续费', 'warning']")
&& str_contains($listRuntime, 'invoice?.status_label')
&& str_contains($listRuntime, 'invoice?.status_key')
&& str_contains($listRuntime, 'invoice?.status_class')
&& str_contains($listRuntime, 'invoice?.fulfillment_label')
&& str_contains($listRuntime, 'invoice?.fulfillment_key')
&& str_contains($listRuntime, 'invoice?.polling_required === true')
&& str_contains($listRuntime, 'invoice?.context_segments')
&& str_contains($listRuntime, "toLocaleString('zh-CN'")
&& str_contains($listRuntime, 'i18n.date(date)')
&& str_contains($listRuntime, 'payload?.balance_display')
&& !str_contains($listRuntime, 'function formatUsd(')
&& !str_contains($listRuntime, 'function invoiceStatusInfo(')
&& !str_contains($listRuntime, 'function fulfillmentStatusInfo(')
&& !str_contains($listRuntime,
"renewal_grace: ['已到期,宽限期内可续费', 'warning']"),
"renewal_grace: ['已到期,宽限期内可续费', 'warning']")
&& !preg_match('/[\\x{4e00}-\\x{9fff}]/u', $detailRuntime)
&& !preg_match('/[\\x{4e00}-\\x{9fff}]/u', $listRuntime)
&& !str_contains($detailRuntime, 'payload?.detail')
&& !str_contains($detailRuntime, 'task.error'),
'Invoice list client must consume the server presentation without rebuilding it.');
$assert(is_string($adminRuntime) && is_string($adminRows)

@ -29,14 +29,14 @@ $catalog = $read('app/Services/Cloud/CloudBillingPresentationCatalog.php');
$adminPresentation = $read('app/Services/Cloud/CloudAdminBillingPresentation.php');
$assert(str_contains($listTemplate, 'value="upgrade"')
&& str_contains($listTemplate, '升级账单')
&& str_contains($listRuntime, 'invoice?.title')
&& str_contains($listTemplate, "billing.purpose.upgrade")
&& str_contains($listRuntime, 'invoice?.title_key')
&& str_contains($catalog, "'upgrade' => '实例升级'"),
'The user invoice list does not identify or refresh upgrade invoices.');
$assert(str_contains($detailRuntime, 'invoiceCanPay(invoice)')
&& str_contains($detailRuntime, 'presentation?.fulfillment_title')
&& str_contains($detailRuntime, 'presentation?.fulfillment_title_key')
&& str_contains($presentation, "if (\$purpose === 'upgrade')")
&& str_contains($presentation, "? '目标周期流量' : '周期流量'")
&& str_contains($presentation, "? 'billing.spec.target_period_traffic'")
&& str_contains($detailTemplate, 'id="invoice-fulfillment-title"'),
'Upgrade invoice detail must show task state without exposing payment controls.');
$assert(str_contains($invoiceService,

Loading…
Cancel
Save