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:
co-authored by
Claude Sonnet 5.5
parent
047c23beff
commit
55a834a2f8
@@ -9,6 +9,7 @@ use App\Models\MailCampaign;
|
||||
use App\Models\Notification;
|
||||
use App\Services\Email\MailCampaignRenderer;
|
||||
use App\Support\EmailRecipients;
|
||||
use App\Support\RenewalCampaign;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -27,6 +28,7 @@ class SendMailCampaignRecipient implements ShouldQueue
|
||||
private readonly int $campaignId,
|
||||
private readonly ?int $customerId,
|
||||
private readonly string $email,
|
||||
private readonly ?int $serviceId = null,
|
||||
) {}
|
||||
|
||||
public function handle(MailCampaignRenderer $renderer): void
|
||||
@@ -43,7 +45,29 @@ class SendMailCampaignRecipient implements ShouldQueue
|
||||
return;
|
||||
}
|
||||
|
||||
$rendered = $renderer->render($campaign, $renderer->recipientValues($campaign, $customer, $this->email));
|
||||
$values = $renderer->recipientValues($campaign, $customer, $this->email);
|
||||
if ($this->serviceId !== null) {
|
||||
$renewal = $customer ? RenewalCampaign::valuesFor($campaign, $customer, $this->serviceId) : null;
|
||||
if ($renewal === null) {
|
||||
MailLog::create([
|
||||
'campaign_id' => $campaign->id,
|
||||
'template_id' => $campaign->template_id ?? 0,
|
||||
'subject' => $campaign->subject,
|
||||
'to' => $this->email,
|
||||
'customer_id' => $customer?->id,
|
||||
'service_id' => $this->serviceId,
|
||||
'sent_by' => $campaign->created_by,
|
||||
'message' => 'Không gửi: dịch vụ không còn thuộc khách hàng hoặc không thể tính giá gia hạn.',
|
||||
'status' => 'failed',
|
||||
]);
|
||||
$this->markDone($campaign, true);
|
||||
|
||||
return;
|
||||
}
|
||||
$values = [...$values, ...$renewal];
|
||||
}
|
||||
|
||||
$rendered = $renderer->render($campaign, $values);
|
||||
$cc = EmailRecipients::parse($campaign->cc);
|
||||
$bcc = EmailRecipients::parse($campaign->bcc);
|
||||
$mailConfig = Arr::only($campaign->template?->mailConfig() ?? [], ['from_email', 'from_name', 'reply_to', 'reply_to_name']);
|
||||
@@ -81,6 +105,7 @@ class SendMailCampaignRecipient implements ShouldQueue
|
||||
'cc' => implode(', ', $cc),
|
||||
'bcc' => implode(', ', $bcc),
|
||||
'customer_id' => $customer?->id,
|
||||
'service_id' => $this->serviceId,
|
||||
'sent_by' => $campaign->created_by,
|
||||
'message' => $rendered['html'],
|
||||
'status' => $failed ? 'failed' : 'sent',
|
||||
|
||||
Reference in New Issue
Block a user