update email template

This commit is contained in:
baodev0
2026-09-09 16:56:22 +07:00
parent d3d9f76ba0
commit 2365ef72e9
210 changed files with 6335 additions and 4688 deletions
@@ -0,0 +1,36 @@
<?php
namespace App\Console\Commands\Whmcs;
use App\Integrations\Whmcs\Extractors\ClientExtractor;
use App\Jobs\Whmcs\SyncClientJob;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class SyncClientsCommand extends Command
{
protected $signature = 'whmcs:sync-clients {--sync : Run each record inline instead of queueing it}';
protected $description = 'Extract clients from the WHMCS database and upsert them into customers';
public function handle(ClientExtractor $extractor): int
{
$sync = (bool) $this->option('sync');
$total = DB::connection('whmcs')->table('tblclients')->count();
$bar = $this->output->createProgressBar($total);
$bar->start();
foreach ($extractor->extract() as $row) {
$job = new SyncClientJob((array) $row);
$sync ? dispatch_sync($job) : dispatch($job);
$bar->advance();
}
$bar->finish();
$this->newLine();
$this->info("Dispatched {$total} client(s) for sync.");
return Command::SUCCESS;
}
}
@@ -0,0 +1,38 @@
<?php
namespace App\Console\Commands\Whmcs;
use App\Integrations\Whmcs\Extractors\CustomerDomainExtractor;
use App\Integrations\Whmcs\Transformers\CustomerDomainTransformer;
use App\Integrations\Whmcs\Writers\CustomerDomainWriter;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class SyncCustomerDomainsCommand extends Command
{
protected $signature = 'whmcs:sync-domains';
protected $description = 'Extract customer domain registrations (tbldomains) from WHMCS and upsert them into module_domain (run after whmcs:sync-clients, whmcs:sync-orders, domain:sync)';
public function handle(CustomerDomainExtractor $extractor, CustomerDomainTransformer $transformer, CustomerDomainWriter $writer): int
{
$total = DB::connection('whmcs')->table('tbldomains')->count();
$bar = $this->output->createProgressBar($total);
$bar->start();
$skipped = 0;
foreach ($extractor->extract() as $row) {
if (! $writer->write($transformer->transform($row))) {
$skipped++;
}
$bar->advance();
}
$bar->finish();
$this->newLine();
$this->info("Processed {$total} domain(s), skipped {$skipped} (unresolved customer).");
return Command::SUCCESS;
}
}
@@ -0,0 +1,36 @@
<?php
namespace App\Console\Commands\Whmcs;
use App\Integrations\Whmcs\Extractors\InvoiceExtractor;
use App\Jobs\Whmcs\SyncInvoiceJob;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class SyncInvoicesCommand extends Command
{
protected $signature = 'whmcs:sync-invoices {--sync : Run each record inline instead of queueing it}';
protected $description = 'Extract invoices (with their line items) from WHMCS and upsert them into invoices/invoice_items';
public function handle(InvoiceExtractor $extractor): int
{
$sync = (bool) $this->option('sync');
$total = DB::connection('whmcs')->table('tblinvoices')->count();
$bar = $this->output->createProgressBar($total);
$bar->start();
foreach ($extractor->extract() as $row) {
$job = new SyncInvoiceJob((array) $row);
$sync ? dispatch_sync($job) : dispatch($job);
$bar->advance();
}
$bar->finish();
$this->newLine();
$this->info("Dispatched {$total} invoice(s) for sync.");
return Command::SUCCESS;
}
}
@@ -0,0 +1,38 @@
<?php
namespace App\Console\Commands\Whmcs;
use App\Integrations\Whmcs\Extractors\OrderItemExtractor;
use App\Integrations\Whmcs\Transformers\OrderItemTransformer;
use App\Integrations\Whmcs\Writers\OrderItemWriter;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class SyncOrderItemsCommand extends Command
{
protected $signature = 'whmcs:sync-order-items';
protected $description = 'Extract provisioned services (tblhosting) from WHMCS and upsert them into order_items (run after whmcs:sync-orders)';
public function handle(OrderItemExtractor $extractor, OrderItemTransformer $transformer, OrderItemWriter $writer): int
{
$total = DB::connection('whmcs')->table('tblhosting')->count();
$bar = $this->output->createProgressBar($total);
$bar->start();
$skipped = 0;
foreach ($extractor->extract() as $row) {
if (! $writer->write($transformer->transform($row))) {
$skipped++;
}
$bar->advance();
}
$bar->finish();
$this->newLine();
$this->info("Processed {$total} order item(s), skipped {$skipped} (unresolved order).");
return Command::SUCCESS;
}
}
@@ -0,0 +1,36 @@
<?php
namespace App\Console\Commands\Whmcs;
use App\Integrations\Whmcs\Extractors\OrderExtractor;
use App\Jobs\Whmcs\SyncOrderJob;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class SyncOrdersCommand extends Command
{
protected $signature = 'whmcs:sync-orders {--sync : Run each record inline instead of queueing it}';
protected $description = 'Extract orders from the WHMCS database and upsert them into orders (run before whmcs:sync-invoices)';
public function handle(OrderExtractor $extractor): int
{
$sync = (bool) $this->option('sync');
$total = DB::connection('whmcs')->table('tblorders')->count();
$bar = $this->output->createProgressBar($total);
$bar->start();
foreach ($extractor->extract() as $row) {
$job = new SyncOrderJob((array) $row);
$sync ? dispatch_sync($job) : dispatch($job);
$bar->advance();
}
$bar->finish();
$this->newLine();
$this->info("Dispatched {$total} order(s) for sync.");
return Command::SUCCESS;
}
}
@@ -0,0 +1,72 @@
<?php
namespace App\Console\Commands\Whmcs;
use App\Integrations\Whmcs\Extractors\AddonExtractor;
use App\Integrations\Whmcs\Extractors\ProductExtractor;
use App\Integrations\Whmcs\Extractors\ProductGroupExtractor;
use App\Integrations\Whmcs\Transformers\ProductAddonTransformer;
use App\Integrations\Whmcs\Transformers\ProductCategoryTransformer;
use App\Integrations\Whmcs\Transformers\ProductTransformer;
use App\Integrations\Whmcs\Writers\ProductAddonWriter;
use App\Integrations\Whmcs\Writers\ProductCategoryWriter;
use App\Integrations\Whmcs\Writers\ProductWriter;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class SyncProductsCommand extends Command
{
protected $signature = 'whmcs:sync-products';
protected $description = 'Extract product groups, products (with pricing) and addons from WHMCS and upsert them into product_categories/products/product_pricings/product_addon';
public function handle(
ProductGroupExtractor $groupExtractor,
ProductCategoryTransformer $groupTransformer,
ProductCategoryWriter $groupWriter,
ProductExtractor $productExtractor,
ProductTransformer $productTransformer,
ProductWriter $productWriter,
AddonExtractor $addonExtractor,
ProductAddonTransformer $addonTransformer,
ProductAddonWriter $addonWriter,
): int {
// Order matters: categories before products (FK), products before addons (type guess looks at linked products).
$this->info('Syncing product categories...');
$bar = $this->output->createProgressBar(DB::connection('whmcs')->table('tblproductgroups')->count());
$bar->start();
foreach ($groupExtractor->extract() as $row) {
$groupWriter->write($groupTransformer->transform($row));
$bar->advance();
}
$bar->finish();
$this->newLine();
$this->info('Syncing products...');
$bar = $this->output->createProgressBar(DB::connection('whmcs')->table('tblproducts')->count());
$bar->start();
$skippedProducts = 0;
foreach ($productExtractor->extract() as $row) {
if (! $productWriter->write($productTransformer->transform($row))) {
$skippedProducts++;
}
$bar->advance();
}
$bar->finish();
$this->newLine();
$this->info('Syncing addons...');
$bar = $this->output->createProgressBar(DB::connection('whmcs')->table('tbladdons')->count());
$bar->start();
foreach ($addonExtractor->extract() as $row) {
$addonWriter->write($addonTransformer->transform($row));
$bar->advance();
}
$bar->finish();
$this->newLine();
$this->info("Skipped: {$skippedProducts} product(s) (unresolved category).");
return Command::SUCCESS;
}
}
@@ -0,0 +1,38 @@
<?php
namespace App\Console\Commands\Whmcs;
use App\Integrations\Whmcs\Extractors\ServiceExtractor;
use App\Integrations\Whmcs\Transformers\ServiceTransformer;
use App\Integrations\Whmcs\Writers\ServiceWriter;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class SyncServicesCommand extends Command
{
protected $signature = 'whmcs:sync-services';
protected $description = 'Extract provisioned services (tblhosting) from WHMCS and upsert them into services (run after whmcs:sync-clients, whmcs:sync-products, whmcs:sync-order-items)';
public function handle(ServiceExtractor $extractor, ServiceTransformer $transformer, ServiceWriter $writer): int
{
$total = DB::connection('whmcs')->table('tblhosting')->count();
$bar = $this->output->createProgressBar($total);
$bar->start();
$skipped = 0;
foreach ($extractor->extract() as $row) {
if (! $writer->write($transformer->transform($row))) {
$skipped++;
}
$bar->advance();
}
$bar->finish();
$this->newLine();
$this->info("Processed {$total} service(s), skipped {$skipped} (unresolved customer).");
return Command::SUCCESS;
}
}