NASER optimize last api & dynamic price & fix orders with 0 price & test all changes
This commit is contained in:
@@ -127,45 +127,58 @@ class ProductController extends SuperController
|
||||
{
|
||||
// $RPrices = Http::get('https://pricing.liman.gold/pricingApi', [])->json();
|
||||
// $RPrices = Http::get('https://pricing.liman.gold/pricingApi', [])->json();
|
||||
// $RPrices =Http::timeout(40)->get('http://212.23.201.173:8381/price_list', [])->json();
|
||||
$RPrices = Http::timeout(40)->get('http://37.32.11.142:4949/api/free', [])->json();
|
||||
|
||||
$RPrices =Http::timeout(40)->get('http://212.23.201.173:8381/price_list', [])->json();
|
||||
|
||||
try{
|
||||
$cooper =Http::timeout(40)->get('https://www.livedata.ir/main/static/p.json', [])->json();
|
||||
if(isset($cooper['s_301006']) && isset($cooper['s_200103'])){
|
||||
$CP = (($cooper['s_301006']/1000000)*$cooper['s_200103'])*10;
|
||||
// Cnt::where('key', 'cu_price')
|
||||
}
|
||||
}catch (\Exception $e){}
|
||||
// try{
|
||||
// $cooper =Http::timeout(40)->get('https://www.livedata.ir/main/static/p.json', [])->json();
|
||||
// if(isset($cooper['s_301006']) && isset($cooper['s_200103'])){
|
||||
// $CP = (($cooper['s_301006']/1000000)*$cooper['s_200103'])*10;
|
||||
//// Cnt::where('key', 'cu_price')
|
||||
// }
|
||||
// }catch (\Exception $e){}
|
||||
|
||||
$products = Product::with([])->whereNotNull('reading_method')->get();
|
||||
foreach ($products as $product) {
|
||||
foreach ($RPrices as $RPrice) {
|
||||
if ($product->reading_method == $RPrice['name']) {
|
||||
$p = Product::where('id', $product->id)->update([
|
||||
$collection = collect($RPrices);
|
||||
$RPrice = $collection->firstWhere('key', $product->reading_method);
|
||||
if (!empty($RPrice)) {
|
||||
// foreach ($RPrices as $RPrice) {
|
||||
// if ($product->reading_method == $RPrice['name']) {
|
||||
if ($RPrice['name'] == 'TGJU فلز مس') {
|
||||
$copper = $RPrice['price'] + $RPrice['profit'];
|
||||
}
|
||||
if ($RPrice['name'] == 'TGJU دلار') {
|
||||
$dollar = $RPrice['price'] + $RPrice['profit'];
|
||||
}
|
||||
if ($RPrice['name'] == 'گلد دات ای از آبشده - رسمی - نقد فردا') {
|
||||
$RPrice['price'] = $RPrice['price'] / 4.3318;
|
||||
}
|
||||
$p = Product::where('id', $product->id)->update([
|
||||
'price' => $RPrice['price'],
|
||||
'price_profit' => $RPrice['profit'],
|
||||
]);
|
||||
|
||||
if($product->bubble== 1){
|
||||
if ($product->bubble == 1) {
|
||||
$ReportController = new ReportController();
|
||||
$liquidGold= $ReportController->lastPrice();
|
||||
$liquidGold = $ReportController->lastPrice();
|
||||
$p = Product::find($product->id);
|
||||
$p->amount = $RPrice['price'] / $liquidGold['price'];
|
||||
$p->save();
|
||||
|
||||
}
|
||||
}
|
||||
if($product->reading_method == 'مس' && $CP){
|
||||
$p = Product::where('id', $product->id)->update([
|
||||
'price' => $CP,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($copper) && isset($dollar)) {
|
||||
$cp = ($copper / 1000000) * $dollar;
|
||||
$p = Product::where('metal_id', 3)->update([
|
||||
'price' => $cp,
|
||||
'price_profit' => 0,
|
||||
'updated_at' => \Carbon\Carbon::now()->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
}
|
||||
|
||||
return response()->json(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function auto_close_open()
|
||||
|
||||
Reference in New Issue
Block a user