Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
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
Email Patches
Plain Diff
Browse Files
Authored by
hf
9 years ago
Commit
017533163fffa68d2b978e702bf2d0b9d480ff91
1 parent
530c5ec2
code review by fei.hong: do format search new arrival codes
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
24 deletions
library/LibModels/Web/Product/SearchData.php
library/WebPlugin/Helpers.php
yohobuy/www.yohobuy.com/application/controllers/Common.php
yohobuy/www.yohobuy.com/application/models/Index/Home.php
library/LibModels/Web/Product/SearchData.php
View file @
0175331
...
...
@@ -142,20 +142,35 @@ class SearchData extends \LibModels\Wap\Product\SearchData
*/
public
static
function
getSearchDataBySort
(
array
$params
,
array
$sortList
)
{
$data
=
array
();
foreach
(
$sortList
as
$v
)
{
if
(
empty
(
$v
[
'viewNum'
])){
continue
;
}
$searchParams
=
array_merge
(
$params
,
$v
);
$list
=
self
::
searchElasticByCondition
(
$searchParams
,
true
);
$productList
=
empty
(
$list
[
'data'
][
'product_list'
])
?
array
()
:
$list
[
'data'
][
'product_list'
];
if
(
count
(
$productList
)
<
$v
[
'viewNum'
]){
continue
;
}
$data
=
array_merge
(
$data
,
$productList
);
// $data = array();
// foreach ($sortList as $v) {
// if(empty($v['viewNum'])){
// continue;
// }
// $searchParams = array_merge($params, $v);
// $list = self::searchElasticByCondition($searchParams, true);
// $productList = empty($list['data']['product_list']) ? array() : $list['data']['product_list'];
// if(count($productList) < $v['viewNum']){
// continue;
// }
// $data = array_merge($data, $productList);
// }
// return $data;
/* 2016/01/26 code review by fei.hong: 优化合并misort参数, 减少调用搜索的次数 */
$sortIds
=
''
;
$viewNum
=
0
;
foreach
(
$sortList
as
$value
)
{
$viewNum
+=
intval
(
$value
[
'viewNum'
]);
$sortIds
.=
$value
[
'misort'
]
.
','
;
}
return
$data
;
$params
[
'viewNum'
]
=
$viewNum
;
$params
[
'misort'
]
=
rtrim
(
$sortIds
,
','
);
$searchd
=
self
::
searchElasticByCondition
(
$params
);
if
(
empty
(
$searchd
[
'data'
][
'product_list'
]))
{
return
array
();
}
return
$searchd
[
'data'
][
'product_list'
];
}
/**
...
...
library/WebPlugin/Helpers.php
View file @
0175331
...
...
@@ -226,6 +226,7 @@ class Helpers
if
(
$oneGoods
[
'is_default'
]
===
'Y'
)
{
$productData
[
'default_images'
]
=
self
::
procProductImg
(
$oneGoods
);
$flag
=
true
;
break
;
}
}
// 如果还未赋值,则取第一个skc产品的默认图片
...
...
@@ -247,7 +248,7 @@ class Helpers
$result
[
'is_soon_sold_out'
]
=
(
$productData
[
'is_soon_sold_out'
]
===
'Y'
);
$result
[
'url'
]
=
self
::
url
(
'/product/pro_'
.
$productData
[
'product_id'
]
.
'_'
.
$productData
[
'goods_list'
][
0
][
'goods_id'
]
.
'/'
.
$productData
[
'cn_alphabet'
]
.
'.html'
,
'item'
);
.
'/'
.
$productData
[
'cn_alphabet'
]
.
'.html'
,
array
(),
'item'
);
// APP访问需要加附加的参数
// 备注:如果以后APP的接口太多,可以把这边参数提取出来,变成一个公共的方法来生成,便于以后管理维护
if
(
$isApp
)
{
...
...
yohobuy/www.yohobuy.com/application/controllers/Common.php
View file @
0175331
...
...
@@ -49,8 +49,8 @@ class CommonController extends WebAction
HomeModel
::
COOKIE_NAME_LIFESTYLE
);
$channel
=
$this
->
post
(
'type'
,
''
);
$pageIndex
=
intval
(
$this
->
post
(
'pageIndex'
,
0
));
$pageCount
=
intval
(
$this
->
post
(
'pageCount'
,
8
));
$pageIndex
=
(
int
)
$this
->
post
(
'pageIndex'
,
0
);
$pageCount
=
(
int
)
$this
->
post
(
'pageCount'
,
8
);
if
(
!
in_array
(
$channel
,
$channels
))
{
break
;
}
else
{
...
...
yohobuy/www.yohobuy.com/application/models/Index/Home.php
View file @
0175331
...
...
@@ -247,14 +247,13 @@ class HomeModel
*/
public
static
function
getNewArrival
(
$channel
)
{
$result
=
array
();
$key
=
sprintf
(
WebCacheConfig
::
KEY_WEB_HOME_CHANNEL_NEWARRIVAL_DATA
.
'_'
.
$channel
);
$key
=
WebCacheConfig
::
KEY_WEB_HOME_CHANNEL_NEWARRIVAL_DATA
.
'_'
.
$channel
;
//缓存数据
$result
=
Cache
::
get
(
$key
);
if
(
empty
(
$result
))
{
if
(
empty
(
$result
))
{
$params
=
array
(
'order'
=>
's_t_desc'
,
'shelve_time'
=>
strtotime
(
"-60 days"
)
.
','
.
time
()
'order'
=>
's_t_desc'
,
'shelve_time'
=>
strtotime
(
"-60 days"
)
.
','
.
time
()
);
//男首频道最新上架参数是gender=1,3
if
(
$channel
==
self
::
COOKIE_NAME_BOYS
)
{
...
...
@@ -270,9 +269,13 @@ class HomeModel
// 获取分类列表获取商品信息
$goodsList
=
SearchData
::
getSearchDataBySort
(
$params
,
$sortList
);
$pos
=
1
;
$val
=
array
();
foreach
(
$goodsList
as
$goods
)
{
// 格式化数据
$val
=
Helpers
::
formatProduct
(
$goods
,
true
,
true
,
true
,
280
,
373
);
if
(
!
$val
)
{
continue
;
}
if
(
$val
[
'price'
]
==
false
)
{
$val
[
'price'
]
=
$val
[
'salePrice'
];
}
...
...
@@ -287,13 +290,16 @@ class HomeModel
$val
[
'tags'
][
'isReNew'
]
=
false
;
//$val['tags']['is_advance'];暂时不显示
unset
(
$val
[
'tags'
][
'is_advance'
],
$val
[
'tags'
][
'is_discount'
],
$val
[
'tags'
][
'is_limited'
],
$val
[
'tags'
][
'is_new'
],
$val
[
'tags'
][
'is_yohood'
],
$val
[
'tags'
][
'midYear'
],
$val
[
'tags'
][
'yearEnd'
]);
if
(
!
empty
(
$val
))
{
$result
[]
=
$val
;
}
$result
[]
=
$val
;
}
}
Cache
::
set
(
$key
,
$result
,
3600
);
}
// 当一级缓存失效,并且接口异常时, 尝试从二级缓存获取数据
if
(
empty
(
$result
))
{
$result
=
Cache
::
get
(
$key
,
'slave'
);
}
return
$result
;
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment