Authored by wangqing

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

@@ -4,7 +4,6 @@ namespace LibModels\Web\Product; @@ -4,7 +4,6 @@ namespace LibModels\Web\Product;
4 use Api\Yohobuy; 4 use Api\Yohobuy;
5 class SearchData extends \LibModels\Wap\Product\SearchData 5 class SearchData extends \LibModels\Wap\Product\SearchData
6 { 6 {
7 - public static $shopsUrl = 'http://101.200.31.165/yohosearch/shops.json';  
8 /** 7 /**
9 * 获取搜索的服务地址 8 * 获取搜索的服务地址
10 * 9 *
@@ -392,17 +392,31 @@ class HelperSearch @@ -392,17 +392,31 @@ class HelperSearch
392 //清空品牌参数 392 //清空品牌参数
393 unset($params['brand']); 393 unset($params['brand']);
394 //设置已选中的品牌 394 //设置已选中的品牌
  395 + $existBrandNum = 0;
  396 + $existName = '';
395 foreach ($brandIds as $key => $val) { 397 foreach ($brandIds as $key => $val) {
396 if (isset($brandAll[$val])) { 398 if (isset($brandAll[$val])) {
397 $brandParam = $brandIds; 399 $brandParam = $brandIds;
398 unset($brandParam[$key]); 400 unset($brandParam[$key]);
399 - $params['brand'] = implode(',', $brandParam); 401 + if ($existBrandNum === 0) {
  402 + $existName .= $brandAll[$val].'、';
  403 + }
  404 + if ($existBrandNum === 1){
  405 + $existName .= substr($brandAll[$val], 0, 3).'...';
  406 + }
  407 + $existBrandNum++;
  408 + }
  409 + if ($existBrandNum > 1) {
  410 + break;
  411 + }
  412 + }
  413 + //设置选中
  414 + if (isset(self::$params['brand']) && !empty(self::$params['brand'])) {
400 self::$selected['brand'] = array( 415 self::$selected['brand'] = array(
401 - 'name' => $brandAll[$val], 416 + 'name' => rtrim($existName, '、'),
402 'href' => self::buildUrl($params) 417 'href' => self::buildUrl($params)
403 ); 418 );
404 } 419 }
405 - }  
406 ksort($brandList); 420 ksort($brandList);
407 //品牌列表排序, 添加品牌索引 421 //品牌列表排序, 添加品牌索引
408 $index_key = array(); 422 $index_key = array();
@@ -432,9 +446,13 @@ class HelperSearch @@ -432,9 +446,13 @@ class HelperSearch
432 * @param array $filter 446 * @param array $filter
433 * @return array 447 * @return array
434 */ 448 */
435 - public static function size($filter) 449 + public static function size($filter, $isAjax = false)
436 { 450 {
437 $params = self::$params; 451 $params = self::$params;
  452 + $paramsValue = array_filter($params);
  453 + if (!$isAjax && empty($paramsValue)) {
  454 + return array();
  455 + }
438 $sizeId = isset($params['size']) && !empty($params['size']) ? $params['size'] : ''; 456 $sizeId = isset($params['size']) && !empty($params['size']) ? $params['size'] : '';
439 if (isset($params['size'])) { 457 if (isset($params['size'])) {
440 unset($params['size']); 458 unset($params['size']);
@@ -694,7 +712,7 @@ class HelperSearch @@ -694,7 +712,7 @@ class HelperSearch
694 $selected = true; 712 $selected = true;
695 } 713 }
696 else { 714 else {
697 - $params['specialoffer'] = 1; 715 + $params['specialoffer'] = 'Y';
698 } 716 }
699 return array( 717 return array(
700 'name' => '打折', 718 'name' => '打折',
@@ -731,12 +749,12 @@ class HelperSearch @@ -731,12 +749,12 @@ class HelperSearch
731 { 749 {
732 $params = self::$params; 750 $params = self::$params;
733 $selected = ''; 751 $selected = '';
734 - if (isset($params['isNew']) && !empty($params['isNew'])) {  
735 - unset($params['isNew']); 752 + if (isset($params['new']) && !empty($params['new'])) {
  753 + unset($params['new']);
736 $selected = true; 754 $selected = true;
737 } 755 }
738 else { 756 else {
739 - $params['isNew'] = 'Y'; 757 + $params['new'] = 'Y';
740 } 758 }
741 return array( 759 return array(
742 'name' => '新品', 760 'name' => '新品',
@@ -843,7 +861,6 @@ class HelperSearch @@ -843,7 +861,6 @@ class HelperSearch
843 ))); 861 )));
844 $active = ''; 862 $active = '';
845 $desc = true; 863 $desc = true;
846 -  
847 } 864 }
848 else if (self::$params['order'] == 'p_d_asc') { 865 else if (self::$params['order'] == 'p_d_asc') {
849 $url = self::buildUrl(array_merge($params, array( 866 $url = self::buildUrl(array_merge($params, array(
@@ -903,23 +920,13 @@ class HelperSearch @@ -903,23 +920,13 @@ class HelperSearch
903 { 920 {
904 $result = array(); 921 $result = array();
905 $data = array(); 922 $data = array();
906 - $is_array_key = array(  
907 - 'brand',  
908 - 'style'  
909 - );  
910 foreach (self::$selected as $key => $val) { 923 foreach (self::$selected as $key => $val) {
911 - if (in_array($key, $is_array_key)) {  
912 - foreach ($val as $k => $v) {  
913 - $data[] = $v;  
914 - }  
915 - }  
916 - else {  
917 $data[] = $val; 924 $data[] = $val;
918 } 925 }
919 - }  
920 if ($data) { 926 if ($data) {
921 $result['conditions'] = $data; 927 $result['conditions'] = $data;
922 } 928 }
  929 +// print_r($result); exit;
923 return $result; 930 return $result;
924 } 931 }
925 932
@@ -1305,7 +1312,8 @@ class HelperSearch @@ -1305,7 +1312,8 @@ class HelperSearch
1305 elseif ($type == 'shop') { 1312 elseif ($type == 'shop') {
1306 return 'http://101.200.31.165/yohosearch/shops.json'; 1313 return 'http://101.200.31.165/yohosearch/shops.json';
1307 } 1314 }
1308 - return 'http://192.168.10.64:8080/yohosearch/search-once.json'; 1315 + return 'http://101.200.31.165/yohosearch/search.json';
  1316 +// return 'http://192.168.10.64:8080/yohosearch/search-once.json';
1309 } 1317 }
1310 } 1318 }
1311 1319
@@ -40,7 +40,7 @@ class SearchModel @@ -40,7 +40,7 @@ class SearchModel
40 'gender' => FILTER_SANITIZE_STRING, 40 'gender' => FILTER_SANITIZE_STRING,
41 'p_d' => FILTER_DEFAULT, 41 'p_d' => FILTER_DEFAULT,
42 'shelve_time' => FILTER_DEFAULT, 42 'shelve_time' => FILTER_DEFAULT,
43 - 'isNew' => FILTER_DEFAULT, 43 + 'new' => FILTER_DEFAULT,
44 'specialoffer' => FILTER_DEFAULT, 44 'specialoffer' => FILTER_DEFAULT,
45 'limited' => FILTER_DEFAULT, 45 'limited' => FILTER_DEFAULT,
46 'order' => FILTER_DEFAULT, 46 'order' => FILTER_DEFAULT,
@@ -175,7 +175,7 @@ class SearchModel @@ -175,7 +175,7 @@ class SearchModel
175 // 组合搜索分类url 175 // 组合搜索分类url
176 $urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['condition']); 176 $urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['condition']);
177 // 组合搜索店铺url 177 // 组合搜索店铺url
178 - if (isset($param['keyword'])) { 178 + if (isset($searchCondition['condition']['query'])) {
179 $param['keyword'] = $searchCondition['condition']['query']; 179 $param['keyword'] = $searchCondition['condition']['query'];
180 $urlList['shop'] = HelperSearch::getShopUrl($param); 180 $urlList['shop'] = HelperSearch::getShopUrl($param);
181 } 181 }
@@ -210,11 +210,32 @@ class SearchModel @@ -210,11 +210,32 @@ class SearchModel
210 /** 210 /**
211 * 查询搜索提示 211 * 查询搜索提示
212 * @param $query 212 * @param $query
  213 + * @return array
213 */ 214 */
214 public static function getSuggest($query) 215 public static function getSuggest($query)
215 { 216 {
216 - $param = array();  
217 - $result = SearchData::getSuggest($param);  
218 - return $result; 217 + $data = '';
  218 + $result = SearchData::getSuggest($query);
  219 + if (isset($result['code']) && $result['code'] == 200 && isset($result['suggest']['items']) && !empty($result['suggest']['items'])) {
  220 + foreach ($result['suggest']['items'] as $v) {
  221 + $data .= '<li><a style="display: block;" href="http://search.yohobuy.com/?query='.$v['item'].'" class="clearfix clear search-item" title="'.$v['item'].'" act="http://search.yohobuy.com/?query='.$v['item'].'"><span class="searchvalue" >'.$v['item'].'</span><span class="valuenum">约'.$v['frequency'].'个商品</span></a></li>';
  222 + }
  223 + }
  224 + echo $data;
  225 + }
  226 +
  227 + /**
  228 + * 获取分类的尺码
  229 + */
  230 + public static function getSortSize($condition)
  231 + {
  232 + $size = array();
  233 + //返回搜索条件
  234 + $condition['needFilter'] = 1;
  235 + $condition['viewNum'] = 1;
  236 + $result = SearchData::searchElasticByCondition($condition);
  237 + if (isset($result['code']) && $result['code'] == 200 && isset($result['data']['filter']) && !empty($result['data']['filter'])) {
  238 + return HelperSearch::size($result['data']['filter'], true);
  239 + }
219 } 240 }
220 } 241 }
@@ -16,12 +16,26 @@ class SearchController extends WebAction @@ -16,12 +16,26 @@ class SearchController extends WebAction
16 $this->_view->display('search', $data); 16 $this->_view->display('search', $data);
17 } 17 }
18 18
19 - public function suggest() 19 + /**
  20 + * 搜索提示
  21 + */
  22 + public function suggestAction()
20 { 23 {
21 $query = rawurldecode($this->get('query')); 24 $query = rawurldecode($this->get('query'));
22 if ($query) { 25 if ($query) {
23 $param['query'] = $query; 26 $param['query'] = $query;
24 - $result = SearchModel::getSuggest($param); 27 + SearchModel::getSuggest($param);
25 } 28 }
26 } 29 }
  30 +
  31 + /**
  32 + * 根据分类id,获取分类尺码
  33 + */
  34 + public function sortSizeAction()
  35 + {
  36 + $condition['msort'] = $this->get('msort');
  37 + $size = SearchModel::getSortSize($condition);
  38 + print_r($size); exit;
  39 + $this->echoJson($size);
  40 + }
27 } 41 }