lqmac 4 weeks ago
parent d0a6e826e0
commit 4a17acf451
  1. 3
      app/command/SyncStoreBasicData.php
  2. 1
      app/job/service/goods/StoreGoodsOnline.php
  3. 65
      app/store/controller/Goods.php

@ -163,11 +163,12 @@ class SyncStoreBasicData extends Command
//配送设置 //配送设置
$delivery = Setting::where('key','delivery')->where('store_id', $store['store_id'])->find(); $delivery = Setting::where('key','delivery')->where('store_id', $store['store_id'])->find();
//默认配置 "customer":"F6CAEF5CEA6B5BF219149B9B42BECAA1","key":"pjVBLUai1633"
if (!$delivery) { if (!$delivery) {
$deliveryData = [ $deliveryData = [
"key" => "delivery", "key" => "delivery",
"describe" => "配送设置", "describe" => "配送设置",
"values" => json_decode('{"traces":{"enable":1,"default":"kd100","providerConfig":{"kd100":{"customer":"F6CAEF5CEA6B5BF219149B9B42BECAA1","key":"pjVBLUai1633"},"aliyun":{"appCode":""}}},"delivery_type":[10,20,30]}', true), "values" => json_decode('{"traces":{"enable":1,"default":"kd100","providerConfig":{"kd100":{"customer":"","key":""},"aliyun":{"appCode":""}}},"delivery_type":[10,20,30]}', true),
"store_id" => $store['store_id'], "store_id" => $store['store_id'],
"create_time" => time(), "create_time" => time(),
"update_time" => time(), "update_time" => time(),

@ -54,6 +54,7 @@ class StoreGoodsOnline extends BaseService
'status' => 10, 'status' => 10,
'is_jd_remove' => 0, 'is_jd_remove' => 0,
'update_time' => time(), 'update_time' => time(),
'sale_time' => time(),
'is_delete' => 0 'is_delete' => 0
]; ];
//上架零售商城总后台的商品 //上架零售商城总后台的商品

@ -625,16 +625,73 @@ class Goods extends Controller
} }
//商品一键上架 /**
* 商品一键上架
* [oneClickShelf description]
* @return [type] [description]
*/
public function oneClickShelf(): Json{ public function oneClickShelf(): Json{
//查出下架、自营、入池的商品
$goods = GoodsModel::where('channel','zy')->where('is_delete', 0)->where('status', 20)->where('is_pool', 1)->select();
//设置上架
$model = new GoodsModel; $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('操作成功'); return $this->renderSuccess('操作成功');
} }
/**
* 商品一键下架
* [oneClickOffTheShelf description]
* @return [type] [description]
*/
public function oneClickOffTheShelf(): Json{ public function oneClickOffTheShelf(): Json{
//查出自营、上架商品
$goods = GoodsModel::where('channel','zy')->where('is_delete', 0)->where('status', 10)->select();
//设置下架
$model = new GoodsModel; $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('操作成功'); return $this->renderSuccess('操作成功');
} }

Loading…
Cancel
Save