ztt 9 months ago
parent 0c9559daa1
commit 99747ccd30
  1. 24
      app/api/controller/Goods.php
  2. 4
      app/store/controller/Presale.php

@ -196,16 +196,20 @@ class Goods extends Controller
public function recommended(): Json
{
$service = new GoodsService;
$cache_key = "goods_recommended".$this->storeId;
if(Cache::has($cache_key)) {
$goodsList = Cache::get($cache_key);
return $this->renderSuccess(compact('goodsList'));
}
// $cache_key = "goods_recommended".$this->storeId;
// if(Cache::has($cache_key)) {
// $goodsList = Cache::get($cache_key);
// return $this->renderSuccess(compact('goodsList'));
// }
$goodsList = $service->recommended();
Cache::set($cache_key, $goodsList, 60*60);
// Cache::set($cache_key, $goodsList, 60*60);
return $this->renderSuccess(compact('goodsList'));
}
/**
* 商品大牌和新品
* @return Json
*/
public function brandList(): Json
{
$service = new GoodsService;
@ -231,6 +235,10 @@ class Goods extends Controller
return $this->renderSuccess($goodsList);
}
/**
* 排行行查看更多
* @return Json
*/
public function chartsGoodsList(): Json
{
$service = new GoodsService;
@ -239,6 +247,10 @@ class Goods extends Controller
return $this->renderSuccess($goodsList);
}
/**
* 首页分类商品排行榜 默认返回3条
* @return Json
*/
public function chartsGoodsJing(): Json
{
$service = new GoodsService;

@ -21,7 +21,7 @@ class Presale extends Controller
// 店员列表
$model = new PreSaleModel;
$goodsModel = new \app\common\model\Goods();
$list = $model->where('store_id', $this->storeId)->select();
$list = $model->where('store_id', $this->storeId)->paginate(15);
foreach ($list as &$row) {
$row['goods_list'] = $goodsModel->whereIn('goods_id', explode(',', $row['goods_list']))->select()->toArray();
}
@ -48,7 +48,7 @@ class Presale extends Controller
$list = $model->with(['goods'])
->where('store_id', $this->storeId)
->where('pre_id', $pre_id)
->select();
->paginate(15);
return $this->renderSuccess(compact('list'));
}

Loading…
Cancel
Save