Skip to content

Commit

Permalink
更新查询
Browse files Browse the repository at this point in the history
  • Loading branch information
testerSunshine committed Dec 14, 2019
1 parent 1fa45c2 commit 39e777e
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 13 deletions.
4 changes: 2 additions & 2 deletions UnitTest/TestAll.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/configCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ def checkDate(station_dates):
raise ticketConfigException(u"当前日期设置无符合查询条件的,已被全部删除,请查证后添加!!!")
else:
station_dates[station_dates.index(station_date)] = date
return station_dates
return station_dates
4 changes: 0 additions & 4 deletions init/login.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# -*- coding=utf-8 -*-
import copy
import json
import random
import re
import time
from collections import OrderedDict
from time import sleep
import TickerConfig
from config.urlConf import urls
from inter.GetPassCodeNewOrderAndLogin import getPassCodeNewOrderAndLogin1
from inter.GetRandCode import getRandCode
from inter.LoginAysnSuggest import loginAysnSuggest
Expand Down
2 changes: 1 addition & 1 deletion init/select_ticket_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self):
self.login = GoLogin(self, TickerConfig.IS_AUTO_CODE, self.auto_code_type)
self.cdn_list = []
self.cookies = ""
self.queryUrl = "leftTicket/query"
self.queryUrl = "leftTicket/queryO"
self.passengerTicketStrList = ""
self.passengerTicketStrByAfterLate = ""
self.oldPassengerStr = ""
Expand Down
1 change: 0 additions & 1 deletion inter/ConfirmSingleForQueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def sendConfirmSingleForQueue(self):
if "status" in checkQueueOrderResult and checkQueueOrderResult["status"]:
c_data = checkQueueOrderResult["data"] if "data" in checkQueueOrderResult else {}
if 'submitStatus' in c_data and c_data['submitStatus'] is True:
# print(u"提交订单成功!")
qow = queryOrderWaitTime(self.session)
qow.sendQueryOrderWaitTime()
else:
Expand Down
20 changes: 17 additions & 3 deletions inter/GetQueueCount.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ def data_par(self):
else:
new_train_date = list(filter(None, str(time.asctime(time.strptime(self.station_dates, "%Y-%m-%d"))).split(" ")))
data = OrderedDict()
data['train_date'] = "{0} {1} 0{2} {3} 00:00:00 GMT+0800 (中国标准时间)".format(
data['train_date'] = "{0} {1} {2} {3} 00:00:00 GMT+0800 (中国标准时间)".format(
new_train_date[0],
new_train_date[1],
new_train_date[2],
new_train_date[2] if len(new_train_date[2]) is 2 else f"0{new_train_date[2]}",
new_train_date[4],
),
data['train_no'] = self.ticketInfoForPassengerForm['queryLeftTicketRequestDTO']['train_no'],
Expand Down Expand Up @@ -88,7 +88,11 @@ def sendGetQueueCount(self):
ticket = getQueueCountResult["data"]["ticket"]
ticket_split = sum(map(conversion_int, ticket.split(","))) if ticket.find(",") != -1 else ticket
countT = getQueueCountResult["data"]["countT"]
# if int(countT) is 0:
if int(ticket_split) is 0:
wrapcache.set(key=self.train_no, value=datetime.datetime.now(),
timeout=TickerConfig.TICKET_BLACK_LIST_TIME * 60)
print(f"排队失败,当前余票数还剩: {ticket_split} 张")
return
print(u"排队成功, 你排在: {1}位, 当前余票还剩余: {0} 张".format(ticket_split, countT))
csf = confirmSingleForQueue(self.session, self.ifShowPassCodeTime, self.is_need_code, self.token,
self.set_type, self.ticket_peoples, self.ticketInfoForPassengerForm,
Expand Down Expand Up @@ -133,3 +137,13 @@ def sendQueryQueueByAfterNate(self):
raise ticketIsExitsException(ticket.WAIT_AFTER_NATE_SUCCESS)


if __name__ == '__main__':
new_train_date = list(filter(None, str(time.asctime(time.strptime("2019-10-07", "%Y-%m-%d"))).split(" ")))
print(new_train_date)
train_date = "{0} {1} {2} {3} 00:00:00 GMT+0800 (中国标准时间)".format(
new_train_date[0],
new_train_date[1],
new_train_date[2] if len(new_train_date[2]) is 2 else f"0{new_train_date[2]}",
new_train_date[4],
)
print(train_date)
8 changes: 7 additions & 1 deletion inter/GetQueueCountAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def data_par(self):
data['train_date'] = "{0} {1} {2} {3} 00:00:00 GMT+0800 (中国标准时间)".format(
new_train_date[0],
new_train_date[1],
new_train_date[2],
new_train_date[2] if len(new_train_date[2]) is 2 else f"0{new_train_date[2]}",
new_train_date[4],
time.strftime("%H:%M:%S", time.localtime(time.time()))
),
Expand Down Expand Up @@ -96,6 +96,12 @@ def sendGetQueueCountAsync(self):
ticket_data = getQueueCountAsyncResult["data"]["ticket"]
ticket_split = sum(map(self.conversion_int, ticket_data.split(","))) if ticket_data.find(
",") != -1 else ticket_data
if int(ticket_split) is 0:
# 增加余票数为0时,将车次加入小黑屋
wrapcache.set(key=self.train_no, value=datetime.datetime.now(),
timeout=TickerConfig.TICKET_BLACK_LIST_TIME * 60)
print(f"排队失败,当前余票数为{ticket_split}张")
return
print(u"排队成功, 当前余票还剩余: {0} 张".format(ticket_split))
c = confirmSingleForQueueAsys(session=self.session,
passengerTicketStr=self.passengerTicketStr,
Expand Down
8 changes: 8 additions & 0 deletions inter/PassengerInitApi.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import datetime
import wrapcache
import TickerConfig
from config.urlConf import urls
from inter.ConfirmHB import confirmHB

Expand All @@ -18,6 +21,11 @@ def sendPassengerInitApi(self):
return
data = passengerInitApiRsp.get("data", {})
jzdhDateE = data.get("jzdhDateE")
if not data.get("jzdhHourE"):
wrapcache.set(key=f"hb{self.tickerNo}", value=datetime.datetime.now(),
timeout=TickerConfig.TICKET_BLACK_LIST_TIME * 60)
print(f"获取当前候补日期失败,原因: {data.get('jzdhHourE')}")
return
jzdhHourE = data.get("jzdhHourE").replace(":", "#")
jzdhDate = f"{jzdhDateE}#{jzdhHourE}"
print(f"当前候补日期为:{jzdhDateE} {jzdhHourE}")
Expand Down

0 comments on commit 39e777e

Please sign in to comment.