feat: nhắc gia hạn QR theo dịch vụ, failover server hosting, CCCD admin, log cấp phát dịch vụ

- Mail campaign: mẫu nhắc gia hạn thanh toán QR, chọn dịch vụ + chu kỳ từng dòng (renewal_services)
- Hosting: nhiều server Plesk cho một gói (service_plan_servers), chuyển server khi server chết
- Admin xem/sửa giấy tờ định danh khách, tuỳ chọn gia hạn cho khách, nhật ký cấp phát dịch vụ
- Đánh dấu mẫu email dịch vụ là non-marketing

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
baodev0
2026-10-30 18:36:41 +07:00
co-authored by Claude Sonnet 5.5
parent 047c23beff
commit 55a834a2f8
53 changed files with 1463 additions and 119 deletions
+1
View File
@@ -21,6 +21,7 @@ class Mail extends Model
'bcc',
'customer_id',
'order_id',
'service_id',
'sent_by',
'message',
'status'
+2
View File
@@ -26,6 +26,7 @@ class MailCampaign extends Model
'message',
'variables',
'attachments',
'renewal_services',
'cc',
'bcc',
'recipient_type',
@@ -40,6 +41,7 @@ class MailCampaign extends Model
protected $casts = [
'variables' => 'array',
'attachments' => 'array',
'renewal_services' => 'array',
'total_recipients' => 'integer',
'sent_count' => 'integer',
'failed_count' => 'integer',
+15
View File
@@ -41,6 +41,21 @@ class ServicePlan extends Model
return $this->belongsTo(DnsServer::class, 'dns_manager_server_id');
}
public function servers()
{
return $this->belongsToMany(DnsServer::class, 'service_plan_servers', 'service_plan_id', 'dns_manager_server_id')
->withPivot('priority')
->orderByPivot('priority');
}
public function syncServers(array $serverIds): void
{
$ids = array_values(array_unique(array_map('intval', $serverIds)));
$this->servers()->sync(collect($ids)->mapWithKeys(fn (int $id, int $index) => [$id => ['priority' => $index]])->all());
$this->update(['dns_manager_server_id' => $ids[0] ?? null]);
}
public function summary(): array
{
return [
+10 -1
View File
@@ -54,9 +54,18 @@ class Template extends Model
}
}
public function category(): string
{
$described = EmailScenarioRegistry::describe($this->key, $this->scenario);
return $described['registered'] || ($this->metadata['marketing'] ?? true) !== false
? $described['category']
: EmailScenarioRegistry::BUSINESS;
}
public function isMarketing(): bool
{
return EmailScenarioRegistry::describe($this->key, $this->scenario)['category'] === EmailScenarioRegistry::MARKETING;
return $this->category() === EmailScenarioRegistry::MARKETING;
}
/** Danh sách variable hợp lệ khai báo trong metadata.variables, key theo variable key. */