update rm deadcode

This commit is contained in:
baodev0
2026-09-27 11:42:40 +07:00
parent 82a71244ca
commit 3af59bd9c5
129 changed files with 5194 additions and 2698 deletions
+11 -4
View File
@@ -11,6 +11,7 @@ use App\Repositories\Api\Service\ServiceRepository;
use App\Models\Invoice;
use App\Models\InvoiceItem;
use App\Models\Service;
use App\Support\RenewalPricing;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
@@ -230,8 +231,10 @@ class ServiceExpiry extends Command
return;
}
$price = $this->renewalPrice($orderItem);
$renewalPrice = $this->renewalPrice($orderItem);
$months = $orderItem->months ?? 1;
$addonTotal = RenewalPricing::addonTotal($service, 1);
$price = $renewalPrice + $addonTotal;
if ($price <= 0) {
Log::warning('service:expiry | Cannot create renewal invoice: zero price', ['service_id' => $service->id]);
@@ -270,12 +273,16 @@ class ServiceExpiry extends Command
'product_id' => $service->product_id,
'type' => 'renewal',
'description' => 'Gia hạn dịch vụ: ' . ($orderItem->product?->name ?? $service->server_name ?? ''),
'months' => $orderItem->months ?? 1,
'months' => $months,
'quantity' => 1,
'unit_price' => $price,
'total_price' => $price,
'unit_price' => $renewalPrice,
'total_price' => $renewalPrice,
]);
foreach (RenewalPricing::addonInvoiceItems($service, 1, $months) as $addonItem) {
InvoiceItem::create($addonItem + ['invoice_id' => $invoice->id]);
}
// Update service to point to the new renewal invoice
$service->update(['invoice_id' => $invoice->id]);