You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
4.9 KiB

  1. <?php
  2. namespace App\Controller\v3;
  3. use App\Constants\v3\Tabs;
  4. use App\Controller\BaseController;
  5. /**
  6. * 推荐商品相关
  7. * Class GoodsRecommend
  8. * @package App\Controller\v3
  9. */
  10. class GoodsRecommendController extends BaseController
  11. {
  12. /**
  13. * 获取首页tabs推荐商品列表
  14. * 1、前端上传tab标识
  15. * 2、根据tab标识从Elasticsearch中获取商品IDs
  16. * 3、根据IDs获取商品数据
  17. * 4、返回数据,id、封面图、名称、原价、现价、库存、月销、tag、规格、购物车相关、商户id、商户avatar、商户名
  18. */
  19. public function getByTabsForAppletIndex()
  20. {
  21. $tabsData = [
  22. Tabs::APPLET_INDEX_RECOMMEND => [
  23. [
  24. 'goods' => [
  25. 'id' => 1,
  26. 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png',
  27. 'name' => '【优质】大白菜11',
  28. 'spec' => [
  29. ['key' => '净含量', 'value' => '500g']
  30. ],
  31. 'tags' => ['限时', '折扣'],
  32. 'original_price' => 50.5,
  33. 'price' => 25.25,
  34. 'inventory' => 10,
  35. 'month_sales' => 20,
  36. 'total_sales' => 20,
  37. 'cart_num' => 0,
  38. 'is_effective' => 2,
  39. 'noneffective_note' => '已卖完',
  40. ],
  41. 'store' => ['id' => 111, 'logo' => '', 'name' => '我是一个商家']
  42. ],
  43. ],
  44. Tabs::APPLET_INDEX_NEW => [
  45. [
  46. 'goods' => [
  47. 'id' => 2,
  48. 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png',
  49. 'name' => '【优质】大白菜11',
  50. 'spec' => [
  51. ['key' => '净含量', 'value' => '500g']
  52. ],
  53. 'tags' => ['限时', '折扣'],
  54. 'original_price' => 50.5,
  55. 'price' => 25.25,
  56. 'inventory' => 10,
  57. 'month_sales' => 20,
  58. 'total_sales' => 20,
  59. 'cart_num' => 0,
  60. 'is_effective' => 2,
  61. 'noneffective_note' => '已卖完',
  62. ],
  63. 'store' => ['id' => 222, 'logo' => '', 'name' => '我是一个商家222']
  64. ],
  65. ],
  66. Tabs::APPLET_INDEX_FRESH => [
  67. [
  68. 'goods' => [
  69. 'id' => 3,
  70. 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png',
  71. 'name' => '【优质】大白菜11',
  72. 'spec' => [
  73. ['key' => '净含量', 'value' => '500g']
  74. ],
  75. 'tags' => ['限时', '折扣'],
  76. 'original_price' => 50.5,
  77. 'price' => 25.25,
  78. 'inventory' => 10,
  79. 'month_sales' => 20,
  80. 'total_sales' => 20,
  81. 'cart_num' => 0,
  82. 'is_effective' => 2,
  83. 'noneffective_note' => '已卖完',
  84. ],
  85. 'store' => ['id' => 333, 'logo' => '', 'name' => '我是一个商家333']
  86. ],
  87. ],
  88. Tabs::APPLET_INDEX_OFFICE => [
  89. [
  90. 'goods' => [
  91. 'id' => 4,
  92. 'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png',
  93. 'name' => '【优质】大白菜11',
  94. 'spec' => [
  95. ['key' => '净含量', 'value' => '500g']
  96. ],
  97. 'tags' => ['限时', '折扣'],
  98. 'original_price' => 50.5,
  99. 'price' => 25.25,
  100. 'inventory' => 10,
  101. 'month_sales' => 20,
  102. 'total_sales' => 20,
  103. 'cart_num' => 0,
  104. 'is_effective' => 2,
  105. 'noneffective_note' => '已卖完',
  106. ],
  107. 'store' => ['id' => 444, 'logo' => '', 'name' => '我是一个商家444']
  108. ],
  109. ]
  110. ];
  111. return $this->success([
  112. 'tab_data' => $tabsData[$this->request->post('tab', 'applet_index_recommend')]
  113. ]);
  114. }
  115. }