diff --git a/app/command/SyncCategory.php b/app/command/SyncCategory.php index f2b5d2ff..d269d904 100644 --- a/app/command/SyncCategory.php +++ b/app/command/SyncCategory.php @@ -51,7 +51,7 @@ class SyncCategory extends Command public function copyCategory(int $new_store_id, $is_update_image = 0){ $store_id = 0; $model = new CategoryModel; - $list = $model->getList(['store_id' => self::DEFAULT_STORE_ID]); + $list = $model->getList(['store_id' => self::DEFAULT_STORE_ID,'status' => 1]); // var_dump($list); // exit(); if (!$list) { diff --git a/app/command/UpdateDataProviderGoods.php b/app/command/UpdateDataProviderGoods.php new file mode 100644 index 00000000..5a144aeb --- /dev/null +++ b/app/command/UpdateDataProviderGoods.php @@ -0,0 +1,110 @@ +setName('UpdateDataProviderGoods')->setDescription('处理历史服务商商品数据'); + $this->addArgument("store_id"); + $this->addArgument("is_update_image"); + } + + + protected function execute(Input $input, Output $output) + { + $store_id = $input->getArgument("store_id"); + $where[] = ['is_delete','=', 0]; + $where[] = ['is_recycle','=', 0]; + $where[] = ['status','=', 1]; + $where[] = ['is_provider_data','=', 1]; + + if ($store_id) { + $where[] = ['store_id','=', $store_id]; + } else { + $where[] = ['store_id', '<>', self::DEFAULT_STORE_ID]; + } + $stores = Store::where($where)->field('store_id,is_sync,is_recycle,status,is_delete')->order('store_id asc')->select()->toArray(); + if (!$stores) { + echo "没有要同步的商城了"; + return; + } + foreach ($stores as $store) { + $this->updateGoodsData($store['store_id']); + } + } + + public function updateGoodsData(int $store_id){ + + $list = GoodsModel::where('store_id', $store_id) + ->where('channel','zy') + ->where('status', 10) + ->where('is_pool', 1) + ->where('is_delete', 0) + ->field('goods_id,region,region_text,goods_source,delivery_time,is_check') + ->select(); + echo "
"; + print_r($list); + exit(); + foreach ($list as $key => $value) { + echo $value['goods_id'].PHP_EOL; + $platformGoods = GoodsModel::where('origin_goods_id', $value['goods_id'])->field("goods_id,region,region_text,goods_source,delivery_time,is_check,origin_goods_id")->find(); + if (!$platformGoods) { + echo $value['goods_id']."商品未同步到零售商城".PHP_EOL; + continue; + } + $up_data = [ + 'region_text' => $value['region_text'], + 'region' => $value['region'], + 'goods_source' => $value['goods_source'], + 'delivery_time' => $value['delivery_time'], + 'is_check' => $value['is_check'], + 'update_time' => time(), + ]; + //更新零售商城总后台的商品 + $ret = GoodsModel::where('origin_goods_id', $value['goods_id'])->update($up_data); + var_dump($ret); + //更新零售商城-商城端的商品 + $ret = GoodsModel::where('origin_goods_id', $platformGoods['goods_id'])->update($up_data); + var_dump($ret); + //更新批发商城总后台的商品 + $wholesalePlatformGoods = Db::connect("dataCenterMysql")->table('yoshop_goods')->where('origin_goods_id', $platformGoods['goods_id'])->find(); + if (!$wholesalePlatformGoods) { + echo $platformGoods['goods_id']."商品未同步到批发商城".PHP_EOL; + return true; + } + $ret = Db::connect("dataCenterMysql")->table('yoshop_goods')->where('origin_goods_id', $platformGoods['goods_id'])->update($up_data); + var_dump($ret); + //上架批发商城-商城端的商品 + $ret = Db::connect("dataCenterMysql")->table('yoshop_goods')->where('origin_goods_id', $wholesalePlatformGoods['goods_id'])->update($up_data); + var_dump($ret); + } + } + + + + + + + + + + + + + + +} \ No newline at end of file diff --git a/app/store/controller/Goods.php b/app/store/controller/Goods.php index 39cad0d0..ee24e063 100644 --- a/app/store/controller/Goods.php +++ b/app/store/controller/Goods.php @@ -217,6 +217,9 @@ class Goods extends Controller if (!$model->setIsPool($goodsIds, $state)) { return $this->renderError($model->getError() ?: '操作失败'); } + if ($this->storeInfo->is_provider_data != 1) { + return $this->renderSuccess('操作成功'); + } // 分批每次导入20条 $limit = 20; // 根据商品总数量计算需要的队列任务数量 @@ -249,6 +252,9 @@ class Goods extends Controller if (!$model->setStatus($goodsIds, $state)) { return $this->renderError($model->getError() ?: '操作失败'); } + if ($this->storeInfo->is_provider_data != 1) { + return $this->renderSuccess('操作成功'); + } // 分批每次导入20条 $limit = 20; // 根据商品总数量计算需要的队列任务数量 @@ -353,6 +359,9 @@ class Goods extends Controller if (!$model->setDelete($goodsIds)) { return $this->renderError($model->getError() ?: '删除失败'); } + if ($this->storeInfo->is_provider_data != 1) { + return $this->renderSuccess('操作成功'); + } // 分批每次导入20条 $limit = 20; // 根据商品总数量计算需要的队列任务数量 diff --git a/config/console.php b/config/console.php index 03074cf0..d0611b58 100644 --- a/config/console.php +++ b/config/console.php @@ -18,5 +18,6 @@ return [ 'SyncCategory' => 'app\command\SyncCategory', 'HomeLocation' => 'app\command\HomeLocation', 'SyncGoodsToPerMinute' => 'app\command\SyncGoodsToPerMinute', + 'UpdateDataProviderGoods' => 'app\command\UpdateDataProviderGoods', ], ];