71 lines
1.6 KiB
PHP
71 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Virtual\Exports;
|
|
|
|
use App\Core\AbstractExport;
|
|
use Dipper\Excel\Concerns\WithRows;
|
|
use Dipper\Excel\Concerns\FromQuery;
|
|
use Dipper\Excel\Concerns\WithHeadings;
|
|
use Dipper\Excel\Concerns\WithColumnFormatting;
|
|
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
|
use App\Domains\Virtual\Repositories\OrderCardPartitionRepository;
|
|
|
|
class OrderCardExport extends AbstractExport implements FromQuery, WithHeadings, WithRows, WithColumnFormatting
|
|
{
|
|
public $conditions;
|
|
|
|
public function __construct(array $conditions = [])
|
|
{
|
|
$this->conditions = $conditions;
|
|
parent::__construct();
|
|
}
|
|
|
|
public function query()
|
|
{
|
|
$builder = app(OrderCardPartitionRepository::class)->forceNoReset()->select(['sim', 'counts', 'refunded_at'])
|
|
->withConditions($this->conditions)->orderBy('sim');
|
|
|
|
return $builder;
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
'SIM',
|
|
'数量',
|
|
'退货',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param mixed $row
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function rows($rows)
|
|
{
|
|
$array = [];
|
|
|
|
foreach ($rows as $item) {
|
|
$array[] = [
|
|
$item['sim'],
|
|
$item['counts'],
|
|
$item['refunded_at'] ? '是' : '',
|
|
];
|
|
}
|
|
|
|
return $array;
|
|
}
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
public function columnFormats(): array
|
|
{
|
|
return [
|
|
'A' => NumberFormat::FORMAT_NUMBER,
|
|
'B' => NumberFormat::FORMAT_NUMBER,
|
|
];
|
|
}
|
|
}
|