- Dịch vụ custom: bảng custom_products + services.custom_product_id; createService nhận
custom{} thay product_id, giá = đơn giá tháng x số tháng chu kỳ (1/3/6/12/24/36),
gia hạn tính theo cùng đơn giá, ServiceClientDetailResource trả custom_product và specs.
- Giám sát VM: GET v1/system/vm-metrics/history gom lịch sử về tối đa 240 điểm;
lỗi lấy dung lượng đĩa không còn làm hỏng cả thẻ metrics.
- SealResponse: AES-256-GCM theo khoá phiên do proxy Next cấp qua header x-seal-key
(HMAC của session id). Client opt-in bằng x-seal; chi tiết dịch vụ, mật khẩu VM và
console ticket luôn được mã hoá. Body gửi lên dạng {enc} được giải mã trước validate;
khoá lệch trả 428 để client lấy khoá mới. Đây là che mắt DevTools, không phải bảo mật
chống chính chủ tài khoản.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Support\BillingCycleCatalog;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class CustomProduct extends Model
|
|
{
|
|
public const CATEGORIES = ['vps', 'hosting', 'ssl', 'server_rental', 'other'];
|
|
|
|
public const CYCLE_MONTHS = [1, 3, 6, 12, 24, 36];
|
|
|
|
protected $fillable = [
|
|
'name', 'category', 'cpu', 'ram_mb', 'disk_gb', 'bandwidth_gb',
|
|
'specs', 'description', 'unit_price',
|
|
];
|
|
|
|
protected $casts = ['specs' => 'array'];
|
|
|
|
public static function cycleCode(int $months): string
|
|
{
|
|
foreach (BillingCycleCatalog::builtInCodes() as $code) {
|
|
if (BillingCycleCatalog::monthsFor($code) === $months) {
|
|
return $code;
|
|
}
|
|
}
|
|
|
|
return BillingCycleCatalog::codeFor($months);
|
|
}
|
|
|
|
public function summary(): array
|
|
{
|
|
return [
|
|
'name' => $this->name,
|
|
'category' => $this->category,
|
|
'cpu' => $this->cpu,
|
|
'ram_mb' => $this->ram_mb,
|
|
'disk_gb' => $this->disk_gb,
|
|
'bandwidth_gb' => $this->bandwidth_gb,
|
|
'specs' => $this->specs ?? [],
|
|
'description' => $this->description,
|
|
];
|
|
}
|
|
}
|