Authored by xuqi

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

1 <?php 1 <?php
2 2
3 namespace Plugin\DataProcess; 3 namespace Plugin\DataProcess;
4 -  
5 use Plugin\Helpers; 4 use Plugin\Helpers;
6 5
7 /** 6 /**
@@ -18,9 +17,10 @@ class ListProcess @@ -18,9 +17,10 @@ class ListProcess
18 */ 17 */
19 public static function getListData($data, $returnFilter = true) 18 public static function getListData($data, $returnFilter = true)
20 { 19 {
21 - $result = array('new' => array(), 'filter' => array()); 20 + $result = array();
22 21
23 - if (isset($data['product_list'])) { 22 + if(isset($data['product_list']))
  23 + {
24 $result['new'] = self::getProductData($data['product_list']); 24 $result['new'] = self::getProductData($data['product_list']);
25 } 25 }
26 if ($returnFilter && isset($data['filter'])) { 26 if ($returnFilter && isset($data['filter'])) {
@@ -28,6 +28,7 @@ class ListProcess @@ -28,6 +28,7 @@ class ListProcess
28 } 28 }
29 29
30 return $result; 30 return $result;
  31 +
31 } 32 }
32 33
33 /** 34 /**
@@ -46,34 +47,40 @@ class ListProcess @@ -46,34 +47,40 @@ class ListProcess
46 } 47 }
47 48
48 return $products; 49 return $products;
  50 +
49 } 51 }
50 52
51 /** 53 /**
52 * 处理筛选数据 54 * 处理筛选数据
53 * 55 *
54 * @param $data 56 * @param $data
  57 + * @param string | integer $gender 默认选择的性别,默认1,2,3表示所有
55 * @return array 处理之后的筛选数据 58 * @return array 处理之后的筛选数据
56 */ 59 */
57 - public static function getFilterData($data) 60 + public static function getFilterData($data, $gender = '1,2,3')
58 { 61 {
59 // 过滤条件数据 62 // 过滤条件数据
60 - $filters = array('classify' => array()); 63 + $filters = array('classify'=>array());
  64 +
  65 + // 返回数据中有没有gender时要添加gender
  66 + // $data['gender'] = array('2,3'=>'GIRLS','1,3'=>'BOYS');
61 67
62 $num = 1; 68 $num = 1;
63 - $build = array();  
64 foreach ($data as $key => $val) { 69 foreach ($data as $key => $val) {
65 - if (empty($val)) { 70 + if(empty($val))
  71 + {
66 continue; 72 continue;
67 } 73 }
68 if (!is_callable("self::$key")) { 74 if (!is_callable("self::$key")) {
69 continue; 75 continue;
70 } 76 }
71 - $build = self::$key($val);  
72 - if ($num === 1) { 77 + $build = self::$key($val, $gender);
  78 + if($num === 1)
  79 + {
73 $build['active'] = true; 80 $build['active'] = true;
74 } 81 }
75 82
76 - $num ++; 83 + $num++;
77 $filters['classify'][] = $build; 84 $filters['classify'][] = $build;
78 } 85 }
79 86
@@ -81,6 +88,7 @@ class ListProcess @@ -81,6 +88,7 @@ class ListProcess
81 self::sortArrByField($filters['classify'], 'sort_col'); 88 self::sortArrByField($filters['classify'], 'sort_col');
82 89
83 return $filters; 90 return $filters;
  91 +
84 } 92 }
85 93
86 private static function brand($data) 94 private static function brand($data)
@@ -159,7 +167,7 @@ class ListProcess @@ -159,7 +167,7 @@ class ListProcess
159 foreach ($data as $key => $one) { 167 foreach ($data as $key => $one) {
160 $discount = array(); 168 $discount = array();
161 $discount['dataId'] = $key; 169 $discount['dataId'] = $key;
162 - $discount['name'] = $one['name'] . '折商品'; 170 + $discount['name'] = $one['name'] .'折商品';
163 171
164 $result['subs'][] = $discount; 172 $result['subs'][] = $discount;
165 } 173 }
@@ -167,7 +175,7 @@ class ListProcess @@ -167,7 +175,7 @@ class ListProcess
167 return $result; 175 return $result;
168 } 176 }
169 177
170 - private static function gender($data) 178 + private static function gender($data, $gender)
171 { 179 {
172 $result = array( 180 $result = array(
173 'title' => '性别', 181 'title' => '性别',
@@ -176,8 +184,7 @@ class ListProcess @@ -176,8 +184,7 @@ class ListProcess
176 'dataType' => 'gender', 184 'dataType' => 'gender',
177 'subs' => array( 185 'subs' => array(
178 array( 186 array(
179 - 'chosed' => true,  
180 - 'dataId' => 0, 187 + 'dataId' => '1,2,3',
181 'name' => '所有性别' 188 'name' => '所有性别'
182 ), 189 ),
183 array( 190 array(
@@ -191,6 +198,11 @@ class ListProcess @@ -191,6 +198,11 @@ class ListProcess
191 ) 198 )
192 ); 199 );
193 200
  201 + // 处理选中状态
  202 + foreach ($result['subs'] as &$val) {
  203 + $val['dataId'] === $gender && $val['chosed'] = true;
  204 + }
  205 +
194 return $result; 206 return $result;
195 } 207 }
196 208
@@ -215,18 +227,18 @@ class ListProcess @@ -215,18 +227,18 @@ class ListProcess
215 $category['dataId'] = isset($one['relation_parameter']) ? $one['relation_parameter']['sort'] : 0; 227 $category['dataId'] = isset($one['relation_parameter']) ? $one['relation_parameter']['sort'] : 0;
216 $category['name'] = $one['category_name']; 228 $category['name'] = $one['category_name'];
217 229
218 - /* // 子品类(目前h5不支持二级)  
219 - if(isset($one['sub']))  
220 - {  
221 - $category['subs'] = array();  
222 - foreach ($one['sub'] as $single) {  
223 - $subitem = array();  
224 - $subitem['dataId'] = $single['category_id'];  
225 - $subitem['name'] = $single['category_name']; 230 + /*// 子品类(目前h5不支持二级)
  231 + if(isset($one['sub']))
  232 + {
  233 + $category['subs'] = array();
  234 + foreach ($one['sub'] as $single) {
  235 + $subitem = array();
  236 + $subitem['dataId'] = $single['category_id'];
  237 + $subitem['name'] = $single['category_name'];
226 238
227 - $category['subs'][] = $subitem;  
228 - }  
229 - } */ 239 + $category['subs'][] = $subitem;
  240 + }
  241 + }*/
