python-qdairlines-helper 0.2.6__py3-none-any.whl → 0.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_qdairlines_helper-0.2.6.dist-info → python_qdairlines_helper-0.6.0.dist-info}/METADATA +4 -4
- python_qdairlines_helper-0.6.0.dist-info/RECORD +36 -0
- qdairlines_helper/config/url_const.py +4 -0
- qdairlines_helper/controller/add_passenger.py +1 -1
- qdairlines_helper/controller/book_payment.py +28 -26
- qdairlines_helper/controller/book_search.py +37 -29
- qdairlines_helper/controller/cash_pax_info.py +1 -1
- qdairlines_helper/controller/home.py +1 -1
- qdairlines_helper/controller/nhlms_cashdesk.py +13 -10
- qdairlines_helper/controller/order_detail.py +42 -17
- qdairlines_helper/controller/order_query.py +1 -1
- qdairlines_helper/controller/order_verify.py +11 -2
- qdairlines_helper/controller/pay_success.py +8 -17
- qdairlines_helper/controller/user_login.py +37 -2
- qdairlines_helper/http/flight_order.py +5 -41
- qdairlines_helper/http/http_base.py +54 -0
- qdairlines_helper/http/user_login.py +43 -0
- qdairlines_helper/po/add_passenger_page.py +1 -1
- qdairlines_helper/po/book_search_page.py +79 -8
- qdairlines_helper/po/cash_pax_info_page.py +1 -1
- qdairlines_helper/po/nhlms_cash_desk_page.py +42 -1
- qdairlines_helper/po/order_verify_page.py +41 -2
- python_qdairlines_helper-0.2.6.dist-info/RECORD +0 -35
- qdairlines_helper/utils/exception_utils.py +0 -105
- {python_qdairlines_helper-0.2.6.dist-info → python_qdairlines_helper-0.6.0.dist-info}/WHEEL +0 -0
- {python_qdairlines_helper-0.2.6.dist-info → python_qdairlines_helper-0.6.0.dist-info}/licenses/LICENSE +0 -0
- {python_qdairlines_helper-0.2.6.dist-info → python_qdairlines_helper-0.6.0.dist-info}/top_level.txt +0 -0
{python_qdairlines_helper-0.2.6.dist-info → python_qdairlines_helper-0.6.0.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python_qdairlines_helper
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: qdairlines helper python package
|
|
5
5
|
Author-email: ckf10000 <ckf10000@sina.com>
|
|
6
6
|
License: Apache License
|
|
@@ -210,9 +210,9 @@ Project-URL: Issues, https://github.com/ckf10000/python-qdairlines-helper/issues
|
|
|
210
210
|
Requires-Python: >=3.12
|
|
211
211
|
Description-Content-Type: text/markdown
|
|
212
212
|
License-File: LICENSE
|
|
213
|
-
Requires-Dist: python_playwright_helper>=0.3
|
|
214
|
-
Requires-Dist: python_http_helper>=0.2.
|
|
215
|
-
Requires-Dist: flight_helper>=0.
|
|
213
|
+
Requires-Dist: python_playwright_helper>=0.4.3
|
|
214
|
+
Requires-Dist: python_http_helper>=0.2.2
|
|
215
|
+
Requires-Dist: flight_helper>=0.3.7
|
|
216
216
|
Dynamic: license-file
|
|
217
217
|
|
|
218
218
|
# python-qdairlines-helper
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
python_qdairlines_helper-0.6.0.dist-info/licenses/LICENSE,sha256=WtjCEwlcVzkh1ziO35P2qfVEkLjr87Flro7xlHz3CEY,11556
|
|
2
|
+
qdairlines_helper/__init__.py,sha256=bN1FqEK_jvefO_HU_8HFJpjuOzHTsuhmRe5KAzmraR4,479
|
|
3
|
+
qdairlines_helper/config/__init__.py,sha256=JjIRocePx3gwFNpdauuiwBU6B2Ug565xaHLEMu5Oo0I,479
|
|
4
|
+
qdairlines_helper/config/url_const.py,sha256=KpvvZEPOsJ7FQdJLp79VfUdUSRuItR4OYYCzl8wfKZI,2194
|
|
5
|
+
qdairlines_helper/controller/__init__.py,sha256=oyeciEBlDLNpqHblB0R-nXQG3HsI8L5mmlWulQ7Y38Q,482
|
|
6
|
+
qdairlines_helper/controller/add_passenger.py,sha256=qixajF_MRzmMZ9htAFeGCP3L27iV1Xk-jnfPQEP48s8,5155
|
|
7
|
+
qdairlines_helper/controller/book_payment.py,sha256=yk1A99yHAjVcnXGBSzGanA6Cle4NXwjt6e8Qx4W2Xi0,6184
|
|
8
|
+
qdairlines_helper/controller/book_search.py,sha256=qSsjyn6BgJc5yP-mf2mNIDkEPsG_PTUffH4cEAZFsl8,9267
|
|
9
|
+
qdairlines_helper/controller/cash_pax_info.py,sha256=AZ09ekt-zaYYs3uUSclul014mbCZEF5BVIghOeIGT5s,2507
|
|
10
|
+
qdairlines_helper/controller/home.py,sha256=2r75pe7d16kZ6tkJZ3zM5ycV-DE5iy3njhpE0xf1EZw,1390
|
|
11
|
+
qdairlines_helper/controller/nhlms_cashdesk.py,sha256=Z5ApNGAzYWgBn43zcTqt42h1cFABLtfEDKWTIWSXsAA,4421
|
|
12
|
+
qdairlines_helper/controller/order_detail.py,sha256=hhL37PiozS1jALMk_eB0vg0eigW_Rcl_mf0l-QrW21o,4337
|
|
13
|
+
qdairlines_helper/controller/order_query.py,sha256=7U6S5xlT89UJHFslDbUT5VRgGlAoPQSOi4NRtEKK9xQ,1903
|
|
14
|
+
qdairlines_helper/controller/order_verify.py,sha256=lx2YpDUoooCkU596IEz4kwyJsev-dHskBLHJ4v3d1Rg,2670
|
|
15
|
+
qdairlines_helper/controller/pay_success.py,sha256=J0yWSarIlce4cVXdqZyURWm-DwujTqg32al5JTe5flA,2837
|
|
16
|
+
qdairlines_helper/controller/user_login.py,sha256=CNuPIpGlkk5uU9ltL3DtTgC2SK6K32yA-K0Q-Kxe3MM,6267
|
|
17
|
+
qdairlines_helper/http/__init__.py,sha256=96AJPf2zgw_rm3Wv-boIBltWFgZH3Yo-fn5M9SRK280,489
|
|
18
|
+
qdairlines_helper/http/flight_order.py,sha256=7NTUA8xt6gwPBH7gdU3VjUoBa9LpPAvAEzkWguLPrNk,2066
|
|
19
|
+
qdairlines_helper/http/http_base.py,sha256=zWSgJfyMaekHyvV4lJD-KHiCX9BN3GGb8DperyVpRGQ,2492
|
|
20
|
+
qdairlines_helper/http/user_login.py,sha256=S_thG1RLXv5x5MQJmEG-oo38ReIF3_p17hVwGqs61A8,1815
|
|
21
|
+
qdairlines_helper/po/__init__.py,sha256=HoouLJGLu_dI6IAKTVjBRraGHMcAUgntayTph-BUBAE,481
|
|
22
|
+
qdairlines_helper/po/add_passenger_page.py,sha256=no_QC4hwO7xuZXKLzakNlcWj2R06oVZdzKHvFHsBG5Y,7996
|
|
23
|
+
qdairlines_helper/po/air_order_page.py,sha256=0Ux0B2hUGKCoFLRpJqGHS2w690o0A2PDnvRf9-UKfJE,930
|
|
24
|
+
qdairlines_helper/po/book_search_page.py,sha256=Id4sqpmIQvgxTcESh-3dpCG5ccigkL6VrNLbZPf1gq0,14547
|
|
25
|
+
qdairlines_helper/po/cash_pax_info_page.py,sha256=yH-ZedYweby1x3Sw3JZX6a57-8PdtQHmNKqym7cn-Xo,3397
|
|
26
|
+
qdairlines_helper/po/home_page.py,sha256=KvoOZOYwKjlJjZOT522K_8ic3_2zaYOPWkuklUHVSlM,907
|
|
27
|
+
qdairlines_helper/po/login_page.py,sha256=SdWmkP_47GeosbFRcfvXLeQxxdM7b9UESvmajWq4-nA,2975
|
|
28
|
+
qdairlines_helper/po/nhlms_cash_desk_page.py,sha256=I2FdZvEfEiN9pbD6nZ7VquO1ZMg9zUJjVkStx9eat0M,6670
|
|
29
|
+
qdairlines_helper/po/order_verify_page.py,sha256=PlDZ-WbZBwV7pjjuQjXuMrYXAvys0Uas2FncXitsBLs,4978
|
|
30
|
+
qdairlines_helper/po/pay_success_page.py,sha256=XGddo8as8wf1kCCdvemqHIRWOPIPv1JG8iXEmpH4zck,1329
|
|
31
|
+
qdairlines_helper/utils/__init__.py,sha256=sti2S709puM2mQbQisk0KGq_YNjW6T4zz2vyYXonNB0,479
|
|
32
|
+
qdairlines_helper/utils/po_utils.py,sha256=74ZVyyxPmPk1tcGQoMauXhBE3qsZJej8urni1ch27io,2417
|
|
33
|
+
python_qdairlines_helper-0.6.0.dist-info/METADATA,sha256=WtDdd9E0T432X1X5uzk-HRnEt6U2s5OBVrVcV1nXEeE,14424
|
|
34
|
+
python_qdairlines_helper-0.6.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
35
|
+
python_qdairlines_helper-0.6.0.dist-info/top_level.txt,sha256=MRbQkBMdSG4f5mx2RWfu6aXoDSyM-2KwL-YFqNBdbng,18
|
|
36
|
+
python_qdairlines_helper-0.6.0.dist-info/RECORD,,
|
|
@@ -26,6 +26,10 @@ order_verify_url: str = "/book/orderVerify"
|
|
|
26
26
|
cash_pax_info_url: str = "/book/cashPaxInfoInput"
|
|
27
27
|
# https://nhlms.cloudpnr.com/nobel/WebEntry.do 汇付天下收银台
|
|
28
28
|
nhlms_cashdesk_url: str = "/nobel/WebEntry.do"
|
|
29
|
+
# https://nhlms.cloudpnr.com/nobel/n1026/error?RegionId=P
|
|
30
|
+
nhlms_error_url: str = "/nobel/n1026/error"
|
|
31
|
+
|
|
32
|
+
|
|
29
33
|
# https://excashier.alipay.com/standard/auth.htm?payOrderId=4e3606b1c842414c88f631c35952a88e.85 支付宝收银台
|
|
30
34
|
alipay_url: str = "/standard/auth.htm"
|
|
31
35
|
# https://www.qdairlines.com/book/payPreCash?orderNo=OW20260105B1154687 微信支付收银台
|
|
@@ -14,8 +14,8 @@ from logging import Logger
|
|
|
14
14
|
from playwright.async_api import Page
|
|
15
15
|
import qdairlines_helper.config.url_const as url_const
|
|
16
16
|
from flight_helper.models.dto.passenger import PassengerDTO
|
|
17
|
+
from flight_helper.utils.exception_utils import IPBlockError
|
|
17
18
|
from flight_helper.models.dto.booking import BookingInputDTO
|
|
18
|
-
from qdairlines_helper.utils.exception_utils import IPBlockError
|
|
19
19
|
from qdairlines_helper.po.add_passenger_page import AddPassengerPage
|
|
20
20
|
from qdairlines_helper.utils.po_utils import get_ip_access_blocked_msg
|
|
21
21
|
|
|
@@ -16,10 +16,10 @@ from typing import Any, List, Callable, Optional, Dict
|
|
|
16
16
|
from flight_helper.models.dto.passenger import PassengerDTO
|
|
17
17
|
from flight_helper.models.dto.itinerary import QueryItineraryRequestDTO
|
|
18
18
|
from qdairlines_helper.controller.pay_success import two_check_pay_success
|
|
19
|
-
from qdairlines_helper.utils.exception_utils import PaymentChannelMissError
|
|
20
19
|
from flight_helper.models.dto.booking import BookingInputDTO, OneWayBookingDTO
|
|
21
20
|
from qdairlines_helper.controller.book_search import open_book_search_page, book_search
|
|
22
21
|
from qdairlines_helper.controller.order_verify import load_order_verify_po, order_verify
|
|
22
|
+
from flight_helper.utils.exception_utils import PaymentChannelMissError, PaymentTypeError
|
|
23
23
|
from flight_helper.models.dto.payment import HFPaidAccountPaymentInputDTO, PaymentResultDTO
|
|
24
24
|
from qdairlines_helper.controller.add_passenger import add_passenger, load_add_passenger_po
|
|
25
25
|
from qdairlines_helper.controller.cash_pax_info import load_cash_pax_info_po, select_payment_channel
|
|
@@ -27,10 +27,10 @@ from qdairlines_helper.controller.nhlms_cashdesk import load_nhlms_cash_desk_po,
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
async def book_payment_callback(
|
|
30
|
-
*, page: Page, logger: Logger,
|
|
30
|
+
*, page: Page, logger: Logger, pre_check_of_payment: Callable, book_input_dto: BookingInputDTO,
|
|
31
31
|
one_way_booking_dto: OneWayBookingDTO, passengers_dto: List[PassengerDTO], qdair_cookie: Dict[str, Any],
|
|
32
|
-
callback_get_proxy: Callable, cookie_jar: Optional[CookieJar] = None,
|
|
33
|
-
refresh_attempt: int = 3, retry: int = 0, enable_log: bool = True,
|
|
32
|
+
callback_get_proxy: Callable, qlv_cookie: Dict[str, Any], cookie_jar: Optional[CookieJar] = None,
|
|
33
|
+
timeout: float = 60.0, refresh_attempt: int = 3, retry: int = 0, enable_log: bool = True,
|
|
34
34
|
hf_paid_account_payment_dto: Optional[HFPaidAccountPaymentInputDTO] = None, **kwargs: Any
|
|
35
35
|
) -> PaymentResultDTO:
|
|
36
36
|
# 1. 打开预订搜索页面
|
|
@@ -66,7 +66,10 @@ async def book_payment_callback(
|
|
|
66
66
|
)
|
|
67
67
|
|
|
68
68
|
# 6. 校验订单
|
|
69
|
-
await order_verify(
|
|
69
|
+
await order_verify(
|
|
70
|
+
page=order_verify_po, logger=logger, refresh_attempt=refresh_attempt, timeout=timeout,
|
|
71
|
+
qdair_user_id=book_input_dto.book_login_user
|
|
72
|
+
)
|
|
70
73
|
logger.info(f"订单<{one_way_booking_dto.order_no}>,校验订单结束")
|
|
71
74
|
|
|
72
75
|
# 7. 加载支付类型页面对象
|
|
@@ -88,28 +91,27 @@ async def book_payment_callback(
|
|
|
88
91
|
domain=hf_paid_account_payment_dto.pay_domain, protocol=hf_paid_account_payment_dto.pay_protocol
|
|
89
92
|
)
|
|
90
93
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
# 10. 汇付天下操作支付
|
|
94
|
-
payment_result_dto = await hf_paid_account_payment(
|
|
95
|
-
page=nhlms_cash_desk_po, logger=logger, order_no=pre_order_no, timeout=timeout,
|
|
96
|
-
is_pay_completed_callback=is_pay_completed_callback,
|
|
97
|
-
hf_paid_account_payment_dto=hf_paid_account_payment_dto
|
|
98
|
-
)
|
|
99
|
-
logger.info(f"订单<{one_way_booking_dto.order_no}>,汇付天下操作支付结束")
|
|
100
|
-
payment_result_dto.pre_order_no = pre_order_no
|
|
94
|
+
if hf_paid_account_payment_dto.payment_type != "付款账户支付":
|
|
95
|
+
raise PaymentTypeError(payment_type=hf_paid_account_payment_dto.payment_type)
|
|
101
96
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
97
|
+
# 10. 汇付天下操作支付
|
|
98
|
+
payment_result_dto = await hf_paid_account_payment(
|
|
99
|
+
page=nhlms_cash_desk_po, logger=logger, order_no=one_way_booking_dto.order_no, timeout=timeout,
|
|
100
|
+
hf_paid_account_payment_dto=hf_paid_account_payment_dto, pre_check_of_payment=pre_check_of_payment,
|
|
101
|
+
order_id=one_way_booking_dto.order_no, qlv_cookie=qlv_cookie
|
|
102
|
+
)
|
|
103
|
+
logger.info(f"订单<{one_way_booking_dto.order_no}>,汇付天下操作支付结束")
|
|
104
|
+
payment_result_dto.pre_order_no = pre_order_no
|
|
107
105
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
106
|
+
query_dto = QueryItineraryRequestDTO(
|
|
107
|
+
payment_domain=book_input_dto.book_domain, payment_protocol=book_input_dto.book_protocol,
|
|
108
|
+
storage_state=qdair_cookie.get("storage_state"), token=qdair_cookie.get("token"),
|
|
109
|
+
pre_order_no=pre_order_no, user_id=qdair_cookie.get("user_id"), headers=qdair_cookie.get("headers")
|
|
110
|
+
)
|
|
111
|
+
await two_check_pay_success(
|
|
112
|
+
page=nhlms_cash_desk_po, logger=logger, timeout=timeout, query_dto=query_dto, retry=retry,
|
|
113
|
+
enable_log=enable_log, callback_get_proxy=callback_get_proxy, cookie_jar=cookie_jar
|
|
114
|
+
)
|
|
115
|
+
return payment_result_dto
|
|
114
116
|
else:
|
|
115
117
|
raise PaymentChannelMissError()
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
# ---------------------------------------------------------------------------------------------------------
|
|
11
11
|
"""
|
|
12
12
|
import asyncio
|
|
13
|
+
from time import time
|
|
13
14
|
from logging import Logger
|
|
14
15
|
from typing import Dict, Any, List
|
|
15
16
|
from playwright.async_api import Page, Locator
|
|
16
17
|
import qdairlines_helper.config.url_const as url_const
|
|
17
|
-
from qdairlines_helper.utils.exception_utils import IPBlockError
|
|
18
18
|
from qdairlines_helper.po.book_search_page import BookSearchPage
|
|
19
19
|
from qdairlines_helper.utils.po_utils import get_ip_access_blocked_msg
|
|
20
20
|
from flight_helper.models.dto.booking import OneWayBookingDTO, BookingInputDTO
|
|
21
|
-
from
|
|
22
|
-
|
|
21
|
+
from flight_helper.utils.exception_utils import NotEnoughTicketsError, ExcessiveProfitdError, ExcessiveLossesError, \
|
|
22
|
+
IPBlockError
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
async def open_book_search_page(
|
|
@@ -38,26 +38,18 @@ async def open_book_search_page(
|
|
|
38
38
|
return book_search_po
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
async def _book_search_dialog_handle(
|
|
42
|
-
|
|
43
|
-
):
|
|
44
|
-
|
|
45
|
-
for _ in range(3):
|
|
46
|
-
# 1. 获取页面的空数据状态, 看看当前默认状态是不是空数据页
|
|
47
|
-
await page.get_empyt_data_page(timeout=timeout)
|
|
48
|
-
logger.warning(f"航班预订查询页面,【查询机票】按钮点击完成后,没有加出来数据,尝试再次点击机票查询")
|
|
49
|
-
# 2. 页面数据没有加载出来,尝试点击 查询按钮,重新再来
|
|
50
|
-
await flight_query_btn.click(button="left")
|
|
51
|
-
await asyncio.sleep(3)
|
|
52
|
-
logger.warning(f"航班预订查询页面,【查询机票】按钮再次点击完成")
|
|
53
|
-
except (PlaywrightError, PlaywrightTimeoutError, RuntimeError, EnvironmentError, Exception,):
|
|
41
|
+
async def _book_search_dialog_handle(*, logger: Logger, page: BookSearchPage, timeout: float = 20.0) -> None:
|
|
42
|
+
end_time = time() + timeout
|
|
43
|
+
while time() < end_time:
|
|
44
|
+
await page.handle_yidun_icon(logger=logger, timeout=1)
|
|
54
45
|
try:
|
|
55
|
-
|
|
56
|
-
continue_book_btn = await page.get_reminder_dialog_continue_book_btn(timeout=timeout)
|
|
46
|
+
continue_book_btn = await page.get_reminder_dialog_continue_book_btn(timeout=1)
|
|
57
47
|
await continue_book_btn.click(button="left")
|
|
58
48
|
logger.info("航班预订查询页面,出现温馨提醒弹框,【继续购票】按钮点击完成")
|
|
59
|
-
|
|
49
|
+
return
|
|
50
|
+
except (Exception,):
|
|
60
51
|
pass
|
|
52
|
+
await asyncio.sleep(0.1) # 快速轮询
|
|
61
53
|
|
|
62
54
|
|
|
63
55
|
async def book_search(
|
|
@@ -66,17 +58,31 @@ async def book_search(
|
|
|
66
58
|
) -> None:
|
|
67
59
|
# 1.搜索栏输入起飞城市
|
|
68
60
|
depart_city_input = await book_search_page.get_depart_city_input(timeout=timeout)
|
|
69
|
-
await depart_city_input.fill(value=one_way_booking_dto.dep_code)
|
|
61
|
+
# await depart_city_input.fill(value=one_way_booking_dto.dep_code)
|
|
62
|
+
await book_search_page.simulation_input_element(
|
|
63
|
+
locator=depart_city_input, text=one_way_booking_dto.dep_code, delay=200
|
|
64
|
+
)
|
|
70
65
|
await asyncio.sleep(delay=1)
|
|
71
|
-
await depart_city_input.press("Enter")
|
|
66
|
+
# await depart_city_input.press("Enter")
|
|
67
|
+
depart_city_result = await book_search_page.get_depart_city_search_result(
|
|
68
|
+
depart_city=one_way_booking_dto.dep_city, timeout=timeout
|
|
69
|
+
)
|
|
70
|
+
await depart_city_result.click(button="left")
|
|
72
71
|
logger.info(
|
|
73
72
|
f"航班预订查询页面,搜索栏-起飞城市<{one_way_booking_dto.dep_city} {one_way_booking_dto.dep_code}>输入完成")
|
|
74
73
|
|
|
75
74
|
# 2.搜索栏输入抵达城市
|
|
76
75
|
arrive_city_input = await book_search_page.get_arrive_city_input(timeout=timeout)
|
|
77
|
-
await arrive_city_input.fill(value=one_way_booking_dto.arr_code)
|
|
76
|
+
# await arrive_city_input.fill(value=one_way_booking_dto.arr_code)
|
|
77
|
+
await book_search_page.simulation_input_element(
|
|
78
|
+
locator=arrive_city_input, text=one_way_booking_dto.arr_code, delay=200
|
|
79
|
+
)
|
|
78
80
|
await asyncio.sleep(delay=1)
|
|
79
|
-
await arrive_city_input.press("Enter")
|
|
81
|
+
# await arrive_city_input.press("Enter")
|
|
82
|
+
arrive_city_result = await book_search_page.get_arrive_city_search_result(
|
|
83
|
+
arrive_city=one_way_booking_dto.arr_city, timeout=timeout
|
|
84
|
+
)
|
|
85
|
+
await arrive_city_result.click(button="left")
|
|
80
86
|
logger.info(
|
|
81
87
|
f"航班预订查询页面,搜索栏-抵达城市<{one_way_booking_dto.arr_city} {one_way_booking_dto.arr_code}>输入完成")
|
|
82
88
|
|
|
@@ -92,10 +98,8 @@ async def book_search(
|
|
|
92
98
|
await flight_query_btn.click(button="left")
|
|
93
99
|
logger.info(f"航班预订查询页面,【查询机票】按钮点击完成")
|
|
94
100
|
|
|
95
|
-
# 5
|
|
96
|
-
await _book_search_dialog_handle(
|
|
97
|
-
logger=logger, page=book_search_page, flight_query_btn=flight_query_btn, timeout=timeout
|
|
98
|
-
)
|
|
101
|
+
# 5.点击查询后,再次处理是否有弹框,并航班基本信息plane locator
|
|
102
|
+
await _book_search_dialog_handle(logger=logger, page=book_search_page, timeout=timeout)
|
|
99
103
|
|
|
100
104
|
# 6.获取航班基本信息plane locator
|
|
101
105
|
flight_info_plane: Locator = await book_search_page.get_flight_info_plane(
|
|
@@ -118,11 +122,15 @@ async def book_search(
|
|
|
118
122
|
products: List[Dict[str, Any]] = await book_search_page.get_flight_products(
|
|
119
123
|
locator=flight_info_plane, flight_no=one_way_booking_dto.flight_no, logger=logger
|
|
120
124
|
)
|
|
121
|
-
|
|
125
|
+
# 取出需要预订的舱位产品
|
|
126
|
+
products = [x for x in products if x.get("cabin") == one_way_booking_dto.cabin and not x.get("ticket_info")]
|
|
127
|
+
# 根据价格升序排序(默认)
|
|
128
|
+
products = sorted(products, key=lambda x: x["amounts"]["amount"])
|
|
122
129
|
# 9.1 判断是否存在该舱位
|
|
123
|
-
if
|
|
130
|
+
if len(products) == 0:
|
|
124
131
|
raise RuntimeError(
|
|
125
132
|
f"航班预订查询页面,没有搜索到航班<{one_way_booking_dto.flight_no}>的{one_way_booking_dto.cabin}舱数据")
|
|
133
|
+
cabin_product = products[0]
|
|
126
134
|
# 9.2 判断余座
|
|
127
135
|
seats_status = cabin_product.get("seats_status")
|
|
128
136
|
logger.info(
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
from logging import Logger
|
|
13
13
|
from playwright.async_api import Page
|
|
14
14
|
import qdairlines_helper.config.url_const as url_const
|
|
15
|
-
from
|
|
15
|
+
from flight_helper.utils.exception_utils import IPBlockError
|
|
16
16
|
from qdairlines_helper.po.cash_pax_info_page import CashPaxInfoPage
|
|
17
17
|
from qdairlines_helper.utils.po_utils import get_ip_access_blocked_msg
|
|
18
18
|
|
|
@@ -13,7 +13,7 @@ from logging import Logger
|
|
|
13
13
|
from playwright.async_api import Page
|
|
14
14
|
from qdairlines_helper.po.home_page import HomePage
|
|
15
15
|
import qdairlines_helper.config.url_const as url_const
|
|
16
|
-
from
|
|
16
|
+
from flight_helper.utils.exception_utils import IPBlockError
|
|
17
17
|
from qdairlines_helper.utils.po_utils import get_ip_access_blocked_msg
|
|
18
18
|
|
|
19
19
|
|
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
"""
|
|
12
12
|
import inspect
|
|
13
13
|
from logging import Logger
|
|
14
|
-
from typing import Callable
|
|
14
|
+
from typing import Callable, Dict, Any
|
|
15
15
|
from playwright.async_api import BrowserContext
|
|
16
16
|
import qdairlines_helper.config.url_const as url_const
|
|
17
17
|
from qdairlines_helper.po.nhlms_cash_desk_page import NhlmsCashDeskPage
|
|
18
18
|
from playwright_helper.utils.browser_utils import switch_for_table_window
|
|
19
|
-
from qdairlines_helper.utils.exception_utils import DuplicatePaymentError
|
|
20
19
|
from flight_helper.models.dto.payment import HFPaidAccountPaymentInputDTO, PaymentResultDTO
|
|
21
20
|
|
|
22
21
|
|
|
@@ -37,8 +36,8 @@ async def load_nhlms_cash_desk_po(
|
|
|
37
36
|
|
|
38
37
|
|
|
39
38
|
async def hf_paid_account_payment(
|
|
40
|
-
*, page: NhlmsCashDeskPage, logger: Logger, order_no:
|
|
41
|
-
hf_paid_account_payment_dto: HFPaidAccountPaymentInputDTO, timeout: float = 60.0
|
|
39
|
+
*, page: NhlmsCashDeskPage, logger: Logger, order_no: int, order_id: int, pre_check_of_payment: Callable,
|
|
40
|
+
qlv_cookie: Dict[str, Any], hf_paid_account_payment_dto: HFPaidAccountPaymentInputDTO, timeout: float = 60.0
|
|
42
41
|
) -> PaymentResultDTO:
|
|
43
42
|
# 1. 获取收银台支付流水
|
|
44
43
|
pay_transaction = await page.get_order_transaction(timeout=timeout)
|
|
@@ -65,13 +64,17 @@ async def hf_paid_account_payment(
|
|
|
65
64
|
await password_input.fill(value=hf_paid_account_payment_dto.password)
|
|
66
65
|
logger.info(f"汇付天下收银台页面,交易密码<{hf_paid_account_payment_dto.password}>输入完成")
|
|
67
66
|
|
|
68
|
-
#
|
|
69
|
-
if inspect.iscoroutinefunction(
|
|
70
|
-
|
|
67
|
+
# 5.1. 前置检查,为何放在此处
|
|
68
|
+
if inspect.iscoroutinefunction(pre_check_of_payment):
|
|
69
|
+
await pre_check_of_payment(
|
|
70
|
+
order_id=order_id, logger=logger, cookie=qlv_cookie,
|
|
71
|
+
payment_channel=hf_paid_account_payment_dto.payment_type
|
|
72
|
+
)
|
|
71
73
|
else:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
pre_check_of_payment(
|
|
75
|
+
order_id=order_id, logger=logger, cookie=qlv_cookie,
|
|
76
|
+
payment_channel=hf_paid_account_payment_dto.payment_type
|
|
77
|
+
)
|
|
75
78
|
|
|
76
79
|
# 6. 点击【确认支付】
|
|
77
80
|
confirm_payment_btn = await page.get_confirm_payment_btn(timeout=timeout)
|
|
@@ -10,38 +10,60 @@
|
|
|
10
10
|
# ---------------------------------------------------------------------------------------------------------
|
|
11
11
|
"""
|
|
12
12
|
import re
|
|
13
|
+
import inspect
|
|
14
|
+
from logging import Logger
|
|
13
15
|
from aiohttp import CookieJar
|
|
14
|
-
from typing import Dict, Any, Optional, List
|
|
16
|
+
from typing import Dict, Any, Optional, List, Callable
|
|
15
17
|
from qdairlines_helper.http.flight_order import FlightOrder
|
|
18
|
+
from flight_helper.models.dto.http_schema import HTTPRequestDTO
|
|
16
19
|
from flight_helper.models.dto.itinerary import QueryItineraryResponseDTO, QueryItineraryRequestDTO
|
|
17
20
|
|
|
18
21
|
|
|
19
22
|
async def get_order_detail(
|
|
20
|
-
*, query_dto: QueryItineraryRequestDTO,
|
|
21
|
-
|
|
23
|
+
*, query_dto: QueryItineraryRequestDTO, logger: Logger, callback_get_proxy: Callable,
|
|
24
|
+
timeout: Optional[int] = None, retry: Optional[int] = None, cookie_jar: Optional[CookieJar] = None,
|
|
25
|
+
enable_log: Optional[bool] = None
|
|
22
26
|
) -> Dict[str, Any]:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
http_request_dto = HTTPRequestDTO(
|
|
28
|
+
http_domain=query_dto.payment_domain, http_protocol=query_dto.payment_protocol,
|
|
29
|
+
storage_state=query_dto.storage_state, timeout=timeout, retry=retry, enable_log=enable_log,
|
|
30
|
+
token=query_dto.token
|
|
27
31
|
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
flight_order = FlightOrder(http_request_dto=http_request_dto, cookie_jar=cookie_jar)
|
|
33
|
+
last_order_info: Dict[str, Any] = dict()
|
|
34
|
+
for index in range(5):
|
|
35
|
+
proxy = None
|
|
36
|
+
is_end: bool = True if index + 1 == 5 else False
|
|
37
|
+
if index != 0:
|
|
38
|
+
if inspect.iscoroutinefunction(callback_get_proxy):
|
|
39
|
+
proxy = await callback_get_proxy(logger=logger)
|
|
40
|
+
else:
|
|
41
|
+
proxy = callback_get_proxy(logger=logger)
|
|
42
|
+
try:
|
|
43
|
+
last_order_info = await flight_order.get_order_details(
|
|
44
|
+
pre_order_no=query_dto.pre_order_no, user_id=query_dto.user_id, is_end=is_end, proxy=proxy,
|
|
45
|
+
headers=query_dto.headers,
|
|
46
|
+
)
|
|
47
|
+
await flight_order.http_client.close()
|
|
48
|
+
logger.info("查询青岛航空官网的订单详情数据成功")
|
|
49
|
+
break
|
|
50
|
+
except (Exception,):
|
|
51
|
+
pass
|
|
52
|
+
if isinstance(last_order_info, dict) and last_order_info.get("result") and last_order_info.get("code") == 1:
|
|
53
|
+
return last_order_info.get("result")
|
|
34
54
|
else:
|
|
35
|
-
raise RuntimeError(f"订单<{query_dto.pre_order_no}>,获取详情数据异常,返回值:{
|
|
55
|
+
raise RuntimeError(f"订单<{query_dto.pre_order_no}>,获取详情数据异常,返回值:{last_order_info}")
|
|
36
56
|
|
|
37
57
|
|
|
38
58
|
async def get_order_itinerary(
|
|
39
|
-
*, query_dto: QueryItineraryRequestDTO,
|
|
40
|
-
|
|
59
|
+
*, query_dto: QueryItineraryRequestDTO, logger: Logger, callback_get_proxy: Callable,
|
|
60
|
+
timeout: Optional[int] = None, retry: Optional[int] = None, cookie_jar: Optional[CookieJar] = None,
|
|
61
|
+
enable_log: Optional[bool] = None
|
|
41
62
|
) -> Optional[QueryItineraryResponseDTO]:
|
|
42
63
|
_order_info: Dict[str, Any] = dict(pre_order_no=query_dto.pre_order_no)
|
|
43
64
|
result = await get_order_detail(
|
|
44
|
-
query_dto=query_dto, timeout=timeout, retry=retry, cookie_jar=cookie_jar, enable_log=enable_log
|
|
65
|
+
query_dto=query_dto, timeout=timeout, retry=retry, cookie_jar=cookie_jar, enable_log=enable_log,
|
|
66
|
+
callback_get_proxy=callback_get_proxy, logger=logger
|
|
45
67
|
)
|
|
46
68
|
_order_info["cash_unit"] = result.get("cashUnit")
|
|
47
69
|
_order_info["order_status"] = result.get("orderStatus")
|
|
@@ -60,3 +82,6 @@ async def get_order_itinerary(
|
|
|
60
82
|
if order_itineraries:
|
|
61
83
|
_order_info["itinerary_info"] = order_itineraries
|
|
62
84
|
return QueryItineraryResponseDTO(**_order_info)
|
|
85
|
+
else:
|
|
86
|
+
logger.warning(
|
|
87
|
+
f'青岛航空官网订单<{query_dto.pre_order_no}>,当前状态:{result.get("orderStatus")},没有生成行程单信息')
|
|
@@ -14,7 +14,7 @@ from logging import Logger
|
|
|
14
14
|
from playwright.async_api import Page
|
|
15
15
|
import qdairlines_helper.config.url_const as url_const
|
|
16
16
|
from qdairlines_helper.po.air_order_page import AirOrderPage
|
|
17
|
-
from
|
|
17
|
+
from flight_helper.utils.exception_utils import IPBlockError
|
|
18
18
|
from qdairlines_helper.utils.po_utils import get_ip_access_blocked_msg
|
|
19
19
|
|
|
20
20
|
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
from logging import Logger
|
|
13
13
|
from playwright.async_api import Page
|
|
14
14
|
import qdairlines_helper.config.url_const as url_const
|
|
15
|
-
from
|
|
15
|
+
from flight_helper.utils.exception_utils import IPBlockError
|
|
16
|
+
from flight_helper.utils.exception_utils import OrderLimitError
|
|
16
17
|
from qdairlines_helper.po.order_verify_page import OrderVerifyPage
|
|
17
18
|
from qdairlines_helper.utils.po_utils import get_ip_access_blocked_msg
|
|
18
19
|
|
|
@@ -32,7 +33,7 @@ async def load_order_verify_po(
|
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
async def order_verify(
|
|
35
|
-
*, page: OrderVerifyPage, logger: Logger, refresh_attempt: int = 3, timeout: float = 60.0
|
|
36
|
+
*, page: OrderVerifyPage, logger: Logger, qdair_user_id: str, refresh_attempt: int = 3, timeout: float = 60.0
|
|
36
37
|
) -> None:
|
|
37
38
|
# 1. 先确认订单数据是否加载出来
|
|
38
39
|
await page.get_order_info_plane(timeout=timeout, refresh_attempt=refresh_attempt)
|
|
@@ -46,3 +47,11 @@ async def order_verify(
|
|
|
46
47
|
next_btn = await page.get_next_btn(timeout=timeout)
|
|
47
48
|
await next_btn.click(button="left")
|
|
48
49
|
logger.info("订单校验页面,【下一步】按钮点击完成")
|
|
50
|
+
|
|
51
|
+
# 4. 判断是否存在消息提示弹框
|
|
52
|
+
message: str = await page.get_message_box(logger=logger, timeout=5)
|
|
53
|
+
if message:
|
|
54
|
+
raise OrderLimitError(user_id=qdair_user_id, message=message)
|
|
55
|
+
|
|
56
|
+
# 5. 看看是否出现易盾校验码
|
|
57
|
+
await page.handle_yidun_icon(logger=logger, timeout=5)
|
|
@@ -9,17 +9,17 @@
|
|
|
9
9
|
# Copyright ©2011-2026. Hunan xxxxxxx Company limited. All rights reserved.
|
|
10
10
|
# ---------------------------------------------------------------------------------------------------------
|
|
11
11
|
"""
|
|
12
|
-
import inspect
|
|
13
12
|
from logging import Logger
|
|
14
13
|
from aiohttp import CookieJar
|
|
15
14
|
from playwright.async_api import Page
|
|
16
15
|
from typing import Dict, Any, Optional, Callable
|
|
17
16
|
import qdairlines_helper.config.url_const as url_const
|
|
18
17
|
from qdairlines_helper.po.pay_success_page import PaySuccessPage
|
|
18
|
+
from qdairlines_helper.po.nhlms_cash_desk_page import NhlmsCashDeskPage
|
|
19
19
|
from qdairlines_helper.utils.po_utils import get_ip_access_blocked_msg
|
|
20
20
|
from qdairlines_helper.controller.order_detail import get_order_detail
|
|
21
21
|
from flight_helper.models.dto.itinerary import QueryItineraryRequestDTO
|
|
22
|
-
from
|
|
22
|
+
from flight_helper.utils.exception_utils import IPBlockError, PaymentFailedError
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
async def load_pay_success_page(
|
|
@@ -37,30 +37,21 @@ async def load_pay_success_page(
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
async def two_check_pay_success(
|
|
40
|
-
*, page:
|
|
40
|
+
*, page: NhlmsCashDeskPage, logger: Logger, query_dto: QueryItineraryRequestDTO, callback_get_proxy: Callable,
|
|
41
41
|
cookie_jar: Optional[CookieJar] = None, timeout: float = 60.0, retry: int = 0, enable_log: bool = True
|
|
42
|
-
) ->
|
|
42
|
+
) -> None:
|
|
43
43
|
try:
|
|
44
44
|
# 1. 看支付成功页面是否加载完成
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
timeout=timeout
|
|
48
|
-
)
|
|
49
|
-
# 2. 检测页面的支付成功image是否存在
|
|
50
|
-
await pay_success_po.get_pay_success_image(timeout=timeout)
|
|
51
|
-
return True
|
|
45
|
+
await page.check_is_pay_success(logger=logger)
|
|
46
|
+
return
|
|
52
47
|
except Exception as e:
|
|
53
48
|
logger.error(e)
|
|
54
49
|
|
|
55
|
-
if inspect.iscoroutinefunction(callback_get_proxy):
|
|
56
|
-
query_dto.proxy = await callback_get_proxy(logger=logger)
|
|
57
|
-
else:
|
|
58
|
-
query_dto.proxy = callback_get_proxy(logger=logger)
|
|
59
|
-
|
|
60
50
|
# 2. 尝试取查询票号,看订单状态,是 BOOKED,还是 TICKETED
|
|
61
51
|
order_detail: Dict[str, Any] = await get_order_detail(
|
|
62
52
|
query_dto=query_dto, timeout=int(timeout), retry=retry, enable_log=enable_log, cookie_jar=cookie_jar,
|
|
53
|
+
callback_get_proxy=callback_get_proxy, logger=logger
|
|
63
54
|
)
|
|
64
55
|
order_status = (order_detail.get("orderStatus", "")).upper()
|
|
65
|
-
if order_status not in ("TICKED",):
|
|
56
|
+
if order_status not in ("TICKED", "PAYED"):
|
|
66
57
|
raise PaymentFailedError(pre_order_no=query_dto.pre_order_no, order_status=order_status)
|
|
@@ -9,13 +9,17 @@
|
|
|
9
9
|
# Copyright ©2011-2026. Hunan xxxxxxx Company limited. All rights reserved.
|
|
10
10
|
# ---------------------------------------------------------------------------------------------------------
|
|
11
11
|
"""
|
|
12
|
+
import inspect
|
|
12
13
|
from logging import Logger
|
|
13
|
-
from
|
|
14
|
+
from aiohttp import CookieJar
|
|
15
|
+
from typing import Dict, Any, Optional, Callable
|
|
14
16
|
from playwright.async_api import Page, BrowserContext
|
|
15
17
|
from qdairlines_helper.po.login_page import LoginPage
|
|
16
18
|
import qdairlines_helper.config.url_const as url_const
|
|
19
|
+
from qdairlines_helper.http.user_login import UserLogin
|
|
17
20
|
from qdairlines_helper.controller.home import load_home_po
|
|
18
|
-
from
|
|
21
|
+
from flight_helper.utils.exception_utils import IPBlockError
|
|
22
|
+
from flight_helper.models.dto.http_schema import HTTPRequestDTO
|
|
19
23
|
from playwright.async_api import Error as PlaywrightError, TimeoutError as PlaywrightTimeoutError
|
|
20
24
|
from qdairlines_helper.utils.po_utils import get_ip_access_blocked_msg, parse_user_info_from_page_response
|
|
21
25
|
|
|
@@ -94,3 +98,34 @@ async def user_login_callback(
|
|
|
94
98
|
user_info = parse_user_info_from_page_response(network_logs=network_logs)
|
|
95
99
|
user_info.update(dict(storage_state=await context.storage_state()))
|
|
96
100
|
return user_info
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
async def get_user_info(
|
|
104
|
+
*, logger: Logger, http_request_dto: HTTPRequestDTO, callback_get_proxy: Callable,
|
|
105
|
+
cookie_jar: Optional[CookieJar] = None
|
|
106
|
+
) -> Dict[str, Any]:
|
|
107
|
+
user_login = UserLogin(http_request_dto=http_request_dto, cookie_jar=cookie_jar)
|
|
108
|
+
last_user_info: Dict[str, Any] = dict()
|
|
109
|
+
count = 2
|
|
110
|
+
for index in range(count):
|
|
111
|
+
proxy = None
|
|
112
|
+
is_end: bool = True if index + 1 == count else False
|
|
113
|
+
if index != 0:
|
|
114
|
+
if inspect.iscoroutinefunction(callback_get_proxy):
|
|
115
|
+
proxy = await callback_get_proxy(logger=logger)
|
|
116
|
+
else:
|
|
117
|
+
proxy = callback_get_proxy(logger=logger)
|
|
118
|
+
try:
|
|
119
|
+
last_user_info = await user_login.get_user_info(
|
|
120
|
+
is_end=is_end, proxy=proxy, headers=http_request_dto.headers
|
|
121
|
+
)
|
|
122
|
+
await user_login.http_client.close()
|
|
123
|
+
logger.info("获取青岛航空官网的用户详情数据成功")
|
|
124
|
+
break
|
|
125
|
+
except (Exception,) as e:
|
|
126
|
+
logger.error(e)
|
|
127
|
+
pass
|
|
128
|
+
if isinstance(last_user_info, dict) and last_user_info.get("result") and last_user_info.get("code") == 1:
|
|
129
|
+
return last_user_info.get("result")
|
|
130
|
+
else:
|
|
131
|
+
raise RuntimeError(f"获取用户详情数据异常,返回值:{last_user_info}")
|
|
@@ -11,51 +11,15 @@
|
|
|
11
11
|
"""
|
|
12
12
|
from aiohttp import CookieJar
|
|
13
13
|
from typing import Optional, Dict, Any
|
|
14
|
+
from qdairlines_helper.http.http_base import HttpBase
|
|
14
15
|
import qdairlines_helper.config.url_const as url_const
|
|
15
|
-
from
|
|
16
|
+
from flight_helper.models.dto.http_schema import HTTPRequestDTO
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
class FlightOrder:
|
|
19
|
+
class FlightOrder(HttpBase):
|
|
19
20
|
|
|
20
|
-
def __init__(
|
|
21
|
-
|
|
22
|
-
domain: Optional[str] = None, protocol: Optional[str] = None, timeout: Optional[int] = None,
|
|
23
|
-
retry: Optional[int] = None, enable_log: Optional[bool] = None, cookie_jar: Optional[CookieJar] = None
|
|
24
|
-
):
|
|
25
|
-
self._domain = domain or "127.0.0.1:18070"
|
|
26
|
-
self._protocol = protocol or "http"
|
|
27
|
-
self._timeout = timeout or 60
|
|
28
|
-
self._retry = retry or 0
|
|
29
|
-
self._token = token
|
|
30
|
-
self._origin = f"{self._protocol}://{self._domain}"
|
|
31
|
-
self._enable_log = enable_log or True
|
|
32
|
-
self._cookie_jar = cookie_jar or CookieJar()
|
|
33
|
-
self._proxy = proxy
|
|
34
|
-
self._playwright_state: Dict[str, Any] = playwright_state
|
|
35
|
-
self.http_client: Optional[_HttpClientFactory] = None
|
|
36
|
-
|
|
37
|
-
def _get_http_client(self) -> _HttpClientFactory:
|
|
38
|
-
"""延迟获取 HTTP 客户端"""
|
|
39
|
-
if self.http_client is None:
|
|
40
|
-
self.http_client = _HttpClientFactory(
|
|
41
|
-
protocol=self._protocol,
|
|
42
|
-
domain=self._domain,
|
|
43
|
-
timeout=self._timeout,
|
|
44
|
-
retry=self._retry,
|
|
45
|
-
enable_log=self._enable_log,
|
|
46
|
-
cookie_jar=self._cookie_jar,
|
|
47
|
-
playwright_state=self._playwright_state
|
|
48
|
-
)
|
|
49
|
-
return self.http_client
|
|
50
|
-
|
|
51
|
-
def _get_headers(self) -> Dict[str, str]:
|
|
52
|
-
headers = {
|
|
53
|
-
"content-type": "application/json;charset=utf-8",
|
|
54
|
-
"origin": self._domain,
|
|
55
|
-
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36",
|
|
56
|
-
"authorization": f"Bearer {self._token}"
|
|
57
|
-
}
|
|
58
|
-
return headers
|
|
21
|
+
def __init__(self, *, http_request_dto: HTTPRequestDTO, cookie_jar: Optional[CookieJar] = None):
|
|
22
|
+
super().__init__(http_request_dto=http_request_dto, cookie_jar=cookie_jar)
|
|
59
23
|
|
|
60
24
|
async def get_order_details(
|
|
61
25
|
self, *, pre_order_no: str, user_id: str, proxy: Optional[Dict[str, Any]] = None,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
# ---------------------------------------------------------------------------------------------------------
|
|
4
|
+
# ProjectName: python-qdairlines-helper
|
|
5
|
+
# FileName: http_base.py
|
|
6
|
+
# Description: http基础模块
|
|
7
|
+
# Author: ASUS
|
|
8
|
+
# CreateDate: 2026/01/13
|
|
9
|
+
# Copyright ©2011-2026. Hunan xxxxxxx Company limited. All rights reserved.
|
|
10
|
+
# ---------------------------------------------------------------------------------------------------------
|
|
11
|
+
"""
|
|
12
|
+
from aiohttp import CookieJar
|
|
13
|
+
from typing import Optional, Dict, Any
|
|
14
|
+
from flight_helper.models.dto.http_schema import HTTPRequestDTO
|
|
15
|
+
from http_helper.client.async_proxy import HttpClientFactory as _HttpClientFactory
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class HttpBase(object):
|
|
19
|
+
|
|
20
|
+
def __init__(self, *, http_request_dto: HTTPRequestDTO, cookie_jar: Optional[CookieJar] = None):
|
|
21
|
+
self._domain = http_request_dto.http_domain or "127.0.0.1:18070"
|
|
22
|
+
self._protocol = http_request_dto.http_protocol or "http"
|
|
23
|
+
self._timeout = http_request_dto.timeout or 60
|
|
24
|
+
self._retry = http_request_dto.retry or 0
|
|
25
|
+
self._token = http_request_dto.token
|
|
26
|
+
self._origin = f"{self._protocol}://{self._domain}"
|
|
27
|
+
self._enable_log = http_request_dto.enable_log if http_request_dto.enable_log is not None else True
|
|
28
|
+
self._cookie_jar = cookie_jar or CookieJar()
|
|
29
|
+
self._proxy = http_request_dto.proxy
|
|
30
|
+
self._playwright_state: Dict[str, Any] = http_request_dto.storage_state
|
|
31
|
+
self.http_client: Optional[_HttpClientFactory] = None
|
|
32
|
+
|
|
33
|
+
def _get_http_client(self) -> _HttpClientFactory:
|
|
34
|
+
"""延迟获取 HTTP 客户端"""
|
|
35
|
+
if self.http_client is None:
|
|
36
|
+
self.http_client = _HttpClientFactory(
|
|
37
|
+
protocol=self._protocol,
|
|
38
|
+
domain=self._domain,
|
|
39
|
+
timeout=self._timeout,
|
|
40
|
+
retry=self._retry,
|
|
41
|
+
enable_log=self._enable_log,
|
|
42
|
+
cookie_jar=self._cookie_jar,
|
|
43
|
+
playwright_state=self._playwright_state
|
|
44
|
+
)
|
|
45
|
+
return self.http_client
|
|
46
|
+
|
|
47
|
+
def _get_headers(self) -> Dict[str, str]:
|
|
48
|
+
headers = {
|
|
49
|
+
"content-type": "application/json;charset=utf-8",
|
|
50
|
+
"origin": self._domain,
|
|
51
|
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36",
|
|
52
|
+
"authorization": f"Bearer {self._token}"
|
|
53
|
+
}
|
|
54
|
+
return headers
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
# ---------------------------------------------------------------------------------------------------------
|
|
4
|
+
# ProjectName: python-qdairlines-helper
|
|
5
|
+
# FileName: user_login.py
|
|
6
|
+
# Description: 用户登录模块
|
|
7
|
+
# Author: ASUS
|
|
8
|
+
# CreateDate: 2026/01/13
|
|
9
|
+
# Copyright ©2011-2026. Hunan xxxxxxx Company limited. All rights reserved.
|
|
10
|
+
# ---------------------------------------------------------------------------------------------------------
|
|
11
|
+
"""
|
|
12
|
+
from aiohttp import CookieJar
|
|
13
|
+
from typing import Optional, Dict, Any
|
|
14
|
+
from qdairlines_helper.http.http_base import HttpBase
|
|
15
|
+
import qdairlines_helper.config.url_const as url_const
|
|
16
|
+
from flight_helper.models.dto.http_schema import HTTPRequestDTO
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class UserLogin(HttpBase):
|
|
20
|
+
def __init__(self, *, http_request_dto: HTTPRequestDTO, cookie_jar: Optional[CookieJar] = None):
|
|
21
|
+
super().__init__(http_request_dto=http_request_dto, cookie_jar=cookie_jar)
|
|
22
|
+
|
|
23
|
+
async def get_user_info(
|
|
24
|
+
self, *, proxy: Optional[Dict[str, Any]] = None, headers: Dict[str, str] = None,
|
|
25
|
+
is_end: Optional[bool] = None
|
|
26
|
+
) -> Dict[str, Any]:
|
|
27
|
+
_headers = self._get_headers()
|
|
28
|
+
if headers is not None:
|
|
29
|
+
_headers.update(headers)
|
|
30
|
+
_headers["referer"] = f"{self._origin}{url_const.login_url}"
|
|
31
|
+
if is_end is None:
|
|
32
|
+
is_end = True
|
|
33
|
+
if proxy:
|
|
34
|
+
self._proxy = proxy
|
|
35
|
+
exception_keywords = [r'<h3[^>]*class="font-bold"[^>]*>([^<]+)</h3>']
|
|
36
|
+
return await self._get_http_client().request(
|
|
37
|
+
method="GET",
|
|
38
|
+
url=url_const.login_after_api_url,
|
|
39
|
+
headers=_headers,
|
|
40
|
+
is_end=is_end,
|
|
41
|
+
proxy_config=self._proxy or None,
|
|
42
|
+
exception_keywords=exception_keywords
|
|
43
|
+
)
|
|
@@ -13,7 +13,7 @@ from typing import Optional
|
|
|
13
13
|
from playwright.async_api import Page, Locator
|
|
14
14
|
from playwright_helper.libs.base_po import BasePo
|
|
15
15
|
import qdairlines_helper.config.url_const as url_const
|
|
16
|
-
from
|
|
16
|
+
from flight_helper.utils.exception_utils import PassengerTypeError
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class AddPassengerPage(BasePo):
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
"""
|
|
12
12
|
import re
|
|
13
13
|
from logging import Logger
|
|
14
|
-
from typing import Optional, Dict, Any, List
|
|
15
14
|
from playwright.async_api import Page, Locator
|
|
16
15
|
from playwright_helper.libs.base_po import BasePo
|
|
16
|
+
from typing import Optional, Dict, Any, List, Literal
|
|
17
17
|
import qdairlines_helper.config.url_const as url_const
|
|
18
|
-
from
|
|
18
|
+
from flight_helper.utils.exception_utils import ProductTypeError
|
|
19
19
|
from playwright_helper.utils.type_utils import convert_order_amount_text, safe_convert_advanced
|
|
20
20
|
from playwright.async_api import Error as PlaywrightError, TimeoutError as PlaywrightTimeoutError
|
|
21
21
|
|
|
@@ -37,14 +37,21 @@ class BookSearchPage(BasePo):
|
|
|
37
37
|
selector: str = '//strong[contains(text(), "没有在飞航班")]'
|
|
38
38
|
return await self.get_locator(selector=selector, timeout=timeout)
|
|
39
39
|
|
|
40
|
+
@staticmethod
|
|
41
|
+
def _get_reminder_dialog_selector() -> str:
|
|
42
|
+
return '//div[@class="el-dialog__body"]//button[contains(@class, "search_btn")]'
|
|
43
|
+
|
|
44
|
+
async def is_exist_reminder_dialog(self) -> bool:
|
|
45
|
+
# 使用 count() 快速判断是否存在(不会因找不到而抛异常)
|
|
46
|
+
return await self.__page.locator(selector=self._get_reminder_dialog_selector()).count() > 0
|
|
47
|
+
|
|
40
48
|
async def get_reminder_dialog_continue_book_btn(self, timeout: float = 5.0) -> Locator:
|
|
41
49
|
"""
|
|
42
50
|
获取预订搜索页的温馨提醒弹框中的【继续购票】按钮
|
|
43
51
|
:param timeout: 超时时间(秒)
|
|
44
52
|
:return: (是否存在, 错误信息|元素对象)
|
|
45
53
|
"""
|
|
46
|
-
|
|
47
|
-
return await self.get_locator(selector=selector, timeout=timeout)
|
|
54
|
+
return await self.get_locator(selector=self._get_reminder_dialog_selector(), timeout=timeout)
|
|
48
55
|
|
|
49
56
|
async def get_depart_city_input(self, timeout: float = 5.0) -> Locator:
|
|
50
57
|
"""
|
|
@@ -55,6 +62,22 @@ class BookSearchPage(BasePo):
|
|
|
55
62
|
selector: str = '//div[contains(@class, "flight_search_form")]//input[@id="orig"]'
|
|
56
63
|
return await self.get_locator(selector=selector, timeout=timeout)
|
|
57
64
|
|
|
65
|
+
@staticmethod
|
|
66
|
+
def _get_city_search_result_selector(city_name: str, endpoint: Literal["orig", "dest"]) -> str:
|
|
67
|
+
return f'xpath=//div[@name="{endpoint}" and @class="vcp-select"]//span[contains(text(), "{city_name}")]/..'
|
|
68
|
+
|
|
69
|
+
async def get_depart_city_search_result(self, depart_city: str, timeout: float = 5.0) -> Locator:
|
|
70
|
+
"""
|
|
71
|
+
获取预订搜索页搜索栏的起飞城市搜索结果
|
|
72
|
+
:param depart_city: 起飞城市
|
|
73
|
+
:param timeout: 超时时间(秒)
|
|
74
|
+
:return: (是否存在, 错误信息|元素对象)
|
|
75
|
+
"""
|
|
76
|
+
if depart_city == "晋江":
|
|
77
|
+
depart_city = "泉州"
|
|
78
|
+
selector = self._get_city_search_result_selector(city_name=depart_city, endpoint="orig")
|
|
79
|
+
return await self.get_locator(selector=selector, timeout=timeout, strict=False)
|
|
80
|
+
|
|
58
81
|
async def get_arrive_city_input(self, timeout: float = 5.0) -> Locator:
|
|
59
82
|
"""
|
|
60
83
|
获取预订搜索页搜索栏的抵达城市输入框
|
|
@@ -64,6 +87,18 @@ class BookSearchPage(BasePo):
|
|
|
64
87
|
selector: str = '//div[contains(@class, "flight_search_form")]//input[@id="dest"]'
|
|
65
88
|
return await self.get_locator(selector=selector, timeout=timeout)
|
|
66
89
|
|
|
90
|
+
async def get_arrive_city_search_result(self, arrive_city: str, timeout: float = 5.0) -> Locator:
|
|
91
|
+
"""
|
|
92
|
+
获取预订搜索页搜索栏的抵达城市搜索结果
|
|
93
|
+
:param arrive_city: 抵达城市
|
|
94
|
+
:param timeout: 超时时间(秒)
|
|
95
|
+
:return: (是否存在, 错误信息|元素对象)
|
|
96
|
+
"""
|
|
97
|
+
if arrive_city == "晋江":
|
|
98
|
+
arrive_city = "泉州"
|
|
99
|
+
selector = self._get_city_search_result_selector(city_name=arrive_city, endpoint="dest")
|
|
100
|
+
return await self.get_locator(selector=selector, timeout=timeout, strict=False)
|
|
101
|
+
|
|
67
102
|
async def get_depart_date_input(self, timeout: float = 5.0) -> Locator:
|
|
68
103
|
"""
|
|
69
104
|
获取预订搜索页搜索栏的起飞日期输入框
|
|
@@ -144,8 +179,10 @@ class BookSearchPage(BasePo):
|
|
|
144
179
|
amounts: Dict[str, Any] = await self._get_flight_product_price(locator=locator, timeout=timeout)
|
|
145
180
|
seats_status: int = await self._get_flight_product_seats_status(locator=locator, timeout=timeout)
|
|
146
181
|
cabin = await self._get_flight_product_cabin(locator=locator, timeout=timeout)
|
|
182
|
+
ticket_info: str = await self._get_flight_product_ticket_info(locator=locator, timeout=timeout)
|
|
147
183
|
flight_products.append(dict(
|
|
148
|
-
amounts=amounts, cabin=cabin, seats_status=seats_status, booking_btn=booking_btn
|
|
184
|
+
amounts=amounts, cabin=cabin, seats_status=seats_status, booking_btn=booking_btn,
|
|
185
|
+
ticket_info=ticket_info
|
|
149
186
|
))
|
|
150
187
|
except (PlaywrightError, PlaywrightTimeoutError, EnvironmentError, RuntimeError, Exception) as e:
|
|
151
188
|
logger.error(e)
|
|
@@ -161,7 +198,7 @@ class BookSearchPage(BasePo):
|
|
|
161
198
|
"""
|
|
162
199
|
selector: str = 'xpath=.//div[@class="ticket_clazz"]/div/span'
|
|
163
200
|
locator: Locator = await self.get_sub_locator(locator=locator, selector=selector, timeout=timeout)
|
|
164
|
-
text: str = (await locator.inner_text(timeout=timeout)).strip()
|
|
201
|
+
text: str = (await locator.inner_text(timeout=timeout * 1000)).strip()
|
|
165
202
|
match = re.search(r'\((.*?)舱\)', text)
|
|
166
203
|
if match:
|
|
167
204
|
return match.group(1).strip()
|
|
@@ -176,7 +213,7 @@ class BookSearchPage(BasePo):
|
|
|
176
213
|
"""
|
|
177
214
|
selector: str = 'xpath=.//div[@class="price_flex_top"]'
|
|
178
215
|
locator: Locator = await self.get_sub_locator(locator=locator, selector=selector, timeout=timeout)
|
|
179
|
-
amount_text: str = (await locator.inner_text(timeout=timeout)).strip()
|
|
216
|
+
amount_text: str = (await locator.inner_text(timeout=timeout * 1000)).strip()
|
|
180
217
|
return convert_order_amount_text(amount_text=amount_text)
|
|
181
218
|
|
|
182
219
|
async def _get_flight_product_booking_btn(self, locator: Locator, timeout: float = 5.0) -> Locator:
|
|
@@ -189,6 +226,20 @@ class BookSearchPage(BasePo):
|
|
|
189
226
|
selector: str = 'xpath=(.//td[@class="ticket_num"]/div/span)[1]'
|
|
190
227
|
return await self.get_sub_locator(locator=locator, selector=selector, timeout=timeout)
|
|
191
228
|
|
|
229
|
+
async def _get_flight_product_ticket_info(self, locator: Locator, timeout: float = 5.0) -> Optional[str]:
|
|
230
|
+
"""
|
|
231
|
+
获取预订搜索页航班内容栏航班产品下的单据信息
|
|
232
|
+
:param timeout: 超时时间(秒)
|
|
233
|
+
:param locator: flight_product Locator 对象
|
|
234
|
+
:return: (是否存在, 错误信息|元素对象)
|
|
235
|
+
"""
|
|
236
|
+
try:
|
|
237
|
+
selector: str = 'xpath=.//td[@class="ticket_info"]//span[contains(@class, "text-left")]'
|
|
238
|
+
locator = await self.get_sub_locator(locator=locator, selector=selector, timeout=timeout)
|
|
239
|
+
return (await locator.inner_text()).strip()
|
|
240
|
+
except (Exception,):
|
|
241
|
+
return
|
|
242
|
+
|
|
192
243
|
async def _get_flight_product_seats_status(self, locator: Locator, timeout: float = 5.0) -> int:
|
|
193
244
|
"""
|
|
194
245
|
获取预订搜索页航班内容栏航班产品下的余票信息
|
|
@@ -198,10 +249,30 @@ class BookSearchPage(BasePo):
|
|
|
198
249
|
"""
|
|
199
250
|
selector: str = 'xpath=(.//td[@class="ticket_num"]/div/span)[2]'
|
|
200
251
|
locator: Locator = await self.get_sub_locator(locator=locator, selector=selector, timeout=timeout)
|
|
201
|
-
more_seats_text: str = (await locator.inner_text(timeout=timeout)).strip()
|
|
252
|
+
more_seats_text: str = (await locator.inner_text(timeout=timeout * 1000)).strip()
|
|
202
253
|
match = re.search(r'\d+', more_seats_text)
|
|
203
254
|
if match:
|
|
204
255
|
# ⚠️ 正则 \d+ 没有捕获组,只能用 group(0) 或 group()
|
|
205
256
|
return safe_convert_advanced(value=match.group().strip())
|
|
206
257
|
else:
|
|
207
258
|
return 999999
|
|
259
|
+
|
|
260
|
+
async def handle_yidun_icon(self, logger: Logger, timeout: float = 20.0) -> None:
|
|
261
|
+
"""
|
|
262
|
+
获取搜索页面中的易盾校验弹框
|
|
263
|
+
:param logger: 日志对象
|
|
264
|
+
:param timeout: 超时时间(秒)
|
|
265
|
+
:return: (是否存在, 错误信息|元素对象)
|
|
266
|
+
"""
|
|
267
|
+
selector: str = 'xpath=//div[@class="yidun_intelli-tips"]//div[@class="yidun_intelli-icon"]'
|
|
268
|
+
try:
|
|
269
|
+
icon: Locator = await self.get_locator(selector=selector, timeout=timeout, strict=False)
|
|
270
|
+
await icon.click(button="left")
|
|
271
|
+
logger.info("预订搜索页面,易盾校验框【易盾icon】点击完成")
|
|
272
|
+
btn: Locator = await self.get_locator(
|
|
273
|
+
selector='//div[@class="el-dialog__body"]//button[@type="button"]', timeout=3, strict=False
|
|
274
|
+
)
|
|
275
|
+
await btn.click(button="left")
|
|
276
|
+
logger.info("预订搜索页面,易盾校验框【确认】点击完成")
|
|
277
|
+
except (Exception,):
|
|
278
|
+
pass
|
|
@@ -14,7 +14,7 @@ from urllib.parse import urlparse, parse_qs
|
|
|
14
14
|
from playwright.async_api import Page, Locator
|
|
15
15
|
from playwright_helper.libs.base_po import BasePo
|
|
16
16
|
import qdairlines_helper.config.url_const as url_const
|
|
17
|
-
from
|
|
17
|
+
from flight_helper.utils.exception_utils import PaymentChannelError
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
class CashPaxInfoPage(BasePo):
|
|
@@ -9,12 +9,17 @@
|
|
|
9
9
|
# Copyright ©2011-2026. Hunan xxxxxxx Company limited. All rights reserved.
|
|
10
10
|
# ---------------------------------------------------------------------------------------------------------
|
|
11
11
|
"""
|
|
12
|
+
import asyncio
|
|
13
|
+
from logging import Logger
|
|
12
14
|
from typing import Optional, Any
|
|
15
|
+
from collections import OrderedDict
|
|
16
|
+
from datetime import datetime, timedelta
|
|
13
17
|
from playwright.async_api import Page, Locator
|
|
14
18
|
from playwright_helper.libs.base_po import BasePo
|
|
15
19
|
import qdairlines_helper.config.url_const as url_const
|
|
16
20
|
from playwright_helper.utils.type_utils import safe_convert_advanced
|
|
17
|
-
from
|
|
21
|
+
from flight_helper.utils.exception_utils import HFPaymentTypeError, PaymentFailError
|
|
22
|
+
from playwright.async_api import Error as PlaywrightError, TimeoutError as PlaywrightTimeoutError
|
|
18
23
|
|
|
19
24
|
|
|
20
25
|
class NhlmsCashDeskPage(BasePo):
|
|
@@ -93,3 +98,39 @@ class NhlmsCashDeskPage(BasePo):
|
|
|
93
98
|
"""
|
|
94
99
|
selector: str = 'xpath=//div[@class="content-bottom network-recharge"]//button[@id="submitBtn"]'
|
|
95
100
|
return await self.get_locator(selector=selector, timeout=timeout)
|
|
101
|
+
|
|
102
|
+
async def check_is_pay_success(self, logger: Logger) -> None:
|
|
103
|
+
"""检查支付是否成功"""
|
|
104
|
+
data = OrderedDict([
|
|
105
|
+
("支付成功", 'xpath=//img[@alt="支付成功"]'),
|
|
106
|
+
(PaymentFailError("账户余额不足"), 'xpath=//span[contains(text(), "账户余额不足")]'),
|
|
107
|
+
(
|
|
108
|
+
PaymentFailError(
|
|
109
|
+
"尊敬的旅客:您的IP由于频繁访问已受限,客票预定可前往青岛航空微信公众号预定。如您需要办理其他客票业务,请联系官方客服热线:0532-96630。"
|
|
110
|
+
),
|
|
111
|
+
'//h3[contains(text(), "您的IP")]'
|
|
112
|
+
)
|
|
113
|
+
])
|
|
114
|
+
timeout = 60
|
|
115
|
+
end_time = datetime.now() + timedelta(seconds=timeout)
|
|
116
|
+
|
|
117
|
+
while datetime.now() < end_time:
|
|
118
|
+
for index, (outcome, selector) in enumerate(data.items()):
|
|
119
|
+
try:
|
|
120
|
+
await self.get_locator(selector=selector, timeout=1)
|
|
121
|
+
if index == 0:
|
|
122
|
+
logger.info(f"支付结果检测:{outcome}")
|
|
123
|
+
return # 成功
|
|
124
|
+
else:
|
|
125
|
+
# 一旦匹配失败,立即抛出!
|
|
126
|
+
raise outcome
|
|
127
|
+
except (PlaywrightTimeoutError, PlaywrightError, RuntimeError):
|
|
128
|
+
# 只捕获“未找到元素”的异常,其他异常往上抛
|
|
129
|
+
continue
|
|
130
|
+
except Exception:
|
|
131
|
+
# 可选:记录未知异常,但不吞掉
|
|
132
|
+
raise # 或 log 后 re-raise
|
|
133
|
+
|
|
134
|
+
await asyncio.sleep(0.5) # 避免 CPU 占用过高
|
|
135
|
+
logger.error(f"支付结果检测:超时,当前页面url: {self.__page.url}")
|
|
136
|
+
raise PlaywrightTimeoutError(f"支付结果检测超时,{timeout}秒内未出现成功或已知失败状态")
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
# Copyright ©2011-2026. Hunan xxxxxxx Company limited. All rights reserved.
|
|
10
10
|
# ---------------------------------------------------------------------------------------------------------
|
|
11
11
|
"""
|
|
12
|
-
from
|
|
12
|
+
from logging import Logger
|
|
13
|
+
from typing import Optional, List
|
|
13
14
|
from playwright.async_api import Page, Locator
|
|
14
15
|
from playwright_helper.libs.base_po import BasePo
|
|
15
16
|
import qdairlines_helper.config.url_const as url_const
|
|
@@ -24,6 +25,44 @@ class OrderVerifyPage(BasePo):
|
|
|
24
25
|
super().__init__(page, url or url_const.order_verify_url)
|
|
25
26
|
self.__page = page
|
|
26
27
|
|
|
28
|
+
async def handle_yidun_icon(self, logger: Logger, timeout: float = 20.0) -> None:
|
|
29
|
+
"""
|
|
30
|
+
获取订单校验页中的易盾校验弹框
|
|
31
|
+
:param logger: 日志对象
|
|
32
|
+
:param timeout: 超时时间(秒)
|
|
33
|
+
:return: (是否存在, 错误信息|元素对象)
|
|
34
|
+
"""
|
|
35
|
+
selector: str = 'xpath=//div[@class="yidun_intelli-tips"]//div[@class="yidun_intelli-icon"]'
|
|
36
|
+
try:
|
|
37
|
+
locator: Locator = await self.get_locator(selector=selector, timeout=timeout, strict=False)
|
|
38
|
+
await locator.click(button="left")
|
|
39
|
+
logger.info("订单校验页面,易盾校验框【易盾icon】点击完成")
|
|
40
|
+
except (Exception,):
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
async def get_message_box(self, logger: Logger, timeout: float = 20.0) -> Optional[str]:
|
|
44
|
+
"""
|
|
45
|
+
获取订单校验页中的提示消息弹框内容
|
|
46
|
+
内容可能是:1. 您的账户订单数已达最大上限,请前往青岛航空官方微信小程序进行预订。
|
|
47
|
+
2. 请前往青岛航空官方微信小程序进行预订。
|
|
48
|
+
3. 抱歉,证件号码为:450511197305180615已经创建订单,订单号OW20260117B1280813,请勿重复占座
|
|
49
|
+
:param logger: 日志对象
|
|
50
|
+
:param timeout: 超时时间(秒)
|
|
51
|
+
:return: (是否存在, 错误信息|元素对象)
|
|
52
|
+
"""
|
|
53
|
+
selectors: List[str] = [
|
|
54
|
+
'xpath=//div[@class="el-message-box"]//div[@class="el-message-box__message"]/p',
|
|
55
|
+
'xpath=//div[@class="layui-layer-content"]'
|
|
56
|
+
]
|
|
57
|
+
for selector in selectors:
|
|
58
|
+
try:
|
|
59
|
+
locator: Locator = await self.get_locator(selector=selector, timeout=timeout, strict=False)
|
|
60
|
+
text: str = (await locator.inner_text()).strip()
|
|
61
|
+
logger.info(f"订单校验页面,提示框消息内容【{text}】获取完成")
|
|
62
|
+
return text
|
|
63
|
+
except (Exception,) as e:
|
|
64
|
+
logger.error(e)
|
|
65
|
+
|
|
27
66
|
async def get_order_info_plane(self, timeout: float = 5.0, refresh_attempt: int = 3) -> Locator:
|
|
28
67
|
"""
|
|
29
68
|
获取订单校验页中的订单信息版面,注意这里有个小坑,经常出现已经进入了该页面,但是订单信息没有加载出来,需要不断尝试刷新页面
|
|
@@ -35,7 +74,7 @@ class OrderVerifyPage(BasePo):
|
|
|
35
74
|
selector: str = 'xpath=//div[@class="order_info"]'
|
|
36
75
|
while attempt <= refresh_attempt:
|
|
37
76
|
try:
|
|
38
|
-
await self.__page.reload(timeout=timeout)
|
|
77
|
+
await self.__page.reload(timeout=timeout * 1000)
|
|
39
78
|
return await self.get_locator(selector=selector, timeout=timeout)
|
|
40
79
|
except (PlaywrightError, PlaywrightTimeoutError, EnvironmentError, RuntimeError, Exception) as e:
|
|
41
80
|
attempt += 1
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
python_qdairlines_helper-0.2.6.dist-info/licenses/LICENSE,sha256=WtjCEwlcVzkh1ziO35P2qfVEkLjr87Flro7xlHz3CEY,11556
|
|
2
|
-
qdairlines_helper/__init__.py,sha256=bN1FqEK_jvefO_HU_8HFJpjuOzHTsuhmRe5KAzmraR4,479
|
|
3
|
-
qdairlines_helper/config/__init__.py,sha256=JjIRocePx3gwFNpdauuiwBU6B2Ug565xaHLEMu5Oo0I,479
|
|
4
|
-
qdairlines_helper/config/url_const.py,sha256=Ro-8r3dRxuloJC5NIpwUMQ7Pezg2cDyZOqNUfTqCOFQ,2086
|
|
5
|
-
qdairlines_helper/controller/__init__.py,sha256=oyeciEBlDLNpqHblB0R-nXQG3HsI8L5mmlWulQ7Y38Q,482
|
|
6
|
-
qdairlines_helper/controller/add_passenger.py,sha256=GxaoSoLOH_XXTR79bDtSEbnmM_dSpBko6OzlrQtuT7U,5159
|
|
7
|
-
qdairlines_helper/controller/book_payment.py,sha256=x_jrgmZ4REMn-Zii7ZUQpuX3j8YAEFe8omt1Fm1z7YY,6059
|
|
8
|
-
qdairlines_helper/controller/book_search.py,sha256=5Tnuolm92HwbIgwhg1SF7e7bPbV2ZRluVTfVxjna-oI,9153
|
|
9
|
-
qdairlines_helper/controller/cash_pax_info.py,sha256=V5QKlvbWp8eF6gRos818w-9MyuienjgECkKKZkxCys8,2511
|
|
10
|
-
qdairlines_helper/controller/home.py,sha256=KzTyl7vvI3_Blc-XQ8ItueGR1hnV6f9gEdYalfXG9Ws,1394
|
|
11
|
-
qdairlines_helper/controller/nhlms_cashdesk.py,sha256=Fai8zZiqhUJl5-RWdkaGOdB3GTd5UQ7fpXDt4Emv65w,4312
|
|
12
|
-
qdairlines_helper/controller/order_detail.py,sha256=LEYrxcGx3kcYuJ9IZa-crRhCJLYTppdMVUu8hEXGrnI,3154
|
|
13
|
-
qdairlines_helper/controller/order_query.py,sha256=JzNrJj6HRHSJMQhszucWPf6nWQl4Y5B7oE1N9SpD47k,1907
|
|
14
|
-
qdairlines_helper/controller/order_verify.py,sha256=G9CC4a6KZg-VdWH6hzHDN7DkaoW2J9_yc7-mE2fL7Ms,2273
|
|
15
|
-
qdairlines_helper/controller/pay_success.py,sha256=tegkKa2b2R8ZqYTtGI6LqqW7h3SShpvM26cf_syi14E,3180
|
|
16
|
-
qdairlines_helper/controller/user_login.py,sha256=7PBbzP7doeUEy4M_Igb32IhjT4GzY_I-U3YimxekR_Q,4735
|
|
17
|
-
qdairlines_helper/http/__init__.py,sha256=96AJPf2zgw_rm3Wv-boIBltWFgZH3Yo-fn5M9SRK280,489
|
|
18
|
-
qdairlines_helper/http/flight_order.py,sha256=tC25YNk1pDzMmk4Zy6v120PwNuuaDhlHFh5xPBxtKco,3665
|
|
19
|
-
qdairlines_helper/po/__init__.py,sha256=HoouLJGLu_dI6IAKTVjBRraGHMcAUgntayTph-BUBAE,481
|
|
20
|
-
qdairlines_helper/po/add_passenger_page.py,sha256=XpaU6g7YSLhA8h3bHWJ_6CwnwgUmRtmLulPoRhkQ6_I,8000
|
|
21
|
-
qdairlines_helper/po/air_order_page.py,sha256=0Ux0B2hUGKCoFLRpJqGHS2w690o0A2PDnvRf9-UKfJE,930
|
|
22
|
-
qdairlines_helper/po/book_search_page.py,sha256=6EgA-yAqwzyT6FIMQD901-LmVmht5eBFiwLiKCE_MEs,10848
|
|
23
|
-
qdairlines_helper/po/cash_pax_info_page.py,sha256=iJlmIxD8IKnMyTNcylmoz9jV0k4u-B5ALXZEUcRajY4,3401
|
|
24
|
-
qdairlines_helper/po/home_page.py,sha256=KvoOZOYwKjlJjZOT522K_8ic3_2zaYOPWkuklUHVSlM,907
|
|
25
|
-
qdairlines_helper/po/login_page.py,sha256=SdWmkP_47GeosbFRcfvXLeQxxdM7b9UESvmajWq4-nA,2975
|
|
26
|
-
qdairlines_helper/po/nhlms_cash_desk_page.py,sha256=TwqszVbCc4iRSE684uafdlGJB1VC5wS9ZuGWvfeb8Fo,4542
|
|
27
|
-
qdairlines_helper/po/order_verify_page.py,sha256=omgs6CBPTPCGnO8cxRFd2ePFUrJZVD5cD_GBCXsZIes,2917
|
|
28
|
-
qdairlines_helper/po/pay_success_page.py,sha256=XGddo8as8wf1kCCdvemqHIRWOPIPv1JG8iXEmpH4zck,1329
|
|
29
|
-
qdairlines_helper/utils/__init__.py,sha256=sti2S709puM2mQbQisk0KGq_YNjW6T4zz2vyYXonNB0,479
|
|
30
|
-
qdairlines_helper/utils/exception_utils.py,sha256=rXPao6h9sW5uL3lUA36FS3WTlePAm5EZ6MBjWeJJTUs,3934
|
|
31
|
-
qdairlines_helper/utils/po_utils.py,sha256=74ZVyyxPmPk1tcGQoMauXhBE3qsZJej8urni1ch27io,2417
|
|
32
|
-
python_qdairlines_helper-0.2.6.dist-info/METADATA,sha256=aTq22fxpTiqZKIUBftm2IPxgGj2vxmrO9OxSGppduqU,14424
|
|
33
|
-
python_qdairlines_helper-0.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
34
|
-
python_qdairlines_helper-0.2.6.dist-info/top_level.txt,sha256=MRbQkBMdSG4f5mx2RWfu6aXoDSyM-2KwL-YFqNBdbng,18
|
|
35
|
-
python_qdairlines_helper-0.2.6.dist-info/RECORD,,
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""
|
|
3
|
-
# ---------------------------------------------------------------------------------------------------------
|
|
4
|
-
# ProjectName: python-qdairlines-helper
|
|
5
|
-
# FileName: exception_utils.py
|
|
6
|
-
# Description: 异常工具模块
|
|
7
|
-
# Author: ASUS
|
|
8
|
-
# CreateDate: 2026/01/07
|
|
9
|
-
# Copyright ©2011-2026. Hunan xxxxxxx Company limited. All rights reserved.
|
|
10
|
-
# ---------------------------------------------------------------------------------------------------------
|
|
11
|
-
"""
|
|
12
|
-
from typing import Literal
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class DuplicatePaymentError(Exception):
|
|
16
|
-
def __init__(self, order_no: str):
|
|
17
|
-
self.order_no = order_no
|
|
18
|
-
super().__init__(f"订单<{order_no}>重复支付")
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class NotEnoughTicketsError(Exception):
|
|
22
|
-
def __init__(self, flight_no: str, seats_status: int, passengers: int):
|
|
23
|
-
self.flight_no = flight_no
|
|
24
|
-
self.seats_status = seats_status
|
|
25
|
-
self.passengers = passengers
|
|
26
|
-
super().__init__(f"青岛航空官网显示航班<{flight_no}>的余票<{seats_status}>少于乘客人数<{passengers}>")
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
class ExcessiveProfitdError(Exception):
|
|
30
|
-
def __init__(
|
|
31
|
-
self, flight_no: str, query_price: float, order_price: float, reduction_threshold: float,
|
|
32
|
-
asset: Literal["票面价", "销售价"] = "票面价"
|
|
33
|
-
):
|
|
34
|
-
self.flight_no = flight_no
|
|
35
|
-
self.query_price = query_price
|
|
36
|
-
self.order_price = order_price
|
|
37
|
-
self.reduction_threshold = reduction_threshold
|
|
38
|
-
self.asset = asset
|
|
39
|
-
super().__init__(
|
|
40
|
-
f"航班<{flight_no}>官网价:{query_price} 低于:订单{asset}[{order_price}] - 下降阈值[{reduction_threshold}],收益过高"
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
class ExcessiveLossesError(Exception):
|
|
45
|
-
def __init__(
|
|
46
|
-
self, flight_no: str, query_price: float, order_price: float, increase_threshold: float,
|
|
47
|
-
asset: Literal["票面价", "销售价"] = "票面价"
|
|
48
|
-
):
|
|
49
|
-
self.flight_no = flight_no
|
|
50
|
-
self.query_price = query_price
|
|
51
|
-
self.order_price = order_price
|
|
52
|
-
self.increase_threshold = increase_threshold
|
|
53
|
-
self.asset = asset
|
|
54
|
-
super().__init__(
|
|
55
|
-
f"航班<{flight_no}>官网价:{query_price} 高于:订单{asset}[{order_price}] + 上浮阈值[{increase_threshold}],亏损太多"
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
class PaymentChannelError(Exception):
|
|
60
|
-
def __init__(self, channel_name: str):
|
|
61
|
-
self.channel_name = channel_name
|
|
62
|
-
super().__init__(f"支付渠道<{channel_name}>暂不支持")
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
class PaymentChannelMissError(Exception):
|
|
66
|
-
def __init__(self):
|
|
67
|
-
super().__init__(f"支付渠道参数丢失")
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
class PaymentTypeError(Exception):
|
|
71
|
-
def __init__(self, payment_type: str):
|
|
72
|
-
self.payment_type = payment_type
|
|
73
|
-
super().__init__(f"付款方式<{payment_type}>暂不支持")
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
class PassengerTypeError(Exception):
|
|
77
|
-
def __init__(self, passenger_type: str):
|
|
78
|
-
self.passenger_type = passenger_type
|
|
79
|
-
super().__init__(f"乘客类型<{passenger_type}>暂不支持")
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
class ProductTypeError(Exception):
|
|
83
|
-
def __init__(self, product_type: str):
|
|
84
|
-
self.product_type = product_type
|
|
85
|
-
super().__init__(f"产品类型<{product_type}>暂不支持")
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
class HFPaymentTypeError(Exception):
|
|
89
|
-
def __init__(self, payment_type: str):
|
|
90
|
-
self.payment_type = payment_type
|
|
91
|
-
super().__init__(f"汇付天下的付款方式<{payment_type}>暂不支持")
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
class PaymentFailedError(Exception):
|
|
95
|
-
def __init__(self, pre_order_no: str, order_status: str):
|
|
96
|
-
self.pre_order_no = pre_order_no
|
|
97
|
-
self.order_status = order_status
|
|
98
|
-
super().__init__(f"青岛航空官网订单<{pre_order_no}>支付失败,支付结束后的状态<{order_status}>")
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
class IPBlockError(Exception):
|
|
102
|
-
|
|
103
|
-
def __init__(self, message: str):
|
|
104
|
-
self.message = message
|
|
105
|
-
super().__init__(message)
|
|
File without changes
|
|
File without changes
|
{python_qdairlines_helper-0.2.6.dist-info → python_qdairlines_helper-0.6.0.dist-info}/top_level.txt
RENAMED
|
File without changes
|