/// <summary> /// 亚朵查询订单 /// </summary> /// <returns></returns> public DataResult AtourSearchOrder(string orderid) { var result = new DataResult(); var ordermodel = OrderBll.GetModel(orderid); //日志 var logmodel = new HO_HotelOrderLogModel { HOLOrderId = orderid, HOLLogType = 1,//订单日志 HOLAddId = 0, HOLAddName = "系统", HOLAddDepartId = 0, HOLAddDepartName = "系统", HOLAddTime = DateTime.Now }; if (ordermodel.Id > 0 && !string.IsNullOrWhiteSpace(ordermodel.HOSupplierSerialId)) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("orderNo", orderid); dic.Add("atourOrderNo", ordermodel.HOSupplierSerialId); dic.Add("appId", AtourAuth_APPID); var sign = AtourSignUtil.GetSignUtil(dic); var url = AtourAuth_URL + "baoku/order/queryOrder"; var orderrequest = new { orderNo = orderid, atourOrderNo = ordermodel.HOSupplierSerialId, appId = AtourAuth_APPID, sign = sign }; StringBuilder parm = new StringBuilder(); PropertyInfo[] request = orderrequest.GetType().GetProperties(); int j = 0; foreach (var t in request) { if (j > 0) { parm.Append("&"); } parm.AppendFormat("{0}={1}", t.Name, t.GetValue(orderrequest, null)); j++; } var orderresponse = ApiHelper.HttpPost(url, parm.ToString(), "application/x-www-form-urlencoded"); if (!string.IsNullOrWhiteSpace(orderresponse)) { var searchstatus = ""; var data = JsonConvert.DeserializeObject <JObject>(orderresponse); if (data["msg"].ToString().ToLower() == "success") { result.Code = DataResultType.Sucess; var oldstatus = GetStatus(ordermodel.HOStatus); if (data["result"] != null && data["result"].Any()) { var updatestatus = data["result"].FirstOrDefault(); if (updatestatus != null) { searchstatus = updatestatus["status"].ToString(); } } var up = OrderBll.UpdateAutorSataus(orderid, searchstatus); var neworder = OrderBll.GetModel(orderid); var newstatus = GetStatus(neworder.HOStatus); if (oldstatus != newstatus) { logmodel.HOLRemark = "亚朵查询订单接口返回:" + JsonConvert.SerializeObject(orderresponse); OrderLogBll.AddOrderModel(logmodel); logmodel.HOLRemark = "亚朵订单更新:亚朵返回订单状态" + searchstatus + "(1-预定 2-取消 3-夜审取消(即noshow) 4-入住 5-离店)" + "我方订单状态:" + oldstatus; OrderLogBll.AddOrderModel(logmodel); logmodel.HOLRemark = "我方订单更新:更新结果=" + (up > 0 ? "更新成功" : "更新失败") + "当前订单状态:" + newstatus; OrderLogBll.AddOrderModel(logmodel); //状态通知 int status = 0; switch (data["result"]["status"].ToString()) { case "1": status = 2; break; case "2": status = 1; break; case "3": status = 5; break; case "4": status = 3; break; case "5": status = 4; break; } if (status > 0) { var api = OpenApi.HotelOrderStatus(orderid, status); logmodel.HOLRemark = "状态更改通知飞猪:请求参数{id=" + orderid + ",状态:" + status + "};返回结果:" + api; OrderLogBll.AddOrderModel(logmodel); } } } else { result.Code = DataResultType.Fail; result.Message = data["msg"].ToString(); logmodel.HOLRemark = "亚朵订单更新:接口返回失败,失败原因:" + data["msg"].ToString(); OrderLogBll.AddOrderModel(logmodel); } } } return(result); }
/// <summary> /// 亚朵操作订单 /// </summary> /// <returns></returns> public DataResult AtourCancelOrder(string orderid) { var result = new DataResult(); result.Code = DataResultType.Fail; //日志 var logmodel = new HO_HotelOrderLogModel { HOLOrderId = orderid, HOLLogType = 1,//订单日志 HOLAddId = 0, HOLAddName = "系统", HOLAddDepartId = 0, HOLAddDepartName = "系统", HOLAddTime = DateTime.Now, }; var ordermodel = OrderBll.GetModel(orderid); if (ordermodel.Id > 0 && !string.IsNullOrWhiteSpace(ordermodel.HOSupplierSerialId)) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("atourOrderNo", ordermodel.HOSupplierSerialId); dic.Add("appId", AtourAuth_APPID); var sign = AtourSignUtil.GetSignUtil(dic); var url = AtourAuth_URL + "baoku/order/cancelOrder"; var orderrequest = new { atourOrderNo = ordermodel.HOSupplierSerialId, appId = AtourAuth_APPID, sign = sign }; StringBuilder parm = new StringBuilder(); PropertyInfo[] request = orderrequest.GetType().GetProperties(); int j = 0; foreach (var t in request) { if (j > 0) { parm.Append("&"); } parm.AppendFormat("{0}={1}", t.Name, t.GetValue(orderrequest, null)); j++; } var orderresponse = ApiHelper.HttpPost(url, parm.ToString(), "application/x-www-form-urlencoded"); logmodel.HOLRemark = "亚朵取消请求:" + parm.ToString() + "||亚朵取消接口返回:" + JsonConvert.SerializeObject(orderresponse); OrderLogBll.AddOrderModel(logmodel); if (!string.IsNullOrWhiteSpace(orderresponse)) { var data = JsonConvert.DeserializeObject <JObject>(orderresponse); if (data["msg"].ToString().ToLower() == "success") { result.Code = DataResultType.Sucess; OrderBll.UpdateAutorSataus(orderid, "2"); OpenApi.HotelOrderStatus(orderid, 5);//noshow } else { result.Code = DataResultType.Fail; } } } return(result); }