From fb546861b5a1824c0ca628c02b3e9a1dd5085c70 Mon Sep 17 00:00:00 2001 From: houhuan Date: Wed, 10 Dec 2025 01:01:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E6=AF=8F=E6=97=A5?= =?UTF-8?q?=E8=90=A5=E6=94=B6=E4=BB=BB=E5=8A=A1=E9=80=BB=E8=BE=91=E5=B9=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复daily_job函数中的逻辑错误,确保正确检查和处理已存在的营收记录 将config.json中的cutoff_hour和cutoff_time更新为00:00 --- app.log | 1 + backend/app.py | 22 ++++++++++------------ config.json | 4 ++-- data/data.db | Bin 16384 -> 16384 bytes 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/app.log b/app.log index 6ad123d..80fe152 100644 --- a/app.log +++ b/app.log @@ -3,3 +3,4 @@ 准备发送消息: 【益选便利店】2025-12-08的营业额:3629.76 准备发送消息: 【益选便利店】2025-12-06的营业额:1803.09 准备发送消息: 【益选便利店】2025-12-09的营业额:3462.53 +准备发送消息: 【益选便利店】2025-12-10的营业额:3222.85 diff --git a/backend/app.py b/backend/app.py index c130631..b09f9c3 100644 --- a/backend/app.py +++ b/backend/app.py @@ -106,18 +106,16 @@ def daily_job(target_date=None): shop_name = cfg.get("shop_name", "益选便利店") if target_date is None: target_date = datetime.now().date() - - existing = DailyRevenue.query.filter_by(date=target_date).first() - if existing: - if not existing.is_final: - existing.is_final = True - existing.source = existing.source or 'generator' - db.session.commit() - push_feishu(target_date.isoformat(), existing.amount, "daily_finalize") - else: - push_feishu(target_date.isoformat(), existing.amount, "daily_exists") - return - + existing = DailyRevenue.query.filter_by(date=target_date).first() + if existing: + if not existing.is_final: + existing.is_final = True + existing.source = existing.source or 'generator' + db.session.commit() + push_feishu(target_date.isoformat(), existing.amount, "daily_finalize") + else: + push_feishu(target_date.isoformat(), existing.amount, "daily_exists") + return amount = gen_amount_for_date(target_date, cfg) rev = DailyRevenue(date=target_date, amount=amount, is_final=True, source='generator') db.session.add(rev) diff --git a/config.json b/config.json index 92d00ed..54596ab 100644 --- a/config.json +++ b/config.json @@ -11,6 +11,6 @@ 1600, 2000 ], - "cutoff_hour": 13, - "cutoff_time": "13:18" + "cutoff_hour": 0, + "cutoff_time": "00:00" } diff --git a/data/data.db b/data/data.db index d11dbbffef27b2552eb45a614fefdee62820745d..34efa17cc2071f783161a5986f21527b259def3e 100644 GIT binary patch delta 250 zcmZo@U~Fh$oFL7}Hc`fzk!@qb5`I2bJ{t!9rTkueANZ#6*=!aR(Bg}VVC7^`WOw9r zlxHw9Ff!FOG}1LRa9F9k*%%05A_kTUhGtf#mO!LuW@2GtV1!e~Bt11RwJ5P9zi9I` zxjaTbR{m`a{8#ut@jvE2%D-*1pu!Se~a|mde1toQzG)2nOZmO{KJZQ3tf-ppOx%qYgC06il-eKp#2mr~I8`%H=