50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Exports;
|
|
|
|
use Maatwebsite\Excel\Concerns\FromArray;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
use Maatwebsite\Excel\Concerns\WithTitle;
|
|
|
|
class ThirdPartyWarehouseStorageDetailExport implements FromArray, WithHeadings, WithTitle
|
|
{
|
|
/** @param list<array<string,mixed>> $rows */
|
|
public function __construct(private readonly array $rows)
|
|
{
|
|
}
|
|
|
|
public function title(): string
|
|
{
|
|
return '每日商品仓储费';
|
|
}
|
|
|
|
/** @return array<int,string> */
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'日期', '货主', '商品编码', '商品名称', '供应商', '分类', '单位',
|
|
'上日结余', '当日进出净额', '当日库存结余', '当天仓储费',
|
|
];
|
|
}
|
|
|
|
/** @return array<int,array<int,mixed>> */
|
|
public function array(): array
|
|
{
|
|
return array_map(static fn (array $row): array => [
|
|
$row['date'],
|
|
$row['owner'],
|
|
$row['sku_code'],
|
|
$row['product_name'],
|
|
$row['supplier'],
|
|
$row['category'],
|
|
$row['unit'],
|
|
(float) $row['opening'],
|
|
(float) $row['net_movement'],
|
|
(float) $row['closing'],
|
|
(float) $row['storage_fee'],
|
|
], $this->rows);
|
|
}
|
|
}
|