<?php
use think\Request;
use think\Cache;
define('NS_VER_B2C', 'NS_VER_B2C');
define('NS_VER_B2C_FX', 'NS_VER_B2C_FX');
if (addon_is_exit('Nsfx')) {
    define('NS_VERSION', NS_VER_B2C_FX);
} else {
    define('NS_VERSION', NS_VER_B2C);
}
require APP_PATH . 'error_message.php';
if (addon_is_exit('NsPintuan')) {
    define('IS_SUPPORT_PINTUAN', 1);
} else {
    define('IS_SUPPORT_PINTUAN', 0);
}
if (addon_is_exit('NsO2o')) {
    define('IS_SUPPORT_O2O', 1);
} else {
    define('IS_SUPPORT_O2O', 0);
}
if (addon_is_exit('NsBargain')) {
    define('IS_SUPPORT_BARGAIN', 1);
} else {
    define('IS_SUPPORT_BARGAIN', 0);
}
define('ORDER_REFUND_STATUS', 11);
define('ORDER_COMPLETE_SUCCESS', 4);
define('ORDER_COMPLETE_SHUTDOWN', 5);
define('ORDER_COMPLETE_REFUND', -2);
define("STYLE_DEFAULT_ADMIN", "admin");
define("STYLE_BLUE_ADMIN", "adminblue");
define("DECRYPT_NIU", 1);
define("DECRYPT_NIUSHOP", 1);
define("DECRYPT_NIUCLOUD", 1);
define("DECRYPT_NIUTEST", 1);

initencrypt();

function initencrypt() {
    define("IS_CHECKED", 1);
    $data['devolution_url']  = '163.org.cn';
    $data['devolution_phone']  = '';
    $data['create_date']  = 1520309486;
    $data['devolution_date']  = 1532523536;
    $data['devolution_expire_date']  = 0;
    $data['devolution_status']  = 1;
    $data['module_mark']  = 'B2C_FLAGSHIP';
    $data['time']  = 'debb9fe217088997f3c868c40f7cfe44';
    define("NIUSHOP_AUTH_VERSION", $data['module_mark']);
    defined('NIUSHOP_DEVOLUTION_URL') or define('NIUSHOP_DEVOLUTION_URL', $data['devolution_url']);
    defined('NIUSHOP_DEVOLUTION_DATE') or define('NIUSHOP_DEVOLUTION_DATE', $data['devolution_date']);
    defined('NIUSHOP_DEVOLUTION_EXPIRE_DATE') or define('NIUSHOP_DEVOLUTION_EXPIRE_DATE', $data['devolution_expire_date']);
    $auth_control = authControl();
    $addon_auth = addons_auth();
    $auth_version = NIUSHOP_AUTH_VERSION;
    $pathinfo = Request::instance()->pathinfo();
    $pathinfo_array = explode('/', $pathinfo);
    Request::instance()->addon('admin');
}

function addons_auth() {
    return ['B2C_STANDARD' => ['nswxtemplatemsg', 'nsweixinpay', 'nsalipay', 'nsunionpay', 'nsdiyview', 'nsalisms', ], 'B2C_ENTERPRISE' => ['nswxtemplatemsg', 'nsweixinpay', 'nsalipay', 'nspresell', 'nspintuan', 'nsdiyview', 'nsanalysis', 'nsunionpay', 'nsalisms', 'nso2o', 'nscombopackage', 'nsbargain'], 'B2C_FX' => ['nswxtemplatemsg', 'nsweixinpay', 'nsalipay', 'nsdiyview', 'nsfx', 'nsunionpay', 'nsalisms', 'nscombopackage'], 'B2C_FLAGSHIP' => ['nswxtemplatemsg', 'nsweixinpay', 'nsalipay', 'nspresell', 'nspintuan', 'nsdiyview', 'nsanalysis', 'nsfx', 'nsunionpay', 'nsalisms', 'nso2o', 'nscombopackage', 'nsbargain']];
}

function authControl() {
    return ['nswxtemplatemsg', 'nsweixinpay', 'nsalipay', 'nspresell', 'nspintuan', 'nsdiyview', 'nsanalysis', 'nsfx', 'nsunionpay', 'nsalisms', 'nso2o', 'nscombopackage', 'nsbargain'];
}
