|
@@ -342,5 +342,94 @@ class InfoController extends AbstractAction |
|
@@ -342,5 +342,94 @@ class InfoController extends AbstractAction |
342
|
$detail = array();
|
342
|
$detail = array();
|
343
|
$data = array();
|
343
|
$data = array();
|
344
|
}
|
344
|
}
|
|
|
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
|
+ $app = $this->get('app');
|
|
|
364
|
+ $isApp = empty($app) ? false : true;
|
|
|
365
|
+
|
|
|
366
|
+ /* 判断是否有内容 */
|
|
|
367
|
+ $detail = DetailData::package($id, $isApp);
|
|
|
368
|
+ if (empty($detail['getArticleContent'])) {
|
|
|
369
|
+ break;
|
|
|
370
|
+ }
|
|
|
371
|
+
|
|
|
372
|
+ /* 品牌信息 */
|
|
|
373
|
+ $result['brand'] = $detail['getBrand'];
|
|
|
374
|
+
|
|
|
375
|
+ $build = array();
|
|
|
376
|
+ $good = array();
|
|
|
377
|
+ $skns = array();
|
|
|
378
|
+ $product = array();
|
|
|
379
|
+
|
|
|
380
|
+ /* 商品信息 */
|
|
|
381
|
+ foreach ($detail['getArticleContent'] as $value) {
|
|
|
382
|
+ $build = array();
|
|
|
383
|
+ if (isset($value['goods']['data'])) {
|
|
|
384
|
+ $good = array();
|
|
|
385
|
+ // 遍历取得SKN
|
|
|
386
|
+ $skns = array();
|
|
|
387
|
+ foreach ($value['goods']['data'] as $goods) {
|
|
|
388
|
+ $skns[] = $goods['id'];
|
|
|
389
|
+ }
|
|
|
390
|
+ // 通过SKN获取商品信息
|
|
|
391
|
+ $product = ListData::productInfoBySkns($skns);
|
|
|
392
|
+ if (!empty($product['data']['product_list'])) {
|
|
|
393
|
+ foreach ($product['data']['product_list'] as $i => $goods) {
|
|
|
394
|
+ // 最多显示4个
|
|
|
395
|
+ if ($i > 3) {
|
|
|
396
|
+ break;
|
|
|
397
|
+ }
|
|
|
398
|
+ $good[] = Helpers::formatProduct($goods, false, true, true, 235, 314, true);
|
|
|
399
|
+ }
|
|
|
400
|
+ }
|
|
|
401
|
+ // 没有商品
|
|
|
402
|
+ if (!isset($i)) {
|
|
|
403
|
+ continue;
|
|
|
404
|
+ }
|
|
|
405
|
+ $result['goods'] = $good;
|
|
|
406
|
+ }
|
|
|
407
|
+ // 悬停浮动商品
|
|
|
408
|
+ elseif (isset($value['goodsGroup']['data'])) {
|
|
|
409
|
+ foreach ($value['goodsGroup']['data'] as $goods) {
|
|
|
410
|
+ $good = array();
|
|
|
411
|
+ $good['img'] = Helpers::getImageUrl($goods['cover']['cover'], 235, 314);
|
|
|
412
|
+ $good['icon'] = Helpers::getProductIcon($goods['cover']['maxSortId']);
|
|
|
413
|
+ $good['goods'] = array();
|
|
|
414
|
+ $skns = array();
|
|
|
415
|
+ foreach ($goods['list'] as $mini) {
|
|
|
416
|
+ $skns[] = $mini['id'];
|
|
|
417
|
+ }
|
|
|
418
|
+ // 通过SKN获取商品信息
|
|
|
419
|
+ $product = ListData::productInfoBySkns($skns);
|
|
|
420
|
+ if (!empty($product['data']['product_list'])) {
|
|
|
421
|
+ foreach ($product['data']['product_list'] as $i => $goods) {
|
|
|
422
|
+ $good['goods'][] = Helpers::formatProduct($goods, false, true, true, 235, 314, true);
|
|
|
423
|
+ }
|
|
|
424
|
+ $result['group'][] = $good;
|
|
|
425
|
+ }
|
|
|
426
|
+ }
|
|
|
427
|
+ }
|
|
|
428
|
+ }
|
|
|
429
|
+ }
|
|
|
430
|
+ while (false);
|
|
|
431
|
+
|
|
|
432
|
+ $this->echoJson($result);
|
|
|
433
|
+ }
|
345
|
|
434
|
|
346
|
} |
435
|
} |