Authored by hf

do fixes bug to lifestyle maylike data empty filter

framework @ 75bbc3b0
Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
... ...
... ... @@ -67,14 +67,43 @@ class RecomData
*/
public static function mayLikeLifestyle($page = 1, $limit = 50)
{
$param = Yohobuy::param();
$param['method'] = 'app.search.lifeStyle';
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = '4';
$param['client_secret'] = Sign::getSign($param);
// $param = Yohobuy::param();
// $param['method'] = 'app.search.lifeStyle';
// $param['page'] = $page;
// $param['limit'] = $limit;
// $param['yh_channel'] = '4';
// $param['client_secret'] = Sign::getSign($param);
//
// return Yohobuy::get(Yohobuy::API_URL, $param);
// 人气单品
$param = array(
array(
'stocknumber' => 1,
'status' => 1,
'order' => 's_n_desc',
'viewNum' => $limit,
'msort' => '10',
),
'N', false
);
$result['top'] = Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/search/service/v1/product', 'search', $param, 3600); // 缓存1小时
return Yohobuy::get(Yohobuy::API_URL, $param);
// 新品到着
$param = array(
array('status' => 1, 'stocknumber' => 1, 'gender' => ''),
array(
array('misort' => 103, 'viewNum' => 10), //数码3c
array('misort' => 266, 'viewNum' => 10), //居家
array('misort' => 280, 'viewNum' => 10), //玩具娱乐
array('misort' => 101, 'viewNum' => 10), //办公文具
array('misort' => 259, 'viewNum' => 10), //美妆
),
false
);
$result['new'] = Yohobuy::yarClient(Yohobuy::SERVICE_URL . '/search/service/v1/product', 'searchBySortList', $param, 3600); // 缓存1小时
return $result;
}
}
... ...
... ... @@ -47,8 +47,8 @@ class RecomController extends AbstractAction
if (empty($recom['data']['product_list'])) {
break;
}
/* 判断是否已没有数据 */
/* 判断是否已没有数据 */
if (intval($page) > intval($recom['data']['page_total'])) {
break;
}
... ... @@ -59,7 +59,6 @@ class RecomController extends AbstractAction
$data['goods'][] = Helpers::formatProduct($value, true);
}
$this->_view->display('maylike', $data);
} while (false);
echo ' ';
... ... @@ -120,32 +119,65 @@ class RecomController extends AbstractAction
if (!$this->isAjax()) {
break;
}
/* 创意生活只有一页数据 */
$page = $this->get('page', 1);
if (intval($page) > 1) {
break;
}
/* 取可能喜欢的数据 */
$recom = RecomData::mayLikeLifestyle();
if (empty($recom['data']['product_list'])) {
/* 构建人气单品数据 */
if (empty($recom['top']['data']['product_list'])) {
break;
}
/* 构建模板需要的商品数据 */
$data = array();
$build = array();
$build['show'] = true;
foreach ($recom['top']['data']['product_list'] as $value) {
$build['goods'][] = Helpers::formatProduct($value, true, false, false);
}
$data['goodsContainer'][] = $build;
/* 构建新品到着数据 */
if (empty($recom['new']['data']['product_list'])) {
break;
}
$build = array();
if (!empty($recom['data']['product_list']['top'])) {
$build = array();
$build['show'] = true;
foreach ($recom['data']['product_list']['top'] as $value) {
$build['goods'][] = Helpers::formatProduct($value, true);
}
$data['goodsContainer'][] = $build;
}
if (!empty($recom['data']['product_list']['new'])) {
$build = array();
foreach ($recom['data']['product_list']['new'] as $value) {
$build['show'] = false;
$build['goods'][] = Helpers::formatProduct($value, true);
}
$data['goodsContainer'][] = $build;
$build['show'] = true;
foreach ($recom['new']['data']['product_list'] as $value) {
$build['goods'][] = Helpers::formatProduct($value, true, false, false);
}
$data['goodsContainer'][] = $build;
// if (empty($recom['data']['product_list'])) {
// break;
// }
//
// /* 构建模板需要的商品数据 */
// $data = array();
// $build = array();
// if (!empty($recom['data']['product_list']['top'])) {
// $build = array();
// $build['show'] = true;
// foreach ($recom['data']['product_list']['top'] as $value) {
// $build['goods'][] = Helpers::formatProduct($value, true);
// }
// $data['goodsContainer'][] = $build;
// }
// if (!empty($recom['data']['product_list']['new'])) {
// $build = array();
// foreach ($recom['data']['product_list']['new'] as $value) {
// $build['show'] = false;
// $build['goods'][] = Helpers::formatProduct($value, true);
// }
// $data['goodsContainer'][] = $build;
// }
$this->_view->display('maylikelife', $data);
} while (false);
... ...