refactor(platform-orders): centralize export ledger url builder

This commit is contained in:
萝卜
2026-03-17 11:00:06 +08:00
parent 9f9d522ee1
commit b00ccd6fbd
3 changed files with 13 additions and 15 deletions

View File

@@ -50,6 +50,15 @@ class PlatformOrder extends Model
|| (data_get($this->meta, 'refund_receipts.0.amount') !== null);
}
public function exportLedgerUrl(array $query = []): string
{
// 安全阀download=1 必须显式存在(用于防止预取/误触发)。
// 且为了测试/口径稳定download 固定在 query 的第一位。
$query = ['download' => 1] + $query;
return '/admin/platform-orders/' . $this->id . '/export-ledger?' . \Illuminate\Support\Arr::query($query);
}
public function refundTotal(): float
{
// 优先读扁平字段 refund_summary.total_amount