|
|
<?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;
|
|
|
}
|
|
|
|
|
|
/* 顶部的轮翻广告列表 */
|
|
|
$result['headerBanner'] = self::bannerData($newsale['newsaleTop']);
|
|
|
|
|
|
foreach($products as $single)
|
|
|
/* 下部商品列表 */
|
|
|
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'];
|
|
|
|
|
|
if(count($single['data']) === 1)
|
|
|
{
|
|
|
$result = $banner;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
$result['list'][] = $banner;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|