<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class BusinessOrderResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        $data = parent::toArray($request);
        $data['confirm_at'] = date('Y-m-d H:i:s', $data['confirm_at'] / 1000);
        $map = ['未发货', '已发货', '部分发货', "已收货", '' => ''];
        $data['shipping_status'] = $map[$data['shipping_status']] ?? '';
        $map = ['帮忙团订单', '自卖团订单', '' => ''];
        $data['is_supplier'] = $map[$data['is_supplier']] ?? '';
        $map = ['未取消', '已取消', '' => ''];
        $data['cancel_status'] = $map[$data['cancel_status']] ?? '';
        $map = ['未发起售后 ', '退款中', '退款成功', '待处理', '拒绝退款', '待(顾客)退货', '待(团长)确认退货', '撤销', '撤销', '(系统)关闭' => ''];
        $data['after_sales_status'] = $map[$data['after_sales_status']] ?? '';
        return $data;
    }
}
