NASER disable tahesab functions

This commit is contained in:
gholak tala
2026-02-08 08:02:11 +00:00
parent 26d87a793f
commit cfb5b17ab7
4 changed files with 80 additions and 41 deletions
@@ -8,52 +8,80 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Models\Tahesab; use App\Models\Tahesab;
use App\Models\Customer; use App\Models\Customer;
use Morilog\Jalali\Jalalian;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
use Hekmatinasser\Verta\Verta; use Hekmatinasser\Verta\Verta;
class TahesabController extends Controller 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) { $customer = Customer::findOrFail($customer_id);
return $e->getMessage();
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'])) { if (empty($response['OK'])) {
return "tahesab api error!!!"; return "tahesab api error!!!";
} }
$customer->moshtari_code = $response['OK'];
$customer->save();
return true; return true;
@@ -87,7 +115,7 @@ class TahesabController extends Controller
} }
$date = Verta::instance(Carbon::parse($data['pay_at']))->format('Y-m-d'); $date = Verta::instance(Carbon::parse($data['pay_at']))->format('Y-m-d');
[$year, $month, $day] = explode('-', $date); [$year, $month, $day] = explode('-', $date);
$amount = $data['amount']; $amount = $data['amount'];
$tahesab = Tahesab::create([ $tahesab = Tahesab::create([
@@ -104,7 +132,7 @@ class TahesabController extends Controller
'DBName' => $this->Config('tahesab_db'), 'DBName' => $this->Config('tahesab_db'),
'Content-Type' => 'application/json', 'Content-Type' => 'application/json',
'Authorization' => "Bearer " . $this->Config('tahesab_token'), 'Authorization' => "Bearer " . $this->Config('tahesab_token'),
])->post('https://185.252.86.194:8081', [ ])->post((string)env('TAHESAB'), [
"DoNewSanadBuySaleGOLD" => [ "DoNewSanadBuySaleGOLD" => [
1,//Sabte_Kol_Or_Movaghat_1_0 1,//Sabte_Kol_Or_Movaghat_1_0
(int)$customer->moshtari_code, //Moshtari_Code (int)$customer->moshtari_code, //Moshtari_Code
@@ -187,7 +215,7 @@ class TahesabController extends Controller
'DBName' => $this->Config('tahesab_db'), 'DBName' => $this->Config('tahesab_db'),
'Content-Type' => 'application/json', 'Content-Type' => 'application/json',
'Authorization' => "Bearer " . $this->Config('tahesab_token'), 'Authorization' => "Bearer " . $this->Config('tahesab_token'),
])->post('https://185.252.86.194:8081', [ ])->post((string)env('TAHESAB'), [
"DoNewSanadVKHBank" => [ "DoNewSanadVKHBank" => [
1,//Sabte_Kol_Or_Movaghat_1_0 1,//Sabte_Kol_Or_Movaghat_1_0
$customer->moshtari_code,//Moshtari_Code $customer->moshtari_code,//Moshtari_Code
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Auth; namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Admin\TahesabController;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Cnt; use App\Models\Cnt;
use App\Models\Customer; use App\Models\Customer;
@@ -160,6 +161,12 @@ class AuthController extends Controller
$data['active'] = true; $data['active'] = true;
// Create customer // Create customer
$customer = Customer::create($data); $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')}"; $message = "{$data['name']} عزیز، اکانت شما در پلتفرم {$this->Config('name_fa')} ایجاد شد.\nنام کاربری: {$data['mobile']}\n\nورود به نرم افزار:\n{$this->Config('app_url')}";
$this->Send($data['mobile'], $message); $this->Send($data['mobile'], $message);
@@ -18,6 +18,7 @@ use Rooyesh\Wallet\models\Transaction;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use App\Models\Setting; use App\Models\Setting;
use App\Http\Controllers\Admin\TahesabController;
//use App\Models\Price; //use App\Models\Price;
@@ -102,6 +103,9 @@ class CustomerController extends Controller
$updateData['credential_id'] = $request->credential_id; $updateData['credential_id'] = $request->credential_id;
} }
$customer->update($updateData); $customer->update($updateData);
// $tah = new TahesabController();
// $tah->store(["customer_id" => $customer->id]);
if (!$customer->is_legal) { if (!$customer->is_legal) {
$response = Http::withHeaders([ $response = Http::withHeaders([
@@ -103,12 +103,12 @@ class SingleOrderController extends Controller
$response['sell'] = $this->processSellTransaction($data, $wallet, $wallet_interface); $response['sell'] = $this->processSellTransaction($data, $wallet, $wallet_interface);
} }
} }
// try { try {
// $tahesab = new TahesabController(); $tahesab = new TahesabController();
// $data['tahesab'] = $tahesab->storeTrade($data); $data['tahesab'] = $tahesab->storeTrade($data);
// }catch (\Exception $e){ }catch (\Exception $e){
// return response($e->getMessage(), 500); return response($e->getMessage(), 500);
// } }
// $response['reward'] = $this->give_order_reward($data, $wallet, $wallet_interface); // $response['reward'] = $this->give_order_reward($data, $wallet, $wallet_interface);
$response['Notifications'] = $this->sendTransactionNotifications($data, $transactionType); $response['Notifications'] = $this->sendTransactionNotifications($data, $transactionType);