Authored by Rock Zhang

修改新品到着筛选有关的bug

@@ -38,11 +38,12 @@ class NewsaleData @@ -38,11 +38,12 @@ class NewsaleData
38 * 38 *
39 * @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部 39 * @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
40 * @param string $channel 1表示男, 2表示女 40 * @param string $channel 1表示男, 2表示女
41 - * @param integer $limit 查询返回的最大限制数, 默认为50 41 + * @param string $order 排序方式,默认s_t_desc表示按照时间倒序排列
  42 + * @param integer $limit 查询返回的最大限制数, 默认为60
42 * @param integer $page 分页第几页, 默认第1页 43 * @param integer $page 分页第几页, 默认第1页
43 * @return array 新品到着商品数据 44 * @return array 新品到着商品数据
44 */ 45 */
45 - public static function getNewProducts($gender, $channel, $limit = 50, $page = 1) 46 + public static function getNewProducts($gender, $channel, $order = 's_t_desc', $limit = 60, $page = 1)
46 { 47 {
47 // 构建url地址列表 48 // 构建url地址列表
48 $urlList = array(); 49 $urlList = array();
@@ -50,6 +51,7 @@ class NewsaleData @@ -50,6 +51,7 @@ class NewsaleData
50 $param = Yohobuy::param(); 51 $param = Yohobuy::param();
51 $param['method'] = 'app.search.newProduct'; 52 $param['method'] = 'app.search.newProduct';
52 $param['gender'] = $gender; 53 $param['gender'] = $gender;
  54 + $param['order'] = $order;
53 $param['page'] = $page; 55 $param['page'] = $page;
54 $param['limit'] = $limit; 56 $param['limit'] = $limit;
55 $param['yh_channel'] = $channel; 57 $param['yh_channel'] = $channel;
@@ -89,9 +91,11 @@ class NewsaleData @@ -89,9 +91,11 @@ class NewsaleData
89 * @param integer $dayLimit 限制读取多少天,默认为1天 91 * @param integer $dayLimit 限制读取多少天,默认为1天
90 * @param integer $limit 查询返回的最大限制数, 默认为50 92 * @param integer $limit 查询返回的最大限制数, 默认为50
91 * @param integer $page 分页第几页, 默认第1页 93 * @param integer $page 分页第几页, 默认第1页
  94 + * @param string $order 排序方式,默认s_t_desc表示按照时间倒序排列
  95 + *
92 * @return array 根据指定条件筛选出来的商品 96 * @return array 根据指定条件筛选出来的商品
93 */ 97 */
94 - public static function selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit = null, $limit = 50, $page = 1) 98 + public static function selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit = null, $limit = 60, $page = 1, $order = 's_t_desc')
95 { 99 {
96 $selectItems = array( 100 $selectItems = array(
97 'gender' => $gender, 101 'gender' => $gender,
@@ -112,6 +116,7 @@ class NewsaleData @@ -112,6 +116,7 @@ class NewsaleData
112 $param['method'] = 'app.search.newProduct'; 116 $param['method'] = 'app.search.newProduct';
113 $param['page'] = $page; 117 $param['page'] = $page;
114 $param['limit'] = $limit; 118 $param['limit'] = $limit;
  119 + $param['order'] = $order;
115 $param['yh_channel'] = $channel; 120 $param['yh_channel'] = $channel;
116 $param = array_merge($param, $queriedParams); 121 $param = array_merge($param, $queriedParams);
117 122
@@ -146,7 +146,7 @@ class FloorProcess @@ -146,7 +146,7 @@ class FloorProcess
146 $build = array(); 146 $build = array();
147 foreach ($data['list'] as $one) { 147 foreach ($data['list'] as $one) {
148 $build['url'] = Helpers::getFilterUrl($one['url']); 148 $build['url'] = Helpers::getFilterUrl($one['url']);
149 - $build['img'] = Helpers::getImageUrl($one['src'], 140, 140); 149 + $build['img'] = Helpers::getImageUrl($one['src'], 128, 140);
150 $build['textCn'] = $one['title']; 150 $build['textCn'] = $one['title'];
151 $result['hotCategory']['list'][] = $build; 151 $result['hotCategory']['list'][] = $build;
152 } 152 }
@@ -156,9 +156,9 @@ class ListProcess @@ -156,9 +156,9 @@ class ListProcess
156 ) 156 )
157 ); 157 );
158 158
159 - foreach ($data as $one) { 159 + foreach ($data as $key => $one) {
160 $discount = array(); 160 $discount = array();
161 - $discount['dataId'] = $one['count']; 161 + $discount['dataId'] = $key;
162 $discount['name'] = $one['name'] .'折商品'; 162 $discount['name'] = $one['name'] .'折商品';
163 163
164 $result['subs'][] = $discount; 164 $result['subs'][] = $discount;
@@ -20,22 +20,20 @@ class NewsaleController extends AbstractAction @@ -20,22 +20,20 @@ class NewsaleController extends AbstractAction
20 $this->setTitle('新品到着'); 20 $this->setTitle('新品到着');
21 $this->setNavHeader('新品到着'); 21 $this->setNavHeader('新品到着');
22 22
23 - $channel = $this->get('channel', 1);  
24 - if (!is_numeric($channel)) {  
25 - $this->error();  
26 - } 23 + $channel = $this->getCookie('_Channel', 'boys');
  24 + $this->channelTrans($channel);
27 25
28 $data = array(); 26 $data = array();
29 $data['newArrival'] = true; 27 $data['newArrival'] = true;
30 $data['headerBanner'] = \Product\NewsaleModel::getNewFocus($channel); 28 $data['headerBanner'] = \Product\NewsaleModel::getNewFocus($channel);
31 - $goodsList = \Product\NewsaleModel::getNewProducts($channel, 20); 29 + $goodsList = \Product\NewsaleModel::getNewProducts($channel, 60);
32 if (!empty($goodsList)) { 30 if (!empty($goodsList)) {
33 $data += $goodsList; 31 $data += $goodsList;
34 } 32 }
35 // 设置一些筛选的默认参数 33 // 设置一些筛选的默认参数
36 $data += array( 34 $data += array(
37 'brand' => 0, 35 'brand' => 0,
38 - 'sort' => 0, 36 + 'msort' => 0,
39 'gender' => $this->getCookie('_Channel', 'boys'), 37 'gender' => $this->getCookie('_Channel', 'boys'),
40 'price' => 0, 38 'price' => 0,
41 'size' => 0, 39 'size' => 0,
@@ -56,10 +54,8 @@ class NewsaleController extends AbstractAction @@ -56,10 +54,8 @@ class NewsaleController extends AbstractAction
56 $this->setTitle('折扣专区'); 54 $this->setTitle('折扣专区');
57 $this->setNavHeader('Sale'); 55 $this->setNavHeader('Sale');
58 56
59 - $channel = $this->get('channel', 1);  
60 - if (!is_numeric($channel)) {  
61 - $this->error();  
62 - } 57 + $channel = $this->getCookie('_Channel', 'boys');
  58 + $this->channelTrans($channel);
63 59
64 $data = array(); 60 $data = array();
65 $data['discount'] = true; 61 $data['discount'] = true;
@@ -71,7 +67,7 @@ class NewsaleController extends AbstractAction @@ -71,7 +67,7 @@ class NewsaleController extends AbstractAction
71 // 设置一些筛选的默认参数 67 // 设置一些筛选的默认参数
72 $data += array( 68 $data += array(
73 'brand' => 0, 69 'brand' => 0,
74 - 'sort' => 0, 70 + 'msort' => 0,
75 'gender' => $this->getCookie('_Channel', 'boys'), 71 'gender' => $this->getCookie('_Channel', 'boys'),
76 'price' => 0, 72 'price' => 0,
77 'size' => 0, 73 'size' => 0,
@@ -109,16 +105,16 @@ class NewsaleController extends AbstractAction @@ -109,16 +105,16 @@ class NewsaleController extends AbstractAction
109 public function selectNewSaleAction() 105 public function selectNewSaleAction()
110 { 106 {
111 if ($this->isAjax()) { 107 if ($this->isAjax()) {
112 - $gender = $this->get('gender', '1,3'); 108 + $gender = $this->get('gender', 'boys');
113 $brand = $this->get('brand', null); 109 $brand = $this->get('brand', null);
114 - $sort = $this->get('sort', null); 110 + $sort = $this->get('msort', null);
115 $color = $this->get('color', null); 111 $color = $this->get('color', null);
116 $size = $this->get('size', null); 112 $size = $this->get('size', null);
117 $price = $this->get('price', null); 113 $price = $this->get('price', null);
118 - $p_d = $this->get('p_d', null);  
119 - $channel = $this->get('channel', '1'); 114 + $p_d = $this->get('discount', null);
  115 + $channel = $this->getCookie('_Channel', 'boys');
120 $dayLimit = $this->get('dayLimit', '1'); 116 $dayLimit = $this->get('dayLimit', '1');
121 - $limit = $this->get('limit', 20); 117 + $limit = $this->get('limit', 60);
122 $page = $this->get('page', 1); 118 $page = $this->get('page', 1);
123 119
124 // 转换性别 120 // 转换性别
@@ -135,6 +131,9 @@ class NewsaleController extends AbstractAction @@ -135,6 +131,9 @@ class NewsaleController extends AbstractAction
135 $gender = '1,2,3'; 131 $gender = '1,2,3';
136 } 132 }
137 133
  134 + // 转换频道
  135 + $this->channelTrans($channel);
  136 +
138 $data = NewsaleData::selectNewSaleProducts( 137 $data = NewsaleData::selectNewSaleProducts(
139 $gender, $brand, $sort, $color, 138 $gender, $brand, $sort, $color,
140 $size, $price, $p_d, $channel, $dayLimit, $limit, $page 139 $size, $price, $p_d, $channel, $dayLimit, $limit, $page
@@ -154,4 +153,28 @@ class NewsaleController extends AbstractAction @@ -154,4 +153,28 @@ class NewsaleController extends AbstractAction
154 } 153 }
155 } 154 }
156 155
  156 + /**
  157 + * 转换频道
  158 + * @param string &$channel 待转换的频道
  159 + * @return integer 转换之后的频道
  160 + */
  161 + private function channelTrans(&$channel)
  162 + {
  163 + switch ($channel) {
  164 + case 'girls':
  165 + $channel = 2;
  166 + break;
  167 + case 'kids':
  168 + $channel = 3;
  169 + break;
  170 + case 'lifestyle':
  171 + $channel = 4;
  172 + break;
  173 + case 'boys':
  174 + default:
  175 + $channel = 1;
  176 + break;
  177 + }
  178 + }
  179 +
157 } 180 }