lqmac 1 month ago
parent 4eb8e7b3bd
commit ae4fa25029
  1. 60
      app/command/SyncChannel.php
  2. 2
      app/command/SyncStoreBasicData.php
  3. 2
      app/command/SyncStoreBasicDataAdmin.php
  4. 7
      app/store/controller/Controller.php
  5. 1
      config/console.php

@ -0,0 +1,60 @@
<?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\Category as CategoryModel;
use app\common\model\Channel;
use think\facade\Db;
class SyncChannel extends Command
{
const DEFAULT_STORE_ID = 0;
protected function configure()
{
// 指令配置
$this->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);
}
}
}

@ -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(),

@ -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(),

@ -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']);
}
}
}

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

Loading…
Cancel
Save