Authored by Rock Zhang

添加热卖排行榜后台逻辑

... ... @@ -45,9 +45,6 @@ class NewsaleData
*/
public static function getNewProducts($gender, $channel, $order = 's_t_desc', $limit = 60, $page = 1)
{
// 构建url地址列表
$urlList = array();
$param = Yohobuy::param();
$param['method'] = 'app.search.newProduct';
$param['gender'] = $gender;
... ... @@ -82,7 +79,6 @@ class NewsaleData
*/
public static function selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit = null, $limit = 60, $page = 1, $order = 's_t_desc')
{
$selectItems = array(
'gender' => $gender,
'brand' => $brand,
... ... @@ -182,4 +178,30 @@ class NewsaleData
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取热销排行榜商品数据
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param string|null $sort 品类ID查询参数
* @param integer|null $tab_id Tab的ID
* @param integer $limit 查询返回的最大限制数, 默认为50
* @param integer $page 分页第几页, 默认第1页
* @return array 新品到着商品数据
*/
public static function getTopProducts($gender, $sort = null, $tab_id = null, $limit = 50, $page = 1)
{
$param = Yohobuy::param();
$param['method'] = 'app.search.top';
$param['gender'] = $gender;
!empty($sort) && $param['sort'] = $sort;
!empty($tab_id) && $param['tab_id'] = $tab_id;
$param['page'] = $page;
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -226,6 +226,24 @@ class NewsaleModel
return $result;
}
/**
* 筛选出来的热销排行榜商品数据处理
*
* @param array $data 筛选出来的原数据
* @return array 处理之后的数据
*/
public static function selectTopData($data)
{
$result = array();
if (isset($data['code']) && $data['code'] === 200 && isset($data['data']['product_list'])) {
$result = NewSaleProcess::newSaleData($data['data']);
unset($result['filter']);
}
return $result;
}
/**
* 获取筛选数据
... ...
... ... @@ -79,23 +79,48 @@ class NewsaleController extends AbstractAction
$this->setTitle('热销排行榜');
$this->setNavHeader('热销排行榜');
$channel = Helpers::getChannelByCookie();
// 设置一些默认参数
$data = array(
'discountPage' => true,
'headerBanner' => \Product\NewsaleModel::getNewFocus($channel),
'showDownloadApp' => true,
'pageFooter' => true,
'brand' => '0',
'sort' => '0',
'gender' => Helpers::getGenderByCookie(),
'price' => '0',
'size' => '0',
'discount' => '0.1,0.9',
'cartUrl' => Helpers::url('/cart/index/index', null),
);
$this->_view->display('hotrank', $data);
}
/**
* Ajax方式获取热销排行榜商品
*
* @return array 根据指定条件筛选之后的商品
*/
public function selectHotrankAction()
{
$result = array();
if ($this->isAjax()) {
$sort = $this->get('sort', null);
$tab_id = $this->get('tab_id', null);
$limit = $this->get('limit', 50);
$page = $this->get('page', 1);
// 获取性别
$gender = Helpers::getGenderByCookie();
$data = NewsaleData::getTopProducts($gender, $sort, $tab_id, $limit, $page);
$result = \Product\NewsaleModel::selectTopData($data);
}
if (empty($result)) {
echo ' ';
} else {
$this->_view->display('product', $result);
}
}
/**
* Ajax方式筛选新品到着、折扣专区商品
*
... ...