From ae4fa2502949fa9869cccd385762620b6f14ff92 Mon Sep 17 00:00:00 2001 From: lqmac Date: Thu, 9 Jan 2025 01:09:40 +0800 Subject: [PATCH] 1 --- app/command/SyncChannel.php | 60 +++++++++++++++++++++++++ app/command/SyncStoreBasicData.php | 2 +- app/command/SyncStoreBasicDataAdmin.php | 2 +- app/store/controller/Controller.php | 7 ++- config/console.php | 1 + 5 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 app/command/SyncChannel.php diff --git a/app/command/SyncChannel.php b/app/command/SyncChannel.php new file mode 100644 index 00000000..325f5c57 --- /dev/null +++ b/app/command/SyncChannel.php @@ -0,0 +1,60 @@ +setName('SyncChannel')->setDescription('同步渠道'); + } + + + protected function execute(Input $input, Output $output) + { + + $where[] = ['is_delete','=', 0]; + $where[] = ['status','=', 1]; + $channels = Db::connect("shopMysql")->name('yoshop_channel')->where('status',1)->where('is_delete', 0)->order("id desc")->select(); + if (!$channels) { + echo "没有要同步的渠道了"; + return; + } + foreach ($channels as $key => $value) { + $channel = Channel::where('code', $value['code'])->find(); + $upData = [ + 'name' => $value['name'], + 'alias' => $value['alias'], + 'shop_name' => $value['shop_name'], + 'shop_label' => $value['shop_label'], + 'remark' => $value['remark'], + 'update_time' => time(), + ]; + if ($channel) { + // 更新渠道信息 + + $ret = Channel::where('id', $channel['id'])->update($upData); + } else { + $upData['code'] = $value['code']; + $upData['create_time'] = time(); + $ret = Channel::create($upData); + } + var_dump($ret); + } + + } + + +} \ No newline at end of file diff --git a/app/command/SyncStoreBasicData.php b/app/command/SyncStoreBasicData.php index 7b3f83f8..292dd243 100644 --- a/app/command/SyncStoreBasicData.php +++ b/app/command/SyncStoreBasicData.php @@ -167,7 +167,7 @@ class SyncStoreBasicData extends Command $deliveryData = [ "key" => "delivery", "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'], "create_time" => time(), "update_time" => time(), diff --git a/app/command/SyncStoreBasicDataAdmin.php b/app/command/SyncStoreBasicDataAdmin.php index d77ddc86..4e84b429 100644 --- a/app/command/SyncStoreBasicDataAdmin.php +++ b/app/command/SyncStoreBasicDataAdmin.php @@ -167,7 +167,7 @@ class SyncStoreBasicData extends Command $deliveryData = [ "key" => "delivery", "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'], "create_time" => time(), "update_time" => time(), diff --git a/app/store/controller/Controller.php b/app/store/controller/Controller.php index 01014260..7dad3db4 100644 --- a/app/store/controller/Controller.php +++ b/app/store/controller/Controller.php @@ -165,7 +165,12 @@ class Controller extends BaseController $user = StoreUserService::getLoginInfo(); if (!empty($user)) { if (isset($user['user']['store']['store_version']) && $user['user']['store']['store_version']) { - $this->merchantId = MerchantModel::getMerchantId($user['user']['user_name']); + $merchantId = MerchantModel::getMerchantId($user['user']['user_name']); + // $this->merchantId = -1; + // if ($merchantId) { + $this->merchantId = $merchantId; + //} + //$this->merchantId = MerchantModel::getMerchantId($user['user']['user_name']); } } } diff --git a/config/console.php b/config/console.php index 4f47d49b..12506a25 100644 --- a/config/console.php +++ b/config/console.php @@ -18,5 +18,6 @@ return [ 'SyncCategory' => 'app\command\SyncCategory', 'SyncCategoryAdmin' => 'app\command\SyncCategoryAdmin', 'HomeLocation' => 'app\command\HomeLocation', + 'SyncChannel' => 'app\command\SyncChannel', ], ];