diff --git a/config.py b/config.py index 4a30dc9..5857db9 100644 --- a/config.py +++ b/config.py @@ -402,7 +402,7 @@ YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY', '') # ========================================== # 系統版本與路徑 # ========================================== -SYSTEM_VERSION = "V10.638" +SYSTEM_VERSION = "V10.639" LOG_FILE_PATH = os.path.join(BASE_DIR, 'logs/system.log') public_url = PUBLIC_URL # 用於模板顯示 diff --git a/docs/AI_INTELLIGENCE_MODULE_SOT.md b/docs/AI_INTELLIGENCE_MODULE_SOT.md index 2041fbb..9ebb070 100644 --- a/docs/AI_INTELLIGENCE_MODULE_SOT.md +++ b/docs/AI_INTELLIGENCE_MODULE_SOT.md @@ -74,6 +74,7 @@ - V10.622 起任何 `external_offers` 自動同步成功寫入後,必須呼叫 `mark_pchome_growth_cache_stale()` 寫入共享 cache epoch;`/api/ai/pchome-growth/opportunities` 讀快取前必須比對 `get_pchome_growth_cache_epoch()`。這是跨 Gunicorn worker 的可見性保護,避免自動候選已進外部價格參考,但 AI 情報頁仍回 120 秒舊作戰清單。 - V10.623 起 `/price_comparison` 與 `/ai_intelligence` 不得只靠大段文字說明流程:比價頁第一屏必須有主 KPI、目前卡點、四步流程與結果決策摘要;作戰頁第一屏必須有今日任務、可立即處理、待補比價與最新業績日。所有狀態都要由實際 API/前端狀態驅動,讓使用者一眼知道下一步要按哪個動作。 - V10.638 起 PChome 導向 MOMO 補抓會把「找到但不能自動比價」的候選以 `match_status='needs_review'`、`data_quality_status='needs_review'` 保存到 `external_offers`;這些候選不得進價格壓力判斷,也不得發告警,但 `/api/ai/pchome-growth/opportunities` 可回傳待確認候選數,讓 UI 顯示「已有候選待確認」而不是只顯示無法比價。 +- V10.639 起待確認候選排序必須容忍缺少單位數量;沒有 `momo_total_quantity` / `competitor_total_quantity` 時仍可保存為 `needs_review`,不得中斷 PChome 導向 MOMO 回填。 ## 零之一、12 Agent 決策信封(2026-05-24) diff --git a/services/external_market_offer_service.py b/services/external_market_offer_service.py index 38b6673..1e5e6f9 100644 --- a/services/external_market_offer_service.py +++ b/services/external_market_offer_service.py @@ -726,8 +726,8 @@ def _targeted_candidate_sync_rank(candidate: dict[str, Any]) -> tuple[float, flo if isinstance(candidate.get("target_unit_price_comparison"), dict) else {} ) - momo_total = _to_float(unit_price_comparison.get("momo_total_quantity")) - pchome_total = _to_float(unit_price_comparison.get("competitor_total_quantity")) + momo_total = _to_float(unit_price_comparison.get("momo_total_quantity")) or 0.0 + pchome_total = _to_float(unit_price_comparison.get("competitor_total_quantity")) or 0.0 quantity_delta = 999999.0 same_quantity = 0.0 if momo_total > 0 and pchome_total > 0: