fix: 修正每日营收任务逻辑并更新配置

修复daily_job函数中的逻辑错误,确保正确检查和处理已存在的营收记录
将config.json中的cutoff_hour和cutoff_time更新为00:00
This commit is contained in:
2025-12-10 01:01:05 +08:00
parent 4a3e39d76d
commit fb546861b5
4 changed files with 13 additions and 14 deletions
+10 -12
View File
@@ -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)