Example #1
0
 def _get_queue_count(self):
     form_data = {
         'train_date': datetime.datetime.strptime(
             self.ticket_passenger_info['queryLeftTicketRequestDTO']['train_date'], '%Y%m%d').strftime(
             '%b %a %d %Y 00:00:00 GMT+0800') + ' (中国标准时间)',
         'train_no': self.ticket_passenger_info['queryLeftTicketRequestDTO']['train_no'],
         'stationTrainCode': self.train.stationTrainCode.value,
         'seatType': self.seat_type.sys_code,
         'fromStationTelecode': self.train.from_station_code.value,
         'toStationTelecode': self.train.to_station_code.value,
         'leftTicket': self.ticket_passenger_info['leftTicketStr'],
         'purpose_codes': self.ticket_passenger_info['purpose_codes'],
         'train_location': self.ticket_passenger_info['train_location'],
         '_json_att': '',
         'REPEAT_SUBMIT_TOKEN': self.token
     }
     Log.v("正在获取排队信息以及余票信息中...")
     json_response = send_requests(LOGIN_SESSION, self.URLS['getQueueCount'], data=form_data)
     status, msg = submit_response_checker(json_response, ["status"], True, "获取余票信息成功")
     if status:
         self.left_tickets = json_response['data']['ticket']
         Log.v("票数剩余{0}张, 排队人数为{1}人".format(
             self.left_tickets,
             json_response['data']['count']
         ))
     else:
         BlackTrains.add_train(self.train)
     return status, msg
Example #2
0
 def _get_queue_count_async(self):
     form_data = {
         'train_date':
         datetime.datetime.strptime(
             self.train.train_date.value,
             '%Y%m%d').strftime('%b %a %d %Y 00:00:00 GMT+0800') +
         ' (中国标准时间)',
         'train_no':
         self.train.sys_train_no.value,
         'stationTrainCode':
         self.train.stationTrainCode.value,
         'seatType':
         self.seat_type.sys_code,
         'fromStationTelecode':
         self.train.from_station_code.value,
         'toStationTelecode':
         self.train.to_station_code.value,
         'leftTicket':
         self.ticket_passenger_info['leftTicketStr'],
         'purpose_codes':
         find_by_name("ticket", Config.basic_config.ticket_type).sys_code,
         '_json_att':
         ''
     }
     json_response = send_requests(LOGIN_SESSION,
                                   self.URLS['getQueueCountAsync'],
                                   data=form_data)
     status, msg = submit_response_checker(json_response, ["status"], True)
     if not status:
         BlackTrains.add_train(self.train)
     return status, msg
Example #3
0
 def filter_black_trains(self):
     result = []
     for v in self.result:
         flag = BlackTrains.check(v[1])
         if flag:
             Log.v("{0} 车次已经在小黑屋".format(v[1].stationTrainCode.value))
         else:
             result.append(copy.copy(v))
     return result
Example #4
0
 def _confirm_single_or_go_for_queue(self):
     form_data = {
         'passengerTicketStr':
         build_passenger_ticket_string(self.seat_type, self.passenger_data),
         'oldPassengerStr':
         build_oldpassenger_ticket_string(self.passenger_data),
         'randCode':
         '',
         'purpose_codes':
         self.ticket_passenger_info['purpose_codes'],
         'key_check_isChange':
         self.ticket_passenger_info['key_check_isChange'],
         'leftTicketStr':
         self.ticket_passenger_info['leftTicketStr'],
         'train_location':
         self.ticket_passenger_info['train_location'],
         'choose_seats':
         '',  # 暂时未加选座
         'seatDetailType':
         '000',
         'whatsSelect':
         '1',
         'roomType':
         '00',
         'dwAll':
         'N',
         '_json_att':
         '',
         'REPEAT_SUBMIT_TOKEN':
         self.token,
     }
     Log.v("正在为你请求排队提交订单")
     json_response = send_requests(LOGIN_SESSION,
                                   self.URLS['confirmForQueue'],
                                   data=form_data)
     status, msg = submit_response_checker(json_response,
                                           ["status", "data.submitStatus"],
                                           True, "请求排队成功")
     if not status:
         BlackTrains.add_train(self.train)
     return status, msg
Example #5
0
 def _wait_for_order_id(self):
     # 排队逻辑
     t = datetime.datetime.now()
     # 排队10分钟
     delta = datetime.timedelta(minutes=10)
     while not self.order_id:
         loop_time = datetime.datetime.now()
         status, msg = self._query_order_wait_time()
         Log.v(msg)
         s, data = find_by_phrase(msg)
         if s:
             self.break_submit, self.break_msg = False, data["msg"]
             return self.break_submit, self.break_msg
         # 5s 获取排队信息
         time.sleep(5)
         if self.order_id:
             return True, "OK"
         if loop_time > t + delta:
             BlackTrains.add_train(self.train)
             return False, "提交超时"
     return False, "排队失败"