Authored by Rock Zhang

初步修复新品到着,品牌一览的bug

... ... @@ -15,57 +15,54 @@ use Api\Sign;
*/
class NewsaleData
{
const URI_NEWSALE_TOPPOS = 'operations/api/v5/resource/get';
/**
* 获取新品到着,折扣专区焦点图数据
* @param string $contentCode 内容位置码
* @return array 新品到着焦点图有关数据
*/
public static function getNewsaleFocus($contentCode)
{
// 构建必传参数
$param = Yohobuy::param();
$param['content_code'] = $contentCode;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL.'operations/api/v5/resource/get', $param);
}
/**
* 获取新品到着商品数据
* 封装新品到着、折扣专区页面的顶部焦点图和下部商品的数据
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param string $channel 1表示男, 2表示女
* @param integer $limit 查询返回的最大限制数, 默认为50
* @param integer $page 分页第几页, 默认第1页
* @return array 新品到着商品数据
* @param string $contentCode 获取广告资源需要的位置码
* @param string $gender 1,3表示男, 2,3表示女,1,2,3表示全部
* @param integer $channel 频道标识 1:男,2:女,3:潮童,4:创意生活
* @param integer $limit 查询返回的最大限制数, 默认为50
* @param integer $page 分页第几页, 默认第1页
* @return array(
* "newsaleTop": "顶部的轮翻广告数据",
* "newsaleList": "产品列表数据"
* )
* @author gtskk <rocky.zhang@yoho.cn>
*/
public static function getNewProducts($gender, $channel, $limit = 50, $page = 1)
public static function package($contentCode, $gender, $channel, $limit = 50, $page = 1)
{
$param = Yohobuy::param();
$param['method'] = 'app.search.newProduct';
$param['gender'] = $gender;
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = $channel;
// 构建url地址列表
$urlList = array();
$param['dayLimit'] = 1;
$param['client_secret'] = Sign::getSign($param);
$urlList['new'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
$param['dayLimit'] = 2;
unset($param['client_secret']);
$param['client_secret'] = Sign::getSign($param);
$urlList['week'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
$param['dayLimit'] = 3;
unset($param['client_secret']);
$param['client_secret'] = Sign::getSign($param);
$urlList['sale'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
//var_dump($urlList);exit;
return Yohobuy::getMulti($urlList);
$urlList = array();
/* 顶部的轮翻广告数据 */
$param = Yohobuy::param();
$param['content_code'] = $contentCode;
$param['client_secret'] = Sign::getSign($param);
$urlList['newsaleTop'] = Yohobuy::httpBuildQuery(Yohobuy::SERVICE_URL . self::URI_NEWSALE_TOPPOS, $param);
/* 产品列表数据 */
$param = Yohobuy::param();
$param['method'] = 'app.search.newProduct';
$param['gender'] = $gender;
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = $channel;
// 构建url地址列表
$param['dayLimit'] = 1;
$param['client_secret'] = Sign::getSign($param);
$urlList['new'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
$param['dayLimit'] = 2;
unset($param['client_secret']);
$param['client_secret'] = Sign::getSign($param);
$urlList['week'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
$param['dayLimit'] = 3;
unset($param['client_secret']);
$param['client_secret'] = Sign::getSign($param);
$urlList['sale'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
return Yohobuy::getMulti($urlList);
}
/**
... ...
<?php
namespace Plugin\DataProcess;
namespace Product;
use LibModels\Wap\Product\NewsaleData;
use Configs\CacheConfig;
use Plugin\Helpers;
/**
* 新品到着、折扣专区数据处理类
* 新品到着、折扣专区相关的模板数据模型
*
* @name NewsaleModel
* @package Models/Category
* @copyright yoho.inc
* @version 1.0 (2015-10-22 19:52:44)
* @author gtskk <rocky.zhang@yoho.cn>
*/
class NewSaleProcess
class NewsaleModel
{
/* 男生频道取新品到着及折扣专区数据的位置码 */
const CODE_TOP_NEW_BOYS = 'a7989369aa86681c678bc40f171b8f1d';
const CODE_TOP_SALE_BOYS = 'e9c9be32d72e2906d404a72ee24cb523';
/* 女生频道取新品到着及折扣专区数据的位置码 */
const CODE_TOP_NEW_GIRLS = 'b0ba12104cfecacdcfd7ad74117a22b8';
const CODE_TOP_SALE_GIRLS = '785c0e6aab746949073c4ffb9d5106ac';
/* 潮童频道取新品到着及折扣专区数据的位置码 */
const CODE_TOP_NEW_KIDS = 'c39607aa21219117976848819cf81a69';
const CODE_TOP_SALE_KIDS = 'ad1bb67a6007819c86f737d74172fd2e';
/* 创意生活频道取新品到着及折扣专区数据的位置码 */
const CODE_TOP_NEW_LIFESTYLE = '7c9ae01071f7a75d3911782feb4caebd';
const CODE_TOP_SALE_LIFESTYLE = '8132c7db3adbeb7b0d0002de9691c753';
/**
* 处理新品到着、折扣专区数据
* 根据频道获取新品到着数据
*
* @param array $data 接口传回的数据
* @return array 处理之后的数据
* @param int $channel boys表示男生频道, girls表示女生频道, kids表示潮童频道, lifestyle表示创意生活频道
* @return array
*/
public static function newSaleData($focus, $products)
public static function getNewsaleByChannel($channel)
{
$result = array(
'headerBanner' => self::bannerData($focus),
'goodsContainer' => array()
);
$result = array();
$newsale = array();
/* 根据频道调用接口 */
switch (intval($channel)) {
case 'boys': // 男生
$newsale = NewsaleData::package(self::CODE_TOP_NEW_BOYS, '1,3', 1);
break;
case 'girls': // 女生
$newsale = NewsaleData::package(self::CODE_TOP_NEW_GIRLS, '2,3', 2);
break;
case 'kids': // 潮童
$newsale = NewsaleData::package(self::CODE_TOP_NEW_KIDS, '1,2,3', 3);
break;
case 'lifestyle': // 创意生活
$newsale = NewsaleData::package(self::CODE_TOP_NEW_LIFESTYLE, '1,2,3', 4);
break;
}
foreach($products as $single)
/* 顶部的轮翻广告列表 */
$result['headerBanner'] = self::bannerData($newsale['newsaleTop']);
/* 下部商品列表 */
unset($newsale['newsaleTop']);
foreach($newsale as $single)
{
// 处理Tabs
$noTab = true;
... ... @@ -53,7 +93,7 @@ class NewSaleProcess
}
// 对于第一个productsLi添加show字段
if(count($result['goodsContainer']) === 0)
if(!isset($result['goodsContainer']))
{
$productsLi['show'] = true;
}
... ... @@ -64,24 +104,6 @@ class NewSaleProcess
return $result;
}
/**
* 筛选出来的商品数据处理
*
* @param array $data 筛选出来的原数据
* @return array 处理之后的数据
*/
public static function selectData($data)
{
$result = array('goods'=>array());
if($data['code'] === 200)
{
foreach ($data['data']['product_list'] as $val) {
$result['goods'][] = Helpers::formatProduct($val);
}
}
return $result;
}
/**
* 处理页面顶部焦点图数据
... ... @@ -91,19 +113,28 @@ class NewSaleProcess
*/
private static function bannerData($data)
{
$result = array('list'=>array());
$result = array();
foreach ($data as $single)
{
foreach ($single['data'] as $one)
{
$banner = array();
$banner['img'] = Helpers::getImageUrl($one['src'], 750, 364, 1);
$banner['img'] = Helpers::getImageUrl($one['src'], 640, 240, 1);
$banner['url'] = $one['url'];
$result['list'][] = $banner;
if(count($single['data']) === 1)
{
$result = $banner;
}
else
{
$result['list'][] = $banner;
}
}
}
return $result;
}
}
... ...
... ... @@ -180,7 +180,7 @@ class ListController extends AbstractAction
),
'brand' => $brand,
'msort' => 0,
'gender' => $this->getCookie('_Channel', '1,2'),
'gender' => $this->getCookie('_Channel', '1,3'),
'sort' => 0,
'price' => 0,
'size' => 0,
... ... @@ -241,7 +241,7 @@ class ListController extends AbstractAction
'goodList' => array(
'brand' => 0,
'msort' => 0,
'gender' => $this->getCookie('_Channel', '1,2'),
'gender' => $this->getCookie('_Channel', '1,3'),
'sort' => $sort,
'price' => 0,
'size' => 0,
... ...
... ... @@ -2,7 +2,7 @@
use Action\AbstractAction;
use LibModels\Wap\Product\NewsaleData;
use Plugin\DataProcess\NewSaleProcess;
use Product\NewsaleModel;
/**
* 新品到着
... ... @@ -23,18 +23,9 @@ class NewsaleController extends AbstractAction
)
);
// 新品到着顶部焦点图
$focusData = NewsaleData::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d');
// 处理返回的数据
$focus = array();
if (isset($focusData['code']) && $focusData['code'] == 200) {
$focus = $focusData['data'];
}
// 批量获取新品到着商品数据
$products = NewsaleData::getNewProducts('1,3', 1, 60);
$channel = $this->getCookie('_Channel', 'boys');
// 添加商品数据
$data += NewSaleProcess::newSaleData($focus, $products);
$data += NewsaleModel::getNewsaleByChannel($channel);
$this->_view->display('new', $data);
}
... ...