lqmac 8 months ago
parent 1be278da4d
commit 3cf25d8c3f
  1. 4
      app/api/controller/Controller.php
  2. 6
      app/api/controller/Goods.php
  3. 4
      app/store/model/Goods.php

@ -34,6 +34,8 @@ class Controller extends BaseController
protected $storeInfo;
protected $user;
/**
* API基类初始化
* @throws BaseException
@ -49,7 +51,7 @@ class Controller extends BaseController
$this->checkStore();
// 验证当前客户端状态
$this->checkClient();
//$user = $this->getLoginUser();
$this->user = $this->getLoginUser(false);
// if ($user) {
// if ($user->user_type == 0 || $user->status == 0) {
// throwError('很抱歉,您没有权限进入系统');

@ -294,11 +294,11 @@ class Goods extends Controller
public function recommended(): Json
{
$service = new GoodsService;
$cache_key = "goods_recommended".$this->storeId;
if(Cache::has($cache_key)) {
$cache_key = "goods_recommended".$this->storeId.($this->user ? $this->user->user_type : 0);
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);
return $this->renderSuccess(compact('goodsList'));

@ -183,7 +183,7 @@ class Goods extends GoodsModel
public function setIsPool(array $goodsIds, int $is_pool): bool
{
// 批量更新记录
return static::updateBase(['is_pool' => $is_pool,'update_time' => time()], [['goods_id', 'in', $goodsIds]]);
return static::updateBase(['is_pool' => $is_pool,'update_time' => time(),'sale_time' => time()], [['goods_id', 'in', $goodsIds]]);
}
/**
* 修改商品状态
@ -194,7 +194,7 @@ class Goods extends GoodsModel
public function setIsSale(array $goodsIds, int $is_sale): bool
{
// 批量更新记录
return static::updateBase(['is_sale' => $is_sale,'update_time' => time()], [['goods_id', 'in', $goodsIds]]);
return static::updateBase(['is_sale' => $is_sale,'update_time' => time(),'sale_time' => time()], [['goods_id', 'in', $goodsIds]]);
}
/**
* 修改商品状态

Loading…
Cancel
Save