Authored by hf

code review by fei.hong: do format new arrival codes

<?php
namespace WebPlugin\DataProcess;
class Channel
... ... @@ -13,7 +14,7 @@ class Channel
public static function getFormat($channel, $data)
{
if(empty($data)) {
if (empty($data)) {
return array();
}
// 通用处理器
... ... @@ -28,4 +29,5 @@ class Channel
ksort($result);
return array_values($result);
}
}
... ...
<?php
namespace WebPlugin\DataProcess\Channel;
abstract class AbstractChannel
{
/***
/* * *
* 处理数据
* @param array $resource
* @return array[以key方式存储数据]
*/
public static function format($resource){}
public static function format($resource)
{
}
/**
* 获取格式化最新上架数据
*
... ... @@ -18,20 +24,16 @@ abstract class AbstractChannel
public static function getFormatNewArrivals(&$resource)
{
$result = array();
foreach($resource as $key => $val)
{
if(isset($resource[$key]) && isset($resource[$key + 2]))
{
foreach ($resource as $key => $val) {
if (isset($resource[$key]) && isset($resource[$key + 2])) {
$temp = array('newArrivls' => array('name' => '', 'navs' => array()), 'href' => '');
//newArrivals
if($resource[$key]['template_name'] == 'text' && $resource[$key + 1]['template_name'] == 'textNav')
{
if ($resource[$key]['template_name'] == 'text' && $resource[$key + 1]['template_name'] == 'textNav') {
//text模版
$temp['newArrivls']['name'] = $resource[$key]['data']['text'];
//textNav模版
foreach($resource[$key + 1]['data'] as $val)
{
$temp['newArrivls']['navs'][] = array('href' => $val['url'],'name' => $val['name']);
foreach ($resource[$key + 1]['data'] as $val) {
$temp['newArrivls']['navs'][] = array('href' => $val['url'], 'name' => $val['name']);
}
//link模版
$temp['href'] = $resource[$key + 2]['data'][0]['url'];
... ... @@ -42,4 +44,5 @@ abstract class AbstractChannel
}
return $result;
}
}
\ No newline at end of file
}
... ...
<?php
namespace WebPlugin\DataProcess\Channel;
class Boys extends AbstractChannel
{
/**
* 格式化数据
*
... ... @@ -13,4 +16,5 @@ class Boys extends AbstractChannel
$result = self::getFormatNewArrivals($resource);
return $result;
}
}
\ No newline at end of file
}
... ...
<?php
namespace WebPlugin\DataProcess\Channel;
class Girls extends AbstractChannel
{
public static function format($resource)
{
$result = array();
$result += self::getFormatNewArrivals($resource);
foreach($resource as $key => $val)//老版是title模版
{
if(isset($resource[$key]) && isset($resource[$key + 2]))
{
foreach ($resource as $key => $val) {//老版是title模版
if (isset($resource[$key]) && isset($resource[$key + 2])) {
$temp = array('newArrivls' => array('name' => '', 'navs' => array(), 'href' => ''));
if($resource[$key]['template_name'] == 'text' &&
$resource[$key + 1]['template_name'] == 'title' && //老版是title模版
$resource[$key + 2]['template_name'] == 'link'
)
{
if ($resource[$key]['template_name'] == 'text' &&
$resource[$key + 1]['template_name'] == 'title' && //老版是title模版
$resource[$key + 2]['template_name'] == 'link'
) {
//text模版
$temp['newArrivls']['name'] = $resource[$key]['data']['text'];
//title模版
foreach($resource[$key + 1]['data']['nav'] as $val)
{
$temp['newArrivls']['navs'][] = array('href' => $val['url'],'name' => $val['name']);
foreach ($resource[$key + 1]['data']['nav'] as $val) {
$temp['newArrivls']['navs'][] = array('href' => $val['url'], 'name' => $val['name']);
}
$link = $resource[$key + 2]['data'][0];
$temp['newArrivls']['href'] = $link['url'];
$temp['newArrivls']['href'] = $link['url'];
unset($resource[$key], $resource[$key + 1]);
$result[$key] = $temp;
}
... ... @@ -32,4 +31,5 @@ class Girls extends AbstractChannel
}
return $result;
}
}
... ...
<?php
namespace WebPlugin\DataProcess\Channel;
class Kids extends AbstractChannel
{
/**
* 格式化数据
*
... ... @@ -12,20 +15,16 @@ class Kids extends AbstractChannel
{
$result = array();
$result += self::getFormatNewArrivals($resource);
foreach($resource as $key => $val)//老版处理
{
if(isset($resource[$key]) && isset($resource[$key + 1]))
{
foreach ($resource as $key => $val) {//老版处理
if (isset($resource[$key]) && isset($resource[$key + 1])) {
$temp = array('newArrivls' => array('name' => '', 'navs' => array()));
//newArrivals
if($resource[$key]['template_name'] == 'text' && $resource[$key + 1]['template_name'] == 'textNav')
{
if ($resource[$key]['template_name'] == 'text' && $resource[$key + 1]['template_name'] == 'textNav') {
//text模版
$temp['newArrivls']['name'] = $resource[$key]['data']['text'];
//textNav模版
foreach($resource[$key + 1]['data'] as $val)
{
$temp['newArrivls']['navs'][] = array('href' => $val['url'],'name' => $val['name']);
foreach ($resource[$key + 1]['data'] as $val) {
$temp['newArrivls']['navs'][] = array('href' => $val['url'], 'name' => $val['name']);
}
unset($resource[$key], $resource[$key + 1]);
$result[$key] = $temp;
... ... @@ -35,5 +34,4 @@ class Kids extends AbstractChannel
return $result;
}
}
\ No newline at end of file
}
... ...
<?php
namespace WebPlugin\DataProcess\Channel;
class Lifestyle extends AbstractChannel
{
/**
* 格式化数据
*
... ... @@ -12,20 +15,16 @@ class Lifestyle extends AbstractChannel
{
$result = array();
$result += self::getFormatNewArrivals($resource);
foreach($resource as $key => $val)//老版处理
{
if(isset($resource[$key]) && isset($resource[$key + 1]))
{
foreach ($resource as $key => $val) {//老版处理
if (isset($resource[$key]) && isset($resource[$key + 1])) {
$temp = array('newArrivls' => array('name' => '', 'navs' => array()));
//newArrivals
if($resource[$key]['template_name'] == 'textNav' && $resource[$key + 1]['template_name'] == 'link')
{
if ($resource[$key]['template_name'] == 'textNav' && $resource[$key + 1]['template_name'] == 'link') {
//text模版
$temp['newArrivls']['name'] = '最新上架 NEW ARRIVALS';
//textNav模版
foreach($resource[$key]['data'] as $val)
{
$temp['newArrivls']['navs'][] = array('href' => $val['url'],'name' => $val['name']);
foreach ($resource[$key]['data'] as $val) {
$temp['newArrivls']['navs'][] = array('href' => $val['url'], 'name' => $val['name']);
}
unset($resource[$key], $resource[$key + 1]);
$result[$key] = $temp;
... ... @@ -34,4 +33,5 @@ class Lifestyle extends AbstractChannel
}
return $result;
}
}
\ No newline at end of file
}
... ...
<?php
namespace WebPlugin\DataProcess;
use WebPlugin\Images;
... ... @@ -12,6 +13,7 @@ use LibModels\Web\Product\SearchData;
*/
class Process
{
/**
*
* @param array $data
... ... @@ -21,15 +23,16 @@ class Process
{
// 组合处理数据
$result = self::mergeProcess($data, $type);
$build = array();
foreach ($data as $key => $val) {
$fun = $val['template_name'];
if (empty($val['data']) || ! is_callable("self::$fun")) {
if (empty($val['data']) || !is_callable("self::$fun")) {
continue;
}
// 单个处理数据
$build = self::$fun($val, $type);
if (! empty($build)) {
if (!empty($build)) {
$result[$key] = $build;
unset($data[$key]);
}
... ... @@ -62,7 +65,7 @@ class Process
}
$len = count($data['menuNav']['blocks']);
foreach ($data['menuNav']['blocks'] as $key => $val) {
if($len <= 2 && $key == 0) {
if ($len <= 2 && $key == 0) {
$val['img'] = Images::getImageUrl($val['img'], 185, 152, 1);
}
$val['img'] = Images::getImageUrl($val['img'], 185, 76, 1);
... ... @@ -73,7 +76,7 @@ class Process
'img' => $val['img']
);
}
foreach ($data['menuNav']['list'] as $val) {
if (empty($val['name']) && empty($val['url'])) {
continue;
... ... @@ -84,7 +87,7 @@ class Process
'href' => $val['url']
);
}
foreach ($data['imgs'] as $key => $val) {
$val['url'] = Helpers::transUrl($val['url'], $type);
if ($key == 0) {
... ... @@ -118,19 +121,16 @@ class Process
{
$result = array();
$temp = array();
$width = 1150;
$height = 450;
if ($data['focus_type'] == 1) {
foreach ($data['data'] as $val) {
$ret = array();
$val['src'] = Images::getImageUrl($val['src'], $width, $height, 1);
$val['src'] = Images::getImageUrl($val['src'], 1150, 450, 1);
$val['url'] = Helpers::transUrl($val['url'], $type);
$ret = array (
$ret = array(
'href' => $val['url'],
'img' => $val['src'],
);
if(!empty($val['bgColor'])) {
$ret['bgColor'] = $val['bgColor'];
if (!empty($val['bgColor'])) {
$ret['bgColor'] = $val['bgColor'];
}
$temp[] = $ret;
}
... ... @@ -152,21 +152,17 @@ class Process
$temp = array();
if ($data['template_name'] == 'recommend_content_three') {
foreach ($data['data']['big_image'] as $val) {
$width = 1150;
$height = 450;
$val['src'] = Images::getImageUrl($val['src'], $width, $height, 1);
$val['src'] = Images::getImageUrl($val['src'], 1150, 450, 1);
$val['url'] = Helpers::transUrl($val['url'], $type);
$temp['list'][] = array(
'href' => $val['url'],
'img' => $val['src'],
// 'bgColor'=> $val[]
// 'bgColor'=> $val[]
);
}
foreach ($data['data']['list'] as $val) {
$width = 138;
$height = 54;
$val['src'] = Images::getImageUrl($val['src'], $width, $height, 1);
$val['src'] = Images::getImageUrl($val['src'], 138, 54, 1);
$val['url'] = Helpers::transUrl($val['url'], $type);
$temp['pagination'][] = array(
'href' => $val['url'],
... ... @@ -270,11 +266,12 @@ class Process
'mergeGirlkidsData',
'mergeHotBrandsData'
);
$temp = array();
foreach ($data as $key => $val) {
foreach ($mergeProcessList as $merge) {
if (isset($data[$key])) {
$temp = self::$merge($key, $data, $type);
if (! empty($temp)) {
if (!empty($temp)) {
$result[$key] = $temp;
}
}
... ... @@ -298,43 +295,35 @@ class Process
public static function mergeSinglehotData($key, array &$data, $type)
{
$result = array();
if ((isset($data[$key]) && isset($data[$key + 2])) || (isset($data[$key]) && isset($data[$key + 3])))
{
if ((isset($data[$key]) && isset($data[$key + 2])) || (isset($data[$key]) && isset($data[$key + 3]))) {
$title = '';
$source = $goods = $floor = array();
if ($data[$key]['template_name'] == 'textNav' && $data[$key + 1]['template_name'] == 'goods'
&& $data[$key + 2]['template_name'] == 'floor')
{
if ($data[$key]['template_name'] == 'textNav' && $data[$key + 1]['template_name'] == 'goods' && $data[$key + 2]['template_name'] == 'floor') {
$title = '人气单品 TOP100';
$source = $data[$key];
$goods = $data[$key + 1];
$floor = $data[$key + 2];
unset($data[$key], $data[$key + 1], $data[$key + 2]);
} else if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'textNav'
&& $data[$key + 2]['template_name'] == 'goods' && $data[$key + 3]['template_name'] == 'floor')
{
} else if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'textNav' && $data[$key + 2]['template_name'] == 'goods' && $data[$key + 3]['template_name'] == 'floor') {
$title = $data[$key]['data']['text'];
$source = $data[$key + 1];
$goods = $data[$key + 2];
$floor = $data[$key + 3];
unset($data[$key], $data[$key + 1], $data[$key + 2], $data[$key + 3]);
} else if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'textNav'
&& $data[$key + 2]['template_name'] == 'goods' && $data[$key + 3]['template_name'] == 'app_icon_list')
{
} else if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'textNav' && $data[$key + 2]['template_name'] == 'goods' && $data[$key + 3]['template_name'] == 'app_icon_list') {
$title = $data[$key]['data']['text'];
$source = $data[$key + 1];
$goods = $data[$key + 2];
$floor = $data[$key + 3];
unset($data[$key], $data[$key + 1], $data[$key + 2], $data[$key + 3]);
}
if (! empty($source) && ! empty($floor))
{
if (!empty($source) && !empty($floor)) {
$result = array(
'singlehot' => array(
'name' => '',
'imgHot' => array(),
'brands' => array(),
'navs'=> array(),
'navs' => array(),
)
);
// text模版
... ... @@ -367,9 +356,7 @@ class Process
{
$result = array();
if (isset($data[$key]) && isset($data[$key + 2])) {
if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'small_pic'
&& $data[$key + 2]['template_name'] == 'floor')
{
if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'small_pic' && $data[$key + 2]['template_name'] == 'floor') {
$result = array(
'singlehot' => array(
'name' => '',
... ... @@ -379,40 +366,27 @@ class Process
// text
$result['singlehot']['name'] = $data[$key]['data']['text'];
$len = 10;
$list = array();
// small_pic
foreach ($data[$key + 1]['data'] as &$val) {
$w = 378;
$h = 248;
$val['src'] = Images::getImageUrl($val['src'], $w, $h, 1);
$val['src'] = Images::getImageUrl($val['src'], 378, 248, 1);
}
//floor
foreach ($data[$key + 2]['data'] as &$val)
{
$w = 185;
$h = 248;
$val['src'] = Images::getImageUrl($val['src'], $w, $h, 1);
foreach ($data[$key + 2]['data'] as &$val) {
$val['src'] = Images::getImageUrl($val['src'], 185, 248, 1);
}
for ($i = 0; $i < $len; $i ++)
{
for ($i = 0; $i < $len; $i ++) {
$pos = $i;
if ($i == 1)
{
if ($i == 1) {
$val = $data[$key + 1]['data'][0]; // 第二个是大图
}
else if ($i == $len - 1)
{
} else if ($i == $len - 1) {
$val = $data[$key + 1]['data'][1]; // 最后一个是大图
}
else
{
if ($pos > 1) // 小图
{
} else {
if ($pos > 1) { // 小图
$pos = $pos - 1;
}
$val = $data[$key + 2]['data'][$pos];
}
$result['singlehot']['imgHot'][] = array(
'href' => $val['url'],
'img' => $val['src'],
... ... @@ -437,16 +411,14 @@ class Process
{
$result = array();
if (isset($data[$key]) && isset($data[$key + 2])) {
if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'focus'
&& ($data[$key + 2]['template_name'] == 'floor' ||
$data[$key + 2]['template_name'] == 'app_icon_list'))
{
if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'focus' && ($data[$key + 2]['template_name'] == 'floor' ||
$data[$key + 2]['template_name'] == 'app_icon_list')) {
//slider颜色
$sliderColor = array('girls' => '#8ae6e0','kids'=>'#7AD3F8','lifestyle'=>'#4e433d', 'boys'=>'');
$sliderColor = array('girls' => '#8ae6e0', 'kids' => '#7AD3F8', 'lifestyle' => '#4e433d', 'boys' => '');
$result = array(
'preferenceBrands' => array(
'name' => '',
'sliderColor'=> $sliderColor[$type],
'sliderColor' => $sliderColor[$type],
'imgBrand' => array(),
'brandUrl' => ''
)
... ... @@ -454,11 +426,15 @@ class Process
// text模版
$result['preferenceBrands']['name'] = $data[$key]['data']['text'];
// focus模版
$width = 0;
$height = 0;
foreach ($data[$key + 1]['data'] as $val) {
if($type == 'boys') {
$width = 378; $height = 175;
} else{
$width = 320;$height = 430;
if ($type == 'boys') {
$width = 378;
$height = 175;
} else {
$width = 320;
$height = 430;
}
$val['src'] = Images::getImageUrl($val['src'], $width, $height, 1);
$val['url'] = Helpers::transUrl($val['url'], $type);
... ... @@ -487,10 +463,10 @@ class Process
$floor['moreBrand'] = $data[$key + 3]['data'][0]['url'];
unset($data[$key + 3]);
}
$type_key = sprintf("%s_%s", $type, $key + 2);
$cacheKey = sprintf("%s_%s", WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA, $type_key);
$typeKey = sprintf("%s_%s", $type, $key + 2);
$cacheKey = sprintf("%s_%s", WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA, $typeKey);
Cache::set($cacheKey, $floor, 86400);
$result['preferenceBrands']['brandUrl'] = '/common/getIndexResourceBrand?type=' . $type_key;
$result['preferenceBrands']['brandUrl'] = Helpers::url('/common/getIndexResourceBrand', array('type' => $typeKey));
unset($data[$key], $data[$key + 1], $data[$key + 2]);
}
}
... ... @@ -508,10 +484,8 @@ class Process
public static function mergeGirlkidsData($key, array &$data, $type)
{
$result = array();
if (isset($data[$key]) && isset($data[$key + 2]))
{
if ($data[$key]['template_name'] == 'text' && $data[$key + 2]['template_name'] == 'goods')
{
if (isset($data[$key]) && isset($data[$key + 2])) {
if ($data[$key]['template_name'] == 'text' && $data[$key + 2]['template_name'] == 'goods') {
$result = array(
'girlkids' => array(
'name' => '',
... ... @@ -520,13 +494,13 @@ class Process
);
// text
$result['girlkids']['name'] = $data[$key]['data']['text'];
// goods
$result['girlkids']['imgHot'] = self::mergeGoodsProcess($data[$key + 2], $type);
unset($data[$key], $data[$key + 1], $data[$key + 2]);
}
}
return $result;
}
... ... @@ -541,11 +515,8 @@ class Process
public static function mergeAccordionData($key, array &$data, $type)
{
$result = array();
if (isset($data[$key]) && isset($data[$key + 2]))
{
if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'textNav'
&& $data[$key + 2]['template_name'] == 'focus')
{
if (isset($data[$key]) && isset($data[$key + 2])) {
if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'textNav' && $data[$key + 2]['template_name'] == 'focus') {
$result = array(
'accordion' => array(
'name' => '',
... ... @@ -554,12 +525,12 @@ class Process
)
);
$result['accordion']['name'] = $data[$key]['data']['text'];
// textNav模版
if (! empty($data[$key + 1]['data'])) {
if (!empty($data[$key + 1]['data'])) {
$result['accordion']['navs'] = self::mergeNavProcess($data[$key + 1], $type);
}
// focus模版
foreach ($data[$key + 2]['data'] as $val) {
$val['src'] = Images::getImageUrl($val['src'], 650, 400, 1);
... ... @@ -572,7 +543,7 @@ class Process
unset($data[$key], $data[$key + 1], $data[$key + 2]);
}
}
return $result;
}
... ... @@ -587,12 +558,9 @@ class Process
public static function mergeNewReportData($key, array &$data, $type)
{
$result = array();
if (isset($data[$key]) && isset($data[$key + 3]))
{
if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'single_image'
&& $data[$key + 2]['template_name'] == 'floor' &&
$data[$key + 3]['template_name'] == 'single_image')
{
if (isset($data[$key]) && isset($data[$key + 3])) {
if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'single_image' && $data[$key + 2]['template_name'] == 'floor' &&
$data[$key + 3]['template_name'] == 'single_image') {
$result = array(
'newReport' => array(
'name' => '',
... ... @@ -635,8 +603,7 @@ class Process
{
$result = array();
if (isset($data[$key]) && isset($data[$key + 2])) {
if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'textNav'
&& $data[$key + 2]['template_name'] == 'floor') {
if ($data[$key]['template_name'] == 'text' && $data[$key + 1]['template_name'] == 'textNav' && $data[$key + 2]['template_name'] == 'floor') {
$result = array(
'category' => array(
'name' => '',
... ... @@ -646,18 +613,20 @@ class Process
);
// text模版
$result['category']['name'] = $data[$key]['data']['text'];
// textNav模版
if (! empty($data[$key + 1]['data'])) {
if (!empty($data[$key + 1]['data'])) {
$result['category']['navs'] = self::mergeNavProcess($data[$key + 1], $type);
}
// floor模版
$width = 0;
$width = 0;
$height = 0;
foreach ($data[$key + 2]['data'] as $pos => $val) {
$width = 185; $height = 510;
if($pos == 1) {
$width = 377; $height = 504;
$width = 185;
$height = 510;
if ($pos == 1) {
$width = 377;
$height = 504;
}
$val['src'] = Images::getImageUrl($val['src'], $width, $height, 2);
$val['url'] = Helpers::transUrl($val['url'], $type);
... ... @@ -670,7 +639,7 @@ class Process
unset($data[$key], $data[$key + 1], $data[$key + 2]);
}
}
return $result;
}
... ... @@ -685,10 +654,8 @@ class Process
public static function mergeHotCategoryData($key, &$data, $type)
{
$result = array();
if (isset($data[$key]) && isset($data[$key + 1]))
{
if ($data[$key]['template_name'] == 'hotCategory' && $data[$key + 1]['template_name'] == 'floor')
{
if (isset($data[$key]) && isset($data[$key + 1])) {
if ($data[$key]['template_name'] == 'hotCategory' && $data[$key + 1]['template_name'] == 'floor') {
$result = array(
'name' => '',
'navs' => array(),
... ... @@ -707,11 +674,9 @@ class Process
$result['navs'] = $temp['navs'];
$result['tplrecommend']['keyword'] = $temp['tplrecommend']['keyword'];
$result['tplrecommend']['category'] = $temp['tplrecommend']['category'];
foreach ($data[$key]['data']['imgs'] as $key2 => $val)
{
foreach ($data[$key]['data']['imgs'] as $key2 => $val) {
$val['url'] = Helpers::transUrl($val['url'], $type);
if ($key2 == 0 || $key2 == 4) // 两个大图
{
if ($key2 == 0 || $key2 == 4) { // 两个大图
$val['img'] = Images::getImageUrl($val['img'], 378, 248, 1); // 大图
$result['tplrecommend']['brands'][] = array(
'href' => $val['url'],
... ... @@ -727,10 +692,9 @@ class Process
);
}
}
// floor模版
foreach ($data[$key + 1]['data'] as $val)
{
foreach ($data[$key + 1]['data'] as $val) {
$val['src'] = Images::getImageUrl($val['src'], 222, 298, 1); // 小图
$result['tplrecommend']['products'][] = array(
'href' => $val['url'],
... ... @@ -744,7 +708,7 @@ class Process
);
}
}
return $result;
}
... ... @@ -783,7 +747,7 @@ class Process
$skns = '';
foreach ($data['data'] as $val) {
$skns .= $val['id'] . ' ';
}
}
$params = array(
'query' => rtrim($skns),
'client_type' => 'web'
... ... @@ -793,8 +757,7 @@ class Process
$pos = 0;
$url = '';
$oneGoods = array();
foreach ($goodsList as $goods)
{
foreach ($goodsList as $goods) {
$oneGoods = array();
$pos ++;
if ($pos > 12) {
... ... @@ -810,7 +773,7 @@ class Process
$oneGoods['href'] = Helpers::transUrl($url, $type);
$result[$goods['product_skn']] = $oneGoods;
}
// 排序
uksort($result, function ($a, $b) use($skns) {
$skn_arr = explode(' ', $skns);
... ... @@ -818,29 +781,27 @@ class Process
});
$pos = 1;
//添加TOP标示
foreach($result as &$val) {
if($pos < 4) {
$val['tip'] = 'TOP'.$pos;
}
else {
break;
}
$pos ++;
foreach ($result as &$val) {
if ($pos < 4) {
$val['tip'] = 'TOP' . $pos;
} else {
break;
}
$pos ++;
}
return $result;
}
/**
* 热门品牌数据处理
*
* @param array $data
* @param string $type
*/
public static function mergeHotBrandsData($key,array &$data,$type)
public static function mergeHotBrandsData($key, array &$data, $type)
{
$result = array();
if ($data[$key]['template_name'] == 'custom_brands')
{
if ($data[$key]['template_name'] == 'custom_brands') {
$result = array(
'hotBrands' => array(
'name' => '',
... ... @@ -854,24 +815,23 @@ class Process
'logoBrand' => '',
'moreBrand' => ''
);
$brands = $data[$key]['data']['list'];
foreach ($brands as $val)
{
$val['src'] = Images::getImageUrl($val['src'], 185, 86, 2);
$val['url'] = Helpers::transUrl($val['url'], $type);
$floor['logoBrand'][] = array(
'href' => $val['url'],
'img' => $val['src']
);
}
foreach ($brands as $val) {
$val['src'] = Images::getImageUrl($val['src'], 185, 86, 2);
$val['url'] = Helpers::transUrl($val['url'], $type);
$floor['logoBrand'][] = array(
'href' => $val['url'],
'img' => $val['src']
);
}
$floor['moreBrand'] = Helpers::url('/brands');
$typeKey = sprintf("%s_%s", $type, $key);
$typeKey = sprintf("%s_%s", $type, $key);
$cacheKey = sprintf("%s_%s", WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA, $typeKey);
Cache::set($cacheKey, $floor, 86400);
$result['hotBrands']['brandUrl'] = Helpers::url('/common/getIndexResourceBrand', array('type' => $typeKey));
}
return $result;
}
}
\ No newline at end of file
}
... ...
... ... @@ -26,15 +26,14 @@ class CommonController extends WebAction
if (empty($type)) {
break;
}
}
while (false);
// 首页资源品牌,采用内存存储
$type = $this->get('type');
if (! empty($type)) {
// 首页资源品牌,采用内存存储
$key = WebCacheConfig::KEY_WEB_INDEX_BRANDS_LIST_DATA . '_' . $type;
// array('logoBrand'=>'','moreBrand'=>'')
$data = Cache::get($key);
}
}
while (false);
$this->echoJson($data);
}
... ...