SamiKoen commited on
Commit
7f5cdbd
·
verified ·
1 Parent(s): 12a9860

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +19 -3
  2. whatsapp_features.py +15 -2
app.py CHANGED
@@ -141,6 +141,22 @@ try:
141
  price_element = item.find('priceTaxWithCur')
142
  price_str = price_element.text if price_element is not None and price_element.text else "0"
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  # EFT fiyatı
145
  price_eft_element = item.find('priceEft')
146
  price_eft_str = price_eft_element.text if price_eft_element is not None and price_eft_element.text else ""
@@ -149,9 +165,9 @@ try:
149
  link_element = item.find('productLink')
150
  product_link = link_element.text if link_element is not None and link_element.text else ""
151
 
152
- # Fiyat formatting
153
  try:
154
- price_float = float(price_str)
155
  if price_float > 200000:
156
  price = str(round(price_float / 5000) * 5000)
157
  elif price_float > 30000:
@@ -161,7 +177,7 @@ try:
161
  else:
162
  price = str(round(price_float / 10) * 10)
163
  except (ValueError, TypeError):
164
- price = price_str
165
 
166
  # EFT fiyat formatting
167
  if price_eft_str:
 
141
  price_element = item.find('priceTaxWithCur')
142
  price_str = price_element.text if price_element is not None and price_element.text else "0"
143
 
144
+ # Kampanya fiyatı
145
+ price_rebate_element = item.find('priceRebateWithTax')
146
+ price_rebate_str = price_rebate_element.text if price_rebate_element is not None and price_rebate_element.text else ""
147
+
148
+ # Kampanya fiyatı varsa onu kullan, yoksa normal fiyatı kullan
149
+ final_price_str = price_str
150
+ if price_rebate_str:
151
+ try:
152
+ normal_price = float(price_str)
153
+ rebate_price = float(price_rebate_str)
154
+ # Kampanya fiyatı normal fiyattan farklı ve düşükse kullan
155
+ if rebate_price < normal_price:
156
+ final_price_str = price_rebate_str
157
+ except (ValueError, TypeError):
158
+ final_price_str = price_str
159
+
160
  # EFT fiyatı
161
  price_eft_element = item.find('priceEft')
162
  price_eft_str = price_eft_element.text if price_eft_element is not None and price_eft_element.text else ""
 
165
  link_element = item.find('productLink')
166
  product_link = link_element.text if link_element is not None and link_element.text else ""
167
 
168
+ # Fiyat formatting (kampanya fiyatı veya normal fiyat)
169
  try:
170
+ price_float = float(final_price_str)
171
  if price_float > 200000:
172
  price = str(round(price_float / 5000) * 5000)
173
  elif price_float > 30000:
 
177
  else:
178
  price = str(round(price_float / 10) * 10)
179
  except (ValueError, TypeError):
180
+ price = final_price_str
181
 
182
  # EFT fiyat formatting
183
  if price_eft_str:
whatsapp_features.py CHANGED
@@ -145,7 +145,13 @@ class WhatsAppBudgetRecommendations:
145
  product_link = item_info[2] if len(item_info) > 2 else ""
146
 
147
  text += f"**{i}. {full_name}**\n"
148
- text += f"💰 Fiyat: {price} TL\n"
 
 
 
 
 
 
149
 
150
  # Resim URL'si varsa ekle
151
  if len(item_info) > 6 and item_info[6]:
@@ -189,8 +195,15 @@ class WhatsAppCategoryRecommendations:
189
  name, item_info, full_name = product
190
  price = item_info[1] if len(item_info) > 1 else "Fiyat yok"
191
 
 
 
 
 
 
 
 
192
  text += f"**{i}. {full_name}**\n"
193
- text += f"💰 Fiyat: {price} TL\n\n"
194
 
195
  return text
196
 
 
145
  product_link = item_info[2] if len(item_info) > 2 else ""
146
 
147
  text += f"**{i}. {full_name}**\n"
148
+ # Fiyatı formatlı göster
149
+ try:
150
+ price_float = float(price)
151
+ price_formatted = f"{price_float:,.0f}"
152
+ except:
153
+ price_formatted = price
154
+ text += f"💰 Fiyat: {price_formatted} TL\n"
155
 
156
  # Resim URL'si varsa ekle
157
  if len(item_info) > 6 and item_info[6]:
 
195
  name, item_info, full_name = product
196
  price = item_info[1] if len(item_info) > 1 else "Fiyat yok"
197
 
198
+ # Fiyatı formatlı göster
199
+ try:
200
+ price_float = float(price)
201
+ price_formatted = f"{price_float:,.0f}"
202
+ except:
203
+ price_formatted = price
204
+
205
  text += f"**{i}. {full_name}**\n"
206
+ text += f"💰 Fiyat: {price_formatted} TL\n\n"
207
 
208
  return text
209