feat: 计算逻辑更新
This commit is contained in:
@@ -2,6 +2,7 @@ import datetime
|
||||
|
||||
from calculators import Calculator, Helper
|
||||
from commons.models.data_network import DataNetwork
|
||||
from commons.models.fujian_survey import FujianSurvey
|
||||
from commons.models.oil import Oil
|
||||
|
||||
from commons.models.price_result import PriceResult
|
||||
@@ -17,13 +18,18 @@ class Oil92Calculator(Calculator):
|
||||
self.year = year
|
||||
self.month = month
|
||||
|
||||
def _get_survey_price(self):
|
||||
query = FujianSurvey.get_query(self.year, self.month, name='汽油', spec='92#')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
fluctuating = self._get_fluctuating('price_survey', price)
|
||||
return round(price, 2), round(fluctuating, 2)
|
||||
|
||||
def _get_network_price(self):
|
||||
query = DataNetwork.get_query(self.year, self.month, name='汽油', spec='92号')
|
||||
data = query.first()
|
||||
price = data.price if data else 0
|
||||
|
||||
fluctuating = price - int(getattr(self.previous_prices, 'price_network', price))
|
||||
|
||||
fluctuating = self._get_fluctuating('price_network', price)
|
||||
return round(price, 2), round(fluctuating, 2)
|
||||
|
||||
def _get_calculate_price(self, round_dit=2):
|
||||
|
Reference in New Issue
Block a user