<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "pay_main".
 *
 * @property integer $id
 * @property string $pay_id
 * @property integer $pay_type
 * @property string $amount_money
 * @property string $pay_time
 * @property integer $pay_user
 * @property integer $order_id
 * @property string $create_time
 * @property integer $delete_flag
 */
class PayMain extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'pay_main';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['order_id'], 'required'],
            [['pay_type', 'order_id','pay_user', 'delete_flag'], 'integer'],
            [['amount_money','order_money'], 'number'],
            [['pay_time', 'create_time', 'pay_order_id'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'pay_type' => 'Pay Type',
            'amount_money' => 'Amount Money',
            'pay_time' => 'Pay Time',
            'pay_user' => 'Pay User',
            'order_id' => 'Order ID',
            'delete_flag' => 'Delete Flag',
            'pay_order_id' => 'pay_roder_id',
            'order_money' => 'order_money'
        ];
    }

    /**
     * Des:获取支付信息
     * Name: getPayInfo
     * @param $oder_id
     * @return array
     * @author 倪宗锋
     */
    public function getPayInfo($oder_id)
    {
        $return = $this->find()
            ->from(static::tableName())
            ->where(['=','order_id', $oder_id])
            ->asArray(true)
            ->one();
        return $return;
    }
}
