From: fomichev Date: Tue, 12 Nov 2024 09:07:29 +0000 (+0300) Subject: Цены X-Git-Tag: 1.6~13^2~8 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=6e3e6ced8646338bf737aca02d1e8a430636b4e4;p=erp24_rep%2Fyii-erp24%2F.git Цены --- diff --git a/erp24/media/controllers/FlowwowController.php b/erp24/media/controllers/FlowwowController.php index d7fd1eab..0b65b8c5 100644 --- a/erp24/media/controllers/FlowwowController.php +++ b/erp24/media/controllers/FlowwowController.php @@ -14,6 +14,9 @@ class FlowwowController extends Controller */ public function actionFeed($id) { + + + $productsInfo = MarketplaceService::getAllProductsInfo($id); diff --git a/erp24/services/MarketplaceService.php b/erp24/services/MarketplaceService.php index 639051cb..59db72fe 100644 --- a/erp24/services/MarketplaceService.php +++ b/erp24/services/MarketplaceService.php @@ -83,8 +83,31 @@ class MarketplaceService ->asArray() ->all(); + + $productsGuidsIds = array_column($productsGuids, 'id'); + + //var_dump( $productsGuidsIds); // 2. Получение цен на букеты - $prices = ArrayHelper::map(Prices::findAll(['product_id' => ArrayHelper::getColumn($productsGuids, 'id')]), 'product_id', 'price'); + //$prices = ArrayHelper::map(Prices::findAll(['product_id' => ArrayHelper::getColumn($productsGuids, 'id')]), 'product_id', 'price'); + + $allPrices = Prices::findAll(['product_id' => $productsGuidsIds]); + + if (empty($allPrices)) { + Yii::warning('Не найдено цен для GUID.'); + } + + $prices = ArrayHelper::map($allPrices, 'product_id', 'price') ?: []; // Ensure $prices is an array + + foreach ($productsGuidsIds as $productId) { + // Ensure $productId is scalar before checking + if (is_scalar($productId) && !array_key_exists($productId, $prices)) { + $prices[$productId] = 0; + } elseif (!is_scalar($productId)) { + Yii::warning('Invalid productId type: ' . gettype($productId)); + } + } + + // var_dump($prices); // 3. Получение состава букетов $bouquetComposition = []; @@ -103,7 +126,7 @@ class MarketplaceService } } $componentsGuids = array_unique($componentsGuids); - + //var_dump($componentsGuids); // 4. Проверка остатков $marketplaceStores = array_column(MarketplaceStore::findAll(['warehouse_id' => $marketId]), null, 'guid'); @@ -120,7 +143,7 @@ class MarketplaceService } $balanceStoreIds = array_unique($balanceStoreIds); - + //var_dump($balanceStoreIds); foreach ($bouquetComposition as $guid => $products) { $stockRecords = []; foreach ($products as $product_id => $count) {