2024-11-02 13:26:07 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Exports;
|
|
|
|
|
|
2024-11-02 17:05:46 +08:00
|
|
|
use App\Http\Enum\AfterSaleOrderStatusEnum;
|
2024-11-02 13:26:07 +08:00
|
|
|
use App\Models\DailyReport;
|
|
|
|
|
use App\Models\Shop;
|
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
|
|
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
|
|
|
|
|
class BusinessAfterOrderExport implements FromCollection, ShouldAutoSize
|
|
|
|
|
{
|
|
|
|
|
private $data;
|
|
|
|
|
|
|
|
|
|
public function __construct($orders)
|
|
|
|
|
{
|
|
|
|
|
$this->data = $this->createData($orders);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return \Illuminate\Support\Collection
|
|
|
|
|
*/
|
|
|
|
|
public function collection()
|
|
|
|
|
{
|
|
|
|
|
return new Collection($this->data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function createData($orders)
|
|
|
|
|
{
|
|
|
|
|
$headTitle = [
|
|
|
|
|
'父订单编号',
|
|
|
|
|
'店铺名称',
|
|
|
|
|
'退款金额',
|
|
|
|
|
'用户申请退运费金额',
|
|
|
|
|
'退款原因',
|
|
|
|
|
'描述',
|
|
|
|
|
'图片链接',
|
|
|
|
|
'售后单状态',
|
|
|
|
|
'售后单创建时间',
|
|
|
|
|
];
|
|
|
|
|
$bodyData = [];
|
|
|
|
|
foreach ($orders as $order) {
|
|
|
|
|
$bodyData[] = [
|
|
|
|
|
$order['order_sn'],
|
|
|
|
|
$order['shop']['name'],
|
|
|
|
|
bcdiv($order['refund_amount'],100,2),
|
|
|
|
|
bcdiv($order['refund_shipping_amount'],100,2),
|
2024-11-02 17:05:46 +08:00
|
|
|
$order['reason'],
|
2024-11-02 13:26:07 +08:00
|
|
|
$order['description'],
|
|
|
|
|
implode(",",$order['image_list']),
|
2024-11-02 17:05:46 +08:00
|
|
|
AfterSaleOrderStatusEnum::getData($order['after_sales_status']),
|
2024-11-02 13:26:07 +08:00
|
|
|
$order['after_sale_created_at']
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [$headTitle, $bodyData];
|
|
|
|
|
}
|
|
|
|
|
}
|