feat: email gửi tay/nhắc gia hạn, gói hosting, sửa dữ liệu sản phẩm
- Gửi email theo template cho 1 khách, tab lịch sử email, nhắc gia hạn dịch vụ hàng loạt - Mail lưu from/bcc/sent_by; mẫu MARKETING và mẫu cũ trong TemplateSeeder - Gói hosting: giới hạn, trạng thái, lấy plan Plesk qua CLI gateway - Backfill payment_method và ngày đơn hàng còn thiếu - Bổ sung field CPU/RAM/Disk/Băng thông cho loại sản phẩm vps và cloud Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8651dde6b1
commit
30898ea46f
@@ -8,6 +8,8 @@ use App\Support\MailPlaceholders;
|
||||
use Database\Seeders\EmailTemplates\AccountTemplates;
|
||||
use Database\Seeders\EmailTemplates\AdminTemplates;
|
||||
use Database\Seeders\EmailTemplates\BillingTemplates;
|
||||
use Database\Seeders\EmailTemplates\LegacyTemplates;
|
||||
use Database\Seeders\EmailTemplates\MarketingTemplates;
|
||||
use Database\Seeders\EmailTemplates\ServiceTemplates;
|
||||
use Database\Seeders\EmailTemplates\TemplateVariables;
|
||||
use Illuminate\Database\Seeder;
|
||||
@@ -16,9 +18,31 @@ class TemplateSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
foreach (self::templates() as $item) {
|
||||
foreach ([...self::templates(), ...self::legacyTemplates()] as $item) {
|
||||
$this->upsert($item);
|
||||
}
|
||||
|
||||
foreach (MarketingTemplates::all() as $item) {
|
||||
$this->createMarketingIfMissing($item);
|
||||
}
|
||||
}
|
||||
|
||||
private function createMarketingIfMissing(array $item): void
|
||||
{
|
||||
$template = Template::firstOrNew(['name' => $item['name']]);
|
||||
if ($template->exists) {
|
||||
return;
|
||||
}
|
||||
|
||||
$template->fill([
|
||||
'type_id' => 0,
|
||||
'format' => 'html',
|
||||
'subject' => $item['subject'],
|
||||
'message' => EmailTemplateShell::page($item['body']),
|
||||
'status' => 1,
|
||||
]);
|
||||
$template->syncVariables($item['variables']);
|
||||
$template->save();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,6 +70,17 @@ class TemplateSeeder extends Seeder
|
||||
return [$layout, ...$scenarios];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, array{scenario: string, name: string, subject: string, message: string}>
|
||||
*/
|
||||
public static function legacyTemplates(): array
|
||||
{
|
||||
return array_map(
|
||||
fn (array $item) => [...$item, 'message' => EmailTemplateShell::page($item['body'])],
|
||||
LegacyTemplates::all(),
|
||||
);
|
||||
}
|
||||
|
||||
private function upsert(array $item): void
|
||||
{
|
||||
$scenario = $item['scenario'];
|
||||
|
||||
Reference in New Issue
Block a user