<?php

namespace App\Http\Controllers\Manage\Finance\Transformers;
/**
 * Created by PhpStorm.
 * User: tandunzhao
 * Date: 2017/11/17
 * Time: 下午4:26
 */

class BillTransformer
{
    public function transform($bill){
        return [
            'channel_id'       =>  isset($bill->distribution_channel_id) ? $bill->distribution_channel_id : "",
            'channel_name'       =>  isset($bill->distribution_channel_name) ? $bill->distribution_channel_name : "",
            'date'       =>  isset($bill->date) ? date('Y-m-d',strtotime($bill->date)) : "",
            'recharge_amount'       =>  (float)(isset($bill->recharge_amount) ? $bill->recharge_amount : 0),
            'settlement_price'   =>  (float)(isset($bill->settlement_price) ? $bill->settlement_price : 0),
            'tallage'   =>  (float)(isset($bill->tallage) ? ($bill->tallage) : 0),
            'rate'   =>  (100 * (float)(isset($bill->rate) ? ($bill->rate) : 0))."%",
        ];
    }
}