]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
fix(ERP-247): skip item save on null subsidy/partner_warehouse_id, log Yii::error origin/feature_filippov_ERP-247_add_delivery_logging
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Sat, 28 Feb 2026 19:56:56 +0000 (22:56 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Sat, 28 Feb 2026 19:56:56 +0000 (22:56 +0300)
When getSubsidy() or getPartnerWarehouseId() returns null — log error with
orderId + shopSku and skip saving the item (continue) instead of writing
invalid fallback values (0 / 'N/A') to DB.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
erp24/services/MarketplaceService.php

index b84aaffb98a3e52a30f519a2912ea599fe2c4bdc..d774196dd0b01e9cdc4695fd4f6b75440d64750c 100644 (file)
@@ -1435,14 +1435,16 @@ class MarketplaceService
                                 $orderItem->shop_sku = $item->getShopSku();
                                 $subsidy = $item->getSubsidy();
                                 if ($subsidy === null) {
-                                    Yii::warning('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    Yii::error('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    continue;
                                 }
-                                $orderItem->subsidy = $subsidy ?? 0;
+                                $orderItem->subsidy = $subsidy;
                                 $partnerWarehouseId = $item->getPartnerWarehouseId();
                                 if ($partnerWarehouseId === null) {
-                                    Yii::warning('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    Yii::error('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    continue;
                                 }
-                                $orderItem->partner_warehouse_id = $partnerWarehouseId ?? 'N/A';
+                                $orderItem->partner_warehouse_id = $partnerWarehouseId;
                                 $orderItem->promos = json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE);
                                 $orderItem->subsidies = json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE);
 
@@ -1675,14 +1677,16 @@ class MarketplaceService
                                 $orderItem->shop_sku = $item->getShopSku();
                                 $subsidy = $item->getSubsidy();
                                 if ($subsidy === null) {
-                                    Yii::warning('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    Yii::error('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    continue;
                                 }
-                                $orderItem->subsidy = $subsidy ?? 0;
+                                $orderItem->subsidy = $subsidy;
                                 $partnerWarehouseId = $item->getPartnerWarehouseId();
                                 if ($partnerWarehouseId === null) {
-                                    Yii::warning('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    Yii::error('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    continue;
                                 }
-                                $orderItem->partner_warehouse_id = $partnerWarehouseId ?? 'N/A';
+                                $orderItem->partner_warehouse_id = $partnerWarehouseId;
                                 $orderItem->promos = json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE);
                                 $orderItem->subsidies = json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE);
 
@@ -1712,14 +1716,16 @@ class MarketplaceService
                                 $orderItem->shop_sku = $item->getShopSku();
                                 $subsidy = $item->getSubsidy();
                                 if ($subsidy === null) {
-                                    Yii::warning('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    Yii::error('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    continue;
                                 }
-                                $orderItem->subsidy = $subsidy ?? 0;
+                                $orderItem->subsidy = $subsidy;
                                 $partnerWarehouseId = $item->getPartnerWarehouseId();
                                 if ($partnerWarehouseId === null) {
-                                    Yii::warning('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    Yii::error('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    continue;
                                 }
-                                $orderItem->partner_warehouse_id = $partnerWarehouseId ?? 'N/A';
+                                $orderItem->partner_warehouse_id = $partnerWarehouseId;
                                 $orderItem->promos = json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE);
                                 $orderItem->subsidies = json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE);
 
@@ -1742,11 +1748,13 @@ class MarketplaceService
                                     $updateNeeded = false;
                                     $subsidy = $item->getSubsidy();
                                     if ($subsidy === null) {
-                                        Yii::warning('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                        Yii::error('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                        continue;
                                     }
                                     $partnerWarehouseId = $item->getPartnerWarehouseId();
                                     if ($partnerWarehouseId === null) {
-                                        Yii::warning('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                        Yii::error('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                        continue;
                                     }
                                     $fields = [
                                         'offer_id' => $item->getOfferId(),
@@ -1758,8 +1766,8 @@ class MarketplaceService
                                         'count' => $item->getCount(),
                                         'vat' => $item->getVat(),
                                         'shop_sku' => $item->getShopSku(),
-                                        'subsidy' => $subsidy ?? 0,
-                                        'partner_warehouse_id' => $partnerWarehouseId ?? 'N/A',
+                                        'subsidy' => $subsidy,
+                                        'partner_warehouse_id' => $partnerWarehouseId,
                                         'promos' => json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE),
                                         'subsidies' => json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE),
                                     ];
@@ -1793,14 +1801,16 @@ class MarketplaceService
                                     $orderItem->shop_sku = $item->getShopSku();
                                     $subsidy = $item->getSubsidy();
                                     if ($subsidy === null) {
-                                        Yii::warning('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                        Yii::error('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                        continue;
                                     }
-                                    $orderItem->subsidy = $subsidy ?? 0;
+                                    $orderItem->subsidy = $subsidy;
                                     $partnerWarehouseId = $item->getPartnerWarehouseId();
                                     if ($partnerWarehouseId === null) {
-                                        Yii::warning('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                        Yii::error('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                        continue;
                                     }
-                                    $orderItem->partner_warehouse_id = $partnerWarehouseId ?? 'N/A';
+                                    $orderItem->partner_warehouse_id = $partnerWarehouseId;
                                     $orderItem->promos = json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE);
                                     $orderItem->subsidies = json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE);
 
@@ -1976,14 +1986,16 @@ class MarketplaceService
                                     $orderItem->shop_sku = $item->getShopSku();
                                     $subsidy = $item->getSubsidy();
                                     if ($subsidy === null) {
-                                        Yii::warning('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                        Yii::error('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                        continue;
                                     }
-                                    $orderItem->subsidy = $subsidy ?? 0;
+                                    $orderItem->subsidy = $subsidy;
                                     $partnerWarehouseId = $item->getPartnerWarehouseId();
                                     if ($partnerWarehouseId === null) {
-                                        Yii::warning('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                        Yii::error('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                        continue;
                                     }
-                                    $orderItem->partner_warehouse_id = $partnerWarehouseId ?? 'N/A';
+                                    $orderItem->partner_warehouse_id = $partnerWarehouseId;
                                     $orderItem->promos = json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE);
                                     $orderItem->subsidies = json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE);