]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
fix(ERP-247): add warning logs for null subsidy/partner_warehouse_id, restore deliver...
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Sat, 28 Feb 2026 19:35:06 +0000 (22:35 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Sat, 28 Feb 2026 19:35:06 +0000 (22:35 +0300)
- Extract getSubsidy() and getPartnerWarehouseId() to local vars in all 6 item-saving blocks
- Log Yii::warning with orderId + shopSku when either returns null
- Restore срок доставки shipments loop (was removed as debug, actually informational)
- Change level from Yii::error to Yii::info for shipment delivery time logging

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

index 2a12f571bcf1652fb4943a19b7a757a86eb05768..11a6c58d9971f0968dbd81cd0345e19d75ea48f4 100644 (file)
@@ -1351,6 +1351,9 @@ class MarketplaceService
                             }
                             $shipments = $delivery->getShipments();
                             if ($shipments) {
+                                foreach ($shipments as $index => $shipment) {
+                                    Yii::info('срок доставки ' . $index . ': ' . json_encode($shipment, JSON_UNESCAPED_UNICODE), 'marketplace');
+                                }
                                 $deliveryDateTo = ($shipments[0])->getShipmentDate() ?? null;
                                 $deliveryTimeTo = ($shipments[0])->getShipmentTime() ?? '';
 
@@ -1430,9 +1433,16 @@ class MarketplaceService
                                 $orderItem->count = $item->getCount();
                                 $orderItem->vat = $item->getVat();
                                 $orderItem->shop_sku = $item->getShopSku();
-                                $orderItem->subsidy = $item->getSubsidy() ?? 0;
-                                // Если partner_warehouse_id отсутствует, устанавливаем значение по умолчанию
-                                $orderItem->partner_warehouse_id = $item->getPartnerWarehouseId() ?? 'N/A';
+                                $subsidy = $item->getSubsidy();
+                                if ($subsidy === null) {
+                                    Yii::warning('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                }
+                                $orderItem->subsidy = $subsidy ?? 0;
+                                $partnerWarehouseId = $item->getPartnerWarehouseId();
+                                if ($partnerWarehouseId === null) {
+                                    Yii::warning('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                }
+                                $orderItem->partner_warehouse_id = $partnerWarehouseId ?? 'N/A';
                                 $orderItem->promos = json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE);
                                 $orderItem->subsidies = json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE);
 
@@ -1578,6 +1588,9 @@ class MarketplaceService
                         
                         $shipments = $delivery ? $delivery->getShipments() : null;
                         if ($shipments) {
+                            foreach ($shipments as $index => $shipment) {
+                                Yii::info('срок доставки ' . $index . ': ' . json_encode($shipment, JSON_UNESCAPED_UNICODE), 'marketplace');
+                            }
                             $deliveryDateTo = ($shipments[0])->getShipmentDate() ?? null;
                             $deliveryTimeTo = ($shipments[0])->getShipmentTime() ?? '';
 
@@ -1660,9 +1673,16 @@ class MarketplaceService
                                 $orderItem->count = $item->getCount();
                                 $orderItem->vat = $item->getVat();
                                 $orderItem->shop_sku = $item->getShopSku();
-                                $orderItem->subsidy = $item->getSubsidy() ?? 0;
-                                // Если partner_warehouse_id отсутствует, устанавливаем значение по умолчанию
-                                $orderItem->partner_warehouse_id = $item->getPartnerWarehouseId() ?? 'N/A';
+                                $subsidy = $item->getSubsidy();
+                                if ($subsidy === null) {
+                                    Yii::warning('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                }
+                                $orderItem->subsidy = $subsidy ?? 0;
+                                $partnerWarehouseId = $item->getPartnerWarehouseId();
+                                if ($partnerWarehouseId === null) {
+                                    Yii::warning('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                }
+                                $orderItem->partner_warehouse_id = $partnerWarehouseId ?? 'N/A';
                                 $orderItem->promos = json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE);
                                 $orderItem->subsidies = json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE);
 
@@ -1690,9 +1710,16 @@ class MarketplaceService
                                 $orderItem->count = $item->getCount();
                                 $orderItem->vat = $item->getVat();
                                 $orderItem->shop_sku = $item->getShopSku();
-                                $orderItem->subsidy = $item->getSubsidy() ?? 0;
-                                // Если partner_warehouse_id отсутствует, устанавливаем значение по умолчанию
-                                $orderItem->partner_warehouse_id = $item->getPartnerWarehouseId() ?? 'N/A';
+                                $subsidy = $item->getSubsidy();
+                                if ($subsidy === null) {
+                                    Yii::warning('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                }
+                                $orderItem->subsidy = $subsidy ?? 0;
+                                $partnerWarehouseId = $item->getPartnerWarehouseId();
+                                if ($partnerWarehouseId === null) {
+                                    Yii::warning('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                }
+                                $orderItem->partner_warehouse_id = $partnerWarehouseId ?? 'N/A';
                                 $orderItem->promos = json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE);
                                 $orderItem->subsidies = json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE);
 
@@ -1713,6 +1740,14 @@ class MarketplaceService
                                 ]);
                                 if ($orderItem) {
                                     $updateNeeded = false;
+                                    $subsidy = $item->getSubsidy();
+                                    if ($subsidy === null) {
+                                        Yii::warning('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    }
+                                    $partnerWarehouseId = $item->getPartnerWarehouseId();
+                                    if ($partnerWarehouseId === null) {
+                                        Yii::warning('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    }
                                     $fields = [
                                         'offer_id' => $item->getOfferId(),
                                         'offer_name' => $item->getOfferName(),
@@ -1723,8 +1758,8 @@ class MarketplaceService
                                         'count' => $item->getCount(),
                                         'vat' => $item->getVat(),
                                         'shop_sku' => $item->getShopSku(),
-                                        'subsidy' => $item->getSubsidy() ?? 0,
-                                        'partner_warehouse_id' => $item->getPartnerWarehouseId() ?? 'N/A',
+                                        'subsidy' => $subsidy ?? 0,
+                                        'partner_warehouse_id' => $partnerWarehouseId ?? 'N/A',
                                         'promos' => json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE),
                                         'subsidies' => json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE),
                                     ];
@@ -1756,9 +1791,16 @@ class MarketplaceService
                                     $orderItem->count = $item->getCount();
                                     $orderItem->vat = $item->getVat();
                                     $orderItem->shop_sku = $item->getShopSku();
-                                    $orderItem->subsidy = $item->getSubsidy() ?? 0;
-                                    // Если partner_warehouse_id отсутствует, устанавливаем значение по умолчанию
-                                    $orderItem->partner_warehouse_id = $item->getPartnerWarehouseId() ?? 'N/A';
+                                    $subsidy = $item->getSubsidy();
+                                    if ($subsidy === null) {
+                                        Yii::warning('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    }
+                                    $orderItem->subsidy = $subsidy ?? 0;
+                                    $partnerWarehouseId = $item->getPartnerWarehouseId();
+                                    if ($partnerWarehouseId === null) {
+                                        Yii::warning('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    }
+                                    $orderItem->partner_warehouse_id = $partnerWarehouseId ?? 'N/A';
                                     $orderItem->promos = json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE);
                                     $orderItem->subsidies = json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE);
 
@@ -1826,6 +1868,9 @@ class MarketplaceService
                                 }
                                 $shipments = $delivery->getShipments();
                                 if ($shipments) {
+                                    foreach ($shipments as $index => $shipment) {
+                                        Yii::info('срок доставки ' . $index . ': ' . json_encode($shipment, JSON_UNESCAPED_UNICODE), 'marketplace');
+                                    }
                                     $deliveryDateTo = ($shipments[0])->getShipmentDate() ?? null;
                                     $deliveryTimeTo = ($shipments[0])->getShipmentTime() ?? '';
 
@@ -1882,6 +1927,9 @@ class MarketplaceService
                             $delivery = $order->getDelivery();
                             $shipments = $delivery->getShipments();
                             if ($shipments) {
+                                foreach ($shipments as $index => $shipment) {
+                                    Yii::info('срок доставки ' . $index . ': ' . json_encode($shipment, JSON_UNESCAPED_UNICODE), 'marketplace');
+                                }
                                 $deliveryDateTo = ($shipments[0])->getShipmentDate() ?? null;
                                 $deliveryTimeTo = ($shipments[0])->getShipmentTime() ?? '';
 
@@ -1926,9 +1974,16 @@ class MarketplaceService
                                     $orderItem->count = $item->getCount();
                                     $orderItem->vat = $item->getVat();
                                     $orderItem->shop_sku = $item->getShopSku();
-                                    $orderItem->subsidy = $item->getSubsidy() ?? 0;
-                                    // Если partner_warehouse_id отсутствует, устанавливаем значение по умолчанию
-                                    $orderItem->partner_warehouse_id = $item->getPartnerWarehouseId() ?? 'N/A';
+                                    $subsidy = $item->getSubsidy();
+                                    if ($subsidy === null) {
+                                        Yii::warning('getSubsidy() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    }
+                                    $orderItem->subsidy = $subsidy ?? 0;
+                                    $partnerWarehouseId = $item->getPartnerWarehouseId();
+                                    if ($partnerWarehouseId === null) {
+                                        Yii::warning('getPartnerWarehouseId() вернул null для orderId=' . $marketplaceOrder->id . ', shopSku=' . $item->getShopSku(), 'marketplace');
+                                    }
+                                    $orderItem->partner_warehouse_id = $partnerWarehouseId ?? 'N/A';
                                     $orderItem->promos = json_encode($item->getPromos(), JSON_UNESCAPED_UNICODE);
                                     $orderItem->subsidies = json_encode($item->getSubsidies(), JSON_UNESCAPED_UNICODE);