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
@@ -337,12 +337,15 @@ class OrderControllerRefactor extends Controller
|
||||
{
|
||||
$result = $this->orderQueryService->renewService(
|
||||
$id,
|
||||
(int) $request->user()->id,
|
||||
$request->user(),
|
||||
(int) $request->validated()['months'],
|
||||
);
|
||||
|
||||
if (!$result['ok']) {
|
||||
return response()->json(['success' => false, 'message' => $result['message']], $result['code']);
|
||||
return response()->json(
|
||||
['success' => false, 'message' => $result['message'], 'data' => $result['data'] ?? null],
|
||||
$result['code'],
|
||||
);
|
||||
}
|
||||
|
||||
return response()->json(['success' => true, 'message' => $result['message'], 'data' => $result['data']]);
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api\Service;
|
||||
use App\Enums\Product\ProductTypeEnums;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Resources\Api\Service\ProductCategoryResource;
|
||||
use App\Http\Resources\Api\Service\ServiceResource;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductCategories;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -161,11 +162,12 @@ class ProductCategoryController extends Controller
|
||||
->with([
|
||||
'osVersions.osGroup',
|
||||
'category',
|
||||
'servicePlan',
|
||||
'pricings' => fn($q) => $q->where('is_active', 1)
|
||||
])
|
||||
->get();
|
||||
|
||||
$productResources = $products->map(fn($product) => $this->formatProduct($product));
|
||||
$productResources = ServiceResource::collection($products)->resolve();
|
||||
|
||||
$categoryArray = $category->toArray();
|
||||
$categoryArray['products'] = $productResources;
|
||||
@@ -265,11 +267,12 @@ class ProductCategoryController extends Controller
|
||||
->with([
|
||||
'osVersions.osGroup',
|
||||
'category',
|
||||
'servicePlan',
|
||||
'pricings' => fn($q) => $q->where('is_active', 1)
|
||||
])
|
||||
->get();
|
||||
|
||||
$productResources = $products->map(fn($product) => $this->formatProduct($product));
|
||||
$productResources = ServiceResource::collection($products)->resolve();
|
||||
|
||||
$childArray = $child->toArray();
|
||||
$childArray['parent'] = $child->parent ? $child->parent->toArray() : null;
|
||||
@@ -281,81 +284,4 @@ class ProductCategoryController extends Controller
|
||||
'data' => $childArray,
|
||||
]);
|
||||
}
|
||||
|
||||
private function formatProduct($product): array
|
||||
{
|
||||
$billingCycleLabels = [
|
||||
'monthly' => 'Hàng tháng',
|
||||
'quarterly' => 'Hàng quý',
|
||||
'semi_annually' => 'Nửa năm',
|
||||
'annually' => 'Hàng năm',
|
||||
'biennially' => '2 năm',
|
||||
'triennially' => '3 năm',
|
||||
'onetime' => 'Một lần',
|
||||
];
|
||||
|
||||
$periodMonths = [
|
||||
'monthly' => 1,
|
||||
'quarterly' => 3,
|
||||
'semi_annually' => 6,
|
||||
'annually' => 12,
|
||||
'biennially' => 24,
|
||||
'triennially' => 36,
|
||||
'onetime' => 0,
|
||||
];
|
||||
|
||||
$periodUnits = [
|
||||
'monthly' => 'month',
|
||||
'quarterly' => 'quarter',
|
||||
'semi_annually' => 'semi_year',
|
||||
'annually' => 'year',
|
||||
'biennially' => 'biennially',
|
||||
'triennially' => 'triennially',
|
||||
'onetime' => 'none',
|
||||
];
|
||||
|
||||
return [
|
||||
'uuid' => $product->uuid,
|
||||
'name' => $product->name,
|
||||
'slug' => $product->slug,
|
||||
'short_description' => $product->short_description,
|
||||
'description' => $product->description,
|
||||
'thumbnail' => $product->thumbnail ? asset($product->thumbnail) : null,
|
||||
'product_type' => $product->product_type,
|
||||
'specs' => [
|
||||
'cpu' => (int) $product->cpu,
|
||||
'ram' => (int) $product->ram,
|
||||
'disk' => (int) $product->disk,
|
||||
'bandwidth' => (int) $product->bandwidth,
|
||||
'gpu' => $product->gpu,
|
||||
],
|
||||
'stock' => $product->stock,
|
||||
'price' => (int) $product->price,
|
||||
'price_sale' => $product->price_sale ? (int) $product->price_sale : null,
|
||||
'group' => $product->category->name ?? null,
|
||||
'os' => $product->osVersions->groupBy('os_group_id')->map(function ($versions) {
|
||||
$group = $versions->first()->osGroup;
|
||||
return [
|
||||
'name' => $group?->name,
|
||||
'thumbnail' => $group?->thumbnail,
|
||||
'versions' => $versions->map(fn($os) => [
|
||||
'id' => $os->id,
|
||||
'version' => $os->version,
|
||||
'name' => $os->name,
|
||||
])->values(),
|
||||
];
|
||||
})->values(),
|
||||
'pricing' => $product->pricings
|
||||
->sortBy(fn($p) => $periodMonths[$p->billing_cycle] ?? 999)
|
||||
->values()
|
||||
->map(fn($p) => [
|
||||
'id' => $p->id,
|
||||
'name' => $billingCycleLabels[$p->billing_cycle] ?? $p->billing_cycle,
|
||||
'price' => (int) $p->price,
|
||||
'price_sale' => $p->price_sale ? (int) $p->price_sale : null,
|
||||
'period' => $periodMonths[$p->billing_cycle] ?? 1,
|
||||
'period_unit' => $periodUnits[$p->billing_cycle] ?? 'month',
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,8 @@ class ServiceController extends Controller
|
||||
'osVersions.osGroup',
|
||||
'category',
|
||||
'pricings' => fn($q) => $q->where('is_active', 1),
|
||||
'addons'
|
||||
'addons',
|
||||
'servicePlan',
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
|
||||
Reference in New Issue
Block a user