feat: add PPT shortcut buttons after sales & trend query results
Previously after querying sales or trend data, there were no direct PPT generation buttons — users had to navigate back to 簡報報表 menu. Changes: 1. sales_quick_kb(date_str): + [📊 產出日報 PPT] → cmd:ppt:daily <date> + [📄 策略簡報] → cmd:ppt:strategy <date> 2. trend ≤35 days (weekly/monthly view): + [📊 產出趨勢簡報] → cmd:ppt:strategy <start_date> + [📅 產出日報 PPT] → cmd:ppt:daily <end_date> + [← 返回業績查詢] → menu:sales 3. trend >35 days (quarterly/half-year/yearly view): + [📊 產出趨勢簡報] → cmd:ppt:strategy <period> + [📅 月報 PPT] → cmd:ppt:monthly <month> + [← 返回業績查詢] → menu:sales
This commit is contained in:
@@ -3169,6 +3169,8 @@ def sales_quick_kb(date_str):
|
||||
return [
|
||||
[{'text': '⬅️ 昨日業績', 'callback_data': f'cmd:sales:{yesterday}'},
|
||||
{'text': '🏆 熱銷商品', 'callback_data': f'cmd:top:{date_str}'}],
|
||||
[{'text': '📊 產出日報 PPT', 'callback_data': f'cmd:ppt:daily {date_str}'},
|
||||
{'text': '📄 策略簡報', 'callback_data': f'cmd:ppt:strategy {date_str}'}],
|
||||
[{'text': '📋 完整報表', 'callback_data': f'cmd:report:{date_str}'}],
|
||||
]
|
||||
except Exception:
|
||||
@@ -4311,7 +4313,13 @@ def handle_cmd(cmd, arg, chat_id, reply_to):
|
||||
|
||||
if days_count <= 35:
|
||||
# 週/月:逐日文字 + 折線圖
|
||||
send_message(chat_id, fmt_trend(data, period_label), reply_to, _submenu_trend())
|
||||
_trend_kb_short = [
|
||||
[{'text': '📊 產出趨勢簡報', 'callback_data': f'cmd:ppt:strategy {start_str}'},
|
||||
{'text': '📅 產出日報 PPT', 'callback_data': f'cmd:ppt:daily {end_str}'}],
|
||||
[{'text': '🔄 加載新趨勢', 'callback_data': f'cmd:trend:{sub}'},
|
||||
{'text': '← 返回業績查詢', 'callback_data': 'menu:sales'}],
|
||||
]
|
||||
send_message(chat_id, fmt_trend(data, period_label), reply_to, _trend_kb_short)
|
||||
try:
|
||||
png = gen_trend_chart(data_points=data, title=chart_title)
|
||||
if png:
|
||||
@@ -4323,7 +4331,21 @@ def handle_cmd(cmd, arg, chat_id, reply_to):
|
||||
else:
|
||||
# 季/半年/年:摘要 + 聚合柱狀圖(不洗版面)
|
||||
granularity = 'monthly' if days_count > 100 else 'weekly'
|
||||
send_message(chat_id, fmt_trend_summary(data, period_label), reply_to, _submenu_trend())
|
||||
# 決定働用 strategy 簡報的期間標籤
|
||||
if sub in ('quarter', 'quarterly', '季'):
|
||||
ppt_sub = 'quarterly'
|
||||
elif sub in ('half', '半年'):
|
||||
ppt_sub = 'half'
|
||||
elif sub in ('year', 'yearly', '年'):
|
||||
ppt_sub = 'yearly'
|
||||
else:
|
||||
ppt_sub = 'weekly'
|
||||
_trend_kb_long = [
|
||||
[{'text': '📊 產出趨勢簡報', 'callback_data': f'cmd:ppt:strategy {ppt_sub}'},
|
||||
{'text': '📅 月報 PPT', 'callback_data': f'cmd:ppt:monthly {start_str[:7].replace("/","/")}'}],
|
||||
[{'text': '← 返回業績查詢', 'callback_data': 'menu:sales'}],
|
||||
]
|
||||
send_message(chat_id, fmt_trend_summary(data, period_label), reply_to, _trend_kb_long)
|
||||
try:
|
||||
png = gen_aggregated_chart(data, chart_title, granularity=granularity)
|
||||
if png:
|
||||
|
||||
Reference in New Issue
Block a user