Authored by cailing

热销排行

<?php
namespace LibModels\Web\Product;
use Api\Yohobuy;
use Api\Sign;
/**
* 热销排行
*
* */
class HotrankData extends \LibModels\Wap\Product\SearchData
{
const URI_HOTRANK_RES = '/operations/service/v4/resource';
const URI_HOTRANK_TAG = '/operations/api/v5/resource/get';
/**
获取热销排行
* 分类标签
*/
public static function getHotranktag($client_type = 'web',$channel = 0, $is_concurrent = true, $callback = '')
{
// 构建必传参数
$params = Yohobuy::param();
$params['client_type'] = 'web';
$params['channel'] =$channel ;
$params['is_concurrent'] = true;
$params['callback'] = $callback;
$params['client_secret'] = Sign::getSign($params);
return Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_HOTRANK_TAG, $params);
}
}
\ No newline at end of file
... ...
... ... @@ -263,7 +263,8 @@ class Process
'mergeNewReportData',
'mergeSinglehotData2',
'mergeHotCategoryData',
'mergeGirlkidsData'
'mergeGirlkidsData',
'mergeHotBrandsData'
);
foreach ($data as $key => $val) {
foreach ($mergeProcessList as $merge) {
... ... @@ -807,7 +808,7 @@ class Process
// 排序
uksort($result, function ($a, $b) use($skns) {
$skn_arr = explode(' ', $skns);
return array_search($a, $skn_arr) > array_search($b, $skn_arr);
return array_search($a, $skn_arr) > array_search($b, $skn_arr);
});
$pos = 1;
//添加TOP标示
... ... @@ -819,8 +820,61 @@ class Process
break;
}
$pos ++;
}
return $result;
}
}
return $result;
}
/**
* 热门品牌数据处理
*
* @param array $data
* @param string $type
*/
public static function mergeHotBrandsData($key,array &$data,$type)
{
$result = array();
$temp = array();
if ($data[$key]['template_name'] == 'custom_brands')
{
// print_r($data[$key]);
$result = array(
'hotBrands' => array(
'name' => '',
'brandUrl' => ''
)
);
// text模版
$result['hotBrands']['name'] = '热门品牌';
//floor模板
$floor = array(
'logoBrand' => '',
'moreBrand' => ''
);
$brands = $data[$key]['data']['list'];
foreach ($brands as $val)
{
$width = 185;
$height = 86;
$type = 'lifestyle';
$val['src'] = Images::getImageUrl($val['src'], $width, $height, 2);
$val['url'] = Helpers::transUrl($val['url'], $type);
$floor['logoBrand'][] = array(
'href' => $val['url'],
'img' => $val['src']
);
}
$floor['moreBrand'] = 'http://yohobuy.com/brands';
//$floor['moreBrand'] = 'http://yohobuy.com/brands?gender=1,3&openby:yohobuy={"action":"go.list","params":{"actiontype":0,"gender":"1,3"}}';
//print_r($floor);
$type_key = sprintf("%s_%s", $type, $key);
$cacheKey = sprintf("%s_%s", CacheConfig::KEY_INDEX_BRANDS_LIST_DATA, $type_key);
//print_r($cacheKey);
Cache::set($cacheKey, $floor, 7200);
$result['hotBrands']['brandUrl'] = '/common/getIndexResourceBrand?type=' . $type_key;
//print_r($result['hotBrands']['brandUrl']);
}
return $result;
}
}
\ No newline at end of file
... ...
<?php
namespace product;
use Plugin\Images;
use Plugin\Helpers;
use Plugin\Cache;
use Configs\CacheConfig;
use LibModels\Web\Home\IndexData;
use \LibModels\Web\Product\HotrankData;
use \LibModels\Web\Product\SearchData;
class HotrankModel {
/**
* 人气单品 一周热卖
*/
static public function getSearchData($condition, $options)
{
// 调用接口查询商品数据
$result = SearchData::searchElasticByCondition($condition);
//print_r($result);
if(!empty($result)){
$res = self::getProductList($result);
if(!empty($res['popular'])){
$data['popular'] = $res['popular'];
}
if(!empty($res['hotWeek'])){
$data['hotWeek'] = $res['hotWeek'];
}
}
return $data;
}
/**
* 获取分类标签
*/
static public function getHotranktag($classes)
{
$list = SearchData::getClassesData($classes);
//print_r($list);
$nav = array();
if(!empty($list['data']['sort'])){
foreach($list['data']['sort'] as $li=>$lt){
$nav[$li]['sid'] = $lt['sort_id'];
$nav[$li]['textCn'] = $lt['sort_name'];
}
}
//print_r($nav);
return $nav;
}
/**
* 人气单品 一周热卖 数据处理
*/
static public function getProductList($result)
{
/*----product start---------*/
if(empty($result) || empty($result['data']) || empty($result['data']['product_list'])){
return;
}
$data = $result['data']['product_list'];
$popular = array();
$hotWeek = array();
foreach($data as $key=>$val){
if(empty($val['goods_list'])){
continue;
}
$defaultGoodsId = 0;
foreach ($val['goods_list'] as $v){
if($v['is_default'] == 'Y'){
$defaultGoodsId = $v['goods_id'];
}
}
if(empty($defaultGoodsId)){
$defaultGoodsId = $val['goods_list'][0]['goods_id'];
}
$product_id = empty($val['product_id']) ? '' : $val['product_id'];
$re['url'] = 'http://item.yohobuy.com/product/pro_'.$product_id.'_'.$defaultGoodsId.'.html';
$re['marketPrice'] = (int)$val['market_price'] == (int)$val['sales_price'] ? '' : '¥'.$val['market_price'];
$re['salePrice'] = empty($val['sales_price']) ? '' : '¥'.$val['sales_price'];
$re['name'] = $val['product_name'];
if($key <= 9){
$re['rank'] = $key + 1;
if($key <= 5){
$re['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 378, 504, 2);
$popular['list'][] = $re;
}else{
$re['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
$popular['list'][] = $re;
}
}else{
$re['rank'] = '';
$re['thumb'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
$hot[] = $re;
}
}
$popular['name'] = '人气单品';
$hotWeek = array(
'name'=>'一周热卖',
'list'=>$hot,
);
return array('popular'=>$popular,'hotWeek'=>$hotWeek);
}
}
\ No newline at end of file
... ...
... ... @@ -2,6 +2,10 @@
use Action\WebAction;
use LibModels\Web\Product\BrandData;
use LibModels\Web\Product\HotrankData;
use product\HotrankModel;
use LibModels\Web\Home\IndexData;
class IndexController extends WebAction
{
/**
... ... @@ -47,5 +51,240 @@ class IndexController extends WebAction
//渲染模板
$this->_view->display('list',$data);
}
public function hotrankAction() {
$this->setWebNavHeader(\Index\HomeModel::COOKIE_NAME_LIFESTYLE);
$data = array(
'hotrankPage' => true,
'hotrank' => array(
array(
'slide' => array(
'list' => array(
array(
'href' => '/?gender=1,3',
'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
),
array(
'href' => '/?gender=1,3',
'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
),
array(
'href' => '/?gender=1,3',
'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
),
array(
'href' => '/?gender=1,3',
'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
),
array(
'href' => '/?gender=1,3',
'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
),
array(
'href' => '/?gender=1,3',
'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
),
array(
'href' => '/?gender=1,3',
'img' => 'http://img10.static.yhbimg.com/taobaocms/2015/11/26/12/01c3b99f554ad50d9e5a9900719715c94c.jpg'
),
array(
'href' => '/?gender=1,3',
'img' => 'http://img12.static.yhbimg.com/taobaocms/2015/11/27/09/02a4f1c10e1e81574520e5c0239741a076.jpg'
)
)
)
),
array(
'popular' => array(
'name' => '人气单品',
'list' => array(
array(
'href' => '',
'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
'price' => '399',
'sPrice' => '199',
'rank' => '1'
),
array(
'href' => '',
'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
'price' => '399',
'sPrice' => '199',
'rank' => '2'
),
array(
'href' => '',
'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
'price' => '399',
'sPrice' => '199',
'rank' => '3'
),
array(
'href' => '',
'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
'price' => '399',
'sPrice' => '199',
'rank' => '4'
),
array(
'href' => '',
'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
'price' => '399',
'sPrice' => '199',
'rank' => '5'
),
array(
'href' => '',
'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
'price' => '399',
'sPrice' => '199',
'rank' => '6'
),
array(
'href' => '',
'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
'price' => '399',
'sPrice' => '199',
'rank' => '7'
),
array(
'href' => '',
'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
'price' => '399',
'sPrice' => '199',
'rank' => '8'
),
array(
'href' => '',
'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
'price' => '399',
'sPrice' => '199',
'rank' => '9'
),
array(
'href' => '',
'img' => 'http://img13.static.yhbimg.com/goodsimg/2014/09/16/07/027e03e45e3e88db0adbf6255671546a0b.jpg?imageMogr2/thumbnail/378x504/extent/378x504/background/d2hpdGU=/position/center/quality/90',
'title' => 'YYYOHOOD 黄伟文Wyman X yohood联名商品 圆领卫衣',
'price' => '399',
'sPrice' => '199',
'rank' => '10'
)
)
)
),
array(
'hotBrands' => array(
'name' => '热门品牌',
)
),
array(
'hotWeek' => array(
'name' => '一周热卖',
'nav' => array(
array(
'textCn' => 'TOP100',
'url' => '',
'sid' => 1
),
array(
'textCn' => '上装',
'url' => '',
'sid' => 2
),
array(
'textCn' => '男生测试',
'url' => '',
'sid' => 3
),
array(
'textCn' => '配饰',
'url' => '',
'sid' => 4
)
),
'list' => array(
array(
'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
'marketPrice' => '109',
'salePrice' => '129'
),
array(
'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
'marketPrice' => '109',
'salePrice' => '129'
),
array(
'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
'marketPrice' => '109',
'salePrice' => '129'
),
array(
'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
'marketPrice' => '109',
'salePrice' => '129'
),
array(
'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
'marketPrice' => '109',
'salePrice' => '129'
),
array(
'thumb' => 'http://img13.static.yhbimg.com/goodsimg/2015/11/24/10/020dce58a189f3fbfc071b3d5dc7ccc4e9.jpg?imageMogr2/thumbnail/280x373/extent/280x373/background/d2hpdGU=/position/center/quality/90',
'url' => 'http://item.yohobuy.com/product/pro_294497_377385.html',
'name' => 'MARtube马克图布 暖手宝移动电源萌兔',
'marketPrice' => '109',
'salePrice' => '129'
),
)
)
)
)
);
$data = array( 'hotrankPage' => true,
'footerTop'=> true,
'hotrank' => array()
);
//焦点图 热门品牌
$focus = \Index\HomeModel::getChannelResource('lifestyle', 'd131aba83a84a6977eee3a7403a713de');
//print_r($focus);
$data['hotrank']['slide'] = $focus[0]['slide'];
$data['hotrank']['hotBrands'] = $focus[1]['hotBrands'];
//人气单品 一周热卖
$page = 1;
$param = array('order'=>'s_n_desc','viewNum'=>60,'page'=>1,'stocknumber'=>1,'status'=>1,'gender'=>'','attribute_not'=>2);
$publiclist = \product\HotrankModel::getSearchData($param,$page);
$data['hotrank']['popular'] = $publiclist['popular'];
$data['hotrank']['hotWeek'] = $publiclist['hotWeek'];
//print_r($publiclist);
//分类标签
$classes = array('gender' => 2);
$nav = \product\HotrankModel::getHotranktag($classes);
$data['hotrank']['hotWeek']['nav'] = $nav;
//print_r($data);
$this->_view->display('hotrank', $data);
}
}
?>
\ No newline at end of file
... ...