|
@@ -343,4 +343,90 @@ class InfoController extends AbstractAction |
|
@@ -343,4 +343,90 @@ class InfoController extends AbstractAction |
343
|
$data = array();
|
343
|
$data = array();
|
344
|
}
|
344
|
}
|
345
|
|
345
|
|
|
|
346
|
+ /**
|
|
|
347
|
+ * 提供给YOHO资讯站调用的接口
|
|
|
348
|
+ *
|
|
|
349
|
+ * @param int id 逛内容ID
|
|
|
350
|
+ * @return json
|
|
|
351
|
+ */
|
|
|
352
|
+ public function foryohoAction()
|
|
|
353
|
+ {
|
|
|
354
|
+ $result = array();
|
|
|
355
|
+
|
|
|
356
|
+ do {
|
|
|
357
|
+ /* 判断参数是否有效 */
|
|
|
358
|
+ $id = $this->get('id');
|
|
|
359
|
+ if (!is_numeric($id)) {
|
|
|
360
|
+ break;
|
|
|
361
|
+ }
|
|
|
362
|
+
|
|
|
363
|
+ /* 判断是否有内容 */
|
|
|
364
|
+ $detail = DetailData::packageForYoho($id, true);
|
|
|
365
|
+ if (empty($detail['getArticleContent'])) {
|
|
|
366
|
+ break;
|
|
|
367
|
+ }
|
|
|
368
|
+
|
|
|
369
|
+ /* 品牌信息 */
|
|
|
370
|
+ $result['brand'] = $detail['getBrand'];
|
|
|
371
|
+
|
|
|
372
|
+ $build = array();
|
|
|
373
|
+ $good = array();
|
|
|
374
|
+ $skns = array();
|
|
|
375
|
+ $product = array();
|
|
|
376
|
+
|
|
|
377
|
+ /* 商品信息 */
|
|
|
378
|
+ foreach ($detail['getArticleContent'] as $value) {
|
|
|
379
|
+ $build = array();
|
|
|
380
|
+ if (isset($value['goods']['data'])) {
|
|
|
381
|
+ $good = array();
|
|
|
382
|
+ // 遍历取得SKN
|
|
|
383
|
+ $skns = array();
|
|
|
384
|
+ foreach ($value['goods']['data'] as $goods) {
|
|
|
385
|
+ $skns[] = $goods['id'];
|
|
|
386
|
+ }
|
|
|
387
|
+ // 通过SKN获取商品信息
|
|
|
388
|
+ $product = ListData::productInfoBySkns($skns);
|
|
|
389
|
+ if (!empty($product['data']['product_list'])) {
|
|
|
390
|
+ foreach ($product['data']['product_list'] as $i => $goods) {
|
|
|
391
|
+ // 最多显示4个
|
|
|
392
|
+ if ($i > 3) {
|
|
|
393
|
+ break;
|
|
|
394
|
+ }
|
|
|
395
|
+ $good[] = Helpers::formatProduct($goods, false, true, true, 235, 314, true);
|
|
|
396
|
+ }
|
|
|
397
|
+ }
|
|
|
398
|
+ // 没有商品
|
|
|
399
|
+ if (!isset($i)) {
|
|
|
400
|
+ continue;
|
|
|
401
|
+ }
|
|
|
402
|
+ $result['goods'] = $good;
|
|
|
403
|
+ }
|
|
|
404
|
+ // 悬停浮动商品
|
|
|
405
|
+ elseif (isset($value['goodsGroup']['data'])) {
|
|
|
406
|
+ foreach ($value['goodsGroup']['data'] as $goods) {
|
|
|
407
|
+ $good = array();
|
|
|
408
|
+ $good['img'] = Helpers::getImageUrl($goods['cover']['cover'], 235, 314);
|
|
|
409
|
+ $good['icon'] = Helpers::getProductIcon($goods['cover']['maxSortId']);
|
|
|
410
|
+ $good['goods'] = array();
|
|
|
411
|
+ $skns = array();
|
|
|
412
|
+ foreach ($goods['list'] as $mini) {
|
|
|
413
|
+ $skns[] = $mini['id'];
|
|
|
414
|
+ }
|
|
|
415
|
+ // 通过SKN获取商品信息
|
|
|
416
|
+ $product = ListData::productInfoBySkns($skns);
|
|
|
417
|
+ if (!empty($product['data']['product_list'])) {
|
|
|
418
|
+ foreach ($product['data']['product_list'] as $i => $goods) {
|
|
|
419
|
+ $good['goods'][] = Helpers::formatProduct($goods, false, true, true, 235, 314, true);
|
|
|
420
|
+ }
|
|
|
421
|
+ $result['group'][] = $good;
|
|
|
422
|
+ }
|
|
|
423
|
+ }
|
|
|
424
|
+ }
|
|
|
425
|
+ }
|
|
|
426
|
+ }
|
|
|
427
|
+ while (false);
|
|
|
428
|
+
|
|
|
429
|
+ $this->echoJson($result);
|
|
|
430
|
+ }
|
|
|
431
|
+
|
346
|
} |
432
|
} |