Authored by wangqing

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

... ... @@ -4,7 +4,6 @@ namespace LibModels\Web\Product;
use Api\Yohobuy;
class SearchData extends \LibModels\Wap\Product\SearchData
{
public static $shopsUrl = 'http://101.200.31.165/yohosearch/shops.json';
/**
* 获取搜索的服务地址
*
... ...
... ... @@ -392,16 +392,30 @@ class HelperSearch
//清空品牌参数
unset($params['brand']);
//设置已选中的品牌
$existBrandNum = 0;
$existName = '';
foreach ($brandIds as $key => $val) {
if (isset($brandAll[$val])) {
$brandParam = $brandIds;
unset($brandParam[$key]);
$params['brand'] = implode(',', $brandParam);
self::$selected['brand'] = array(
'name' => $brandAll[$val],
'href' => self::buildUrl($params)
);
if ($existBrandNum === 0) {
$existName .= $brandAll[$val].'、';
}
if ($existBrandNum === 1){
$existName .= substr($brandAll[$val], 0, 3).'...';
}
$existBrandNum++;
}
if ($existBrandNum > 1) {
break;
}
}
//设置选中
if (isset(self::$params['brand']) && !empty(self::$params['brand'])) {
self::$selected['brand'] = array(
'name' => rtrim($existName, '、'),
'href' => self::buildUrl($params)
);
}
ksort($brandList);
//品牌列表排序, 添加品牌索引
... ... @@ -432,9 +446,13 @@ class HelperSearch
* @param array $filter
* @return array
*/
public static function size($filter)
public static function size($filter, $isAjax = false)
{
$params = self::$params;
$paramsValue = array_filter($params);
if (!$isAjax && empty($paramsValue)) {
return array();
}
$sizeId = isset($params['size']) && !empty($params['size']) ? $params['size'] : '';
if (isset($params['size'])) {
unset($params['size']);
... ... @@ -694,7 +712,7 @@ class HelperSearch
$selected = true;
}
else {
$params['specialoffer'] = 1;
$params['specialoffer'] = 'Y';
}
return array(
'name' => '打折',
... ... @@ -731,12 +749,12 @@ class HelperSearch
{
$params = self::$params;
$selected = '';
if (isset($params['isNew']) && !empty($params['isNew'])) {
unset($params['isNew']);
if (isset($params['new']) && !empty($params['new'])) {
unset($params['new']);
$selected = true;
}
else {
$params['isNew'] = 'Y';
$params['new'] = 'Y';
}
return array(
'name' => '新品',
... ... @@ -843,7 +861,6 @@ class HelperSearch
)));
$active = '';
$desc = true;
}
else if (self::$params['order'] == 'p_d_asc') {
$url = self::buildUrl(array_merge($params, array(
... ... @@ -903,23 +920,13 @@ class HelperSearch
{
$result = array();
$data = array();
$is_array_key = array(
'brand',
'style'
);
foreach (self::$selected as $key => $val) {
if (in_array($key, $is_array_key)) {
foreach ($val as $k => $v) {
$data[] = $v;
}
}
else {
$data[] = $val;
}
}
if ($data) {
$result['conditions'] = $data;
}
// print_r($result); exit;
return $result;
}
... ... @@ -1305,7 +1312,8 @@ class HelperSearch
elseif ($type == 'shop') {
return 'http://101.200.31.165/yohosearch/shops.json';
}
return 'http://192.168.10.64:8080/yohosearch/search-once.json';
return 'http://101.200.31.165/yohosearch/search.json';
// return 'http://192.168.10.64:8080/yohosearch/search-once.json';
}
}
... ...
... ... @@ -40,7 +40,7 @@ class SearchModel
'gender' => FILTER_SANITIZE_STRING,
'p_d' => FILTER_DEFAULT,
'shelve_time' => FILTER_DEFAULT,
'isNew' => FILTER_DEFAULT,
'new' => FILTER_DEFAULT,
'specialoffer' => FILTER_DEFAULT,
'limited' => FILTER_DEFAULT,
'order' => FILTER_DEFAULT,
... ... @@ -175,7 +175,7 @@ class SearchModel
// 组合搜索分类url
$urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['condition']);
// 组合搜索店铺url
if (isset($param['keyword'])) {
if (isset($searchCondition['condition']['query'])) {
$param['keyword'] = $searchCondition['condition']['query'];
$urlList['shop'] = HelperSearch::getShopUrl($param);
}
... ... @@ -210,11 +210,32 @@ class SearchModel
/**
* 查询搜索提示
* @param $query
* @return array
*/
public static function getSuggest($query)
{
$param = array();
$result = SearchData::getSuggest($param);
return $result;
$data = '';
$result = SearchData::getSuggest($query);
if (isset($result['code']) && $result['code'] == 200 && isset($result['suggest']['items']) && !empty($result['suggest']['items'])) {
foreach ($result['suggest']['items'] as $v) {
$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>';
}
}
echo $data;
}
/**
* 获取分类的尺码
*/
public static function getSortSize($condition)
{
$size = array();
//返回搜索条件
$condition['needFilter'] = 1;
$condition['viewNum'] = 1;
$result = SearchData::searchElasticByCondition($condition);
if (isset($result['code']) && $result['code'] == 200 && isset($result['data']['filter']) && !empty($result['data']['filter'])) {
return HelperSearch::size($result['data']['filter'], true);
}
}
}
\ No newline at end of file
... ...
... ... @@ -16,12 +16,26 @@ class SearchController extends WebAction
$this->_view->display('search', $data);
}
public function suggest()
/**
* 搜索提示
*/
public function suggestAction()
{
$query = rawurldecode($this->get('query'));
if ($query) {
$param['query'] = $query;
$result = SearchModel::getSuggest($param);
SearchModel::getSuggest($param);
}
}
/**
* 根据分类id,获取分类尺码
*/
public function sortSizeAction()
{
$condition['msort'] = $this->get('msort');
$size = SearchModel::getSortSize($condition);
print_r($size); exit;
$this->echoJson($size);
}
}
\ No newline at end of file
... ...