use app\records\OrdersUnion;
+use OpenAPI\Client\Configuration;
use OpenAPI\Client\ObjectSerializer;
use Yii;
use yii\base\Exception;
use yii\data\ArrayDataProvider;
use yii\db\Expression;
use yii\db\Query;
+use yii\helpers\ArrayHelper;
use yii_app\helpers\DataHelper;
use yii_app\models\FlowwowOrdersForm;
use yii_app\records\MarketplaceOrderDelivery;
use yii_app\records\MarketplaceOrderStatusHistory;
use yii_app\records\MarketplaceOrderStatusTypes;
use yii_app\records\MarketplaceStore;
+use yii_app\records\MatrixErp;
use yii_app\records\Prices;
use yii_app\records\PricesDynamic;
use yii_app\records\Products1c;
}
return $this->redirect(['index']);
}
+
+
+ public function actionYandexStocks() {
+
+
+ $infoForMarketplace = MarketplaceService::infoForMarketplace(2);
+
+ $products = Products1c::find()->alias('p')->leftJoin('products_class pc', 'p.parent_id = pc.category_id')
+ ->where(['pc.tip' => [ProductsClass::MARKETPLACE, ProductsClass::MARKETPLACE_ADDITIONAL]])->all();
+ $matrixErp = MatrixErp::find()->where(['guid' => ArrayHelper::getColumn($products, 'id')])->all();
+ $matrixErpByGuid = [];
+ $hiddenOfferings = [];
+ foreach ($matrixErp as $matrix) {
+ /* @var $matrix MatrixErp */
+ $matrixErpByGuid[$matrix->guid] = $matrix;
+ $hiddenOfferings [] = [
+ "offerId" => $matrix->guid,
+ ];
+ }
+
+ $campaignIds = ArrayHelper::map(MarketplaceStore::find()->where(['warehouse_id' => 2])->all(), 'warehouse_guid', 'guid');
+ $skus = [];
+ foreach (array_keys($campaignIds) as $campaignId) {
+ foreach ($infoForMarketplace as $storeId => $guidsWithCnt) {
+ if ($campaignIds[$campaignId] != $storeId) {
+ continue;
+ }
+
+ foreach ($guidsWithCnt as $guid => $cnt) {
+ $skus[$campaignId][] = [
+ "sku" => $guid,
+ "items" => [
+ [
+ "count" => $cnt,
+ "updatedAt" => date("c"),
+ ]
+ ]
+ ];
+ }
+ }
+ }
+ //var_dump($skus);die();
+ $flattenSkus = [];
+ foreach ($skus as $campaignId => $sku) {
+ foreach ($sku as $item) {
+ $flattenSkus[] = [
+ "guid" => $item['sku'],
+ "count" => $item['items'][0]['count'],
+ "campaignId" => $campaignId,
+ ];
+ }
+ }
+ $dataProvider = new ArrayDataProvider([
+ 'allModels' => $flattenSkus,
+ 'sort' => [
+ 'attributes' => ['guid', 'count', 'campaignId'],
+ ],
+ 'pagination' => [
+ 'pageSize' => 200,
+ ],
+ ]);
+
+ return $this->render('yandex-stocks', ['dataProvider' => $dataProvider]);
+
+
+
+ }
+
/**
* Deletes an existing MarketplaceOrders model.
* If deletion is successful, the browser will be redirected to the 'index' page.
--- /dev/null
+<?php
+
+use kartik\grid\GridView;
+use yii\web\YiiAsset;
+use yii_app\records\MarketplaceOrders;
+use yii\helpers\Html;
+use yii\helpers\Url;
+use yii\grid\ActionColumn;
+
+use yii_app\records\MarketplaceStore;
+use yii_app\records\Products1c;
+use yii_app\records\WriteOffsErp;
+
+/** @var yii\web\View $this */
+/** @var yii_app\records\MarketplaceOrdersSearch $searchModel */
+/** @var yii\data\ActiveDataProvider $dataProvider */
+
+$this->title = 'Остатки Яндекса';
+$this->params['breadcrumbs'][] = $this->title;
+YiiAsset::register($this);
+?>
+<div class="marketplace-orders-index p-4">
+ <?= Html::a('Назад', ['index'], ['class' => 'btn btn-primary my-4']) ?>
+ <h1><?= Html::encode($this->title) ?></h1>
+
+
+ <?= GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'responsive' => true,
+ 'hover' => true,
+ 'columns' => [
+ [
+ 'attribute' => 'guid',
+ 'value' => function ($model) {
+ $product = Products1c::find()->where(['id' => $model['guid']])->one();
+ return $product->name . " (" . $model['guid'] . ")";
+ }
+ ],
+ 'count',
+ [
+ 'attribute' => 'campaignId',
+ 'value' => function ($model) {
+ $store = MarketplaceStore::find()->where(['warehouse_guid' => $model['campaignId']])->one();
+ $storeName = $store->name;
+ return $storeName . " (" . $model['campaignId'] . ")";
+ }
+ ],
+ ]
+
+ ]); ?>
+
+
+</div>