|
|
|
@ -23,16 +23,35 @@ class GoodsRecommendController extends BaseController |
|
|
|
*/ |
|
|
|
public function getByTabsForAppletIndex() |
|
|
|
{ |
|
|
|
$goods = Goods::query() |
|
|
|
->with(['store']) |
|
|
|
->forPage($this->request->input('page', 1), $this->request->input('pagesize', 15)) |
|
|
|
->get()->toArray(); |
|
|
|
return $this->success(['tab_data' => $goods]); |
|
|
|
$tab = $this->request->input('tab', ''); |
|
|
|
$page = $this->request->input('page', 1); |
|
|
|
$pagesize = $this->request->input('pagesize', 10); |
|
|
|
|
|
|
|
$builder = Goods::query()->with('store'); |
|
|
|
|
|
|
|
switch ($tab) { |
|
|
|
case Tabs::APPLET_INDEX_RECOMMEND: |
|
|
|
$builder = $builder->orderBy('sales', 'desc'); |
|
|
|
break; |
|
|
|
case Tabs::APPLET_INDEX_NEW: |
|
|
|
$builder = $builder->orderBy('created_at', 'desc'); |
|
|
|
break; |
|
|
|
case Tabs::APPLET_INDEX_FRESH: |
|
|
|
$builder = $builder->orderBy('price', 'asc'); |
|
|
|
break; |
|
|
|
case Tabs::APPLET_INDEX_OFFICE: |
|
|
|
$builder = $builder->whereIn('category_id', [97,98]); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
$paginate = $builder->paginate($pagesize); |
|
|
|
$goods = $paginate->toArray(); |
|
|
|
return $this->success(['has_more_pages' => $paginate->hasMorePages(), 'tab_data' => $goods]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取搜索页推荐商品列表 |
|
|
|
* 获取推荐商品列表 |
|
|
|
* 1、前端上传标识 |
|
|
|
* recommend_search_goods |
|
|
|
* recommend_search_stores |
|
|
|
@ -45,9 +64,10 @@ class GoodsRecommendController extends BaseController |
|
|
|
{ |
|
|
|
$goods = Goods::query() |
|
|
|
->with(['store']) |
|
|
|
->limit(6) |
|
|
|
->inRandomOrder() |
|
|
|
->limit(2) |
|
|
|
->get()->toArray(); |
|
|
|
return $this->success(['tab_data' => $goods]); |
|
|
|
return $this->success(['has_more_pages' => false, 'tab_data' => $goods]); |
|
|
|
} |
|
|
|
|
|
|
|
|