Authored by hf

code review by fei.hong: do merge yang.yang and shaofeng codes

... ... @@ -84,13 +84,13 @@ class BrandData
/**
* 通过品牌id获取品牌Folder
*
* @param int $brand_id 品牌id
* @param int $brandId 品牌id
* @param int $status 状态
* @return array
*/
public static function getFolderByBrand($brand_id, $status = 1)
public static function getFolderByBrand($brandId, $status = 1)
{
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_BRAND_FOLDER, 'getFolderByBrand', array($brand_id, $status));
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_BRAND_FOLDER, 'getFolderByBrand', array($brandId, $status), 600);
}
/**
... ... @@ -101,7 +101,7 @@ class BrandData
*/
public static function getByNodeContent($node, $mode = 'release')
{
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_BRAND_NODECONTENT, 'getByNodeContent', array($node, $mode));
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URL_BRAND_NODECONTENT, 'getByNodeContent', array($node, $mode), 600);
}
/*
... ...
... ... @@ -286,7 +286,7 @@ class HelperSearch
//即将售罄
$isFew = $val['is_soon_sold_out'] === 'Y' ? true : false;
//SALE
$isSale = ($val['is_discount'] == 'Y') ? true : false;
$isSale = ($val['is_discount'] == 'Y' && $val['market_price']/$val['sales_price'] >= 2) ? true : false;
//新品节
//再到着
//年终大促
... ... @@ -1419,7 +1419,7 @@ class HelperSearch
$result[$key]['isVedio'] = true;
$result[$key]['src'] = $vo;
} else {
$result[$key]['href'] = isset($href[1][$key]) ? $href[1][$key] : '';
$result[$key]['href'] = isset($href[1][$key]) ? str_replace('&', '&', $href[1][$key]) : '';
$result[$key]['src'] = $vo;
}
}
... ... @@ -1427,6 +1427,7 @@ class HelperSearch
}
}
/**
* 组织品牌店铺信息
* @param $shop 搜索接口返回的,店铺数据,用于搜索品牌时显示品牌信息条
... ...
... ... @@ -42,21 +42,7 @@ class BrandsModel
{
//获取$condition和$option 筛选条件和排序条件
$searchCondition = SearchModel::searchCondition($condition, $options);
if (USE_CACHE) {
$key = WebCacheConfig::KEY_WEB_PRODUCT_INDEX_BRAND;
if (!empty($searchCondition['userInput'])) {
$key .= http_build_query($searchCondition['userInput'], null, '&');
}
$key .= http_build_query($condition, null, '&');
$channel = HomeModel::getSwitchChannel();
//key加上性别参数
$key .= $channel;
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($key, 'master');
if (!empty($result)) {
return $result;
}
}
// 并行调用品牌相关接口并封装数据
$result = self::getBrandData($searchCondition, $options);
... ... @@ -70,16 +56,6 @@ class BrandsModel
$result['leftContent'][]['picLink']['list'] = $nodeContent;
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
elseif(isset($result['goods']) && !empty($result['goods']) && isset($result['leftContent']) && !empty($result['leftContent'])) {
Cache::set($key, $result, 1800); // 缓存30分钟
}
}
return $result;
}
... ... @@ -152,7 +128,7 @@ class BrandsModel
'title' => 'YOHO!有货'
),
array(
'href' => Helpers::url('/brands/brands'),
'href' => Helpers::url('/brands'),
'name' => '品牌一览',
'title' => '品牌一览'
),
... ... @@ -270,7 +246,7 @@ class BrandsModel
$sortCondition= array(
'attribute_not' => $searchCondition['sortCondition']['attribute_not'],
'brand' => $searchCondition['sortCondition']['brand']
);;
);
$urlList['sort'] = SearchData::getClassesUrl($sortCondition);
//组合搜索品牌url
... ...
... ... @@ -33,20 +33,7 @@ class IndexModel
public static function getIndexData($customCondition, $customOptions)
{
$searchCondition = SearchModel::searchCondition($customCondition, $customOptions);
if (USE_CACHE) {
$key = WebCacheConfig::KEY_WEB_PRODUCT_LIST_INDEX;
if (!empty($searchCondition['userInput'])) {
$key .= http_build_query($searchCondition['userInput'], null, '&');
}
//key加上性别参数
$key .= Helpers::getChannelNameByCookie();
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($key, 'master');
if (!empty($result)) {
return $result;
}
}
// 组合搜索商品url
$urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
... ... @@ -68,7 +55,7 @@ class IndexModel
$misort = isset($searchCondition['condition']['misort']) ? $searchCondition['condition']['misort'] : 0;
$positionId = isset($searchCondition['options']['positionId']) ? $searchCondition['options']['positionId'] : '';
$gender = $searchCondition['condition']['gender'] == '2,3' ? 2 : 1;
if ($msort && $misort && $positionId) {
$banner = array();
$bannerData = SearchData::getBannerData($positionId, $msort, $misort, $gender);
... ... @@ -89,16 +76,6 @@ class IndexModel
}
$result['leftContent'][] = $res;
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
elseif(isset($data['product']) && !empty($data['product']['product_list']) && isset($data['sort']) && !empty($data['sort'])) {
Cache::set($key, $result, 600); // 缓存10分钟
}
}
return $result;
}
... ...
... ... @@ -32,20 +32,7 @@ class NewModel
{
$urlList = array();
$searchCondition = SearchModel::searchCondition($customCondition, $customOptions);
if (USE_CACHE) {
$key = WebCacheConfig::KEY_WEB_PRODUCT_LIST_NEW;
if (!empty($searchCondition['userInput'])) {
$key .= http_build_query($searchCondition['userInput'], null, '&');
}
$channel = HomeModel::getSwitchChannel();
//key加上性别参数
$key .= $channel;
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($key, 'master');
if (!empty($result)) {
return $result;
}
}
// 组合搜索商品url
$urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
// 组合搜索分类url
... ... @@ -61,17 +48,7 @@ class NewModel
// 组织模板数据
$result = HelperSearch::getList($data, $searchCondition['options'], $searchCondition['userInput']);
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
elseif(isset($data['product']) && !empty($data['product']['product_list']) && isset($data['sort']) && !empty($data['sort'])) {
Cache::set($key, $result, 1800); // 缓存30分钟
}
}
return $result;
}
... ...
... ... @@ -183,20 +183,6 @@ class SearchModel
public static function getListData($customCondition = array(), $customOptions = array())
{
$searchCondition = self::searchCondition($customCondition, $customOptions);
if (USE_CACHE) {
$key = WebCacheConfig::KEY_WEB_PRODUCT_LIST_SALE;
if (!empty($searchCondition['userInput'])) {
$key .= http_build_query($searchCondition['userInput'], null, '&');
}
$channel = HomeModel::getSwitchChannel();
//key加上性别参数
$key .= $channel;
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($key, 'master');
if (!empty($result)) {
return $result;
}
}
// 组合搜索商品url
$urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
// 组合搜索分类url
... ... @@ -210,16 +196,6 @@ class SearchModel
$data = Yohobuy::getMulti($urlList);
// 组织模板数据
$result = HelperSearch::getList($data, $searchCondition['options'], $searchCondition['userInput']);
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
elseif (isset($data['product']['product_list']) && !empty($data['product']['product_list']) && isset($data['sort']) && !empty($data['sort'])) {
Cache::set($key, $result, 1800); // 缓存30分钟
}
}
// 清空不使用的变量
$searchCondition = array();
... ... @@ -242,17 +218,6 @@ class SearchModel
public static function searchData($customCondition, $customOptions)
{
$searchCondition = self::searchCondition($customCondition, $customOptions);
if (USE_CACHE) {
$key = WebCacheConfig::KEY_WEB_PRODUCT_SEARCH_DATA;
if (!empty($searchCondition['userInput'])) {
$key .= http_build_query($searchCondition['userInput'], null, '&');
}
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get($key, 'master');
if (!empty($result)) {
return $result;
}
}
$urlList = array();
// 组合搜索商品url
$urlList['product'] = SearchData::getProductUrl($searchCondition['condition']);
... ... @@ -274,16 +239,6 @@ class SearchModel
}
// 组织模板数据
$result = HelperSearch::getList($data, $searchCondition['options'], $searchCondition['userInput']);
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get($key, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
elseif (isset($data['product']['product_list']) && !empty($data['product']['product_list']) && isset($data['sort']) && !empty($data['sort'])) {
Cache::set($key, $result, 600); // 缓存10分钟
}
}
// 清空不使用的变量
$searchCondition = array();
... ...