230 242
231 $result['subs'][] = $category; 243 $result['subs'][] = $category;
232 } 244 }
@@ -279,7 +291,7 @@ class ListProcess @@ -279,7 +291,7 @@ class ListProcess
279 291
280 foreach ($data as $one) { 292 foreach ($data as $one) {
281 $size = array(); 293 $size = array();
282 - $size['dataId'] = $one['size_id']; 294 + $size['dataId'] = $one['size_id'];
283 $size['name'] = $one['size_name']; 295 $size['name'] = $one['size_name'];
284 296
285 $result['subs'][] = $size; 297 $result['subs'][] = $size;
@@ -295,8 +307,7 @@ class ListProcess @@ -295,8 +307,7 @@ class ListProcess
295 * @param string $field 字段名称 307 * @param string $field 字段名称
296 * @param boolean $desc 时候降序排列,默认为false 308 * @param boolean $desc 时候降序排列,默认为false
297 */ 309 */
298 - private static function sortArrByField(&$array, $field, $desc = false)  
299 - { 310 + private static function sortArrByField(&$array, $field, $desc = false){
300 $fieldArr = array(); 311 $fieldArr = array();
301 foreach ($array as $k => $v) { 312 foreach ($array as $k => $v) {
302 $fieldArr[$k] = $v[$field]; 313 $fieldArr[$k] = $v[$field];
@@ -304,5 +315,4 @@ class ListProcess @@ -304,5 +315,4 @@ class ListProcess
304 $sort = $desc == false ? SORT_ASC : SORT_DESC; 315 $sort = $desc == false ? SORT_ASC : SORT_DESC;
305 array_multisort($fieldArr, $sort, $array); 316 array_multisort($fieldArr, $sort, $array);
306 } 317 }
307 -  
308 } 318 }
@@ -161,7 +161,7 @@ class Helpers @@ -161,7 +161,7 @@ class Helpers
161 break; 161 break;
162 case 'newest': 162 case 'newest':
163 default: 163 default:
164 - $result = ($order == 0) ? 's_t_desc' : 's_t_asc'; 164 + $result = ($order == 1) ? 's_t_desc' : 's_t_asc';
165 break; 165 break;
166 } 166 }
167 167
@@ -57,6 +57,8 @@ class BoysController extends AbstractAction @@ -57,6 +57,8 @@ class BoysController extends AbstractAction
57 57
58 $this->echoJson($bottomBanner); 58 $this->echoJson($bottomBanner);
59 } while (false); 59 } while (false);
  60 +
  61 + echo ' ';
60 } 62 }
61 63
62 } 64 }
@@ -53,6 +53,8 @@ class GirlsController extends AbstractAction @@ -53,6 +53,8 @@ class GirlsController extends AbstractAction
53 $this->echoJson($bottomBanner); 53 $this->echoJson($bottomBanner);
54 54
55 } while (false); 55 } while (false);
  56 +
  57 + echo ' ';
56 } 58 }
57 59
58 } 60 }
1 <?php 1 <?php
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 -use LibModels\Wap\Product\SearchData; 4 +// use LibModels\Wap\Product\SearchData;
5 use Plugin\DataProcess\ListProcess; 5 use Plugin\DataProcess\ListProcess;
6 use Plugin\Helpers; 6 use Plugin\Helpers;
7 7
@@ -94,8 +94,7 @@ class SearchController extends AbstractAction @@ -94,8 +94,7 @@ class SearchController extends AbstractAction
94 if ($domain !== null) { 94 if ($domain !== null) {
95 $url = Helpers::url('', array( 95 $url = Helpers::url('', array(
96 'from' => 'search', 96 'from' => 'search',
97 - 'query' => $query,  
98 - 'gender' => $condition['gender'] 97 + 'query' => $query
99 ), $domain); 98 ), $domain);
100 $this->go($url); 99 $this->go($url);
101 } 100 }
@@ -271,23 +270,22 @@ class SearchController extends AbstractAction @@ -271,23 +270,22 @@ class SearchController extends AbstractAction
271 'gender' => FILTER_DEFAULT, 270 'gender' => FILTER_DEFAULT,
272 'p_d' => FILTER_DEFAULT,), false); 271 'p_d' => FILTER_DEFAULT,), false);
273 272
  273 + // 转义分类
274 if (isset($condition['sort'])) { 274 if (isset($condition['sort'])) {
275 $condition['sort'] = rawurldecode($condition['sort']); 275 $condition['sort'] = rawurldecode($condition['sort']);
276 } 276 }
  277 + // 转换折扣
277 if (isset($condition['discount'])) { 278 if (isset($condition['discount'])) {
278 $condition['p_d'] = rawurldecode($condition['discount']); 279 $condition['p_d'] = rawurldecode($condition['discount']);
279 unset($condition['discount']); 280 unset($condition['discount']);
280 } 281 }
  282 + // 转义性别
281 if (isset($condition['gender'])) { 283 if (isset($condition['gender'])) {
282 $condition['gender'] = rawurldecode($condition['gender']); 284 $condition['gender'] = rawurldecode($condition['gender']);
283 } 285 }
284 286
285 - $listData = SearchData::searchByCondition($condition);  
286 - // 处理返回的数据  
287 - if (isset($listData['data']) && isset($listData['data']['filter'])) {  
288 - $data['filter'] = ListProcess::getFilterData($listData['data']['filter']);  
289 - }  
290 - $listData = array(); 287 + // 区别各种列表页面的筛选数据
  288 + $data = Product\FilterModel::getFilterData($condition);
