...
|
...
|
@@ -343,4 +343,90 @@ class InfoController extends AbstractAction |
|
|
$data = array();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 提供给YOHO资讯站调用的接口
|
|
|
*
|
|
|
* @param int id 逛内容ID
|
|
|
* @return json
|
|
|
*/
|
|
|
public function foryohoAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
do {
|
|
|
/* 判断参数是否有效 */
|
|
|
$id = $this->get('id');
|
|
|
if (!is_numeric($id)) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 判断是否有内容 */
|
|
|
$detail = DetailData::packageForYoho($id, true);
|
|
|
if (empty($detail['getArticleContent'])) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
/* 品牌信息 */
|
|
|
$result['brand'] = $detail['getBrand'];
|
|
|
|
|
|
$build = array();
|
|
|
$good = array();
|
|
|
$skns = array();
|
|
|
$product = array();
|
|
|
|
|
|
/* 商品信息 */
|
|
|
foreach ($detail['getArticleContent'] as $value) {
|
|
|
$build = array();
|
|
|
if (isset($value['goods']['data'])) {
|
|
|
$good = array();
|
|
|
// 遍历取得SKN
|
|
|
$skns = array();
|
|
|
foreach ($value['goods']['data'] as $goods) {
|
|
|
$skns[] = $goods['id'];
|
|
|
}
|
|
|
// 通过SKN获取商品信息
|
|
|
$product = ListData::productInfoBySkns($skns);
|
|
|
if (!empty($product['data']['product_list'])) {
|
|
|
foreach ($product['data']['product_list'] as $i => $goods) {
|
|
|
// 最多显示4个
|
|
|
if ($i > 3) {
|
|
|
break;
|
|
|
}
|
|
|
$good[] = Helpers::formatProduct($goods, false, true, true, 235, 314, true);
|
|
|
}
|
|
|
}
|
|
|
// 没有商品
|
|
|
if (!isset($i)) {
|
|
|
continue;
|
|
|
}
|
|
|
$result['goods'] = $good;
|
|
|
}
|
|
|
// 悬停浮动商品
|
|
|
elseif (isset($value['goodsGroup']['data'])) {
|
|
|
foreach ($value['goodsGroup']['data'] as $goods) {
|
|
|
$good = array();
|
|
|
$good['img'] = Helpers::getImageUrl($goods['cover']['cover'], 235, 314);
|
|
|
$good['icon'] = Helpers::getProductIcon($goods['cover']['maxSortId']);
|
|
|
$good['goods'] = array();
|
|
|
$skns = array();
|
|
|
foreach ($goods['list'] as $mini) {
|
|
|
$skns[] = $mini['id'];
|
|
|
}
|
|
|
// 通过SKN获取商品信息
|
|
|
$product = ListData::productInfoBySkns($skns);
|
|
|
if (!empty($product['data']['product_list'])) {
|
|
|
foreach ($product['data']['product_list'] as $i => $goods) {
|
|
|
$good['goods'][] = Helpers::formatProduct($goods, false, true, true, 235, 314, true);
|
|
|
}
|
|
|
$result['group'][] = $good;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
while (false);
|
|
|
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|