Authored by 周少峰

Merge branch 'master' into feature/students

@@ -14,36 +14,6 @@ namespace Api; @@ -14,36 +14,6 @@ namespace Api;
14 use Plugin\Cache; 14 use Plugin\Cache;
15 class Yohobuy 15 class Yohobuy
16 { 16 {
17 - /* 正式环境 */  
18 - // php API  
19 -// const API_URL = 'http://api2.open.yohobuy.com/';  
20 -// const API_URL2 = 'http://api.open.yohobuy.com/';  
21 -// const SERVICE_URL = 'http://service.api.yohobuy.com/';  
22 -// const YOHOBUY_URL = 'http://www.yohobuy.com/';  
23 -  
24 - //java API  
25 - // const API_URL = 'http://api.yoho.yohoops.org/';//  
26 - // const API_URL2 = 'http://api.yoho.yohoops.org/';//  
27 - // const SERVICE_URL = 'http://service.yoho.yohoops.org/';  
28 - // const YOHOBUY_URL = 'http://www.yohobuy.com/';  
29 - // const API_OLD = 'http://api2.open.yohobuy.com/';  
30 - // 支付回调地址  
31 - // const SERVICE_NOTIFY = 'http://service.yoho.cn/';  
32 -  
33 - // 测试环境 */  
34 - const API_URL = 'http://testapi.yoho.cn:28078/'; // http://testapi.yoho.cn:28078/ http://devapi.yoho.cn:58078/  
35 - const SERVICE_URL = 'http://testservice.yoho.cn:28077/'; // http://testservice.yoho.cn:28077/ http://devservice.yoho.cn:58077/  
36 - const YOHOBUY_URL = 'http://www.yohobuy.com/';  
37 - const API_OLD = 'http://test2.open.yohobuy.com/';  
38 -// 支付回调地址  
39 - const SERVICE_NOTIFY = 'http://testservice.yoho.cn:28077/';  
40 -  
41 - /* 预览环境 */  
42 -// const API_URL = 'http://preapi.yoho.cn/';  
43 -// const API_URL2 = 'http://preapi.yoho.cn/';  
44 -// const SERVICE_URL = 'http://preservice.yoho.cn/';  
45 -// const YOHOBUY_URL = 'http://www.yohobuy.com/';  
46 -// const API_OLD = 'http://api2.open.yohobuy.com/';  
47 17
48 /** 18 /**
49 * 登录老接口Api配置 19 * 登录老接口Api配置
@@ -64,6 +34,17 @@ class Yohobuy @@ -64,6 +34,17 @@ class Yohobuy
64 'h5' => 'fd4ad5fcfa0de589ef238c0e7331b585', 34 'h5' => 'fd4ad5fcfa0de589ef238c0e7331b585',
65 ); 35 );
66 36
  37 + //分流服务器接口
  38 + public static $interfaceShunt = array(
  39 + 'tencentServers' => array(
  40 + 'api' => array('123.206.1.98', '123.206.2.80'),
  41 + 'service' => array('123.206.1.98', '123.206.2.80')
  42 + ),
  43 + 'awsServers' => array(
  44 + 'api' => 'app-java-168863769.cn-north-1.elb.amazonaws.com.cn',
  45 + 'service' => 'service-yoho-579825100.cn-north-1.elb.amazonaws.com.cn'
  46 + )
  47 + );
67 48
68 /** 49 /**
69 * 取得当前的客户端类型 50 * 取得当前的客户端类型
@@ -167,13 +148,27 @@ class Yohobuy @@ -167,13 +148,27 @@ class Yohobuy
167 */ 148 */
168 public static function get($url, $data = array(), $cache = false, $returnJson = false, $timeout = 5, $userAgent = null, $useGzip = true) 149 public static function get($url, $data = array(), $cache = false, $returnJson = false, $timeout = 5, $userAgent = null, $useGzip = true)
169 { 150 {
  151 + $isApi = false;
  152 + $isService = false;
  153 +
  154 + if (USE_INTER_FACE_SHUNT) {
  155 + if (strpos($url, 'api.')) {
  156 + $isApi = true;
  157 + } else if (strpos($url, 'service.')) {
  158 + $isService = true;
  159 + }
  160 + $url = self::_getUrl($url, $data);
  161 + }
  162 +
170 // 销毁私钥参数 163 // 销毁私钥参数
171 if (isset($data['private_key'])) { 164 if (isset($data['private_key'])) {
172 unset($data['private_key']); 165 unset($data['private_key']);
173 } 166 }
  167 +
174 if (!empty($data)) { 168 if (!empty($data)) {
175 $url = self::httpBuildQuery($url, $data); 169 $url = self::httpBuildQuery($url, $data);
176 } //echo $url; 170 } //echo $url;
  171 +
177 /* 开启缓存的情况 */ 172 /* 开启缓存的情况 */
178 if ($cache && USE_CACHE) { 173 if ($cache && USE_CACHE) {
179 // 先尝试获取一级缓存(master), 有数据则直接返回. 174 // 先尝试获取一级缓存(master), 有数据则直接返回.
@@ -182,17 +177,27 @@ class Yohobuy @@ -182,17 +177,27 @@ class Yohobuy
182 return $result; 177 return $result;
183 } 178 }
184 } 179 }
  180 +
  181 +
185 $ch = curl_init($url); 182 $ch = curl_init($url);
186 curl_setopt($ch, CURLOPT_HEADER, 0); 183 curl_setopt($ch, CURLOPT_HEADER, 0);
187 curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 184 curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
188 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 185 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
189 186
  187 + if ($isApi) {
  188 + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: api.yoho.cn'));
  189 + } else if ($isService) {
  190 + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: service.yoho.cn'));
  191 + }
  192 +
190 if ($useGzip) { 193 if ($useGzip) {
191 curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); 194 curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
192 } 195 }
  196 +
193 if (!empty($userAgent)) { 197 if (!empty($userAgent)) {
194 curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); 198 curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
195 } 199 }
  200 +
196 $result = curl_exec($ch); 201 $result = curl_exec($ch);
197 if (!$returnJson && !empty($result)) { 202 if (!$returnJson && !empty($result)) {
198 $result = json_decode($result, true); 203 $result = json_decode($result, true);
@@ -229,9 +234,27 @@ class Yohobuy @@ -229,9 +234,27 @@ class Yohobuy
229 */ 234 */
230 public static function post($url, $data = array(), $returnJson = false, $timeout = 10, $header = array(), $cookie = array()) 235 public static function post($url, $data = array(), $returnJson = false, $timeout = 10, $header = array(), $cookie = array())
231 { 236 {
232 - $ch = curl_init($url); 237 + $isApi = false;
  238 + $isService = false;
  239 +
  240 + if (USE_INTER_FACE_SHUNT) {
  241 + if (strpos($url, 'api.')) {
  242 + $isApi = true;
  243 + } else if (strpos($url, 'service.')) {
  244 + $isService = true;
  245 + }
  246 + $url = self::_getUrl($url, $data);
  247 + }
233 248
  249 + $ch = curl_init($url);
234 curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 250 curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
  251 +
  252 + if ($isApi) {
  253 + array_push($header, 'Host: api.yoho.cn');
  254 + } else if ($isService) {
  255 + array_push($header, 'Host: service.yoho.cn');
  256 + }
  257 +
235 if (!empty($header)) { 258 if (!empty($header)) {
236 curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 259 curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
237 } else { 260 } else {
@@ -247,6 +270,7 @@ class Yohobuy @@ -247,6 +270,7 @@ class Yohobuy
247 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 YOHOWEB'); 270 curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 YOHOWEB');
248 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 271 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
249 curl_setopt($ch, CURLOPT_POST, true); 272 curl_setopt($ch, CURLOPT_POST, true);
  273 +
250 // 销毁私钥参数 274 // 销毁私钥参数
251 if (isset($data['private_key'])) { 275 if (isset($data['private_key'])) {
252 unset($data['private_key']); 276 unset($data['private_key']);
@@ -530,4 +554,40 @@ class Yohobuy @@ -530,4 +554,40 @@ class Yohobuy
530 } 554 }
531 return $isMobile; 555 return $isMobile;
532 } 556 }
  557 +
  558 + /**
  559 + *根据配置决定请求Java接口的地址
  560 + */
  561 + private static function _getUrl($url, $param)
  562 + {
  563 + if (USE_INTER_FACE_SHUNT === false) {
  564 + return $url;
  565 + }
  566 +
  567 + $uid = 0;
  568 + $mod = 0;
  569 +
  570 + if (isset($param['uid'])) {
  571 + $uid = $param['uid'];
  572 + $mod = $param['uid'] % 1024;
  573 + }
  574 +
  575 + if ($mod > 128 || $uid === 0) {
  576 + $paseUrl = parse_url($url);
  577 + if (strpos($url, 'api.')) {
  578 + $url = 'http://' . self::$interfaceShunt['awsServers']['api'] . $paseUrl['path']. '/';
  579 + } else if (strpos($url, 'service.')) {
  580 + $url = 'http://' . self::$interfaceShunt['awsServers']['service'] . $paseUrl['path']. '/';
  581 + }
  582 + } else {
  583 + $paseUrl = parse_url($url);
  584 + if (strpos($url, 'api.')) {
  585 + $url = 'http://' . array_rand(self::$interfaceShunt['tencentServers']['api']) . $paseUrl['path'] . '/';
  586 + } else if (strpos($url, 'service.')) {
  587 + $url = 'http://' . array_rand(self::$interfaceShunt['tencentServers']['service']) . $paseUrl['path']. '/';
  588 + }
  589 + }
  590 +
  591 + return $url;
  592 + }
533 } 593 }
@@ -70,7 +70,7 @@ class UserData @@ -70,7 +70,7 @@ class UserData
70 $param['uid'] = $uid; 70 $param['uid'] = $uid;
71 $param['client_secret'] = Sign::getSign($param); 71 $param['client_secret'] = Sign::getSign($param);
72 72
73 - return Yohobuy::post(Yohobuy::API_URL, $param); 73 + return Yohobuy::post(API_URL, $param);
74 } 74 }
75 75
76 /** 76 /**
@@ -1825,9 +1825,6 @@ class HelperSearch @@ -1825,9 +1825,6 @@ class HelperSearch
1825 */ 1825 */
1826 public static function pinYin($zh){ 1826 public static function pinYin($zh){
1827 $ret = ""; 1827 $ret = "";
1828 - if(mb_detect_encoding($zh, array('GB2312','GBK','UTF-8'))!='UTF-8'){  
1829 - $zh = '';  
1830 - }  
1831 @$s1 = iconv("UTF-8","gbk//ignore", $zh); 1828 @$s1 = iconv("UTF-8","gbk//ignore", $zh);
1832 @$s2 = iconv("gbk//ignore","UTF-8", $s1); 1829 @$s2 = iconv("gbk//ignore","UTF-8", $s1);
1833 if($s2 == $zh){$zh = $s1;} 1830 if($s2 == $zh){$zh = $s1;}
1 { 1 {
2 "name": "web-yohobuy", 2 "name": "web-yohobuy",
3 - "version": "4.8.11", 3 + "version": "4.8.12",
4 "description": "web yohobuy static", 4 "description": "web yohobuy static",
5 "keywords": [], 5 "keywords": [],
6 "homepage": "", 6 "homepage": "",
@@ -65,7 +65,7 @@ article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, @@ -65,7 +65,7 @@ article, aside, details, figcaption, figure, footer, header, hgroup, main, menu,
65 } 65 }
66 66
67 body { 67 body {
68 - font-family: arial, "Microsoft YaHei"; 68 + font-family: arial, "SimHei";
69 } 69 }
70 70
71 @font-face { 71 @font-face {
@@ -50,7 +50,7 @@ application.template.ext = ".phtml" @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
50 application.assets.path = ROOT_PATH "/assets/web" 50 application.assets.path = ROOT_PATH "/assets/web"
51 51
52 ; 应用的版本号 52 ; 应用的版本号
53 -application.version = "4.8.11" 53 +application.version = "4.8.12"
54 54
55 ; 网站SEO信息 55 ; 网站SEO信息
56 application.seo.title = "YOHO!BUY 有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证" 56 application.seo.title = "YOHO!BUY 有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证"
@@ -50,7 +50,7 @@ application.template.ext = ".phtml" @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
50 application.assets.path = ROOT_PATH "/assets/web" 50 application.assets.path = ROOT_PATH "/assets/web"
51 51
52 ; 应用的版本号 52 ; 应用的版本号
53 -application.version = "4.8.11" 53 +application.version = "4.8.12"
54 54
55 ; 网站SEO信息 55 ; 网站SEO信息
56 application.seo.title = "YOHO!BUY 有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证" 56 application.seo.title = "YOHO!BUY 有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证"
@@ -50,7 +50,7 @@ application.template.ext = ".phtml" @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
50 application.assets.path = ROOT_PATH "/assets/web" 50 application.assets.path = ROOT_PATH "/assets/web"
51 51
52 ; 应用的版本号 52 ; 应用的版本号
53 -application.version = "4.8.11" 53 +application.version = "4.8.12"
54 54
55 ; 网站SEO信息 55 ; 网站SEO信息
56 application.seo.title = "YOHO!BUY 有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证" 56 application.seo.title = "YOHO!BUY 有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证"
@@ -50,7 +50,7 @@ application.template.ext = ".phtml" @@ -50,7 +50,7 @@ application.template.ext = ".phtml"
50 application.assets.path = ROOT_PATH "/assets/web" 50 application.assets.path = ROOT_PATH "/assets/web"
51 51
52 ; 应用的版本号 52 ; 应用的版本号
53 -application.version = "4.8.11" 53 +application.version = "4.8.12"
54 54
55 ; 网站SEO信息 55 ; 网站SEO信息
56 application.seo.title = "YOHO!BUY 有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证" 56 application.seo.title = "YOHO!BUY 有货 | 年轻人潮流购物中心,中国潮流购物风向标,官方授权正品保证"
@@ -11,6 +11,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer'); @@ -11,6 +11,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
11 11
12 define('EXHIBITION_TICKET', 51335912);//展览票skn 12 define('EXHIBITION_TICKET', 51335912);//展览票skn
13 13
  14 +define('USE_INTER_FACE_SHUNT', false);//分流开关
  15 +
14 #test环境 16 #test环境
15 define('API_URL', 'http://testapi.yoho.cn:28078/'); 17 define('API_URL', 'http://testapi.yoho.cn:28078/');
16 define('SERVICE_URL', 'http://testservice.yoho.cn:28077/'); 18 define('SERVICE_URL', 'http://testservice.yoho.cn:28077/');
@@ -12,6 +12,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'production'); @@ -12,6 +12,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'production');
12 12
13 define('EXHIBITION_TICKET', 51335912);//展览票skn 13 define('EXHIBITION_TICKET', 51335912);//展览票skn
14 14
  15 +define('USE_INTER_FACE_SHUNT', false);//分流开关
  16 +
15 define('API_URL', 'http://api.yoho.yohoops.org/'); 17 define('API_URL', 'http://api.yoho.yohoops.org/');
16 define('SERVICE_URL', 'http://service.yoho.yohoops.org/'); 18 define('SERVICE_URL', 'http://service.yoho.yohoops.org/');
17 define('YOHOBUY_URL', 'http://www.yohobuy.com/'); 19 define('YOHOBUY_URL', 'http://www.yohobuy.com/');
@@ -12,6 +12,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'preview'); @@ -12,6 +12,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'preview');
12 12
13 define('EXHIBITION_TICKET', 51335912);//展览票skn 13 define('EXHIBITION_TICKET', 51335912);//展览票skn
14 14
  15 +define('USE_INTER_FACE_SHUNT', false);//分流开关
  16 +
