From cfb5b17ab780cb8a9f2c422253f3fa2142c9b61a Mon Sep 17 00:00:00 2001 From: gholak tala Date: Sun, 8 Feb 2026 08:02:11 +0000 Subject: [PATCH] NASER disable tahesab functions --- .../Controllers/Admin/TahesabController.php | 98 ++++++++++++------- app/Http/Controllers/Auth/AuthController.php | 7 ++ .../Customer/CustomerController.php | 4 + .../Single/SingleOrderController.php | 12 +-- 4 files changed, 80 insertions(+), 41 deletions(-) diff --git a/app/Http/Controllers/Admin/TahesabController.php b/app/Http/Controllers/Admin/TahesabController.php index 012c0c4..b7bcc33 100755 --- a/app/Http/Controllers/Admin/TahesabController.php +++ b/app/Http/Controllers/Admin/TahesabController.php @@ -8,52 +8,80 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; use App\Models\Tahesab; use App\Models\Customer; +use Morilog\Jalali\Jalalian; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; use Hekmatinasser\Verta\Verta; class TahesabController extends Controller { - public function store() + public function create_user($customer_id) { - $customer = auth()->user(); - if (!$customer) { - throw new UnprocessableEntityHttpException("Auth needed"); - } - $customer = Customer::where('id', $customer->id)->first(); - if ($customer && ($customer->moshtari_code !== null)) { - return "customer exists"; - } - try { - $response = Http::withoutVerifying()->timeout(10)->withHeaders([ - 'DBName' => $this->Config('tahesab_db'), - 'Content-Type' => 'application/json', - 'Authorization' => "Bearer " . $this->Config('tahesab_token'), - ])->post('https://185.252.86.194:8081', [ - "DoNewMoshtari" => [ - $customer->name, - $this->Config('name_fa'), - $customer->mobile, - "", - $customer->n_code ?? "", - $customer->birth_date ?? "", // !== null ? jalalian::fromCarbon(Carbon::parse($customer->birth_date))->format('Y/m/d') : null, - "", - "", - -1, - 0 // tala - ] - ]); - } catch (\Exception $e) { - return $e->getMessage(); + $customer = Customer::findOrFail($customer_id); + + if ($customer && ($customer->moshtari_code == null)) { + try { + $response = Http::withoutVerifying()->timeout(10)->withHeaders([ + 'DBName' => $this->Config('tahesab_db'), + 'Content-Type' => 'application/json', + 'Authorization' => "Bearer " . $this->Config('tahesab_token'), + ])->post((string)env('TAHESAB'), [ + "DoNewMoshtari" => [ + (string)$customer->name, + $this->Config('name_fa'), + (string)$customer->mobile, + "", + "", + "", + "", + "", + -1, + 0 + ] +//{"DoNewMoshtari":["Name", "GroupName", "Tel", "Address", "CodeMeli", "Tarikh_Tavalod", "Moaref", "Code_Moaref", Moshtari_Code, Jens_Felez]} + ]); + if (!empty($response['OK'])) { + $customer->moshtari_code = $response['OK']; + $customer->save(); + } + } catch (\Exception $e) { + return $e->getMessage(); + } + }else { + if($customer && $customer->birth_date !== null){ + $birth_date = Verta::instance(Carbon::parse($customer->birth_date))->format('Y-m-d'); + } + try { + $response = Http::withoutVerifying()->timeout(10)->withHeaders([ + 'DBName' => $this->Config('tahesab_db'), + 'Content-Type' => 'application/json', + 'Authorization' => "Bearer " . $this->Config('tahesab_token'), + ])->post((string)env('TAHESAB'), [ + "DoEditMoshtari" => [ + $customer->name, + $this->Config('name_fa'), + $customer->mobile, + "", + $customer->n_code ?? "", + $birth_date ?? "", + "", + "", + (int)$customer->moshtari_code, + 0 // tala + ] +//{"DoEditMoshtari":["Name","GroupName", "Tel", "Address", "CodeMeli", "Tarikh_Tavalod", "Moaref", "Code_Moaref", Moshtari_Code]} + ]); + } catch (\Exception $e) { + return response($e->getMessage(), 500); + } + } if (empty($response['OK'])) { return "tahesab api error!!!"; } - $customer->moshtari_code = $response['OK']; - $customer->save(); return true; @@ -87,7 +115,7 @@ class TahesabController extends Controller } $date = Verta::instance(Carbon::parse($data['pay_at']))->format('Y-m-d'); [$year, $month, $day] = explode('-', $date); - + $amount = $data['amount']; $tahesab = Tahesab::create([ @@ -104,7 +132,7 @@ class TahesabController extends Controller 'DBName' => $this->Config('tahesab_db'), 'Content-Type' => 'application/json', 'Authorization' => "Bearer " . $this->Config('tahesab_token'), - ])->post('https://185.252.86.194:8081', [ + ])->post((string)env('TAHESAB'), [ "DoNewSanadBuySaleGOLD" => [ 1,//Sabte_Kol_Or_Movaghat_1_0 (int)$customer->moshtari_code, //Moshtari_Code @@ -187,7 +215,7 @@ class TahesabController extends Controller 'DBName' => $this->Config('tahesab_db'), 'Content-Type' => 'application/json', 'Authorization' => "Bearer " . $this->Config('tahesab_token'), - ])->post('https://185.252.86.194:8081', [ + ])->post((string)env('TAHESAB'), [ "DoNewSanadVKHBank" => [ 1,//Sabte_Kol_Or_Movaghat_1_0 $customer->moshtari_code,//Moshtari_Code diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index ad5a482..5cf72b7 100755 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Auth; +use App\Http\Controllers\Admin\TahesabController; use App\Http\Controllers\Controller; use App\Models\Cnt; use App\Models\Customer; @@ -160,6 +161,12 @@ class AuthController extends Controller $data['active'] = true; // Create customer $customer = Customer::create($data); + +// $tah = new TahesabController(); +// return $tah->store([ +// 'customer_id' => $customer->id, +// ]); + $message = "{$data['name']} عزیز، اکانت شما در پلتفرم {$this->Config('name_fa')} ایجاد شد.\nنام کاربری: {$data['mobile']}\n\nورود به نرم افزار:\n{$this->Config('app_url')}"; $this->Send($data['mobile'], $message); diff --git a/app/Http/Controllers/Customer/CustomerController.php b/app/Http/Controllers/Customer/CustomerController.php index 6b50af1..b18f512 100755 --- a/app/Http/Controllers/Customer/CustomerController.php +++ b/app/Http/Controllers/Customer/CustomerController.php @@ -18,6 +18,7 @@ use Rooyesh\Wallet\models\Transaction; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Http; use App\Models\Setting; +use App\Http\Controllers\Admin\TahesabController; //use App\Models\Price; @@ -102,6 +103,9 @@ class CustomerController extends Controller $updateData['credential_id'] = $request->credential_id; } $customer->update($updateData); + +// $tah = new TahesabController(); +// $tah->store(["customer_id" => $customer->id]); if (!$customer->is_legal) { $response = Http::withHeaders([ diff --git a/app/Http/Controllers/Single/SingleOrderController.php b/app/Http/Controllers/Single/SingleOrderController.php index 89a7825..f6a98f2 100755 --- a/app/Http/Controllers/Single/SingleOrderController.php +++ b/app/Http/Controllers/Single/SingleOrderController.php @@ -103,12 +103,12 @@ class SingleOrderController extends Controller $response['sell'] = $this->processSellTransaction($data, $wallet, $wallet_interface); } } -// try { -// $tahesab = new TahesabController(); -// $data['tahesab'] = $tahesab->storeTrade($data); -// }catch (\Exception $e){ -// return response($e->getMessage(), 500); -// } + try { + $tahesab = new TahesabController(); + $data['tahesab'] = $tahesab->storeTrade($data); + }catch (\Exception $e){ + return response($e->getMessage(), 500); + } // $response['reward'] = $this->give_order_reward($data, $wallet, $wallet_interface); $response['Notifications'] = $this->sendTransactionNotifications($data, $transactionType);