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

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


class FinancialStatTransformer
{
    public function transform($financialStat){
        return [
            'channel_id'       =>  isset($financialStat->distribution_channel_id) ? $financialStat->distribution_channel_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),
        ];
    }
}