<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "order_finance_t".
 *
 * @property integer $id
 * @property integer $order_id
 * @property string $total_price
 * @property integer $banks
 * @property string $serial_number
 * @property string $voucher
 * @property string $transfer_date
 * @property string $proportion
 * @property string $servicecharge
 * @property string $business_retreat
 * @property string $business_proportion
 * @property string $business_routine
 * @property string $force_retreat
 * @property string $force_proportion
 * @property string $force_routine
 * @property string $finance_status
 * @property string $lock_id
 * @property string $created_at
 * @property string $updated_at
 */
class OrderFinanceT extends \common\models\Base
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'order_finance_t';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['order_id', 'banks', 'finance_status', 'lock_id'], 'integer'],
            [['total_price'], 'number'],
            [['created_at', 'updated_at'], 'safe'],
            [['serial_number', 'voucher', 'transfer_date'], 'string', 'max' => 200],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'order_id' => '保单id',
            'total_price' => '转账金额',
            'banks' => '转账银行',
            'serial_number' => '流水号',
            'voucher' => '凭证号',
            'transfer_date' => '转账时间',
            'proportion' => '商业补点比例',
            'servicecharge' => '商业补点手续费',
            'business_retreat' => '商业退保保费',
            'business_proportion' => '商业退保比例',
            'business_routine' => '商业退保手续费',
            'force_retreat' => '交强退保保费',
            'force_proportion' => '交强退保比例',
            'force_routine' => '交强退保手续费',
            'finance_status' => '财务状态',
            'lock_id' => '操作者',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
        ];
    }

    public function getOrder()
    {
        return $this->hasOne(OrderT::className(),['id'=>'order_id']);
    }
    public function getLock()
    {
        return $this->hasOne(UserT::className(),['id'=>'lock_id']);
    }

    public function getStatusName()
    {
        switch ($this->finance_status)
        {
            case 12:
                return '出纳办结';
            break;
            case 13:
                return '财务办结';
            break;
            case 14:
                return '完成';
                break;
            default:
                return '-------';
        }
    }
}