Authored by unknown

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

@@ -35,20 +35,22 @@ class Cache @@ -35,20 +35,22 @@ class Cache
35 */ 35 */
36 public static function set($key, $value, $expire = 3600) 36 public static function set($key, $value, $expire = 3600)
37 { 37 {
38 - try {  
39 - // WINDOWS  
40 - if (DIRECTORY_SEPARATOR === '\\') {  
41 - HoodCache::Memcache('master')->set(self::makeKey($key, 'master'), $value, $expire);  
42 - HoodCache::Memcache('slave')->set(self::makeKey($key, 'slave'), $value, 86400); // 二级缓存1天  
43 - }  
44 - // LINUX  
45 - else {  
46 - HoodCache::Memcached('master')->set(self::makeKey($key, 'master'), $value, $expire);  
47 - HoodCache::Memcached('slave')->set(self::makeKey($key, 'slave'), $value, 86400); // 二级缓存1天  
48 - }  
49 - } catch (Exception $e) {  
50 - // do nothing  
51 - } 38 + if(USE_CACHE) {
  39 + try {
  40 + // WINDOWS
  41 + if (DIRECTORY_SEPARATOR === '\\') {
  42 + HoodCache::Memcache('master')->set(self::makeKey($key, 'master'), $value, $expire);
  43 + HoodCache::Memcache('slave')->set(self::makeKey($key, 'slave'), $value, 86400); // 二级缓存1天
  44 + }
  45 + // LINUX
  46 + else {
  47 + HoodCache::Memcached('master')->set(self::makeKey($key, 'master'), $value, $expire);
  48 + HoodCache::Memcached('slave')->set(self::makeKey($key, 'slave'), $value, 86400); // 二级缓存1天
  49 + }
  50 + } catch (Exception $e) {
  51 + // do nothing
  52 + }
  53 + }
52 } 54 }
53 55
54 /** 56 /**
@@ -61,20 +63,20 @@ class Cache @@ -61,20 +63,20 @@ class Cache
61 public static function get($key, $node = 'master') 63 public static function get($key, $node = 'master')
62 { 64 {
63 $result = array(); 65 $result = array();
64 -  
65 - try {  
66 - // WINDOWS  
67 - if (DIRECTORY_SEPARATOR === '\\') {  
68 - $result = HoodCache::Memcache($node)->get(self::makeKey($key, $node));  
69 - }  
70 - // LINUX  
71 - else {  
72 - $result = HoodCache::Memcached($node)->get(self::makeKey($key, $node));  
73 - }  
74 - } catch (Exception $e) {  
75 - $result = array(); 66 + if(USE_CACHE) {
  67 + try {
  68 + // WINDOWS
  69 + if (DIRECTORY_SEPARATOR === '\\') {
  70 + $result = HoodCache::Memcache($node)->get(self::makeKey($key, $node));
  71 + }
  72 + // LINUX
  73 + else {
  74 + $result = HoodCache::Memcached($node)->get(self::makeKey($key, $node));
  75 + }
  76 + } catch (Exception $e) {
  77 + $result = array();
  78 + }
76 } 79 }
77 -  
78 return $result; 80 return $result;
79 } 81 }
80 82
@@ -86,16 +88,18 @@ class Cache @@ -86,16 +88,18 @@ class Cache
86 */ 88 */
87 public static function delete($key) 89 public static function delete($key)
88 { 90 {
89 - // WINDOWS  
90 - if (DIRECTORY_SEPARATOR === '\\') {  
91 - HoodCache::Memcache('master')->delete(self::makeKey($key, 'master'));  
92 - HoodCache::Memcache('slave')->delete(self::makeKey($key, 'slave'));  
93 - }  
94 - // LINUX  
95 - else {  
96 - HoodCache::Memcached('master')->delete(self::makeKey($key, 'master'));  
97 - HoodCache::Memcached('slave')->delete(self::makeKey($key, 'slave'));  
98 - } 91 + if(USE_CACHE) {
  92 + // WINDOWS
  93 + if (DIRECTORY_SEPARATOR === '\\') {
  94 + HoodCache::Memcache('master')->delete(self::makeKey($key, 'master'));
  95 + HoodCache::Memcache('slave')->delete(self::makeKey($key, 'slave'));
  96 + }
  97 + // LINUX
  98 + else {
  99 + HoodCache::Memcached('master')->delete(self::makeKey($key, 'master'));
  100 + HoodCache::Memcached('slave')->delete(self::makeKey($key, 'slave'));
  101 + }
  102 + }
99 } 103 }
100 104
101 /** 105 /**
@@ -292,7 +292,7 @@ class HelperSearch @@ -292,7 +292,7 @@ class HelperSearch
292 { 292 {
293 $result = array(); 293 $result = array();
294 $options = self::$options; 294 $options = self::$options;
295 - if (!isset($options['controller']) || $options['controller'] == 'Search') { 295 + if (!isset($options['controller']) || $options['controller'] != 'Search') {
296 return $result; 296 return $result;
297 } 297 }
298 $params = self::$params; 298 $params = self::$params;
@@ -242,11 +242,14 @@ class DetailModel @@ -242,11 +242,14 @@ class DetailModel
242 ++ $i; 242 ++ $i;
243 } 243 }
244 // 遍历所有颜色, 构建尺码显示数据 244 // 遍历所有颜色, 构建尺码显示数据
  245 + $i = 1;
245 foreach ($colorList as $value) { 246 foreach ($colorList as $value) {
246 // 各个尺码的颜色,每行显示一个颜色的对应尺码 247 // 各个尺码的颜色,每行显示一个颜色的对应尺码
247 - $sizeGroup[]['size'] = $sizeList[ $value['skcId'] ]; 248 + $sizeGroup[$i]['size'] = $sizeList[ $value['skcId'] ];
248 // 默认颜色 249 // 默认颜色
249 $colorGroup[0]['color'][] = $value; 250 $colorGroup[0]['color'][] = $value;
  251 +
  252 + ++ $i;
250 } 253 }
251 254
252 // 商品图: 多个 255 // 商品图: 多个
@@ -275,6 +278,8 @@ class DetailModel @@ -275,6 +278,8 @@ class DetailModel
275 $notForSale = $baseInfo['attribute'] == 2; 278 $notForSale = $baseInfo['attribute'] == 2;
276 // 显示加入购物车链接 279 // 显示加入购物车链接
277 if (!$soldOut && !$notForSale) { 280 if (!$soldOut && !$notForSale) {
  281 + ksort($colorGroup, SORT_NUMERIC);
  282 +
278 $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html'); 283 $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
279 $result['cartInfo']['productId'] = $productId; 284 $result['cartInfo']['productId'] = $productId;
280 $result['cartInfo']['thumbs'] = $thumbImageList; 285 $result['cartInfo']['thumbs'] = $thumbImageList;
@@ -150,7 +150,7 @@ class SearchModel @@ -150,7 +150,7 @@ class SearchModel
150 // 组合搜索折扣区间url 150 // 组合搜索折扣区间url
151 $urlList['discount'] = HelperSearch::getDiscountUrl($searchCondition['condition']); 151 $urlList['discount'] = HelperSearch::getDiscountUrl($searchCondition['condition']);
152 // 组合搜索最新上架url 152 // 组合搜索最新上架url
153 - $urlList['recent'] = HelperSearch::getRecentShelveUrl($searchCondition['condition']); 153 + //$urlList['recent'] = HelperSearch::getRecentShelveUrl($searchCondition['condition']);
154 //用户浏览记录 154 //用户浏览记录
155 //$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']); 155 //$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']);
156 156