public async Task <Base12306cnResult <string> > SubmitOrderRequestAsync(SubmitOrderRequestInfo reqInfo) { var request = CreateRequest(UrlsIn12306cn._submitOrderRequestUrl, reqInfo.Referer, HttpMethodOptions.Post); //request.Method = MethodOptions.Post; request.AddParameter(HttpR.ContentTypeKey, HttpR.ContentType, ParameterOptions.HttpContentHeader); request.AddParameter("secretStr", reqInfo.SecretStr); //request.AddParameter("train_date", reqInfo.TrainDate); request.AddParameter("back_train_date", reqInfo.BackTrainDate); request.AddParameter("tour_flag", reqInfo.TourFlag); request.AddParameter("purpose_codes", reqInfo.PurposeCode); request.AddParameter("query_from_station_name", reqInfo.FromStation); request.AddParameter("query_to_station_name", reqInfo.ToStation); request.AddParameter("undefined", string.Empty); var res = await _netClientService.ExecuteAsync(request); Console.WriteLine("SubmitOrderRequestAsync,res.ResponseUri:{0},res.Content:{1} /r/n", res.ResponseUri, res.Content); Console.WriteLine("----------------------------------------------------------------"); return(res.Content.ToModel <Base12306cnResult <string> >()); }
public async Task Execute12306cnAsync(Execute12306cnInfo execute12306cnInfo) { _execute12306cnInfo = execute12306cnInfo; _userOrderInfo = GetUserOrderInfo(execute12306cnInfo.UserName); var otnLeftTicketQueryInfo = new OtnLeftTicketQueryInfo { PurposeCode = _userOrderInfo.PurposeCode, Date = _userOrderInfo.RideDate, FromStation = _userOrderInfo.FromStationCode, ToStation = _userOrderInfo.ToStationCode }; otnLeftTicketQueryInfo.Referer = string.Format(UrlsIn12306cn._otnLeftTicketInitUrl, _userOrderInfo.TourFlag, string.Format("{0},{1}", _userOrderInfo.FromStationName, _userOrderInfo.FromStationCode), string.Format("{0},{1}", _userOrderInfo.ToStationName, _userOrderInfo.ToStationCode), _userOrderInfo.RideDate, "N,N,Y"); var otnLeftTicketQueryResult = await OtnLeftTicketQueryAsync(otnLeftTicketQueryInfo); if (otnLeftTicketQueryResult == null) { return; } var tickets = ParseToTickets(otnLeftTicketQueryResult.data); if (tickets == null || !tickets.Any()) { return; } var ticketInfo = tickets.FirstOrDefault(m => !string.IsNullOrEmpty(m.TrainNo) && m.TrainNo.ToUpper().StartsWith(_userOrderInfo.TrainType.ToString().ToUpper())); Console.WriteLine("Execute12306cnAsync,ticketInfo:{0} /r/n", JsonConvert.SerializeObject(ticketInfo)); Console.WriteLine("----------------------------------------------------------------"); if (ticketInfo == null) { return; } var submitOrderRequestInfo = new SubmitOrderRequestInfo { SecretStr = ticketInfo.SecretStr, TrainDate = _userOrderInfo.RideDate, BackTrainDate = _userOrderInfo.BackRideDate, FromStation = _userOrderInfo.FromStationName, ToStation = _userOrderInfo.ToStationName, TourFlag = _userOrderInfo.TourFlag, PurposeCode = _userOrderInfo.PurposeCode, Referer = otnLeftTicketQueryInfo.Referer }; var submitOrderRequestResult = await SubmitOrderRequestAsync(submitOrderRequestInfo); if (submitOrderRequestResult == null) { return; } var confirmPassengerInitDcResult = await OtnConfirmPassengerInitDcAsync(otnLeftTicketQueryInfo.Referer); if (confirmPassengerInitDcResult == null) { return; } var confirmPassengerDTOsResult = await ConfirmPassengerDTOsAsync(confirmPassengerInitDcResult.GlobalRepeatSubmitToken); if (confirmPassengerDTOsResult == null) { return; } var passengerInfo = confirmPassengerDTOsResult.data.normal_passengers.FirstOrDefault(); if (passengerInfo == null) { Console.WriteLine("ConfirmPassengerDTOsAsync,passengerInfo is null"); return; } var confirmPassengerCheckOrderInfo = new ConfirmPassengerCheckOrderInfo { RepeatSubmitToken = confirmPassengerInitDcResult.GlobalRepeatSubmitToken, JsonAtt = string.Empty, BedLevelOrderNum = "000000000000000000000000000000", CancelFlag = 2, OldPassengerStr = Enum12306Datas.OldPassengerStrFormat(passengerInfo), PassengerTicketStr = Enum12306Datas.PassengerTicketStrFormat(_userOrderInfo, passengerInfo), TourFlag = _userOrderInfo.TourFlag, WhatsSelect = 1, Referer = UrlsIn12306cn._otnConfirmPassengerInitDcUrl }; var confirmPassengerCheckOrderResult = await ConfirmPassengerCheckOrderAsync(confirmPassengerCheckOrderInfo); if (!confirmPassengerCheckOrderResult.data.submitStatus) { return; } var confirmPassengerQueueCountInfo = new ConfirmPassengerQueueCountInfo { TrainDate = DateTime.Parse(_userOrderInfo.RideDate).ToCst(), TrainNo = ticketInfo.TrainCode, RepeatSubmitToken = confirmPassengerInitDcResult.GlobalRepeatSubmitToken, FromStationTelecode = ticketInfo.FromStationTelecode, ToStationTelecode = ticketInfo.ToStationTelecode, LeftTicket = confirmPassengerInitDcResult.TicketInfoForPassengerInfo.leftTicketStr, PurposeCode = confirmPassengerInitDcResult.TicketInfoForPassengerInfo.purpose_codes, SeatType = _userOrderInfo.SeatType.ToString(), TrainLocation = confirmPassengerInitDcResult.TicketInfoForPassengerInfo.train_location, StationTrainCode = ticketInfo.TrainNo, Referer = UrlsIn12306cn._otnConfirmPassengerInitDcUrl }; var confirmPassengerQueueCountResult = await ConfirmPassengerQueueCountAsync(confirmPassengerQueueCountInfo); var confirmSingleForQueueInfo = new ConfirmSingleForQueueInfo (confirmPassengerCheckOrderInfo.Referer, confirmPassengerInitDcResult.GlobalRepeatSubmitToken, confirmPassengerCheckOrderInfo.JsonAtt, null, null, confirmPassengerInitDcResult.TicketInfoForPassengerInfo.key_check_isChange, confirmPassengerInitDcResult.TicketInfoForPassengerInfo.leftTicketStr, confirmPassengerCheckOrderInfo.OldPassengerStr, confirmPassengerCheckOrderInfo.PassengerTicketStr, _userOrderInfo.PurposeCode, null, null, null, ticketInfo.TrainLocation, confirmPassengerCheckOrderInfo.WhatsSelect.ToString() ); var confirmSingleForQueueResult = await ConfirmSingleForQueueAsync(confirmSingleForQueueInfo); }