Showing
4 changed files
with
172 additions
and
71 deletions
@@ -2,33 +2,33 @@ | @@ -2,33 +2,33 @@ | ||
2 | namespace LibModels\Web\Product; | 2 | namespace LibModels\Web\Product; |
3 | 3 | ||
4 | use Api\Yohobuy; | 4 | use Api\Yohobuy; |
5 | -use Api\Sign; | ||
6 | 5 | ||
7 | 6 | ||
8 | /** | 7 | /** |
9 | * 热销排行 | 8 | * 热销排行 |
10 | - * | ||
11 | - * */ | 9 | + */ |
12 | class HotrankData extends \LibModels\Wap\Product\SearchData | 10 | class HotrankData extends \LibModels\Wap\Product\SearchData |
13 | -{ | ||
14 | - const URI_HOTRANK_RES = '/operations/service/v4/resource'; | ||
15 | - const URI_HOTRANK_TAG = '/operations/api/v5/resource/get'; | 11 | +{ |
12 | + const URI_HOTRANK_TAG = 'http://test.service.api.yohobuy.com/operations/service/v1/hotranktag'; | ||
16 | 13 | ||
17 | - | ||
18 | /** | 14 | /** |
19 | - 获取热销排行 | ||
20 | - * 分类标签 | 15 | + * 获取标签 |
16 | + * $client_type 客户端类型 | ||
17 | + * $channel 频道类型 | ||
21 | */ | 18 | */ |
22 | - public static function getHotranktag($client_type = 'web',$channel = 0, $is_concurrent = true, $callback = '') | 19 | + public static function getHotranktag($client_type = 'web',$channel = 0,$is_concurrent = true) |
23 | { | 20 | { |
24 | - // 构建必传参数 | ||
25 | - $params = Yohobuy::param(); | ||
26 | - $params['client_type'] = 'web'; | ||
27 | - $params['channel'] =$channel ; | ||
28 | - $params['is_concurrent'] = true; | ||
29 | - $params['callback'] = $callback; | ||
30 | - $params['client_secret'] = Sign::getSign($params); | ||
31 | - return Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_HOTRANK_TAG, $params); | 21 | + $params = array('client_type'=>$client_type,'channel'=>$channel,'is_concurrent' => $is_concurrent); |
22 | + return Yohobuy::yarClient(self::URI_HOTRANK_TAG, 'getTag',$params); | ||
32 | } | 23 | } |
33 | 24 | ||
25 | + /** | ||
26 | + * 通过ID获取标签信息 | ||
27 | + * $id 标签ID | ||
28 | + */ | ||
29 | + public static function getTagById($id,$is_concurrent = true) | ||
30 | + { | ||
31 | + $params['id'] = $id; | ||
32 | + return Yohobuy::yarClient(self::URI_HOTRANK_TAG, 'getOneTag',$params); | ||
33 | + } | ||
34 | } | 34 | } |
@@ -834,9 +834,8 @@ class Process | @@ -834,9 +834,8 @@ class Process | ||
834 | { | 834 | { |
835 | $result = array(); | 835 | $result = array(); |
836 | $temp = array(); | 836 | $temp = array(); |
837 | - if ($data[$key]['template_name'] == 'custom_brands') | 837 | + if ($data[$key]['template_name'] == 'custom_brands' || $data[$key]['template_name'] == 'kids_brands') |
838 | { | 838 | { |
839 | - // print_r($data[$key]); | ||
840 | $result = array( | 839 | $result = array( |
841 | 'hotBrands' => array( | 840 | 'hotBrands' => array( |
842 | 'name' => '', | 841 | 'name' => '', |
@@ -856,7 +855,6 @@ class Process | @@ -856,7 +855,6 @@ class Process | ||
856 | { | 855 | { |
857 | $width = 185; | 856 | $width = 185; |
858 | $height = 86; | 857 | $height = 86; |
859 | - $type = 'lifestyle'; | ||
860 | $val['src'] = Images::getImageUrl($val['src'], $width, $height, 2); | 858 | $val['src'] = Images::getImageUrl($val['src'], $width, $height, 2); |
861 | $val['url'] = Helpers::transUrl($val['url'], $type); | 859 | $val['url'] = Helpers::transUrl($val['url'], $type); |
862 | $floor['logoBrand'][] = array( | 860 | $floor['logoBrand'][] = array( |
@@ -865,11 +863,8 @@ class Process | @@ -865,11 +863,8 @@ class Process | ||
865 | ); | 863 | ); |
866 | } | 864 | } |
867 | $floor['moreBrand'] = 'http://yohobuy.com/brands'; | 865 | $floor['moreBrand'] = 'http://yohobuy.com/brands'; |
868 | - //$floor['moreBrand'] = 'http://yohobuy.com/brands?gender=1,3&openby:yohobuy={"action":"go.list","params":{"actiontype":0,"gender":"1,3"}}'; | ||
869 | - //print_r($floor); | ||
870 | $type_key = sprintf("%s_%s", $type, $key); | 866 | $type_key = sprintf("%s_%s", $type, $key); |
871 | $cacheKey = sprintf("%s_%s", CacheConfig::KEY_INDEX_BRANDS_LIST_DATA, $type_key); | 867 | $cacheKey = sprintf("%s_%s", CacheConfig::KEY_INDEX_BRANDS_LIST_DATA, $type_key); |
872 | - //print_r($cacheKey); | ||
873 | Cache::set($cacheKey, $floor, 7200); | 868 | Cache::set($cacheKey, $floor, 7200); |
874 | $result['hotBrands']['brandUrl'] = '/common/getIndexResourceBrand?type=' . $type_key; | 869 | $result['hotBrands']['brandUrl'] = '/common/getIndexResourceBrand?type=' . $type_key; |
875 | //print_r($result['hotBrands']['brandUrl']); | 870 | //print_r($result['hotBrands']['brandUrl']); |
@@ -2,10 +2,9 @@ | @@ -2,10 +2,9 @@ | ||
2 | namespace product; | 2 | namespace product; |
3 | 3 | ||
4 | use Plugin\Images; | 4 | use Plugin\Images; |
5 | -use Plugin\Helpers; | ||
6 | -use Plugin\Cache; | ||
7 | -use Configs\CacheConfig; | ||
8 | -use LibModels\Web\Home\IndexData; | 5 | +use Api\Yohobuy; |
6 | +//use Plugin\Helpers; | ||
7 | +//use LibModels\Web\Home\IndexData; | ||
9 | use \LibModels\Web\Product\HotrankData; | 8 | use \LibModels\Web\Product\HotrankData; |
10 | use \LibModels\Web\Product\SearchData; | 9 | use \LibModels\Web\Product\SearchData; |
11 | 10 | ||
@@ -14,14 +13,14 @@ class HotrankModel { | @@ -14,14 +13,14 @@ class HotrankModel { | ||
14 | /** | 13 | /** |
15 | * 人气单品 一周热卖 | 14 | * 人气单品 一周热卖 |
16 | */ | 15 | */ |
17 | - static public function getSearchData($condition, $options) | 16 | + static public function getSearchData($param,$page,$ajax) |
18 | { | 17 | { |
19 | // 调用接口查询商品数据 | 18 | // 调用接口查询商品数据 |
20 | - $result = SearchData::searchElasticByCondition($condition); | 19 | + $result = SearchData::searchElasticByCondition($param); |
21 | //print_r($result); | 20 | //print_r($result); |
22 | 21 | ||
23 | if(!empty($result)){ | 22 | if(!empty($result)){ |
24 | - $res = self::getProductList($result); | 23 | + $res = self::getProductList($result,$page,$ajax); |
25 | if(!empty($res['popular'])){ | 24 | if(!empty($res['popular'])){ |
26 | $data['popular'] = $res['popular']; | 25 | $data['popular'] = $res['popular']; |
27 | } | 26 | } |
@@ -37,18 +36,16 @@ class HotrankModel { | @@ -37,18 +36,16 @@ class HotrankModel { | ||
37 | /** | 36 | /** |
38 | * 获取分类标签 | 37 | * 获取分类标签 |
39 | */ | 38 | */ |
40 | - static public function getHotranktag($classes) | 39 | + static public function getHotranktag($client_type,$channel,$is_concurrent) |
41 | { | 40 | { |
42 | - $list = SearchData::getClassesData($classes); | ||
43 | - //print_r($list); | 41 | + $list = \LibModels\Web\Product\HotrankData::getHotranktag($client_type,$channel,$is_concurrent); |
44 | $nav = array(); | 42 | $nav = array(); |
45 | - if(!empty($list['data']['sort'])){ | ||
46 | - foreach($list['data']['sort'] as $li=>$lt){ | ||
47 | - $nav[$li]['sid'] = $lt['sort_id']; | ||
48 | - $nav[$li]['textCn'] = $lt['sort_name']; | 43 | + if(!empty($list['data']['list'])){ |
44 | + foreach($list['data']['list'] as $li=>$lt){ | ||
45 | + $nav[$li]['sid'] = $lt['id']; | ||
46 | + $nav[$li]['textCn'] = $lt['tag_name']; | ||
49 | } | 47 | } |
50 | } | 48 | } |
51 | - //print_r($nav); | ||
52 | return $nav; | 49 | return $nav; |
53 | } | 50 | } |
54 | 51 | ||
@@ -56,8 +53,10 @@ class HotrankModel { | @@ -56,8 +53,10 @@ class HotrankModel { | ||
56 | /** | 53 | /** |
57 | * 人气单品 一周热卖 数据处理 | 54 | * 人气单品 一周热卖 数据处理 |
58 | */ | 55 | */ |
59 | - static public function getProductList($result) | 56 | + static public function getProductList($result,$page,$ajax=0) |
60 | { | 57 | { |
58 | + // 调用发起请求 | ||
59 | + Yohobuy::yarConcurrentLoop(); | ||
61 | /*----product start---------*/ | 60 | /*----product start---------*/ |
62 | if(empty($result) || empty($result['data']) || empty($result['data']['product_list'])){ | 61 | if(empty($result) || empty($result['data']) || empty($result['data']['product_list'])){ |
63 | return; | 62 | return; |
@@ -83,26 +82,35 @@ class HotrankModel { | @@ -83,26 +82,35 @@ class HotrankModel { | ||
83 | $product_id = empty($val['product_id']) ? '' : $val['product_id']; | 82 | $product_id = empty($val['product_id']) ? '' : $val['product_id']; |
84 | $re['url'] = 'http://item.yohobuy.com/product/pro_'.$product_id.'_'.$defaultGoodsId.'.html'; | 83 | $re['url'] = 'http://item.yohobuy.com/product/pro_'.$product_id.'_'.$defaultGoodsId.'.html'; |
85 | 84 | ||
86 | - $re['marketPrice'] = (int)$val['market_price'] == (int)$val['sales_price'] ? '' : '¥'.$val['market_price']; | ||
87 | - $re['salePrice'] = empty($val['sales_price']) ? '' : '¥'.$val['sales_price']; | ||
88 | - $re['name'] = $val['product_name']; | ||
89 | - if($key <= 9){ | ||
90 | - $re['rank'] = $key + 1; | ||
91 | - if($key <= 5){ | ||
92 | - $re['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 378, 504, 2); | ||
93 | - $popular['list'][] = $re; | ||
94 | - }else{ | ||
95 | - $re['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2); | ||
96 | - $popular['list'][] = $re; | ||
97 | - } | ||
98 | - }else{ | ||
99 | - $re['rank'] = ''; | ||
100 | - $re['thumb'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2); | ||
101 | - $hot[] = $re; | ||
102 | - } | 85 | + $re['name'] = $val['product_name']; |
86 | + if($key <= 9 && $page == 1 && $ajax == 0){ | ||
87 | + $re['rank'] = $key + 1; | ||
88 | + if($key <= 5){ | ||
89 | + $re['price'] = (int)$val['market_price'] == (int)$val['sales_price'] ? '' : '¥'.$val['market_price']; | ||
90 | + $re['sPrice'] = empty($val['sales_price']) ? '' : '¥'.$val['sales_price']; | ||
91 | + $re['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 378, 504, 2); | ||
92 | + $popular['list'][] = $re; | ||
93 | + }else{ | ||
94 | + $re['price'] = (int)$val['market_price'] == (int)$val['sales_price'] ? '' : '¥'.$val['market_price']; | ||
95 | + $re['sPrice'] = empty($val['sales_price']) ? '' : '¥'.$val['sales_price']; | ||
96 | + $re['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2); | ||
97 | + $popular['list'][] = $re; | ||
98 | + } | ||
99 | + }else if ($ajax == 1){ | ||
100 | + $re['marketPrice'] = (int)$val['market_price'] == (int)$val['sales_price'] ? '' : '¥'.$val['market_price']; | ||
101 | + $re['salePrice'] = empty($val['sales_price']) ? '' : '¥'.$val['sales_price']; | ||
102 | + $re['rank'] = ''; | ||
103 | + $re['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2); | ||
104 | + $hot[] = $re; | ||
105 | + }else{ | ||
106 | + $re['marketPrice'] = (int)$val['market_price'] == (int)$val['sales_price'] ? '' : '¥'.$val['market_price']; | ||
107 | + $re['salePrice'] = empty($val['sales_price']) ? '' : '¥'.$val['sales_price']; | ||
108 | + $re['rank'] = ''; | ||
109 | + $re['thumb'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2); | ||
110 | + $hot[] = $re; | ||
111 | + } | ||
103 | } | 112 | } |
104 | $popular['name'] = '人气单品'; | 113 | $popular['name'] = '人气单品'; |
105 | - | ||
106 | $hotWeek = array( | 114 | $hotWeek = array( |
107 | 'name'=>'一周热卖', | 115 | 'name'=>'一周热卖', |
108 | 'list'=>$hot, | 116 | 'list'=>$hot, |
@@ -2,12 +2,16 @@ | @@ -2,12 +2,16 @@ | ||
2 | use Action\WebAction; | 2 | use Action\WebAction; |
3 | use LibModels\Web\Product\BrandData; | 3 | use LibModels\Web\Product\BrandData; |
4 | 4 | ||
5 | -use LibModels\Web\Product\HotrankData; | 5 | +use \LibModels\Web\Product\HotrankData; |
6 | use product\HotrankModel; | 6 | use product\HotrankModel; |
7 | use LibModels\Web\Home\IndexData; | 7 | use LibModels\Web\Home\IndexData; |
8 | 8 | ||
9 | class IndexController extends WebAction | 9 | class IndexController extends WebAction |
10 | { | 10 | { |
11 | + public $channel; | ||
12 | + public $gender; | ||
13 | + public $road;//频道 | ||
14 | + public $code; | ||
11 | /** | 15 | /** |
12 | * 品牌首页 | 16 | * 品牌首页 |
13 | */ | 17 | */ |
@@ -53,7 +57,7 @@ class IndexController extends WebAction | @@ -53,7 +57,7 @@ class IndexController extends WebAction | ||
53 | } | 57 | } |
54 | 58 | ||
55 | public function hotrankAction() { | 59 | public function hotrankAction() { |
56 | - $this->setWebNavHeader(\Index\HomeModel::COOKIE_NAME_LIFESTYLE); | 60 | + |
57 | $data = array( | 61 | $data = array( |
58 | 'hotrankPage' => true, | 62 | 'hotrankPage' => true, |
59 | 'hotrank' => array( | 63 | 'hotrank' => array( |
@@ -261,30 +265,124 @@ class IndexController extends WebAction | @@ -261,30 +265,124 @@ class IndexController extends WebAction | ||
261 | ) | 265 | ) |
262 | ) | 266 | ) |
263 | ); | 267 | ); |
268 | + | ||
269 | + | ||
270 | + $cookie = $this->getCookie('_Channel'); | ||
271 | + $cookie = 'lifestyle'; | ||
272 | + $this->channel = isset($cookie) ? $cookie : 'boys'; | ||
273 | + switch ($this->channel){ | ||
274 | + case 'boys' : | ||
275 | + $this->gender = '1,3'; | ||
276 | + $this->road = 1; | ||
277 | + $this->code = '80d772d8dff25300a2a2e4c97165330c'; | ||
278 | + break; | ||
279 | + case 'girls' : | ||
280 | + $this->gender = '2,3'; | ||
281 | + $this->road = 2; | ||
282 | + $this->code = '8df64e505e94edb9881fd1e7efb702e9'; | ||
283 | + break; | ||
284 | + case 'lifestyle' : | ||
285 | + $this->gender = ''; | ||
286 | + $this->road = 4; | ||
287 | + $this->code = 'd131aba83a84a6977eee3a7403a713de'; | ||
288 | + break; | ||
289 | + case 'kids' : | ||
290 | + $this->gender = ''; | ||
291 | + $this->road = 3; | ||
292 | + $this->code = 'bd6a06a08f8ca9b0db762f78e0bc5b68'; | ||
293 | + break; | ||
294 | + | ||
295 | + } | ||
296 | + $this->setWebNavHeader(\Index\HomeModel::$this->channel); | ||
264 | $data = array( 'hotrankPage' => true, | 297 | $data = array( 'hotrankPage' => true, |
265 | 'footerTop'=> true, | 298 | 'footerTop'=> true, |
266 | 'hotrank' => array() | 299 | 'hotrank' => array() |
267 | ); | 300 | ); |
268 | //焦点图 热门品牌 | 301 | //焦点图 热门品牌 |
269 | - $focus = \Index\HomeModel::getChannelResource('lifestyle', 'd131aba83a84a6977eee3a7403a713de'); | ||
270 | - //print_r($focus); | 302 | + $focus = \Index\HomeModel::getChannelResource($this->channel, $this->code); |
271 | $data['hotrank']['slide'] = $focus[0]['slide']; | 303 | $data['hotrank']['slide'] = $focus[0]['slide']; |
272 | $data['hotrank']['hotBrands'] = $focus[1]['hotBrands']; | 304 | $data['hotrank']['hotBrands'] = $focus[1]['hotBrands']; |
273 | 305 | ||
274 | //人气单品 一周热卖 | 306 | //人气单品 一周热卖 |
275 | - $page = 1; | ||
276 | - $param = array('order'=>'s_n_desc','viewNum'=>60,'page'=>1,'stocknumber'=>1,'status'=>1,'gender'=>'','attribute_not'=>2); | ||
277 | - $publiclist = \product\HotrankModel::getSearchData($param,$page); | 307 | + $page = $this->get('page',1); |
308 | + $sort_id = $this->get('sid',0); | ||
309 | + $viewNum = 60; | ||
310 | + $param = array('order'=>'s_n_desc','viewNum'=>$viewNum,'page'=>$page,'stocknumber'=>1,'status'=>1,'gender'=>$this->gender,'attribute_not'=>2); | ||
311 | + if($sort_id != 0){ | ||
312 | + $param['sort'] = $sort_id; | ||
313 | + } | ||
314 | + if($this->road == 3){ | ||
315 | + $param['msort'] = 365; | ||
316 | + }elseif($this->road == 4){ | ||
317 | + $param['msort'] = 10; | ||
318 | + }else{ | ||
319 | + $param['not_maxSortId'] = '10,365'; | ||
320 | + } | ||
321 | + $publiclist = \product\HotrankModel::getSearchData($param,$page,0); | ||
278 | $data['hotrank']['popular'] = $publiclist['popular']; | 322 | $data['hotrank']['popular'] = $publiclist['popular']; |
279 | $data['hotrank']['hotWeek'] = $publiclist['hotWeek']; | 323 | $data['hotrank']['hotWeek'] = $publiclist['hotWeek']; |
280 | - //print_r($publiclist); | ||
281 | - | 324 | + |
282 | //分类标签 | 325 | //分类标签 |
283 | - $classes = array('gender' => 2); | ||
284 | - $nav = \product\HotrankModel::getHotranktag($classes); | ||
285 | - $data['hotrank']['hotWeek']['nav'] = $nav; | ||
286 | - //print_r($data); | 326 | + $nav = \product\HotrankModel::getHotranktag('web',$this->road,true); |
327 | + $data['hotrank']['hotWeek']['nav'] = $nav; | ||
287 | $this->_view->display('hotrank', $data); | 328 | $this->_view->display('hotrank', $data); |
288 | } | 329 | } |
330 | + | ||
331 | + /* | ||
332 | + * 一周热卖加载更多 | ||
333 | + */ | ||
334 | + public function getdataAction() | ||
335 | + { | ||
336 | + $page = $this->get('page',1); | ||
337 | + //加载到100个以后停止 | ||
338 | + if($page > 2) | ||
339 | + { | ||
340 | + echo json_encode(array('code'=>201,'data'=>'')); | ||
341 | + exit; | ||
342 | + } | ||
343 | + $sid = $this->get('sid',1); | ||
344 | + $sort = ''; | ||
345 | + //是否是默认标签 | ||
346 | + if($sid > 1) | ||
347 | + { | ||
348 | + //通过ID获取标签信息 | ||
349 | + $info = \LibModels\Web\Product\HotrankData::getTagById($sid, false); | ||
350 | + if(!empty($info['data'])) | ||
351 | + { | ||
352 | + $sort = $info['data']['category_id']; | ||
353 | + } | ||
354 | + } | ||
355 | + $viewNum = 60; | ||
356 | + //过滤掉赠品 | ||
357 | + $param = array('order'=>'s_n_desc','viewNum'=>$viewNum,'page'=>$page,'sort'=>$sort,'stocknumber'=>1,'status'=>1,'gender'=>$this->gender, | ||
358 | + 'attribute_not'=>2); | ||
359 | + if(empty($param['sort'])) | ||
360 | + { | ||
361 | + if($this->road == 3) | ||
362 | + { | ||
363 | + $param['msort'] = 365; | ||
364 | + }elseif($this->road == 4){ | ||
365 | + $param['msort'] = 10; | ||
366 | + }else{ | ||
367 | + $param['not_maxSortId'] = '10,365'; | ||
368 | + } | ||
369 | + } | ||
370 | + | ||
371 | + $list = \product\HotrankModel::getSearchData($param, $page, 1); | ||
372 | + $lister = $list['hotWeek']['list']; | ||
373 | + $lister = array_values($lister); | ||
374 | + if($sid == 1 && $page == 1) | ||
375 | + { | ||
376 | + $lister = array_slice($lister, 10, 50); | ||
377 | + }else{ | ||
378 | + $lister = array_slice($lister, 0, 50); | ||
379 | + } | ||
380 | + $data = array( | ||
381 | + 'code'=>200, | ||
382 | + 'data'=>$lister, | ||
383 | + ); | ||
384 | + echo json_encode($data); | ||
385 | + exit; | ||
386 | + } | ||
289 | } | 387 | } |
290 | ?> | 388 | ?> |
-
Please register or login to post a comment