Add debug logging for carrot product pricing in FalukantService
- Introduced console logs to trace the price calculation process specifically for the carrot product (productId: 3). - Enhanced visibility into the evaluation of cities and the resulting prices, aiding in debugging and performance monitoring. - Logged details when skipping the current city, calculating prices, and adding cities to the results, improving traceability of pricing logic.
This commit is contained in:
@@ -3725,9 +3725,16 @@ class FalukantService extends BaseService {
|
||||
|
||||
// Für jede Stadt den Preis berechnen und Branch-Typ bestimmen
|
||||
const results = [];
|
||||
const isCarrot = productId === 3; // Debug für Karotten
|
||||
if (isCarrot) {
|
||||
console.log(`[getProductPricesInCities CARROT] productId: ${productId}, currentPrice: ${currentPrice}, currentRegionId: ${currentRegionId}, knowledgeFactor: ${knowledgeFactor}, product.sellCost: ${product.sellCost}, cities: ${cities.length}`);
|
||||
}
|
||||
for (const city of cities) {
|
||||
// Aktuelle Stadt ausschließen
|
||||
if (currentRegionId && city.id === currentRegionId) {
|
||||
if (isCarrot) {
|
||||
console.log(`[getProductPricesInCities CARROT] Skipping current city: ${city.name} (${city.id})`);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3742,6 +3749,10 @@ class FalukantService extends BaseService {
|
||||
const max = basePrice;
|
||||
const priceInCity = min + (max - min) * (knowledgeFactor / 100);
|
||||
|
||||
if (isCarrot) {
|
||||
console.log(`[getProductPricesInCities CARROT] City: ${city.name} (${city.id}), worthPercent: ${worthPercent}, basePrice: ${basePrice}, priceInCity: ${priceInCity}, currentPrice: ${currentPrice}, isBetter: ${priceInCity > currentPrice}`);
|
||||
}
|
||||
|
||||
// Nur Städte zurückgeben, wo der Preis höher ist
|
||||
// Keine Toleranz, da wir die aktuelle Stadt bereits ausschließen
|
||||
if (priceInCity > currentPrice) {
|
||||
@@ -3757,6 +3768,10 @@ class FalukantService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
if (isCarrot) {
|
||||
console.log(`[getProductPricesInCities CARROT] Adding ${city.name} to results: price=${priceInCity}, branchType=${branchType}`);
|
||||
}
|
||||
|
||||
results.push({
|
||||
regionId: city.id,
|
||||
regionName: city.name,
|
||||
@@ -3765,6 +3780,10 @@ class FalukantService extends BaseService {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (isCarrot) {
|
||||
console.log(`[getProductPricesInCities CARROT] Returning ${results.length} cities with better prices:`, results.map(r => `${r.regionName} (${r.price})`).join(', '));
|
||||
}
|
||||
|
||||
// Sortiere nach Preis (höchster zuerst)
|
||||
results.sort((a, b) => b.price - a.price);
|
||||
|
||||
Reference in New Issue
Block a user