NASER fix conflicts
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
$Setting = Setting::where('can_edit',1)->select('id','title_fa', 'key','value','description','is_active')->get();
|
||||
return response()->json($Setting);
|
||||
}
|
||||
public function edit(Request $request)
|
||||
{
|
||||
// Check if the setting exists
|
||||
$setting = Setting::where('key', $request->key)->first();
|
||||
|
||||
if ($setting) {
|
||||
// Update the existing setting
|
||||
$setting->value = $request->value;
|
||||
$setting->description = $request->description;
|
||||
$setting->is_active = $request->is_active;
|
||||
$setting->save();
|
||||
} else {
|
||||
// Create a new setting
|
||||
$setting = new Setting();
|
||||
$setting->key = $request->key;
|
||||
$setting->value = $request->value;
|
||||
$setting->description = $request->description;
|
||||
$setting->is_active = $request->is_active;
|
||||
$setting->save();
|
||||
}
|
||||
|
||||
// Return the setting as a JSON response
|
||||
return response()->json($setting);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Http\Controllers\SuperController;
|
||||
use App\Models\Permission;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Setting;
|
||||
|
||||
class UserController extends SuperController
|
||||
{
|
||||
@@ -29,6 +30,9 @@ class UserController extends SuperController
|
||||
->findOrFail(auth()->id());
|
||||
// $permission = Permission::where('user_type',$user->user_type)->select('rid')->distinct('rid')->get()->pluck('rid')->toArray();
|
||||
// $user['permission'] = $permission;
|
||||
$query = Setting::query();
|
||||
$settings = $query->get();
|
||||
$user->settings= $settings;
|
||||
return response()->json($user);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ use Rooyesh\Wallet\models\Transaction;
|
||||
use Rooyesh\Wallet\models\Wallet;
|
||||
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
|
||||
use App\Http\Controllers\Admin\TahesabController;
|
||||
use App\Models\Setting;
|
||||
|
||||
|
||||
class WalletController extends Controller
|
||||
@@ -117,9 +118,16 @@ class WalletController extends Controller
|
||||
'active' => true
|
||||
], 7, true, $deposit, $gold_block);
|
||||
|
||||
$data['direction'] = 0;
|
||||
// $tahesab = new TahesabController();
|
||||
// $tahesab->wallet($data);
|
||||
if(Setting::where('key', 'send_to_tahesab')->first()->value == "true"){
|
||||
try {
|
||||
$data['direction'] = 0;
|
||||
$tahesab = new TahesabController();
|
||||
$tahesab->wallet($data);
|
||||
}catch (\Exception $e){
|
||||
return response($e->getMessage(), 500);
|
||||
}
|
||||
}
|
||||
|
||||
$status = $data['value'] > 0 ?" شارژ شد ": " کسر شد ";
|
||||
$message = 'کیف پول شما به اندازه ' . number_format(abs($data['value'])) . " ریال در تاریخ " . verta()->format('Y/n/j H:i:s') .$status . "بابت" . "\n"
|
||||
. $data['note']
|
||||
|
||||
Reference in New Issue
Block a user