...
|
...
|
@@ -390,91 +390,80 @@ class HelperSearch |
|
|
$params = self::$params;
|
|
|
//url中的品牌ids
|
|
|
$brandIds = isset($params['brand']) && !empty($params['brand']) ? explode(',', $params['brand']) : array();
|
|
|
if (isset($filter['brand']) && !empty($filter['brand'])) {
|
|
|
$brand = $filter['brand'];
|
|
|
//已选中品牌数量
|
|
|
$existBrandNum = 0;
|
|
|
//已选中品牌标签名
|
|
|
$existName = '';
|
|
|
foreach ($brand as $key => $v) {
|
|
|
$selectBrandIds = $brandIds;
|
|
|
//品牌已被选中
|
|
|
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++;
|
|
|
}
|
|
|
//该品牌未被选中
|
|
|
else {
|
|
|
$selectBrandIds[] = $v['id'];
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'brand' => implode(',', $selectBrandIds)
|
|
|
)));
|
|
|
}
|
|
|
$this_brand = array(
|
|
|
'id' => $v['id'],
|
|
|
'href' => $url,
|
|
|
'name' => $v['brand_name'],
|
|
|
'key' => strtolower($v['brand_name']),
|
|
|
'checked' => in_array($v['id'], $brandIds) ? true : false
|
|
|
);
|
|
|
if (is_numeric($v['brand_alif'])) {
|
|
|
$this_brand['index'] = '0-9';
|
|
|
}
|
|
|
else {
|
|
|
$this_brand['index'] = strtolower($v['brand_alif']);
|
|
|
//如果没有品牌返回空
|
|
|
if (!isset($filter['brand']) || empty($filter['brand'])) {
|
|
|
return array();
|
|
|
}
|
|
|
$brand = $filter['brand'];
|
|
|
//已选中品牌数量
|
|
|
$existBrandNum = 0;
|
|
|
//已选中品牌标签名
|
|
|
$existName = '';
|
|
|
foreach ($brand as $key => $v) {
|
|
|
$selectBrandIds = $brandIds;
|
|
|
//品牌已被选中
|
|
|
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'].'、';
|
|
|
}
|
|
|
//默认品牌 TODO
|
|
|
if (count($result['default']) < 10) {
|
|
|
$result['default'][] = $this_brand;
|
|
|
if ($existBrandNum === 1){
|
|
|
$existName .= substr($v['brand_name'], 0, 3).'...';
|
|
|
}
|
|
|
//品牌列表
|
|
|
$brandList[$v['brand_alif']][] = $this_brand;
|
|
|
$brandAll[$v['id']] = $v['brand_name'];
|
|
|
$existBrandNum++;
|
|
|
}
|
|
|
// print_r($brandList); exit;
|
|
|
//清空品牌参数
|
|
|
unset($params['brand']);
|
|
|
//设置选中
|
|
|
if (isset(self::$params['brand']) && !empty(self::$params['brand'])) {
|
|
|
self::$selected['brand'] = array(
|
|
|
'name' => str_replace('、', '', $existName),
|
|
|
'href' => self::buildUrl($params)
|
|
|
);
|
|
|
//该品牌未被选中
|
|
|
else {
|
|
|
$selectBrandIds[] = $v['id'];
|
|
|
$url = self::buildUrl(array_merge($params, array(
|
|
|
'brand' => implode(',', $selectBrandIds)
|
|
|
)));
|
|
|
}
|
|
|
ksort($brandList);
|
|
|
//品牌列表排序, 添加品牌索引 TODO
|
|
|
$index_key = array();
|
|
|
// print_r($brandList); exit;
|
|
|
foreach ($brandList as $key => $val) {
|
|
|
if ($key && !in_array($key, $index_key) && !is_numeric($key)) {
|
|
|
$index['index'] = strtolower(($key));
|
|
|
$index['name'] = $key;
|
|
|
$index_key[] = $index;
|
|
|
}
|
|
|
if ($key && !in_array($key, $index_key) && is_numeric($key) && count($result['brandIndex']) === 1) {
|
|
|
$index['index'] = '0-9';
|
|
|
$index['name'] = '0~9';
|
|
|
$result['brandIndex'][] = $index;
|
|
|
}
|
|
|
if (is_array($val)) {
|
|
|
foreach ($val as $v) {
|
|
|
$result['brandsShow'][] = $v;
|
|
|
}
|
|
|
}
|
|
|
$this_brand = array(
|
|
|
'id' => $v['id'],
|
|
|
'href' => $url,
|
|
|
'name' => $v['brand_name'],
|
|
|
'key' => strtolower($v['brand_name']),
|
|
|
'checked' => in_array($v['id'], $brandIds) ? true : false
|
|
|
);
|
|
|
//默认品牌
|
|
|
if ($key < 10) {
|
|
|
//默认品牌
|
|
|
$result['default'][] = $this_brand;
|
|
|
}
|
|
|
if (is_numeric($v['brand_alif'])) {
|
|
|
$this_brand['index'] = '0-9';
|
|
|
}
|
|
|
$result['brandIndex'] = array_merge($result['brandIndex'], $index_key);
|
|
|
unset($brandList);
|
|
|
else {
|
|
|
$this_brand['index'] = strtolower($v['brand_alif']);
|
|
|
}
|
|
|
//品牌列表
|
|
|
$brandList[$this_brand['index']][] = $this_brand;
|
|
|
$brandAll[$v['id']] = $v['brand_name'];
|
|
|
}
|
|
|
//清空品牌参数
|
|
|
unset($params['brand']);
|
|
|
//设置选中
|
|
|
if (isset(self::$params['brand']) && !empty(self::$params['brand'])) {
|
|
|
self::$selected['brand'] = array(
|
|
|
'name' => rtrim($existName, '、'),
|
|
|
'href' => self::buildUrl($params)
|
|
|
);
|
|
|
}
|
|
|
ksort($brandList);
|
|
|
//品牌列表排序
|
|
|
foreach ($brandList as $key => $val) {
|
|
|
$index['name'] = $key != '0-9' ? strtoupper($key) : '0~9';
|
|
|
$index['index'] = $key;
|
|
|
$result['brandsShow'] = array_merge_recursive($result['brandsShow'], $val);
|
|
|
$result['brandIndex'][] = $index;
|
|
|
}
|
|
|
unset($brandList);
|
|
|
|
|
|
//搜索页已选中,返回空
|
|
|
if (self::checkSearch('brand')) {
|
|
|
return array();
|
...
|
...
|
@@ -577,24 +566,14 @@ class HelperSearch |
|
|
}
|
|
|
$result = array();
|
|
|
//设置已选中价格
|
|
|
if (!empty($priceId) && isset($filter['price'][$priceId])) {
|
|
|
if (!empty($priceId)) {
|
|
|
$price = explode(',' ,$priceId);
|
|
|
$customName = self::$params['price'] == '2000,99999' ? '¥2000以上' : '¥' . (int)$price[0] . '-' . (int)$price[1];
|
|
|
$name = isset($filter['price'][$priceId]) ? $filter['price'][$priceId] : $customName;
|
|
|
self::$selected['price'] = array(
|
|
|
'name' => $filter['price'][$priceId],
|
|
|
'name' => $name,
|
|
|
'href' => self::buildUrl($params)
|
|
|
);
|
|
|
}else{
|
|
|
$price = explode(',', $priceId);
|
|
|
//TODO
|
|
|
if (!$price[0]) {
|
|
|
$price[0] = 0;
|
|
|
}
|
|
|
if (!$price[1]) {
|
|
|
$price[1] = 99999;
|
|
|
}
|
|
|
self::$selected['price'] = array(
|
|
|
'name' => self::$params['price'] == '2000,99999' ? '¥2000以上' : '¥' . (int)$price[0] . '-' . (int)$price[1],
|
|
|
'href' => self::buildurl($params)
|
|
|
);
|
|
|
}
|
|
|
if (self::checkSearch('price')) {
|
|
|
return array();
|
...
|
...
|
@@ -794,9 +773,9 @@ class HelperSearch |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 是否新品 TODO
|
|
|
* 是否新品
|
|
|
*/
|
|
|
public static function isnew()
|
|
|
public static function isNew()
|
|
|
{
|
|
|
$params = self::$params;
|
|
|
$selected = '';
|
...
|
...
|
@@ -978,7 +957,6 @@ class HelperSearch |
|
|
$result['conditions'] = $data;
|
|
|
$result['clearUrl'] = self::current();
|
|
|
}
|
|
|
// print_r($result); exit;
|
|
|
return $result;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -1192,114 +1170,6 @@ class HelperSearch |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 并行调接口url获取(搜索产品数据)
|
|
|
* @param
|
|
|
*/
|
|
|
public static function getProductUrl($condition)
|
|
|
{
|
|
|
// 排序数据映射表
|
|
|
$orderMaps = array(
|
|
|
's_t_desc' => 'shelve_time:desc',
|
|
|
's_t_asc' => 'shelve_time:asc',
|
|
|
's_p_asc' => 'sales_price:asc',
|
|
|
's_p_desc' => 'sales_price:desc',
|
|
|
'p_d_desc' => 'discount:desc',
|
|
|
'p_d_asc' => 'discount:asc',
|
|
|
'skn_desc' => 'product_skn:desc',
|
|
|
'skn_asc' => 'product_skn:asc',
|
|
|
'activities_desc' => 'activities.order_by:desc',
|
|
|
'activities_asc' => 'activities.order_by:asc',
|
|
|
's_n_asc' => 'sales_num:asc',
|
|
|
's_n_desc' => 'sales_num:desc',
|
|
|
'activities_id_desc' => 'activities.activity_id:desc',
|
|
|
'activities_id_asc' => 'activities.activity_id:asc',
|
|
|
);
|
|
|
$param = array();
|
|
|
$param['status'] = 1; // 是否上架,1表示在架,2表示不在
|
|
|
$param['sales'] = 'Y'; // 只搜索销售的产品
|
|
|
$param['stocknumber'] = 1; // 过滤掉已售罄的商品
|
|
|
if (!isset($condition['order'])) {
|
|
|
$param['order'] = $orderMaps['s_t_desc'];
|
|
|
} else {
|
|
|
$param['order'] = $orderMaps[$condition['order']];
|
|
|
}
|
|
|
if (!isset($condition['page'])) {
|
|
|
$param['page'] = 1;
|
|
|
}
|
|
|
|
|
|
if(isset($condition['viewNum'])) {
|
|
|
$param['viewNum'] = $condition['viewNum'];
|
|
|
} else if (!isset($condition['limit'])) {
|
|
|
$param['viewNum'] = 60;
|
|
|
} else {
|
|
|
$param['viewNum'] = $condition['limit'];
|
|
|
unset($condition['limit']);
|
|
|
}
|
|
|
if (!empty($condition)) {
|
|
|
$param += $condition;
|
|
|
}
|
|
|
return Yohobuy::httpBuildQuery(SearchData::getUrl(), $param);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 并行调接口url获取(产品分类)
|
|
|
* @param
|
|
|
*/
|
|
|
|
|
|
public static function getClassesUrl($condition)
|
|
|
{
|
|
|
$condition['sales'] = 'Y'; //在销售商品分类
|
|
|
$condition['status'] = 1; //上架商品分类
|
|
|
$condition['stocknumber'] = 1; //过滤掉已售罄
|
|
|
return Yohobuy::httpBuildQuery(SearchData::getUrl('sort'), $condition);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 并行调接口url获取(获取折扣区间)
|
|
|
* @param
|
|
|
*/
|
|
|
|
|
|
public static function getDiscountUrl($param = array())
|
|
|
{
|
|
|
return Yohobuy::httpBuildQuery(SearchData::getUrl('discount'), $param);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 并行调接口url获取(获取最新上架)
|
|
|
*/
|
|
|
public static function getRecentShelveUrl($param = array())
|
|
|
{
|
|
|
return Yohobuy::httpBuildQuery(SearchData::getUrl('recent'), $param);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 并行调接口url获取(获取品牌数据)
|
|
|
*/
|
|
|
public static function getBrandUrl($customOptions = array())
|
|
|
{
|
|
|
// 构建必传参数
|
|
|
$param = Yohobuy::param();
|
|
|
$param['brand_id'] = $customOptions['brandId'];
|
|
|
$param['uid'] = $customOptions['uid'];
|
|
|
$param['method'] = 'app.brand.getBrandIntro';
|
|
|
$param['client_secret'] = Sign::getSign($param);
|
|
|
|
|
|
return Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取品牌店铺接口地址 TODO
|
|
|
* @param $param
|
|
|
* @return string
|
|
|
*/
|
|
|
public static function getShopUrl($param)
|
|
|
{
|
|
|
return Yohobuy::httpBuildQuery(SearchData::getUrl('shop'), $param);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取品牌首页banner条
|
|
|
*
|
|
|
* @return array 品牌banner条数据
|
...
|
...
|
@@ -1362,7 +1232,7 @@ class HelperSearch |
|
|
//排序方式
|
|
|
$result['sortType'] = array( self::orderDefault(),self::orderTime(),self::orderPrice(),self::orderDiscount());
|
|
|
//特殊:新品、特价、限量
|
|
|
$result['checks'] = array(self::isnew(),self::specialoffer(),self::limited());
|
|
|
$result['checks'] = array(self::isNew(),self::specialoffer(),self::limited());
|
|
|
//每行显示5个产品
|
|
|
$result['fivePerLine'] = true;
|
|
|
//每行显示6个产品
|
...
|
...
|
|