From 753c741e9c2eb1a586cdaa2d355ee35f59b03446 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Thu, 14 Nov 2024 17:19:40 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D0=BE=D0=B4=D1=81=D0=BA=D0=B0=D0=B7=D0=BA?= =?utf8?q?=D0=B0=20=D1=81=D0=BA=D0=BB=D0=B0=D0=B4=D0=B0=20=D0=B4=D0=BB?= =?utf8?q?=D1=8F=20=D1=8F=D0=BD=D0=B4=D0=B5=D0=BA=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../controllers/YandexMarketController.php | 5 +---- erp24/commands/MarketplaceController.php | 3 ++- erp24/config/console.php | 3 +++ erp24/config/params.php | 1 + .../MarketplaceStoreController.php | 21 ++++++++++++++++--- erp24/views/marketplace-store/_form.php | 10 ++++++++- erp24/views/marketplace-store/create.php | 5 +++-- 7 files changed, 37 insertions(+), 11 deletions(-) diff --git a/erp24/api2/controllers/YandexMarketController.php b/erp24/api2/controllers/YandexMarketController.php index 769ec38b..e49f85b1 100644 --- a/erp24/api2/controllers/YandexMarketController.php +++ b/erp24/api2/controllers/YandexMarketController.php @@ -2,16 +2,13 @@ namespace app\controllers; -use Matrix\Matrix; use Yii; -use yii\grid\GridView; use yii\helpers\ArrayHelper; use yii\rest\Controller; use OpenAPI\Client\Configuration; use OpenAPI\Client\Api; use OpenAPI\Client\Model; use GuzzleHttp; -use yii_app\records\MarketplaceStore; use yii_app\records\MatrixErp; use yii_app\records\Products1c; use yii_app\records\ProductsClass; @@ -23,7 +20,7 @@ class YandexMarketController extends Controller $output = ''; - $config = Configuration::getDefaultConfiguration()->setApiKey('Api-Key', 'ACMA:r3sa2VyjkgcO0aOxGoyAWuGH15g5mWAqXRMuylVA:a0bccb7e'); + $config = Configuration::getDefaultConfiguration()->setApiKey('Api-Key', Yii::$app->params['YANDEX_MARKET_API_KEY']); // $apiInstance = new Api\CampaignsApi( // new GuzzleHttp\Client(), diff --git a/erp24/commands/MarketplaceController.php b/erp24/commands/MarketplaceController.php index b7008ad1..588c5105 100644 --- a/erp24/commands/MarketplaceController.php +++ b/erp24/commands/MarketplaceController.php @@ -2,6 +2,7 @@ namespace yii_app\commands; +use Yii; use yii\console\Controller; use yii\helpers\ArrayHelper; use yii_app\records\MarketplaceStore; @@ -19,7 +20,7 @@ class MarketplaceController extends Controller public function actionYandex() { $infoForMarketplace = MarketplaceService::infoForMarketplace(2); - $config = Configuration::getDefaultConfiguration()->setApiKey('Api-Key', 'ACMA:r3sa2VyjkgcO0aOxGoyAWuGH15g5mWAqXRMuylVA:a0bccb7e'); + $config = Configuration::getDefaultConfiguration()->setApiKey('Api-Key', Yii::$app->params['YANDEX_MARKET_API_KEY']); $products = Products1c::find()->alias('p')->leftJoin('products_class pc', 'p.parent_id = pc.category_id') ->where(['pc.tip' => [ProductsClass::MARKETPLACE, ProductsClass::MARKETPLACE_ADDITIONAL]])->all(); diff --git a/erp24/config/console.php b/erp24/config/console.php index 5c2269ba..d75b8bf4 100755 --- a/erp24/config/console.php +++ b/erp24/config/console.php @@ -1,5 +1,7 @@ require dirname(__DIR__) . '/config/db.php', //'db2' => require dirname(__DIR__) . '/config/db2.php', ], + 'params' => $params, ]; if (YII_ENV_DEV) { diff --git a/erp24/config/params.php b/erp24/config/params.php index 7dfdb4ea..f0185ff7 100644 --- a/erp24/config/params.php +++ b/erp24/config/params.php @@ -14,4 +14,5 @@ return [ ['Login' => 'ipbelo-n2-ci', 'Password' => '8h09h42q38'], ], 'SWITCH_USER_COOKIE_PASSWORD' => '123pass@WORD', + 'YANDEX_MARKET_API_KEY' => 'ACMA:r3sa2VyjkgcO0aOxGoyAWuGH15g5mWAqXRMuylVA:a0bccb7e', ]; diff --git a/erp24/controllers/MarketplaceStoreController.php b/erp24/controllers/MarketplaceStoreController.php index 94453380..22448b18 100644 --- a/erp24/controllers/MarketplaceStoreController.php +++ b/erp24/controllers/MarketplaceStoreController.php @@ -1,15 +1,18 @@ redirect(['view', 'id' => $model->id]); } + $campaignNameById = []; + + $config = Configuration::getDefaultConfiguration()->setApiKey('Api-Key', Yii::$app->params['YANDEX_MARKET_API_KEY']); + $apiInstance = new Api\CampaignsApi(new GuzzleHttp\Client(), $config); + $campaigns = $apiInstance->getCampaigns(); + /* @var $campaigns Model\GetCampaignsResponse */ + foreach ($campaigns->getCampaigns() as $campaign) { + /* @var $campaign Model\CampaignDTO */ + $campaignNameById[$campaign->getId()] = $campaign->getDomain(); + } + return $this->render('create', [ 'model' => $model, 'stores' => $stores, 'storesGuid' => $storesGuid, 'firms' => $firms, - 'warehouses' => $warehouses + 'warehouses' => $warehouses, + 'campaignNameById' => $campaignNameById, ]); } diff --git a/erp24/views/marketplace-store/_form.php b/erp24/views/marketplace-store/_form.php index d4acad91..d10ffe70 100644 --- a/erp24/views/marketplace-store/_form.php +++ b/erp24/views/marketplace-store/_form.php @@ -18,8 +18,16 @@ use yii\widgets\ActiveForm; field($model, 'guid')->textInput(['maxlength' => true, 'value' => $model->guid, 'readonly' => true, 'id' => 'guid-input']) ?> field($model, 'name')->textInput(['maxlength' => true, 'value' => $model->name, 'readonly' => true, 'id' => 'name-input']) ?> field($model, 'warehouse_id')->dropDownList($warehouses, [ - 'prompt' => 'Выберите маркетплейс' + 'prompt' => 'Выберите маркетплейс', + 'onchange' => 'document.getElementById("yandexMarketplaces").style.display = this.value == 2 ? "block" : "none";', ]) ?> +
+ 'Выберите склад для яндекс маркетплейса', + 'onchange' => 'document.getElementById("marketplacestore-warehouse_guid").value = this.value;' + ]) ?> +
field($model, 'warehouse_guid')->textInput(['type' => 'integer']) ?> field($model, 'firm')->dropDownList($firms, ['prompt' => 'Выберите юр лицо']) ?> diff --git a/erp24/views/marketplace-store/create.php b/erp24/views/marketplace-store/create.php index 12aca934..0cb24813 100644 --- a/erp24/views/marketplace-store/create.php +++ b/erp24/views/marketplace-store/create.php @@ -7,7 +7,7 @@ $this->params['breadcrumbs'][] = ['label' => 'Список Магазинов', $this->params['breadcrumbs'][] = $this->title; ?> -
+

title) ?>

@@ -16,7 +16,8 @@ $this->params['breadcrumbs'][] = $this->title; 'stores' => $stores, 'storesGuid' => $storesGuid, 'firms' => $firms, - 'warehouses' => $warehouses + 'warehouses' => $warehouses, + 'campaignNameById' => $campaignNameById, ]) ?>
-- 2.39.5