zarbox added

This commit is contained in:
2026-06-04 14:40:02 +03:30
parent f9c5ca109d
commit 92d01f96da
8 changed files with 208 additions and 181 deletions
+31
View File
@@ -2,6 +2,7 @@
namespace App\Services;
use App\Models\Product;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
@@ -142,4 +143,34 @@ class EtehadiePriceService
return true;
}
/** به‌روز قیمت یک محصول از API با reading_method */
public function syncProductFromApi(Product $product): bool
{
if (!$product->reading_method) {
return false;
}
$prices = $this->fetchPriceList();
if ($prices === null) {
return false;
}
$RPrice = collect($prices)->firstWhere('key', $product->reading_method);
if (empty($RPrice)) {
return false;
}
if (($RPrice['name'] ?? '') === 'گلد دات ای از آبشده - رسمی - نقد فردا') {
$RPrice['price'] = ($RPrice['price'] ?? 0) / 4.3318;
}
ProductPriceService::syncFromReference(
$product,
(int) $RPrice['price'],
(int) ($RPrice['profit'] ?? 0)
);
return true;
}
}