<?php
/**
 * Created by PhpStorm.
 * User: tandunzhao
 * Date: 2017/11/22
 * Time: 上午10:41
 */

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

class FinancialStatDetailTransformer
{
    public function transform($financialStat){
        return [
//            'channel_id'       =>  isset($financialStat->id) ? $financialStat->id : "",
            'accumulative_amount'       =>  (float)(isset($financialStat->accumulative_withdrawal_amount) ? $financialStat->accumulative_withdrawal_amount : 0),
            'enable_amount'       =>  (float)(isset($financialStat->enable_withdrawal_amount) ? $financialStat->enable_withdrawal_amount : 0),
            'latest_amount'       =>  (float)(isset($financialStat->latest_withdrawal_amount) ? $financialStat->latest_withdrawal_amount : 0),
            'latest_time'       =>  isset($financialStat->latest_withdraw_time) ? ($financialStat->latest_withdraw_time ? date('Y-m-d H:i:s', strtotime($financialStat->latest_withdraw_time)) : "") : "",
            'pending_amount'       =>  (float)(isset($financialStat->withdraw_pending_amount) ? $financialStat->withdraw_pending_amount : 0),
            'rate'       =>  (float)(isset($financialStat->commission_rate) ? ($financialStat->commission_rate) : 0),
            'phone'       =>  isset($financialStat->phone) ? ($financialStat->phone) : "",
            'name'       =>  isset($financialStat->name) ? ($financialStat->name) : "",
            'person_in_charge_name'       =>  isset($financialStat->person_in_charge_name) ? ($financialStat->person_in_charge_name) : "",
            'frozen_time'       =>  isset($financialStat->frozen_time) ? ($financialStat->frozen_time ? date('Y-m-d H:i:s', strtotime($financialStat->frozen_time)) : "") : "",
            'pay_merchant'       =>  isset($financialStat->pay_merchant) ? ($financialStat->pay_merchant) : "",
            'nickname'       =>  isset($financialStat->nickname) ? ($financialStat->nickname) : "",
            'channel_remark'       =>  isset($financialStat->channel_remark) ? ($financialStat->channel_remark) : "",
            'channel_created_time'       =>  isset($financialStat->channel_created_at) ? ($financialStat->channel_created_at ? date('Y-m-d H:i:s', strtotime($financialStat->channel_created_at)) : "") : "",
            'fc_remark'       =>  isset($financialStat->fc_remark) ? ($financialStat->fc_remark) : "",
            'recharge_amount_count'       =>  (float)(isset($financialStat->recharge_amount_count) ? ($financialStat->recharge_amount_count) : 0),
            'tallage'  => (float)isset($financialStat->tallage) ? ($financialStat->tallage) : 0,
        ];
    }
}