回筐、账单完成

This commit is contained in:
liu
2026-08-14 01:19:47 +08:00
parent e35c951a59
commit bf8ac68391
39 changed files with 1392 additions and 963 deletions
-67
View File
@@ -1,67 +0,0 @@
<?php
namespace App\Exports;
use App\Models\StatementModel;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
/**
* 门店对账单导出
*/
class StatementExport implements FromCollection, WithHeadings, WithMapping, WithStyles
{
public function __construct(private readonly StatementModel $statement)
{
}
public function collection(): Collection
{
return $this->statement->items()->orderBy('id')->get();
}
public function headings(): array
{
return ['品名', '单价', '数量', '重量', '金额', '对账状态', '备注'];
}
public function map($item): array
{
return [
$item->product_name,
(float) $item->price,
(float) $item->quantity,
(float) $item->weight,
(float) $item->amount,
$item->is_reconciled ? '已对账' : '未对账',
$item->store_remark,
];
}
public function styles(Worksheet $sheet): array
{
$sheet->freezePane('A2');
return [
1 => ['font' => ['bold' => true]],
];
}
/**
* PDF 模板视图数据
*
* @return array{statement: StatementModel, storeName: string, items: Collection}
*/
public function viewData(): array
{
return [
'statement' => $this->statement,
'storeName' => $this->statement->store?->name ?? '',
'items' => $this->collection(),
];
}
}