Authored by cailing

热销排行

  1 +<?php
  2 +namespace LibModels\Web\Product;
  3 +
  4 +use Api\Yohobuy;
  5 +use Api\Sign;
  6 +
  7 +
  8 +/**
  9 + * 热销排行
  10 + *
  11 + * */
  12 +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';
  16 +
  17 +
  18 + /**
  19 + 获取热销排行
  20 + * 分类标签
  21 + */
  22 + public static function getHotranktag($client_type = 'web',$channel = 0, $is_concurrent = true, $callback = '')
  23 + {
  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);
  32 + }
  33 +
  34 +}
@@ -263,7 +263,8 @@ class Process @@ -263,7 +263,8 @@ class Process
263 'mergeNewReportData', 263 'mergeNewReportData',
264 'mergeSinglehotData2', 264 'mergeSinglehotData2',
265 'mergeHotCategoryData', 265 'mergeHotCategoryData',
266 - 'mergeGirlkidsData' 266 + 'mergeGirlkidsData',
  267 + 'mergeHotBrandsData'
267 ); 268 );
268 foreach ($data as $key => $val) { 269 foreach ($data as $key => $val) {
269 foreach ($mergeProcessList as $merge) { 270 foreach ($mergeProcessList as $merge) {
@@ -823,4 +824,57 @@ class Process @@ -823,4 +824,57 @@ class Process
823 return $result; 824 return $result;
824 } 825 }
825 826
  827 + /**
  828 + * 热门品牌数据处理
  829 + *
  830 + * @param array $data
  831 + * @param string $type
  832 + */
  833 + public static function mergeHotBrandsData($key,array &$data,$type)
  834 + {
  835 + $result = array();
  836 + $temp = array();
  837 + if ($data[$key]['template_name'] == 'custom_brands')
  838 + {
  839 + // print_r($data[$key]);
  840 + $result = array(
  841 + 'hotBrands' => array(
  842 + 'name' => '',
  843 + 'brandUrl' => ''
  844 + )
  845 + );
  846 + // text模版
  847 + $result['hotBrands']['name'] = '热门品牌';
  848 + //floor模板
  849 + $floor = array(
  850 + 'logoBrand' => '',
  851 + 'moreBrand' => ''
  852 + );
  853 +
  854 + $brands = $data[$key]['data']['list'];
  855 + foreach ($brands as $val)
  856 + {
  857 + $width = 185;
  858 + $height = 86;
  859 + $type = 'lifestyle';
  860 + $val['src'] = Images::getImageUrl($val['src'], $width, $height, 2);
  861 + $val['url'] = Helpers::transUrl($val['url'], $type);
  862 + $floor['logoBrand'][] = array(
  863 + 'href' => $val['url'],
  864 + 'img' => $val['src']
  865 + );
  866 + }
  867 + $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);
  871 + $cacheKey = sprintf("%s_%s", CacheConfig::KEY_INDEX_BRANDS_LIST_DATA, $type_key);
  872 + //print_r($cacheKey);
  873 + Cache::set($cacheKey, $floor, 7200);
  874 + $result['hotBrands']['brandUrl'] = '/common/getIndexResourceBrand?type=' . $type_key;
  875 + //print_r($result['hotBrands']['brandUrl']);
  876 + }
  877 + return $result;
  878 + }
  879 +
826 } 880 }
  1 +<?php
  2 +namespace product;
  3 +
  4 +use Plugin\Images;
  5 +use Plugin\Helpers;
  6 +use Plugin\Cache;
  7 +use Configs\CacheConfig;
  8 +use LibModels\Web\Home\IndexData;
  9 +use \LibModels\Web\Product\HotrankData;
  10 +use \LibModels\Web\Product\SearchData;
  11 +
  12 +class HotrankModel {
  13 +
  14 + /**
  15 + * 人气单品 一周热卖
  16 + */
  17 + static public function getSearchData($condition, $options)
  18 + {
  19 + // 调用接口查询商品数据
  20 + $result = SearchData::searchElasticByCondition($condition);
  21 + //print_r($result);
  22 +
  23 + if(!empty($result)){
  24 + $res = self::getProductList($result);
  25 + if(!empty($res['popular'])){
  26 + $data['popular'] = $res['popular'];
  27 + }
  28 + if(!empty($res['hotWeek'])){
  29 + $data['hotWeek'] = $res['hotWeek'];
  30 + }
  31 + }
  32 + return $data;
  33 + }
  34 +
  35 +
  36 +
  37 + /**
  38 + * 获取分类标签
  39 + */
  40 + static public function getHotranktag($classes)
  41 + {
  42 + $list = SearchData::getClassesData($classes);
  43 + //print_r($list);
  44 + $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'];
  49 + }
  50 + }
  51 + //print_r($nav);
  52 + return $nav;
  53 + }
  54 +
  55 +
  56 + /**
  57 + * 人气单品 一周热卖 数据处理
  58 + */
  59 + static public function getProductList($result)
  60 + {
  61 + /*----product start---------*/
  62 + if(empty($result) || empty($result['data']) || empty($result['data']['product_list'])){
  63 + return;
  64 + }
  65 + $data = $result['data']['product_list'];
  66 +
  67 + $popular = array();
  68 + $hotWeek = array();
  69 + foreach($data as $key=>$val){
  70 + if(empty($val['goods_list'])){
  71 + continue;
  72 + }
  73 + $defaultGoodsId = 0;
  74 + foreach ($val['goods_list'] as $v){
  75 + if($v['is_default'] == 'Y'){
  76 + $defaultGoodsId = $v['goods_id'];
  77 + }
  78 + }
  79 + if(empty($defaultGoodsId)){
  80 + $defaultGoodsId = $val['goods_list'][0]['goods_id'];
  81 + }
  82 +
  83 + $product_id = empty($val['product_id']) ? '' : $val['product_id'];
  84 + $re['url'] = 'http://item.yohobuy.com/product/pro_'.$product_id.'_'.$defaultGoodsId.'.html';
  85 +
  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 + }
  103 + }
  104 + $popular['name'] = '人气单品';
  105 +
  106 + $hotWeek = array(
  107 + 'name'=>'一周热卖',
  108 + 'list'=>$hot,
  109 + );
  110 +
  111 + return array('popular'=>$popular,'hotWeek'=>$hotWeek);
  112 + }
  113 +}
@@ -2,6 +2,10 @@ @@ -2,6 +2,10 @@
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;
  6 +use product\HotrankModel;
  7 +use LibModels\Web\Home\IndexData;
  8 +
5 class IndexController extends WebAction 9 class IndexController extends WebAction
6 { 10 {
7 /** 11 /**
@@ -47,5 +51,240 @@ class IndexController extends WebAction @@ -47,5 +51,240 @@ class IndexController extends WebAction
47 //渲染模板 51 //渲染模板
48 $this->_view->display('list',$data); 52 $this->_view->display('list',$data);
49 } 53 }
  54 +
  55 + public function hotrankAction() {
  56 + $this->setWebNavHeader(\Index\HomeModel::COOKIE_NAME_LIFESTYLE);
  57 + $data = array(
  58 + 'hotrankPage' => true,
  59 + 'hotrank' => array(
  60 + array(
  61 + 'slide' => array(
  62 + 'list' => array(
  63 + array(
  64 + 'href' => '/?gender=1,3',
  65 + 'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
  66 + ),
  67 + array(
  68 + 'href' => '/?gender=1,3',
  69 + 'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
  70 + ),
  71 + array(
  72 + 'href' => '/?gender=1,3',
  73 + 'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
  74 + ),
  75 + array(
  76 + 'href' => '/?gender=1,3',
  77 + 'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
  78 + ),
  79 + array(
  80 + 'href' => '/?gender=1,3',
  81 + 'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
  82 + ),
  83 + array(
  84 + 'href' => '/?gender=1,3',
  85 + 'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
  86 + ),
  87 + array(
  88 + 'href' => '/?gender=1,3',
  89 + 'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
  90 + ),
  91 + array(
  92 + 'href' => '/?gender=1,3',
  93 + 'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
  94 + )
  95 + )
  96 + )
  97 + ),
  98 + array(
  99 + 'popular' => array(
  100 + 'name' => '人气单品',
  101 + 'list' => array(
  102 + array(
  103 + 'href' => '',
  104 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  105 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  106 + 'price' => '399',
  107 + 'sPrice' => '199',
  108 + 'rank' => '1'
  109 + ),
  110 + array(
  111 + 'href' => '',
  112 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  113 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  114 + 'price' => '399',
  115 + 'sPrice' => '199',
  116 + 'rank' => '2'
  117 + ),
  118 + array(
  119 + 'href' => '',
  120 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  121 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  122 + 'price' => '399',
  123 + 'sPrice' => '199',
  124 + 'rank' => '3'
  125 + ),
  126 + array(
  127 + 'href' => '',
  128 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  129 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  130 + 'price' => '399',
  131 + 'sPrice' => '199',
  132 + 'rank' => '4'
  133 + ),
  134 + array(
  135 + 'href' => '',
  136 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  137 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  138 + 'price' => '399',
  139 + 'sPrice' => '199',
  140 + 'rank' => '5'
  141 + ),
  142 + array(
  143 + 'href' => '',
  144 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  145 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  146 + 'price' => '399',
  147 + 'sPrice' => '199',
  148 + 'rank' => '6'
  149 + ),
  150 + array(
  151 + 'href' => '',
  152 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  153 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  154 + 'price' => '399',
  155 + 'sPrice' => '199',
  156 + 'rank' => '7'
  157 + ),
  158 + array(
  159 + 'href' => '',
  160 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  161 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  162 + 'price' => '399',
  163 + 'sPrice' => '199',
  164 + 'rank' => '8'
  165 + ),
  166 + array(
  167 + 'href' => '',
  168 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  169 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  170 + 'price' => '399',
  171 + 'sPrice' => '199',
  172 + 'rank' => '9'
  173 + ),
  174 + array(
  175 + 'href' => '',
  176 + 'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
  177 + 'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
  178 + 'price' => '399',
  179 + 'sPrice' => '199',
  180 + 'rank' => '10'
  181 + )
  182 + )
  183 +
  184 + )
  185 + ),
  186 + array(
  187 + 'hotBrands' => array(
  188 + 'name' => '热门品牌',
  189 + )
  190 + ),
  191 + array(
  192 + 'hotWeek' => array(
  193 + 'name' => '一周热卖',
  194 + 'nav' => array(
  195 + array(
  196 + 'textCn' => 'TOP100',
  197 + 'url' => '',
  198 + 'sid' => 1
  199 + ),
  200 + array(
  201 + 'textCn' => '上装',
  202 + 'url' => '',
  203 + 'sid' => 2
  204 + ),
  205 + array(
  206 + 'textCn' => '男生测试',
  207 + 'url' => '',
  208 + 'sid' => 3
  209 + ),
  210 + array(
  211 + 'textCn' => '配饰',
  212 + 'url' => '',
  213 + 'sid' => 4
  214 + )
  215 + ),
  216 + 'list' => array(
  217 + array(
  218 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  219 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  220 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  221 + 'marketPrice' => '109',
  222 + 'salePrice' => '129'
  223 + ),
  224 + array(
  225 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  226 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  227 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  228 + 'marketPrice' => '109',
  229 + 'salePrice' => '129'
  230 + ),
  231 + array(
  232 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  233 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  234 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  235 + 'marketPrice' => '109',
  236 + 'salePrice' => '129'
  237 + ),
  238 + array(
  239 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  240 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  241 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  242 + 'marketPrice' => '109',
  243 + 'salePrice' => '129'
  244 + ),
  245 + array(
  246 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  247 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  248 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  249 + 'marketPrice' => '109',
  250 + 'salePrice' => '129'
  251 + ),
  252 + array(
  253 + 'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
  254 + 'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
  255 + 'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
  256 + 'marketPrice' => '109',
  257 + 'salePrice' => '129'
  258 + ),
  259 + )
  260 + )
  261 + )
  262 + )
  263 + );
  264 + $data = array( 'hotrankPage' => true,
  265 + 'footerTop'=> true,
  266 + 'hotrank' => array()
  267 + );
  268 + //焦点图 热门品牌
  269 + $focus = \Index\HomeModel::getChannelResource('lifestyle', 'd131aba83a84a6977eee3a7403a713de');
  270 + //print_r($focus);
  271 + $data['hotrank']['slide'] = $focus[0]['slide'];
  272 + $data['hotrank']['hotBrands'] = $focus[1]['hotBrands'];
  273 +
  274 + //人气单品 一周热卖
  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);
  278 + $data['hotrank']['popular'] = $publiclist['popular'];
  279 + $data['hotrank']['hotWeek'] = $publiclist['hotWeek'];
  280 + //print_r($publiclist);
  281 +
  282 + //分类标签
  283 + $classes = array('gender' => 2);
  284 + $nav = \product\HotrankModel::getHotranktag($classes);
  285 + $data['hotrank']['hotWeek']['nav'] = $nav;
  286 + //print_r($data);
  287 + $this->_view->display('hotrank', $data);
  288 + }
50 } 289 }
51 ?> 290 ?>