BrokerPushMatchRecordExcel.php
1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace App\Excel;
use App\Enums\BrokerPushMatchRecordStatusEnum;
use App\Support\ExcelExport;
class BrokerPushMatchRecordExcel extends ExcelExport
{
protected function beforeHandle(): void
{
$this->builder->with(['activity:id,song_name', 'project:id,name', 'user:id,nick_name', 'broker:id,nick_name']);
$this->setHeader(['经纪人ID', '经纪人', '分类', '试唱用户ID', '试唱用户', '试唱用户认证', '歌曲厂牌', '关联歌曲ID', '关联歌曲', '通知内容', '发送时间', '发送状态', '用户行为'], 'A1:M1');
$this->setColumns(['A:E' => 20, 'F:K' => 32, 'L:M' => 20]);
}
protected function setData($item): array
{
return [
$item->broker?->id,
$item->broker?->nick_name,
$item->broker_level,
$item->user?->id,
$item->user?->nick_name,
$item->user_tag,
$item->project?->name,
$item->activity?->id,
$item->activity?->song_name,
$item->content,
$item->send_at,
BrokerPushMatchRecordStatusEnum::tryFrom($item->status)?->label(),
$this->formatReadStatus($item->read_at)
];
}
/**
* @param $status
* @return string
*/
protected function formatReadStatus($status): string
{
return is_null($status) ? '未查看' : '已查看';
}
}