From a10ab91a318bd48094a36b72c31389e7ba4a134f Mon Sep 17 00:00:00 2001 From: han0 Date: Mon, 19 May 2025 18:12:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9B=9B=E8=88=8D?= =?UTF-8?q?=E4=BA=94=E5=85=A5=E8=AE=A1=E7=AE=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/collectors/__init__.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/web/collectors/__init__.py b/web/collectors/__init__.py index 4fcab46..9ae3afb 100644 --- a/web/collectors/__init__.py +++ b/web/collectors/__init__.py @@ -1,4 +1,6 @@ import datetime +import decimal +from decimal import Decimal from sqlalchemy import func @@ -60,24 +62,25 @@ class Collector: material_id, price, price_fuzhou, price_xiamen, price_putian, price_sanming, price_quanzhou, \ price_zhangzhou, price_nanpin, price_longyan, price_ningde, price_pintan, price_zhangzhoukfq = item display_digit = self.digit_map.get(material_id, 1) + PricePublish( year=self.year, month=self.month, material_id=material_id, name=self.name_map.get(material_id, ''), spec=self.spec_map.get(material_id, ''), - price=round(price, 2), - price_fuzhou=round(price_fuzhou or 0, 2), - price_xiamen=round(price_xiamen or 0, 2), - price_putian=round(price_putian or 0, 2), - price_sanming=round(price_sanming or 0, 2), - price_quanzhou=round(price_quanzhou or 0, 2), - price_zhangzhou=round(price_zhangzhou or 0, 2), - price_nanpin=round(price_nanpin or 0, 2), - price_longyan=round(price_longyan or 0, 2), - price_ningde=round(price_ningde or 0, 2), - price_pintan=round(price_pintan or 0, 2), - price_zhangzhoukfq=round(price_zhangzhoukfq or 0, 2), + price=price.quantize(Decimal('0.00'), decimal.ROUND_HALF_UP) if price else 0, + price_fuzhou=price_fuzhou.quantize(Decimal('0.00'), decimal.ROUND_HALF_UP) if price_fuzhou else 0, + price_xiamen=price_xiamen.quantize(Decimal('0.00'), decimal.ROUND_HALF_UP) if price_xiamen else 0, + price_putian=price_putian.quantize(Decimal('0.00'), decimal.ROUND_HALF_UP) if price_putian else 0, + price_sanming=price_sanming.quantize(Decimal('0.00'), decimal.ROUND_HALF_UP) if price_sanming else 0, + price_quanzhou=price_quanzhou.quantize(Decimal('0.00'), decimal.ROUND_HALF_UP) if price_quanzhou else 0, + price_zhangzhou=price_zhangzhou.quantize(Decimal('0.00'), decimal.ROUND_HALF_UP) if price_zhangzhou else 0, + price_nanpin=price_nanpin.quantize(Decimal('0.00'), decimal.ROUND_HALF_UP) if price_nanpin else 0, + price_longyan=price_longyan.quantize(Decimal('0.00'), decimal.ROUND_HALF_UP) if price_longyan else 0, + price_ningde=price_ningde.quantize(Decimal('0.00'), decimal.ROUND_HALF_UP) if price_ningde else 0, + price_pintan=price_pintan.quantize(Decimal('0.00'), decimal.ROUND_HALF_UP) if price_pintan else 0, + price_zhangzhoukfq=price_zhangzhoukfq.quantize(Decimal('0.00'), decimal.ROUND_HALF_UP) if price_zhangzhoukfq else 0, tax=self.tax_map.get(material_id, 0), # 从材料表获取税率 type=2, unit=self.unit_map.get(material_id, ''),