feat: nạp tiền thủ công mã 30 phút, gia hạn trừ số dư, đồng bộ domain từ Plesk
- Nạp tiền: mã thanh toán sống 30 phút (ManualDepositDraft), khôi phục/huỷ mã, lệnh dọn mã hết hạn; total_pending chỉ tính giao dịch đã nộp chứng từ, admin duyệt/từ chối/xoá giao dịch - Gia hạn dịch vụ: phát hành invoice gia hạn trên order gốc và trừ số dư ngay - Đồng bộ domain từ Plesk theo server, ServiceOrderRecorder tạo order/invoice cho dịch vụ admin dựng - Danh sách dịch vụ trả field theo loại (service_plan, dns_records_count), đếm dịch vụ theo loại Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
10af41c5cf
commit
c5115b52dd
@@ -88,16 +88,28 @@ class DomainPricing extends Model
|
||||
*/
|
||||
public static function findByDomain(string $domain): self
|
||||
{
|
||||
return static::matchDomain($domain)
|
||||
?? throw new \InvalidArgumentException('Tên miền không được hỗ trợ. Vui lòng chọn đuôi tên miền có trong danh sách.');
|
||||
}
|
||||
|
||||
public static function matchDomain(string $domain): ?self
|
||||
{
|
||||
$domain = mb_strtolower(trim($domain));
|
||||
$candidates = static::domains()->where('is_active', true)->get()
|
||||
->sortByDesc(fn (self $row) => strlen((string) $row->tld));
|
||||
|
||||
foreach ($candidates as $row) {
|
||||
$tld = ltrim((string) $row->tld, '.');
|
||||
$tld = mb_strtolower(ltrim((string) $row->tld, '.'));
|
||||
if ($tld !== '' && str_ends_with($domain, '.' . $tld)) {
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Tên miền không được hỗ trợ. Vui lòng chọn đuôi tên miền có trong danh sách.');
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function yearsForMonths(int $months): int
|
||||
{
|
||||
return max(1, (int) ceil($months / 12));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,11 @@ class Product extends Model
|
||||
return $this->belongsTo(ModuleIpAddress::class, 'module_ip_address');
|
||||
}
|
||||
|
||||
public function servicePlan()
|
||||
{
|
||||
return $this->belongsTo(ServicePlan::class);
|
||||
}
|
||||
|
||||
public function addons()
|
||||
{
|
||||
return $this->hasMany(Addon::class, 'type', 'product_type')
|
||||
|
||||
@@ -40,4 +40,21 @@ class ServicePlan extends Model
|
||||
{
|
||||
return $this->belongsTo(DnsServer::class, 'dns_manager_server_id');
|
||||
}
|
||||
|
||||
public function summary(): array
|
||||
{
|
||||
return [
|
||||
'title' => $this->title,
|
||||
'vcpu' => $this->vcpu,
|
||||
'ram' => $this->ram,
|
||||
'disk' => $this->disk,
|
||||
'bandwidth' => $this->bandwidth,
|
||||
'databases' => $this->databases,
|
||||
'mailboxes' => $this->mailboxes,
|
||||
'ftp_accounts' => $this->ftp_accounts,
|
||||
'subdomains' => $this->subdomains,
|
||||
'domain_aliases' => $this->domain_aliases,
|
||||
'features' => $this->features ?? [],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,20 @@ class Transaction extends Model
|
||||
};
|
||||
}
|
||||
|
||||
public function typeLabel(): string
|
||||
{
|
||||
return match ($this->type) {
|
||||
'manual' => 'Nạp tiền chuyển khoản',
|
||||
'vnpay' => 'Nạp tiền qua VNPay',
|
||||
'invoice' => 'Thanh toán hoá đơn',
|
||||
'refund' => 'Hoàn tiền',
|
||||
'admin_add_total', 'admin_add_credit' => 'Cộng số dư',
|
||||
'admin_deduct_credit' => 'Trừ số dư',
|
||||
'admin_record' => 'Ghi nhận giao dịch',
|
||||
default => 'Giao dịch',
|
||||
};
|
||||
}
|
||||
|
||||
public function getProofImageUrlsAttribute(): array
|
||||
{
|
||||
if (! $this->proof_image) {
|
||||
|
||||
Reference in New Issue
Block a user