added merge wallet 3
This commit is contained in:
@@ -23,16 +23,23 @@ class UpdateProductStatus extends Command
|
||||
|
||||
public function handle()
|
||||
{
|
||||
// منطق توابع خود را اینجا بیاورید
|
||||
// اگر توابع در کلاس دیگری هستند، آن کلاس را صدا بزنید یا کد را اینجا کپی کنید
|
||||
|
||||
$this->info('Starting update...');
|
||||
// \Illuminate\Support\Facades\Log::info("handle at: " . now());
|
||||
|
||||
// 1. Get Price Logic
|
||||
// 0. فید zaarbox — reading_method به شکل key (مثل 1_29_5) با این فید sync میشود
|
||||
try {
|
||||
app(\App\Services\ZaarboxPriceService::class)->syncProductsFromApi();
|
||||
} catch (\Throwable $e) {
|
||||
\Illuminate\Support\Facades\Log::warning('Zaarbox product sync failed', ['message' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
$RPrices =Http::timeout(40)->get('http://212.23.201.173:8381/price_list', [])->json();
|
||||
// 1. فید قدیمی — reading_method به شکل name (سازگاری با پروژههای قدیمی)
|
||||
try {
|
||||
$RPrices = Http::timeout(40)->get('http://212.23.201.173:8381/price_list', [])->json();
|
||||
} catch (\Throwable $e) {
|
||||
$RPrices = null;
|
||||
}
|
||||
|
||||
$CP = null;
|
||||
try{
|
||||
$cooper =Http::timeout(40)->get('https://www.livedata.ir/main/static/p.json', [])->json();
|
||||
if(isset($cooper['s_301006']) && isset($cooper['s_200103'])){
|
||||
@@ -44,9 +51,9 @@ class UpdateProductStatus extends Command
|
||||
$current_time = now()->format('H:i:s');
|
||||
|
||||
foreach ($products as $product) {
|
||||
foreach ($RPrices as $RPrice) {
|
||||
$show = ($current_time >= $product->auto_open_at && $current_time <= $product->auto_close_at);
|
||||
$show = ($current_time >= $product->auto_open_at && $current_time <= $product->auto_close_at);
|
||||
|
||||
foreach (is_array($RPrices) ? $RPrices : [] as $RPrice) {
|
||||
if ($product->reading_method == $RPrice['name']) {
|
||||
ProductPriceService::syncFromReference(
|
||||
$product,
|
||||
@@ -65,15 +72,15 @@ class UpdateProductStatus extends Command
|
||||
|
||||
}
|
||||
}
|
||||
if ($product->reading_method == 'مس' && $CP) {
|
||||
ProductPriceService::syncFromReference($product, (int) $CP, 0);
|
||||
Product::where('id', $product->id)->update(['show' => $show]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($product->reading_method == 'مس' && $CP) {
|
||||
ProductPriceService::syncFromReference($product, (int) $CP, 0);
|
||||
Product::where('id', $product->id)->update(['show' => $show]);
|
||||
}
|
||||
}
|
||||
// 2. Auto Close/Open Logic
|
||||
// $this->auto_close_open(); -> کد داخل این تابع را اینجا قرار دهید
|
||||
// \Illuminate\Support\Facades\Log::info("handle end at: " . now());
|
||||
|
||||
$this->info('Product statuses updated successfully.');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user