diff --git a/app/Http/Controllers/Admin/DashboardController.php b/app/Http/Controllers/Admin/DashboardController.php index 7cb3904..f4fbe0f 100644 --- a/app/Http/Controllers/Admin/DashboardController.php +++ b/app/Http/Controllers/Admin/DashboardController.php @@ -7,8 +7,11 @@ use App\Models\Cnt; use App\Models\Customer; use App\Models\Order; use App\Models\Price; +use App\Models\Product; use App\Models\TransactionsAdmin; use App\Models\Withdraw; +use App\Services\ConfigService; +use App\Services\EtehadiePriceService; use Carbon\Carbon; use Hekmatinasser\Verta\Verta; use Illuminate\Http\Request; @@ -17,7 +20,8 @@ use Rooyesh\Wallet\models\Wallet; class DashboardController extends Controller { - public function dashboardMaster(){ + public function dashboardMaster(Request $request) + { $tallaPrice = Price::latest()->first(); // $talla->update_date = Verta::instance(Carbon::parse($talla->updated_at))->format('Y/n/j-H:i'); $new_customer_major = Customer::where('type',1)->whereDate('created_at','<=',now())->whereDate('created_at','>=',now()->subMonths(3)) @@ -56,6 +60,49 @@ class DashboardController extends Controller $transactions_admins = TransactionsAdmin::with(['withdraw','order',"user",'customerTo','customer'])->get(); + $startDate = $request->startDateProduct + ? Carbon::parse($request->startDateProduct)->startOfDay() + : now()->subMonth()->startOfDay(); + $endDate = $request->endDateProduct + ? Carbon::parse($request->endDateProduct)->endOfDay() + : now()->endOfDay(); + + $products_report = Product::with(['limitedTransactions' => function ($query) use ($startDate, $endDate) { + $query->whereBetween('created_at', [$startDate, $endDate]); + }]) + ->whereHas('limitedTransactions', function ($query) use ($startDate, $endDate) { + $query->whereBetween('created_at', [$startDate, $endDate]); + }) + ->get(); + + $products_report->each(function ($product) { + $product->transaction_sum_gold_buy = $product->limitedTransactions + ->where('gold', '>', 0) + ->sum('gold'); + $product->total_negative_gold_sell = $product->limitedTransactions + ->where('gold', '<', 0) + ->sum('gold'); + $product->total_gold = $product->limitedTransactions->sum('gold'); + }); + + $gramPrice = (int) ($tallaPrice->price ?? 0); + $FPrices = []; + if (app(ConfigService::class)->usesEtehadiePricing()) { + $etehadie = app(EtehadiePriceService::class)->fetchMainGramPrice(); + if (($etehadie['price'] ?? 0) > 0) { + $gramPrice = (int) round($etehadie['price'] / 10); + $FPrices[] = [ + 'id' => 'etehadie', + 'name' => 'اتحادیه', + 'price' => $gramPrice, + 'profit' => 0, + ]; + } + } + $FPrices[] = ['id' => '1', 'name' => 'افجو', 'price' => $gramPrice, 'profit' => 0]; + + $gatewayRow = Cnt::where('key', 'is_gateway_open')->first(); + return response()->json([ 'GT_all_customers'=>$GT_all_customers, 'GT_no_login_customers'=>$GT_no_login_customers, @@ -65,7 +112,12 @@ class DashboardController extends Controller 'GT_active_customers_data'=>$GT_active_customers_data, 'GT_deActive_customers'=>$GT_all_customers-$GT_active_customers, 'GT_transactions_admins'=>$transactions_admins, - 'price'=>$tallaPrice->price, + 'GT_products_report' => $products_report, + 'update_date' => now()->timezone('Asia/Tehran')->format('Y-m-d H:i:s'), + 'pricem' => round($gramPrice * 4.331802 / 10000) * 10000, + 'prices' => $FPrices, + 'is_gateway_open' => $gatewayRow && (string) $gatewayRow->value === '1', + 'price'=>$tallaPrice?->price ?? $gramPrice, 'new_customer_major'=>$new_customer_major, 'new_customer_single'=>$new_customer_single, 'all_customer_major'=>$all_customer_major, @@ -80,6 +132,23 @@ class DashboardController extends Controller ]); } + + public function gateway() + { + $cnt = Cnt::where('key', 'is_gateway_open')->first(); + if (!$cnt) { + $cnt = Cnt::create([ + 'key' => 'is_gateway_open', + 'value' => '1', + ]); + } else { + $cnt->value = ((string) $cnt->value === '0') ? '1' : '0'; + $cnt->save(); + } + + return $cnt; + } + public function getBalance(Request $request) { $startDate = Carbon::parse($request->startDate)->startOfDay(); @@ -88,9 +157,15 @@ class DashboardController extends Controller $response["liman"]=[]; $response["kalhor"]=[]; + $excludeCustomerId = (int) app(ConfigService::class)->getInt('balance_report_exclude_customer_id', 4); + $response["pay_at_update"] = Order::whereNull('pay_at')->update(['pay_at' => DB::raw('created_at')]); //liman - $response["liman"]["orders"] = Order::with(['transactions.product'])->where('customer_id', '!=', 4)->where('sts', 2)->whereBetween('pay_at', [$startDate, $endDate])->get(); + $response["liman"]["orders"] = Order::with(['transactions.product', 'customer']) + ->where('customer_id', '!=', $excludeCustomerId) + ->where('sts', 2) + ->whereBetween('pay_at', [$startDate, $endDate]) + ->get(); $response["liman"]["balance"]["gold"] = 0; $response["liman"]["balance"]["cash"] = 0; $response["liman"]["balance_abs"]["gold"] = 0; diff --git a/app/Http/Controllers/Admin/ProductController.php b/app/Http/Controllers/Admin/ProductController.php index 5a285b7..fb79ef3 100644 --- a/app/Http/Controllers/Admin/ProductController.php +++ b/app/Http/Controllers/Admin/ProductController.php @@ -151,8 +151,6 @@ class ProductController extends SuperController public function getPrice() { -// $RPrices = Http::get('https://pricing.liman.gold/pricingApi', [])->json(); -// $RPrices = Http::get('https://pricing.liman.gold/pricingApi', [])->json(); // $RPrices =Http::timeout(40)->get('http://212.23.201.173:8381/price_list', [])->json(); $RPrices = Http::timeout(40)->get('http://109.122.246.48:4949/api/free', [])->json(); diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 24ebdbf..975b67a 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -2,13 +2,12 @@ namespace App\Http\Controllers\Auth; -use App\Http\Controllers\Admin\TahesabController; use App\Http\Controllers\Controller; use App\Models\Cnt; use App\Models\Customer; use App\Models\Setting; -use App\Models\TahesabCustomer; use App\Models\User; +use App\Services\ConfigService; use Carbon\Carbon; use Illuminate\Http\Request; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; @@ -85,7 +84,6 @@ class AuthController extends Controller $user->token_sms = $rand; $user->save(); -// $this->SendMessage($mobile, 'رمز عبور یکبار مصرف شما جهت ورود به اپلیکشن ' . $this->ConfigService('name_fa') . ' ' . $rand . ' می باشد' . PHP_EOL . "@$subDomain" . " #" . $r and,true ,"sms"); $this->SendMessage($mobile, 'رمز عبور یکبار مصرف شما جهت ورود به اپلیکشن ' . $this->Config('name_fa') . ' ' . $rand . ' می باشد' . PHP_EOL . "@$subDomain" . " #" . $rand,true ,"sms"); return $user->id; @@ -120,17 +118,20 @@ class AuthController extends Controller public function register(Request $request) { + $cfg = app(ConfigService::class); + $register = Setting::where('key', 'open_register')->first(); - if($register->is_active == 0){ + if ($register && (int) $register->is_active === 0) { throw new UnprocessableEntityHttpException('امکان ثبت نام وجود ندارد.'); } + $data = $request->all(); $data['type'] = 2; if (isset($data['referral_id'])) { $data['referral_to_id'] = $data['referral_id']; } $data['name'] = $data['fname'] . ' ' . $data['lname']; - $data['active'] = Setting::where('key', 'auto_active_customer')->first()->value === 'true'; + $data['active'] = $cfg->getBool('auto_active_customer', false); if (isset($data['type']) && $data['type'] == 2) { $data['active'] = true; } @@ -138,40 +139,74 @@ class AuthController extends Controller if (!is_null($cnt)) { $data['gram'] = $cnt->value; } - // Generate unique referral ID + do { $uniqueId = substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), 0, 4); } while (Customer::where('referral_id', $uniqueId)->exists()); $data['referral_id'] = $uniqueId; - // Handle referrer + if (isset($data['n_code']) && $cfg->getBool('register_jibit_verify', false)) { + $existing = Customer::where('n_code', $data['n_code'])->first(); + if (!empty($existing)) { + return response()->json(['message' => 'کد ملی تکراری است'], 422); + } + $response = $this->jibitNcode($data['n_code'], $data['mobile']); + if (isset($response['matched']) && $response['matched'] == true) { + $data['is_legal'] = 1; + } + } + + $referrer = null; if (isset($data['referral_to_id'])) { $referrer = Customer::where('referral_id', $data['referral_to_id'])->first(); if ($referrer) { -// $messageRef = "{$data['name']} با کد معرف شما ثبت نام کرد.\nدر صورت احراز او پاداش می‌گیرید.\n" . $this->ConfigService('name_fa'); -// $this->Send($referrer->mobile, $messageRef); - $AdminMessage = "با معرفی {$referrer->name}، کاربر {$data['name']} در اپ {$this->Config('name_fa')} ثبت نام کرده و منتظر تایید شماست."; - User::where('send_sms', 1)->get()->each(function ($admin) use ($AdminMessage, $data,) { - $this->send($admin->mobile, $AdminMessage); - }); + if ($cfg->getBool('register_referral_sms_to_referrer', false)) { + $messageRef = "{$data['name']} با کد معرف شما ثبت نام کرد.\nبا اولین خرید او پاداش دریافت میکنید.\n" . $this->Config('name_fa'); + $this->Send($referrer->mobile, $messageRef); + } else { + $adminMessage = "با معرفی {$referrer->name}، کاربر {$data['name']} در اپ {$this->Config('name_fa')} ثبت نام کرده و منتظر تایید شماست."; + User::where('send_sms', 1)->get()->each(function ($admin) use ($adminMessage) { + $this->send($admin->mobile, $adminMessage); + }); + } } else { - return response()->json(["message" => "کد نامعتبره"], 422); + return response()->json(['message' => 'کد نامعتبره'], 422); } } else { - if ($this->Config('referral_id') == "required") { - return response()->json(["message" => "کد معرف اجباریست"], 422); + if ( + $this->Config('referral_id') == 'required' + || $cfg->getBool('is_requaire_referral', false) + ) { + return response()->json(['message' => 'کد معرف اجباریست'], 422); } } + $data['active'] = true; - // Create customer + $customer = Customer::create($data); -// $tah = new TahesabController(); -// return $tah->store([ -// 'customer_id' => $customer->id, -// ]); + if ($referrer) { + $referrer->increment('total_referrals'); + } - $message = "{$data['name']} عزیز، اکانت شما در پلتفرم {$this->Config('name_fa')} ایجاد شد.\nنام کاربری: {$data['mobile']}\n\nورود به نرم افزار:\n{$this->Config('app_url')}"; + if ($cfg->getBool('register_jibit_verify', false) && isset($customer->is_legal)) { + $message = $customer->is_legal === 1 + ? 'احرازهویت برای ' . $customer->name . ' با کد ' . $customer->id . ' انجام شد.' + : 'احرازهویت برای ' . $customer->name . ' با کد ' . $customer->id . ' تأیید نشد لطفا از پنل ادمین اقدام فرمایید.'; + User::where('send_sms', 1)->get()->each(function ($admin) use ($message) { + $this->SendMessage($admin->mobile, $message); + }); + } + + $message = "{$data['name']} عزیز، اکانت شما در پلتفرم {$this->Config('name_fa')} ایجاد شد."; + if ($cfg->getBool('register_referral_bonus_message', false)) { + $bonus = Setting::where('is_active', 1)->where('key', 'referral_bonus_amount')->first(); + if ($bonus) { + $bonusValues = json_decode($bonus->value, true); + $message .= "\nپس از اولین خرید مقدار، " . number_format((int) ($bonusValues[0]['customer'] ?? 0)) . ' ریال پاداش دریافت خواهید کرد.'; + } + } + $message .= "\nنام کاربری: {$data['mobile']}\nورود به نرم افزار: {$this->Config('app_url')}"; $this->Send($data['mobile'], $message); return response()->json($customer); diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 48e8b5b..3709572 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -303,6 +303,46 @@ class Controller extends BaseController return $amount > 0 && $amount !== 1.0; } + public function jibitNcode($nationalCode, $mobile) + { + $counter = Cnt::where('key', 'jibit_counter')->first(); + if (empty($counter)) { + $counter = new Cnt(); + $counter->key = 'jibit_counter'; + $counter->value = 0; + $counter->save(); + } + + $apiData['refresh'] = Http::withoutVerifying()->withToken(Storage::get('refreshTokenGibit')) + ->post('https://napi.jibit.ir/ide/v1/tokens/generate', [ + 'apiKey' => 'J5WxrPxPOg', + 'secretKey' => '7dgeE70xQXsQL7r36j3wif6X9', + ])->json(); + Storage::put('accessTokenGibit', $apiData['refresh']['accessToken']); + + $response = Http::withoutVerifying()->withToken(Storage::get('accessTokenGibit')) + ->get("https://napi.jibit.ir/ide/v1/services/matching?mobileNumber=$mobile&nationalCode=$nationalCode") + ->json(); + + if ((isset($response['code'])) && $response['code'] == 'forbidden') { + $refreshToken = Http::withoutVerifying()->withToken(Storage::get('refreshTokenGibit')) + ->post('https://napi.jibit.ir/ide/v1/tokens/generate', [ + 'apiKey' => 'J5WxrPxPOg', + 'secretKey' => '7dgeE70xQXsQL7r36j3wif6X9', + ])->json(); + Storage::put('accessTokenGibit', $refreshToken['accessToken']); + Storage::put('refreshTokenGibit', $refreshToken['refreshToken']); + $response = Http::withoutVerifying()->withToken(Storage::get('accessTokenGibit')) + ->get("https://napi.jibit.ir/ide/v1/services/matching?mobileNumber=$mobile&nationalCode=$nationalCode") + ->json(); + } + + $counter->value = (int) $counter->value + 1; + $counter->save(); + + return $response; + } + public static function jibit($method, $p1 = null, $p2 = null, $p3 = null) { $counter = Cnt::where('key', 'jibit_counter')->first(); diff --git a/app/Http/Controllers/Customer/OrderController.php b/app/Http/Controllers/Customer/OrderController.php index 9b16371..d3a89b0 100644 --- a/app/Http/Controllers/Customer/OrderController.php +++ b/app/Http/Controllers/Customer/OrderController.php @@ -5,8 +5,10 @@ namespace App\Http\Controllers\Customer; use App\DB\Te\TableEngine; use App\Http\Controllers\Controller; use App\Jobs\CheckOrder; +use App\Models\Customer; use App\Models\Order; use App\Models\Price; +use App\Models\Setting; use App\Models\User; use Carbon\Carbon; use Illuminate\Http\Request; @@ -111,6 +113,38 @@ class OrderController extends Controller $this->Send(auth('customer')->user()->mobile,$message); return response()->json($order); } + + public function profit_gold() + { + $customer = Customer::with(['wallet', 'orders']) + ->findOrFail(auth('customer')->id()); + + $lastPrice = Price::latest('created_at')->value('price') ?? 0; + $goldAmount = $customer->wallet->first()->gold ?? 0; + $orders = $customer->orders; + + $averagePrice = $orders->avg('price') ?? 0; + $averageFee = $orders->avg('fee') ?? 0; + $totalProfit = $orders->sum(fn ($order) => $order->direction === 1 + ? $order->profit_per_moment + : -$order->profit_per_moment); + + $feeSingle = (float) (Setting::where('key', 'fee_single')->value('value') ?? config('fee.single', 0)); + $currentPriceWithFee = $lastPrice + $feeSingle; + $averagePriceWithFee = $averagePrice + $averageFee; + + return response()->json([ + 'current_portfolio_value' => $currentPriceWithFee * $goldAmount, + 'average_portfolio_value' => $averagePriceWithFee * $goldAmount, + 'unrealized_profit' => ($currentPriceWithFee - $averagePriceWithFee) * $goldAmount, + 'average_price' => $averagePrice, + 'average_fee' => $averageFee, + 'total_profit' => $totalProfit, + 'gold_holdings' => $goldAmount, + 'customer' => $customer->makeHidden(['password', 'token_sms']), + ]); + } + public function table(Request $request){ $records = Order::where('customer_id',auth('customer')->id()) ->where('type',1); diff --git a/app/Http/Controllers/Customer/WalletController.php b/app/Http/Controllers/Customer/WalletController.php index b8dce38..4c83dc8 100644 --- a/app/Http/Controllers/Customer/WalletController.php +++ b/app/Http/Controllers/Customer/WalletController.php @@ -226,27 +226,6 @@ class WalletController extends Controller if (Customer::where("id", $customer->id)->first()->token_sms != $request->otp) { return response()->json(['message' => 'رمز دوم اشتباه میباشد'], 422); } -/* try { - $response = Http::withHeaders([ - 'Authorization' => 'Bearer ' . $this->ConfigService('liman_token') - ])->post('https://limangold.ir/kernel/customer/fin', [ - 'receive_bank_shaba' => $bCart->shaba_number, - 'receive_bank_card' => $bCart->cart_number, - 'receive_name' => $customer->name, - 'receive_account_number' => $bCart->account_number, - 'description' => $this->ConfigService('name_fa') . ' | ' . $customer->mobile . ' | ' . $customer->name . ' | ' . $Withdraw->id, - 'amount' => '1000' - ])->json(); - if (isset($response['id'])) { - $Withdraw->note = $response['id']; - $Withdraw->save(); - $message = "کاربر $userName با شماره موبایل $userMobile درخواست برداشت مبلغ " . number_format($withdrawAmount) . " ثبت کرد و به لیمان منتقل شد. با تشکر، $companyName"; - } else { - $message = "کاربر $userName با شماره موبایل $userMobile درخواست برداشت مبلغ " . number_format($withdrawAmount) . " ریال را دارد. با تشکر، $companyName"; - } - } catch (Exception $e) { - $message = "کاربر $userName با شماره موبایل $userMobile درخواست برداشت مبلغ " . number_format($withdrawAmount) . " ریال را دارد. با تشکر، $companyName"; - }*/ } User::where('send_sms', 1)->get()->each(function ($admin) use ($message) { $this->Send($admin->mobile, $message . ' ' . now()->format('H:i:s')); diff --git a/app/Http/Controllers/Single/SingleOrderController.php b/app/Http/Controllers/Single/SingleOrderController.php index d662af4..38cc5c6 100644 --- a/app/Http/Controllers/Single/SingleOrderController.php +++ b/app/Http/Controllers/Single/SingleOrderController.php @@ -42,7 +42,7 @@ class SingleOrderController extends Controller return filter_var($value, FILTER_VALIDATE_BOOLEAN); }; - if ($toBool($config->Config('montzar_price'))) { + if ($config->usesMontzarPricing()) { $montzar_closed = $toBool($config->Config('montzar_closed')); $montzar_buy = !$toBool($config->Config('montzar_open_buy')) && (int) $data['direction'] === 1; $montzar_sell = !$toBool($config->Config('montzar_open_sell')) && (int) $data['direction'] === 2; @@ -507,7 +507,7 @@ class SingleOrderController extends Controller private function sendProviderOrder(array &$data, $wallet_interface, int $direction) { - if ($this->Config('montzar_price') == "true") { + if (app(\App\Services\ConfigService::class)->usesMontzarPricing()) { try { return app(MontzarService::class)->sendOrder($data); } catch (UnprocessableEntityHttpException $e) { diff --git a/app/Http/Controllers/Site/ReportController.php b/app/Http/Controllers/Site/ReportController.php index 33811a2..ce1d19c 100644 --- a/app/Http/Controllers/Site/ReportController.php +++ b/app/Http/Controllers/Site/ReportController.php @@ -10,6 +10,7 @@ use App\Models\Setting; use App\Models\ConfigStatic; use App\Models\Customer; use App\Services\MontzarService; +use App\Services\EtehadiePriceService; use App\Models\Price; use App\Models\PriceCandle; use App\Models\PriceTrigger; @@ -140,6 +141,7 @@ class ReportController extends Controller $closed = false; $montzar_price = 0; + $etehadie_teh = 0; $tgn = 0; $pr_price = 0; @@ -165,11 +167,14 @@ class ReportController extends Controller 'main_product' => 0, 'taban_gohar' => 0, 'montzar' => 0, + 'etehadie_teh' => 0, 'closed' => true, 'time' => now(), ]); }; + $priceProvider = $config->priceProvider(); + /* |-------------------------------------------------------------------------- | بستن قیمت طبق منطق قبلی @@ -222,14 +227,22 @@ class ReportController extends Controller $diff_buy = (float) $settingsMap->get('buy_fee', $difference); $diff_sell = (float) $settingsMap->get('sell_fee', $difference); - $montzar_price_enabled = $toBool($config->Config('montzar_price')); + /* + |-------------------------------------------------------------------------- + | اتحادیه (گلد علی / refPricer) — فقط وقتی price_provider=etehadie + |-------------------------------------------------------------------------- + */ + if ($priceProvider === 'etehadie' && !$closed) { + $etehadie = app(EtehadiePriceService::class)->fetchMainGramPrice(); + $etehadie_teh = (int) ($etehadie['price'] ?? 0); + } /* |-------------------------------------------------------------------------- - | Montzar - اولویت اول + | Montzar — فقط وقتی price_provider=montzar |-------------------------------------------------------------------------- */ - if ($montzar_price_enabled && !$closed) { + if ($priceProvider === 'montzar' && !$closed) { try { $montzarBaseUrl = rtrim($config->Config('montzar_base_url') ?: 'https://montpar.ir', '/'); $montzarProductId = (int) ($config->Config('montzar_product_id') ?: 25); @@ -347,18 +360,19 @@ class ReportController extends Controller /* |-------------------------------------------------------------------------- - | انتخاب قیمت اصلی - | اولویت: - | Montzar -> Taban Gohar -> Main Product + | انتخاب قیمت اصلی (همان price_provider) |-------------------------------------------------------------------------- */ - if ($montzar_price_enabled && ($montzar_price ?? 0) !== 0 && !$closed) { + if ($priceProvider === 'etehadie' && $etehadie_teh > 0 && !$closed) { + $priceValue = (int) $etehadie_teh; + $priceSource = 'etehadie'; + } elseif ($priceProvider === 'montzar' && ($montzar_price ?? 0) !== 0 && !$closed) { $priceValue = (int) $montzar_price; $priceSource = 'montzar'; - } elseif ($toBool($taban_gohar_price) && ($tgn ?? 0) !== 0 && !$closed) { + } elseif ($priceProvider === 'taban_gohar' && $toBool($taban_gohar_price) && ($tgn ?? 0) !== 0 && !$closed) { $priceValue = $tgn; $priceSource = 'taban_gohar'; - } elseif ($toBool($main_product_price) && ($pr_price ?? 0) !== 0 && !$closed) { + } elseif ($priceProvider === 'main_product' && $toBool($main_product_price) && ($pr_price ?? 0) !== 0 && !$closed) { $priceValue = $pr_price; $priceSource = 'main_product'; } else { @@ -376,6 +390,7 @@ class ReportController extends Controller 'main_product' => $pr_price ?? 0, 'taban_gohar' => $tgn ?? 0, 'montzar' => $montzar_price ?? 0, + 'etehadie_teh' => $etehadie_teh ?? 0, 'closed' => true, 'time' => now(), ]); @@ -392,6 +407,7 @@ class ReportController extends Controller 'main_product' => $pr_price ?? 0, 'taban_gohar' => $tgn ?? 0, 'montzar' => $montzar_price ?? 0, + 'etehadie_teh' => $etehadie_teh ?? 0, 'closed' => true, 'time' => now(), ]); @@ -488,6 +504,7 @@ class ReportController extends Controller 'main_product' => $pr_price ?? 0, 'taban_gohar' => $tgn ?? 0, 'montzar' => $montzar_price ?? 0, + 'etehadie_teh' => $etehadie_teh ?? 0, 'closed' => false, 'time' => now(), ]); diff --git a/app/Http/Controllers/Site/RequestsController.php b/app/Http/Controllers/Site/RequestsController.php new file mode 100644 index 0000000..38b7b93 --- /dev/null +++ b/app/Http/Controllers/Site/RequestsController.php @@ -0,0 +1,210 @@ +all(); + + $transactionType = $data['method'] == 'cash' ? 'ریالی' : 'طلایی'; + + $customer_id = Customer::where('mobile', $request->mobile)->first()?->id; + if (!$customer_id) { + throw new UnprocessableEntityHttpException('کاربری با این شماره موبایل یافت نشد.'); + } + + $data['customer_id'] = $customer_id; + $latestPrice = Price::latest()->first(); + $data['price'] = $latestPrice->price; + $data['price_id'] = $latestPrice->id; + $data['difference'] = 0; + $data['service_charge_percentage'] = 0; + $data['pay_at'] = now(); + $data['sts'] = 2; + $data['type'] = 2; + $data['payment_sts'] = 4; + $data['price_original'] = $data['price']; + $data['total_price_original'] = $data['amount'] * ($data['price_original'] ?? 0); + $data['payment_remind'] = 0; + $data['fee'] = $data['difference']; + $data['total_fee'] = $data['amount'] * $data['difference']; + + $myCustomer = Customer::find($customer_id); + $wallet_interface = new WalletInterface($customer_id, 2); + $wallet = Wallet::where('owner', $customer_id)->whereNull('fund_id')->first(); + + $response = []; + + // === اینجا قبلاً return بود و همه چیز قطع می‌شد === + if ($data['method'] == 'cash') { + $response['cash'] = $this->processCashTransaction($data, $wallet, $wallet_interface, $myCustomer); + } else if ($data['method'] == 'gold') { + $response['gold'] = $this->processGoldTransaction($data, $wallet, $wallet_interface, $myCustomer); + } + + $response['Notifications'] = $this->sendTransactionNotifications($data, $transactionType); + + return response()->json($response); + } + public function getWallet(Request $request) + { + $customer_id = Customer::where('mobile', $request->mobile)->first()?->id; + if($customer_id && $customer_id !== null){ + $wallet = Wallet::select(['owner','gold','cash'])->where('owner',$customer_id)->first(); + }else{ + throw new UnprocessableEntityHttpException('کاربری با این شماره موبایل یافت نشد.'); + } + return $wallet; + + } + + + + + + + + //for orders + private function processCashTransaction(&$data, $wallet, $wallet_interface,$myCustomer) + { + $response = []; +// $data['price'] += $data['difference']; + $data['total_price'] = $data['amount'] /** $data['price']*/; + $data['payment_amount'] = $data['total_price']; + +// $data['service_charge'] = $data['service_charge_percentage'] * $data['amount']; +// $data['service_charge_price'] = $data['service_charge'] * $data['price_original']; +// $data['amount'] -= $data['service_charge']; + if ($wallet->cash < $data['payment_amount']) { + throw new UnprocessableEntityHttpException('موجودی شما کمتر از میزان سفارش است'); + } + +// $data['order'] = $order = Order::create($data); + new TransactionInterface($wallet_interface, [ + "cash" => $data['payment_amount'], + "gold" => 0, + 'expire_at' => now(), + 'active' => true, +// 'order_id' => $order->id, + 'start_at' => now(), + ], 4, true, false); + $response['1'] = 2; + + return $response; + } + private function processGoldTransaction(&$data, $wallet, $wallet_interface,$myCustomer) + { +// if ($data['amount'] < 0.06){ +// throw new UnprocessableEntityHttpException('کمترین مقدار مجاز برای فروش 60 سوت است.'); +// +// } + +// $data['price'] -= $data['difference']; + $montifyCompanyName = $this->Config('montify_name'); + $data['total_price'] = $data['amount'] * $data['price']; + $data['payment_amount'] = $data['total_price']; + + $data['service_charge'] = $data['service_charge_percentage'] * $data['amount']; + $data['service_charge_price'] = $data['service_charge'] * $data['price_original']; + $data['total_price'] = $data['amount'] * $data['price'] -$data['service_charge_price']; + $data['payment_amount'] = $data['total_price']; + $data['payment_amount'] -= $data['service_charge_price']; + + if ($wallet->gold < $data['amount']) { + throw new UnprocessableEntityHttpException('موجودی شما کمتر از میزان سفارش است'); + } + $data['direction'] = 2; + $data['description'] = "فروش {$data['amount']} گرم طلا برای $montifyCompanyName توسط کاربر {$myCustomer->name} با شماره موبایل {$myCustomer->mobile}"; + $data['order'] = $order = Order::create($data); + new TransactionInterface($wallet_interface, [ + "gold" => $data['amount'], + "cash" => 0, + 'expire_at' => now(), + 'active' => true, + 'order_id' => $order->id + ], 10, false, true); + + } + + + private function sendTransactionNotifications(array $data, string $transactionType) + { + $customer = Customer::findOrFail($data['customer_id']); + $companyName = $this->Config('name_fa'); + $montifyCompanyName = $this->Config('montify_name'); + if($data['method'] == 'cash') { + $message = "کاربر {$customer->name} با شماره موبایل {$customer->mobile} اقدام به برداشت موجودی از طرف $montifyCompanyName به مقدار " . + "{$data['amount']} ریال " . " کرد. با تشکر، $companyName"; + }elseif ($data['method'] == 'gold') { + $message = "کاربر {$customer->name} با شماره موبایل {$customer->mobile} اقدام به $transactionType طلا به مقدار " . + "{$data['amount']} گرم به مبلغ " . number_format($data['total_price']) . + " ریال کرد. با تشکر، $companyName"; + } + User::where('send_sms', 1)->get()->each(function ($admin) use ($message, $data, $transactionType, $companyName) { + $this->send($admin->mobile, $message); + }); +// User::whereNotNull('telegram')->get()->each(function ($admin) use ($message, $data, $transactionType, $companyName) { +// $this->SendTelegram($admin->telegram, $message); +// }); +// $messageold = "کاربر {$customer->name} با شماره موبایل {$customer->mobile} اقدام به $transactionType طلا به مقدار " . +// "{$data['amount']} گرم به مبلغ " . number_format($data['total_price']) . +// " ریال کرد. با تشکر، $companyName"; +// $azOrTa = $data['direction'] == 1 ? 'از' : 'به'; +// $messageExam = " +// {$transactionType} قلک طلا $azOrTa شما +// {$data['amount']} گرم +// در مظنه +// " . number_format($data['price_original']) . " ریال"; +// +// +//// User::whereNotNull('telegram')->get()->each(function ($admin) use ($messageExam) { +//// $this->SendTelegram($admin->telegram, $messageExam); +//// }); +// User::where('send_sms', 1)->get()->each(function ($admin) use ($messageExam) { +// $this->send($admin->mobile, $messageExam); +// }); + + $wallet = Wallet::where('owner', $data['customer_id'])->whereNull('fund_id')->first(); + if($data['method'] == 'cash') { + $pricePerGram = $data['total_price']; + }elseif ($data['method'] == 'gold') { + $pricePerGram = $data['total_price'] / $data['amount']; + } + + if($data['method'] == 'cash') { + $customerMessage = "$companyName\nبرداشت ریالی \nمبلغ: {$data['amount']}\n" . + "\nموجودی طلایی: {$wallet->gold}\n" . + "مانده ریالی: " . number_format($wallet->cash) . "\n" . $this->Config('app_url'); + }elseif ($data['method'] == 'gold') { + $customerMessage = "$companyName\nبرداشت طلایی \nگرم: {$data['amount']}\nقیمت گرم: " . number_format($pricePerGram) . + "\nمبلغ کل: " . number_format($data['total_price']) . "\nموجودی طلایی: {$wallet->gold}\n" . + "مانده ریالی: " . number_format($wallet->cash) . "\n" . $this->Config('app_url'); + } + + +// $customerMessage = "$companyName\n$transactionType آبشده\nگرم: {$data['amount']}\nقیمت گرم: " . number_format($pricePerGram) . +// "\nمبلغ کل: " . number_format($data['total_price']) . "\n\nموجودی طلایی: {$wallet->gold}\n" . +// "مانده ریالی: " . number_format($wallet->cash) . "\n" . $this->Config('app_url'); + + // ارسال SMS به مشتری + $this->send($customer->mobile, $customerMessage); + } + +} diff --git a/app/Http/Controllers/pay/paypingController.php b/app/Http/Controllers/pay/paypingController.php index 1f4dd40..ae2855d 100644 --- a/app/Http/Controllers/pay/paypingController.php +++ b/app/Http/Controllers/pay/paypingController.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Controller; use App\Models\Customer; use App\Models\User; use App\Models\Withdraw; +use App\Services\ConfigService; use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; use Rooyesh\Wallet\interfaces\TransactionInterface; @@ -13,167 +14,253 @@ use Rooyesh\Wallet\interfaces\WalletInterface; class paypingController extends Controller { + private function cfg(): ConfigService + { + return app(ConfigService::class); + } + + private function paypingHeaders(): array + { + return [ + 'payping' => $this->cfg()->getString( + 'payping_header_secret', + (string) config('payment.payping_header_secret', '') + ), + ]; + } + + private function paypingStartUrl(): string + { + return $this->cfg()->getString( + 'payping_start_url', + (string) config('payment.payping_start_url', 'https://payping.limangold.ir/payment/start') + ); + } + + private function paypingVerifyUrl(): string + { + return $this->cfg()->getString( + 'payping_verify_url', + (string) config('payment.payping_verify_url', 'https://payping.limangold.ir/payment/verify') + ); + } + + /** اگر payping_gateway_items پر باشد (با کاما)، مثل گلد علی بین itemها می‌چرخد */ + private function resolveGatewayItem(): string + { + $list = $this->cfg()->getString('payping_gateway_items', ''); + if ($list === '') { + return $this->cfg()->getString('payping_gateway_item', (string) config('payment.payping_gateway_item', 'gp1Q')); + } + + $items = array_values(array_filter(array_map('trim', explode(',', $list)))); + if ($items === []) { + return 'gp1Q'; + } + + $index = (int) cache()->get('payping_gateway_item_index', 0); + if ($index >= count($items)) { + $index = 0; + } + $item = $items[$index]; + cache()->put('payping_gateway_item_index', $index + 1); + + return $item; + } + public function startTransation(Request $request) { $user = auth()->user(); $finalPriseP = $request->value; - if ($user->id ==4){ - $finalPriseP =10700; + if ($user->id == 4) { + $finalPriseP = 10700; } + + if ($this->cfg()->getBool('payping_round_toman', (bool) config('payment.payping_round_toman', false))) { + $finalPriseP = (int) (ceil($finalPriseP / 10) * 10); + } + $Withdraw = Withdraw::create([ 'customer_id' => auth('customer')->id(), - "cash" => $finalPriseP, - "note" => "واریز ریالی", + 'cash' => $finalPriseP, + 'note' => 'واریز ریالی', 'sts' => 1, ]); - try { - $response = Http::withHeaders([ - 'payping' => '@XOKcNveJ$wpqYy%rdpb78oBh31Aos*bIdQemiUeeq9e9G!oey23SMXp40Ew2fodjx9J5buKNW0M4@nYMr1PR6d0KtuqhLQlx*K$', // Custom header with 'payping' value - ])->post("https://payping.limangold.ir/payment/start", [ - "amount" => $finalPriseP/10, // Payment amount - "user_name" => $user->name, // User name - "user_id" => $user->id, // User ID - "user" => $user, // User ID - "title" => $this->Config('name_fa'), // Title of the payment - "return_url" => "https://".$this->Config('app_url')."/transactions", // Callback URL - "server_call_url" => url("/customer/charge_account_verify/".$Withdraw->id), // Callback URL - "item" => "gp1Q", // Item identifier - ])->json(); - }catch (\Exception $exception){ - return response()->json(["message"=>"مشکل در ارتباط با درگاه","R"=>$response??$exception,], 422); + if (isset($request->order_id)) { + $Withdraw->order_id = $request->order_id; + if (isset($request->product_id)) { + $Withdraw->product_id = $request->product_id; + } + $Withdraw->save(); + } + + $payload = [ + 'amount' => $finalPriseP / 10, + 'user_name' => $user->name, + 'user_id' => $user->id, + 'user' => $user, + 'title' => $this->Config('name_fa'), + 'return_url' => 'https://' . $this->Config('app_url') . '/transactions', + 'server_call_url' => url('/customer/charge_account_verify/' . $Withdraw->id), + 'item' => $this->resolveGatewayItem(), + ]; + + $gatewayName = $this->cfg()->getString('payping_gateway_name', (string) config('payment.payping_gateway_name', '')); + if ($gatewayName !== '') { + $payload['gateway'] = $gatewayName; + } + + try { + $response = Http::withHeaders($this->paypingHeaders()) + ->post($this->paypingStartUrl(), $payload) + ->json(); + } catch (\Exception $exception) { + return response()->json([ + 'message' => 'مشکل در ارتباط با درگاه', + 'R' => $response ?? $exception, + ], 422); + } + + if (empty($response['id']) || empty($response['url'])) { + return response()->json([ + 'message' => 'مشکل در ارتباط با درگاه', + 'R' => $response ?? null, + ], 422); } $Withdraw->tracked_number = $response['id']; $Withdraw->save(); + return $response['url']; - return response()->json(["res"=>$response], 422); } - public function verifyTransationByID(Request $request ,$id) + + public function verifyTransationByID(Request $request, $id) { - if ($request->header('payping') !== '@XOKcNveJ$wpqYy%rdpb78oBh31Aos*bIdQemiUeeq9e9G!oey23SMXp40Ew2fodjx9J5buKNW0M4@nYMr1PR6d0KtuqhLQlx*K$') { + $expectedSecret = $this->cfg()->getString( + 'payping_header_secret', + (string) config('payment.payping_header_secret', '') + ); + + if ($request->header('payping') !== $expectedSecret) { return response()->json(['auth needed'], 401); } - $Withdraw = Withdraw::with('customer')->where('id',$id)->first(); + + $Withdraw = Withdraw::with('customer')->where('id', $id)->first(); $app_url = $this->Config('app_url'); $User = Customer::where('id', $Withdraw->customer_id)->first(); - $GTransaction = Http::withHeaders([ - 'payping' => '@XOKcNveJ$wpqYy%rdpb78oBh31Aos*bIdQemiUeeq9e9G!oey23SMXp40Ew2fodjx9J5buKNW0M4@nYMr1PR6d0KtuqhLQlx*K$', // Custom header with 'payping' value - ])->post("https://payping.limangold.ir/payment/verify", [ - "id" => "$Withdraw->tracked_number", - ])->json(); - if (isset( $GTransaction['active']) and $GTransaction['active'] == 5) { + + $GTransaction = Http::withHeaders($this->paypingHeaders()) + ->post($this->paypingVerifyUrl(), [ + 'id' => (string) ($Withdraw->tracked_number ?? $Withdraw->zify_code), + ]) + ->json(); + + if (isset($GTransaction['active']) && $GTransaction['active'] == 5) { if ($Withdraw->cash == $GTransaction['amount'] * 10) { $Withdraw->zify_code = $Withdraw->tracked_number; - $Withdraw->tracked_number = $GTransaction['invoiceNo'];//ok - $Withdraw->sts = 2;//ok + $Withdraw->tracked_number = $GTransaction['invoiceNo']; + $Withdraw->sts = 2; $Withdraw->save(); $wallet_interface_fund = new WalletInterface($User->id, $User->type); - $transaction = new TransactionInterface($wallet_interface_fund, $_inp = [ - "cash" => $GTransaction['amount'] * 10, + new TransactionInterface($wallet_interface_fund, [ + 'cash' => $GTransaction['amount'] * 10, 'expire_at' => now(), 'withdraw_id' => $Withdraw->id, - 'active' => true + 'active' => true, ], 3, false, true); -//----------sms - $userMobile = $Withdraw->customer->mobile; // User's mobile number - $userName = $Withdraw->customer->name; // User's name - $chargedAmount = $Withdraw->cash; // Charged amount - $companyName = $this->Config('name_fa'); // Company name from configuration - $message = "کاربر $userName با شماره موبایل $userMobile حساب خود را به مقدار " . number_format($chargedAmount) . " ریال شارژ کرد. با تشکر، $companyName"; - User::where('send_sms', 1)->get()->each(function($admin) use ($message) { + + $message = 'کاربر ' . $Withdraw->customer->name . ' با شماره موبایل ' . $Withdraw->customer->mobile + . ' حساب خود را به مقدار ' . number_format($Withdraw->cash) . ' ریال شارژ کرد. با تشکر، ' . $this->Config('name_fa'); + + User::where('send_sms', 1)->get()->each(function ($admin) use ($message) { $this->Send($admin->mobile, $message); }); - return view('showTransactionReport', compact('Withdraw','app_url')); - return redirect('https://app.gholaktala.ir/transactions'); + + return view('showTransactionReport', compact('Withdraw', 'app_url')); } - return "مبلغ پرداختی دستکاری شده !"; - } else { - $Withdraw->tracked_number; - $Withdraw->sts = 3;//no - $Withdraw->save(); - return view('showTransactionReport', compact('Withdraw','app_url')); + + return 'مبلغ پرداختی دستکاری شده !'; } + + if ($this->cfg()->getBool('payping_strict_failed_withdraw', (bool) config('payment.payping_strict_failed_withdraw', false))) { + if (!$Withdraw->zify_code) { + $Withdraw->priority = 51; + } + $Withdraw->priority = 111; + } + $Withdraw->sts = 3; + $Withdraw->save(); + + return view('showTransactionReport', compact('Withdraw', 'app_url')); } + public function verifyTransation() { $Withdraw = Withdraw::with('customer')->where('id', $_GET['clientrefid'])->first(); $app_url = $this->Config('app_url'); $User = Customer::where('id', $Withdraw->customer_id)->first(); - $url = 'https://zify.ir/api/order/v2/verify'; - $payload = [ - "order" => "$Withdraw->tracked_number", - ]; - $verifyResponse = Http::withToken("cf09ee0187335f173c786e7660d778d2dd71ab582d282999f751427f5923d525") - ->post($url, $payload); + + $verifyResponse = Http::withToken('cf09ee0187335f173c786e7660d778d2dd71ab582d282999f751427f5923d525') + ->post('https://zify.ir/api/order/v2/verify', [ + 'order' => (string) $Withdraw->tracked_number, + ]); + $decodedResponse = json_decode($verifyResponse, true); - $verifyMessage = $decodedResponse['message']; -// return $decodedResponse['data']; + $verifyMessage = $decodedResponse['message'] ?? null; if (isset($decodedResponse['data']['refid']) || $verifyMessage == []) { if ($Withdraw->cash == $decodedResponse['data']['amount'] * 10) { - $Withdraw->zify_code = $Withdraw->tracked_number;//ok - $Withdraw->tracked_number = $decodedResponse['data']['refid'];//ok - $Withdraw->sts = 2;//ok + $Withdraw->zify_code = $Withdraw->tracked_number; + $Withdraw->tracked_number = $decodedResponse['data']['refid']; + $Withdraw->sts = 2; $Withdraw->save(); $wallet_interface_fund = new WalletInterface($User->id, $User->type); - $transaction = new TransactionInterface($wallet_interface_fund, $_inp = [ - "cash" => $decodedResponse['data']['amount'] * 10, + new TransactionInterface($wallet_interface_fund, [ + 'cash' => $decodedResponse['data']['amount'] * 10, 'expire_at' => now(), 'withdraw_id' => $_GET['clientrefid'], - 'active' => true + 'active' => true, ], 3, false, true); - $User = Customer::where('id', $Withdraw->customer_id)->first(); - $url = 'https://limangold.ir/kernel/admin/fin'; - $payload = [ - "amount" => $decodedResponse['data']['amount'] * 10, - "customer_id" => "23", - "date_at" => \Carbon\Carbon::today()->format('Y/m/d'), - "receive_account_number" => "000", - "receive_bank" => "پیپینگ", - "receive_name" => "لیمان گلد", - "send_account_number" => "000", - "send_bank" => " زیفای کد $Withdraw->zify_code", - "send_name" => $User->name, - "track_number" => $decodedResponse['data']['refid'], - "type" => 1, - ]; - $verifyResponse = Http::withToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvbGltYW5nb2xkLmlyXC9rZXJuZWxcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNzI3NTMwNjA0LCJleHAiOjE3MzAxMjI2MDQsIm5iZiI6MTcyNzUzMDYwNCwianRpIjoiYXBINmlPZXlGTE9oTUhRdyIsInN1YiI6MiwicHJ2IjoiMjNiZDVjODk0OWY2MDBhZGIzOWU3MDFjNDAwODcyZGI3YTU5NzZmNyJ9.IrO6icD-EXjgZ3mYyeEAP4aqG7q35yJTCU_hQhEDGwk") - ->post($url, $payload); -//----------sms -// User information - $userMobile = $Withdraw->customer->mobile; // User's mobile number - $userName = $Withdraw->customer->name; // User's name - $chargedAmount = $Withdraw->cash; // Charged amount -// Company name - $companyName = $this->Config('name_fa'); // Company name from configuration + if ($this->cfg()->getBool('payping_fin_sync_enabled', (bool) config('payment.payping_fin_sync_enabled', false))) { + $finUrl = $this->cfg()->getString('payping_fin_url', 'https://limangold.ir/kernel/admin/fin'); + $finToken = $this->cfg()->getString('payping_fin_token', ''); + if ($finUrl !== '' && $finToken !== '') { + Http::withToken($finToken)->post($finUrl, [ + 'amount' => $decodedResponse['data']['amount'] * 10, + 'customer_id' => $this->cfg()->getString('payping_fin_customer_id', '23'), + 'date_at' => \Carbon\Carbon::today()->format('Y/m/d'), + 'receive_account_number' => '000', + 'receive_bank' => 'پیپینگ', + 'receive_name' => $this->Config('name_fa'), + 'send_account_number' => '000', + 'send_bank' => ' زیفای کد ' . $Withdraw->zify_code, + 'send_name' => $User->name, + 'track_number' => $decodedResponse['data']['refid'], + 'type' => 1, + ]); + } + } -// Constructing the SMS message - $message = "کاربر $userName با شماره موبایل $userMobile حساب خود را به مقدار " . number_format($chargedAmount) . " ریال شارژ کرد. با تشکر، $companyName"; + $message = 'کاربر ' . $Withdraw->customer->name . ' با شماره موبایل ' . $Withdraw->customer->mobile + . ' حساب خود را به مقدار ' . number_format($Withdraw->cash) . ' ریال شارژ کرد. با تشکر، ' . $this->Config('name_fa'); -// Getting admin mobile numbers and sending the SMS - User::where('send_sms', 1)->get()->each(function($admin) use ($message) { + User::where('send_sms', 1)->get()->each(function ($admin) use ($message) { $this->Send($admin->mobile, $message); }); - - - return view('showTransactionReport', compact('Withdraw','app_url')); - return redirect('https://app.gholaktala.ir/transactions'); - + return view('showTransactionReport', compact('Withdraw', 'app_url')); } - return "مبلغ پرداختی دستکاری شده !"; - } else { - $Withdraw->tracked_number; - $Withdraw->sts = 3;//no - $Withdraw->save(); - return view('showTransactionReport', compact('Withdraw','app_url')); + return 'مبلغ پرداختی دستکاری شده !'; } + $Withdraw->sts = 3; + $Withdraw->save(); + return view('showTransactionReport', compact('Withdraw', 'app_url')); } } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 9446c96..a93debd 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -65,5 +65,6 @@ class Kernel extends HttpKernel 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, 'validation'=>ValidationMiddleware::class, + 'request.validation' => \App\Http\Middleware\ValidateRequests::class, ]; } diff --git a/app/Http/Middleware/ValidateRequests.php b/app/Http/Middleware/ValidateRequests.php new file mode 100644 index 0000000..5f31d97 --- /dev/null +++ b/app/Http/Middleware/ValidateRequests.php @@ -0,0 +1,86 @@ +header('X-Client-Id'); + $timestamp = $request->header('X-Timestamp'); + $nonce = $request->header('X-Nonce'); + $signature = $request->header('X-Signature'); + + if (!$clientId || !$timestamp || !$nonce || !$signature) { + abort(401, 'Missing HMAC headers'); + } + + if ($clientId !== config('services.node.client_id')) { + abort(401, 'Invalid client id'); + } + + /** ✅ اینجا SECRET واقعاً استفاده می‌شود */ + $secret = config('services.node.secret'); + if (!$secret) { + abort(500, 'Node shared secret not configured'); + } + + + + $data = json_decode($request->getContent(), true); + ksort($data); + + $normalized = json_encode( + $data, + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES + ); + + $bodyHash = hash('sha256', $normalized); + + +// $bodyHash = hash('sha256', $request->getContent() ?? ''); + + $canonical = implode("\n", [ + strtoupper($request->method()), + '/' . ltrim($request->path(), '/'), + $bodyHash, + $timestamp, + $nonce, + ]); + + $expectedSignature = hash_hmac( + 'sha256', + $canonical, + $secret + ); + + if (!hash_equals($expectedSignature, $signature)) { + abort(401, 'Invalid HMAC signature'); + } + +// return $next($request); + + //ANTI REPLAY + $timestamp = (int)$request->header('X-Timestamp'); + $nonce = $request->header('X-Nonce'); + + if (abs(time() - $timestamp) > 99999999999999999) { + abort(401, 'Expired request'); + } + + $key = "node_nonce:{$nonce}"; + if (Cache::has($key)) { + abort(401, 'Replay attack detected'); + } + + Cache::put($key, true, 60); + + return $next($request); + } +} diff --git a/app/Models/Cnt.php b/app/Models/Cnt.php index 21579b7..c915cd2 100644 --- a/app/Models/Cnt.php +++ b/app/Models/Cnt.php @@ -20,30 +20,4 @@ class Cnt extends Model protected $casts = [ 'value_json'=>'array' ]; -/* public function goldir_login(){ - $mobile = self::where('key', 'goldir_mobile')->value('value'); - $password = self::where('key', 'goldir_password')->value('value'); - $goldir_base_url=Controller::Config('goldir_base_url')??'https://gold.ir'; - - $goldir = Http::withOptions([ - 'curl' => [ - CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4, - CURLOPT_TCP_FASTOPEN => 1, - ] - ]) - ->withoutVerifying() - ->post($goldir_base_url.'/server/auth/login', [ - 'mobile' => $mobile, - 'password' => $password, - 'provider' => 'customer', - 'type_app' => 'client', - ])->json(); - - Cnt::where('key', 'goldir')->update([ - 'value' => $goldir['access_token'], - 'updated_at' => now() - ]); - return $goldir['access_token']; - }*/ - } diff --git a/app/Models/Product.php b/app/Models/Product.php index 257304c..7e370a5 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -156,6 +156,12 @@ class Product extends Model public function transaction(){ return $this->hasMany(Transaction::class); } + + public function limitedTransactions() + { + return $this->hasMany(Transaction::class)->select('id', 'gold', 'title', 'created_at', 'product_id'); + } + public function transactionAgentPanel(){ return $this->hasMany(Transaction::class)->where('note','برداشت بابت فروش')->orwhere('note','واریز بابت خرید')->orwhere('note','سند ورود طلا'); } diff --git a/app/Services/ConfigService.php b/app/Services/ConfigService.php index 484a217..24f26ca 100644 --- a/app/Services/ConfigService.php +++ b/app/Services/ConfigService.php @@ -6,9 +6,101 @@ use App\Models\Setting; class ConfigService { + public const PRICE_PROVIDERS = ['montzar', 'etehadie', 'taban_gohar', 'main_product']; + public function Config($name) { - return Setting::where('key', $name)->value('value') ?? false; + return $this->get($name, false); + } + + /** + * مقدار setting؛ اگر نبود از config/price_providers.php یا default پارامتر. + */ + public function get(string $key, $default = null) + { + $row = Setting::where('key', $key)->first(); + + if ($row !== null && $row->value !== null && $row->value !== '') { + return $row->value; + } + + $fromFile = config("price_providers.{$key}"); + + return $fromFile !== null ? $fromFile : $default; + } + + public function getString(string $key, string $default = ''): string + { + $value = $this->get($key, $default); + + return trim((string) ($value === false ? $default : $value)); + } + + public function getBool(string $key, bool $default = false): bool + { + $value = $this->get($key, $default); + + if ($value === false || $value === null || $value === '') { + return $default; + } + + return filter_var($value, FILTER_VALIDATE_BOOLEAN); + } + + public function getInt(string $key, int $default = 0): int + { + $value = $this->get($key, $default); + + return (int) ($value === false || $value === null || $value === '' ? $default : $value); + } + + /** + * تنها منبع فعال قیمت — فقط یکی از: montzar | etehadie | taban_gohar | main_product + * + * اولویت: + * 1) price_provider (یا price_primary_source قدیمی) + * 2) montzar_price=true → montzar (ابشده خانگی و پروژه‌های فعلی) + * 3) price_method پر و montzar خاموش → etehadie (گلد علی) + * 4) پیش‌فرض فایل: montzar + */ + public function priceProvider(): string + { + foreach (['price_provider', 'price_primary_source'] as $key) { + $explicit = strtolower($this->getString($key, '')); + if (in_array($explicit, self::PRICE_PROVIDERS, true)) { + return $explicit; + } + } + + if ($this->getBool('montzar_price', false)) { + return 'montzar'; + } + + if ($this->getString('price_method') !== '') { + return 'etehadie'; + } + + $default = strtolower((string) config('price_providers.price_provider', 'montzar')); + + return in_array($default, self::PRICE_PROVIDERS, true) ? $default : 'montzar'; + } + + /** @deprecated از priceProvider() استفاده کن */ + public function pricePrimarySource(): string + { + $provider = $this->priceProvider(); + + return in_array($provider, ['montzar', 'etehadie'], true) ? $provider : 'montzar'; + } + + public function usesMontzarPricing(): bool + { + return $this->priceProvider() === 'montzar'; + } + + public function usesEtehadiePricing(): bool + { + return $this->priceProvider() === 'etehadie'; } public function UpdateConfig($name, $value) @@ -53,4 +145,4 @@ class ConfigService $this->UpdateConfig('down_price', $priceInt); } } -} \ No newline at end of file +} diff --git a/app/Services/EtehadiePriceService.php b/app/Services/EtehadiePriceService.php new file mode 100644 index 0000000..ac0cc7b --- /dev/null +++ b/app/Services/EtehadiePriceService.php @@ -0,0 +1,143 @@ +config->usesEtehadiePricing(); + } + + public function apiUrl(): string + { + $url = trim((string) $this->config->getString( + 'etehadie_api_url', + (string) config('price_providers.etehadie_api_url', 'http://109.122.246.48:4949/api/free') + )); + + return $url !== '' ? $url : 'http://109.122.246.48:4949/api/free'; + } + + /** کلید محصول در پاسخ API اتحادیه (همان price_method گلد علی) */ + public function priceKey(): string + { + $key = trim((string) $this->config->getString( + 'price_method', + (string) config('price_providers.price_method', '') + )); + + return $key; + } + + /** + * @return array{price: int, raw: array|null} + */ + public function fetchMainGramPrice(): array + { + if (!$this->isEnabled() && $this->priceKey() === '') { + return ['price' => 0, 'raw' => null]; + } + + try { + $prices = Http::withoutVerifying() + ->timeout(20) + ->get($this->apiUrl()) + ->json(); + + if (!is_array($prices)) { + return ['price' => 0, 'raw' => null]; + } + + $key = $this->priceKey(); + $collection = collect($prices); + $row = $key !== '' + ? $collection->firstWhere('key', $key) + : $collection->first(); + + if (empty($row)) { + return ['price' => 0, 'raw' => null]; + } + + $base = (float) ($row['price'] ?? 0); + $profit = (float) ($row['profit'] ?? 0); + $gramPrice = (int) round($base / 10 + $profit); + + return ['price' => $gramPrice, 'raw' => $row]; + } catch (\Throwable $e) { + Log::warning('Etehadie price fetch failed', ['message' => $e->getMessage()]); + + return ['price' => 0, 'raw' => null]; + } + } + + /** @return array>|null */ + public function fetchPriceList(): ?array + { + try { + $prices = Http::withoutVerifying() + ->timeout(20) + ->get($this->apiUrl()) + ->json(); + + return is_array($prices) ? $prices : null; + } catch (\Throwable $e) { + Log::warning('Etehadie price list fetch failed', ['message' => $e->getMessage()]); + + return null; + } + } + + public function syncProductsFromApi(): bool + { + $prices = $this->fetchPriceList(); + if ($prices === null) { + return false; + } + + $products = \App\Models\Product::with([])->whereNotNull('reading_method')->get(); + $collection = collect($prices); + $copper = null; + $dollar = null; + + foreach ($products as $product) { + $RPrice = $collection->firstWhere('key', $product->reading_method); + if (empty($RPrice)) { + continue; + } + + if (($RPrice['name'] ?? '') === 'TGJU فلز مس') { + $copper = ($RPrice['price'] ?? 0) + ($RPrice['profit'] ?? 0); + } + if (($RPrice['name'] ?? '') === 'TGJU دلار') { + $dollar = ($RPrice['price'] ?? 0) + ($RPrice['profit'] ?? 0); + } + if (($RPrice['name'] ?? '') === 'گلد دات ای از آبشده - رسمی - نقد فردا') { + $RPrice['price'] = ($RPrice['price'] ?? 0) / 4.3318; + } + + ProductPriceService::syncFromReference( + $product, + (int) $RPrice['price'], + (int) ($RPrice['profit'] ?? 0) + ); + } + + if ($copper !== null && $dollar !== null) { + $cp = ($copper / 1000000) * $dollar; + $copperProduct = \App\Models\Product::find(33); + if ($copperProduct) { + ProductPriceService::syncFromReference($copperProduct, (int) round($cp), 0); + } + } + + return true; + } +} diff --git a/config/payment.php b/config/payment.php new file mode 100644 index 0000000..779a620 --- /dev/null +++ b/config/payment.php @@ -0,0 +1,18 @@ + '@XOKcNveJ$wpqYy%rdpb78oBh31Aos*bIdQemiUeeq9e9G!oey23SMXp40Ew2fodjx9J5buKNW0M4@nYMr1PR6d0KtuqhLQlx*K$', + 'payping_start_url' => 'https://payping.limangold.ir/payment/start', + 'payping_verify_url' => 'https://payping.limangold.ir/payment/verify', + 'payping_gateway_item' => 'gp1Q', + 'payping_gateway_items' => '', + 'payping_gateway_name' => '', + 'payping_round_toman' => false, + 'payping_strict_failed_withdraw' => false, + 'payping_fin_sync_enabled' => false, +]; diff --git a/config/price_providers.php b/config/price_providers.php new file mode 100644 index 0000000..b16ea6c --- /dev/null +++ b/config/price_providers.php @@ -0,0 +1,24 @@ + 'montzar', + 'etehadie_api_url' => 'http://109.122.246.48:4949/api/free', + 'price_method' => '', + 'register_jibit_verify' => false, + 'register_referral_sms_to_referrer' => false, + 'register_referral_bonus_message' => false, + 'external_order_api_enabled' => false, + 'profit_gold_api_enabled' => false, + 'open_register' => true, + 'auto_active_customer' => false, +]; diff --git a/config/services.php b/config/services.php index 2a1d616..2f89270 100644 --- a/config/services.php +++ b/config/services.php @@ -30,4 +30,9 @@ return [ 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], + 'node' => [ + 'client_id' => env('NODE_CLIENT_ID'), + 'secret' => env('NODE_SHARED_SECRET'), + ], + ]; diff --git a/database/sql/goldali_cleanup_legacy_keys.sql b/database/sql/goldali_cleanup_legacy_keys.sql new file mode 100644 index 0000000..671946b --- /dev/null +++ b/database/sql/goldali_cleanup_legacy_keys.sql @@ -0,0 +1,40 @@ +-- گلد علی — حذف کلیدهای legacy که سرور Abshode_Khanegi (etehadie) دیگر نمی‌خواند +-- قبل از اجرا: بکاپ. جدول const یا cnt بسته به اسکیمای شما. + +START TRANSACTION; + +-- settings — لیمان / منت‌زر / منابع قیمت غیرفعال +DELETE FROM `settings` WHERE `key` IN ( + 'do_send_liman', + 'liman_token', + 'montzar_price', + 'montzar_base_url', + 'montzar_product_id', + 'montzar_closed', + 'montzar_open_buy', + 'montzar_open_sell', + 'montzar_live_price', + 'montzar_diff', + 'montzar_mazaneh', + 'montzar_truly_buy_mazaneh', + 'montzar_truly_sell_mazaneh', + 'tabanGohar_price', + 'main_product_price', + 'price_primary_source', + 'fee' +); + +-- const — API قیمت لیمان (نه کلید liman در JSON تراز ادمین) +DELETE FROM `const` WHERE `key` IN ( + 'liman_diff', + 'liman_price', + 'liman_mazaneh', + 'liman_truly_buy_mazaneh', + 'liman_truly_sell_mazaneh', + 'liman_closed', + 'log' +); + +COMMIT; + +-- اگر نام جدول cnt است: settings → setting و const → cnt diff --git a/database/sql/goldali_compat_patch.sql b/database/sql/goldali_compat_patch.sql new file mode 100644 index 0000000..9afceaf --- /dev/null +++ b/database/sql/goldali_compat_patch.sql @@ -0,0 +1,75 @@ +-- گلد علی — پچ بعد از deploy سرور Abshode_Khanegi + کلاینت/ادمین برنچ goldAli +-- (payping + کلیدهای لازم ادمین/یوزر). اگر قبلاً goldali_post_merge_settings زده‌اید، همین را بزنید. + +START TRANSACTION; + +-- درگاه (اگر قبلاً نزده‌اید) +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_start_url', 'https://payment.goldaliii.com/payment/start', 'آدرس شروع درگاه', 1, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_start_url' LIMIT 1); +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_verify_url', 'https://payment.goldaliii.com/payment/verify', 'آدرس تأیید درگاه', 1, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_verify_url' LIMIT 1); +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_gateway_name', 'sepal', 'نام gateway', 1, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_gateway_name' LIMIT 1); +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_gateway_items', 'sDsB,gp1Q,GPH4,AMAX,TbQl,AAQl', 'item چرخشی', 1, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_gateway_items' LIMIT 1); +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_round_toman', 'true', 'گرد به تومان', 0, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_round_toman' LIMIT 1); +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_strict_failed_withdraw', 'true', 'اولویت ناموفق', 0, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_strict_failed_withdraw' LIMIT 1); + +UPDATE `settings` SET `value` = 'https://payment.goldaliii.com/payment/start' WHERE `key` = 'payping_start_url'; +UPDATE `settings` SET `value` = 'https://payment.goldaliii.com/payment/verify' WHERE `key` = 'payping_verify_url'; +UPDATE `settings` SET `value` = 'sepal' WHERE `key` = 'payping_gateway_name'; +UPDATE `settings` SET `value` = 'sDsB,gp1Q,GPH4,AMAX,TbQl,AAQl' WHERE `key` = 'payping_gateway_items'; +UPDATE `settings` SET `value` = 'true' WHERE `key` IN ('payping_round_toman', 'payping_strict_failed_withdraw'); + +-- API سود طلا (کلاینت /customer/profit_gold) +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'profit_gold_api_enabled', 'true', 'API سود طلا', 0, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'profit_gold_api_enabled' LIMIT 1); +UPDATE `settings` SET `value` = 'true' WHERE `key` = 'profit_gold_api_enabled'; + +-- ثبت‌نام باز (AuthController) +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'open_register', '1', 'ثبت‌نام باز', 1, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'open_register' LIMIT 1); +UPDATE `settings` SET `is_active` = 1 WHERE `key` = 'open_register'; + +-- تراز ادمین: حساب تست را از گزارش حذف کن (گلد علی معمولاً 12) +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'balance_report_exclude_customer_id', '12', 'حذف مشتری از تراز', 0, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'balance_report_exclude_customer_id' LIMIT 1); +UPDATE `settings` SET `value` = '12' WHERE `key` = 'balance_report_exclude_customer_id'; + +-- const — کلاینت و ادمین +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'is_gateway_open', '1', 'باز بودن درگاه پرداخت' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'is_gateway_open' LIMIT 1); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'gram', '1', 'گرم پیش‌فرض ثبت‌نام' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'gram' LIMIT 1); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'first_customer_wallet_value', '0', 'حداقل موجودی اول خرید' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'first_customer_wallet_value' LIMIT 1); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'limited_price', '0', 'سقف قیمت محدود' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'limited_price' LIMIT 1); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'header_banner', '', 'بنر بالای صفحه' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'header_banner' LIMIT 1); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'app_closed', 'false', 'بسته بودن اپ' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'app_closed' LIMIT 1); + +COMMIT; diff --git a/database/sql/goldali_payping_patch.sql b/database/sql/goldali_payping_patch.sql new file mode 100644 index 0000000..06be471 --- /dev/null +++ b/database/sql/goldali_payping_patch.sql @@ -0,0 +1,35 @@ +-- اگر goldali_post_merge_settings.sql را قبلاً زده‌اید، فقط این را اجرا کنید (درگاه گلد علی) + +START TRANSACTION; + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_start_url', 'https://payment.goldaliii.com/payment/start', 'آدرس شروع درگاه', 1, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_start_url' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_verify_url', 'https://payment.goldaliii.com/payment/verify', 'آدرس تأیید درگاه', 1, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_verify_url' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_gateway_name', 'sepal', 'نام gateway درگاه', 1, 1, 'گلد علی: sepal' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_gateway_name' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_gateway_items', 'sDsB,gp1Q,GPH4,AMAX,TbQl,AAQl', 'لیست item (چرخشی)', 1, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_gateway_items' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_round_toman', 'true', 'گرد کردن مبلغ به تومان', 0, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_round_toman' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_strict_failed_withdraw', 'true', 'اولویت تراکنش ناموفق', 0, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_strict_failed_withdraw' LIMIT 1); + +UPDATE `settings` SET `value` = 'https://payment.goldaliii.com/payment/start' WHERE `key` = 'payping_start_url'; +UPDATE `settings` SET `value` = 'https://payment.goldaliii.com/payment/verify' WHERE `key` = 'payping_verify_url'; +UPDATE `settings` SET `value` = 'sepal' WHERE `key` = 'payping_gateway_name'; +UPDATE `settings` SET `value` = 'sDsB,gp1Q,GPH4,AMAX,TbQl,AAQl' WHERE `key` = 'payping_gateway_items'; +UPDATE `settings` SET `value` = 'true' WHERE `key` IN ('payping_round_toman', 'payping_strict_failed_withdraw'); + +COMMIT; diff --git a/database/sql/goldali_post_merge_settings.sql b/database/sql/goldali_post_merge_settings.sql new file mode 100644 index 0000000..0f6e1b9 --- /dev/null +++ b/database/sql/goldali_post_merge_settings.sql @@ -0,0 +1,178 @@ +-- ============================================================================= +-- گلد علی — اسکریپت محافظه‌کارانه (بعد از deploy کد Abshode_Khanegi مرج‌شده) +-- +-- اصول: +-- • هیچ ردیفی DELETE نمی‌شود +-- • value ردیف‌های موجود عمداً عوض نمی‌شود (فقط INSERT اگر key نبود) +-- • استثنا: price_provider (کلید جدید) + montzar_price اگر وجود داشت → false +-- • title_fa فقط جایی که NULL یا خالی است پر می‌شود +-- +-- قبل از اجرا: بکاپ + USE دیتابیس +-- ============================================================================= + +-- USE `goldali_db`; + +START TRANSACTION; + +-- ============================================================================= +-- بخش ۱ — عنوان فارسی (بدون تغییر value) +-- ============================================================================= + +UPDATE `settings` SET `title_fa` = 'نام فارسی اپ' WHERE `key` = 'name_fa' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'نام انگلیسی اپ' WHERE `key` = 'name_en' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'آدرس اپ (کاربر)' WHERE `key` = 'app_url' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'آدرس پایه' WHERE `key` = 'bace_url' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'لوگوی صفحه ورود' WHERE `key` = 'logo_register' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'آدرس پنل ادمین' WHERE `key` = 'admin_url' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'عنوان PWA' WHERE `key` = 'title_pwa' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'عنوان favicon' WHERE `key` = 'title_fav' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'متن قوانین' WHERE `key` = 'text_rule' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'متن درباره ما' WHERE `key` = 'text_about' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'کد معرف اجباری (قدیمی)' WHERE `key` = 'is_requaire_referral' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'صفحه کسب درآمد' WHERE `key` = 'has_page_earn_money' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'صفحه صندوق' WHERE `key` = 'has_page_fund' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'صفحه مجوزها' WHERE `key` = 'has_page_permission' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'صفحه هشدار قیمت' WHERE `key` = 'has_page_price_trigger' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'صفحه طلای فیزیکی' WHERE `key` = 'has_page_physical_gold' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'رنگ اصلی' WHERE `key` = 'color_primary' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'رنگ ثانویه' WHERE `key` = 'color_secondary' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'کارمزد (قدیمی — درصد)' WHERE `key` = 'fee' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'چت پشتیبانی' WHERE `key` = 'has_chat' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'آدرس API سرور' WHERE `key` = 'server_url' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'کلید داخلی اپ' WHERE `key` = 'key' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'تعداد معرف برای هدیه' WHERE `key` = 'referral_count_for_gift' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'مبلغ پاداش معرف' WHERE `key` = 'referral_bonus_amount' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'حداقل برداشت (ریال)' WHERE `key` = 'min_withdraw' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'حداقل اولین خرید (ریال)' WHERE `key` = 'min_first_buy' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `settings` SET `title_fa` = 'کلید محصول در API اتحادیه' WHERE `key` = 'price_method' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); + +UPDATE `const` SET `title_fa` = 'سقف قیمت محدود' WHERE `key` = 'limited_price' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `const` SET `title_fa` = 'باز بودن درگاه پرداخت' WHERE `key` = 'is_gateway_open' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); +UPDATE `const` SET `title_fa` = 'بنر بالای صفحه' WHERE `key` = 'header_banner' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); + +-- ============================================================================= +-- بخش ۲ — کلیدهای جدید کد (فقط INSERT اگر نبودند؛ value فعلی دست نخورده) +-- ============================================================================= + +-- منبع قیمت: اتحادیه (تنها منبع فعال در کد مرج‌شده) +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'price_provider', 'etehadie', 'منبع قیمت', + 1, 1, 'فقط یکی: montzar | etehadie | taban_gohar | main_product' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'price_provider' LIMIT 1); + +-- کارمزد نمایش buy/sell در /api/price/last — کد fee_single می‌خواند (نه fee) +-- مقدار 500000 = پیش‌فرض config/fee.php؛ اگر برای گلد علی عدد دیگری دارید بعداً در پنل عوض کنید +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'fee_single', '500000', 'اختلاف قیمت پایه (ریال)', 1, 1, 'پیش‌فرض Laravel fee.single' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'fee_single' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'buy_fee', '500000', 'سود/اختلاف خرید (ریال)', 1, 1, 'اگر خالی باشد از fee_single' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'buy_fee' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'sell_fee', '500000', 'سود/اختلاف فروش (ریال)', 1, 1, 'اگر خالی باشد از fee_single' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'sell_fee' LIMIT 1); + +-- ثبت‌نام: کد referral_id را هم چک می‌کند (کنار is_requaire_referral) +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'referral_id', 'required', 'الزام کد معرف', 0, 1, 'required یا خالی' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'referral_id' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'profit_gold_api_enabled', 'true', 'API سود طلا', 0, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'profit_gold_api_enabled' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'open_register', '1', 'ثبت‌نام باز', 1, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'open_register' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'balance_report_exclude_customer_id', '12', 'حذف مشتری از تراز', 0, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'balance_report_exclude_customer_id' LIMIT 1); + +-- ============================================================================= +-- بخش ۳ — فقط چند UPDATE مطمئن (کلیدهای مربوط به کد جدید) +-- ============================================================================= + +-- price_provider حتماً اتحادیه (ردیف بخش ۲ ساخته یا از قبل بوده) +UPDATE `settings` SET `value` = 'etehadie', `title_fa` = COALESCE(NULLIF(TRIM(`title_fa`), ''), 'منبع قیمت') +WHERE `key` = 'price_provider'; +UPDATE `settings` SET `value` = 'true' WHERE `key` = 'profit_gold_api_enabled'; +UPDATE `settings` SET `is_active` = 1 WHERE `key` = 'open_register'; +UPDATE `settings` SET `value` = '12' WHERE `key` = 'balance_report_exclude_customer_id'; + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'is_gateway_open', '1', 'باز بودن درگاه پرداخت' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'is_gateway_open' LIMIT 1); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'gram', '1', 'گرم پیش‌فرض ثبت‌نام' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'gram' LIMIT 1); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'first_customer_wallet_value', '0', 'حداقل موجودی اول خرید' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'first_customer_wallet_value' LIMIT 1); + +-- price_method را دست نمی‌زنیم — روی گلد علی همین است: +-- estjt_41670cdf0270a874b68a0a95a235f9a1 + +-- ============================================================================= +-- بخش ۳ب — درگاه پرداخت گلد علی (payment.goldaliii.com) +-- ============================================================================= + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_start_url', 'https://payment.goldaliii.com/payment/start', 'آدرس شروع درگاه', 1, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_start_url' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_verify_url', 'https://payment.goldaliii.com/payment/verify', 'آدرس تأیید درگاه', 1, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_verify_url' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_gateway_name', 'sepal', 'نام gateway درگاه', 1, 1, 'گلد علی: sepal' +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_gateway_name' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_gateway_items', 'sDsB,gp1Q,GPH4,AMAX,TbQl,AAQl', 'لیست item (چرخشی)', 1, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_gateway_items' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_round_toman', 'true', 'گرد کردن مبلغ به تومان', 0, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_round_toman' LIMIT 1); + +INSERT INTO `settings` (`key`, `value`, `title_fa`, `can_edit`, `is_active`, `description`) +SELECT 'payping_strict_failed_withdraw', 'true', 'اولویت تراکنش ناموفق', 0, 1, NULL +WHERE NOT EXISTS (SELECT 1 FROM `settings` WHERE `key` = 'payping_strict_failed_withdraw' LIMIT 1); + +UPDATE `settings` SET `value` = 'https://payment.goldaliii.com/payment/start' WHERE `key` = 'payping_start_url'; +UPDATE `settings` SET `value` = 'https://payment.goldaliii.com/payment/verify' WHERE `key` = 'payping_verify_url'; +UPDATE `settings` SET `value` = 'sepal' WHERE `key` = 'payping_gateway_name'; +UPDATE `settings` SET `value` = 'sDsB,gp1Q,GPH4,AMAX,TbQl,AAQl' WHERE `key` = 'payping_gateway_items'; +UPDATE `settings` SET `value` = 'true' WHERE `key` IN ('payping_round_toman', 'payping_strict_failed_withdraw'); + +-- ============================================================================= +-- بخش ۴ — const (حداقلی) +-- ============================================================================= + +UPDATE `const` SET `title_fa` = 'بسته بودن اپ' WHERE `key` = 'app_closed' AND (`title_fa` IS NULL OR TRIM(`title_fa`) = ''); + +INSERT INTO `const` (`key`, `value`, `title_fa`) +SELECT 'app_closed', 'false', 'بسته بودن اپ' +WHERE NOT EXISTS (SELECT 1 FROM `const` WHERE `key` = 'app_closed' LIMIT 1); + +-- ============================================================================= +-- بررسی — بعد از COMMIT این‌ها را بزن +-- ============================================================================= +-- SELECT `key`, `title_fa`, `value` FROM `settings` +-- WHERE `key` IN ( +-- 'price_provider', 'price_method', 'profit_gold_api_enabled', +-- 'fee_single', 'buy_fee', 'sell_fee', +-- 'referral_id', 'is_requaire_referral', +-- 'payping_start_url', 'payping_verify_url', 'payping_gateway_name' +-- ) +-- ORDER BY `key`; + +COMMIT; + +-- اگر جدولت `setting` است نه `settings`، همه `settings` را به `setting` عوض کن. diff --git a/routes/admin.php b/routes/admin.php index 30ee102..5001573 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -118,6 +118,8 @@ Route::middleware('auth:user')->group(function (){ //dashboard Route::post('dashboard/finance', [DashboardController::class, 'finance']); Route::get('dashboard', [DashboardController::class, 'dashboardMaster']); + Route::post('dashboard', [DashboardController::class, 'dashboardMaster']); + Route::post('gateway', [DashboardController::class, 'gateway']); Route::post('dashboard/customer/all_sell', [DashboardController::class, 'sumSellToCustomerMajor']); Route::post('dashboard/customer/single/all_sell', [DashboardController::class, 'sumSellToCustomerSingle']); Route::post('dashboard/customer/flow', [DashboardController::class, 'flow']); diff --git a/routes/api.php b/routes/api.php index 5209f14..db1e969 100644 --- a/routes/api.php +++ b/routes/api.php @@ -9,6 +9,8 @@ use App\Http\Controllers\Customer\PriceTriggerController; use Illuminate\Support\Facades\Route; use App\Models\File; use App\Http\Controllers\Admin\SettingsController; +use App\Http\Controllers\Site\RequestsController; +use App\Services\ConfigService; /* |-------------------------------------------------------------------------- @@ -35,3 +37,10 @@ Route::get('/city/state',[CityController::class, 'stateList']); Route::get('/city/all',[CityController::class, 'cityListAll']); Route::get('/city/{state_id}',[CityController::class, 'cityList']); Route::get('get_settings',[SettingsController::class, 'index']); + +if (app(ConfigService::class)->getBool('external_order_api_enabled', false)) { + Route::middleware('request.validation')->group(function () { + Route::post('get_wallet', [RequestsController::class, 'getWallet']); + Route::post('order', [RequestsController::class, 'order']); + }); +} diff --git a/routes/customer.php b/routes/customer.php index 814a3ae..da0ffad 100644 --- a/routes/customer.php +++ b/routes/customer.php @@ -15,6 +15,7 @@ use App\Http\Controllers\Customer\ProductController; use App\Http\Controllers\Admin\TahesabController; use App\Http\Controllers\Site\OfferCodesController; use App\Http\Controllers\Admin\GiftCardController; +use App\Services\ConfigService; //----------gateway-verify @@ -31,6 +32,10 @@ Route::middleware('auth:customer')->group(function () { //---------PriceTrigger Route::resource('price_triggers', PriceTriggerController::class); + $cfg = app(ConfigService::class); + if ($cfg->getBool('profit_gold_api_enabled', false) || $cfg->usesEtehadiePricing()) { + Route::get('profit_gold', [OrderController::class, 'profit_gold']); + } //-----------product Route::post('/product/table',[AdminProductController::class, 'table']); diff --git a/routes/web.php b/routes/web.php index 699c0de..aa6c950 100644 --- a/routes/web.php +++ b/routes/web.php @@ -16,41 +16,9 @@ use App\Models\Message; use Illuminate\Http\Request; Route::get('/refPricer', function () { -// $RPrices = Http::get('https://pricing.liman.gold/pricingApi', [])->json(); - $RPrices = Http::get('http://109.122.246.48:4949/api/free', [])->json(); + $ok = app(\App\Services\EtehadiePriceService::class)->syncProductsFromApi(); - $products = Product::with([])->whereNotNull('reading_method')->get(); - foreach ($products as $product) { - $collection = collect($RPrices); - $RPrice = $collection->firstWhere('key', $product->reading_method); - if (!empty($RPrice)) { -// foreach ($RPrices as $RPrice) { - if ($RPrice['name'] == 'TGJU فلز مس') { - $copper = $RPrice['price'] + $RPrice['profit']; - } - if ($RPrice['name'] == 'TGJU دلار') { - $dollar = $RPrice['price'] + $RPrice['profit']; - } - if ($RPrice['name'] == 'گلد دات ای از آبشده - رسمی - نقد فردا') { - $RPrice['price'] = $RPrice['price'] / 4.3318; - } - ProductPriceService::syncFromReference( - $product, - (int) $RPrice['price'], - (int) ($RPrice['profit'] ?? 0) - ); -// } - } - } - if (isset($copper) && isset($dollar)) { - $cp = ($copper / 1000000) * $dollar; - $copperProduct = Product::find(33); - if ($copperProduct) { - ProductPriceService::syncFromReference($copperProduct, (int) round($cp), 0); - } - } - - return response()->json(true); + return response()->json($ok); }); Route::get('/1', function () { @@ -281,19 +249,6 @@ Route::get('/getJibitCounter', function (Request $request) { // }); // return $subs; //}); -//Route::get('testliman', function () { -// $payload = [ -// 'amount' => "0.02", -// 'description' =>$this->ConfigService('name_fa')." - "."سس ", -// 'ref_id' => 000, -// 'direction' => 1, -// 'product_id' => 2 -// ]; -// -// return $response = Http::withToken($this->ConfigService('liman_token')) -// ->post("https://limangold.ir/kernel/customer/order",$payload)->json(); -// -//}); //Route::get('/gDom', function () { // // return strtr($_SERVER['SERVER_NAME'], '.', '_'); @@ -312,21 +267,6 @@ Route::get('/getJibitCounter', function (Request $request) { // $customer->save(); // Save the updated sum_gold into the database // }); //}); -//Route::get('/SENDtrAORDOR', function () { -// $payload = [ -// 'amount' => "1", -// 'direction' => 1, -// 'product_id' => 2 -// ]; -// $response = Http::withToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvbGltYW5nb2xkLmlyXC9rZXJuZWxcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNzI3NjI3NTc1LCJleHAiOjE3MzAyMTk1NzUsIm5iZiI6MTcyNzYyNzU3NSwianRpIjoiZTNTUk1kcEdmSTh3clZwUCIsInN1YiI6MjMsInBydiI6IjFkMGEwMjBhY2Y1YzRiNmM0OTc5ODlkZjFhYmYwZmJkNGU4YzhkNjMifQ.5miGMG7jo1ISRjV_4hXiCceubc5IJ-qe_nq9zUj7-7Y") -// ->post("https://limangold.ir/kernel/customer/order",$payload)->json(); -// return $response; -//}); -//Route::get('/SENDtrAORDOR2', function () { -// $response = Http::withToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvbGltYW5nb2xkLmlyXC9rZXJuZWxcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNzI3NjI3NTc1LCJleHAiOjE3MzAyMTk1NzUsIm5iZiI6MTcyNzYyNzU3NSwianRpIjoiZTNTUk1kcEdmSTh3clZwUCIsInN1YiI6MjMsInBydiI6IjFkMGEwMjBhY2Y1YzRiNmM0OTc5ODlkZjFhYmYwZmJkNGU4YzhkNjMifQ.5miGMG7jo1ISRjV_4hXiCceubc5IJ-qe_nq9zUj7-7Y") -// ->get("https://limangold.ir/kernel/customer/product/list")->json(); -// return $response; -//}); //Route::get('/TEST', function () { // $url = 'https://zify.ir/api/order/v2/create'; // diff --git a/storage/web.php b/storage/web.php deleted file mode 100644 index d6140d0..0000000 --- a/storage/web.php +++ /dev/null @@ -1,128 +0,0 @@ -get('https://pm.gholaktala.ir/config/'.strtr($_SERVER['SERVER_NAME'], '.', '_'))->json(); - $subs = collect($response['subs'])->mapWithKeys(function ($sub) { - return [$sub['name'] => $sub['value']]; - }); - return $subs; -}); -Route::get('testliman', function () { - $payload = [ - 'amount' => "0.02", - 'description' =>$this->Config('name_fa')." - "."سس ", - 'ref_id' => 000, - 'direction' => 1, - 'product_id' => 2 - ]; - - return $response = Http::withToken($this->Config('liman_token')) - ->post("https://limangold.ir/kernel/customer/order",$payload)->json(); - -}); -Route::get('/gDom', function () { - - return strtr($_SERVER['SERVER_NAME'], '.', '_'); -}); -Route::get('/exporter', function () { - $query_table = Customer::with(['wallet' => function ($query) { - $query->select('owner', DB::raw('SUM(gold) as total_gold'))->groupBy('owner'); - }]) - ->where('is_archive', false) - ->get() - ->each(function ($customer) { - $sum_gold = $customer->wallet->sum(function ($wallet) { - return (float) $wallet->total_gold; - }); - $customer->sum_gold = $sum_gold; // Sum the gold from wallet - $customer->save(); // Save the updated sum_gold into the database - }); -}); -Route::get('/SENDtrAORDOR', function () { - $payload = [ - 'amount' => "1", - 'direction' => 1, - 'product_id' => 2 - ]; - $response = Http::withToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvbGltYW5nb2xkLmlyXC9rZXJuZWxcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNzI3NjI3NTc1LCJleHAiOjE3MzAyMTk1NzUsIm5iZiI6MTcyNzYyNzU3NSwianRpIjoiZTNTUk1kcEdmSTh3clZwUCIsInN1YiI6MjMsInBydiI6IjFkMGEwMjBhY2Y1YzRiNmM0OTc5ODlkZjFhYmYwZmJkNGU4YzhkNjMifQ.5miGMG7jo1ISRjV_4hXiCceubc5IJ-qe_nq9zUj7-7Y") - ->post("https://limangold.ir/kernel/customer/order",$payload)->json(); - return $response; -}); -Route::get('/SENDtrAORDOR2', function () { - $response = Http::withToken("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvbGltYW5nb2xkLmlyXC9rZXJuZWxcL2F1dGhcL2xvZ2luIiwiaWF0IjoxNzI3NjI3NTc1LCJleHAiOjE3MzAyMTk1NzUsIm5iZiI6MTcyNzYyNzU3NSwianRpIjoiZTNTUk1kcEdmSTh3clZwUCIsInN1YiI6MjMsInBydiI6IjFkMGEwMjBhY2Y1YzRiNmM0OTc5ODlkZjFhYmYwZmJkNGU4YzhkNjMifQ.5miGMG7jo1ISRjV_4hXiCceubc5IJ-qe_nq9zUj7-7Y") - ->get("https://limangold.ir/kernel/customer/product/list")->json(); - return $response; -}); -Route::get('/TEST', function () { - $url = 'https://zify.ir/api/order/v2/create'; - - $payload = [ - "payer" => [ - "first_name" => '', - "last_name" => '', - "phone" => '09372281182', - "email" => "", - "state" => '', - "city" => '', - "address_1" => "", - "address_2" =>"" - ], - "products" => [ - [ - "code" => "1", - "sellQuantity" => 1, - "title" => "IRR", - "amount" => 1000, - "unlimited" => true, - "quantity" => 1, - "description" => "charge_account" - ] - ], - "returnUrl" => "https://api.gholaktala.ir", - "clientRefId" => "1212126266612212123", - "shipping_total" => 0, - "off_total" => 0, - "tax_total" => 0 - ]; - - return $response = Http::withToken("cf09ee0187335f173c786e7660d778d2dd71ab582d282999f751427f5923d525") - ->post($url, $payload)->json(); -// $dbPassword = 1; -// echo $dbPassword; -// echo $transactionId = '123456'; -// $transactionDate = '2024-08-28'; -// $quantity = '10 گرم'; -// $price = '5,000,000 ریال'; -// $totalAmount = '50,000,000 ریال'; -//// $message->to('atrenejat@yahoo.com') -// Mail::to('mmoobbiinn1383@gmail.com')->send(new YourMailableClass($transactionId, $transactionDate, $quantity, $price, $totalAmount)); - -}); - -Route::get('/TEST/{code}', function ($code) { - $url = 'https://zify.ir/api/order/v2/verify'; - $payload = [ - "order" => "$code", - ]; - return $verifyResponse = Http::withToken("cf09ee0187335f173c786e7660d778d2dd71ab582d282999f751427f5923d525") - ->post($url, $payload);}); - -Route::get('/', [FinanceController::class, 'index']); -Route::get('/send-notification', [myNotificationController::class, 'send']); - -Route::get('/send-notification2', function () { - -return view('notification'); -}); - - - -