From bfb1315028f86dd9f23cb591bc11791d2714de2e Mon Sep 17 00:00:00 2001 From: han0 Date: Tue, 22 Apr 2025 15:41:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=96=B0=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E4=BB=B7=E7=9A=84=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/calculators/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/web/calculators/__init__.py b/web/calculators/__init__.py index f297547..baa7dc5 100644 --- a/web/calculators/__init__.py +++ b/web/calculators/__init__.py @@ -190,11 +190,16 @@ class Calculator: return getattr(self.previous_prices, 'price_recommend', 0) def _get_calculate_price(self, round_dit=2): - prices = (self.price_ftb, self.price_ss, self.price_fhb, self.price_network, self.price_survey, self.price_last_month) - total = sum(float(i) for i in prices) - if total == 0: + prices = [ + self.price_ftb * self.weight_ftb, + self.price_ss * self.weight_ss, + self.price_fhb * self.weight_fhb, + self.price_network * self.weight_network, + self.price_survey * self.weight_survey, + ] + if sum(prices) == 0: return 0 - result = total / len([i for i in prices if i != 0]) + result = sum(prices) / sum([self.weight_ftb, self.weight_ss, self.weight_fhb, self.weight_network, self.weight_survey]) result = round(result, round_dit) return result