feat: 實作 POS API 整合功能,包含商品與銷售訂單同步及韌性機制
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 57s

This commit is contained in:
2026-02-06 11:56:29 +08:00
parent 906b094c18
commit 3fd333085b
30 changed files with 1120 additions and 22 deletions

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Modules\Integration\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Modules\Inventory\Services\ProductService;
use Illuminate\Support\Facades\Log;
class ProductSyncController extends Controller
{
protected $productService;
public function __construct(ProductService $productService)
{
$this->productService = $productService;
}
public function upsert(Request $request)
{
$request->validate([
'external_pos_id' => 'required|string',
'name' => 'required|string',
'price' => 'nullable|numeric',
'sku' => 'nullable|string',
'barcode' => 'nullable|string',
'category' => 'nullable|string',
'unit' => 'nullable|string',
'updated_at' => 'nullable|date',
]);
try {
$product = $this->productService->upsertFromPos($request->all());
return response()->json([
'message' => 'Product synced successfully',
'data' => [
'id' => $product->id,
'external_pos_id' => $product->external_pos_id,
]
]);
} catch (\Exception $e) {
Log::error('Product Sync Failed', ['error' => $e->getMessage(), 'payload' => $request->all()]);
return response()->json(['message' => 'Sync failed'], 500);
}
}
}