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
@@ -6,9 +6,26 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
use Illuminate\Validation\Rule;
|
||||
use App\Enums\Product\ProductBillingCycle;
|
||||
use App\Enums\Product\ProductTypeEnums;
|
||||
use App\Models\Product;
|
||||
|
||||
class StoreOrderRequest extends FormRequest
|
||||
{
|
||||
private const DOMAIN_PATTERN = '/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$/i';
|
||||
|
||||
private function isHostingOrder(): bool
|
||||
{
|
||||
return Product::where('uuid', $this->input('product_id'))
|
||||
->value('product_type') === ProductTypeEnums::HOSTING->value;
|
||||
}
|
||||
|
||||
protected function prepareForValidation(): void
|
||||
{
|
||||
if (is_string($this->input('server_name'))) {
|
||||
$this->merge(['server_name' => trim($this->input('server_name'))]);
|
||||
}
|
||||
}
|
||||
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
@@ -19,7 +36,9 @@ class StoreOrderRequest extends FormRequest
|
||||
return [
|
||||
'product_id' => ['required', Rule::exists('products', 'uuid')->whereNull('deleted_at')],
|
||||
'billing_cycle'=> ['required', Rule::enum(ProductBillingCycle::class)],
|
||||
'server_name' => 'nullable|string|max:255',
|
||||
'server_name' => $this->isHostingOrder()
|
||||
? ['required', 'string', 'max:253', 'regex:'.self::DOMAIN_PATTERN]
|
||||
: 'nullable|string|max:255',
|
||||
'os_id' => 'nullable|integer',
|
||||
'addons' => 'array',
|
||||
'addons.*.addon_id' => 'nullable|exists:product_addon,id',
|
||||
@@ -35,6 +54,8 @@ class StoreOrderRequest extends FormRequest
|
||||
'billing_cycle.required' => 'Vui lòng chọn chu kỳ thanh toán',
|
||||
'billing_cycle.enum' => 'Chu kỳ thanh toán không hợp lệ',
|
||||
'billing_cycle.exists' => 'Chu kỳ thanh toán không áp dụng cho sản phẩm này',
|
||||
'server_name.required' => 'Vui lòng nhập tên miền cho hosting',
|
||||
'server_name.regex' => 'Tên miền không hợp lệ (ví dụ: example.com)',
|
||||
'os_id.exists' => 'Hệ điều hành không hợp lệ',
|
||||
'addons.*.addon_id.exists' => 'Addon không tồn tại',
|
||||
'addons.*.qty.min' => 'Số lượng addon phải lớn hơn 0',
|
||||
|
||||
Reference in New Issue
Block a user