Browse Source

优化候补逻辑

pull/569/head
文贤平 5 years ago
parent
commit
6d9ebc9b8a
  1. 13
      TickerConfig.py
  2. 5
      Update.md
  3. 19
      init/select_ticket_info.py
  4. 2
      inter/ChechFace.py
  5. 7
      inter/Query.py
  6. 2
      inter/SubmitOrderRequest.py

13
TickerConfig.py

@ -1,18 +1,20 @@
# 关于软件使用配置说明,一定要看!!!
# ps: 如果是候补车票,需要通过人证一致性核验的用户及激活的“铁路畅行”会员可以提交候补需求,请您按照操作说明在铁路12306app.上完成人证核验
# 这个日期一定要填小于最长订票时间(30天)
# t("#fromDate").val() + "#" + t("#dafaultTime").html().replace("时", "") + "#" + t("#dafaultMinutes").html().replace("分", ""),
# 关于候补了之后是否还能继续捡漏的问题在此说明: 软件为全自动候补加捡漏,如果软件候补成功则会停止抢票,发出邮件通知,但是不会影响你继续捡漏,
# 如果这个时候捡漏捡到的话,也是可以付款成功的,也就是说,捡漏+候补,可以最大程度提升抢票成功率
# 候补最晚兑现日期,目前软件为捡漏加自动候补,所以这个值一定要填
# 刷票模式:1=刷票 2=候补+刷票
TICKET_TYPE = 2
# 候补最晚兑现日期,目前软件为捡漏加自动候补,所以这个值一定要填,并且这个日期一定要填小于最长订票时间(30天)
# 格式为日期+小时+分
# 举例: 比如今天才可以买10.1号的票,比如你那个发车是10.1号上午两点,你兑现时间写到10.1晚上22点?
# t("#fromDate").val() + "#" + t("#dafaultTime").html().replace("时", "") + "#" + t("#dafaultMinutes").html().replace("分", ""),
J_Z_PARAM = "2019-09-28#22#59"
# 出发日期(list) "2018-01-06", "2018-01-07"
STATION_DATES = [
"2019-09-27"
"2019-10-01"
]
# 填入需要购买的车次(list),"G1353"
@ -125,3 +127,6 @@ PASSENGER_TICKER_STR = {
'软卧': 4,
'硬卧': 3,
}
# 软件版本
RE_VERSION = "1.0.101"

5
Update.md

@ -168,3 +168,8 @@
- 剔除新增TICKET_TYPE字段,发现此字段冗余,目前改为全天自动候补+捡漏
- 增加候补订单功能
- 优先级:下单再候补
- 2019.09.03更新
- 恢复TICKET_TYPE字段,1=刷票 2=候补+刷票
- 优化候补逻辑
- 候补订单只能在规定车次内候补

19
init/select_ticket_info.py

@ -54,8 +54,10 @@ class select:
:return:
"""
print(u"*" * 50)
print(f"检查当前版本为: {TickerConfig.RE_VERSION}")
print(u"检查当前python版本为:{},目前版本只支持3.6以上".format(sys.version.split(" ")[0]))
print(u"12306刷票小助手,最后更新于2019.01.08,请勿作为商业用途,交流群号:286271084(已满),"
print(u"12306刷票小助手,最后更新于2019.09.03,请勿作为商业用途,交流群号:"
u" 1群:286271084(已满)\n"
u" 2群:649992274(已满)\n"
u" 3群:632501142(已满)\n"
u" 4群: 606340519(已满)\n"
@ -236,19 +238,8 @@ class select:
c.sendChechFace()
else:
random_time = round(random.uniform(sleep_time_s, sleep_time_t), 2)
print(u"正在第{0}次查询 随机停留时长:{6} 乘车日期: {1} 车次:{2} 查询无票 cdn轮询IP:{4}当前cdn总数:{5} 总耗时:{3}ms".format(num,
",".join(
TickerConfig.STATION_DATES),
",".join(
TickerConfig.STATION_TRAINS),
(
datetime.datetime.now() - now).microseconds / 1000,
queryResult.get(
"cdn",
None),
len(
self.cdn_list),
random_time))
nateMsg = ' 候补无资格' if TickerConfig.ORDER_TYPE == 2 else ""
print(f"正在第{num}次查询 随机停留时长:{random_time} 乘车日期: {','.join(TickerConfig.STATION_DATES)} 车次:{'.'.join(TickerConfig.STATION_TRAINS)} 下单无票{nateMsg} 耗时:{(datetime.datetime.now() - now).microseconds / 1000}ms")
time.sleep(random_time)
except PassengerUserException as e:
print(e)

2
inter/ChechFace.py

@ -33,7 +33,7 @@ class chechFace:
print("".join(chechFaceRsp.get("messages")) or chechFaceRsp.get("validateMessages"))
return
data = chechFaceRsp["data"]
if not data.get("face_flag") and data.get("face_check_code") == 14:
if not data.get("face_flag"):
"""
未通过人脸核验
"""

7
inter/Query.py

@ -91,12 +91,11 @@ class query:
# "status": True,
# }
# elif TickerConfig.TICKET_TYPE is 1:
if ticket_info[1] == "预订": # 筛选未在开始时间内的车次
if ticket_info[1] == "预订" and self.check_is_need_train(ticket_info): # 筛选未在开始时间内的车次
for j in self._station_seat:
is_ticket_pass = ticket_info[j]
if ticket_info[11] == "Y":
if is_ticket_pass != '' and is_ticket_pass != '' and is_ticket_pass != '*' and self.check_is_need_train(
ticket_info): # 过滤有效目标车次
if is_ticket_pass != '' and is_ticket_pass != '' and is_ticket_pass != '*': # 过滤有效目标车次
secretStr = ticket_info[0]
train_no = ticket_info[2]
query_from_station_name = ticket_info[6]
@ -149,7 +148,7 @@ class query:
"cdn": self.httpClint.cdn,
"status": True,
}
elif is_ticket_pass == '' and ticket_info[-2] == "1":
elif is_ticket_pass == '' and ticket_info[-2] == "1" and TickerConfig.TICKET_TYPE is 2:
"""
is_ticket_pass如果有别的显示但是可以候补可以提issues提出来附上query log我将添加上
判断车次是否可以候补

2
inter/SubmitOrderRequest.py

@ -102,7 +102,7 @@ class submitOrderRequestByAfterNate:
def sendSubmitOrderRequest(self, ):
submitOrderRequestRsp = self.session.httpClint.send(urls.get("SubmitOrderRequestRsp"), self.data_apr())
if not submitOrderRequestRsp.get("status"):
if not submitOrderRequestRsp.get("status") or not submitOrderRequestRsp.get("data", {}).get("flag"):
print("".join(submitOrderRequestRsp.get("messages")) or submitOrderRequestRsp.get("validateMessages"))
return
confirm = confirmHB(self.secretList, self.session, self.tickerNo)

Loading…
Cancel
Save