feat: Reorganize database migrations for module snapshots, VMware, and OS groups, and implement customer order creation email notifications.

This commit is contained in:
pbao9
2026-03-12 12:31:52 +07:00
parent 1934be9a19
commit 508d5186db
19 changed files with 350 additions and 195 deletions
@@ -1,59 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('module_vmware', function (Blueprint $table) {
$table->id();
$table->string('name')->nullable();
$table->foreignId('module_ip_address')
->constrained('module_ip_address')->nullable();
$table->foreignId('vcenter_id')
->constrained('module_vcenter')->nullable();
$table->integer('port')->nullable();
$table->integer('order_id')->nullable();
$table->integer('first_payment')->nullable();
$table->integer('next_payment')->nullable();
$table->integer('next_due_date')->nullable();
$table->integer('next_invoice')->nullable();
$table->string('user')->nullable();
$table->text('password')->nullable();
$table->string('hostname')->nullable();
$table->string('vmware_id')->nullable();
$table->bigInteger('os_id')->default(0)->index();
$table->bigInteger('customer_id')->default(0)->index();
$table->tinyInteger('status')
->default(1)
->comment('1: Running;0:Off;2:Suspend');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('module_vmwares');
}
};
@@ -1,34 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('module_snapshot', function (Blueprint $table) {
$table->id();
$table->string('name', 255)->nullable();
$table->bigInteger('customer_id')->default(0)->index();
$table->bigInteger('module_vmware_id')->default(0)->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('module_snapshots');
}
};
@@ -1,49 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('module_snapshot', function (Blueprint $table) {
$table->text('description')->nullable()->after('name');
// Async snapshot status
$table->enum('status', [
'pending',
'processing',
'success',
'failed'
])->default('pending')->index()->after('module_vmware_id');
// vCenter mapping
$table->string('snapshot_ref')->nullable()->comment('Snapshot ID / moRef from vCenter');
$table->string('vcenter_task_id')->nullable()->comment('Task ID from vCenter');
// Error handling
$table->text('error_message')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('module_snapshot', function (Blueprint $table) {
$table->dropColumn([
'description',
'status',
'snapshot_ref',
'vcenter_task_id',
'error_message',
]);
});
}
};
@@ -1,39 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('module_snapshot', function (Blueprint $table) {
//
$table->unsignedBigInteger('size_bytes')
->nullable()
->comment('Snapshot size in bytes');
$table->decimal('size_gb', 10, 2)
->nullable()
->comment('Snapshot size in GB');
$table->timestamp('size_last_synced_at')
->nullable()
->comment('Last time snapshot size was synced');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('module_snapshot', function (Blueprint $table) {
//
});
}
};
@@ -43,7 +43,6 @@ return new class extends Migration
$table->string('payment_method', 100)->nullable();
$table->boolean('auto_renew')->default(false);
$table->date('due_date')->nullable();
$table->timestamp('paid_at')->nullable();
@@ -0,0 +1,83 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('module_vmware', function (Blueprint $table) {
$table->id();
$table->string('name')->nullable();
$table->unsignedBigInteger('module_ip_address')->nullable()->index();
$table->unsignedBigInteger('vcenter_id')->nullable()->index();
$table->integer('port')->nullable();
$table->unsignedBigInteger('order_id')->nullable()->index();
$table->integer('first_payment')->nullable();
$table->integer('next_payment')->nullable();
$table->integer('next_due_date')->nullable();
$table->integer('next_invoice')->nullable();
$table->string('user')->nullable();
$table->text('password')->nullable();
$table->string('hostname')->nullable();
$table->string('vmware_id')->nullable();
$table->unsignedBigInteger('os_id')->nullable()->index();
$table->unsignedBigInteger('customer_id')->nullable()->index();
$table->tinyInteger('status')
->default(1)
->comment('1: Running; 0: Off; 2: Suspend');
$table->timestamps();
// Foreign Keys
$table->foreign('module_ip_address')
->references('id')
->on('module_ip_address')
->nullOnDelete();
$table->foreign('vcenter_id')
->references('id')
->on('module_vcenter')
->nullOnDelete();
$table->foreign('order_id')
->references('id')
->on('orders')
->nullOnDelete();
$table->foreign('os_id')
->references('id')
->on('os')
->nullOnDelete();
$table->foreign('customer_id')
->references('id')
->on('customers')
->nullOnDelete();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('module_vmware');
}
};
@@ -0,0 +1,71 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('module_snapshot', function (Blueprint $table) {
$table->id();
$table->string('name', 255)->nullable();
$table->unsignedBigInteger('customer_id')->nullable()->index();
$table->unsignedBigInteger('module_vmware_id')->nullable()->index();
$table->text('description')->nullable();
// Async snapshot status
$table->enum('status', [
'pending',
'processing',
'success',
'failed'
])->default('pending')->index();
// vCenter mapping
$table->string('snapshot_ref')->nullable()->comment('Snapshot ID / moRef from vCenter');
$table->string('vcenter_task_id')->nullable()->comment('Task ID from vCenter');
$table->unsignedBigInteger('size_bytes')
->nullable()
->comment('Snapshot size in bytes');
$table->decimal('size_gb', 10, 2)
->nullable()
->comment('Snapshot size in GB');
$table->timestamp('size_last_synced_at')
->nullable()
->comment('Last time snapshot size was synced');
// Error handling
$table->text('error_message')->nullable();
$table->timestamps();
$table->foreign('customer_id')
->references('id')
->on('customers')
->nullOnDelete();
$table->foreign('module_vmware_id')
->references('id')
->on('module_vmware')
->nullOnDelete();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('module_snapshots');
}
};
+1 -1
View File
@@ -23,6 +23,6 @@ class DatabaseSeeder extends Seeder
$this->call(TemplateSeeder::class);
$this->call(Setting::class);
$this->call(ControlPanelSeeder::class);
// $this->call(VPSProductSeeder::class);
$this->call(VPSProductSeeder::class);
}
}
+7
View File
@@ -44,6 +44,13 @@ class TemplateSeeder extends Seeder
'type_id' => 0,
'status' => 1
],
[
'name' => 'Order Created',
'subject' => 'Xác nhận đơn hàng #{$order_num}',
'message' => '<table cellpadding=0 cellspacing=0 role=presentation style=width:100%;font-family:Montserrat,-apple-system><tr><td style=background-color:#eceff1;font-family:Montserrat,-apple-system,sans-serif align=center><table cellpadding=0 cellspacing=0 role=presentation style=width:600px><tr><td align=center><table cellpadding=0 cellspacing=0 role=presentation style=width:100%><tr><td style=padding:48px;text-align:center> <tr style=background-color:#fff><td style="text-align:center;padding:20px;border-bottom:.5px solid #ececec"><img alt={$company_name} src={$company_logo} style=max-height:100px><tr><td style=border-radius:4px;background-color:#fff;padding:48px;text-align:left;font-family:Montserrat,-apple-system,sans-serif;font-size:16px;line-height:24px;color:#626262><p style=margin-bottom:10px;font-size:20px;font-weight:600>Kính chào {$client_name},<p>Cảm ơn bạn đã đặt hàng tại <strong>{$company_name}</strong>! Đơn hàng của bạn đã được tiếp nhận thành công.<p><strong>Thông tin đơn hàng:</strong><ul><li>Mã đơn hàng: <strong>{$order_num}</strong><li>Mã hóa đơn: <strong>{$invoice_num}</strong><li>Tổng tiền: <strong>{$order_total} đ</strong></ul><p>Chúng tôi sẽ xử lý đơn hàng của bạn trong thời gian sớm nhất và thông báo khi dịch vụ được kích hoạt.<p>Nếu bạn có bất kỳ câu hỏi nào, vui lòng liên hệ với chúng tôi để được hỗ trợ.<p>Lưu ý:<ul><li>Đây là tin nhắn tự động. Vui lòng không trả lời tin nhắn này!</ul><p> </table><tr><td style=padding:48px;text-align:center> </table></table>',
'type_id' => 0,
'status' => 1
],
[
'name' => 'Service Expiry',
'subject' => 'Thông báo dịch vụ sắp hết hạn',