Toggle navigation
Toggle navigation
This project
Loading...
Sign in
wangshusheng
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to dashboard
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
毕凯
9 years ago
Commit
bc9bde820fb3725c7daefb30001a439050ad088e
2 parents
67ef9561
35ccdc34
Merge branch 'develop' of
http://git.dev.yoho.cn/web/yohobuy
into develop
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
368 additions
and
250 deletions
library/LibModels/Web/Product/SearchData.php
library/Plugin/HelperSearch.php
yohobuy/www.yohobuy.com/application/models/Product/Search.php
yohobuy/www.yohobuy.com/application/modules/Product/controllers/Index.php
yohobuy/www.yohobuy.com/application/modules/Product/controllers/List.php
yohobuy/www.yohobuy.com/application/modules/Product/controllers/Search.php
library/LibModels/Web/Product/SearchData.php
View file @
bc9bde8
...
...
@@ -4,7 +4,7 @@ namespace LibModels\Web\Product;
use
Api\Yohobuy
;
class
SearchData
extends
\LibModels\Wap\Product\SearchData
{
public
static
$shops
_u
rl
=
'http://101.200.31.165/yohosearch/shops.json'
;
public
static
$shops
U
rl
=
'http://101.200.31.165/yohosearch/shops.json'
;
/**
* 获取搜索的服务地址
*
...
...
@@ -136,7 +136,7 @@ class SearchData extends \LibModels\Wap\Product\SearchData
*/
public
static
function
getShop
(
array
$params
)
{
return
Yohobuy
::
get
(
self
::
$shops
_u
rl
,
$params
);
return
Yohobuy
::
get
(
self
::
$shops
U
rl
,
$params
);
}
/**
...
...
library/Plugin/HelperSearch.php
View file @
bc9bde8
...
...
@@ -3,6 +3,7 @@
namespace
Plugin
;
use
Plugin\Paging
;
use
LibModels\Web\Product\BrandData
;
use
Api\Yohobuy
;
/**
* 搜索辅助类
*/
...
...
@@ -62,13 +63,13 @@ class HelperSearch
unset
(
self
::
$params
[
'page'
]);
unset
(
self
::
$params
[
'/sale'
]);
unset
(
self
::
$params
[
'sale'
]);
$filter
=
$data
[
'
data
'
][
'filter'
];
$filter
=
$data
[
'
product
'
][
'filter'
];
//产品列表
$result
[
'goods'
]
=
self
::
getProductList
(
$data
[
'
data
'
][
'product_list'
],
$options
[
'imgSize'
]);
$result
[
'goods'
]
=
self
::
getProductList
(
$data
[
'
product
'
][
'product_list'
],
$options
[
'imgSize'
]);
//总页数
$result
[
'page_total'
]
=
$data
[
'
data
'
][
'page_total'
];
$result
[
'page_total'
]
=
$data
[
'
product
'
][
'page_total'
];
//当前页
$result
[
'page'
]
=
$data
[
'
data
'
][
'page'
];
$result
[
'page'
]
=
$data
[
'
product
'
][
'page'
];
self
::
$page
=
$result
[
'page'
];
//清除选中
$result
[
'filters'
][
'checkedConditions'
][
'clearUrl'
]
=
self
::
current
();
...
...
@@ -98,25 +99,33 @@ class HelperSearch
//可选每页显示数量
$result
[
'opts'
][
'pageCounts'
]
=
self
::
viewNum
();
$result
[
'opts'
][
'curPage'
]
=
self
::
$page
;
$result
[
'opts'
][
'pageCount'
]
=
$data
[
'data'
][
'page_total'
];
$result
[
'opts'
][
'nextHref'
]
=
(
$next
=
self
::
next
(
$data
[
'data'
][
'page_total'
],
$data
[
'data'
][
'filter'
]))
?
$next
[
'href'
]
:
''
;
$result
[
'hasNextPage'
]
=
self
::
next
(
$data
[
'data'
][
'page_total'
]);
$result
[
'opts'
][
'pageCount'
]
=
$data
[
'product'
][
'page_total'
];
$result
[
'opts'
][
'nextHref'
]
=
(
$next
=
self
::
next
(
$data
[
'product'
][
'page_total'
],
$data
[
'product'
][
'filter'
]))
?
$next
[
'href'
]
:
''
;
$result
[
'hasNextPage'
]
=
self
::
next
(
$data
[
'product'
][
'page_total'
]);
//分类条件
$result
[
'filters'
][
'sort'
]
=
isset
(
$
filter
[
'group_sort'
])
?
self
::
searchSort
(
$filter
[
'group_
sort'
])
:
array
();
$result
[
'filters'
][
'sort'
]
=
isset
(
$
data
[
'sort'
])
?
self
::
searchSort
(
$data
[
'sort'
][
'
sort'
])
:
array
();
//左侧分类分类
$result
[
'leftContent'
][][
'allSort'
]
=
isset
(
$
filter
[
'group_sort'
])
?
self
::
groupSort
(
$filter
[
'group_
sort'
])
:
array
();
$result
[
'leftContent'
][][
'allSort'
]
=
isset
(
$
data
[
'sort'
])
?
self
::
groupSort
(
$data
[
'sort'
][
'
sort'
])
:
array
();
//一周新品上架
$result
[
'leftContent'
][][
'newSales'
]
=
isset
(
$
filter
[
'recent'
])
?
self
::
recentShelve
(
$filter
[
'recent'
])
:
array
();
$result
[
'leftContent'
][][
'newSales'
]
=
isset
(
$
data
[
'recent'
])
?
self
::
recentShelve
(
$data
[
'recent'
]
[
'recent'
])
:
array
();
//全部折扣
$result
[
'leftContent'
][][
'allDiscount'
]
=
isset
(
$
filter
[
'discount'
])
?
self
::
getDiscount
(
$filter
[
'discount'
])
:
array
();
$result
[
'leftContent'
][][
'allDiscount'
]
=
isset
(
$
data
[
'discount'
])
?
self
::
getDiscount
(
$data
[
'discount'
]
[
'discount'
])
:
array
();
//总记录数
$result
[
'totalCount'
]
=
$data
[
'data'
][
'total'
];
$result
[
'totalCount'
]
=
$data
[
'product'
][
'total'
];
//品牌店铺信息
$result
[
'shopEntry'
]
=
isset
(
$data
[
'shop'
])
&&
!
empty
(
$data
[
'shop'
])
?
self
::
shop
(
$data
[
'shop'
],
$data
[
'sort'
][
'sort'
])
:
array
();
//分页
$result
[
'pager'
]
=
self
::
pager
(
$result
[
'totalCount'
],
$options
[
'viewNum'
]);
//选中条件
$result
[
'filters'
][
'checkedConditions'
][
'conditions'
]
=
self
::
getSelected
();
if
(
self
::
getSelected
())
{
$result
[
'filters'
][
'checkedConditions'
][
'conditions'
]
=
self
::
getSelected
();
}
//没有选中
else
{
$result
[
'filters'
][
'checkedConditions'
]
=
array
();
}
if
(
isset
(
$options
[
'controller'
])
&&
$options
[
'controller'
]
==
'Search'
)
{
self
::
setSearchNav
(
$data
[
'
data
'
][
'total'
]);
self
::
setSearchNav
(
$data
[
'
product
'
][
'total'
]);
}
$result
[
'pathNav'
]
=
self
::
$listnav
;
return
$result
;
...
...
@@ -128,7 +137,8 @@ class HelperSearch
* @author sefon 2015-12-21 17:24:04
* @return array
*/
public
static
function
getProductList
(
$product
,
$imgSize
){
public
static
function
getProductList
(
$product
,
$imgSize
)
{
$goods
=
array
();
foreach
(
$product
as
$key
=>
$val
){
//NEW
...
...
@@ -171,7 +181,8 @@ class HelperSearch
* @param $filter
* @return array
*/
public
static
function
standard
(
$filter
)
{
public
static
function
standard
(
$filter
)
{
$params
=
self
::
$params
;
$result
=
array
();
foreach
(
$filter
as
$key
=>
$val
)
{
...
...
@@ -199,7 +210,7 @@ class HelperSearch
'href'
=>
self
::
buildUrl
(
array_merge
(
$params
,
array
(
'parameter_'
.
$val
[
'standard_id'
]
=>
$pval
[
'standard_id'
]
)))
,
'
select
ed'
=>
isset
(
self
::
$params
[
'parameter_'
.
$val
[
'standard_id'
]])
&&
self
::
$params
[
'parameter_'
.
$val
[
'standard_id'
]]
==
$pval
[
'standard_id'
]
?
true
:
false
'
check
ed'
=>
isset
(
self
::
$params
[
'parameter_'
.
$val
[
'standard_id'
]])
&&
self
::
$params
[
'parameter_'
.
$val
[
'standard_id'
]]
==
$pval
[
'standard_id'
]
?
true
:
false
);
}
if
(
!
empty
(
$sub
)
&&
count
(
$sub
)
>
1
)
{
...
...
@@ -216,7 +227,8 @@ class HelperSearch
* 性别
* @return array
*/
public
static
function
gender
(
$filter
)
{
public
static
function
gender
(
$filter
)
{
if
(
empty
(
$filter
)
||
!
isset
(
$filter
[
'gender'
])
||
empty
(
$filter
[
'gender'
]))
{
return
array
();
}
...
...
@@ -241,8 +253,9 @@ class HelperSearch
$result
[]
=
array
(
'name'
=>
$val
,
'href'
=>
self
::
buildUrl
(
array_merge
(
$params
,
array
(
'gender'
=>
$key
'gender'
=>
$key
,
)))
,
'checked'
=>
isset
(
self
::
$params
[
'gender'
])
&&
self
::
$params
[
'gender'
]
==
$key
?
true
:
false
);
}
return
$result
;
...
...
@@ -342,7 +355,8 @@ class HelperSearch
* @param array $filter
* @return array
*/
public
static
function
brand
(
$filter
)
{
public
static
function
brand
(
$filter
)
{
$options
=
self
::
$options
;
//品牌列表返回空
if
(
isset
(
$options
[
'brandName'
]))
{
...
...
@@ -388,8 +402,8 @@ class HelperSearch
'id'
=>
$v
[
'id'
],
'href'
=>
$url
,
'name'
=>
$v
[
'brand_name'
],
'key'
=>
$v
[
'brand_name'
],
'active'
=>
in_array
(
$v
[
'id'
],
$brandIds
)
?
true
:
false
'key'
=>
strtolower
(
$v
[
'brand_name'
]),
'checked'
=>
in_array
(
$v
[
'id'
],
$brandIds
)
?
true
:
false
);
if
(
is_numeric
(
$v
[
'brand_alif'
]))
{
$this_brand
[
'index'
]
=
'0-9'
;
...
...
@@ -421,7 +435,7 @@ class HelperSearch
//品牌列表排序, 添加品牌索引
$index_key
=
array
();
foreach
(
$brandList
as
$key
=>
$val
)
{
if
(
$key
&&
!
in_array
(
$key
,
$index_key
))
{
if
(
$key
&&
!
in_array
(
$key
,
$index_key
)
&&
!
is_numeric
(
$key
)
)
{
$index
[
'index'
]
=
strtolower
((
$key
));
$index
[
'name'
]
=
$key
;
$result
[
'brandIndex'
][]
=
$index
;
...
...
@@ -446,7 +460,8 @@ class HelperSearch
* @param array $filter
* @return array
*/
public
static
function
size
(
$filter
)
{
public
static
function
size
(
$filter
)
{
$params
=
self
::
$params
;
$sizeId
=
isset
(
$params
[
'size'
])
&&
!
empty
(
$params
[
'size'
])
?
$params
[
'size'
]
:
''
;
if
(
isset
(
$params
[
'size'
]))
{
...
...
@@ -483,7 +498,8 @@ class HelperSearch
* @param array $filter
* @return array
*/
public
static
function
color
(
$filter
)
{
public
static
function
color
(
$filter
)
{
$params
=
self
::
$params
;
$colorId
=
isset
(
$params
[
'color'
])
&&
!
empty
(
self
::
$params
[
'color'
])
?
self
::
$params
[
'color'
]
:
''
;
if
(
isset
(
$params
[
'color'
]))
{
...
...
@@ -519,7 +535,8 @@ class HelperSearch
* @param array
$filter
* @return array
*/
public static function price(
$filter
) {
public static function price(
$filter
)
{
$params
= self::
$params
;
$priceId
= isset(
$params['price']
) && !empty(self::
$params['price']
) ? self::
$params['price']
: '';
if (isset(
$params['price']
)) {
...
...
@@ -561,7 +578,8 @@ class HelperSearch
/**
* 获取自定义价格要提交的地址
*/
public static function customPrice(
$filter
) {
public static function customPrice(
$filter
)
{
$params
= self::
$params
;
$result
= array(
'min' => '',
...
...
@@ -584,7 +602,8 @@ class HelperSearch
* @param array
$filter
* @return array
*/
public static function style(
$filter
) {
public static function style(
$filter
)
{
$params
= self::
$params
;
$styleIds
= isset(
$params['style']
) && !empty(
$params['style']
) ? explode(',',
$params['style']
) : array();
if (isset(
$params['style']
)) {
...
...
@@ -975,7 +994,8 @@ class HelperSearch
/**
* 当前页地址
*/
public static function current(){
public static function current()
{
$url
= explode('?',
$_SERVER['REQUEST_URI']
);
self::
$listnav[0]['href']
=
$url[0]
;
return
$url[0]
;
...
...
@@ -983,7 +1003,8 @@ class HelperSearch
/**
* 下一页
*/
public static function next(
$total
){
public static function next(
$total
)
{
$param
= self::
$params
;
$page
= self::
$page
;
$next
= array();
...
...
@@ -1024,13 +1045,14 @@ class HelperSearch
* @param
$viewNum
* @return mixed
*/
public static function pager(
$total
,
$viewNum
){
public static function pager(
$total
,
$viewNum
){
$Paging
= new Paging('Yoho');
return
$Paging->setTotal
(
$total
)->setSize(
$viewNum
)->view(0);
}
//组织静态资源数据格式
public static function formatNodeContent(
$code
){
public static function formatNodeContent(
$code
)
{
$nodeContent
= BrandData::getByNodeContent(
$code
);
if (isset(
$nodeContent['code']
) &&
$nodeContent['code']
=== 200) {
$result
= array();
...
...
@@ -1052,13 +1074,16 @@ class HelperSearch
/**
* 组织品牌店铺信息
* @param
$shop
* @param
$shopSort
* @return array
*/
public static function shop(
$shop
)
public static function shop(
$shop
,
$shopSort
)
{
$url
= Helpers::url('','',
$shop['brand_domain']
);
$shopEntry
= array();
$sort
= array();
foreach (
$shop
['sort']
as
$msort
) {
foreach (
$shop
Sort
as
$msort
) {
if (!isset(
$msort['sub']
) || empty(
$msort['sub']
)) {
continue;
}
...
...
@@ -1112,4 +1137,159 @@ 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; // 过滤掉已售罄的商品
//
$param['needFilter']
= 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(self::getUrl(),
$param
);
}
/**
* 并行调接口url获取(产品分类)
* @param
*/
public static function getClassesUrl(
$condition
)
{
$condition['sales']
= 'Y'; //在销售商品分类
$condition['status']
= 1; //上架商品分类
$condition['stocknumber']
= 1; //过滤掉已售罄
return Yohobuy::httpBuildQuery(self::getUrl('sort'),
$condition
);
}
/**
* 并行调接口url获取(获取折扣区间)
* @param
*/
public static function getDiscountUrl(
$param
= array())
{
return Yohobuy::httpBuildQuery(self::getUrl('discount'),
$param
);
}
/**
* 并行调接口url获取(获取最新上架)
*/
public static function getRecentShelveUrl(
$param
= array())
{
return Yohobuy::httpBuildQuery(self::getUrl('recent'),
$param
);
}
/**
* 并行调接口url获取(获取用户浏览记录)
*/
// public static function getReviewUrl(
$param
= array())
// {
// return Yohobuy::httpBuildQuery(self::getUrl('review'),
$param
);
// }
/**
* 获取品牌店铺接口地址
* @param
$param
* @return string
*/
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';
}
}
}
...
...
yohobuy/www.yohobuy.com/application/models/Product/Search.php
View file @
bc9bde8
<?php
namespace
Product
;
use
Api\Yohobuy
;
use
Plugin\Helpers
;
use
Plugin\HelperSearch
;
use
\LibModels\Web\Product\SearchData
;
...
...
@@ -17,68 +19,163 @@ class SearchModel
{
/**
* 根据条件获取搜索数据
*
* @param $condition 搜索数据的条件
* @param $options Array([imgSize]
* => Array([0] => 235[1] => 314)[minImgSize] => Array([0] => 60[1] => 80)[gender] => 1[needPd] => Y[rowNum] => 5[viewNum] => 60)
* @author sefon 2015-12-17 16:12:18
* @return array
* 搜索相关页面公共条件处理
* @param $param
* @param $option
* @return mixed
*/
public
static
function
getSearchData
(
$condition
,
$options
)
public
static
function
searchCondition
(
$param
,
$option
)
{
$data
=
array
();
// 调用接口查询商品数据
$result
=
SearchData
::
searchElasticByCondition
(
$condition
);
if
(
isset
(
$result
[
'code'
])
&&
$result
[
'code'
]
===
200
)
{
// 调用分类信息
$category
=
SearchData
::
getClassesData
(
$condition
);
if
(
isset
(
$category
[
'code'
])
&&
$category
[
'code'
]
===
200
)
{
$result
[
'data'
][
'filter'
][
'group_sort'
]
=
$category
[
'data'
][
'sort'
];
/* 过滤请求参数 */
$condition
=
filter_input_array
(
INPUT_GET
,
array
(
'query'
=>
FILTER_SANITIZE_STRING
,
'brand'
=>
FILTER_SANITIZE_STRING
,
'sort'
=>
FILTER_VALIDATE_INT
,
'msort'
=>
FILTER_VALIDATE_INT
,
'misort'
=>
FILTER_VALIDATE_INT
,
'color'
=>
FILTER_VALIDATE_INT
,
'size'
=>
FILTER_DEFAULT
,
'style'
=>
FILTER_DEFAULT
,
'price'
=>
FILTER_DEFAULT
,
'gender'
=>
FILTER_SANITIZE_STRING
,
'p_d'
=>
FILTER_DEFAULT
,
'shelve_time'
=>
FILTER_DEFAULT
,
'isNew'
=>
FILTER_DEFAULT
,
'specialoffer'
=>
FILTER_DEFAULT
,
'limited'
=>
FILTER_DEFAULT
,
'order'
=>
FILTER_DEFAULT
,
'viewNum'
=>
FILTER_VALIDATE_INT
,
'rowNum'
=>
FILTER_VALIDATE_INT
,
'page'
=>
FILTER_VALIDATE_INT
),
false
);
//关键字
if
(
isset
(
$condition
[
'query'
])
&&
!
empty
(
$condition
[
'query'
]))
{
$condition
[
'query'
]
=
rawurldecode
(
$condition
[
'query'
]);
}
//品牌
if
(
isset
(
$condition
[
'brand'
])
&&
!
empty
(
$condition
[
'brand'
]))
{
$condition
[
'brand'
]
=
rawurldecode
(
$condition
[
'brand'
]);
}
//性别
if
(
isset
(
$condition
[
'gender'
])
&&
!
empty
(
$condition
[
'gender'
]))
{
$condition
[
'gender'
]
=
rawurldecode
(
$condition
[
'gender'
]);
}
else
{
$condition
[
'gender'
]
=
Helpers
::
getGenderByCookie
();
}
//每页显示商品数
$viewNumArray
=
array
(
60
,
100
,
200
);
if
(
!
isset
(
$condition
[
'viewNum'
])
||
empty
(
$condition
[
'viewNum'
])){
$condition
[
'viewNum'
]
=
60
;
}
if
(
!
in_array
(
$condition
[
'viewNum'
],
$viewNumArray
))
{
$condition
[
'viewNum'
]
=
60
;
}
//每行显示的商品数量
if
(
!
isset
(
$condition
[
'rowNum'
])
||
empty
(
$condition
[
'rowNum'
])){
$condition
[
'rowNum'
]
=
5
;
}
if
(
$condition
[
'rowNum'
]
==
6
)
{
$imgSize
=
array
(
195
,
260
);
$minImgSize
=
array
(
50
,
67
);
}
else
{
$condition
[
'rowNum'
]
=
5
;
$imgSize
=
array
(
235
,
314
);
$minImgSize
=
array
(
60
,
80
);
}
//自定义搜索价格
if
(
isset
(
$condition
[
'price'
])
&&
!
empty
(
$condition
[
'price'
]))
{
$price
=
explode
(
','
,
$condition
[
'price'
]);
if
(
!
$price
[
0
])
{
$price
[
0
]
=
0
;
}
// 调用折扣区间
$discount
=
SearchData
::
getDiscount
();
if
(
isset
(
$discount
[
'code'
])
&&
$discount
[
'code'
]
===
200
)
{
$result
[
'data'
][
'filter'
][
'discount'
]
=
$discount
[
'data'
][
'discount'
];
if
(
!
$price
[
1
])
{
$price
[
1
]
=
99999
;
}
// 调用最新上架
$recent
=
SearchData
::
recentShelve
();
if
(
isset
(
$discount
[
'code'
])
&&
$discount
[
'code'
]
===
200
)
{
$result
[
'data'
][
'filter'
][
'recent'
]
=
$recent
[
'data'
][
'recent'
];
$condition
[
'price'
]
=
implode
(
','
,
$price
);
}
//返回搜索条件
$condition
[
'needFilter'
]
=
1
;
//过滤赠品
$condition
[
'attribute_not'
]
=
2
;
//默认排序
if
(
!
isset
(
$condition
[
'order'
])
||
empty
(
$condition
[
'order'
]))
{
$condition
[
'order'
]
=
's_n_desc'
;
}
if
(
!
isset
(
$condition
[
'p_d'
])
||
empty
(
$condition
[
'p_d'
]))
{
$condition
[
'p_d'
]
=
'0,0.9'
;
}
$options
=
array
(
'imgSize'
=>
$imgSize
,
'minImgSize'
=>
$minImgSize
,
'rowNum'
=>
$condition
[
'rowNum'
],
'viewNum'
=>
$condition
[
'viewNum'
],
);
//接收高级选项
foreach
(
$_GET
as
$key
=>
$val
)
{
if
(
strpos
(
'parameter_'
,
$key
)
!==
false
)
{
$condition
[
$key
]
=
(
int
)
$val
;
}
//用户浏览记录
$result
[
'data'
][
'filter'
][
'review'
]
=
SearchData
::
getRecentReview
();
// 组织模板数据
$data
=
HelperSearch
::
getList
(
$result
,
$options
);
}
//每页记录数减1,下一页占位
$condition
[
'viewNum'
]
=
$condition
[
'viewNum'
]
-
1
;
$condition
=
array_merge
(
$condition
,
$param
);
$options
=
array_merge
(
$options
,
$option
);
$data
[
'condition'
]
=
$condition
;
$data
[
'options'
]
=
$options
;
return
$data
;
}
/**
* 搜索页面获取搜索数据
* @param $condition
* @param $options
* 根据条件获取搜索数据
* @param array $customCondition
* @param array $customOptions
* @return array
*/
public
static
function
searchData
(
$condition
,
$options
){
$data
=
self
::
getSearchData
(
$condition
,
$options
);
//获取品牌店铺信息
if
(
isset
(
$condition
[
'query'
]))
{
$param
[
'keyword'
]
=
$condition
[
'query'
];
$result
=
SearchData
::
getShop
(
$param
);
if
(
isset
(
$result
[
'code'
])
&&
$result
[
'code'
]
===
200
&&
isset
(
$result
[
'data'
])
&&
!
empty
(
$result
[
'data'
]))
{
//调用品牌分类
$class
[
'brand'
]
=
$result
[
'data'
][
'id'
];
$brandSort
=
SearchData
::
getClassesData
(
$class
);
$shop
=
$result
[
'data'
];
if
(
isset
(
$brandSort
[
'data'
][
'sort'
])
&&
!
empty
(
$brandSort
[
'data'
][
'sort'
]))
$shop
[
'sort'
]
=
$brandSort
[
'data'
][
'sort'
];
$shopEntry
=
HelperSearch
::
shop
(
$shop
);
}
}
$data
[
'shopEntry'
]
=
isset
(
$shopEntry
)
?
$shopEntry
:
array
();
public
static
function
getListData
(
$customCondition
=
array
(),
$customOptions
=
array
())
{
$urlList
=
array
();
$searchCondition
=
self
::
searchCondition
(
$customCondition
,
$customOptions
);
// 组合搜索商品url
$urlList
[
'product'
]
=
HelperSearch
::
getProductUrl
(
$searchCondition
[
'condition'
]);
// 组合搜索分类url
$urlList
[
'sort'
]
=
HelperSearch
::
getClassesUrl
(
$searchCondition
[
'condition'
]);
// 组合搜索折扣区间url
$urlList
[
'discount'
]
=
HelperSearch
::
getDiscountUrl
(
$searchCondition
[
'condition'
]);
// 组合搜索最新上架url
$urlList
[
'recent'
]
=
HelperSearch
::
getRecentShelveUrl
(
$searchCondition
[
'condition'
]);
//用户浏览记录
//$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']);
$result
=
Yohobuy
::
getMulti
(
$urlList
,
array
(),
true
);
// 组织模板数据
$data
=
HelperSearch
::
getList
(
$result
,
$searchCondition
[
'options'
]);
return
$data
;
}
/**
* 搜索页面获取搜索数据
* @param $customCondition
* @param $customOptions
* @return array
*/
public
static
function
searchData
(
$customCondition
,
$customOptions
)
{
$urlList
=
array
();
$searchCondition
=
self
::
searchCondition
(
$customCondition
,
$customOptions
);
// 组合搜索商品url
$urlList
[
'product'
]
=
HelperSearch
::
getProductUrl
(
$searchCondition
[
'condition'
]);
// 组合搜索分类url
$urlList
[
'sort'
]
=
HelperSearch
::
getClassesUrl
(
$searchCondition
[
'condition'
]);
// 组合搜索店铺url
$param
[
'keyword'
]
=
$searchCondition
[
'condition'
][
'query'
];
$urlList
[
'shop'
]
=
HelperSearch
::
getShopUrl
(
$param
);
//用户浏览记录
//$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']);
$result
=
Yohobuy
::
getMulti
(
$urlList
,
array
(),
true
);
// 组织模板数据
$data
=
HelperSearch
::
getList
(
$result
,
$searchCondition
[
'options'
]);
return
$data
;
}
/**
* 根据product_sn查询产品图片信息
...
...
yohobuy/www.yohobuy.com/application/modules/Product/controllers/Index.php
View file @
bc9bde8
...
...
@@ -17,10 +17,10 @@ class IndexController extends WebAction
$uid
=
$this
->
getUid
();
//根据品牌域名获取品牌id(同时判断品牌域名是否有效)
$brandInfo
=
BrandData
::
getBrandLogoByDomain
(
$domain
);
if
(
!
empty
(
$brandInfo
[
'data'
])
&&
$brandInfo
[
'code'
]
===
200
)
{
if
(
!
empty
(
$brandInfo
[
'data'
])
&&
$brandInfo
[
'code'
]
===
200
)
{
$brandId
=
$brandInfo
[
'data'
][
'id'
];
$node
=
isset
(
$brandInfo
[
'static_content_code'
])
?
$brandInfo
[
'static_content_code'
]
:
false
;
}
else
{
}
else
{
$this
->
go
(
SITE_MAIN
);
}
...
...
@@ -60,7 +60,7 @@ class IndexController extends WebAction
$condition
[
'gender'
]
=
$gender
;
//每页显示商品数
if
(
!
isset
(
$condition
[
'viewNum'
])
||
empty
(
$condition
[
'viewNum'
]))
{
if
(
!
isset
(
$condition
[
'viewNum'
])
||
empty
(
$condition
[
'viewNum'
]))
{
$condition
[
'viewNum'
]
=
60
;
}
$view_num_arr
=
array
(
60
,
100
,
200
);
...
...
@@ -68,7 +68,7 @@ class IndexController extends WebAction
$condition
[
'viewNum'
]
=
60
;
}
//每行显示的商品数量
if
(
!
isset
(
$condition
[
'rowNum'
])
||
empty
(
$condition
[
'rowNum'
]))
{
if
(
!
isset
(
$condition
[
'rowNum'
])
||
empty
(
$condition
[
'rowNum'
]))
{
$condition
[
'rowNum'
]
=
5
;
}
if
(
$condition
[
'rowNum'
]
==
6
)
{
...
...
yohobuy/www.yohobuy.com/application/modules/Product/controllers/List.php
View file @
bc9bde8
...
...
@@ -17,87 +17,12 @@ class ListController extends WebAction
*/
public
function
saleAction
()
{
/* 过滤请求参数 */
$condition
=
filter_input_array
(
INPUT_GET
,
array
(
//'query' => FILTER_SANITIZE_STRING,
'brand'
=>
FILTER_VALIDATE_INT
,
'sort'
=>
FILTER_VALIDATE_INT
,
'msort'
=>
FILTER_VALIDATE_INT
,
'misort'
=>
FILTER_VALIDATE_INT
,
'color'
=>
FILTER_VALIDATE_INT
,
'size'
=>
FILTER_DEFAULT
,
'style'
=>
FILTER_DEFAULT
,
'price'
=>
FILTER_DEFAULT
,
'gender'
=>
FILTER_DEFAULT
,
'p_d'
=>
FILTER_DEFAULT
,
'shelve_time'
=>
FILTER_DEFAULT
,
'isNew'
=>
FILTER_DEFAULT
,
'specialoffer'
=>
FILTER_DEFAULT
,
'limited'
=>
FILTER_DEFAULT
,
'order'
=>
FILTER_DEFAULT
,
'viewNum'
=>
FILTER_VALIDATE_INT
,
'rowNum'
=>
FILTER_VALIDATE_INT
,
'page'
=>
FILTER_VALIDATE_INT
),
false
);
//字符转码
if
(
!
empty
(
$condition
))
{
foreach
(
$condition
as
$key
=>
$val
)
{
$condition
[
$key
]
=
rawurldecode
(
$val
);
}
}
//性別(频道)
$gender_cookie
=
!
isset
(
$_COOKIE
[
'_Gender'
])
?
'3'
:
(
$_COOKIE
[
'_Gender'
]
==
'2,3'
?
2
:
1
);
$gender
=
$this
->
get
(
'gender'
)
?
(
$this
->
get
(
'gender'
)
==
'2,3'
?
2
:
1
)
:
$gender_cookie
;
$condition
[
'gender'
]
=
$gender
;
//每页显示商品数
if
(
!
isset
(
$condition
[
'viewNum'
])
||
empty
(
$condition
[
'viewNum'
])){
$condition
[
'viewNum'
]
=
60
;
}
$view_num_arr
=
array
(
60
,
100
,
200
);
if
(
!
in_array
(
$condition
[
'viewNum'
],
$view_num_arr
))
{
$condition
[
'viewNum'
]
=
60
;
}
//每行显示的商品数量
if
(
!
isset
(
$condition
[
'rowNum'
])
||
empty
(
$condition
[
'rowNum'
])){
$condition
[
'rowNum'
]
=
5
;
}
if
(
$condition
[
'rowNum'
]
==
6
)
{
$imgSize
=
array
(
195
,
260
);
$minImgSize
=
array
(
50
,
67
);
}
else
{
$condition
[
'rowNum'
]
=
5
;
$imgSize
=
array
(
235
,
314
);
$minImgSize
=
array
(
60
,
80
);
}
//返回搜索条件
$condition
[
'needFilter'
]
=
1
;
//过滤赠品
$condition
[
'attribute_not'
]
=
2
;
/*sale*/
//默认排序
if
(
!
isset
(
$condition
[
'order'
])
||
empty
(
$condition
[
'order'
]))
{
$condition
[
'order'
]
=
's_n_desc'
;
}
if
(
!
isset
(
$condition
[
'p_d'
])
||
empty
(
$condition
[
'p_d'
]))
{
$condition
[
'p_d'
]
=
'0,0.9'
;
}
$options
=
array
(
'imgSize'
=>
$imgSize
,
'minImgSize'
=>
$minImgSize
,
'rowNum'
=>
$condition
[
'rowNum'
],
'viewNum'
=>
$condition
[
'viewNum'
],
);
$params
=
$condition
+
$_GET
;
$params
=
array_filter
(
$params
);
//每页记录数减1,下一页占位
$params
[
'viewNum'
]
=
$params
[
'viewNum'
]
-
1
;
$list
=
SearchModel
::
getSearchData
(
$params
,
$options
);
$list
=
SearchModel
::
getListData
();
$data
=
array
(
//初始化js
'productListPage'
=>
true
,
'list'
=>
$list
);
$cate
=
array
(
'boys'
,
'girls'
,
'kids'
,
'lifestyle'
);
$this
->
setWebNavHeader
(
$cate
[
$gender
-
1
]);
$this
->
_view
->
display
(
'list'
,
$data
);
}
...
...
yohobuy/www.yohobuy.com/application/modules/Product/controllers/Search.php
View file @
bc9bde8
...
...
@@ -5,98 +5,14 @@ class SearchController extends WebAction
{
public
function
indexAction
()
{
/* 过滤请求参数 */
$condition
=
filter_input_array
(
INPUT_GET
,
array
(
'query'
=>
FILTER_SANITIZE_STRING
,
'brand'
=>
FILTER_VALIDATE_INT
,
'sort'
=>
FILTER_VALIDATE_INT
,
'msort'
=>
FILTER_VALIDATE_INT
,
'misort'
=>
FILTER_VALIDATE_INT
,
'color'
=>
FILTER_VALIDATE_INT
,
'size'
=>
FILTER_DEFAULT
,
'style'
=>
FILTER_DEFAULT
,
'price'
=>
FILTER_DEFAULT
,
'gender'
=>
FILTER_DEFAULT
,
'p_d'
=>
FILTER_DEFAULT
,
'shelve_time'
=>
FILTER_DEFAULT
,
'isNew'
=>
FILTER_DEFAULT
,
'specialoffer'
=>
FILTER_DEFAULT
,
'limited'
=>
FILTER_DEFAULT
,
'order'
=>
FILTER_DEFAULT
,
'viewNum'
=>
FILTER_VALIDATE_INT
,
'rowNum'
=>
FILTER_VALIDATE_INT
,
'page'
=>
FILTER_VALIDATE_INT
),
false
);
//字符转码
foreach
(
$condition
as
$key
=>
$val
){
$condition
[
$key
]
=
rawurldecode
(
$val
);
}
//性別(频道)
$gender_cookie
=
!
isset
(
$_COOKIE
[
'_Gender'
])
?
'3'
:
(
$_COOKIE
[
'_Gender'
]
==
'2,3'
?
2
:
1
);
$gender
=
$this
->
get
(
'gender'
)
?
(
$this
->
get
(
'gender'
)
==
'2,3'
?
2
:
1
)
:
$gender_cookie
;
$condition
[
'gender'
]
=
$gender
;
//每页显示商品数
if
(
!
isset
(
$condition
[
'viewNum'
])
||
empty
(
$condition
[
'viewNum'
])){
$condition
[
'viewNum'
]
=
60
;
}
$view_num_arr
=
array
(
60
,
100
,
200
);
if
(
!
in_array
(
$condition
[
'viewNum'
],
$view_num_arr
))
{
$condition
[
'viewNum'
]
=
60
;
}
//每行显示的商品数量
if
(
!
isset
(
$condition
[
'rowNum'
])
||
empty
(
$condition
[
'rowNum'
])){
$condition
[
'rowNum'
]
=
5
;
}
if
(
$condition
[
'rowNum'
]
==
6
)
{
$imgSize
=
array
(
195
,
260
);
$minImgSize
=
array
(
50
,
67
);
}
else
{
$condition
[
'rowNum'
]
=
5
;
$imgSize
=
array
(
235
,
314
);
$minImgSize
=
array
(
60
,
80
);
}
//自定义搜索价格
if
(
isset
(
$condition
[
'price'
])
&&
!
empty
(
$condition
[
'price'
]))
{
$price
=
explode
(
','
,
$condition
[
'price'
]);
if
(
!
$price
[
0
])
{
$price
[
0
]
=
0
;
}
if
(
!
$price
[
1
])
{
$price
[
1
]
=
99999
;
}
$condition
[
'price'
]
=
implode
(
','
,
$price
);
}
//返回搜索条件
$condition
[
'needFilter'
]
=
1
;
//过滤赠品
$condition
[
'attribute_not'
]
=
2
;
/*sale*/
//默认排序
if
(
!
isset
(
$condition
[
'order'
])
||
empty
(
$condition
[
'order'
]))
{
$condition
[
'order'
]
=
's_n_desc'
;
}
if
(
!
isset
(
$condition
[
'p_d'
])
||
empty
(
$condition
[
'p_d'
]))
{
$condition
[
'p_d'
]
=
'0,0.9'
;
}
$options
=
array
(
'imgSize'
=>
$imgSize
,
'minImgSize'
=>
$minImgSize
,
'rowNum'
=>
$condition
[
'rowNum'
],
'viewNum'
=>
$condition
[
'viewNum'
],
);
$params
=
$condition
+
$_GET
;
$params
=
array_filter
(
$params
);
//每页记录数减1,下一页占位
$params
[
'viewNum'
]
=
$params
[
'viewNum'
]
-
1
;
$options
[
'controller'
]
=
$this
->
_request
->
controller
;
$searchData
=
SearchModel
::
searchData
(
$params
,
$options
);
$cate
=
array
(
'boys'
,
'girls'
,
'kids'
,
'lifestyle'
);
$this
->
setWebNavHeader
(
$cate
[
$gender
-
1
]);
$searchData
=
SearchModel
::
searchData
(
array
(),
$options
);
$data
=
array
(
//初始化js
'searchListPage'
=>
true
,
'search'
=>
$searchData
);
$this
->
setWebNavHeader
();
$this
->
_view
->
display
(
'search'
,
$data
);
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment