<?php
/**
 * Created by PhpStorm.
 * User: hp
 * Date: 2017/11/22
 * Time: 14:17
 */

namespace App\Http\Controllers\Channel\XChengXu\Transformers;

use Hashids;

class XcxSendOrderTransformer
{
    public function transform($sendOrderItem)
    {
        return [
            'id' => isset($sendOrderItem->id)?$sendOrderItem->id:'',
            'distribution_channel_id' => isset($sendOrderItem->distribution_channel_id)?$sendOrderItem->distribution_channel_id:'',
            'name' => isset($sendOrderItem->name)?$sendOrderItem->name:'',
            'domain' => isset($sendOrderItem->domain)?$sendOrderItem->domain:'',
            'remark' => isset($sendOrderItem->remark)?$sendOrderItem->remark:'',
            'star_num' => isset($sendOrderItem->star_num)?$sendOrderItem->star_num:'',
            'updated_at' => date("Y-m-d H:i:s", strtotime($sendOrderItem->updated_at)),
            'created_at' => date("Y-m-d H:i:s", strtotime($sendOrderItem->created_at)),
            'totalChargeAmount' => isset($sendOrderItem->totalChargeAmount)?$sendOrderItem->totalChargeAmount:'',
            'cost' => isset($sendOrderItem->cost)?$sendOrderItem->cost:'',
            'promotion_type_name' => isset($sendOrderItem->promotion_type_name)?$sendOrderItem->promotion_type_name:'',
            'promotion_url' => isset($sendOrderItem->promotion_url)?$sendOrderItem->promotion_url:'',
            'promotion_type' => isset($sendOrderItem->promotion_type)?$sendOrderItem->promotion_type:'',
            'totalOrderNum' => isset($sendOrderItem->totalOrderNum)?$sendOrderItem->totalOrderNum:'',
            'sucOrderNum' => isset($sendOrderItem->sucOrderNum)?$sendOrderItem->sucOrderNum:'',
            'addUserNum' => isset($sendOrderItem->addUserNum)?$sendOrderItem->addUserNum:'',
            'totalChargeAmount' => isset( $sendOrderItem->totalChargeAmount)? $sendOrderItem->totalChargeAmount:'',
            'pre_send_date' => empty($sendOrderItem->pre_send_date) ? '' : date("Y/m/d", strtotime($sendOrderItem->pre_send_date))
        ];
    }
}