<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "log_order".
 *
 * @property integer $id
 * @property string $name
 * @property integer $order_id
 * @property string $time
 * @property integer $uid
 * @property integer $u_type
 * @property integer $log_type
 */
class LogOrder extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'log_order';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['order_id', 'uid', 'u_type', 'log_type'], 'integer'],
            [['time'], 'safe'],
            [['name'], 'string', 'max' => 20],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'order_id' => 'Order ID',
            'time' => 'Time',
            'uid' => 'Uid',
            'u_type' => 'U Type',
            'log_type' => 'Log Type',
        ];
    }

    /**
     * Des:获取订单日志列表
     * Name: getOrderLog
     * @param $order_id
     * @return array
     * @author 倪宗锋
     */
    public function getOrderLog($order_id)
    {
        $where = ['=', 'order_id',$order_id];
        $select = [
            'name',
            'time',
            'log_type'
        ];
        $getList = self::find()->select($select)
            ->where($where)
            ->asArray(true)
            ->all();
        if (empty($getList)) {
            return [];
        }
        return $getList;
    }
}
