|
|
@ -99,11 +99,12 @@ class GoodsRecommendController extends BaseController |
|
|
public function getByTab() |
|
|
public function getByTab() |
|
|
{ |
|
|
{ |
|
|
$marketId = $this->request->input('market_id', 0); |
|
|
$marketId = $this->request->input('market_id', 0); |
|
|
|
|
|
$tab = $this->request->input('tab', ''); |
|
|
|
|
|
|
|
|
$storeTable = ApplicationContext::getContainer()->get(Store::class)->getTable(); |
|
|
$storeTable = ApplicationContext::getContainer()->get(Store::class)->getTable(); |
|
|
$goodsTable = ApplicationContext::getContainer()->get(Goods::class)->getTable(); |
|
|
$goodsTable = ApplicationContext::getContainer()->get(Goods::class)->getTable(); |
|
|
|
|
|
|
|
|
$goods = Goods::query() |
|
|
|
|
|
|
|
|
$builder = Goods::query() |
|
|
->select(''.$goodsTable.'.*') |
|
|
->select(''.$goodsTable.'.*') |
|
|
->addSelect(''.$goodsTable.'.sales as total_sales') |
|
|
->addSelect(''.$goodsTable.'.sales as total_sales') |
|
|
->join($storeTable,''.$storeTable.'.id', '=', ''.$goodsTable.'.store_id') |
|
|
->join($storeTable,''.$storeTable.'.id', '=', ''.$goodsTable.'.store_id') |
|
|
@ -126,9 +127,18 @@ class GoodsRecommendController extends BaseController |
|
|
// $query->where('time2', '>=', date('H:i'))
|
|
|
// $query->where('time2', '>=', date('H:i'))
|
|
|
// ->orWhere('time4', '>=', date('H:i'));
|
|
|
// ->orWhere('time4', '>=', date('H:i'));
|
|
|
// })
|
|
|
// })
|
|
|
->inRandomOrder() |
|
|
|
|
|
->limit(20) |
|
|
|
|
|
->get()->toArray(); |
|
|
|
|
|
|
|
|
->inRandomOrder(); |
|
|
|
|
|
|
|
|
|
|
|
switch ($tab) { |
|
|
|
|
|
case Tabs::RECOMMEND_FOR_GOODS_DETAIL: |
|
|
|
|
|
$builder = $builder->limit(10); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
$builder = $builder->limit(20); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$goods = $builder->get()->toArray(); |
|
|
|
|
|
|
|
|
return $this->success(['has_more_pages' => false, 'tab_data' => $goods]); |
|
|
return $this->success(['has_more_pages' => false, 'tab_data' => $goods]); |
|
|
} |
|
|
} |
|
|
|