SystemConfig.php 1.26 KB
<?php

namespace common\models;

use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;

/**
 * 系统配置
 * This is the model class for table "{{%system_config}}".
 */
class SystemConfig extends ActiveRecord
{
    const APPEAL_NOTICE_MEMBERS     = 'apeal_notice_members';
    const DISPATCH_CUSTOMER_SERVICE = 'dispatch_customer_service';

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

    /**
     * @return array
     */
    public function behaviors()
    {
        return [
            'time' => [
                'class' => TimestampBehavior::className(),
                'createdAtAttribute' => 'created_at',
                'updatedAtAttribute' => 'updated_at',
            ]
        ];
    }

    /**
     * 获取质保单指定客服人员信息
     * @return array|mixed
     */
    public static function getAppealServiceMembers()
    {
        $configRow = self::findOne(['config_key' => self::APPEAL_NOTICE_MEMBERS]);
        if ($configRow && isset($configRow->values)) {
            $memberConfig = $configRow->values;
            $members = json_decode($memberConfig, true);
            if ($members) {
                return $members;
            }
        }
        return [];
    }
}