DeepLearning101 commited on
Commit
cb67f44
·
verified ·
1 Parent(s): a572c5d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -4
main.py CHANGED
@@ -326,14 +326,19 @@ async def repay_payment(payload: RepayPayload):
326
  raise HTTPException(status_code=500, detail=str(e))
327
 
328
  def notify_boss(name, tel, date, time, pax, amount):
329
- if not LINE_ACCESS_TOKEN or not BOSS_LINE_ID: return
 
 
330
  msg = f"🔔 【新訂單通知】\n姓名:{name}\n電話:{tel}\n時間:{date} {time}\n人數:{pax}位"
331
  if amount > 0: msg += f"\n💰 已收到線上付款:${amount}"
332
-
333
  headers = {"Authorization": f"Bearer {LINE_ACCESS_TOKEN}"}
334
  payload = {"to": BOSS_LINE_ID, "messages": [{"type": "text", "text": msg}]}
335
- try: requests.post("https://api.line.me/v2/bot/message/push", headers=headers, json=payload)
336
- except: pass
 
 
 
337
 
338
  # 🌟 新增:郵件發送 API (供 ADMIN 呼叫)
339
  class EmailPayload(BaseModel):
 
326
  raise HTTPException(status_code=500, detail=str(e))
327
 
328
  def notify_boss(name, tel, date, time, pax, amount):
329
+ if not LINE_ACCESS_TOKEN or not BOSS_LINE_ID:
330
+ print(f"⚠️ notify_boss 跳過:LINE_ACCESS_TOKEN={'有' if LINE_ACCESS_TOKEN else '無'}, BOSS_LINE_ID={'有' if BOSS_LINE_ID else '無'}")
331
+ return
332
  msg = f"🔔 【新訂單通知】\n姓名:{name}\n電話:{tel}\n時間:{date} {time}\n人數:{pax}位"
333
  if amount > 0: msg += f"\n💰 已收到線上付款:${amount}"
334
+
335
  headers = {"Authorization": f"Bearer {LINE_ACCESS_TOKEN}"}
336
  payload = {"to": BOSS_LINE_ID, "messages": [{"type": "text", "text": msg}]}
337
+ try:
338
+ r = requests.post("https://api.line.me/v2/bot/message/push", headers=headers, json=payload)
339
+ print(f"✅ notify_boss LINE 回應:{r.status_code} {r.text}")
340
+ except Exception as e:
341
+ print(f"❌ notify_boss LINE 發送失敗:{e}")
342
 
343
  # 🌟 新增:郵件發送 API (供 ADMIN 呼叫)
344
  class EmailPayload(BaseModel):