...
|
...
|
@@ -20,6 +20,7 @@ use LibModels\Wap\Product\SearchData; |
|
|
*/
|
|
|
class PlusstarData
|
|
|
{
|
|
|
|
|
|
const URI_BRANDLIST = 'guang/api/v1/plustar/getlist';
|
|
|
const URI_BRANDINFO_PLUSSTAR = 'guang/service/v1/plustar/';
|
|
|
const URI_BRANDINFO_FAVORITE = 'shops/service/v1/favorite/';
|
...
|
...
|
@@ -126,30 +127,34 @@ class PlusstarData |
|
|
$result['getUidProductFav'] = array();
|
|
|
$result['getArticleByBrand'] = array();
|
|
|
|
|
|
$key = CacheConfig::KEY_ACTION_GUANG_PLUSTAR_DATA . strval($id);
|
|
|
// 客户端类型
|
|
|
$clientType = $isApp ? 'iphone' : 'h5';
|
|
|
$key = CacheConfig::KEY_ACTION_GUANG_PLUSTAR_DATA . strval($id) . $clientType;
|
|
|
|
|
|
// 品牌详情信息
|
|
|
$brandInfo = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_PLUSSTAR, 'getBrandInfo', array(array('id' => $id)), 3600); // 缓存1小时
|
|
|
if (!isset($brandInfo['data']['brand_id'])) {
|
|
|
if (USE_CACHE) {
|
|
|
// 先尝试获取二级缓存(slave), 有数据则直接返回.
|
|
|
$result = Cache::get($key, 'slave');
|
|
|
if (!empty($result)) {
|
|
|
return $result;
|
|
|
$cached = Cache::get($key, 'master');
|
|
|
if (!empty($cached)) {
|
|
|
return $cached;
|
|
|
}
|
|
|
}
|
|
|
return $result;
|
|
|
|
|
|
// 品牌详情信息
|
|
|
$brandInfo = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_PLUSSTAR, 'getBrandInfo', array(array('id' => $id)), 3600); // 缓存1小时
|
|
|
if (!isset($brandInfo['data']['brand_id'])) {
|
|
|
return $result;
|
|
|
} else {
|
|
|
$result['getBrandInfo'] = $brandInfo;
|
|
|
}
|
|
|
|
|
|
// 是否收藏店铺
|
|
|
$isUidOk = $uid && is_numeric($uid);
|
|
|
if ($isUidOk) {
|
|
|
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_FAVORITE, 'getUidBrandFav', array($uid, $brandInfo['data']['brand_id']), function($retval) use(&$result) {
|
|
|
$result['getUidBrandFav'] = (isset($retval['message']) && $retval['message'] == 'favorite') ? true : false;
|
|
|
});
|
|
|
}
|
|
|
// // 是否收藏店铺
|
|
|
// $isUidOk = $uid && is_numeric($uid);
|
|
|
// if ($isUidOk) {
|
|
|
// Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_FAVORITE, 'getUidBrandFav', array($uid, $brandInfo['data']['brand_id']), function($retval) use(&$result) {
|
|
|
// $result['getUidBrandFav'] = (isset($retval['message']) && $retval['message'] == 'favorite') ? true : false;
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
// 相关资讯列表 (3篇)
|
|
|
$result['getArticleByBrand'] = array();
|
...
|
...
|
@@ -202,11 +207,11 @@ class PlusstarData |
|
|
// 用户是否收藏该商品
|
|
|
$skn = $value['product_skn'];
|
|
|
$result['getUidProductFav'][$skn] = false;
|
|
|
if ($isUidOk) {
|
|
|
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_FAVORITE, 'getUidProductFav', array($uid, $value['product_skn']), function($retval) use(&$result, &$skn) {
|
|
|
$result['getUidProductFav'][$skn] = empty($retval['data']) ? false : $retval['data'];
|
|
|
});
|
|
|
}
|
|
|
// if ($isUidOk) {
|
|
|
// Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_BRANDINFO_FAVORITE, 'getUidProductFav', array($uid, $value['product_skn']), function($retval) use(&$result, &$skn) {
|
|
|
// $result['getUidProductFav'][$skn] = empty($retval['data']) ? false : $retval['data'];
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
$i ++;
|
|
|
}
|
...
|
...
|
@@ -215,11 +220,16 @@ class PlusstarData |
|
|
// 调用发起请求
|
|
|
Yohobuy::yarConcurrentLoop();
|
|
|
|
|
|
if (USE_CACHE && !empty($result['getBrandInfo'])) {
|
|
|
if (USE_CACHE) {
|
|
|
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
|
|
|
if (empty($result)) {
|
|
|
$result = Cache::get($key, 'slave');
|
|
|
}
|
|
|
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
|
|
|
elseif (!empty($result['getBrandInfo'])) {
|
|
|
Cache::set($key, $result);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
|
|
...
|
...
|
|