]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Вывод остатков
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 26 Aug 2025 13:35:38 +0000 (16:35 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 26 Aug 2025 13:35:38 +0000 (16:35 +0300)
erp24/controllers/MarketplaceOrdersController.php
erp24/views/marketplace-orders/index.php
erp24/views/marketplace-orders/yandex-stocks.php [new file with mode: 0644]

index 07c89f4296f8ce480be80e774cc0741d53c90063..a56526cc8685dbd9defaaa39b417b0d0816811dc 100644 (file)
@@ -4,12 +4,14 @@ namespace app\controllers;
 
 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;
@@ -22,6 +24,7 @@ use yii\filters\VerbFilter;
 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;
@@ -809,6 +812,74 @@ class MarketplaceOrdersController extends Controller
         }
         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.
index a2461d54960e917e884d15bcab67243dda1884bc..5eaf7bf9cc01756d2430ab81c940dc4f7cf1175d 100644 (file)
@@ -43,6 +43,7 @@ YiiAsset::register($this);
         <?= Html::a('Письма с заказами', ['/marketplace-flowwow-emails/index'], ['class' => 'btn btn-success']) ?>
         <?= Html::a('Проверка почты', ['/marketplace-orders/get-flowwow-orders'], ['class' => 'btn btn-success']) ?>
         <?= Html::a('Статусы заказов в 1С', ['/crud/marketplace-order1c-statuses/index'], ['class' => 'btn btn-success']) ?>
+        <?= Html::a('Остатки Яндекс', ['/marketplace-orders/yandex-stocks'], ['class' => 'btn btn-success']) ?>
 
     </p>
     <div class="create-test-order-form mb-4">
diff --git a/erp24/views/marketplace-orders/yandex-stocks.php b/erp24/views/marketplace-orders/yandex-stocks.php
new file mode 100644 (file)
index 0000000..c91d794
--- /dev/null
@@ -0,0 +1,53 @@
+<?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>