<?php
/**
 * Created by PhpStorm.
 * User: tandunzhao
 * Date: 2017/12/7
 * Time: 下午8:03
 */

namespace App\Http\Controllers\Manage\Finance\Transformers;


use App\Modules\Channel\Services\ChannelService;

class LiquidationTransformer
{
    public function transform($liquidation){
        return [
            'id'       =>  isset($liquidation->id) ? $liquidation->id : 0,
            'channel_id'       =>  isset($liquidation->distribution_channel_id) ? $liquidation->distribution_channel_id : 0,
            'channel_name'       =>  isset($liquidation->distribution_channel_name) ? $liquidation->distribution_channel_name : "",
            'pay_merchant_source'       =>  isset($liquidation->pay_merchant_source) ? $liquidation->pay_merchant_source : "",
            'pay_merchant_source_name' => ChannelService::getSourceName(isset($liquidation->pay_merchant_source) ? $liquidation->pay_merchant_source : ""),
            'amount'       =>  (float)(isset($liquidation->amount) ? $liquidation->amount : 0),
            'payment_id'       =>  isset($liquidation->payment_id) ? $liquidation->payment_id : 0,
            'date'       =>  isset($liquidation->date) ? ($liquidation->date ? date('Y-m-d H:i:s', strtotime($liquidation->date)) : "") : "",
            'payment_id'       =>  isset($liquidation->payment_id) ? $liquidation->payment_id : 0,
            'remark'       =>  isset($liquidation->remark) ? $liquidation->remark : "",
            'created_time'       =>  isset($liquidation->created_at) ? ($liquidation->created_at ? date('Y-m-d H:i:s', strtotime($liquidation->created_at)) : "") : "",
            'phone'       =>  isset($liquidation->phone) ? $liquidation->phone : "",
            'pay_merchant_id'       =>  isset($liquidation->pay_merchant_id) ? $liquidation->pay_merchant_id : 0,
            'nickname'       =>  isset($liquidation->nickname) ? $liquidation->nickname : "",
            'person_in_charge_name'       =>  isset($liquidation->person_in_charge_name) ? $liquidation->person_in_charge_name : "",
        ];
    }

}