15 define('API_URL', 'http://api.yoho.yohoops.org/'); 17 define('API_URL', 'http://api.yoho.yohoops.org/');
16 define('SERVICE_URL', 'http://service.yoho.yohoops.org/'); 18 define('SERVICE_URL', 'http://service.yoho.yohoops.org/');
17 define('YOHOBUY_URL', 'http://www.yohobuy.com/'); 19 define('YOHOBUY_URL', 'http://www.yohobuy.com/');
@@ -12,6 +12,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'testing'); @@ -12,6 +12,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'testing');
12 12
13 define('EXHIBITION_TICKET', 51335912);//展览票skn 13 define('EXHIBITION_TICKET', 51335912);//展览票skn
14 14
  15 +define('USE_INTER_FACE_SHUNT', false);//分流开关
  16 +
15 define('API_URL', 'http://testapi.yoho.cn:28078/'); 17 define('API_URL', 'http://testapi.yoho.cn:28078/');
16 define('SERVICE_URL', 'http://testservice.yoho.cn:28077/'); 18 define('SERVICE_URL', 'http://testservice.yoho.cn:28077/');
17 define('YOHOBUY_URL', 'http://www.yohobuy.com/'); 19 define('YOHOBUY_URL', 'http://www.yohobuy.com/');
@@ -12,6 +12,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'production'); @@ -12,6 +12,8 @@ defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'production');
12 12
13 define('EXHIBITION_TICKET', 51335912);//展览票skn 13 define('EXHIBITION_TICKET', 51335912);//展览票skn
14 14
  15 +define('USE_INTER_FACE_SHUNT', false);//分流开关
  16 +
15 define('API_URL', 'http://api.yoho.yohoops.org/'); 17 define('API_URL', 'http://api.yoho.yohoops.org/');
16 define('SERVICE_URL', 'http://service.yoho.yohoops.org/'); 18 define('SERVICE_URL', 'http://service.yoho.yohoops.org/');
17 define('YOHOBUY_URL', 'http://www.yohobuy.com/'); 19 define('YOHOBUY_URL', 'http://www.yohobuy.com/');