From: Alexander Smirnov Date: Tue, 12 Nov 2024 07:47:02 +0000 (+0300) Subject: [ERP-148] починил Маринин метод 2 X-Git-Tag: 1.6~15^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=d947964d59ad24e2aa20550493174bb8e78d622d;p=erp24_rep%2Fyii-erp24%2F.git [ERP-148] починил Маринин метод 2 --- diff --git a/erp24/api2/controllers/YandexMarketController.php b/erp24/api2/controllers/YandexMarketController.php index ea029597..48f6c1bf 100644 --- a/erp24/api2/controllers/YandexMarketController.php +++ b/erp24/api2/controllers/YandexMarketController.php @@ -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'); diff --git a/erp24/services/MarketplaceService.php b/erp24/services/MarketplaceService.php index 0085659c..ad2b1bee 100644 --- a/erp24/services/MarketplaceService.php +++ b/erp24/services/MarketplaceService.php @@ -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 "
"; 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 "
"; var_dump($balance2Dim); die;
+
         $balanceStoreIds = array_unique($balanceStoreIds);
 
         foreach ($bouquetComposition as $guid => $products) {
@@ -87,7 +87,6 @@ class MarketplaceService
                     }
                 }
             }
-//            echo "
"; 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 "
"; var_dump($priorities); die;
+
         // 6. Массив для хранения гуидов, которые можно отправить
         $availableGuids = [];