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