This commit is contained in:
2026-06-06 22:06:53 +03:30
parent 6a92116535
commit 7acde1ce9d
7 changed files with 219 additions and 0 deletions
@@ -6,6 +6,7 @@ use App\DB\Te\TableEngine;
use App\Http\Controllers\Controller;
use App\Models\Price;
use App\Models\PriceCandle;
use App\Services\ZaarboxPriceService;
use Illuminate\Http\Request;
class PriceController extends Controller
@@ -46,6 +47,18 @@ class PriceController extends Controller
->export($prise);
return response()->json($prise);
}
public function chartPrices(ZaarboxPriceService $zaarboxPriceService)
{
return response()->json([
'code' => 0,
'message' => 'عملیات با موفقیت انجام شد.',
'data' => [
'prices' => $zaarboxPriceService->getAllPrices(),
],
]);
}
public function table(Request $request){
$records = Price::with(['user']);
TableEngine::create($records, $request->all())
@@ -349,6 +349,33 @@ class ProductController extends SuperController
unset($data['price_offset_percent']);
}
if (!Product::hasOrderLimitColumns()) {
unset($data['order_limit_enabled'], $data['min_order_cash'], $data['max_order_cash']);
} elseif (empty($data['order_limit_enabled'])) {
$data['order_limit_enabled'] = false;
$data['min_order_cash'] = null;
$data['max_order_cash'] = null;
} else {
$min = $data['min_order_cash'] ?? null;
$max = $data['max_order_cash'] ?? null;
$hasMin = $min !== null && $min !== '';
$hasMax = $max !== null && $max !== '';
if (!$hasMin && !$hasMax) {
throw new UnprocessableEntityHttpException(
'با فعال بودن محدودیت مبلغ سفارش، حداقل یکی از حداقل یا حداکثر مبلغ باید وارد شود'
);
}
if ($hasMin && $hasMax && (float) $min > (float) $max) {
throw new UnprocessableEntityHttpException('حداقل مبلغ نمی‌تواند بیشتر از حداکثر باشد');
}
$data['order_limit_enabled'] = true;
$data['min_order_cash'] = $hasMin ? (int) $min : null;
$data['max_order_cash'] = $hasMax ? (int) $max : null;
}
return $data;
}
}