store 6
This commit is contained in:
@@ -29,8 +29,12 @@ class ProductPriceSyncService
|
||||
*/
|
||||
public function syncStorePrices(bool $forceRefresh = true): bool
|
||||
{
|
||||
$feed = $this->zaarboxPriceService->cachedPriceList($forceRefresh)
|
||||
?? $this->cachedLegacyPriceList($forceRefresh);
|
||||
$zaarboxFeed = $this->zaarboxPriceService->cachedPriceList($forceRefresh);
|
||||
$feed = $zaarboxFeed ?? $this->cachedLegacyPriceList($forceRefresh);
|
||||
$source = $zaarboxFeed !== null ? 'zaarbox' : 'legacy';
|
||||
$sourceUrl = $source === 'zaarbox'
|
||||
? $this->zaarboxPriceService->apiUrl()
|
||||
: 'http://212.23.201.173:8381/price_list';
|
||||
|
||||
if ($feed === null) {
|
||||
return false;
|
||||
@@ -43,6 +47,7 @@ class ProductPriceSyncService
|
||||
}
|
||||
|
||||
$synced = false;
|
||||
$logItems = [];
|
||||
|
||||
foreach ($products as $product) {
|
||||
$row = $this->zaarboxPriceService->findFeedRow($feed, (string) $product->reading_method);
|
||||
@@ -53,9 +58,13 @@ class ProductPriceSyncService
|
||||
$row = $this->zaarboxPriceService->normalizeFeedRow($row);
|
||||
$basePrice = (int) ($row['price'] ?? 0);
|
||||
$baseProfit = (int) ($row['profit'] ?? 0);
|
||||
$sourceName = trim((string) ($row['name'] ?? $product->reading_method));
|
||||
|
||||
ProductPriceService::syncFromReference($product, $basePrice, $baseProfit);
|
||||
$synced = true;
|
||||
$result = ProductPriceService::syncFromReference($product, $basePrice, $baseProfit, $sourceName);
|
||||
if ($result !== null) {
|
||||
$logItems[] = $result;
|
||||
$synced = true;
|
||||
}
|
||||
|
||||
if ((int) ($product->bubble ?? 0) === 1 && $liquidGoldPrice > 0 && $basePrice > 0) {
|
||||
$p = Product::find($product->id);
|
||||
@@ -66,6 +75,8 @@ class ProductPriceSyncService
|
||||
}
|
||||
}
|
||||
|
||||
app(PriceSyncLogService::class)->record($source, $sourceUrl, $liquidGoldPrice, $logItems);
|
||||
|
||||
return $synced;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user