|
|
|
@ -625,16 +625,73 @@ class Goods extends Controller |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//商品一键上架 |
|
|
|
|
/** |
|
|
|
|
* 商品一键上架 |
|
|
|
|
* [oneClickShelf description] |
|
|
|
|
* @return [type] [description] |
|
|
|
|
*/ |
|
|
|
|
public function oneClickShelf(): Json{ |
|
|
|
|
|
|
|
|
|
//查出下架、自营、入池的商品 |
|
|
|
|
$goods = GoodsModel::where('channel','zy')->where('is_delete', 0)->where('status', 20)->where('is_pool', 1)->select(); |
|
|
|
|
//设置上架 |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
GoodsModel::update(['status'=>10]); |
|
|
|
|
GoodsModel::where('store_id',$this->storeId)->update(['status'=>10]); |
|
|
|
|
if ($this->storeInfo->is_provider_data != 1) { |
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!$goods) { |
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
} |
|
|
|
|
$goodsIds = array_column($goods->toArray(), 'goods_id'); |
|
|
|
|
// 分批每次导入20条 |
|
|
|
|
$limit = 20; |
|
|
|
|
// 根据商品总数量计算需要的队列任务数量 |
|
|
|
|
$jobCount = \count($goodsIds) / $limit; |
|
|
|
|
// 逐次发布队列任务 |
|
|
|
|
for ($i = 0; $i < $jobCount; $i++) { |
|
|
|
|
$data = array_slice($goodsIds, $i * $limit, $limit); |
|
|
|
|
|
|
|
|
|
StoreGoodsOnlineJob::dispatch([ |
|
|
|
|
'list' => $data, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 商品一键下架 |
|
|
|
|
* [oneClickOffTheShelf description] |
|
|
|
|
* @return [type] [description] |
|
|
|
|
*/ |
|
|
|
|
public function oneClickOffTheShelf(): Json{ |
|
|
|
|
//查出自营、上架商品 |
|
|
|
|
$goods = GoodsModel::where('channel','zy')->where('is_delete', 0)->where('status', 10)->select(); |
|
|
|
|
//设置下架 |
|
|
|
|
$model = new GoodsModel; |
|
|
|
|
GoodsModel::update(['status'=>20]); |
|
|
|
|
GoodsModel::where('store_id',$this->storeId)->update(['status'=>20]); |
|
|
|
|
if ($this->storeInfo->is_provider_data != 1) { |
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!$goods) { |
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
} |
|
|
|
|
$goodsIds = array_column($goods->toArray(), 'goods_id'); |
|
|
|
|
|
|
|
|
|
// 分批每次导入20条 |
|
|
|
|
$limit = 20; |
|
|
|
|
// 根据商品总数量计算需要的队列任务数量 |
|
|
|
|
$jobCount = \count($goodsIds) / $limit; |
|
|
|
|
// 逐次发布队列任务 |
|
|
|
|
for ($i = 0; $i < $jobCount; $i++) { |
|
|
|
|
$data = array_slice($goodsIds, $i * $limit, $limit); |
|
|
|
|
|
|
|
|
|
StoreGoodsOfflineJob::dispatch([ |
|
|
|
|
'list' => $data, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return $this->renderSuccess('操作成功'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|