From a58f818fb9fd82a3ca7a4c53e00cab755d2aa111 Mon Sep 17 00:00:00 2001 From: Oneami <34282948+Oneami@users.noreply.github.com> Date: Wed, 19 Jun 2024 10:39:50 +0300 Subject: [PATCH] Update PaymentService.php (#249) * Update PaymentService.php * Fix BelpostLabelService * Format Oneami code * Format Oneami code * 416. Index page * Format Oneami code * #430 Internal movement: contact person * Format Oneami code * Update PaymentService.php * Update InstallmentOrderService.php * Update InstallmentOrderService.php --------- Co-authored-by: Oneami --- src/app/Services/Order/InstallmentOrderService.php | 2 +- src/app/Services/Payment/PaymentService.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/app/Services/Order/InstallmentOrderService.php b/src/app/Services/Order/InstallmentOrderService.php index c0c6eff5..d3456b1f 100644 --- a/src/app/Services/Order/InstallmentOrderService.php +++ b/src/app/Services/Order/InstallmentOrderService.php @@ -39,7 +39,7 @@ public function createInstallmentForm(Order $order) $onlinePaymentsSum = $order->getAmountPaidOrders(); $uniqItemsCount = $order->getUniqItemsCount(); foreach ($order->items as $itemKey => $item) { - if ($item->installment->num_payments === 0) { + if (!$item->installment?->num_payments) { continue; } if ($itemKey > 0) { diff --git a/src/app/Services/Payment/PaymentService.php b/src/app/Services/Payment/PaymentService.php index d3bab8e8..74c00234 100644 --- a/src/app/Services/Payment/PaymentService.php +++ b/src/app/Services/Payment/PaymentService.php @@ -142,7 +142,7 @@ public function autoSetOrderStatus(OnlinePayment $onlinePayment): void 'data' => fn ($query) => $query->with('installment'), ])->first(); - if (in_array($order->status_key, ['fitting', 'sent', 'installment'])) { + if (in_array($order->status_key, ['fitting', 'sent', 'installment', 'partial_complete'])) { $partialBuybackItemsCount = 0; $isInstallment = $order->payment_id === Installment::PAYMENT_METHOD_ID; $successfulPaymentsSum = $order->onlinePayments @@ -196,9 +196,6 @@ public function autoSetOrderStatus(OnlinePayment $onlinePayment): void $order->update(['status_key' => ($isPartialComplete ? 'partial_complete' : 'complete')]); } else { $order->update(['status_key' => 'delivered']); - $order->data->each(function (OrderItem $orderItem) { - $orderItem->update(['status_key' => 'waiting_refund']); - }); $order->adminComments()->create([ 'comment' => "Получен наложенный платеж на сумму {$paymentSum}. Распределите сумму по товарам!", ]);