<?php namespace Vip\Src;

use Dever;
use Buy\Src\Base as P;

class Base extends P
{
    # 获取基本配置
    public function config()
    {
        $config = Dever::db('main/config')->one();

        $config['buy'] = $this->url('pay', array(), 'vip');
        $config['login'] = 'location.href=\'' . Dever::url('request.auth?account='.$this->account.'&source='.$this->source.'&refer=' . urlencode($config['buy']), 'oauth') . '\'';

        $vip = Dever::db('vip/config')->one(array('cate_id' => $this->cate));

        $config['title'] = $vip['name'];
        $config['logo'] = $vip['logo'];
        $config['code'] = $vip['code'];
        $config['pic1'] = $vip['pic1'];
        $config['pic2'] = $vip['pic2'];
        $config['pic3'] = $vip['pic3'];
        $config['pic4'] = $vip['pic4'];

        return $config;
    }

    protected function createOrder($prefix = 'HY')
    {
        $order = Dever::order($prefix);

        $info = Dever::db('vip/order')->one(array('order_id' => $order));

        if ($info) {
            return $this->createOrder($prefix);
        }

        return $order;
    }
}