fix som bogs

This commit is contained in:
mobbinoreii 2025-10-25 12:44:50 +00:00
parent ae9dcfb66a
commit c2e01945a8
4 changed files with 38 additions and 39 deletions

View File

@ -53,10 +53,19 @@ class OrderController extends Controller
$data['product'] = $product = $pro;
}
}
if (!$product) {
throw new UnprocessableEntityHttpException('محصول یافت نشد.');
}
if (!$product['active']) {
throw new UnprocessableEntityHttpException('در حال حاضر امکان ثبت سفارش وجود ندارد');
}
if ($data['amount'] > $product["order_limit_max"]) {
throw new UnprocessableEntityHttpException('سقف سفارش مجاز ' . $product["order_limit_max"] . ' گرم است.');
}
if ($data['amount'] < $product["order_limit_min"]) {
throw new UnprocessableEntityHttpException('کف سفارش ' . $product["order_limit_min"] . ' گرم است.');
}
if ($request['direction'] == 1) {
@ -68,9 +77,7 @@ class OrderController extends Controller
if ($data['mazaneh'] != $data['product']['sub_agent']['rate_buy_price']) {
throw new UnprocessableEntityHttpException('تغییر در مظنه !');
}
if (!$product['open_buy']) {
throw new UnprocessableEntityHttpException('درحال حاضر فروش محصول غیرفعال می باشد');
}
}
if ($request['direction'] == 2) {
$credit = $user->sell_credit + $user->gold_balance;

View File

@ -187,7 +187,8 @@ class DashboardAgentController extends Controller
public function delete_customer_setting($customer_setting_id)
{
// پیدا کردن تنظیم
$setting = CustomersSetting::find($customer_setting_id);
$setting = CustomersSetting::find($customer_setting_id);
if (!$setting) {
return response()->json([
@ -195,7 +196,13 @@ class DashboardAgentController extends Controller
'data' => null
], 404);
}
// security
if (auth()->id() != $setting->agent_id) {
return response()->json([
'message' => 'متاسفانه تنظیم موردنظر یافت نشد',
'data' => null
], 404);
}
// حذف تنظیم
$setting->delete();

View File

@ -2,7 +2,21 @@
"products": {
"order_limit_min": {"type":"int"},
"order_limit_max": {"type": "int"}
}
"order_limit_max": {"type": "int"},
"auto_order_limit_buy": {"type": "int"},
"auto_order_limit_sell": {"type": "int"}
},
"orders": {
"product_json": {"type":"text"}
},
"customers": {
"token_sms_limit": {"type":"varchar"},
"count_send_sms_time": {"type":"datetime"},
"count_send_sms": {"type":"varchar"},
"rial_balance": {"type":"varchar(255)"},
"gold_balance": {"type":"varchar"}
},
"push_subscriptions": {},
"push_notification_logs": {}
}

View File

@ -20,37 +20,6 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
Route::get('/productSSE/{token}', function ($token) {
try {
$decrypted = Crypt::decryptString($token);
[$id, $key] = explode('|', $decrypted);
if ($key !== 'mobin') {
return response()->json(['error' => 'Invalid key'], 403);
}
return response()->stream(function () use ($id) {
set_time_limit(0);
while (true) {
$products = json_decode(app(ProductController::class)->list_product($id)->getContent(), true);
echo "data: " . json_encode($products) . "\n\n";
ob_flush();
flush();
// Optional: break or simulate delay
sleep(1); // adjust delay if needed
}
}, 200, [
'Content-Type' => 'text/event-stream',
'Cache-Control' => 'no-cache',
'Connection' => 'keep-alive',
]);
} catch (\Exception $e) {
return response()->json(['error' => 'Decryption failed'], 400);
}
});
Route::post('/finServer',[\App\Http\Controllers\Customer\FinancialDocController::class, 'storeServer']);
@ -64,6 +33,7 @@ Route::middleware('auth:customer')->group(function () {
Route::put('/agent/customer_setting/{id}', [DashboardAgentController::class, 'creat_customer_setting_id']);
Route::get('/agent/customer_setting', [DashboardAgentController::class, 'get_customer_setting']);
Route::get('/agent/customer_setting/{id}', [DashboardAgentController::class, 'get_customer_setting_id']);
Route::delete('/agent/customer_setting/{id}', [DashboardAgentController::class, 'delete_customer_setting']);
//--------------agent
Route::get('/dashboard', [DashboardAgentController::class, 'index']);
Route::post('/customers', [DashboardAgentController::class, 'agent_customers']);
@ -71,6 +41,7 @@ Route::middleware('auth:customer')->group(function () {
Route::put('/customer_setting/{id}', [DashboardAgentController::class, 'creat_customer_setting_id']);
Route::get('/customer_setting', [DashboardAgentController::class, 'get_customer_setting']);
Route::get('/customer_setting/{id}', [DashboardAgentController::class, 'get_customer_setting_id']);
Route::delete('/customer_setting/{id}', [DashboardAgentController::class, 'delete_customer_setting']);
//--------------Customer
Route::get('/me', [CustomerController::class, 'me']);