PlatformOrder: add orderTypeLabel helper

This commit is contained in:
萝卜
2026-03-15 01:40:09 +00:00
parent 2ad5b49096
commit c81c5a1f39
2 changed files with 48 additions and 0 deletions

View File

@@ -10,6 +10,20 @@ class PlatformOrder extends Model
{
use HasFactory;
public function orderTypeLabel(): string
{
$labels = [
'new_purchase' => '新购',
'renewal' => '续费',
'upgrade' => '升级',
'downgrade' => '降级',
];
$type = (string) ($this->order_type ?? '');
return (string) ($labels[$type] ?? $type);
}
public function receiptTotal(): float
{
// 优先读扁平字段 payment_summary.total_amount更稳定、避免遍历 receipts