|
|
|
@ -13,6 +13,95 @@ use App\Controller\BaseController; |
|
|
|
class GoodsRecommendController extends BaseController |
|
|
|
{ |
|
|
|
|
|
|
|
protected $data; |
|
|
|
|
|
|
|
public function __construct() |
|
|
|
{ |
|
|
|
$this->data = [ |
|
|
|
[ |
|
|
|
'goods' => [ |
|
|
|
'id' => 1, |
|
|
|
'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', |
|
|
|
'name' => '【优质】大白菜11', |
|
|
|
'spec' => [ |
|
|
|
['key' => '净含量', 'value' => '500g'] |
|
|
|
], |
|
|
|
'tags' => ['限时', '折扣'], |
|
|
|
'original_price' => 50.5, |
|
|
|
'price' => 25.25, |
|
|
|
'inventory' => 10, |
|
|
|
'month_sales' => 20, |
|
|
|
'total_sales' => 20, |
|
|
|
'cart_num' => 0, |
|
|
|
'is_effective' => 2, |
|
|
|
'noneffective_note' => '已卖完', |
|
|
|
], |
|
|
|
'store' => ['id' => 111, 'logo' => '', 'name' => '我是一个商家'] |
|
|
|
], |
|
|
|
[ |
|
|
|
'goods' => [ |
|
|
|
'id' => 2, |
|
|
|
'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', |
|
|
|
'name' => '【优质】大白菜11', |
|
|
|
'spec' => [ |
|
|
|
['key' => '净含量', 'value' => '500g'] |
|
|
|
], |
|
|
|
'tags' => ['限时', '折扣'], |
|
|
|
'original_price' => 50.5, |
|
|
|
'price' => 25.25, |
|
|
|
'inventory' => 10, |
|
|
|
'month_sales' => 20, |
|
|
|
'total_sales' => 20, |
|
|
|
'cart_num' => 0, |
|
|
|
'is_effective' => 2, |
|
|
|
'noneffective_note' => '已卖完', |
|
|
|
], |
|
|
|
'store' => ['id' => 222, 'logo' => '', 'name' => '我是一个商家222'] |
|
|
|
], |
|
|
|
[ |
|
|
|
'goods' => [ |
|
|
|
'id' => 3, |
|
|
|
'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', |
|
|
|
'name' => '【优质】大白菜11', |
|
|
|
'spec' => [ |
|
|
|
['key' => '净含量', 'value' => '500g'] |
|
|
|
], |
|
|
|
'tags' => ['限时', '折扣'], |
|
|
|
'original_price' => 50.5, |
|
|
|
'price' => 25.25, |
|
|
|
'inventory' => 10, |
|
|
|
'month_sales' => 20, |
|
|
|
'total_sales' => 20, |
|
|
|
'cart_num' => 0, |
|
|
|
'is_effective' => 2, |
|
|
|
'noneffective_note' => '已卖完', |
|
|
|
], |
|
|
|
'store' => ['id' => 333, 'logo' => '', 'name' => '我是一个商家333'] |
|
|
|
], |
|
|
|
[ |
|
|
|
'goods' => [ |
|
|
|
'id' => 4, |
|
|
|
'cover_img' => config('alioss.img_host').'/attachment/types/c9b656181bbbc463624ca3803c5be7539f2fd62253f9a-cwVLri.png', |
|
|
|
'name' => '【优质】大白菜11', |
|
|
|
'spec' => [ |
|
|
|
['key' => '净含量', 'value' => '500g'] |
|
|
|
], |
|
|
|
'tags' => ['限时', '折扣'], |
|
|
|
'original_price' => 50.5, |
|
|
|
'price' => 25.25, |
|
|
|
'inventory' => 10, |
|
|
|
'month_sales' => 20, |
|
|
|
'total_sales' => 20, |
|
|
|
'cart_num' => 0, |
|
|
|
'is_effective' => 2, |
|
|
|
'noneffective_note' => '已卖完', |
|
|
|
], |
|
|
|
'store' => ['id' => 444, 'logo' => '', 'name' => '我是一个商家444'] |
|
|
|
] |
|
|
|
]; |
|
|
|
parent::__construct(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取首页tabs推荐商品列表 |
|
|
|
* 1、前端上传tab标识 |
|
|
|
@ -119,4 +208,17 @@ class GoodsRecommendController extends BaseController |
|
|
|
'tab_data' => $tabsData[$this->request->post('tab', 'applet_index_recommend')] |
|
|
|
]); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取搜索页推荐商品列表 |
|
|
|
* 1、前端上传标识recommend_search_goods 或 recommend_search_stores |
|
|
|
* 2、根据标识从Elasticsearch中获取商品IDs |
|
|
|
* 3、根据IDs获取商品数据 |
|
|
|
* 4、返回数据,id、封面图、名称、原价、现价、库存、月销、tag、规格、购物车相关、商户id、商户avatar、商户名 |
|
|
|
*/ |
|
|
|
public function getForSearch() |
|
|
|
{ |
|
|
|
return $this->success(['tab_data' => $this->data]); |
|
|
|
} |
|
|
|
|
|
|
|
} |