[REFACTOR] 統一訂單同步 API 錯誤回應與修正 Linter 警告

This commit is contained in:
2026-03-19 14:07:32 +08:00
parent e3ceedc579
commit 0b4aeacb55
15 changed files with 1173 additions and 108 deletions

View File

@@ -21,10 +21,13 @@ class InventorySyncController extends Controller
* @param string $warehouseCode
* @return JsonResponse
*/
public function show(string $warehouseCode): JsonResponse
public function show(\Illuminate\Http\Request $request, string $warehouseCode): JsonResponse
{
// 透過 Service 調用跨模組庫存查詢功能
$inventoryData = $this->inventoryService->getPosInventoryByWarehouseCode($warehouseCode);
// 透過 Service 調用跨模組庫存查詢功能,傳入篩選條件
$inventoryData = $this->inventoryService->getPosInventoryByWarehouseCode(
$warehouseCode,
$request->only(['product_id', 'barcode', 'code', 'external_pos_id'])
);
// 若回傳 null表示尋無此倉庫代碼
if (is_null($inventoryData)) {
@@ -40,9 +43,18 @@ class InventorySyncController extends Controller
'warehouse_code' => $warehouseCode,
'data' => $inventoryData->map(function ($item) {
return [
'product_id' => $item->product_id,
'external_pos_id' => $item->external_pos_id,
'product_code' => $item->product_code,
'product_name' => $item->product_name,
'barcode' => $item->barcode,
'category_name' => $item->category_name ?? '未分類',
'unit_name' => $item->unit_name ?? '個',
'price' => (float) $item->price,
'brand' => $item->brand,
'specification' => $item->specification,
'batch_number' => $item->batch_number,
'expiry_date' => $item->expiry_date,
'quantity' => (float) $item->total_quantity,
];
})