<?php
namespace Business\Common;


class SettingServiceModel extends \Business\AbstractModel{

    public function getCurrentVersion($param){
        $type = (int)$param['type'];
        $settingDAO = \DAO\SettingModel::getInstance();
        $type == 0 ? $version = $settingDAO->getListCache(array('android_version','android_apk')) : $version = $settingDAO->getListCache(array('ios_version'));
        if($version['android_version']) {
            $url = \Our\Common::getStaticFile($version['android_apk'],'apk/');
            return array('version'=>$version['android_version'],'url'=>$url);
        }
        return array('version'=>$version['ios_version']);
    }

    public function getServicePhone(){
        $settingDAO = \DAO\SettingModel::getInstance();
        $phone = $settingDAO->getListCache(array('qm_service_phone'))['qm_service_phone'];
        return array('servicePhone'=>$phone);
    }

    public function getSetting(){
        $settingDAO = \DAO\SettingModel::getInstance();
        $setting = $settingDAO->getListCache(array('unpayed_order_close_minutes','unreceived_order_close_minutes','service'));
        $return = array();
        if($setting['unpayed_order_close_minutes']){
            $return['unpayedOrderColseTime'] = (int)$setting['unpayed_order_close_minutes'];
        }
        if($setting['unreceived_order_close_minutes']){
            $return['unreceivedOrderColseTime'] = (int)$setting['unreceived_order_close_minutes'];
        }
        if($setting['service']){
            $return['service'] = unserialize($setting['service']);
        }
        return $return;
    }
    private static $_instance = null;

    /**
     * 单例模式获取类实例
     *
     */
    public static function getInstance() {
        if (!(self::$_instance instanceof self)) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }
}