feat(billing): renewals, coupons, VAT numbering, billing cycles and invoice payment tracking

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-19 16:37:56 +07:00
co-authored by Claude Sonnet 5.5
parent ea9a53f742
commit 25f23d541e
134 changed files with 4926 additions and 185 deletions
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Controllers\Api\Client;
use App\Http\Controllers\Controller;
use App\Http\Requests\Api\BillingProfileRequest;
use App\Support\CustomerBillingProfile;
use Illuminate\Http\JsonResponse;
class BillingProfileController extends Controller
{
public function show(): JsonResponse
{
return response()->json(['error' => false, 'data' => CustomerBillingProfile::payload(auth('client')->user())]);
}
public function update(BillingProfileRequest $request): JsonResponse
{
return response()->json([
'error' => false,
'message' => 'Đã lưu thông tin xuất hóa đơn',
'data' => CustomerBillingProfile::save(auth('client')->user(), $request->validated()),
]);
}
}
@@ -71,7 +71,11 @@ class DomainOrderController extends Controller
'type' => 'domain_order_new',
'title' => 'Đơn đăng ký tên miền mới',
'body' => "Khách hàng {$customer->fullname} vừa đặt mua tên miền {$domainName} (#{$orderNum})",
'link' => '/domain-orders',
'link' => '/domain-orders/' . $result['order']->id,
'data' => [
'order_id' => $result['order']->id,
'order_num' => $orderNum,
],
]);
$setting = Setting::where('key', 'setting')->first();
@@ -105,7 +109,7 @@ class DomainOrderController extends Controller
$orderUrl = rtrim(config('app.frontend_url', ''), '/') . '/don-hang';
Mail::to($customer->email)->send(
new DomainOrderReceivedNotification([...$mailData, 'order_url' => $orderUrl])
new DomainOrderReceivedNotification([...$mailData, 'order_url' => $orderUrl, 'invoice_id' => $result['invoice']->id])
);
} catch (\Throwable $e) {
Log::error('DomainOrderController: không thể gửi email khách hàng: ' . $e->getMessage());
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Controllers\Api\Client;
use App\Http\Controllers\Controller;
use App\Http\Requests\Api\Client\InvoiceLookupRequest;
use App\Services\InvoicePdfService;
use App\Support\InvoiceLookup;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Response;
class InvoiceLookupController extends Controller
{
private const NOT_FOUND = 'Không tìm thấy hóa đơn. Vui lòng kiểm tra lại số hóa đơn và mã tra cứu.';
public function show(InvoiceLookupRequest $request): JsonResponse
{
$invoice = InvoiceLookup::find($request->validated('invoice_number'), $request->validated('lookup_code'));
if (!$invoice) {
return response()->json(['error' => true, 'message' => self::NOT_FOUND], 404);
}
return response()->json(['error' => false, 'data' => InvoiceLookup::payload($invoice)]);
}
public function pdf(InvoiceLookupRequest $request, InvoicePdfService $pdfService): Response|JsonResponse
{
$invoice = InvoiceLookup::find($request->validated('invoice_number'), $request->validated('lookup_code'));
if (!$invoice) {
return response()->json(['error' => true, 'message' => self::NOT_FOUND], 404);
}
return response($pdfService->generate($invoice), 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename="' . $pdfService->generateFileName($invoice) . '"',
]);
}
}