...
|
...
|
@@ -5,6 +5,7 @@ use Api\Yohobuy; |
|
|
use Plugin\Helpers;
|
|
|
use Plugin\HelperSearch;
|
|
|
use \LibModels\Web\Product\SearchData;
|
|
|
use Configs\CacheConfig;
|
|
|
|
|
|
/**
|
|
|
* sale首页模板数据模型
|
...
|
...
|
@@ -165,19 +166,41 @@ class SearchModel |
|
|
{
|
|
|
$urlList = array();
|
|
|
$searchCondition = self::searchCondition($customCondition, $customOptions);
|
|
|
if (USE_CACHE) {
|
|
|
$key = CacheConfig::KEY_WEB_PRODUCT_SEARCH_DATA;
|
|
|
if (!empty($condition)) {
|
|
|
$key .= http_build_query($searchCondition['condition'], null, '&');
|
|
|
}
|
|
|
// 先尝试获取一级缓存(master), 有数据则直接返回.
|
|
|
$result = Cache::get($key, 'master');
|
|
|
if (!empty($result)) {
|
|
|
return $result;
|
|
|
}
|
|
|
}
|
|
|
// 组合搜索商品url
|
|
|
$urlList['product'] = HelperSearch::getProductUrl($searchCondition['condition']);
|
|
|
// 组合搜索分类url
|
|
|
$urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['condition']);
|
|
|
$urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['sortCondition']);
|
|
|
// 组合搜索店铺url
|
|
|
if (isset($searchCondition['condition']['query'])) {
|
|
|
$param['keyword'] = $searchCondition['condition']['query'];
|
|
|
$urlList['shop'] = HelperSearch::getShopUrl($param);
|
|
|
}
|
|
|
$result = Yohobuy::getMulti($urlList, array(), true);
|
|
|
$data = Yohobuy::getMulti($urlList, array(), true);
|
|
|
// 组织模板数据
|
|
|
$data = HelperSearch::getList($result, $searchCondition['options']);
|
|
|
return $data;
|
|
|
$result = HelperSearch::getList($data, $searchCondition['options']);
|
|
|
|
|
|
if (USE_CACHE) {
|
|
|
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
|
|
|
if (empty($result)) {
|
|
|
$result = Cache::get($key, 'slave');
|
|
|
}
|
|
|
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
|
|
|
else {
|
|
|
Cache::set($key, $result, 1800); // 缓存30分钟
|
|
|
}
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
/**
|
|
|
* 根据product_sn查询产品图片信息
|
...
|
...
|
|