Kaynağa Gözat

fix(onsale): 解决 soldCount 为 0 时误发结束战报问题

- 对 soldCount==0 的车辆流进行特殊处理,不再发送结束战报
- 该类车辆为上架无人问津,被商家撤下或到期的流车,购买记录为空
- 修正旧逻辑误将结束状态虚报为售出多件的情况
- 在 soldCount 明确为 0 时静默处理,并置位 ended_notified 避免重复播报
- soldCount 缺失时依旧正常播报以防止抓取抖动误判
charley 2 hafta önce
ebeveyn
işleme
b5b74c8f0c
1 değiştirilmiş dosya ile 10 ekleme ve 0 silme
  1. 10 0
      deca_spider/onsale_alert_spider.py

+ 10 - 0
deca_spider/onsale_alert_spider.py

@@ -495,6 +495,16 @@ def _detect_and_report_ended(log, pool, existing: dict, onsale_codes: set):
         if not ended:
             log.info(f"[疑似消失未确认结束] {code} 详情仍在售或取详情失败,跳过(可能抓取抖动) | {info['title']}")
             continue
+        # 【2026/08/31】soldCount==0 的车不发结束战报:这类是「上架后无人问津、被商家撤下或到 saleEndAt
+        # 到期」的流车,从没成交(既不在在售 is_on_sale=0、也不在已售成交列表),购买记录必空。旧逻辑
+        # 「结束即全部售出」会把它虚报成「售出<总份数>件 / 0 人参与拆卡」,属误发(主公反馈老是误发)。
+        # 故 soldCount==0 时静默不发,并置位 ended_notified 停止下轮重复对账/重打详情。
+        # 只在详情明确返回 soldCount==0 时静默;soldCount 缺失(None)不静默,保守走正常播报,防抓取抖动误吞真售罄车。
+        sold_now = data.get("soldCount")
+        if sold_now == 0:
+            _mark_ended_notified(pool, code)
+            log.info(f"[结束静默] {code} soldCount=0 流车(无人成交/撤下),不发战报并置位防重扫 | {info['title']}")
+            continue
         # 售出件数=总份数(结束即全部售出):优先详情最新 cardCount,缺失回退库内旧值
         card = data.get("cardCount")
         if card is None: