Authored by Rock Zhang

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

@@ -40,9 +40,11 @@ class SearchData @@ -40,9 +40,11 @@ class SearchData
40 * @param string $query 查询条件, 默认为null 40 * @param string $query 查询条件, 默认为null
41 * @param string $brand 品牌,默认为null 41 * @param string $brand 品牌,默认为null
42 * @param string $gender 性别,默认为null,"1,3"表示男, "2,3"表示女, "1,2,3"表示全部 42 * @param string $gender 性别,默认为null,"1,3"表示男, "2,3"表示女, "1,2,3"表示全部
  43 + * @param integer $color 颜色id
  44 + * @param integer $size 尺码id
  45 + * @param integer $price 价格
43 * @param string $p_d 折扣,默认为null 46 * @param string $p_d 折扣,默认为null
44 - * @param string $misort 商品分类,默认为null  
45 - * @param string $msort 商品分类,默认为null 47 + * @param string $sort 商品所属品类,默认为null
46 * @param string $order 排序方式,默认为按照时间倒序排列s_t_desc, 48 * @param string $order 排序方式,默认为按照时间倒序排列s_t_desc,
47 * s_t_asc表示按时间正序排列, 49 * s_t_asc表示按时间正序排列,
48 * s_p_asc表示按价格正序排列, 50 * s_p_asc表示按价格正序排列,
@@ -53,7 +55,7 @@ class SearchData @@ -53,7 +55,7 @@ class SearchData
53 * @param integer $limit 指定查询多少个,默认是60哥 55 * @param integer $limit 指定查询多少个,默认是60哥
54 * @return array 搜索到的数据 56 * @return array 搜索到的数据
55 */ 57 */
56 - 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) 58 + 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)
57 { 59 {
58 // 构建必传参数 60 // 构建必传参数
59 $param = Yohobuy::param(); 61 $param = Yohobuy::param();
@@ -61,9 +63,11 @@ class SearchData @@ -61,9 +63,11 @@ class SearchData
61 is_null($query) || $param['query'] = $query; 63 is_null($query) || $param['query'] = $query;
62 is_null($brand) || $param['brand'] = $brand; 64 is_null($brand) || $param['brand'] = $brand;
63 is_null($gender) || $param['gender'] = $gender; 65 is_null($gender) || $param['gender'] = $gender;
  66 + is_null($color) || $param['color'] = $color;
  67 + is_null($size) || $param['size'] = $size;
  68 + is_null($price) || $param['price'] = $price;
64 is_null($p_d) || $param['p_d'] = $p_d; 69 is_null($p_d) || $param['p_d'] = $p_d;
65 - is_null($misort) || $param['misort'] = $misort;  
66 - is_null($msort) || $param['msort'] = $msort; 70 + is_null($sort) || $param['sort'] = $sort;
67 $param['method'] = 'app.search.li'; 71 $param['method'] = 'app.search.li';
68 $param['order'] = $order; 72 $param['order'] = $order;
69 $param['page'] = $page; 73 $param['page'] = $page;
@@ -146,7 +146,7 @@ class ListProcess @@ -146,7 +146,7 @@ class ListProcess
146 $result = array( 146 $result = array(
147 'title' => '折扣', 147 'title' => '折扣',
148 'name' => '所有商品', 148 'name' => '所有商品',
149 - 'dataType' => 'p_d', 149 + 'dataType' => 'discount',
150 'subs' => array( 150 'subs' => array(
151 array( 151 array(
152 'chosed' => true, 152 'chosed' => true,
@@ -210,7 +210,7 @@ class ListProcess @@ -210,7 +210,7 @@ class ListProcess
210 210
211 foreach ($data as $one) { 211 foreach ($data as $one) {
212 $category = array(); 212 $category = array();
213 - $category['dataId'] = $one['category_id']; 213 + $category['dataId'] = isset($one['relation_parameter']) ? $one['relation_parameter']['sort'] : 0;
214 $category['name'] = $one['category_name']; 214 $category['name'] = $one['category_name'];
215 215
216 /*// 子品类(目前h5不支持二级) 216 /*// 子品类(目前h5不支持二级)
@@ -247,11 +247,12 @@ class ListProcess @@ -247,11 +247,12 @@ class ListProcess
247 ) 247 )
248 ); 248 );
249 249
250 - foreach ($data as $one) { 250 + foreach ($data as $key => $one) {
251 $price = array(); 251 $price = array();
  252 + $price['dataId'] = $key;
252 $price['name'] = $one; 253 $price['name'] = $one;
253 254
254 - $result[] = $price; 255 + $result['subs'][] = $price;
255 } 256 }
256 257
257 return $result; 258 return $result;
@@ -35,6 +35,7 @@ class NewSaleProcess @@ -35,6 +35,7 @@ class NewSaleProcess
35 foreach ($single['tabs'] as $key => $one) { 35 foreach ($single['tabs'] as $key => $one) {
36 $tabItem = array(); 36 $tabItem = array();
37 $tabItem['title'] = $one; 37 $tabItem['title'] = $one;
  38 + $tabItem['dataId'] = $key;
38 if ($key === 1) { 39 if ($key === 1) {
39 $tabItem['focus'] = true; 40 $tabItem['focus'] = true;
40 } 41 }
@@ -62,22 +63,4 @@ class NewSaleProcess @@ -62,22 +63,4 @@ class NewSaleProcess
62 return $result; 63 return $result;
63 } 64 }
64 65
65 - /**  
66 - * 筛选出来的商品数据处理  
67 - *  
68 - * @param array $data 筛选出来的原数据  
69 - * @return array 处理之后的数据  
70 - */  
71 - public static function selectData($data)  
72 - {  
73 - $result = array('goods' => array());  
74 -  
75 - if (isset($data['code']) && $data['code'] === 200) {  
76 - foreach ($data['data']['product_list'] as $val) {  
77 - $result['goods'][] = Helpers::formatProduct($val);  
78 - }  
79 - }  
80 -  
81 - return $result;  
82 - }  
83 } 66 }
@@ -197,4 +197,23 @@ class NewsaleModel @@ -197,4 +197,23 @@ class NewsaleModel
197 197
198 return $result; 198 return $result;
199 } 199 }
  200 +
  201 + /**
  202 + * 筛选出来的商品数据处理
  203 + *
  204 + * @param array $data 筛选出来的原数据
  205 + * @return array 处理之后的数据
  206 + */
  207 + public static function selectData($data)
  208 + {
  209 + $result = array('goods' => array());
  210 +
  211 + if (isset($data['code']) && $data['code'] === 200) {
  212 + foreach ($data['data']['product_list'] as $val) {
  213 + $result['goods'][] = Helpers::formatProduct($val);
  214 + }
  215 + }
  216 +
  217 + return $result;
  218 + }
200 } 219 }
@@ -36,11 +36,9 @@ class ListController extends AbstractAction @@ -36,11 +36,9 @@ class ListController extends AbstractAction
36 'brand' => 0, 36 'brand' => 0,
37 'msort' => 0, 37 'msort' => 0,
38 'gender' => $this->getCookie('_Channel', 'boys'), 38 'gender' => $this->getCookie('_Channel', 'boys'),
39 - 'sort' => 0,  
40 'price' => 0, 39 'price' => 0,
41 'size' => 0, 40 'size' => 0,
42 - 'discount' => '',  
43 - 'p_d' => '' 41 + 'discount' => ''
44 ) 42 )
45 ); 43 );
46 44
@@ -97,9 +95,11 @@ class ListController extends AbstractAction @@ -97,9 +95,11 @@ class ListController extends AbstractAction
97 $query = $this->get('query', null); 95 $query = $this->get('query', null);
98 $brand = $this->get('brand', null); 96 $brand = $this->get('brand', null);
99 $gender = $this->get('gender', null); 97 $gender = $this->get('gender', null);
100 - $p_d = $this->get('p_d', null);  
101 - $misort = $this->get('misort', null);  
102 - $msort = $this->get('msort', null); 98 + $color = $this->get('color', null);
  99 + $size = $this->get('size', null);
  100 + $price = $this->get('price', null);
  101 + $p_d = $this->get('discount', null);
  102 + $sort = $this->get('msort', null);
103 103
104 // 转换性别 104 // 转换性别
105 if($gender === 'boys') 105 if($gender === 'boys')
@@ -115,7 +115,6 @@ class ListController extends AbstractAction @@ -115,7 +115,6 @@ class ListController extends AbstractAction
115 $gender = '1,2,3'; 115 $gender = '1,2,3';
116 } 116 }
117 117
118 -  
119 // 转换排序方式 118 // 转换排序方式
120 $order = $this->get('order', null); 119 $order = $this->get('order', null);
121 $type = $this->get('type', ''); 120 $type = $this->get('type', '');
@@ -134,7 +133,7 @@ class ListController extends AbstractAction @@ -134,7 +133,7 @@ class ListController extends AbstractAction
134 133
135 $data = array(); 134 $data = array();
136 // 查询数据 135 // 查询数据
137 - $listData = SearchData::searchLiDatas($query, $brand, $gender, $p_d, $misort, $msort, $order); 136 + $listData = SearchData::searchLiDatas($query, $brand, $gender, $color, $size, $price, $p_d, $sort, $order);
138 // 处理返回的数据 137 // 处理返回的数据
139 if (isset($listData['code']) && $listData['code'] === 200) { 138 if (isset($listData['code']) && $listData['code'] === 200) {
140 $tmpData = $listData['data']; 139 $tmpData = $listData['data'];
@@ -166,7 +165,7 @@ class ListController extends AbstractAction @@ -166,7 +165,7 @@ class ListController extends AbstractAction
166 $color = $this->get('color', null); 165 $color = $this->get('color', null);
167 $size = $this->get('size', null); 166 $size = $this->get('size', null);
168 $price = $this->get('price', null); 167 $price = $this->get('price', null);
169 - $p_d = $this->get('p_d', null); 168 + $p_d = $this->get('discount', null);
170 169
171 $data = array( 170 $data = array(
172 'pageHeader' => array( 171 'pageHeader' => array(
@@ -230,7 +229,7 @@ class ListController extends AbstractAction @@ -230,7 +229,7 @@ class ListController extends AbstractAction
230 $color = $this->get('color', null); 229 $color = $this->get('color', null);
231 $size = $this->get('size', null); 230 $size = $this->get('size', null);
232 $price = $this->get('price', null); 231 $price = $this->get('price', null);
233 - $p_d = $this->get('p_d', null); 232 + $p_d = $this->get('discount', null);
234 233
235 $data = array( 234 $data = array(
236 'pageHeader' => array( 235 'pageHeader' => array(
@@ -245,8 +244,7 @@ class ListController extends AbstractAction @@ -245,8 +244,7 @@ class ListController extends AbstractAction
245 'sort' => $sort, 244 'sort' => $sort,
246 'price' => 0, 245 'price' => 0,
247 'size' => 0, 246 'size' => 0,
248 - 'discount' => '',  
249 - 'p_d' => '' 247 + 'discount' => ''
250 ) 248 )
251 ); 249 );
252 250
@@ -32,6 +32,16 @@ class NewsaleController extends AbstractAction @@ -32,6 +32,16 @@ class NewsaleController extends AbstractAction
32 if (!empty($goodsList)) { 32 if (!empty($goodsList)) {
33 $data += $goodsList; 33 $data += $goodsList;
34 } 34 }
  35 + // 设置一些筛选的默认参数
  36 + $data += array(
  37 + 'brand' => 0,
  38 + 'sort' => 0,
  39 + 'gender' => $this->getCookie('_Channel', 'boys'),
  40 + 'price' => 0,
  41 + 'size' => 0,
  42 + 'dayLimit' => 1,
  43 + 'discount' => ''
  44 + );
35 45
36 $this->_view->display('new', $data); 46 $this->_view->display('new', $data);
37 } 47 }
@@ -58,19 +68,33 @@ class NewsaleController extends AbstractAction @@ -58,19 +68,33 @@ class NewsaleController extends AbstractAction
58 if (!empty($goodsList)) { 68 if (!empty($goodsList)) {
59 $data += $goodsList; 69 $data += $goodsList;
60 } 70 }
  71 + // 设置一些筛选的默认参数
  72 + $data += array(
  73 + 'brand' => 0,
  74 + 'sort' => 0,
  75 + 'gender' => $this->getCookie('_Channel', 'boys'),
  76 + 'price' => 0,
  77 + 'size' => 0,
  78 + 'dayLimit' => 1,
  79 + 'discount' => '0.1,0.3'
  80 + );
61 $data['tabs'] = array( 81 $data['tabs'] = array(
62 array( 82 array(
63 'title' => '1-3折', 83 'title' => '1-3折',
  84 + 'dataId' => '0.1,0.3',
64 'focus' => true 85 'focus' => true
65 ), 86 ),
66 array( 87 array(
67 - 'title' => '4-6折' 88 + 'title' => '4-6折',
  89 + 'dataId' => '0.4,0.6',
68 ), 90 ),
69 array( 91 array(
70 - 'title' => '7-9折' 92 + 'title' => '7-9折',
  93 + 'dataId' => '0.7,0.9',
71 ), 94 ),
72 array( 95 array(
73 - 'title' => 'ALL' 96 + 'title' => 'ALL',
  97 + 'dataId' => '0.1,0.9',
74 ) 98 )
75 ); 99 );
76 100
@@ -97,12 +121,25 @@ class NewsaleController extends AbstractAction @@ -97,12 +121,25 @@ class NewsaleController extends AbstractAction
97 $limit = $this->get('limit', 20); 121 $limit = $this->get('limit', 20);
98 $page = $this->get('page', 1); 122 $page = $this->get('page', 1);
99 123
  124 + // 转换性别
  125 + if($gender === 'boys')
  126 + {
  127 + $gender = '1,3';
  128 + }
  129 + elseif($gender === 'girls')
  130 + {
  131 + $gender = '2,3';
  132 + }
  133 + else
  134 + {
  135 + $gender = '1,2,3';
  136 + }
100 137
101 $data = NewsaleData::selectNewSaleProducts( 138 $data = NewsaleData::selectNewSaleProducts(
102 $gender, $brand, $sort, $color, 139 $gender, $brand, $sort, $color,
103 $size, $price, $p_d, $channel, $dayLimit, $limit, $page 140 $size, $price, $p_d, $channel, $dayLimit, $limit, $page
104 ); 141 );
105 - $result = NewSaleProcess::selectData($data); 142 + $result = \Product\NewsaleModel::selectData($data);
106 143
107 $this->_view->display('product', $result); 144 $this->_view->display('product', $result);
108 } else { 145 } else {