From d40ee0a459cb133c906ff419e4e945a976f25b5d Mon Sep 17 00:00:00 2001 From: Aleksey Filippov Date: Sat, 28 Feb 2026 22:35:06 +0300 Subject: [PATCH] fix(ERP-247): add warning logs for null subsidy/partner_warehouse_id, restore delivery info as Yii::info MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit - 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 --- erp24/services/MarketplaceService.php | 89 ++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 17 deletions(-) diff --git a/erp24/services/MarketplaceService.php b/erp24/services/MarketplaceService.php index 2a12f571..11a6c58d 100644 --- a/erp24/services/MarketplaceService.php +++ b/erp24/services/MarketplaceService.php @@ -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); -- 2.39.5