...
|
...
|
@@ -4,6 +4,7 @@ namespace Plugin; |
|
|
|
|
|
use Plugin\Paging;
|
|
|
use LibModels\Web\Product\BrandData;
|
|
|
use LibModels\Web\Product\SearchData;
|
|
|
use Api\Yohobuy;
|
|
|
use Api\Sign;
|
|
|
/**
|
...
|
...
|
@@ -89,6 +90,10 @@ class HelperSearch |
|
|
$result['shopEntry'] = isset($data['shop']) && !empty($data['shop']) ? self::shop($data['shop'], $data['sort']['sort']) : array();
|
|
|
//分页
|
|
|
$result['pager'] = self::pager($result['totalCount'],$options['viewNum']-1);
|
|
|
//浏览记录
|
|
|
if (isset($options['reviewNum']) && !empty($options['reviewNum'])) {
|
|
|
$result['latestWalk'] = $options['reviewNum'];
|
|
|
}
|
|
|
//选中条件
|
|
|
$result['filters']['checkedConditions'] = self::getSelected();
|
|
|
if (isset($options['controller']) && $options['controller'] == 'Search') {
|
...
|
...
|
@@ -134,7 +139,7 @@ class HelperSearch |
|
|
if (!empty($val['default_images'])) {
|
|
|
$val['default_images'] = Images::getImageUrl($val['default_images'],$imgSize[0],$imgSize[1]);
|
|
|
}
|
|
|
$goods[] = array(
|
|
|
$good = array(
|
|
|
'tags' => array(
|
|
|
'isNew' => $isNew,
|
|
|
'isLimit' => $isLimit
|
...
|
...
|
@@ -143,12 +148,16 @@ class HelperSearch |
|
|
'thumb' => $val['default_images'],
|
|
|
'name' => $val['product_name'],
|
|
|
'salePrice' => $val['sales_price'],
|
|
|
'marketPrice' => $val['market_price'],
|
|
|
'isFew' => $isFew,
|
|
|
'skn' => $val['product_skn'],
|
|
|
'showColBtn' => true,
|
|
|
'coled' => true
|
|
|
);
|
|
|
//市场价不等于售价时显示
|
|
|
if ($val['market_price'] != $val['sales_price']) {
|
|
|
$good['marketPrice'] = $val['market_price'];
|
|
|
}
|
|
|
$goods[] = $good;
|
|
|
}
|
|
|
return $goods;
|
|
|
}
|
...
|
...
|
@@ -343,10 +352,6 @@ class HelperSearch |
|
|
array(
|
|
|
'index' => 'all',
|
|
|
'name' => '全部'
|
|
|
),
|
|
|
array(
|
|
|
'index' => '0-9',
|
|
|
'name' => '0 ~ 9'
|
|
|
)
|
|
|
),
|
|
|
'brandsShow' => array()
|
...
|
...
|
@@ -356,17 +361,29 @@ class HelperSearch |
|
|
$brandIds = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
|
|
|
if (isset($filter['brand']) && !empty($filter['brand'])) {
|
|
|
$brand = $filter['brand'];
|
|
|
// print_r($filter); exit;
|
|
|
//已选中品牌数量
|
|
|
$existBrandNum = 0;
|
|
|
//已选中品牌标签名
|
|
|
$existName = '';
|
|
|
foreach ($brand as $key => $v) {
|
|
|
$selectBrandIds = $brandIds;
|
|
|
//品牌id在提交的参数中,构造url参数去除该品牌id
|
|
|
//品牌已被选中
|
|
|
if (in_array($v['id'], $brandIds)) {
|
|
|
$filterKey = array_search($v['id'], $selectBrandIds);
|
|
|
unset($selectBrandIds[$filterKey]);
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'brand' => implode(',', $selectBrandIds)
|
|
|
)));
|
|
|
if ($existBrandNum === 0) {
|
|
|
$existName .= $v['brand_name'].'、';
|
|
|
}
|
|
|
if ($existBrandNum === 1){
|
|
|
$existName .= substr($v['brand_name'], 0, 3).'...';
|
|
|
}
|
|
|
$existBrandNum++;
|
|
|
}
|
|
|
//该品牌url参数中添加该品牌的id
|
|
|
//该品牌未被选中
|
|
|
else {
|
|
|
$selectBrandIds[] = $v['id'];
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
...
|
...
|
@@ -396,25 +413,6 @@ class HelperSearch |
|
|
}
|
|
|
//清空品牌参数
|
|
|
unset($params['brand']);
|
|
|
//设置已选中的品牌
|
|
|
$existBrandNum = 0;
|
|
|
$existName = '';
|
|
|
foreach ($brandIds as $key => $val) {
|
|
|
if (isset($brandAll[$val])) {
|
|
|
$brandParam = $brandIds;
|
|
|
unset($brandParam[$key]);
|
|
|
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(
|
...
|
...
|
@@ -448,6 +446,7 @@ class HelperSearch |
|
|
if (count($result['brandsShow']) < 11) {
|
|
|
$result['hideMore'] = true;
|
|
|
}
|
|
|
// print_r($result); exit;
|
|
|
return $result;
|
|
|
}
|
|
|
/**
|
...
|
...
|
@@ -459,14 +458,14 @@ class HelperSearch |
|
|
{
|
|
|
$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']);
|
|
|
}
|
|
|
$result = array();
|
|
|
if (!$isAjax && empty($paramsValue)) {
|
|
|
return array();
|
|
|
}
|
|
|
if (isset($filter['size']) && !empty($filter['size'])) {
|
|
|
$size = $filter['size'];
|
|
|
foreach ($size as $k=> $v) {
|
...
|
...
|
@@ -485,7 +484,7 @@ class HelperSearch |
|
|
'checked' => isset(self::$params['size']) && self::$params['size'] == $v['size_id'] ? true : false
|
|
|
);
|
|
|
}
|
|
|
if (self::checkSearch('size')) {
|
|
|
if ( self::checkSearch('size')) {
|
|
|
return array();
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -940,8 +939,8 @@ class HelperSearch |
|
|
}
|
|
|
if ($data) {
|
|
|
$result['conditions'] = $data;
|
|
|
$result['clearUrl'] = self::current();
|
|
|
}
|
|
|
$result['clearUrl'] = self::current();
|
|
|
return $result;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1200,7 +1199,7 @@ class HelperSearch |
|
|
if (!empty($condition)) {
|
|
|
$param += $condition;
|
|
|
}
|
|
|
return Yohobuy::httpBuildQuery(self::getUrl(), $param);
|
|
|
return Yohobuy::httpBuildQuery(SearchData::getUrl(), $param);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -1213,7 +1212,7 @@ class HelperSearch |
|
|
$condition['sales'] = 'Y'; //在销售商品分类
|
|
|
$condition['status'] = 1; //上架商品分类
|
|
|
$condition['stocknumber'] = 1; //过滤掉已售罄
|
|
|
return Yohobuy::httpBuildQuery(self::getUrl('sort'), $condition);
|
|
|
return Yohobuy::httpBuildQuery(SearchData::getUrl('sort'), $condition);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -1223,7 +1222,7 @@ class HelperSearch |
|
|
|
|
|
public static function getDiscountUrl($param = array())
|
|
|
{
|
|
|
return Yohobuy::httpBuildQuery(self::getUrl('discount'), $param);
|
|
|
return Yohobuy::httpBuildQuery(SearchData::getUrl('discount'), $param);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -1231,7 +1230,7 @@ class HelperSearch |
|
|
*/
|
|
|
public static function getRecentShelveUrl($param = array())
|
|
|
{
|
|
|
return Yohobuy::httpBuildQuery(self::getUrl('recent'), $param);
|
|
|
return Yohobuy::httpBuildQuery(SearchData::getUrl('recent'), $param);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -1262,15 +1261,6 @@ class HelperSearch |
|
|
|
|
|
return Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 并行调接口url获取(获取用户浏览记录)
|
|
|
*/
|
|
|
// public static function getReviewUrl($param = array())
|
|
|
// {
|
|
|
// return Yohobuy::httpBuildQuery(self::getUrl('review'), $param);
|
|
|
// }
|
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -1280,58 +1270,7 @@ class HelperSearch |
|
|
*/
|
|
|
public static function getShopUrl($param)
|
|
|
{
|
|
|
return Yohobuy::httpBuildQuery(self::getUrl('shop'), $param);
|
|
|
}
|
|
|
/**
|
|
|
* 获取搜索的服务地址
|
|
|
*
|
|
|
* 备注:此处是根据环境来确定使用阿里云内网还是外网的URL
|
|
|
*
|
|
|
* @return string
|
|
|
*/
|
|
|
private static function getUrl($type = 'search')
|
|
|
{
|
|
|
defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'developer');
|
|
|
switch (APPLICATION_ENV) {
|
|
|
case 'release':
|
|
|
if ($type == 'sort') {
|
|
|
return 'http://100.98.132.63/yohosearch/sortgroup.json';
|
|
|
}
|
|
|
elseif ($type == 'discount') {
|
|
|
return 'http://100.98.132.63/yohosearch/discount.json';
|
|
|
}
|
|
|
elseif ($type == 'recent') {
|
|
|
return 'http://100.98.132.63/yohosearch/recent.json';
|
|
|
}
|
|
|
// elseif ($type == 'review') {
|
|
|
//
|
|
|
// }
|
|
|
elseif ($type == 'shop') {
|
|
|
return 'http://100.98.132.63/yohosearch/shops.json';
|
|
|
}
|
|
|
return 'http://100.98.132.63/yohosearch/search.json';
|
|
|
case 'test':
|
|
|
case 'preview':
|
|
|
case 'developer':
|
|
|
default:
|
|
|
if ($type == 'sort') {
|
|
|
return 'http://101.200.31.165/yohosearch/sortgroup.json';
|
|
|
}
|
|
|
elseif ($type == 'discount') {
|
|
|
return 'http://101.200.31.165/yohosearch/discount.json';
|
|
|
}
|
|
|
elseif ($type == 'recent') {
|
|
|
return 'http://101.200.31.165/yohosearch/recent.json';
|
|
|
}
|
|
|
// elseif ($type == 'review') {
|
|
|
//
|
|
|
// }
|
|
|
elseif ($type == 'shop') {
|
|
|
return 'http://101.200.31.165/yohosearch/shops.json';
|
|
|
}
|
|
|
// return 'http://101.200.31.165/yohosearch/search.json';
|
|
|
return 'http://192.168.10.64:8080/yohosearch/search-once.json';
|
|
|
}
|
|
|
return Yohobuy::httpBuildQuery(SearchData::getUrl('shop'), $param);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
|