空运未填报价日期时不默认当天,查出舱位后由销售点选再写回日期。

包装类型里的托盘不再被抄进增值服务。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-13 18:35:52 +08:00
co-authored by Cursor
parent dda210c219
commit 7ef4a1b1cf
21 changed files with 1068 additions and 58 deletions
+122 -1
View File
@@ -255,10 +255,131 @@ def option_total(option: dict[str, Any] | None, quote: dict[str, Any] | None = N
return text
# TMS 舱位「班期」可能用的键。页面只展示第一个非空值,例如 D234567,不翻译。
_SCHEDULE_KEYS = (
"班期",
"schedule",
"flightSchedule",
"flight_schedule",
"frequency",
"weekFrequency",
"scheduleDays",
"operatingDays",
"flightFrequency",
"departureSchedule",
"scheduleCode",
"flightPeriod",
"frequencyCode",
)
def option_flight_date(option: dict[str, Any] | None) -> str:
"""
舱位上的航班日期。优先 flightDate,其次从起飞时间取日期。
没有则空串。不编当天。
"""
src = dict(option or {})
for key in ("flightDate", "flight_date", "departureDate", "departure_date"):
text = str(src.get(key) or "").strip()
if text:
return _date_head(text)
return _date_head(str(src.get("departureTime") or src.get("departure_time") or ""))
def _date_head(raw: str) -> str:
"""yyyy-MM-dd 开头就取日期,否则原样。空串保持空。"""
text = (raw or "").strip()
if len(text) >= 10 and text[4] == "-" and text[7] == "-":
return text[:10]
return text
def option_schedule(option: dict[str, Any] | None) -> str:
"""班期按 TMS 原样,例如 D234567。没有就空串,不编。"""
src = dict(option or {})
for key in _SCHEDULE_KEYS:
text = str(src.get(key) or "").strip()
if text:
return text
return ""
def option_airline(option: dict[str, Any] | None) -> str:
"""航司:有中文名用中文名,否则用代码。没有就空串。"""
src = dict(option or {})
for key in ("airlineName", "airline", "airlineCode", "carrier"):
text = str(src.get(key) or "").strip()
if text:
return text
return ""
def option_endpoint_name(
option: dict[str, Any] | None,
side: str,
facts: dict[str, str] | None = None,
) -> str:
"""
舱位起运地或目的地。三字码能对上就用中文,对不上展示代码。
side 取 origin / destination。不编城市。
"""
src = dict(option or {})
facts = facts or {}
if side == "destination":
code = str(src.get("destinationAirportCode") or src.get("destination") or "")
fallback = str(facts.get("目的港") or facts.get("目的地") or "")
else:
code = str(src.get("originAirportCode") or src.get("origin") or "")
fallback = str(facts.get("起运港") or facts.get("起运地") or "")
return _place_name(code, fallback)
def _price_sort_value(option: dict[str, Any]) -> float:
"""总价排序用。解析不出的排到同一天最后。"""
raw = option.get("salePrice")
if raw is None or str(raw).strip() == "":
return float("inf")
num = ""
for ch in str(raw).replace(",", ""):
if ch.isdigit() or ch == ".":
num += ch
elif num:
break
try:
return float(num) if num else float("inf")
except ValueError:
return float("inf")
def sort_cabin_options(options: list[dict[str, Any]] | None) -> list[dict[str, Any]]:
"""
没填报价日期时的舱位顺序:航班日期从早到晚,同一天总价从低到高。
没有日期的排在最后。不改入参。
"""
rows = [dict(item) for item in list(options or [])]
def _key(item: dict[str, Any]) -> tuple[str, float]:
day = option_flight_date(item) or "9999-99-99"
return (day, _price_sort_value(item))
return sorted(rows, key=_key)
def apply_selected_option(facts: dict[str, str] | None, option: dict[str, Any] | None) -> dict[str, str]:
"""选定线路后写回起运港(及能对上的三字码)。改选覆盖。"""
"""
选定舱位后写回起运港(及能对上的三字码)。改选覆盖。
工单还没有报价日期时,把这条的航班日期写回去,供报价单和锁舱使用。
销售已经说了日期则不覆盖。
"""
merged = dict(facts or {})
src = dict(option or {})
flight_date = option_flight_date(src)
if flight_date and not str(merged.get("报价日期") or "").strip():
merged["报价日期"] = flight_date
code = str(src.get("originAirportCode") or src.get("origin") or "").strip().upper()
name = _place_name(code)
if name: