polish: 本地回写失败不再报「还车失败」+ 清理死分支

1) order_return 本地回写裸奔
- _record_rental_end / _record_raw_coords 各自包 try/except,只记日志;
  仍然返回 rtn_code 0 + 「(本地记录稍后同步)」+ local_synced=False。
  原来 SQLite 忙的时候直接 500 → 前端「还车失败」,用户再点一次撞 204010

2) 管理端兜底 UPDATE 也包住
- 按 rental_id 的兜底 UPDATE 单独 try/except;失败同样返回成功 + warning,
  避免管理员重复点、第二次拿到「订单信息不存在」

3) _recover_overdue_rental 死分支
- 函数开头已有 _should_auto_return 的 return,后面的三元 else 永远走不到,
  直接写 _run_recovery(...)

测试:156 pytest(新增用户端/管理端「本地写库失败仍报成功」2 条)+ 32 node 全绿
This commit is contained in:
zzy
2026-11-15 18:57:20 +08:00
parent 9b1aac9942
commit 9bdef68650
5 changed files with 97 additions and 16 deletions
+1 -2
View File
@@ -916,8 +916,7 @@ def _recover_overdue_rental(rental: dict):
if not user_id:
print(f"[计时系统] rental_id={rental_id} 没有 user_id,跳过补还车")
return
result = _run_recovery(rental_id, user_id) if _should_auto_return(rental) \
else auto_return_bike(rental_id, user_id)
result = _run_recovery(rental_id, user_id)
print(f"[计时系统] 补还车结果 rental_id={rental_id}: {result.get('message')}")
except Exception as exc:
print(f"[计时系统] 补还车异常 rental_id={rental_id}: {exc}")