feat: 计算逻辑更新
This commit is contained in:
@@ -127,7 +127,7 @@ class Calculator:
|
||||
|
||||
previous_price = int(getattr(self.previous_prices, 'price_recommend', 0))
|
||||
if not previous_price:
|
||||
return 0, 0
|
||||
previous_price = int(getattr(self.previous_prices, 'price_calculate', 0))
|
||||
|
||||
fluctuating = sum(self._fluctuatings) / len(self._fluctuatings)
|
||||
fluctuating = round(fluctuating / round_by) * round_by
|
||||
@@ -141,6 +141,11 @@ class Calculator:
|
||||
result = self.result()
|
||||
PriceResult(**result).upsert()
|
||||
|
||||
def _get_fluctuating(self, field_name, price):
|
||||
previous_price = getattr(self.previous_prices, field_name, 0) or price
|
||||
fluctuating = price - previous_price if price else 0
|
||||
return fluctuating
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from calculators.asphalt_domestic import AsphaltDomesticCalculator
|
||||
|
Reference in New Issue
Block a user