feat(service): detach/attach service to customer with activity log
- Customer tab "delete" no longer deletes the service: it detaches the
customer, discards the order/invoices and logs a `detached` activity
with the previous customer and order.
- New POST customers/{uuid}/services/attach assigns an unassigned
service (GET services?unassigned=1) to a customer, creating a pending
order + unpaid invoice when missing, and logs `attached`.
- Detach/attach also sync module_vmware/module_hosting_accounts
customer_id: ResolvesVm authorises by module_vmware.customer_id, so a
detached customer could still control the VM.
- /services detach-customer (single + bulk) go through the same path.
- GET services/{id} returns the service activity logs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
2ca11d42fb
commit
ecd6f20a5b
@@ -14,13 +14,22 @@ trait ManagesCustomerServices
|
||||
return response()->json(['error' => false, 'data' => $this->serviceProvisioning->getServices($uuid)]);
|
||||
}
|
||||
|
||||
public function attachService(string $uuid, Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate(['service_id' => 'required|integer|exists:services,id']);
|
||||
|
||||
$service = $this->serviceProvisioning->attachService($uuid, $data['service_id']);
|
||||
|
||||
return response()->json(['error' => false, 'message' => 'Đã gán dịch vụ cho khách hàng', 'data' => $service]);
|
||||
}
|
||||
|
||||
public function bulkDeleteServices(string $uuid, Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate(['ids' => 'required|array|min:1', 'ids.*' => 'integer']);
|
||||
|
||||
$deleted = $this->serviceProvisioning->bulkDeleteServices($uuid, $data['ids']);
|
||||
|
||||
return response()->json(['error' => false, 'message' => "Đã xoá {$deleted} dịch vụ", 'data' => ['deleted' => $deleted]]);
|
||||
return response()->json(['error' => false, 'message' => "Đã gỡ {$deleted} dịch vụ khỏi khách hàng", 'data' => ['deleted' => $deleted]]);
|
||||
}
|
||||
|
||||
public function updateService(string $uuid, int $serviceId, Request $request): JsonResponse
|
||||
|
||||
Reference in New Issue
Block a user