...
|
...
|
@@ -5,6 +5,7 @@ namespace LibModels\Wap\Guang; |
|
|
use Api\Yohobuy;
|
|
|
use Configs\CacheConfig;
|
|
|
use Plugin\Cache;
|
|
|
use Api\Sign;
|
|
|
|
|
|
/**
|
|
|
* 逛资讯详情相关的数据模型
|
...
|
...
|
@@ -45,7 +46,17 @@ class DetailData |
|
|
// 先尝试获取一级缓存(master), 有数据则直接返回.
|
|
|
$cached = Cache::get($key, 'master');
|
|
|
if (!empty($cached)) {
|
|
|
$article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticle', array($id, $clientType), false, 1000);
|
|
|
// $article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticle', array($id, $clientType), false, 1000);
|
|
|
|
|
|
// 获取资讯
|
|
|
$param = Yohobuy::param();
|
|
|
$param['article_id'] = $id;
|
|
|
$param['client_type'] = $clientType;
|
|
|
$param['private_key'] = Yohobuy::$privateKeyList['h5'];
|
|
|
$param['client_secret'] = Sign::getSign($param);
|
|
|
$result = Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE . 'getArticle', $param);
|
|
|
$article = $result['data'];
|
|
|
|
|
|
if (isset($article['pageViews'])) {
|
|
|
$cached['getArticle']['pageViews'] = $article['pageViews'];
|
|
|
}
|
...
|
...
|
@@ -54,7 +65,20 @@ class DetailData |
|
|
}
|
|
|
|
|
|
// 获取资讯
|
|
|
$article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticle', array($id, $clientType), false, 1500);
|
|
|
// $article = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticle', array($id, $clientType), false, 1500);
|
|
|
// ksort($article);
|
|
|
// file_put_contents('../../../../../../Desktop/app/o/getArticle.txt', var_export($article, true));
|
|
|
|
|
|
// 获取资讯
|
|
|
$param = Yohobuy::param();
|
|
|
$param['article_id'] = $id;
|
|
|
$param['client_type'] = $clientType;
|
|
|
$param['private_key'] = Yohobuy::$privateKeyList['h5'];
|
|
|
$param['client_secret'] = Sign::getSign($param);
|
|
|
$result = Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE . 'getArticle', $param);
|
|
|
$article = $result['data'];
|
|
|
// file_put_contents('../../../../../../Desktop/app/n/getArticle3.txt', var_export($article, true));
|
|
|
|
|
|
if (!isset($article['author_id'])) {
|
|
|
// 再尝试获取二级缓存(slave), 有数据则直接返回.
|
|
|
$cached = Cache::get($key, 'slave');
|
...
|
...
|
@@ -65,31 +89,89 @@ class DetailData |
|
|
}
|
|
|
$result['getArticle'] = $article;
|
|
|
|
|
|
|
|
|
// 获取作者信息
|
|
|
$param = Yohobuy::param();
|
|
|
$param['author_id'] = $article['author_id'];
|
|
|
$param['client_secret'] = Sign::getSign($param);
|
|
|
$urlList['getAuthor'] = Yohobuy::httpBuildQuery(Yohobuy::SERVICE_URL . self::URI_PACKAGE_AUTHOR . 'getAuthor', $param);
|
|
|
|
|
|
// 获取资讯内容
|
|
|
$param = Yohobuy::param();
|
|
|
$param['article_id'] = $id;
|
|
|
$param['client_type'] = $clientType;
|
|
|
$param['private_key'] = Yohobuy::$privateKeyList['h5'];
|
|
|
$param['client_secret'] = Sign::getSign($param);
|
|
|
$urlList['getArticleContent'] = Yohobuy::httpBuildQuery(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE . 'getArticleContent', $param);
|
|
|
|
|
|
// 获取资讯相关的品牌
|
|
|
$param = Yohobuy::param();
|
|
|
$param['article_id'] = $id;
|
|
|
$param['client_type'] = $clientType;
|
|
|
$param['private_key'] = Yohobuy::$privateKeyList['h5'];
|
|
|
$param['client_secret'] = Sign::getSign($param);
|
|
|
$urlList['getBrand'] = Yohobuy::httpBuildQuery(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE . 'getBrand', $param);
|
|
|
|
|
|
// 获取资讯相关的其它资讯
|
|
|
if (isset($article['tag'])) {
|
|
|
$param = Yohobuy::param();
|
|
|
$param['article_id'] = $id;
|
|
|
$param['client_type'] = $clientType;
|
|
|
$param['tags'] = $article['tag'];
|
|
|
$param['offset'] = 0;
|
|
|
$param['limit'] = 3;
|
|
|
$param['private_key'] = Yohobuy::$privateKeyList['h5'];
|
|
|
$param['client_secret'] = Sign::getSign($param);
|
|
|
$urlList['getOtherArticle'] = Yohobuy::httpBuildQuery(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE . 'getOtherArticle', $param);
|
|
|
}
|
|
|
|
|
|
$multiResult = Yohobuy::getMulti($urlList, array());
|
|
|
$result['getAuthor'] = $multiResult['getAuthor'];
|
|
|
$result['getArticleContent'] = $multiResult['getArticleContent'];
|
|
|
$result['getBrand'] = $multiResult['getBrand'];
|
|
|
$result['getOtherArticle'] = $multiResult['getOtherArticle'];
|
|
|
// var_dump($urlList);
|
|
|
// file_put_contents('../../../../../../Desktop/app/n/getAuthor.txt', var_export($result['getAuthor'], true));
|
|
|
// file_put_contents('../../../../../../Desktop/app/n/getArticleContent.txt', var_export($result['getArticleContent'], true));
|
|
|
// file_put_contents('../../../../../../Desktop/app/n/getBrand.txt', var_export($result['getBrand'], true));
|
|
|
// file_put_contents('../../../../../../Desktop/app/n/getOtherArticle.txt', var_export($result['getOtherArticle'], true));
|
|
|
|
|
|
/*
|
|
|
// 获取作者信息
|
|
|
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_AUTHOR, 'getAuthor', array($article['author_id'], $clientType), function ($retval) use (&$result) {
|
|
|
$result['getAuthor'] = empty($retval) ? array() : $retval;
|
|
|
ksort($retval);
|
|
|
file_put_contents('../../../../../../Desktop/app/o/getAuthor.txt', var_export($retval, true));
|
|
|
});
|
|
|
|
|
|
// 获取资讯内容
|
|
|
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticleContent', array($id, $clientType), function ($retval) use (&$result) {
|
|
|
$result['getArticleContent'] = empty($retval) ? array() : $retval;
|
|
|
ksort($retval);
|
|
|
file_put_contents('../../../../../../Desktop/app/o/getArticleContent.txt', var_export($retval, true));
|
|
|
});
|
|
|
|
|
|
// 获取资讯相关的品牌
|
|
|
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getBrand', array($id, $clientType), function ($retval) use (&$result) {
|
|
|
$result['getBrand'] = empty($retval) ? array() : $retval;
|
|
|
ksort($retval);
|
|
|
file_put_contents('../../../../../../Desktop/app/o/getBrand.txt', var_export($retval, true));
|
|
|
});
|
|
|
|
|
|
// 获取资讯相关的其它资讯
|
|
|
if (isset($article['tag'])) {
|
|
|
Yohobuy::yarConcurrentCall(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getOtherArticle', array($article['tag'], $id, 0, 3, $clientType), function ($retval) use (&$result) {
|
|
|
$result['getOtherArticle'] = empty($retval) ? array() : $retval;
|
|
|
ksort($retval);
|
|
|
file_put_contents('../../../../../../Desktop/app/o/getOtherArticle.txt', var_export($retval, true));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 调用发起请求
|
|
|
Yohobuy::yarConcurrentLoop();
|
|
|
|
|
|
*/
|
|
|
|
|
|
if (USE_CACHE) {
|
|
|
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
|
|
|
if (empty($result)) {
|
...
|
...
|
@@ -181,7 +263,15 @@ class DetailData |
|
|
*/
|
|
|
public static function intro($id)
|
|
|
{
|
|
|
return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticleContent', array($id, 'h5'));
|
|
|
$param = Yohobuy::param();
|
|
|
$param['article_id'] = $id;
|
|
|
$param['client_type'] = 'h5';
|
|
|
$param['private_key'] = Yohobuy::$privateKeyList['h5'];
|
|
|
$param['client_secret'] = Sign::getSign($param);
|
|
|
$result = Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE . 'getArticleContent', $param);
|
|
|
return $result['data'];
|
|
|
|
|
|
// return Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_PACKAGE_ARTICLE, 'getArticleContent', array($id, 'h5'));
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|