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 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