NASER send orders to gold.ir
This commit is contained in:
@@ -126,6 +126,49 @@ class ReportController extends Controller
|
||||
// $difference = config('fee.single');
|
||||
$difference = Setting::where('key', 'fee_single')->first()->value;
|
||||
|
||||
if($this->Config('goldir_price') == 'true'){
|
||||
$goldir_price = 0;
|
||||
try{
|
||||
$goldir = Http::withToken(Cnt::where('key', 'goldir')->first()['value'])
|
||||
->get('https://gold.ir/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();
|
||||
}
|
||||
$customPrice= [];
|
||||
foreach ($goldir as $lp) {
|
||||
if ($lp['id'] == 47) {
|
||||
|
||||
$buy = $lp['sub_agent']['rate_buy_gram_price'];
|
||||
$sell = $lp['sub_agent']['rate_sell_gram_price'];
|
||||
|
||||
$customPrice['price'] = ($buy + $sell) / 2;
|
||||
Cnt::where('key', 'goldir_price')->update(['value' => (float)$customPrice['price']]);//was float
|
||||
$customPrice['diff'] = ($buy - $sell) / 2;
|
||||
Cnt::where('key', 'goldir_diff')->update(['value' => (float)$customPrice['diff']]);//was float
|
||||
|
||||
Cnt::where('key', 'goldir_mazaneh')->update(['value' => ((float)$customPrice['price'] * 4.331802)]);
|
||||
Cnt::where('key', 'goldir_truly_buy_mazaneh')->update(['value' => $lp['sub_agent']['rate_buy_price']]);
|
||||
Cnt::where('key', 'goldir_truly_sell_mazaneh')->update(['value' => $lp['sub_agent']['rate_sell_price']]);
|
||||
Cnt::where('key', 'log')->update(['value' => json_encode($goldir, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT)]);
|
||||
|
||||
if ($lp['open_sell'] == 'true' && $lp['open_buy'] == 'true') {
|
||||
$goldir_price = (int)$customPrice['price'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$customPrice['lp'] = $lp;
|
||||
|
||||
}
|
||||
if($goldir_price == 0){
|
||||
Cnt::where('key', 'goldir_closed')->update(['value' => "true"]);
|
||||
}else{
|
||||
Cnt::where('key', 'goldir_closed')->update(['value' => "false"]);
|
||||
}
|
||||
} catch (\Exception $e) {$goldir_price = 0;}
|
||||
}
|
||||
|
||||
// try {
|
||||
// $tala_ir = (int)str_replace(',', '', Http::timeout(2)->get('https://www.tala.ir/ajax/price')->json()['gold']['gold_18k']['v']) * 10;
|
||||
@@ -145,7 +188,11 @@ class ReportController extends Controller
|
||||
$tgn = (int)$taban_gohar['c']*10;
|
||||
}catch (\Exception $e){$tgn = 0;}
|
||||
|
||||
$priceValue = /*$tgn !== 0 ? $tgn : */$pr_product['price'] + $pr_product['price_profit'];//$tala_ir;//4000
|
||||
if($this->Config('goldir_price') == 'true') {
|
||||
$priceValue = (int)$goldir_price;
|
||||
}else{
|
||||
$priceValue = /*$tgn !== 0 ? $tgn : */$pr_product['price'] + $pr_product['price_profit'];//$tala_ir;//4000
|
||||
}
|
||||
$lastPrice = Price::latest()->first();
|
||||
if (!$lastPrice || $lastPrice->price != $priceValue and $priceValue > 30000000) {
|
||||
$price = new Price();
|
||||
@@ -179,13 +226,9 @@ class ReportController extends Controller
|
||||
'buy' => $price->price + $difference,
|
||||
'price_last' => $price->price + $difference,
|
||||
'price' => $priceValue,
|
||||
// 'tala_ir' => $tala_ir,
|
||||
// 'henzagold' => $henzagold_18,
|
||||
// 'Ounce' => $henzagold_ons_gold,
|
||||
// 'milli' => $milli,
|
||||
'main_product' => $pr_product['price'] + $pr_product['price_profit'],
|
||||
'taban_gohar' => $tgn,
|
||||
// 'refpricer' => $ref
|
||||
'goldir' => $goldir_price ?? 0
|
||||
];
|
||||
} else {
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user