]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-148] починил Маринин метод 2
authorAlexander Smirnov <fredeom@mail.ru>
Tue, 12 Nov 2024 07:47:02 +0000 (10:47 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Tue, 12 Nov 2024 07:47:02 +0000 (10:47 +0300)
erp24/api2/controllers/YandexMarketController.php
erp24/services/MarketplaceService.php

index ea029597090754db8b265de341dbd9236b391328..48f6c1bf46939a4890acf530072095c59b9b53b5 100644 (file)
@@ -16,7 +16,7 @@ class YandexMarketController extends Controller
     public function actionTest() {
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
 //http://localhost:5555/yandex-market/test
-        return MarketplaceService::infoForMarketplace(2, true);
+        return MarketplaceService::infoForMarketplace(2);
 
         $config = Configuration::getDefaultConfiguration()->setApiKey('Api-Key', 'ACMA:r3sa2VyjkgcO0aOxGoyAWuGH15g5mWAqXRMuylVA:a0bccb7e');
 
index 0085659c4e95b798ffa7c67fa23b2760890e5faa..ad2b1bee507a292038b02e7c91664648ee0becc9 100644 (file)
@@ -14,10 +14,12 @@ use yii_app\records\ProductsClass;
 class MarketplaceService
 {
 
-    public static function infoForMarketplace(int $marketId, bool $is_yandex) {
+    public static function infoForMarketplace(int $marketId) {
         if (!array_key_exists($marketId, MarketplaceStore::getWarehouseId()))
             return;
 
+        $is_yandex = $marketId == 2;
+
         // 1. Получение гуидов букетов
         $productsGroup = ProductsClass::find()
             ->where(['tip' => [ProductsClass::MARKETPLACE, ProductsClass::MARKETPLACE_ADDITIONAL]])
@@ -37,7 +39,6 @@ class MarketplaceService
 
         // 3. Получение состава букетов
         $bouquetComposition = [];
-//        $componentsArr = [];
         $componentsGuids = [];
         foreach ($productsGuids as $ind => $dataComponents) {
             $guid = $dataComponents['id'];
@@ -48,13 +49,12 @@ class MarketplaceService
                 $componentsJson = json_decode($components);
                 $bouquetComposition[$guid] = $componentsJson;
                 foreach ($componentsJson as $compJsonGuid => $compJsonCnt) {
-//                    $componentsArr[] = ['guid' => $compJsonGuid, 'cnt' => $compJsonCnt];
                     $componentsGuids[] = $compJsonGuid;
                 }
             }
         }
         $componentsGuids = array_unique($componentsGuids);
-//echo "<pre>"; var_dump($componentsArr); die;
+
         // 4. Проверка остатков
 
         $marketplaceStores = array_column(MarketplaceStore::findAll(['warehouse_id' => $marketId]), null, 'guid');
@@ -69,7 +69,7 @@ class MarketplaceService
             $balance2Dim[$balance['store_id']][$balance['product_id']] = $balance['quantity'];
             $balanceStoreIds[] = $balance['store_id'];
         }
-//        echo "<pre>"; var_dump($balance2Dim); die;
+
         $balanceStoreIds = array_unique($balanceStoreIds);
 
         foreach ($bouquetComposition as $guid => $products) {
@@ -87,7 +87,6 @@ class MarketplaceService
                     }
                 }
             }
-//            echo "<pre>"; var_dump($stockRecords); die;
 
             $bouquetCount = PHP_INT_MAX;
             foreach ($stockRecords as $productGuid => $values) {
@@ -104,7 +103,7 @@ class MarketplaceService
         // 5. Получение приоритетов
         $priorities = MarketplacePriority::find()
             ->where(['guid' => ArrayHelper::getColumn($productsGuids, 'id')])->indexBy('guid')->asArray()->all();
-//        echo "<pre>"; var_dump($priorities); die;
+
         // 6. Массив для хранения гуидов, которые можно отправить
         $availableGuids = [];