优化金额处理

This commit is contained in:
2024-10-15 11:29:06 +08:00
parent 5af6256376
commit b332aa00dd

View File

@@ -9,8 +9,14 @@ from util import common_util
def handle_decimal(string): def handle_decimal(string):
if not string: if not string:
return '' return ''
original_string = string
string = re.sub(r'[^0-9.]', '', string) string = re.sub(r'[^0-9.]', '', string)
if not string: if not string:
# 可能抓到大写金额了,尝试用大写金额解析
try:
return common_util.chinese_money_to_number(original_string)
except Exception as e:
logging.warning('大写金额解析失败', exc_info=e)
return '' return ''
if '.' not in string: if '.' not in string:
if len(string) > 2: if len(string) > 2: