Authored by Rock Zhang

初步完成新品到着,折扣专区的新品到着筛选数据

... ... @@ -40,9 +40,11 @@ class SearchData
* @param string $query 查询条件, 默认为null
* @param string $brand 品牌,默认为null
* @param string $gender 性别,默认为null,"1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $color 颜色id
* @param integer $size 尺码id
* @param integer $price 价格
* @param string $p_d 折扣,默认为null
* @param string $misort 商品分类,默认为null
* @param string $msort 商品分类,默认为null
* @param string $sort 商品所属品类,默认为null
* @param string $order 排序方式,默认为按照时间倒序排列s_t_desc,
* s_t_asc表示按时间正序排列,
* s_p_asc表示按价格正序排列,
... ... @@ -53,7 +55,7 @@ class SearchData
* @param integer $limit 指定查询多少个,默认是60哥
* @return array 搜索到的数据
*/
public static function searchLiDatas($query = null, $brand = null, $gender = null, $p_d = null, $misort = null, $msort = null, $order = 's_t_desc', $page = 1, $limit = 60)
public static function searchLiDatas($query = null, $brand = null, $gender = null, $color = null, $size = null, $price = null, $p_d = null, $sort = null, $order = 's_t_desc', $page = 1, $limit = 60)
{
// 构建必传参数
$param = Yohobuy::param();
... ... @@ -61,9 +63,11 @@ class SearchData
is_null($query) || $param['query'] = $query;
is_null($brand) || $param['brand'] = $brand;
is_null($gender) || $param['gender'] = $gender;
is_null($color) || $param['color'] = $color;
is_null($size) || $param['size'] = $size;
is_null($price) || $param['price'] = $price;
is_null($p_d) || $param['p_d'] = $p_d;
is_null($misort) || $param['misort'] = $misort;
is_null($msort) || $param['msort'] = $msort;
is_null($sort) || $param['sort'] = $sort;
$param['method'] = 'app.search.li';
$param['order'] = $order;
$param['page'] = $page;
... ...
... ... @@ -146,7 +146,7 @@ class ListProcess
$result = array(
'title' => '折扣',
'name' => '所有商品',
'dataType' => 'p_d',
'dataType' => 'discount',
'subs' => array(
array(
'chosed' => true,
... ... @@ -210,7 +210,7 @@ class ListProcess
foreach ($data as $one) {
$category = array();
$category['dataId'] = $one['category_id'];
$category['dataId'] = isset($one['relation_parameter']) ? $one['relation_parameter']['sort'] : 0;
$category['name'] = $one['category_name'];
/*// 子品类(目前h5不支持二级)
... ... @@ -247,11 +247,12 @@ class ListProcess
)
);
foreach ($data as $one) {
foreach ($data as $key => $one) {
$price = array();
$price['dataId'] = $key;
$price['name'] = $one;
$result[] = $price;
$result['subs'][] = $price;
}
return $result;
... ...
... ... @@ -35,6 +35,7 @@ class NewSaleProcess
foreach ($single['tabs'] as $key => $one) {
$tabItem = array();
$tabItem['title'] = $one;
$tabItem['dataId'] = $key;
if ($key === 1) {
$tabItem['focus'] = true;
}
... ... @@ -62,22 +63,4 @@ class NewSaleProcess
return $result;
}
/**
* 筛选出来的商品数据处理
*
* @param array $data 筛选出来的原数据
* @return array 处理之后的数据
*/
public static function selectData($data)
{
$result = array('goods' => array());
if (isset($data['code']) && $data['code'] === 200) {
foreach ($data['data']['product_list'] as $val) {
$result['goods'][] = Helpers::formatProduct($val);
}
}
return $result;
}
}
... ...
... ... @@ -197,4 +197,23 @@ class NewsaleModel
return $result;
}
/**
* 筛选出来的商品数据处理
*
* @param array $data 筛选出来的原数据
* @return array 处理之后的数据
*/
public static function selectData($data)
{
$result = array('goods' => array());
if (isset($data['code']) && $data['code'] === 200) {
foreach ($data['data']['product_list'] as $val) {
$result['goods'][] = Helpers::formatProduct($val);
}
}
return $result;
}
}
... ...
... ... @@ -36,11 +36,9 @@ class ListController extends AbstractAction
'brand' => 0,
'msort' => 0,
'gender' => $this->getCookie('_Channel', 'boys'),
'sort' => 0,
'price' => 0,
'size' => 0,
'discount' => '',
'p_d' => ''
'discount' => ''
)
);
... ... @@ -97,9 +95,11 @@ class ListController extends AbstractAction
$query = $this->get('query', null);
$brand = $this->get('brand', null);
$gender = $this->get('gender', null);
$p_d = $this->get('p_d', null);
$misort = $this->get('misort', null);
$msort = $this->get('msort', null);
$color = $this->get('color', null);
$size = $this->get('size', null);
$price = $this->get('price', null);
$p_d = $this->get('discount', null);
$sort = $this->get('msort', null);
// 转换性别
if($gender === 'boys')
... ... @@ -115,7 +115,6 @@ class ListController extends AbstractAction
$gender = '1,2,3';
}
// 转换排序方式
$order = $this->get('order', null);
$type = $this->get('type', '');
... ... @@ -134,7 +133,7 @@ class ListController extends AbstractAction
$data = array();
// 查询数据
$listData = SearchData::searchLiDatas($query, $brand, $gender, $p_d, $misort, $msort, $order);
$listData = SearchData::searchLiDatas($query, $brand, $gender, $color, $size, $price, $p_d, $sort, $order);
// 处理返回的数据
if (isset($listData['code']) && $listData['code'] === 200) {
$tmpData = $listData['data'];
... ... @@ -166,7 +165,7 @@ class ListController extends AbstractAction
$color = $this->get('color', null);
$size = $this->get('size', null);
$price = $this->get('price', null);
$p_d = $this->get('p_d', null);
$p_d = $this->get('discount', null);
$data = array(
'pageHeader' => array(
... ... @@ -230,7 +229,7 @@ class ListController extends AbstractAction
$color = $this->get('color', null);
$size = $this->get('size', null);
$price = $this->get('price', null);
$p_d = $this->get('p_d', null);
$p_d = $this->get('discount', null);
$data = array(
'pageHeader' => array(
... ... @@ -245,8 +244,7 @@ class ListController extends AbstractAction
'sort' => $sort,
'price' => 0,
'size' => 0,
'discount' => '',
'p_d' => ''
'discount' => ''
)
);
... ...
... ... @@ -32,6 +32,16 @@ class NewsaleController extends AbstractAction
if (!empty($goodsList)) {
$data += $goodsList;
}
// 设置一些筛选的默认参数
$data += array(
'brand' => 0,
'sort' => 0,
'gender' => $this->getCookie('_Channel', 'boys'),
'price' => 0,
'size' => 0,
'dayLimit' => 1,
'discount' => ''
);
$this->_view->display('new', $data);
}
... ... @@ -58,19 +68,33 @@ class NewsaleController extends AbstractAction
if (!empty($goodsList)) {
$data += $goodsList;
}
// 设置一些筛选的默认参数
$data += array(
'brand' => 0,
'sort' => 0,
'gender' => $this->getCookie('_Channel', 'boys'),
'price' => 0,
'size' => 0,
'dayLimit' => 1,
'discount' => '0.1,0.3'
);
$data['tabs'] = array(
array(
'title' => '1-3折',
'dataId' => '0.1,0.3',
'focus' => true
),
array(
'title' => '4-6折'
'title' => '4-6折',
'dataId' => '0.4,0.6',
),
array(
'title' => '7-9折'
'title' => '7-9折',
'dataId' => '0.7,0.9',
),
array(
'title' => 'ALL'
'title' => 'ALL',
'dataId' => '0.1,0.9',
)
);
... ... @@ -97,12 +121,25 @@ class NewsaleController extends AbstractAction
$limit = $this->get('limit', 20);
$page = $this->get('page', 1);
// 转换性别
if($gender === 'boys')
{
$gender = '1,3';
}
elseif($gender === 'girls')
{
$gender = '2,3';
}
else
{
$gender = '1,2,3';
}
$data = NewsaleData::selectNewSaleProducts(
$gender, $brand, $sort, $color,
$size, $price, $p_d, $channel, $dayLimit, $limit, $page
);
$result = NewSaleProcess::selectData($data);
$result = \Product\NewsaleModel::selectData($data);
$this->_view->display('product', $result);
} else {
... ...