mirror of
https://github.com/cqwu-ehall/cqwu-ehall.git
synced 2024-11-25 19:56:27 +00:00
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
from typing import List
|
|
|
|
import cqwu
|
|
from cqwu.types.order import Order
|
|
|
|
|
|
class GetOrders:
|
|
async def get_orders(
|
|
self: "cqwu.Client",
|
|
page: int = 1,
|
|
page_size: int = 10,
|
|
search: str = ""
|
|
) -> List[Order]:
|
|
"""
|
|
获取历史订单
|
|
|
|
:param page: 页码
|
|
:param page_size: 每页数量
|
|
:param search: 搜索关键字
|
|
|
|
:return: 订单列表
|
|
"""
|
|
url = "http://pay.cqwu.edu.cn/queryOrderList"
|
|
params = {
|
|
"orderno": search,
|
|
"page": page,
|
|
"pagesize": page_size,
|
|
}
|
|
if "pay.cqwu.edu.cn" not in self.init_sub_web:
|
|
await self.oauth(
|
|
"http://authserver.cqwu.edu.cn/authserver/login?service="
|
|
"http%3A%2F%2Fpay.cqwu.edu.cn%2FsignAuthentication%3Furl%3DopenPortal")
|
|
async with self.request(cookies=self.sub_cookies, follow_redirects=True) as client:
|
|
html = await client.get(url, params=params)
|
|
try:
|
|
data = html.json()["payOrderList"]
|
|
except KeyError:
|
|
return []
|
|
return [Order(**order) for order in data]
|