批量上架redis

This commit is contained in:
mkm 2023-05-22 11:41:48 +08:00
parent 8e1532f17d
commit c242e5d721

View File

@ -1597,6 +1597,18 @@ class ProductRepository extends BaseRepository
throw new ValidateException('ID'.$product->product_id . ' 商品正在参与助力活动');
}
$this->dao->updates($id,[$field => $status]);
if ($product->product_type==0){
$RedisCacheService = app()->make(RedisCacheService::class);
if ($status==1){
foreach ($id as $k=>$v){
$RedisCacheService->SADD ('CloudMerchanSpu'.$product['mer_id'], $v);
}
}else{
foreach ($id as $k=>$v){
$RedisCacheService->SREM ('CloudMerchanSpu'.$product['mer_id'], $v);
}
}
}
Queue::push(ChangeSpuStatusJob::class,['id' => $id,'product_type'=> $product_type]);
}