Authored by 周少峰

Merge branch 'master' into feature/students

... ... @@ -14,36 +14,6 @@ namespace Api;
use Plugin\Cache;
class Yohobuy
{
/* 正式环境 */
// php API
// const API_URL = 'http://api2.open.yohobuy.com/';
// const API_URL2 = 'http://api.open.yohobuy.com/';
// const SERVICE_URL = 'http://service.api.yohobuy.com/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
//java API
// const API_URL = 'http://api.yoho.yohoops.org/';//
// const API_URL2 = 'http://api.yoho.yohoops.org/';//
// const SERVICE_URL = 'http://service.yoho.yohoops.org/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_OLD = 'http://api2.open.yohobuy.com/';
// 支付回调地址
// const SERVICE_NOTIFY = 'http://service.yoho.cn/';
// 测试环境 */
const API_URL = 'http://testapi.yoho.cn:28078/'; // http://testapi.yoho.cn:28078/ http://devapi.yoho.cn:58078/
const SERVICE_URL = 'http://testservice.yoho.cn:28077/'; // http://testservice.yoho.cn:28077/ http://devservice.yoho.cn:58077/
const YOHOBUY_URL = 'http://www.yohobuy.com/';
const API_OLD = 'http://test2.open.yohobuy.com/';
// 支付回调地址
const SERVICE_NOTIFY = 'http://testservice.yoho.cn:28077/';
/* 预览环境 */
// const API_URL = 'http://preapi.yoho.cn/';
// const API_URL2 = 'http://preapi.yoho.cn/';
// const SERVICE_URL = 'http://preservice.yoho.cn/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_OLD = 'http://api2.open.yohobuy.com/';
/**
* 登录老接口Api配置
... ... @@ -64,6 +34,17 @@ class Yohobuy
'h5' => 'fd4ad5fcfa0de589ef238c0e7331b585',
);
//分流服务器接口
public static $interfaceShunt = array(
'tencentServers' => array(
'api' => array('123.206.1.98', '123.206.2.80'),
'service' => array('123.206.1.98', '123.206.2.80')
),
'awsServers' => array(
'api' => 'app-java-168863769.cn-north-1.elb.amazonaws.com.cn',
'service' => 'service-yoho-579825100.cn-north-1.elb.amazonaws.com.cn'
)
);
/**
* 取得当前的客户端类型
... ... @@ -167,13 +148,27 @@ class Yohobuy
*/
public static function get($url, $data = array(), $cache = false, $returnJson = false, $timeout = 5, $userAgent = null, $useGzip = true)
{
$isApi = false;
$isService = false;
if (USE_INTER_FACE_SHUNT) {
if (strpos($url, 'api.')) {
$isApi = true;
} else if (strpos($url, 'service.')) {
$isService = true;
}
$url = self::_getUrl($url, $data);
}
// 销毁私钥参数
if (isset($data['private_key'])) {
unset($data['private_key']);
}
if (!empty($data)) {
$url = self::httpBuildQuery($url, $data);
} //echo $url;
/* 开启缓存的情况 */
if ($cache && USE_CACHE) {
// 先尝试获取一级缓存(master), 有数据则直接返回.
... ... @@ -182,17 +177,27 @@ class Yohobuy
return $result;
}
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if ($isApi) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: api.yoho.cn'));
} else if ($isService) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: service.yoho.cn'));
}
if ($useGzip) {
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
}
if (!empty($userAgent)) {
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
}
$result = curl_exec($ch);
if (!$returnJson && !empty($result)) {
$result = json_decode($result, true);
... ... @@ -229,9 +234,27 @@ class Yohobuy
*/
public static function post($url, $data = array(), $returnJson = false, $timeout = 10, $header = array(), $cookie = array())
{
$ch = curl_init($url);
$isApi = false;
$isService = false;
if (USE_INTER_FACE_SHUNT) {
if (strpos($url, 'api.')) {
$isApi = true;
} else if (strpos($url, 'service.')) {
$isService = true;
}
$url = self::_getUrl($url, $data);
}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
if ($isApi) {
array_push($header, 'Host: api.yoho.cn');
} else if ($isService) {
array_push($header, 'Host: service.yoho.cn');
}
if (!empty($header)) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
} else {
... ... @@ -247,6 +270,7 @@ class Yohobuy
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 YOHOWEB');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
// 销毁私钥参数
if (isset($data['private_key'])) {
unset($data['private_key']);
... ... @@ -530,4 +554,40 @@ class Yohobuy
}
return $isMobile;
}
/**
*根据配置决定请求Java接口的地址
*/
private static function _getUrl($url, $param)
{
if (USE_INTER_FACE_SHUNT === false) {
return $url;
}
$uid = 0;
$mod = 0;
if (isset($param['uid'])) {
$uid = $param['uid'];
$mod = $param['uid'] % 1024;
}
if ($mod > 128 || $uid === 0) {
$paseUrl = parse_url($url);
if (strpos($url, 'api.')) {
$url = 'http://' . self::$interfaceShunt['awsServers']['api'] . $paseUrl['path']. '/';
} else if (strpos($url, 'service.')) {
$url = 'http://' . self::$interfaceShunt['awsServers']['service'] . $paseUrl['path']. '/';
}
} else {
$paseUrl = parse_url($url);
if (strpos($url, 'api.')) {
$url = 'http://' . array_rand(self::$interfaceShunt['tencentServers']['api']) . $paseUrl['path'] . '/';
} else if (strpos($url, 'service.')) {
$url = 'http://' . array_rand(self::$interfaceShunt['tencentServers']['service']) . $paseUrl['path']. '/';
}
}
return $url;
}
}
... ...
... ... @@ -70,7 +70,7 @@ class UserData
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
return Yohobuy::post(API_URL, $param);
}
/**
... ...
... ... @@ -1825,9 +1825,6 @@ class HelperSearch
*/
public static function pinYin($zh){
$ret = "";
if(mb_detect_encoding($zh, array('GB2312','GBK','UTF-8'))!='UTF-8'){
$zh = '';
}
@$s1 = iconv("UTF-8","gbk//ignore", $zh);
@$s2 = iconv("gbk//ignore","UTF-8", $s1);
if($s2 == $zh){$zh = $s1;}
... ...
{
"name": "web-yohobuy",
"version": "4.8.11",
"version": "4.8.12",
"description": "web yohobuy static",
"keywords": [],
"homepage": "",
... ...
... ... @@ -65,7 +65,7 @@ article, aside, details, figcaption, figure, footer, header, hgroup, main, menu,
}
body {
font-family: arial, "Microsoft YaHei";
font-family: arial, "SimHei";
}
@font-face {
... ...
... ... @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
application.assets.path = ROOT_PATH "/assets/web"
; 应用的版本号
application.version = "4.8.11"
application.version = "4.8.12"
; 网站SEO信息
application.seo.title = "YOHO!BUY 有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证"
... ...
... ... @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
application.assets.path = ROOT_PATH "/assets/web"
; 应用的版本号
application.version = "4.8.11"
application.version = "4.8.12"
; 网站SEO信息
application.seo.title = "YOHO!BUY 有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证"
... ...
... ... @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
application.assets.path = ROOT_PATH "/assets/web"
; 应用的版本号
application.version = "4.8.11"
application.version = "4.8.12"
; 网站SEO信息
application.seo.title = "YOHO!BUY 有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证"
... ...
... ... @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
application.assets.path = ROOT_PATH "/assets/web"
; 应用的版本号
application.version = "4.8.11"
application.version = "4.8.12"
; 网站SEO信息
application.seo.title = "YOHO!BUY 有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证"
... ...
... ... @@ -11,6 +11,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
define('EXHIBITION_TICKET', 51335912);//展览票skn
define('USE_INTER_FACE_SHUNT', false);//分流开关
#test环境
define('API_URL', 'http://testapi.yoho.cn:28078/');
define('SERVICE_URL', 'http://testservice.yoho.cn:28077/');
... ...
... ... @@ -12,6 +12,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'production');
define('EXHIBITION_TICKET', 51335912);//展览票skn
define('USE_INTER_FACE_SHUNT', false);//分流开关
define('API_URL', 'http://api.yoho.yohoops.org/');
define('SERVICE_URL', 'http://service.yoho.yohoops.org/');
define('YOHOBUY_URL', 'http://www.yohobuy.com/');
... ...
... ... @@ -12,6 +12,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'preview');
define('EXHIBITION_TICKET', 51335912);//展览票skn
define('USE_INTER_FACE_SHUNT', false);//分流开关
define('API_URL', 'http://api.yoho.yohoops.org/');
define('SERVICE_URL', 'http://service.yoho.yohoops.org/');
define('YOHOBUY_URL', 'http://www.yohobuy.com/');
... ...
... ... @@ -12,6 +12,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'testing');
define('EXHIBITION_TICKET', 51335912);//展览票skn
define('USE_INTER_FACE_SHUNT', false);//分流开关
define('API_URL', 'http://testapi.yoho.cn:28078/');
define('SERVICE_URL', 'http://testservice.yoho.cn:28077/');
define('YOHOBUY_URL', 'http://www.yohobuy.com/');
... ...
... ... @@ -12,6 +12,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'production');
define('EXHIBITION_TICKET', 51335912);//展览票skn
define('USE_INTER_FACE_SHUNT', false);//分流开关
define('API_URL', 'http://api.yoho.yohoops.org/');
define('SERVICE_URL', 'http://service.yoho.yohoops.org/');
define('YOHOBUY_URL', 'http://www.yohobuy.com/');
... ...