Пример #1
0
        /// <summary>
        /// 消费通知接口
        /// </summary>
        /// <param name="noticeOrderConsumedRequest"></param>
        /// <returns></returns>
        public static bool Run(OrderOrderTravelNoticeBodyRequest orderOrderTravelNoticeBodyRequest)
        {
            var request = new OrderTravelNoticeRequest
            {
                header = new RequestHeader
                {
                    AccountId   = CtripConfig.AccountId,
                    ServiceName = "OrderTravelNotice",
                    RequestTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    Version     = CtripConfig.Version
                }
            };
            var body = Api.BodyForAesEncrypt(orderOrderTravelNoticeBodyRequest);
            var sign = Helper.MakeSign(request.header, body);

            request.header.Sign = sign;
            request.body        = body;
            var data   = JsonSerializeHelper.ToJsonForlowercase(request);
            var contnt = HttpService.Post(data, CtripConfig.Website);

            Console.WriteLine("携程订单号:" + orderOrderTravelNoticeBodyRequest.OtaOrderId);
            Console.WriteLine("返回内容  :" + contnt);
            if (!string.IsNullOrEmpty(contnt))
            {
                var requestBody = Api.CheckBodyData <PublicResponse>(contnt);
                if (requestBody == null)
                {
                    return(false);
                }
                if (requestBody.Data.header.resultCode == ResultCode.Success)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #2
0
 /// <summary>
 /// 出行通知接口
 /// </summary>
 /// <param name="noticeOrderConsumedRequest"></param>
 /// <returns></returns>
 public bool OrderTravelNotice(OrderOrderTravelNoticeBodyRequest orderOrderTravelNoticeBodyRequest)
 {
     return(OrderTravelNoticeService.Run(orderOrderTravelNoticeBodyRequest));
 }
Пример #3
0
        public void VerifyTicket()
        {
            var list = _orderTravelNoticeService.GetList();

            foreach (var row in list)
            {
                var orderDetails = _orderDetailService.GetList(row.OrderNo);



                var confirmBodyRequest = new CreateOrderConfirmBodyRequest
                {
                    OtaOrderId           = row.OtaOrderId,
                    SupplierOrderId      = row.OrderNo,
                    SequenceId           = row.SequenceId,
                    confirmResultCode    = "0000",
                    confirmResultMessage = "确认成功",
                    voucherSender        = 1,
                    vouchers             = new List <CreateOrderConfirmVouchersRequest>(),
                    items = new List <CreateOrderConfirmItemRequest>()
                };
                foreach (var item in orderDetails)
                {
                    confirmBodyRequest.vouchers.Add(new CreateOrderConfirmVouchersRequest
                    {
                        itemId      = item.OtaOrderDetailId,
                        voucherType = 2,
                        voucherCode = item.CertificateNO,
                        voucherData = ""
                    });
                    confirmBodyRequest.items.Add(new CreateOrderConfirmItemRequest
                    {
                        itemId     = item.OtaOrderDetailId,
                        inventorys = new List <CreateOrderConfirmInventoryRespose> {
                            new  CreateOrderConfirmInventoryRespose {
                                quantity = 50000,
                                useDate  = item.ValidityDateStart.ToString("yyyy-MM-dd")
                            }
                        }
                    });
                }

                var ddd = _ctripGateway.CreateOrderConfirm(confirmBodyRequest);
                Console.WriteLine("订单确认接口,携程订单号:" + row.OrderNo + "  是否成功: " + ddd);



                var bodyRequest = new OrderOrderTravelNoticeBodyRequest
                {
                    OtaOrderId      = row.OtaOrderId,
                    SupplierOrderId = row.OrderNo,
                    SequenceId      = row.SequenceId,
                    vouchers        = new List <OrderOrderTravelNoticeVouchersRequest>(),
                    items           = new List <OrderTravelNoticeItemRequest>()
                };
                foreach (var item in orderDetails)
                {
                    bodyRequest.vouchers.Add(new OrderOrderTravelNoticeVouchersRequest
                    {
                        itemId      = item.OtaOrderDetailId,
                        voucherType = 2,
                        voucherCode = item.CertificateNO,
                        voucherData = ""
                    });
                    bodyRequest.items.Add(new OrderTravelNoticeItemRequest
                    {
                        itemId             = item.OtaOrderDetailId,
                        travelInformations = new List <OrderTravelNoticeTravelInformationsRequest> {
                            new OrderTravelNoticeTravelInformationsRequest {
                                name    = "游玩时间",
                                content = item.ValidityDateStart.ToString("yyyy-MM-dd")
                            }
                        }
                    });
                }
                var isSuccess = _ctripGateway.OrderTravelNotice(bodyRequest);
                row.RunCount++;
                if (isSuccess)
                {
                    row.RunCount = 3;
                }
                _orderTravelNoticeService.Update(row.OrderNo, row.RunCount);
                Console.WriteLine("订单出行通知,携程订单号:" + row.OrderNo + "  是否成功: " + isSuccess);
            }
        }