feat(admin): improve payments and server settings

This commit is contained in:
baodev0
2026-10-19 07:59:23 +07:00
parent 9ed77a85fd
commit ea9a53f742
32 changed files with 680 additions and 78 deletions
@@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('dns_manager_servers', function (Blueprint $table) {
$table->string('domain')->nullable()->after('ip_address');
});
}
public function down(): void
{
Schema::table('dns_manager_servers', function (Blueprint $table) {
$table->dropColumn('domain');
});
}
};
@@ -0,0 +1,50 @@
<?php
use App\Support\EmailTemplateShell;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
private const SCENARIO = 'admin_payment_received';
public function up(): void
{
if (DB::table('template')->where('scenario', self::SCENARIO)->exists()) {
return;
}
$body = EmailTemplateShell::title('Khách hàng vừa thanh toán')
. EmailTemplateShell::paragraph('Hệ thống <strong>{{company_name}}</strong> vừa ghi nhận một khoản thanh toán mới.')
. EmailTemplateShell::infoTable([
'Loại thanh toán' => '{{payment_type}}',
'Mã tham chiếu' => '#{{reference}}',
'Số hóa đơn' => '{{invoice_number}}',
'Khách hàng' => '{{customer_name}}',
'Email' => '{{customer_email}}',
'Số tiền vừa trả' => '{{amount_formatted}}',
'Còn thiếu' => '{{outstanding_formatted}}',
'Trạng thái' => '{{payment_status}}',
'Thời gian' => '{{created_at}}',
]);
DB::table('template')->insert([
'type_id' => 0,
'scenario' => self::SCENARIO,
'key' => self::SCENARIO,
'format' => 'html',
'name' => '[Admin] Khách hàng thanh toán',
'subject' => '[ADMIN] Khách hàng thanh toán {{payment_type}} #{{reference}}',
'message' => EmailTemplateShell::wrap(EmailTemplateShell::body($body)),
'metadata' => json_encode(['variables' => []], JSON_UNESCAPED_UNICODE),
'status' => 1,
'created_at' => now(),
'updated_at' => now(),
]);
}
public function down(): void
{
DB::table('template')->where('scenario', self::SCENARIO)->delete();
}
};
@@ -12,6 +12,24 @@ final class AdminTemplates
public static function all(): array
{
return [
[
'scenario' => 'admin_payment_received',
'name' => '[Admin] Khách hàng thanh toán',
'subject' => '[ADMIN] Khách hàng thanh toán {{payment_type}} #{{reference}}',
'body' => T::title('Khách hàng vừa thanh toán')
. T::paragraph('Hệ thống <strong>{{company_name}}</strong> vừa ghi nhận một khoản thanh toán mới.')
. T::infoTable([
'Loại thanh toán' => '{{payment_type}}',
'Mã tham chiếu' => '#{{reference}}',
'Số hóa đơn' => '{{invoice_number}}',
'Khách hàng' => '{{customer_name}}',
'Email' => '{{customer_email}}',
'Số tiền vừa trả' => '{{amount_formatted}}',
'Còn thiếu' => '{{outstanding_formatted}}',
'Trạng thái' => '{{payment_status}}',
'Thời gian' => '{{created_at}}',
]),
],
[
'scenario' => 'admin_order_notification',
'name' => '[Admin] Đơn hàng mới',
@@ -103,6 +103,10 @@ final class TemplateVariables
'paid_row' => ['[Tự động] Dòng đã thanh toán', 'html', ''],
'transaction_code' => ['Mã giao dịch', 'string', 'NAP20261008001'],
'amount_formatted' => ['Số tiền', 'string', '500,000'],
'payment_type' => ['Loại thanh toán', 'string', 'Hóa đơn'],
'reference' => ['Mã tham chiếu', 'string', 'DH20261017001'],
'outstanding_formatted' => ['Số tiền còn thiếu', 'string', '0 VNĐ'],
'payment_status' => ['Trạng thái thanh toán', 'string', 'Đã thanh toán đủ'],
'credit_formatted' => ['Tiền khuyến mãi', 'string', '0'],
'current_total_formatted' => ['Số dư hiện tại', 'string', '1,500,000'],
'current_credit_formatted' => ['Số dư khuyến mãi hiện tại', 'string', '0'],