Authored by hf

do fixes bug refs YW-783

framework @ 75bbc3b0
Subproject commit 119c247f5cf929aa1e059e40609bb16dd6b58f05
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
... ...
... ... @@ -232,10 +232,15 @@ class AbstractAction extends Controller_Abstract
protected function getUdid()
{
$udid = '';
$ip = $this->_request->getServer('REMOTE_ADDR');
if ($ip) {
$udid = ip2long($ip);
$realIP = $this->_request->getServer('HTTP_X_REAL_IP');
if ($realIP) {
$udid = md5($realIP);
} else {
$realIP = $this->_request->getServer('REMOTE_ADDR', '');
$udid = md5($realIP);
}
return $udid;
}
... ... @@ -354,70 +359,6 @@ class AbstractAction extends Controller_Abstract
protected function setNavSide($guangChoosed = 'all')
{
$this->_view->assign('sideNav', \Index\SideModel::getLeftNav($guangChoosed));
/*
$this->_view->assign('sideNav', array(
0 => array(
'textCn' => '男生',
'textEn' => 'BOYS',
'styleClass' => 'boys',
'url' => '/boys',
),
1 => array(
'textCn' => '女生',
'textEn' => 'GIRLS',
'styleClass' => 'girls',
'url' => '/girls',
),
2 => array(
'textCn' => '潮童',
'textEn' => 'KIDS',
'styleClass' => 'kids',
'url' => '/kids',
),
3 => array(
'textCn' => '创意生活',
'textEn' => 'LIFE STYLE',
'styleClass' => 'life',
'url' => '/lifestyle',
),
4 => array(
'textCn' => '逛',
'textEn' => 'TRENDFINDER',
'styleClass' => 'guang',
'subNav' => array(
'list' => array(
0 => array(
'textCn' => '逛',
'textEn' => 'TrendFinder',
'back' => true,
'isSelect' => false,
),
1 => array(
'textCn' => '查看全部',
'textEn' => '',
'back' => false,
'isSelect' => ($guangChoosed === 'all') ? true : false,
'url' => '/guang/list/index?gender=1,2,3'
),
2 => array(
'textCn' => '只看男生',
'textEn' => 'Boys',
'back' => false,
'isSelect' => ($guangChoosed === 'boys') ? true : false,
'url' => '/guang/list/index?gender=1,3'
),
3 => array(
'textCn' => '只看女生',
'textEn' => 'Girls',
'back' => false,
'isSelect' => ($guangChoosed === 'girls') ? true : false,
'url' => '/guang/list/index?gender=2,3',
),
)
)
),
));
*/
}
/**
... ... @@ -439,7 +380,7 @@ class AbstractAction extends Controller_Abstract
*/
protected function setHomeChannelHeader()
{
$header['searchUrl'] = '';
$header['searchUrl'] = '/search';
$this->_view->assign('homeHeader', $header);
}
... ...
... ... @@ -118,7 +118,7 @@ class Yohobuy
}
/* 开启缓存的情况 */
if ($cache) {
if ($cache && USE_CACHE) {
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($url, 'master');
if (!empty($result)) {
... ... @@ -138,7 +138,7 @@ class Yohobuy
$data = array();
/* 开启缓存的情况 */
if ($cache) {
if ($cache && USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($url, 'slave');
... ... @@ -213,7 +213,7 @@ class Yohobuy
public static function getMulti($urlList = array(), $options = array(), $cache = false, $timeout = 3)
{
/* 开启缓存的情况 */
if ($cache) {
if ($cache && USE_CACHE) {
$key = md5(implode(',', array_values($urlList)));
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($key, 'master');
... ... @@ -291,7 +291,7 @@ class Yohobuy
curl_multi_close($mh);
/* 开启缓存的情况 */
if ($cache) {
if ($cache && USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
... ... @@ -319,7 +319,7 @@ class Yohobuy
public static function yarClient($uri, $method, $parameters = array(), $cache = false, $timeout = 3000)
{
/* 开启缓存的情况 */
if ($cache) {
if ($cache && USE_CACHE) {
$key = self::httpBuildQuery($uri . $method, $parameters);
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($key, 'master');
... ... @@ -340,7 +340,7 @@ class Yohobuy
}
/* 开启缓存的情况 */
if ($cache) {
if ($cache && USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
... ...
... ... @@ -7,6 +7,8 @@ namespace Configs;
*/
class CacheConfig
{
/* 公共的数据缓存 */
const KEY_COMMON_SIDE_NAV = 'key_common_side_nav'; // 公共的侧边栏
/* 控制器方法中的数据缓存 */
const KEY_ACTION_INDEX_INDEX = 'key_action_index_index'; // 频道选择
... ... @@ -15,6 +17,7 @@ class CacheConfig
const KEY_ACTION_KIDS_INDEX = 'key_action_kids_index'; // 潮童首页
const KEY_ACTION_LIFESTYLE_INDEX = 'key_action_lifestyle_index'; // 创意生活首页
const KEY_COMMON_SIDE_NAV = 'key_common_side_nav'; // 公共的侧边栏
const KEY_ACTION_PRODUCT_NEWSALE_INDEX = 'key_action_product_newsale_index'; // 新品到着
const KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT = 'key_action_product_newsale_discount'; // 折扣专区
}
... ...
... ... @@ -33,7 +33,7 @@ class ListData
$param = Yohobuy::param();
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_CATEGORY, $param);
return Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_CATEGORY, $param, 3600); // 有缓存1小时
}
/**
... ...
... ... @@ -26,8 +26,6 @@ class ListData
*/
public static function productInfoBySkns($skns)
{
//return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PRODUCT, 'getLessInfoByProductSkns', array());
// 调用搜索接口
$param = Yohobuy::param();
$param['method'] = 'app.search.li';
... ... @@ -36,7 +34,7 @@ class ListData
$param['order'] = 's_t_desc';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
return Yohobuy::get(Yohobuy::API_URL, $param, 3600); // 有缓存1小时
}
/**
... ...
<?php
namespace LibModels\Wap\Product;
use Api\Yohobuy;
... ... @@ -16,180 +17,192 @@ use Api\Sign;
class NewsaleData
{
/**
* 获取新品到着,折扣专区焦点图数据
* @param string $contentCode 内容位置码
* @return array 新品到着焦点图有关数据
*/
public static function getNewsaleFocus($contentCode)
{
// 构建必传参数
$param = Yohobuy::param();
$param['content_code'] = $contentCode;
/**
* 获取新品到着,折扣专区焦点图数据
* @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 新品到着商品数据
*/
public static function getNewProducts($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);
}
/**
* 筛选新品到着、折扣专区商品
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $brand 品牌Id
* @param integer $sort 品类Id
* @param integer $color 颜色Id
* @param integer $size 尺码Id
* @param string $price 价格
* @param string $p_d 折扣
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 新品到着商品数据
*/
public static function getNewProducts($gender, $channel, $limit = 50, $page = 1)
{
// 构建url地址列表
$urlList = array();
$param = Yohobuy::param();
$param['method'] = 'app.search.newProduct';
$param['gender'] = $gender;
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = $channel;
$build = $param;
$build['dayLimit'] = 1;
$build['client_secret'] = Sign::getSign($build);
$urlList['new'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $build);
$build = $param;
$build['dayLimit'] = 2;
$build['client_secret'] = Sign::getSign($build);
$urlList['week'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $build);
$build = $param;
$build['dayLimit'] = 3;
$build['client_secret'] = Sign::getSign($build);
$urlList['sale'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $build);
$build = array();
$param = array();
return Yohobuy::getMulti($urlList);
}
/**
* 筛选新品到着、折扣专区商品
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer $brand 品牌Id
* @param integer $sort 品类Id
* @param integer $color 颜色Id
* @param integer $size 尺码Id
* @param string $price 价格
* @param string $p_d 折扣
* @param integer $channel 表示频道号,1位男生,2为女生
* @param integer $dayLimit 限制读取多少天,默认为1天
* @param integer $limit 查询返回的最大限制数, 默认为50
* @param integer $page 分页第几页, 默认第1页
* @return array 根据指定条件筛选出来的商品
*/
public static function selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit = null, $limit = 50, $page = 1)
{
$selectItems = array(
'gender' => $gender,
'brand' => $brand,
'sort' => $sort,
'color' => $color,
'size' => $size,
'price' => $price,
'p_d' => $p_d,
'dayLimit' => $dayLimit
);
// 拉取筛选参数
$queriedParams = array_filter($selectItems, function($v) {return $v !== null;});
$param = Yohobuy::param();
$param['method'] = 'app.search.newProduct';
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = $channel;
$param = array_merge($param, $queriedParams);
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $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 折扣专区商品数据
*/
public static function getSaleProducts($gender, $channel, $limit = 60, $page = 1)
{
$param = Yohobuy::param();
$param['method'] = 'app.search.sales';
$param['gender'] = $gender;
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = $channel;
// 构建url地址列表
$urlList = array();
$param['p_d'] = '0.1,0.3';
$param['client_secret'] = Sign::getSign($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['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['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['ALL'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param);
return Yohobuy::getMulti($urlList);
}
/**
* 筛选折扣专区商品
*
* @param string gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer brand 品牌Id
* @param integer sort 品类Id
* @param integer color 颜色Id
* @param integer size 尺码Id
* @param string price 价格
* @param string $channel 1表示男, 2表示女
* @param integer $p_d 折扣
* @param integer $limit 查询返回的最大限制数, 默认为50
* @param integer $page 分页第几页, 默认第1页
* @return array 筛选出来的折扣专区商品
*/
public static function selectSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $limit = 50, $page = 1)
{
$selectItems = array(
'gender' => $gender,
'brand' => $brand,
'sort' => $sort,
'color' => $color,
'size' => $size,
'price' => $price
);
// 拉取筛选参数
$queriedParams = array_filter($selectItems, function($v) {return $v !== null;});
$param = Yohobuy::param();
$param['method'] = 'app.search.sales';
$param['yh_channel'] = $channel;
$param['p_d'] = $p_d;
$param['page'] = $page;
$param['limit'] = $limit;
$param = array_merge($param, $queriedParams);
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
* @param integer $dayLimit 限制读取多少天,默认为1天
* @param integer $limit 查询返回的最大限制数, 默认为50
* @param integer $page 分页第几页, 默认第1页
* @return array 根据指定条件筛选出来的商品
*/
public static function selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit = null, $limit = 50, $page = 1)
{
$selectItems = array(
'gender' => $gender,
'brand' => $brand,
'sort' => $sort,
'color' => $color,
'size' => $size,
'price' => $price,
'p_d' => $p_d,
'dayLimit' => $dayLimit
);
// 拉取筛选参数
$queriedParams = array_filter($selectItems, function($v) {
return $v !== null;
});
$param = Yohobuy::param();
$param['method'] = 'app.search.newProduct';
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = $channel;
$param = array_merge($param, $queriedParams);
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $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 折扣专区商品数据
*/
public static function getSaleProducts($gender, $channel, $limit = 60, $page = 1)
{
$param = Yohobuy::param();
$param['method'] = 'app.search.sales';
$param['gender'] = $gender;
$param['page'] = $page;
$param['limit'] = $limit;
$param['yh_channel'] = $channel;
// 构建url地址列表
$urlList = array();
$param['p_d'] = '0.1,0.3';
$param['client_secret'] = Sign::getSign($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['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['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['ALL'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL, $param);
return Yohobuy::getMulti($urlList);
}
/**
* 筛选折扣专区商品
*
* @param string gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部
* @param integer brand 品牌Id
* @param integer sort 品类Id
* @param integer color 颜色Id
* @param integer size 尺码Id
* @param string price 价格
* @param string $channel 1表示男, 2表示女
* @param integer $p_d 折扣
* @param integer $limit 查询返回的最大限制数, 默认为50
* @param integer $page 分页第几页, 默认第1页
* @return array 筛选出来的折扣专区商品
*/
public static function selectSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $limit = 50, $page = 1)
{
$selectItems = array(
'gender' => $gender,
'brand' => $brand,
'sort' => $sort,
'color' => $color,
'size' => $size,
'price' => $price
);
// 拉取筛选参数
$queriedParams = array_filter($selectItems, function($v) {
return $v !== null;
});
$param = Yohobuy::param();
$param['method'] = 'app.search.sales';
$param['yh_channel'] = $channel;
$param['p_d'] = $p_d;
$param['page'] = $page;
$param['limit'] = $limit;
$param = array_merge($param, $queriedParams);
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
<?php
namespace Plugin\DataProcess;
use Plugin\Helpers;
/**
... ... @@ -12,29 +13,29 @@ class NewSaleProcess
/**
* 处理新品到着、折扣专区数据
*
* @param array $data 接口传回的数据
* @param array $products 接口传回的数据
* @return array 处理之后的数据
*/
public static function newSaleData($focus, $products)
public static function newSaleData($products)
{
$result = array(
'headerBanner' => self::bannerData($focus),
'goodsContainer' => array()
);
foreach($products as $single)
{
$result = array();
$noTab = true;
$productsLi = array();
$tabItem = array();
foreach ($products as $single) {
if (empty($single)) {
continue;
}
// 处理Tabs
$noTab = true;
if(isset($single['tabs']) && $noTab)
{
if (isset($single['tabs']) && $noTab) {
$result['tabs'] = array();
foreach ($single['tabs'] as $key => $one)
{
foreach ($single['tabs'] as $key => $one) {
$tabItem = array();
$tabItem['title'] = $one;
if($key === 1)
{
if ($key === 1) {
$tabItem['focus'] = true;
}
$result['tabs'][] = $tabItem;
... ... @@ -43,24 +44,21 @@ class NewSaleProcess
}
// 处理商品
$productsLi = array('goods'=>array());
if(isset($single['product_list']))
{
foreach ($single['product_list'] as $value)
{
$productsLi['goods'][] = Helpers::formatProduct($value);
$productsLi = array();
if (isset($single['product_list'])) {
foreach ($single['product_list'] as $value) {
$productsLi['goods'][] = Helpers::formatProduct($value, true, false);
}
}
// 对于第一个productsLi添加show字段
if(count($result['goodsContainer']) === 0)
{
if (!isset($result['goodsContainer'][0])) {
$productsLi['show'] = true;
}
$result['goodsContainer'][] = $productsLi;
}
return $result;
}
... ... @@ -72,9 +70,9 @@ class NewSaleProcess
*/
public static function selectData($data)
{
$result = array('goods'=>array());
if($data['code'] === 200)
{
$result = array('goods' => array());
if (isset($data['code']) && $data['code'] === 200) {
foreach ($data['data']['product_list'] as $val) {
$result['goods'][] = Helpers::formatProduct($val);
}
... ... @@ -83,27 +81,4 @@ class NewSaleProcess
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;
}
}
... ...
... ... @@ -20,7 +20,7 @@ class Helpers
{
return strtr($url, array('{width}' => $width, '{height}' => $height, '{mode}' => $mode));
}
/**
* 获取过滤后的URL链接
*
... ... @@ -29,16 +29,23 @@ class Helpers
*/
public static function getFilterUrl($url)
{
return strstr($url, '&openby:yohobuy=', true);
$filter = strstr($url, 'openby:yohobuy=', true);
if ($filter) {
return rtrim(rtrim($filter, '?'), '&');
} else {
return $url;
}
}
/**
* 格式化商品信息
*
* @param array $productData 需要格式化的商品数据
* @param bool $showTag 控制是否显示标签
* @param bool $showNew 控制是否显示NEW图标
* @return array | false
*/
public static function formatProduct($productData, $showTags = true)
public static function formatProduct($productData, $showTags = true, $showNew = true)
{
// 商品信息有问题,则不显示
if (!isset($productData['product_skn'])) {
... ... @@ -62,7 +69,7 @@ class Helpers
if ($showTags) {
$result['tags'] = array();
$result['tags']['is_new'] = isset($productData['is_new']) && $productData['is_new'] === 'Y'; // 新品
$result['tags']['is_new'] = $showNew && isset($productData['is_new']) && $productData['is_new'] === 'Y'; // 新品
$result['tags']['is_discount'] = isset($productData['is_discount']) && $productData['is_discount'] === 'Y'; // 在售
$result['tags']['is_limited'] = isset($productData['is_limited']) && $productData['is_limited'] === 'Y'; // 限量
$result['tags']['is_yohood'] = isset($productData['is_yohood']) && $productData['is_yohood'] === 'Y'; // YOHOOD
... ... @@ -73,7 +80,7 @@ class Helpers
return $result;
}
/**
* 格式化资讯文章
*
... ... @@ -84,12 +91,12 @@ class Helpers
* @return array | false
*/
public static function formatArticle($articleData, $showTag = true, $share = false, $showAuthor = true)
{
{
// 资讯ID不存在,则不显示
if (!isset($articleData['id'])) {
return false;
}
$result = array();
$result['id'] = $articleData['id'];
$result['showTags'] = $showTag;
... ... @@ -106,12 +113,12 @@ class Helpers
// $result['collect'] = array();
// $result['collect']['isCollected'] = isset($articleData['isFavor']) && $articleData['isFavor'] === 'Y';
$result['share'] = $share;
// 判断是否显示作者信息
if ($showAuthor) {
$result['author'] = empty($articleData['author']) ? false : $articleData['author'];
}
// 模板中需要的标签标识
if ($showTag && isset($articleData['category_id'])) {
switch (strval($articleData['category_id'])) {
... ... @@ -137,6 +144,28 @@ class Helpers
}
/**
* 格式化广告焦点图数据
*
* @param array $bannerData 需要格式化的广告图数据
* @param int $width 图片的宽度
* @param int $height 图片的高度
* @param int $mode 使用的七牛模式
* @return array
*/
public static function formatBanner($bannerData, $width, $height, $mode = 2)
{
$result = array();
$result['img'] = self::getImageUrl($bannerData['src'], $width, $height, $mode);
if (isset($bannerData['url'])) {
$result['url'] = self::getFilterUrl($bannerData['url']);
}
$result['title'] = $bannerData['title'];
return $result;
}
/**
* 生成公开的TOKEN凭证
*
* @param string $string 字符串
... ... @@ -158,8 +187,7 @@ class Helpers
{
if ($token === self::makeToken($string)) {
return true;
}
else {
} else {
return false;
}
}
... ... @@ -291,7 +319,7 @@ class Helpers
* @param int $type
* @return array
*/
public static function getProductIcon($type)
public static function getProductIcon($type)
{
static $icons = array(
1 => 'cloth',
... ... @@ -306,8 +334,8 @@ class Helpers
308 => 'under'
);
$type = intval($type);
return isset($icons[$type]) ? $icons[$type] : '';
}
}
... ...
<?php
namespace Plugin\Partner\Alipay;
namespace Plugin\Partner\alipay;
use Plugin\Partner\Factory;
... ...
<?php
namespace Plugin\Partner\Qqconnect;
namespace Plugin\Partner\qqconnect;
use Plugin\Partner\Factory;
... ...
<?php
namespace Plugin\Partner\Sinaweibo;
namespace Plugin\Partner\sinaweibo;
use Plugin\Partner\Factory;
... ...
... ... @@ -9,7 +9,7 @@
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^.*(\.css|\.js|\.gif|\.png|\.jpg|\.jpeg|\.svg|\.woff|\.eot|\.ttf)$
RewriteRule ^/(.+)$ /index.php [L]
RewriteRule ^/(.+)$ /index-test.php [L]
<Directory />
LimitRequestBody 10485760
Options FollowSymLinks
... ... @@ -24,15 +24,15 @@
ServerAdmin root@localhost
CustomLog "/Data/logs/apache/access.guang.test.yoho.cn.log" combined
ErrorLog "/Data/logs/apache/error.guang.test.yoho.cn.log"
ServerName guang.test.yoho.cn
ServerName guang.buy.test.yoho.cn
DocumentRoot "/Data/code/git/yohobuy/yohobuy/m.yohobuy.com/public"
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^.*(\.css|\.js|\.gif|\.png|\.jpg|\.jpeg|\.svg|\.woff|\.eot|\.ttf)$
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule / /index.php?/guang/list/index&%1 [L]
RewriteRule ^/(.+)$ /index.php [L]
RewriteRule / /index.php/guang/list/index?%1 [L]
RewriteRule ^/(.+)$ /index-test.php [L]
<Directory />
LimitRequestBody 10485760
Options FollowSymLinks
... ...
server
{
listen 80;
server_name buy.test.yoho.cn guang.test.yoho.cn;
server_name buy.test.yoho.cn guang.buy.test.yoho.cn;
#access_log /Data/logs/access.buy.test.yoho.cn.log combined;
error_log /Data/logs/error.buy.test.yoho.cn.log warn;
... ...
... ... @@ -25,7 +25,6 @@ class BoysController extends AbstractAction
// 渲染模板并输出
$this->_view->display('index', array(
'searchUrl' => '/search',
'boysHomePage' => true,
'maybeLike' => true,
'content' => Index\HomeModel::getBoysFloor()
... ...
... ... @@ -25,7 +25,6 @@ class GirlsController extends AbstractAction
// 渲染模板并输出
$this->_view->display('index', array(
'searchUrl' => '/search',
'grilsHomePage' => true,
'maybeLike' => true,
'content' => Index\HomeModel::getGirlsFloor()
... ...
... ... @@ -25,7 +25,6 @@ class KidsController extends AbstractAction
// 渲染模板并输出
$this->_view->display('index', array(
'searchUrl' => '/search',
'kidsHomePage' => true,
'maybeLike' => true,
'content' => Index\HomeModel::getKidsFloor()
... ...
... ... @@ -25,7 +25,6 @@ class LifestyleController extends AbstractAction
// 渲染模板并输出
$this->_view->display('index', array(
'searchUrl' => '/search',
'lifestyleHomePage' => true,
'maybeLike' => true,
'content' => Index\HomeModel::getLifestyleFloor()
... ...
... ... @@ -20,7 +20,6 @@ use Configs\CacheConfig;
class HomeModel
{
/* 频道选择页取背景图片的位置码 */
const CODE_BG = '7ba9118028f9b22090b57341487567eb';
/* 男生楼层资源的位置码 */
... ... @@ -72,7 +71,7 @@ class HomeModel
*/
public static function setSwitchToCookie($cookie)
{
setcookie('_Channel', $cookie, time() + 86400 * 300, '/', '.' . SITE_DOMAIN);
setcookie('_Channel', $cookie, time() + 86400 * 300, '/', COOKIE_DOMAIN);
}
/**
... ...
<?php
namespace Product;
use Configs\CacheConfig;
use LibModels\Wap\Product\NewsaleData;
use Plugin\DataProcess\NewSaleProcess;
use Plugin\Helpers;
/**
* 新品到着相关的模板数据模型
*
* @name NewsaleModel
* @package models/Product
* @copyright yoho.inc
* @version 1.0 (2015-10-22 17:23:51)
* @author fei.hong <fei.hong@yoho.cn>
*/
class NewsaleModel
{
/* 获取新品到着顶部焦点图的位置码 */
const CODE_FOCUS_NEW = 'a7989369aa86681c678bc40f171b8f1d';
/* 获取折扣专区顶部焦点图的位置码 */
const CODE_FOCUS_SALE = 'e9c9be32d72e2906d404a72ee24cb523';
/**
* 获取新品到着的焦点图资源数据
*
* @return array
*/
public static function getNewFocus()
{
$result = array();
if (USE_CACHE) {
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_INDEX, 'master');
if (!empty($result)) {
return $result;
}
}
// 调用接口获取数据并封装
$newsale = NewsaleData::getNewsaleFocus(self::CODE_FOCUS_NEW);
if (isset($newsale['code']) && isset($newsale['data'][0]['data'][0])) {
$result = Helpers::formatBanner($newsale['data'][0]['data'][0], 640, 240);
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_INDEX, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_INDEX, $result);
}
}
return $result;
}
/**
* 获取折扣专区的焦点图资源数据
*
* @return array
*/
public static function getSaleFocus()
{
$result = array();
if (USE_CACHE) {
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT, 'master');
if (!empty($result)) {
return $result;
}
}
// 调用接口获取数据并封装
$newsale = NewsaleData::getNewsaleFocus(self::CODE_FOCUS_SALE);
if (isset($newsale['code']) && isset($newsale['data'][0]['data'][0])) {
$result = Helpers::formatBanner($newsale['data'][0]['data'][0], 640, 240);
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set(CacheConfig::KEY_ACTION_PRODUCT_NEWSALE_DISCOUNT, $result);
}
}
return $result;
}
/**
* 获取新品到着的商品列表
*
* @param int $channel 1:男生,2:女生,3:潮童,4:创意生活
* @param int $limit 查询的限制数
* @return array
*/
public static function getNewProducts($channel, $limit)
{
$result = array();
$products = array();
/* 根据频道查询商品列表 */
switch (intval($channel)) {
case 1: // 男生
$products = NewsaleData::getNewProducts('1,3', 1, $limit);
break;
case 2: // 女生
$products = NewsaleData::getNewProducts('2,3', 2, $limit);
break;
case 3: // 潮童
$products = NewsaleData::getNewProducts('1,2,3', 3, $limit);
break;
case 4: // 创意生活
$products = NewsaleData::getNewProducts('1,2,3', 4, $limit);
break;
}
/* 格式化商品数据 */
if (!empty($products)) {
$result = NewSaleProcess::newSaleData($products);
}
return $result;
}
/**
* 获取折扣专区的商品列表
*
* @param int $channel 1:男生,2:女生,3:潮童,4:创意生活
* @param int $limit 查询的限制数
* @return array
*/
public static function getSaleProducts($channel, $limit)
{
$result = array();
$products = array();
/* 根据频道查询商品列表 */
switch (intval($channel)) {
case 1: // 男生
$products = NewsaleData::getSaleProducts('1,3', 1, $limit);
break;
case 2: // 女生
$products = NewsaleData::getSaleProducts('2,3', 2, $limit);
break;
case 3: // 潮童
$products = NewsaleData::getSaleProducts('1,2,3', 3, $limit);
break;
case 4: // 创意生活
$products = NewsaleData::getSaleProducts('1,2,3', 4, $limit);
break;
}
/* 格式化商品数据 */
if (!empty($products)) {
$result = NewSaleProcess::newSaleData($products);
}
return $result;
}
}
... ...
... ... @@ -77,15 +77,21 @@ class DetailController extends AbstractAction
}
// 通过SKN获取商品信息
$product = ListData::productInfoBySkns($skns);
foreach ($product['data']['product_list'] as $i => $goods) {
// 最多显示4个
if ($i > 3) {
break;
if (!empty($product['data']['product_list'])) {
foreach ($product['data']['product_list'] as $i => $goods) {
// 最多显示4个
if ($i > 3) {
break;
}
$good[] = Helpers::formatProduct($goods, false);
}
$good[] = Helpers::formatProduct($goods, false);
}
// 没有商品
if (!isset($i)) {
continue;
}
// 单个商品
if ($i === 0) {
elseif ($i === 0) {
$build['relatedReco'] = $good[0];
}
// 多个商品
... ... @@ -106,10 +112,12 @@ class DetailController extends AbstractAction
}
// 通过SKN获取商品信息
$product = ListData::productInfoBySkns($skns);
foreach ($product['data']['product_list'] as $i => $goods) {
$good['goods'][] = Helpers::formatProduct($goods, false);
if (!empty($product['data']['product_list'])) {
foreach ($product['data']['product_list'] as $i => $goods) {
$good['goods'][] = Helpers::formatProduct($goods, false);
}
$build['collocation'][] = $good;
}
$build['collocation'][] = $good;
}
}
... ...
... ... @@ -18,6 +18,7 @@ class ListController extends AbstractAction
public function indexAction()
{
$this->setTitle('逛');
$this->setNavHeader('逛', true, SITE_DOMAIN);
$category = ListData::category();
$articleGroup = array();
... ... @@ -58,6 +59,11 @@ class ListController extends AbstractAction
$data['guang']['swiper'] = array();
$data['guang']['infos'] = array();
foreach ($articleGroup as $id => $value) {
// 判断是否有内容
if (empty($value['list'])) {
continue;
}
// 轮番广告
if ($id == 0) {
$build = array();
... ... @@ -101,6 +107,9 @@ class ListController extends AbstractAction
$this->error();
}
$this->setTitle($tag);
$this->setNavHeader($tag, true, SITE_DOMAIN);
$data = array();
// 模板中使用JS的标识
$data['guangList'] = true;
... ... @@ -115,8 +124,6 @@ class ListController extends AbstractAction
// 分页需要的参数
$data['guang']['tag'] = $tag;
$this->setTitle($tag);
$this->_view->display('list', $data);
}
... ... @@ -126,8 +133,6 @@ class ListController extends AbstractAction
public function editorAction()
{
$id = $this->get('id');
$uid = $this->getUid();
$udid = $this->getUdid();
// 获取作者信息
$author = ListData::author($id);
... ... @@ -137,6 +142,10 @@ class ListController extends AbstractAction
}
$this->setTitle('编辑简介');
$this->setNavHeader('编辑简介', true, SITE_DOMAIN);
$uid = $this->getUid();
$udid = $this->getUdid();
$data = array();
// 模板中使用JS的标识
... ... @@ -185,7 +194,7 @@ class ListController extends AbstractAction
/* 判断参数是否有效 */
$tag = $this->get('tag');
$sortId = $this->get('type');
$sortId = $this->get('type', 0);
$page = $this->get('page');
$gender = $this->get('gender');
$authorId = $this->get('authorId');
... ... @@ -203,7 +212,7 @@ class ListController extends AbstractAction
/* 获取资讯文章列表 */
$uid = $this->getUid();
$udid = $this->getUdid();
$article = ListData::article($gender, 0, $uid, $udid, $page, $tag, $authorId);
$article = ListData::article($gender, $sortId, $uid, $udid, $page, $tag, $authorId);
if (empty($article['data']['list']['artList'])) {
break;
}
... ...
... ... @@ -122,8 +122,8 @@ class BackController extends AbstractAction
'countryCode' => '+86'
);
// 生成HTML (mobileback.html)
$this->_view->html('mobileback.html');
// 生成HTML (phoneback.html)
$this->_view->html('phoneback');
$this->_view->display('mobile', $data);
}
... ...
... ... @@ -28,7 +28,7 @@ class LoginController extends AbstractAction
'aliLoginUrl' => '/passport/login/alipay', // 支付宝快捷登录的URL链接
'weiboLoginUrl' => '/passport/login/sina', // 微博登录的URL链接
'qqLoginUrl' => '/passport/login/qq', // 腾讯QQ登录的URL链接
'interationalUrl' => '/login.html', // 国际号登录的URL链接
'internationalUrl' => '/login.html', // 国际号登录的URL链接
'phoneRetriveUrl' => '/passport/back/mobile', // 通过手机号找回密码的URL链接
'emailRetriveUrl' => '/passport/back/email', // 通过邮箱找回密码的URL链接
);
... ... @@ -47,7 +47,7 @@ class LoginController extends AbstractAction
$this->setTitle('国际账号登录');
$data = array();
$data['loginInterational'] = true; // 模板中使用JS的标识
$data['loginInternational'] = true; // 模板中使用JS的标识
$data['backUrl'] = '/'; // 返回的URL链接
$data['headerText'] = '登录'; // 头部信息
$data['isPassportPage'] = true; // 模板中模块标识
... ...
... ... @@ -10,33 +10,54 @@ use Plugin\DataProcess\NewSaleProcess;
class NewsaleController extends AbstractAction
{
/**
* 新品到着
*
* @param int channel 1:男生,2:女生,3:潮童,4:创意生活
*/
public function indexAction()
{
$this->setTitle('新品到着');
$this->setNavHeader('新品到着');
$data = array(
'newArrival' => true,
'pageHeader' => array(
'navBack' => true,
'navTitle' => '新品到着',
'navHome' => '/'
)
);
$channel = $this->get('channel', 1);
if (!is_numeric($channel)) {
$this->error();
}
// 新品到着顶部焦点图
$focusData = NewsaleData::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d');
// 处理返回的数据
$focus = array();
if (isset($focusData['code']) && $focusData['code'] == 200) {
$focus = $focusData['data'];
$data = array();
$data['newArrival'] = true;
$data['headerBanner'] = \Product\NewsaleModel::getNewFocus();
$goodsList = \Product\NewsaleModel::getNewProducts($channel, 20);
if (!empty($goodsList)) {
$data += $goodsList;
}
$this->_view->display('new', $data);
}
// 批量获取新品到着商品数据
$products = NewsaleData::getNewProducts('1,3', 1, 60);
// 添加商品数据
$data += NewSaleProcess::newSaleData($focus, $products);
/**
* 折扣专区
*
* @param int channel 1:男生,2:女生,3:潮童,4:创意生活
*/
public function discountAction()
{
$this->setTitle('折扣专区');
$this->setNavHeader('Sale');
$this->_view->display('new', $data);
$channel = $this->get('channel', 1);
if (!is_numeric($channel)) {
$this->error();
}
$data = array();
$data['discount'] = true;
$data['headerBanner'] = \Product\NewsaleModel::getNewFocus();
$goodsList = \Product\NewsaleModel::getSaleProducts($channel, 20);
if (!empty($goodsList)) {
$data += $goodsList;
}
$this->_view->display('sale', $data);
}
/**
... ... @@ -56,61 +77,19 @@ class NewsaleController extends AbstractAction
$p_d = $this->get('p_d', null);
$channel = $this->get('channel', '1');
$dayLimit = $this->get('dayLimit', '1');
$limit = $this->get('limit', 50);
$limit = $this->get('limit', 20);
$page = $this->get('page', 1);
$data = NewsaleData::selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page);
$data = NewsaleData::selectNewSaleProducts(
$gender, $brand, $sort, $color,
$size, $price, $p_d, $channel, $dayLimit, $limit, $page
);
$result = NewSaleProcess::selectData($data);
$this->_view->display('product', $result);
} else {
echo ' ';
}
}
/**
* 折扣专区
*/
public function discountAction()
{
$this->setTitle('折扣专区');
$data = array(
'discount' => true,
'pageHeader' => array(
'navBack' => true,
'navTitle' => 'SALE',
'navHome' => '/'
)
);
// 折扣专区顶部焦点图
$focusData = NewsaleData::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523');
// 处理返回的数据
$focus = array();
if (isset($focusData['code']) && $focusData['code'] == 200) {
$focus = $focusData['data'];
}
// 折扣专区商品数据
$products = NewsaleData::getSaleProducts('1,3', 1);
// 更新tabs
$tabs = array();
foreach (array_keys($products) as $key => $value) {
$tabItem = array();
$tabItem['title'] = $value;
if ($key === 0) {
$tabItem['focus'] = true;
}
$tabs[] = $tabItem;
}
$data['tabs'] = $tabs;
// 添加商品数据
$data += NewSaleProcess::newSaleData($focus, $products);
/* echo '<pre>';
print_r($data);exit; */
$this->_view->display('sale', $data);
}
}
... ...
... ... @@ -47,6 +47,11 @@ class RecomController extends AbstractAction
if (empty($recom['data']['product_list'])) {
break;
}
/* 判断是否已没有数据 */
if (intval($page) > intval($recom['data']['page_total'])) {
break;
}
/* 构建商品数据 */
$data = array();
... ... @@ -54,8 +59,8 @@ class RecomController extends AbstractAction
$data['goods'][] = Helpers::formatProduct($value, true);
}
$this->_view->display('maylike', $data);
}
while (false);
} while (false);
echo ' ';
}
... ... @@ -81,19 +86,24 @@ class RecomController extends AbstractAction
}
/* 取可能喜欢的数据 */
$recom = RecomData::mayLikeKids();
$recom = RecomData::mayLikeKids($page);
if (empty($recom['data']['product_list'])) {
break;
}
/* 判断是否已没有数据 */
if (intval($page) > intval($recom['data']['page_total'])) {
break;
}
/* 构建模板需要的商品数据 */
$data = array();
foreach ($recom['data']['product_list'] as $value) {
$data['goods'][] = Helpers::formatProduct($value, true);
}
$this->_view->display('maylike', $data);
}
while (false);
} while (false);
echo ' ';
}
... ... @@ -137,8 +147,8 @@ class RecomController extends AbstractAction
$data['goodsContainer'][] = $build;
}
$this->_view->display('maylikelife', $data);
}
while (false);
} while (false);
echo ' ';
}
... ... @@ -178,5 +188,4 @@ class RecomController extends AbstractAction
// $this->echoJson($data);
// }
// }
}
... ...
<?php
use Yaf\Application;
define('SITE_DOMAIN', 'm.dev.yohobuy.com'); // 网站主域名
define('OLD_DOMAIN', 'm.yohobuy.com'); // 网站旧域名
define('SITE_MAIN', 'http://m.dev.yohobuy.com'); // 网站主域名
define('OLD_MAIN', 'http://m.yohobuy.com'); // 网站旧域名
define('COOKIE_DOMAIN', '.m.dev.yohobuy.com'); // COOKIE作用域
define('USE_CACHE', false); // 缓存的开关
define('APPLICATION_PATH', dirname(__DIR__));
define('ROOT_PATH', dirname(dirname(APPLICATION_PATH)));
... ...
<?php
use Yaf\Application;
define('SITE_DOMAIN', 'buy.test.yoho.cn'); // 网站主域名
define('OLD_DOMAIN', 'm.yohobuy.com'); // 网站旧域名
define('SITE_MAIN', 'http://buy.test.yoho.cn'); // 网站主域名
define('OLD_MAIN', 'http://m.yohobuy.com'); // 网站旧域名
define('COOKIE_DOMAIN', '.test.yoho.cn'); // COOKIE作用域
define('USE_CACHE', true); // 缓存的开关
define('APPLICATION_PATH', dirname(__DIR__));
define('ROOT_PATH', dirname(dirname(APPLICATION_PATH)));
... ...
<?php
use Yaf\Application;
define('SITE_DOMAIN', 'wap.yohobuy.com'); // 网站主域名
define('OLD_DOMAIN', 'm.yohobuy.com'); // 网站旧域名
define('SITE_MAIN', 'http://wap.m.yohobuy.com'); // 网站主域名
define('OLD_MAIN', 'http://m.yohobuy.com'); // 网站旧域名
define('COOKIE_DOMAIN', '.m.yohobuy.com'); // COOKIE作用域
define('USE_CACHE', true); // 缓存的开关
define('APPLICATION_PATH', dirname(__DIR__));
define('ROOT_PATH', dirname(dirname(APPLICATION_PATH)));
... ...