feat: khởi tạo/huỷ domain Plesk qua job, gửi mail hoá đơn qua queue, đính kèm triển khai
- ProvisionDnsDomainJob/SuspendDnsDomainJob: tạo domain admin lên Plesk, huỷ = suspend (is_created=3) - Khách xem zone DNS được gán ở /dich-vu/domain, quản lý bản ghi A/AAAA/CNAME/TXT/MX/SRV - send-mail hoá đơn đẩy SendInvoiceMailJob, preview + sửa nội dung, ghi mail.order_id - invoice_attachments.type (payment_proof/deployment) - CacheService xoá theo SCAN pattern, Redis không persistent mặc định - Backfill transactions.public_code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
30898ea46f
commit
94614d9cb3
@@ -10,6 +10,11 @@ class DnsDomain extends Model
|
||||
{
|
||||
use HasFactory, LogsActivity;
|
||||
|
||||
public const STATUS_PENDING = 0;
|
||||
public const STATUS_CREATED = 1;
|
||||
public const STATUS_INACTIVE = 2;
|
||||
public const STATUS_CANCELLED = 3;
|
||||
|
||||
protected $table = 'dns_manager_domain';
|
||||
|
||||
protected $fillable = [
|
||||
@@ -20,6 +25,11 @@ class DnsDomain extends Model
|
||||
'registrar_id',
|
||||
];
|
||||
|
||||
public function scopeNotCancelled($query)
|
||||
{
|
||||
return $query->where('is_created', '!=', self::STATUS_CANCELLED);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsToMany(Customer::class, 'dns_domain_user', 'domain_id', 'user_id')->withTimestamps();
|
||||
|
||||
@@ -36,6 +36,11 @@ class Invoice extends Model
|
||||
}
|
||||
|
||||
/** The order that originated this invoice. */
|
||||
public function clientPath(): string
|
||||
{
|
||||
return '/hoa-don/' . ($this->order?->order_num ?? $this->invoice_number);
|
||||
}
|
||||
|
||||
public function order()
|
||||
{
|
||||
return $this->belongsTo(Order::class, 'order_id');
|
||||
|
||||
@@ -7,6 +7,9 @@ use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class InvoiceAttachment extends Model
|
||||
{
|
||||
public const TYPE_PAYMENT_PROOF = 'payment_proof';
|
||||
public const TYPE_DEPLOYMENT = 'deployment';
|
||||
|
||||
protected $table = 'invoice_attachments';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
@@ -20,6 +20,7 @@ class Mail extends Model
|
||||
'cc',
|
||||
'bcc',
|
||||
'customer_id',
|
||||
'order_id',
|
||||
'sent_by',
|
||||
'message',
|
||||
'status'
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\Cache\CacheServiceInterface;
|
||||
use App\Traits\LogsActivity;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Traits\HasUuid;
|
||||
|
||||
class Transaction extends Model
|
||||
@@ -30,6 +33,24 @@ class Transaction extends Model
|
||||
|
||||
protected $appends = ['direction', 'proof_image_urls'];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (Transaction $transaction) {
|
||||
$transaction->public_code ??= self::newPublicCode('TXN');
|
||||
});
|
||||
|
||||
$flushListCache = fn () => DB::afterCommit(
|
||||
fn () => app(CacheServiceInterface::class)->clearByModule('transaction')
|
||||
);
|
||||
static::saved($flushListCache);
|
||||
static::deleted($flushListCache);
|
||||
}
|
||||
|
||||
public static function newPublicCode(string $prefix): string
|
||||
{
|
||||
return $prefix . '-' . now()->format('Ymd') . '-' . strtoupper(Str::random(6));
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'customer_id');
|
||||
@@ -53,7 +74,7 @@ class Transaction extends Model
|
||||
'admin_add_total', 'admin_add_credit', 'manual', 'refund' => 'credit',
|
||||
'admin_deduct_credit' => 'debit',
|
||||
'balance' => 'debit',
|
||||
'transfer' => 'neutral',
|
||||
'transfer', 'admin_record' => 'neutral',
|
||||
'invoice' => str_starts_with((string) $this->note, 'Admin xác nhận')
|
||||
? 'neutral'
|
||||
: 'debit',
|
||||
|
||||
Reference in New Issue
Block a user