<?php

namespace App\Admin\Exporters;

use Encore\Admin\Grid\Exporters\ExcelExporter;
use Maatwebsite\Excel\Concerns\WithMapping;

class CouponProfitExport extends ExcelExporter implements WithMapping
{

    protected $headings = ['渠道', '网点名称/编号', '订单号', '平安券编号', '优惠政策', '核销金额', '分润金额', '打款时间'];

    public function __construct()
    {
        $this->fileName = '已打款记录 ' . date('YmdHis') . '.xlsx';
    }

    public function map($info): array
    {
        $data = [
            $info->user->nickname,
            $info->outlet ? $info->outlet->nickname : $info->outletId,
            ' ' . $info->redemptionCode,
            $info->couponName,
            $info->price,
            $info->profit,
            $info->paid_at,
        ];

        return $data;
    }

}
