<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "car_finance_t".
 *
 * @property integer $id
 * @property integer $fix_id
 * @property string $car_no
 * @property string $id_man
 * @property string $engine_no
 * @property double $total_price
 * @property double $real_price
 * @property double $gap_price
 * @property string $gap_reason
 * @property string $pay_type
 * @property string $banks
 * @property string $pay_state
 * @property string $baoanhao
 * @property double $bill_price
 * @property string $gift_no
 * @property string $examine
 * @property integer $business_type
 * @property string $company
 */
class CarFinanceT extends \common\models\Base
{
    public function scenarios()
    {
        return ['create'=>['fix_id','car_no','total_price','real_price','gap_price','pay_type','banks','pay_state','bill_price','examine','business_type','company','baoanhao','id_man','engine_no','gap_reason','gift_no','enter_the_factory_time']];
    }

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'car_finance_t';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['fix_id', 'car_no', 'total_price', 'real_price', 'gap_price', 'pay_type','!order_id', 'banks', 'pay_state', 'bill_price', 'examine', 'business_type','company','id_man','engine_no','gap_reason','enter_the_factory_time'], 'required','on'=>'create'],
            [['id', 'fix_id', 'pay_state', 'banks', 'examine', 'pay_type'], 'integer'],
            [['total_price', 'real_price', 'gap_price', 'bill_price'], 'number'],
            [['enter_the_factory_time'],'safe'],
            [['car_no', 'id_man', 'engine_no', 'gap_reason', 'baoanhao', 'gift_no', 'company'], 'string', 'max' => 200],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'fix_id' => 'Fix ID',
            'car_no' => '车牌号',
            'id_man' => '车主',
            'engine_no' => '发动机号',
            'enter_the_factory_time'=>'进厂日期',
            'total_price' => '应结金额',
            'real_price' => '到账金额',
            'gap_price' => '结算差价',
            'gap_reason' => '差额原因',
            'pay_type' => '支付方式',
            'banks' => '银行',
            'pay_state' => '支付状态',
            'baoanhao' => '报案号',
            'bill_price' => '挂账金额',
            'gift_no' => '礼品券编号',
            'examine' => '审核状态',
            'business_type' => '业务类型',
            'company' => '保险公司',
        ];
    }

    //支付方式
    public function getPayType(){

        switch($this->pay_type){
            case 1:
                return '网银';
            break;
            case 2:
                return '支票';
                break;
            case 3:
                return '刷卡';
                break;
            case 4:
                return '现金';
                break;
            case 5:
                return '微信';
                break;
            case 6:
                return '支付宝';
                break;
            default:
                return '出错了~';
        }
    }

    //支付银行
    public function getPayBank(){

        switch($this->banks){
            case 1:
                return '不需要';
                break;
            case 2:
                return '北京银行';
                break;
            case 3:
                return '农业银行';
                break;
            case 4:
                return '建设银行';
                break;
            case 5:
                return '工商银行';
                break;
            case 6:
                return '浦发银行';
                break;
            case 7:
                return '平安银行';
                break;
            default:
                return '出错了~';
        }
    }

    //支付状态
    public function getPayState(){

        switch($this->pay_state){
            case 1:
                return '已支付已到账';
                break;
            case 2:
                return '已支付未到账';
                break;
            case 3:
                return '挂账';
                break;
            case 4:
                return '已推案未到账';
                break;
            case 5:
                return '未推案未到账';
                break;
            default:
                return '出错了~';
        }
    }

    //审核状态
    public function getExamine(){

        switch($this->examine){
            case 1:
                return '未通过';
                break;
            case 2:
                return '通过';
                break;
            default:
                return '出错了~';
        }
    }

    //业务类型
    public function getBusinessType(){

        switch($this->business_type){
            case 1:
                return '自费板喷';
                break;
            case 2:
                return '自费保养';
                break;
            case 3:
                return '保险理赔';
                break;
            default:
                return '出错了~';
        }
    }
    public function getFixCarT(){
        return $this->hasOne(FixCarT::className(),['id'=>'fix_id']);
    }
}