291 } 289 }
292 290
293 if (empty($data)) { 291 if (empty($data)) {
@@ -302,7 +300,7 @@ class SearchController extends AbstractAction @@ -302,7 +300,7 @@ class SearchController extends AbstractAction
302 * 300 *
303 * @return array 模糊搜索的结果 301 * @return array 模糊搜索的结果
304 */ 302 */
305 - public function fuzzysearch() 303 + /*public function fuzzysearch()
306 { 304 {
307 if ($this->isAjax()) { 305 if ($this->isAjax()) {
308 $keyword = $this->post('keyword', ''); 306 $keyword = $this->post('keyword', '');
@@ -311,6 +309,6 @@ class SearchController extends AbstractAction @@ -311,6 +309,6 @@ class SearchController extends AbstractAction
311 309
312 $this->echoJson($result); 310 $this->echoJson($result);
313 } 311 }
314 - } 312 + }*/
315 313
316 } 314 }
  1 +<?php
  2 +
  3 +namespace Product;
  4 +
  5 +use Configs\CacheConfig;
  6 +use LibModels\Wap\Product\SearchData;
  7 +use LibModels\Wap\Category\BrandData;
  8 +use LibModels\Wap\Category\ClassData;
  9 +use Plugin\DataProcess\ListProcess;
  10 +
  11 +/**
  12 + * 搜索相关的模板数据模型
  13 + *
  14 + * @name Filter
  15 + * @package Product
  16 + * @copyright yoho.inc
  17 + * @version 1.0 (2015-11-1 17:35:52)
  18 + */
  19 +class FilterModel
  20 +{
  21 +
  22 + /**
  23 + * 获取筛选的数据
  24 + *
  25 + * @param array $condition 查询条件
  26 + * @return array
  27 + */
  28 + public static function getFilterData($condition)
  29 + {
  30 + $result = array();
  31 +
  32 + // 区别各种列表页面的筛选数据
  33 + if (isset($condition['brand'])) {
  34 + $listData = BrandData::filterBrandData($condition);
  35 + } else if(isset($condition['sort'])) {
  36 + $listData = ClassData::filterClassData($condition);
  37 + } else {
  38 + $listData = SearchData::searchByCondition($condition);
  39 + }
  40 +
  41 + if (isset($listData['data']) && isset($listData['data']['filter'])) {
  42 + $result['filter'] = ListProcess::getFilterData($listData['data']['filter']);
  43 + }
  44 +
  45 + return $result;
  46 + }
  47 +
  48 +}
@@ -224,15 +224,16 @@ class NewsaleModel @@ -224,15 +224,16 @@ class NewsaleModel
224 /** 224 /**
225 * 获取筛选数据 225 * 获取筛选数据
226 * @param array $data 接口返回的数据 226 * @param array $data 接口返回的数据
  227 + * @param string $gender 默认选择的性别,默认1,2,3表示所有
227 * @return array 处理之后的数据 228 * @return array 处理之后的数据
228 */ 229 */
229 - public static function filterData($data) 230 + public static function filterData($data, $gender = '1,2,3')
230 { 231 {
231 $result = array(); 232 $result = array();
232 233
233 /* 格式化筛选数据 */ 234 /* 格式化筛选数据 */
234 if (isset($data['code']) && $data['code'] == 200 && isset($data['data']['filter'])) { 235 if (isset($data['code']) && $data['code'] == 200 && isset($data['data']['filter'])) {
235 - $result['filter'] = ListProcess::getFilterData($data['data']['filter']); 236 + $result['filter'] = ListProcess::getFilterData($data['data']['filter'], $gender);
236 } 237 }
237 238
238 return $result; 239 return $result;
@@ -117,6 +117,8 @@ class IndexController extends AbstractAction @@ -117,6 +117,8 @@ class IndexController extends AbstractAction
117 117
118 if (isset($condition['gender'])) { 118 if (isset($condition['gender'])) {
119 $condition['gender'] = rawurldecode($condition['gender']); 119 $condition['gender'] = rawurldecode($condition['gender']);
  120 + } else {
  121 + $condition['gender'] = Helpers::getGenderByCookie();
120 } 122 }
121 123
122 $data = array(); 124 $data = array();
@@ -54,7 +54,7 @@ class NewsaleController extends AbstractAction @@ -54,7 +54,7 @@ class NewsaleController extends AbstractAction
54 // 设置一些默认参数 54 // 设置一些默认参数
55 $data = array( 55 $data = array(
56 'discountPage' => true, 56 'discountPage' => true,
57 - 'headerBanner' => \Product\NewsaleModel::getNewFocus($channel), 57 + 'headerBanner' => \Product\NewsaleModel::getSaleFocus($channel),
58 'showDownloadApp' => true, 58 'showDownloadApp' => true,
59 'pageFooter' => true, 59 'pageFooter' => true,
60 'brand' => '0', 60 'brand' => '0',
@@ -142,7 +142,7 @@ class NewsaleController extends AbstractAction @@ -142,7 +142,7 @@ class NewsaleController extends AbstractAction
142 $data = NewsaleData::selectNewSaleProducts( 142 $data = NewsaleData::selectNewSaleProducts(
143 $gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page, $order 143 $gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page, $order
144 ); 144 );
145 - $result = \Product\NewsaleModel::filterData($data); 145 + $result = \Product\NewsaleModel::filterData($data, $gender);
146 } 146 }
147 147
148 if (empty($result)) { 148 if (empty($result)) {