fix(api): 修复创建商品时条码保存有误的问题
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ching 2024-09-25 22:15:45 +08:00
parent fe3b5596d3
commit 3ced4879bc

6
app.py
View File

@ -121,7 +121,7 @@ def add_product(dict_good, location):
if dict_good["gtin"].startswith("0"):
data_barcode = {
"product_id": int(response_grocy["created_object_id"]),
"barcode": dict_good["gtin"].strip("0"),
"barcode": dict_good["gtin"].lstrip("0"),
}
grocy.add_generic(EntityType.PRODUCT_BARCODES, data_barcode)
@ -382,13 +382,13 @@ def consume_stream():
logger.info(f"Skip non-numeric barcode: {msg['data']}")
continue
_, status_code = handle_add_product(msg['data'], '')
resp, status_code = handle_add_product(msg['data'], '')
if status_code == 200:
# 消费完成后确认消息
r.xack(STREAM_KEY, CONSUMER_GROUP, msg_id)
bark_push('商品添加成功', '条形码 %s' % msg['data'])
else:
logger.error(f"Failed to process message: {msg['data']}")
logger.error(f"Failed to process message: {msg['data']} {resp}")
bark_push('商品添加失败', '条形码 %s' % msg['data'])
except Exception as e: