38 lines
950 B
PHP
38 lines
950 B
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use Maatwebsite\Excel\Concerns\FromArray;
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
|
|
class AgentLottoCodesExport implements FromArray,WithHeadings
|
|
{
|
|
protected $data;
|
|
public function __construct($data)
|
|
{
|
|
$this->data = $data;
|
|
}
|
|
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
['商品名称','商品图片','商品规格', '抽奖码', '状态']
|
|
];
|
|
}
|
|
|
|
public function array():array
|
|
{
|
|
$rows =[];
|
|
$orders = $this->data;
|
|
foreach ($orders as $order)
|
|
{
|
|
$goods = $order['order']?$order['order']['shop_info']:'';
|
|
$rows[] = ['name'=>$goods?$goods['title']:'', 'pic'=>$goods?$goods['pic']:'', 'sku'=>$goods?$goods['sku']['name']:"", 'code'=>$order['code'],
|
|
'status'=>$order['award']?"中奖":''];
|
|
}
|
|
return $rows;
|
|
}
|
|
}
|