|
|
@ -24,6 +24,7 @@ use cores\exception\BaseException; |
|
|
|
use think\db\exception\DbException; |
|
|
|
use think\db\exception\DbException; |
|
|
|
use think\response\Json; |
|
|
|
use think\response\Json; |
|
|
|
use app\common\enum\goods\GoodsDeliveryTime; |
|
|
|
use app\common\enum\goods\GoodsDeliveryTime; |
|
|
|
|
|
|
|
use think\facade\Cache; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 商品控制器 |
|
|
|
* 商品控制器 |
|
|
|
* Class Goods |
|
|
|
* Class Goods |
|
|
@ -142,7 +143,7 @@ class Goods extends Controller |
|
|
|
]; |
|
|
|
]; |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
if ($goods->stock_total > ($value['num'] ?? 1)) { |
|
|
|
if ($goods->stock_total >= ($value['num'] ?? 1)) { |
|
|
|
$res = "有货"; |
|
|
|
$res = "有货"; |
|
|
|
} |
|
|
|
} |
|
|
|
$data = [ |
|
|
|
$data = [ |
|
|
@ -288,13 +289,13 @@ class Goods extends Controller |
|
|
|
public function recommended(): Json |
|
|
|
public function recommended(): Json |
|
|
|
{ |
|
|
|
{ |
|
|
|
$service = new GoodsService; |
|
|
|
$service = new GoodsService; |
|
|
|
// $cache_key = "goods_recommended".$this->storeId; |
|
|
|
$cache_key = "goods_recommended".$this->storeId; |
|
|
|
// if(Cache::has($cache_key)) { |
|
|
|
if(Cache::has($cache_key)) { |
|
|
|
// $goodsList = Cache::get($cache_key); |
|
|
|
$goodsList = Cache::get($cache_key); |
|
|
|
// return $this->renderSuccess(compact('goodsList')); |
|
|
|
return $this->renderSuccess(compact('goodsList')); |
|
|
|
// } |
|
|
|
} |
|
|
|
$goodsList = $service->recommended(); |
|
|
|
$goodsList = $service->recommended(); |
|
|
|
// Cache::set($cache_key, $goodsList, 60*60); |
|
|
|
Cache::set($cache_key, $goodsList, 60*60); |
|
|
|
return $this->renderSuccess(compact('goodsList')); |
|
|
|
return $this->renderSuccess(compact('goodsList')); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|