fix: 修正每日营收任务逻辑并更新配置
修复daily_job函数中的逻辑错误,确保正确检查和处理已存在的营收记录 将config.json中的cutoff_hour和cutoff_time更新为00:00
This commit is contained in:
parent
4a3e39d76d
commit
fb546861b5
1
app.log
1
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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -11,6 +11,6 @@
|
||||
1600,
|
||||
2000
|
||||
],
|
||||
"cutoff_hour": 13,
|
||||
"cutoff_time": "13:18"
|
||||
"cutoff_hour": 0,
|
||||
"cutoff_time": "00:00"
|
||||
}
|
||||
|
||||
BIN
data/data.db
BIN
data/data.db
Binary file not shown.
Loading…
Reference in New Issue
Block a user