You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.0 KiB
63 lines
2.0 KiB
|
1 week ago
|
import json
|
||
|
|
import requests
|
||
|
|
import pymysql
|
||
|
|
from pymysql.cursors import DictCursor
|
||
|
|
|
||
|
|
# 通过SQL设置要取哪些测试结果的票
|
||
|
|
get_code_sql = "SELECT take_ticket_code FROM multi_cards_pay_test;"
|
||
|
|
|
||
|
|
# 自助取票机Cookie设置, 如果失效需要手动设置
|
||
|
|
cookie = 'cookie_auto_user_id=1004; _dx_srccode=auto1; TSID=i2lp4qdmvvbl5dr7qtorukngn6'
|
||
|
|
|
||
|
|
# 取票影院
|
||
|
|
host = '192.168.55.97'
|
||
|
|
|
||
|
|
# 测试用例数据库设置
|
||
|
|
db_config_test = {
|
||
|
|
'host': '192.168.55.97',
|
||
|
|
'database': 'quan_list',
|
||
|
|
'user': 'dbadmin',
|
||
|
|
'password': 'fXMSR37mLP7w88ji'
|
||
|
|
}
|
||
|
|
|
||
|
|
# 请求头设置
|
||
|
|
headers = {
|
||
|
|
'Accept': 'application/json, text/javascript, */*',
|
||
|
|
'Accept-Encoding': 'gzip, deflate',
|
||
|
|
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
||
|
|
'Connection': 'keep-alive',
|
||
|
|
'Cookie': cookie,
|
||
|
|
'Host': host,
|
||
|
|
'Referer': f'http://{host}/?m=auto',
|
||
|
|
'User-Agent': 'DX_2.3.0.42076/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.7) Gecko YHZ_Client_Test',
|
||
|
|
}
|
||
|
|
|
||
|
|
# 创建测试用例数据库实例
|
||
|
|
db_conn_test = pymysql.Connect(**db_config_test)
|
||
|
|
db_cursor_test = db_conn_test.cursor(cursor=DictCursor)
|
||
|
|
|
||
|
|
# 查询可用的取票码
|
||
|
|
db_cursor_test.execute(get_code_sql)
|
||
|
|
take_ticket_code_list = db_cursor_test.fetchall()
|
||
|
|
print(take_ticket_code_list)
|
||
|
|
|
||
|
|
for code in list(take_ticket_code_list):
|
||
|
|
if code["take_ticket_code"] == '' or code["take_ticket_code"] is None:
|
||
|
|
continue
|
||
|
|
print('取票码:', code["take_ticket_code"])
|
||
|
|
|
||
|
|
# 获取影票编码
|
||
|
|
url = f'http://{host}/?m=Auto&a=getsaleBySmscode&type=ajax&smscode={code["take_ticket_code"]}'
|
||
|
|
r = requests.get(url, headers=headers).json()
|
||
|
|
if r['status'] != 1000:
|
||
|
|
print(r, '\r\n')
|
||
|
|
continue
|
||
|
|
for t_num, val in r['printinfo'][code["take_ticket_code"]]['ticketprint'].items():
|
||
|
|
print('专资票号:', t_num)
|
||
|
|
print('鼎新票号:', json.loads(val)['TicketSellId'])
|
||
|
|
url = f'http://{host}/?m=Auto&a=updateTicketStatus&type=ajax&sellid={t_num}&gettypeid=1'
|
||
|
|
r = requests.get(url, headers=headers)
|
||
|
|
print('取票结果', r.text)
|
||
|
|
print('\r\n')
|
||
|
|
|