Authored by Rock Zhang

修改数据处理插件的目录结构,初步完成新品到着,折扣专区的数据结构组装

... ... @@ -57,9 +57,11 @@ class NewsaleData
$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;
... ... @@ -120,7 +122,7 @@ class NewsaleData
* @param integer $page 分页第几页, 默认第1页
* @return array 折扣专区商品数据
*/
public static function getSaleProducts($gender, $channel, $limit = 50, $page = 1)
public static function getSaleProducts($gender, $channel, $limit = 60, $page = 1)
{
$param = Yohobuy::param();
$param['method'] = 'app.search.sales';
... ... @@ -133,16 +135,19 @@ class NewsaleData
$urlList = array();
$param['p_d'] = '0.1,0.3';
$param['client_secret'] = Sign::getSign($param);
$urlList['oneThree'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
$urlList['1-3折'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
$param['p_d'] = '0.4,0.6';
unset($param['client_secret']);
$param['client_secret'] = Sign::getSign($param);
$urlList['fourSix'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
$urlList['4-6折'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
$param['p_d'] = '0.7,0.9';
unset($param['client_secret']);
$param['client_secret'] = Sign::getSign($param);
$urlList['SevenNine'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
$urlList['7-9折'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
$param['p_d'] = '0.1,0.9';
unset($param['client_secret']);
$param['client_secret'] = Sign::getSign($param);
$urlList['OneNine'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
$urlList['ALL'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
return Yohobuy::getMulti($urlList);
}
... ...
<?php
namespace Plugin;
namespace Plugin\DataProcess;
/**
* 分类数据处理类
... ... @@ -35,7 +35,7 @@ class ClassProcess
$item['sub'][] = $subitem;
}
$oneClass['ca'][] = $item;
}
... ...
<?php
namespace Plugin;
namespace Plugin\DataProcess;
use Plugin\Helpers;
/**
* 楼层数据处理类
... ...
<?php
namespace Plugin\DataProcess;
use Plugin\Helpers;
/**
* 新品到着、折扣专区数据处理类
*/
class NewSaleProcess
{
/**
* 处理新品到着、折扣专区数据
*
* @param array $data 接口传回的数据
* @return array 处理之后的数据
*/
public static function newSaleData($focus, $products)
{
$result = array(
'headerBanner' => self::bannerData($focus)
);
$list = array('list'=>array());
foreach($products as $single)
{
$noTab = true;
if(isset($single['tabs']) && $noTab)
{
$list['tabs'] = array();
foreach ($single['tabs'] as $one)
{
$list['tabs'][] = $one;
}
$noTab = false;
}
$list['list'][] = $single['product_list'];
}
$result['listNav'] = $list;
return $result;
}
/**
* 处理页面顶部焦点图数据
*
* @param array $data 接口传回的焦点图数据
* @return array 处理之后的数据
*/
private static function bannerData($data)
{
$result = array('list'=>array());
foreach ($data as $single)
{
foreach ($single['data'] as $one)
{
$banner = array();
$banner['img'] = Helpers::getImageUrl($one['src'], 750, 364, 1);
$banner['url'] = $one['url'];
$result['list'][] = $banner;
}
}
return $result;
}
}
... ...
... ... @@ -2,7 +2,7 @@
use Action\AbstractAction;
use LibModels\Wap\Home\IndexData;
use Plugin\FloorProcess;
use Plugin\DataProcess\FloorProcess;
/**
* 男生首页
*/
... ...
... ... @@ -2,7 +2,7 @@
use Action\AbstractAction;
use LibModels\Wap\Home\IndexData;
use Plugin\FloorProcess;
use Plugin\DataProcess\FloorProcess;
/**
* 女生首页
*/
... ...
... ... @@ -2,7 +2,7 @@
use Action\AbstractAction;
use LibModels\Wap\Home\IndexData;
use Plugin\FloorProcess;
use Plugin\DataProcess\FloorProcess;
/**
* 儿童首页
*/
... ...
... ... @@ -2,7 +2,7 @@
use Action\AbstractAction;
use LibModels\Wap\Home\IndexData;
use Plugin\FloorProcess;
use Plugin\DataProcess\FloorProcess;
/**
* 创意生活首页
... ...
<?php
use Action\AbstractAction;
use LibModels\Wap\Category\ClassData;
use Plugin\ClassProcess;
use Plugin\DataProcess\ClassProcess;
/**
* 品牌
... ...
... ... @@ -2,7 +2,7 @@
use Action\AbstractAction;
use LibModels\wap\Product\NewsaleData as Newsale;
use Plugin\Helpers;
use Plugin\DataProcess\NewSaleProcess;
/**
* 新品到着
*/
... ... @@ -10,7 +10,11 @@ class NewsaleController extends AbstractAction
{
public function indexAction()
{
$this->_view->assign('title', '新品到着');
$data = array(
'header' => array(
'title' => '新品到着'
)
);
// 新品到着顶部焦点图
$focusData = Newsale::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d');
... ... @@ -18,58 +22,19 @@ class NewsaleController extends AbstractAction
$focus = array();
if($focusData['code'] == 200)
{
foreach ($focusData['data'] as $single)
{
foreach ($single['data'] as $val) {
$val['src'] = Helpers::getImageUrl($val['src'], 375, 667, 1);
$focus[] = $val;
}
}
$focus = $focusData['data'];
}
// 批量获取新品到着商品数据
$products = Newsale::getNewProducts('1,3', 1, 60);
echo '<pre>';
print_r($focus);print_r($products);exit;
// 添加商品数据
$data += NewSaleProcess::newSaleData($focus, $products);
$this->_view->display('new', compact('f/**/ocus', 'products'));
/*$data = array(
'headerBanner' => array(
'list' => array(
array(
'url' => '',
'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',
)
)
),
'listNav' => array(
'list' => array(
array(
'url' => '',
'textCn' => '5月27日',
'styleClass' => ''
),
array(
'url' => '',
'textCn' => '本周上新'
),
array(
'url' => '',
'textCn' => '销量'
),
array(
'url' => '',
'textCn' => '筛选',
'styleClass' => 'screen-nav'
)
)
)
);
echo '<pre>';
print_r($data);exit;
$this->_view->assign('title', '新品到着');
$this->_view->display('new', $data);*/
$this->_view->display('new', $data);
}
... ... @@ -100,118 +65,17 @@ class NewsaleController extends AbstractAction
}
}
/**
* 折扣专区
*/
public function discountAction()
{
$data = array(
'header' => array(
'title' => 'SALE'
),
'headerBanner' => array(
'list' => array(
array(
'url' => '',
'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
),
array(
'url' => '',
'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
),
array(
'url' => '',
'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
),
array(
'url' => '',
'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
)
)
),
'saleSection' => array(
'list' => array(
array(
'url' => '',
'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
),
array(
'url' => '',
'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
),
array(
'url' => '',
'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
),
array(
'url' => '',
'img' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480'
)
)
),
'latestSale' => array(
'list' => '最新降价'
),
'goodsNav' => array(
'newPatterns' => true,
'price' => true,
'salesVolume' => true,
'screen' => true,
),
'goodsContainer' => array(
'goods' => array(
array(
'id' => '',
'thumb' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',
'name' => 'GAWS DIGI 丛林数码印花拼接卫衣',
'isLike' => false,
'price' => 1268,
'salePrice' => 589,
'isSale' => true,
'isFew' => true,
'isNew' => false,
'url' => ''
),
array(
'id' => '',
'thumb' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',
'name' => 'GAWS DIGI 丛林数码印花拼接卫衣',
'isLike' => false,
'price' => 1268,
'salePrice' => 589,
'isSale' => true,
'isFew' => true,
'isNew' => false,
'url' => ''
),
array(
'id' => '',
'thumb' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',
'name' => 'GAWS DIGI 丛林数码印花拼接卫衣',
'isLike' => false,
'price' => 1268,
'salePrice' => 589,
'isSale' => true,
'isFew' => true,
'isNew' => false,
'url' => ''
),
array(
'id' => '',
'thumb' => 'http://img12.static.yhbimg.com/adpic/2015/08/14/12/0205a06e86edb30a7d1833477a9e886577.jpg?imageView/2/w/640/h/480',
'name' => 'GAWS DIGI 丛林数码印花拼接卫衣',
'isLike' => false,
'price' => 1268,
'salePrice' => 589,
'isSale' => true,
'isFew' => true,
'isNew' => false,
'url' => ''
)
)
),
'title' => '折扣专区'
)
);
/*$this->_view->assign('title', '折扣专区');
// 折扣专区顶部焦点图
$focusData = Newsale::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523');
... ... @@ -219,22 +83,18 @@ class NewsaleController extends AbstractAction
$focus = array();
if($focusData['code'] == 200)
{
foreach ($focusData['data'] as $single)
{
foreach ($single['data'] as $val) {
$val['src'] = Helpers::getImageUrl($val['src'], 375, 667, 1);
$focus[] = $val;
}
}
$focus = $focusData['data'];
}
// 折扣专区商品数据
$products = Newsale::getNewProducts('1,3', 1, 60);
$products = Newsale::getSaleProducts('1,3', 1);
echo '<pre>';
print_r($focus);print_r($products);exit;
// 更新tabs
$data += array('tabs' => array_keys($products));
// 添加商品数据
$data += NewSaleProcess::newSaleData($focus, $products);
$this->_view->display('new', compact('focus', 'products'));*/
echo '<pre>';
var_dump($data);exit;
$this->_view->assign('title', '折扣专区');
$this->_view->display('sale', $data);
... ...