NASER & LOTFI dynamic connect to hamkar app
This commit is contained in:
@@ -156,7 +156,9 @@ class ReportController extends Controller
|
||||
$open_buy = true;
|
||||
$open_sell = true;
|
||||
if($gold_ir_price == 'true' && !$closed){
|
||||
|
||||
$goldir_price = 0;
|
||||
$goldir_base_url=$this->Config('goldir_base_url')??'https://gold.ir';
|
||||
try{
|
||||
$goldir = Http::timeout(7)->withOptions([
|
||||
'curl' => [
|
||||
@@ -166,16 +168,16 @@ class ReportController extends Controller
|
||||
])
|
||||
->withoutVerifying() // غیرفعال کردن بررسی SSL (برای تست سرعت)
|
||||
->withToken(Cnt::where('key', 'goldir')->first()['value'])
|
||||
->get('https://gold.ir/server/customer/product/list')->json();
|
||||
->get($goldir_base_url.'/server/customer/product/list')->json();
|
||||
|
||||
if((isset($goldir['message']) && $goldir['message'] == 'no authorised') || $goldir == null){
|
||||
$cnt = new Cnt();
|
||||
$goldir = Http::timeout(2)->withToken($cnt->goldir_login())
|
||||
->get('https://gold.ir/server/customer/product/list')->json();
|
||||
->get($goldir_base_url.'/server/customer/product/list')->json();
|
||||
}
|
||||
$customPrice= [];
|
||||
$collection = collect($goldir);
|
||||
$lp = $collection->firstWhere('id', 40);
|
||||
$lp = $collection->firstWhere('id', $this->Config('hamkar_product_id'));
|
||||
|
||||
// foreach ($goldir as $lp) {
|
||||
// if ($lp['id'] == 40) {
|
||||
@@ -208,7 +210,9 @@ class ReportController extends Controller
|
||||
}else{
|
||||
Cnt::where('key', 'goldir_closed')->update(['value' => "false"]);
|
||||
}
|
||||
} catch (\Exception $e) {$goldir_price = 0;}
|
||||
} catch (\Exception $e) {
|
||||
echo $e->getMessage();
|
||||
$goldir_price = 0;}
|
||||
}
|
||||
|
||||
if($main_product_price == 'true' && !$closed){
|
||||
|
||||
+3
-1
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
@@ -22,6 +23,7 @@ class Cnt extends Model
|
||||
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' => [
|
||||
@@ -30,7 +32,7 @@ class Cnt extends Model
|
||||
]
|
||||
])
|
||||
->withoutVerifying()
|
||||
->post('https://gold.ir/server/auth/login', [
|
||||
->post($goldir_base_url.'/server/auth/login', [
|
||||
'mobile' => $mobile,
|
||||
'password' => $password,
|
||||
'provider' => 'customer',
|
||||
|
||||
Reference in New Issue
Block a user