Merge branch 'master' into lszyh

lszyh
zyh 1 month ago
commit 12a4e94e61
  1. 2
      app/command/SyncCategory.php
  2. 110
      app/command/UpdateDataProviderGoods.php
  3. 9
      app/store/controller/Goods.php
  4. 1
      config/console.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) {

@ -0,0 +1,110 @@
<?php
namespace app\command;
use app\common\service\GoodsCateEs;
use app\common\service\GoodsEs;
use think\console\Command;
use think\console\Output;
use think\console\Input;
use app\store\model\Goods as GoodsModel;
use app\common\model\Store;
use think\facade\Db;
class UpdateDataProviderGoods extends Command
{
const DEFAULT_STORE_ID = 0;
protected function configure()
{
// 指令配置
$this->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 "<pre>";
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);
}
}
}

@ -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;
// 根据商品总数量计算需要的队列任务数量

@ -18,5 +18,6 @@ return [
'SyncCategory' => 'app\command\SyncCategory',
'HomeLocation' => 'app\command\HomeLocation',
'SyncGoodsToPerMinute' => 'app\command\SyncGoodsToPerMinute',
'UpdateDataProviderGoods' => 'app\command\UpdateDataProviderGoods',
],
];

Loading…
Cancel
Save