This commit is contained in:
2026-06-12 19:49:53 +03:30
parent 11fb7272cb
commit 98e1fe969c
6 changed files with 310 additions and 9 deletions
@@ -71,6 +71,33 @@ class PriceController extends Controller
]);
}
/** لیست مرجع قیمت برای ادمین قدیمی (ghatreh_admin) — GET /admin/p */
public function methodPrices(ZaarboxPriceService $zaarboxPriceService)
{
$prices = $zaarboxPriceService->cachedPriceList(false);
if ($prices === null) {
return response()->json([]);
}
$items = collect($prices)
->map(function ($row) use ($zaarboxPriceService) {
$row = is_array($row) ? $row : (array) $row;
$normalized = $zaarboxPriceService->normalizeFeedRow($row);
return [
'id' => trim((string) ($row['id'] ?? $row['key'] ?? '')),
'key' => trim((string) ($row['key'] ?? '')),
'name' => trim((string) ($row['name'] ?? '')),
'price' => (int) round((float) ($normalized['price'] ?? 0)),
'profit' => (int) round((float) ($normalized['profit'] ?? 0)),
];
})
->filter(fn (array $row) => $row['name'] !== '')
->values();
return response()->json($items);
}
public function table(Request $request){
$records = Price::with(['user']);
TableEngine::create($records, $request->all())