Authored by 郭成尧

shopId问题解决

1 <?php 1 <?php
2 2
3 use Action\AbstractAction; 3 use Action\AbstractAction;
4 -// use LibModels\Wap\Product\SearchData;  
5 -// use Plugin\DataProcess\ListProcess; 4 +use LibModels\Wap\Product\SearchData;
  5 +use Plugin\DataProcess\ListProcess;
6 use Plugin\Helpers; 6 use Plugin\Helpers;
7 7
8 /** 8 /**
@@ -39,6 +39,7 @@ class SearchController extends AbstractAction @@ -39,6 +39,7 @@ class SearchController extends AbstractAction
39 'shop' => FILTER_DEFAULT, 39 'shop' => FILTER_DEFAULT,
40 'categoryId' => FILTER_DEFAULT, 40 'categoryId' => FILTER_DEFAULT,
41 'subCategoryId' => FILTER_DEFAULT, 41 'subCategoryId' => FILTER_DEFAULT,
  42 + 'title' => FILTER_DEFAULT,
42 'query' => FILTER_DEFAULT, 43 'query' => FILTER_DEFAULT,
43 'brand' => FILTER_DEFAULT, 44 'brand' => FILTER_DEFAULT,
44 'sort' => FILTER_DEFAULT, 45 'sort' => FILTER_DEFAULT,
@@ -106,9 +107,9 @@ class SearchController extends AbstractAction @@ -106,9 +107,9 @@ class SearchController extends AbstractAction
106 // 跳转到品牌商品列表页 107 // 跳转到品牌商品列表页
107 if ($domain !== null) { 108 if ($domain !== null) {
108 $url = Helpers::url('', array( 109 $url = Helpers::url('', array(
109 - 'from' => 'search',  
110 - 'query' => $query  
111 - ), $domain); 110 + 'from' => 'search',
  111 + 'query' => $query
  112 + ), $domain);
112 $this->go($url); 113 $this->go($url);
113 } 114 }
114 } 115 }
@@ -122,7 +123,7 @@ class SearchController extends AbstractAction @@ -122,7 +123,7 @@ class SearchController extends AbstractAction
122 if (empty($classNames)) { 123 if (empty($classNames)) {
123 break; 124 break;
124 } 125 }
125 - 126 +
126 /* 精确查一级品类 */ 127 /* 精确查一级品类 */
127 $sorts = array_keys($classNames['first'], $query, true); 128 $sorts = array_keys($classNames['first'], $query, true);
128 if (isset($sorts[0])) { 129 if (isset($sorts[0])) {
@@ -151,13 +152,11 @@ class SearchController extends AbstractAction @@ -151,13 +152,11 @@ class SearchController extends AbstractAction
151 if ($isQueryFirstClass) { 152 if ($isQueryFirstClass) {
152 $this->setTitle('全部' . $query); 153 $this->setTitle('全部' . $query);
153 $this->setNavHeader('全部' . $query, true, SITE_MAIN); 154 $this->setNavHeader('全部' . $query, true, SITE_MAIN);
154 - }  
155 - // 搜索是二级品类 155 + } // 搜索是二级品类
156 elseif ($isQuerySecondClass) { 156 elseif ($isQuerySecondClass) {
157 $this->setTitle($query); 157 $this->setTitle($query);
158 $this->setNavHeader($query, true, SITE_MAIN); 158 $this->setNavHeader($query, true, SITE_MAIN);
159 - }  
160 - // 搜索其它内容 159 + } // 搜索其它内容
161 else { 160 else {
162 $from = $this->get('from'); 161 $from = $this->get('from');
163 if ($haveQuery || $from) { 162 if ($haveQuery || $from) {
@@ -196,6 +195,11 @@ class SearchController extends AbstractAction @@ -196,6 +195,11 @@ class SearchController extends AbstractAction
196 $listData = array(); 195 $listData = array();
197 } 196 }
198 197
  198 + if($condition['title']){
  199 + $this->setTitle($condition['title']);
  200 + $this->setNavHeader($condition['title'], true, SITE_MAIN);
  201 + }
  202 +
199 $this->_view->display('list', $data); 203 $this->_view->display('list', $data);
200 } 204 }
201 205
@@ -254,8 +258,7 @@ class SearchController extends AbstractAction @@ -254,8 +258,7 @@ class SearchController extends AbstractAction
254 // 为了兼容现在运营在用的p_d 258 // 为了兼容现在运营在用的p_d
255 if (isset($condition['p_d'])) { 259 if (isset($condition['p_d'])) {
256 $condition['p_d'] = rawurldecode($condition['p_d']); 260 $condition['p_d'] = rawurldecode($condition['p_d']);
257 - }  
258 - // 转换折扣 261 + } // 转换折扣
259 elseif (isset($condition['discount'])) { 262 elseif (isset($condition['discount'])) {
260 $condition['p_d'] = rawurldecode($condition['discount']); 263 $condition['p_d'] = rawurldecode($condition['discount']);
261 unset($condition['discount']); 264 unset($condition['discount']);
@@ -345,8 +348,7 @@ class SearchController extends AbstractAction @@ -345,8 +348,7 @@ class SearchController extends AbstractAction
345 // 为了兼容现在运营在用的p_d 348 // 为了兼容现在运营在用的p_d
346 if (isset($condition['p_d'])) { 349 if (isset($condition['p_d'])) {
347 $condition['p_d'] = rawurldecode($condition['p_d']); 350 $condition['p_d'] = rawurldecode($condition['p_d']);
348 - }  
349 - // 转换折扣 351 + } // 转换折扣
350 elseif (isset($condition['discount'])) { 352 elseif (isset($condition['discount'])) {
351 $condition['p_d'] = rawurldecode($condition['discount']); 353 $condition['p_d'] = rawurldecode($condition['discount']);
352 unset($condition['discount']); 354 unset($condition['discount']);
@@ -5,6 +5,7 @@ namespace Product; @@ -5,6 +5,7 @@ namespace Product;
5 use Configs\CacheConfig; 5 use Configs\CacheConfig;
6 use LibModels\Wap\Category\ClassData; 6 use LibModels\Wap\Category\ClassData;
7 use LibModels\Wap\Category\BrandData; 7 use LibModels\Wap\Category\BrandData;
  8 +use LibModels\Wap\Product\ShopData;
8 use Plugin\DataProcess\ListProcess; 9 use Plugin\DataProcess\ListProcess;
9 use Plugin\Helpers; 10 use Plugin\Helpers;
10 use Plugin\Cache; 11 use Plugin\Cache;
@@ -12,7 +13,7 @@ use Plugin\Images; @@ -12,7 +13,7 @@ use Plugin\Images;
12 13
13 /** 14 /**
14 * 商品列表相关的模板数据模型 15 * 商品列表相关的模板数据模型
15 - * 16 + *
16 * @name ListModel 17 * @name ListModel
17 * @package models/Product 18 * @package models/Product
18 * @copyright yoho.inc 19 * @copyright yoho.inc
@@ -24,7 +25,7 @@ class ListModel @@ -24,7 +25,7 @@ class ListModel
24 25
25 /** 26 /**
26 * 获取品类商品列表数据 27 * 获取品类商品列表数据
27 - * 28 + *
28 * @param array $condition 条件 29 * @param array $condition 条件
29 * @return array | false 30 * @return array | false
30 * 31 *
@@ -57,8 +58,7 @@ class ListModel @@ -57,8 +58,7 @@ class ListModel
57 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. 58 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
58 if (empty($result)) { 59 if (empty($result)) {
59 $result = Cache::get($key, 'slave'); 60 $result = Cache::get($key, 'slave');
60 - }  
61 - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 61 + } // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
62 else { 62 else {
63 Cache::set($key, $result, 1800); // 缓存30分钟 63 Cache::set($key, $result, 1800); // 缓存30分钟
64 } 64 }
@@ -69,7 +69,7 @@ class ListModel @@ -69,7 +69,7 @@ class ListModel
69 69
70 /** 70 /**
71 * 获取品牌信息 71 * 获取品牌信息
72 - * 72 + *
73 * @param int $id 唯一的ID 73 * @param int $id 唯一的ID
74 * @param int $uid 用户ID 74 * @param int $uid 用户ID
75 * @param string $title 网站标题 75 * @param string $title 网站标题
@@ -100,7 +100,7 @@ class ListModel @@ -100,7 +100,7 @@ class ListModel
100 100
101 /** 101 /**
102 * 获取品牌商品列表数据 102 * 获取品牌商品列表数据
103 - * 103 + *
104 * @param array $condition 条件参数 104 * @param array $condition 条件参数
105 * @param string $title 网站标题 105 * @param string $title 网站标题
106 * @return array 106 * @return array
@@ -140,8 +140,7 @@ class ListModel @@ -140,8 +140,7 @@ class ListModel
140 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. 140 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
141 if (empty($result)) { 141 if (empty($result)) {
142 $result = Cache::get($key, 'slave'); 142 $result = Cache::get($key, 'slave');
143 - }  
144 - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 143 + } // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
145 else { 144 else {
146 Cache::set($key, $result, 1800); // 缓存30分钟 145 Cache::set($key, $result, 1800); // 缓存30分钟
147 } 146 }
@@ -152,7 +151,7 @@ class ListModel @@ -152,7 +151,7 @@ class ListModel
152 151
153 /** 152 /**
154 * 根据品牌ID获取品牌LOGO 153 * 根据品牌ID获取品牌LOGO
155 - * 154 + *
156 * @param int $id 品牌ID 155 * @param int $id 品牌ID
157 * @param string $title 品牌标题 156 * @param string $title 品牌标题
158 * @return array | false 157 * @return array | false
@@ -186,8 +185,7 @@ class ListModel @@ -186,8 +185,7 @@ class ListModel
186 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. 185 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
187 if (empty($result)) { 186 if (empty($result)) {
188 $result = Cache::get($key, 'slave'); 187 $result = Cache::get($key, 'slave');
189 - }  
190 - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 188 + } // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
191 else { 189 else {
192 Cache::set($key, $result); // 缓存1小时 190 Cache::set($key, $result); // 缓存1小时
193 } 191 }
@@ -198,7 +196,7 @@ class ListModel @@ -198,7 +196,7 @@ class ListModel
198 196
199 /** 197 /**
200 * 根据品牌ID获取品牌LOGO 198 * 根据品牌ID获取品牌LOGO
201 - * 199 + *
202 * @param int $id 品牌ID 200 * @param int $id 品牌ID
203 * @param string $title 品牌标题 201 * @param string $title 品牌标题
204 * @return array | false 202 * @return array | false
@@ -233,8 +231,7 @@ class ListModel @@ -233,8 +231,7 @@ class ListModel
233 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. 231 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
234 if (empty($result)) { 232 if (empty($result)) {
235 $result = Cache::get($key, 'slave'); 233 $result = Cache::get($key, 'slave');
236 - }  
237 - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 234 + } // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
238 else { 235 else {
239 Cache::set($key, $result); // 缓存1小时 236 Cache::set($key, $result); // 缓存1小时
240 } 237 }
@@ -245,7 +242,7 @@ class ListModel @@ -245,7 +242,7 @@ class ListModel
245 242
246 /** 243 /**
247 * 获取所有的品牌名称列表 244 * 获取所有的品牌名称列表
248 - * 245 + *
249 * @return array( 246 * @return array(
250 * 品牌ID => 品牌域名(domain) 247 * 品牌ID => 品牌域名(domain)
251 * ) 248 * )
@@ -284,8 +281,7 @@ class ListModel @@ -284,8 +281,7 @@ class ListModel
284 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. 281 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
285 if (empty($result)) { 282 if (empty($result)) {
286 $result = Cache::get($key, 'slave'); 283 $result = Cache::get($key, 'slave');
287 - }  
288 - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 284 + } // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
289 else { 285 else {
290 Cache::set($key, $result); 286 Cache::set($key, $result);
291 } 287 }
@@ -296,7 +292,7 @@ class ListModel @@ -296,7 +292,7 @@ class ListModel
296 292
297 /** 293 /**
298 * 获取所有的品牌名称列表 294 * 获取所有的品牌名称列表
299 - * 295 + *
300 * @return array( 296 * @return array(
301 * 品牌域名(domain) => 品牌名称(name) 297 * 品牌域名(domain) => 品牌名称(name)
302 * ) 298 * )
@@ -335,8 +331,7 @@ class ListModel @@ -335,8 +331,7 @@ class ListModel
335 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据. 331 // 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
336 if (empty($result)) { 332 if (empty($result)) {
337 $result = Cache::get($key, 'slave'); 333 $result = Cache::get($key, 'slave');
338 - }  
339 - // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存 334 + } // 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
340 else { 335 else {
341 Cache::set($key, $result); 336 Cache::set($key, $result);
342 } 337 }
@@ -347,10 +342,11 @@ class ListModel @@ -347,10 +342,11 @@ class ListModel
347 342
348 /** 343 /**
349 * @param $data 344 * @param $data
  345 + * @param $shop_id
350 * @return array 返回的处理好的数据 346 * @return array 返回的处理好的数据
351 * @author chengyao.guo 347 * @author chengyao.guo
352 */ 348 */
353 - public static function categoryData($data) 349 + public static function categoryData($data , $shop_id)
354 { 350 {
355 $result = array(); 351 $result = array();
356 $result['class'] = array(); 352 $result['class'] = array();
@@ -358,9 +354,13 @@ class ListModel @@ -358,9 +354,13 @@ class ListModel
358 foreach ($data as &$item) { 354 foreach ($data as &$item) {
359 array_push($result['class'], array('name' => $item['category_name'])); 355 array_push($result['class'], array('name' => $item['category_name']));
360 foreach ($item['sub'] as &$item2) { 356 foreach ($item['sub'] as &$item2) {
361 - $item2['url'] = Helpers::url('/search/list',array(  
362 - 'shop' => '326'  
363 - )); // tar mark 还有其他参数 357 + $item2['url'] = Helpers::url('/search/list', array(
  358 + 'shop' => $shop_id,
  359 + 'categoryId' => $item['category_id'],
  360 + 'subCategoryId' => $item2['category_id'],
  361 + 'title' => $item2['category_name'],
  362 + 'query' => $item2['category_name'],
  363 + ));
364 } 364 }
365 array_push($result['category'], array('subcategory' => $item['sub'])); 365 array_push($result['category'], array('subcategory' => $item['sub']));
366 } 366 }
@@ -371,14 +371,19 @@ class ListModel @@ -371,14 +371,19 @@ class ListModel
371 * 店铺所有品牌信息处理 371 * 店铺所有品牌信息处理
372 * @author chengyao.guo 372 * @author chengyao.guo
373 * @param $data 373 * @param $data
  374 + * @param $shop_id
374 * @return mixed 375 * @return mixed
375 */ 376 */
376 - public static function brandData($data) 377 + public static function brandData($data,$shop_id)
377 { 378 {
378 // 处理图片链接 379 // 处理图片链接
379 foreach ($data as &$item) { 380 foreach ($data as &$item) {
380 $item['brand_ico'] = Images::getImageUrl($item['brand_ico'], 0, 0); 381 $item['brand_ico'] = Images::getImageUrl($item['brand_ico'], 0, 0);
381 - $item['url'] = Helpers::url('',array(),$item['brand_domain']); 382 + $item['url'] = Helpers::url('/search/list', array(
  383 + 'shop' => $shop_id,
  384 + 'brand' => $item['brand_id'],
  385 + 'title' => $item['brand_name'],
  386 + ));
382 } 387 }
383 return $data; 388 return $data;
384 } 389 }
@@ -255,9 +255,8 @@ class IndexController extends AbstractAction @@ -255,9 +255,8 @@ class IndexController extends AbstractAction
255 $result = array(); 255 $result = array();
256 $resource = ShopData::getShopBrands($requestData['shop_id']); 256 $resource = ShopData::getShopBrands($requestData['shop_id']);
257 if($resource['code'] === 200){ 257 if($resource['code'] === 200){
258 - $result = ListModel::brandData($resource['data']); 258 + $result = ListModel::brandData($resource['data'],$requestData['shop_id']);
259 } 259 }
260 -// ShopData::debugOut($resource);  
261 if(Mobile::isMobile()){ 260 if(Mobile::isMobile()){
262 $this->setTitle('品牌'); 261 $this->setTitle('品牌');
263 }else{ 262 }else{
@@ -285,14 +284,13 @@ class IndexController extends AbstractAction @@ -285,14 +284,13 @@ class IndexController extends AbstractAction
285 $result = array(); 284 $result = array();
286 $resource = ShopData::getShopCategory($requestData['shop_id'], Helpers::getChannelByCookie(), Helpers::getGenderByCookie()); 285 $resource = ShopData::getShopCategory($requestData['shop_id'], Helpers::getChannelByCookie(), Helpers::getGenderByCookie());
287 if ($resource['code'] === 200) { 286 if ($resource['code'] === 200) {
288 - $result = ListModel::categoryData($resource['data']); 287 + $result = ListModel::categoryData($resource['data'],$requestData['shop_id']);
289 } 288 }
290 if(Mobile::isMobile()){ 289 if(Mobile::isMobile()){
291 $this->setTitle('品类'); 290 $this->setTitle('品类');
292 }else{ 291 }else{
293 $this->setNavHeader('品类', true, SITE_MAIN); 292 $this->setNavHeader('品类', true, SITE_MAIN);
294 } 293 }
295 -// ShopData::debugOut($resource);  
296 return $this->_view->display('category', array( 294 return $this->_view->display('category', array(
297 'productCategoryPage' => true, 295 'productCategoryPage' => true,
298 'content' => $result, 296 'content' => $result,
@@ -322,7 +320,6 @@ class IndexController extends AbstractAction @@ -322,7 +320,6 @@ class IndexController extends AbstractAction
322 }else{ 320 }else{
323 $this->setNavHeader('店铺简介', true, SITE_MAIN); 321 $this->setNavHeader('店铺简介', true, SITE_MAIN);
324 } 322 }
325 -// ShopData::debugOut($resource);  
326 return $this->_view->display('intro', array( 323 return $this->_view->display('intro', array(
327 'content' => $result, 324 'content' => $result,
328 )); 325 ));