初始化
This commit is contained in:
867
BLV_API/Controllers/ApiController.cs
Normal file
867
BLV_API/Controllers/ApiController.cs
Normal file
@@ -0,0 +1,867 @@
|
||||
using BLV_API.Dal;
|
||||
using BLV_API.Models;
|
||||
using BLWWS;
|
||||
|
||||
//using BLWWS;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Http.Results;
|
||||
using System.Web.Mvc;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using static BLV_API.Models.BLVEntity;
|
||||
|
||||
namespace BLV_API.Controllers
|
||||
{
|
||||
public class ApiController : Controller
|
||||
{
|
||||
public readonly string _bjInterfaceUrl = System.Configuration.ConfigurationManager.AppSettings["bjInterfaceUrl"];
|
||||
public ActionResult Index()
|
||||
{
|
||||
ViewBag.Title = "宝来威客控与PMS对接API";
|
||||
return View();
|
||||
}
|
||||
/// <summary>
|
||||
/// 入住接口
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ActionResult checkin()
|
||||
{
|
||||
string IP = Tools.GetClientIP(Request);
|
||||
Request.InputStream.Position = 0;
|
||||
byte[] reqBody = new byte[Request.InputStream.Length];
|
||||
Request.InputStream.Read(reqBody, 0, reqBody.Length);
|
||||
string reqData = System.Text.Encoding.UTF8.GetString(reqBody);
|
||||
if (string.IsNullOrEmpty(reqData))
|
||||
{
|
||||
return Json(new BLVEntity.Result() { code = 4001, msg = "传递参数不能为空" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
try
|
||||
{
|
||||
BLVEntity.Root req = JsonConvert.DeserializeObject<BLVEntity.Root>(reqData);
|
||||
if (string.IsNullOrEmpty(req.hotel_code))
|
||||
{
|
||||
LogHelper.WriteLog($"hotel_code({req.hotel_code})不匹配");
|
||||
return Json(new BLVEntity.Result() { code = 4001, msg = $"hotel_code({req.hotel_code})不匹配" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
//ServiceReference1.blwwsSoapClient client = new ServiceReference1.blwwsSoapClient();
|
||||
|
||||
boonliverpms.blwws client = new boonliverpms.blwws();
|
||||
|
||||
try
|
||||
{
|
||||
ExtraData eee = new ExtraData();
|
||||
eee.OriginalData = reqData;
|
||||
eee.RequestIP = IP;
|
||||
string sstr = JsonConvert.SerializeObject(eee);
|
||||
string RRR = HttpUtility.UrlEncode(sstr);
|
||||
var cookie = new System.Net.Cookie("order_original", RRR, "/", cookiedomain);
|
||||
client.CookieContainer = new System.Net.CookieContainer();
|
||||
client.CookieContainer.Add(cookie);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog("cookie: " + ex.Message);
|
||||
}
|
||||
|
||||
string errorMsg = "";
|
||||
bool blvResult = false;
|
||||
StringBuilder xmlString = new StringBuilder();
|
||||
string phoneNumber = "";
|
||||
string idNumber = "";
|
||||
|
||||
//①转发客控后台
|
||||
if (req.infos.Count > 0)
|
||||
{
|
||||
phoneNumber = req.infos[0].mobile;
|
||||
idNumber = req.infos[0].idcard;
|
||||
xmlString.Append("<interface>");
|
||||
foreach (BLVEntity.InfosItem guest in req.infos)
|
||||
{
|
||||
xmlString.Append("<item idtype=\"" + guest.type + "\" idcard = \"" + guest.idcard + "\" customer = \"" + guest.name + "\" sex =\"" +
|
||||
(guest.sex == 1 ? "男" : "女") + "\" country =\"0\" checkindate = \"" + req.checkIn.ToString("yyyy-MM-dd HH:mm:ss") + "\"/>");
|
||||
}
|
||||
xmlString.Append("</interface>");
|
||||
}
|
||||
blvResult = client.CheckIn("blw_ws@2015", req.hotel_code, req.room_no, req.checkIn, xmlString.ToString(), ref errorMsg, phoneNumber, idNumber);
|
||||
//LogHelper.WriteLog($"转发BLV内部开房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
//②转发人脸机
|
||||
//③转发宝镜系统
|
||||
string strBJResult = Tools.PostWebRequest(_bjInterfaceUrl + "/order/checkIn", reqData);
|
||||
BLVEntity.Result bjResult = JsonConvert.DeserializeObject<BLVEntity.Result>(strBJResult);
|
||||
if (bjResult != null && bjResult.code != 200)
|
||||
{
|
||||
LogHelper.WriteLog("调用宝镜checkin接口失败,原因:" + bjResult.msg);
|
||||
}
|
||||
|
||||
/*switch (req.type)
|
||||
{
|
||||
case "reg.checkin"://入住
|
||||
case "guest.checkin"://更新入住人
|
||||
break;
|
||||
case "reg.checkout"://退房
|
||||
//cricsEntity.RoomStatusID = 8;
|
||||
blvResult = client.CheckOut("blw_ws@2015", hotelCode, req.room_no, req.check_out_time, ref errorMsg);
|
||||
//LogHelper.WriteLog($"转发BLV内部退房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
break;
|
||||
case "reg.move"://换房
|
||||
//cricsEntity.RoomStatusID = 2;
|
||||
//先退房
|
||||
blvResult = client.CheckOut("blw_ws@2015", hotelCode, req.old_room_no, req.move_time, ref errorMsg);
|
||||
//LogHelper.WriteLog($"转发BLV内部退房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
//再开房
|
||||
if (req.guests.Count > 0)
|
||||
{
|
||||
phoneNumber = req.guests[0].mobile;
|
||||
idNumber = req.guests[0].id_card_no;
|
||||
xmlString.Append("<interface>");
|
||||
foreach (Luopan2Entity.GuestsItem guest in req.guests)
|
||||
{
|
||||
xmlString.Append("<item idtype=\"" + guest.id_card_type_id + "\" idcard = \"" + guest.id_card_no + "\" customer = \"" + guest.last_name + guest.first_name + "\" sex =\"" +
|
||||
(guest.gender_id == 0 ? "男" : "女") + "\" country =\"0\" checkindate = \"" + req.check_in_time.ToString("yyyy-MM-dd HH:mm:ss") + "\"/>");
|
||||
}
|
||||
xmlString.Append("</interface>");
|
||||
}
|
||||
blvResult = client.CheckIn("blw_ws@2015", hotelCode, req.new_room_no, req.check_in_time, xmlString.ToString(), ref errorMsg, phoneNumber, idNumber);
|
||||
//LogHelper.WriteLog($"转发BLV内部开房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
break;
|
||||
default:
|
||||
LogHelper.WriteLog("宝莱威接口未处理,type:" + req.type);
|
||||
blvResult = true;
|
||||
break;
|
||||
}*/
|
||||
if (blvResult)
|
||||
{
|
||||
return Json(new BLVEntity.Result() { code = 200, msg = "开房成功" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLog(errorMsg);
|
||||
LogHelper.WriteLog("收到checkin请求:" + reqData);
|
||||
return Json(new BLVEntity.Result() { code = 4001, msg = errorMsg }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog(ex.ToString());
|
||||
LogHelper.WriteLog("收到checkin请求:" + reqData);
|
||||
return Json(new BLVEntity.Result() { code = 4001, msg = ex.Message }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 入住接口
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ActionResult checkout()
|
||||
{
|
||||
Request.InputStream.Position = 0;
|
||||
byte[] reqBody = new byte[Request.InputStream.Length];
|
||||
Request.InputStream.Read(reqBody, 0, reqBody.Length);
|
||||
string reqData = System.Text.Encoding.UTF8.GetString(reqBody);
|
||||
if (string.IsNullOrEmpty(reqData))
|
||||
{
|
||||
return Json(new BLVEntity.Result() { code = 4001, msg = "传递参数不能为空" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
string IP = Tools.GetClientIP(Request);
|
||||
BLVEntity.Root req = JsonConvert.DeserializeObject<BLVEntity.Root>(reqData);
|
||||
if (string.IsNullOrEmpty(req.hotel_code))
|
||||
{
|
||||
LogHelper.WriteLog($"hotel_code({req.hotel_code})不匹配");
|
||||
return Json(new BLVEntity.Result() { code = 4001, msg = $"hotel_code({req.hotel_code})不匹配" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
//ServiceReference1.blwwsSoapClient client = new ServiceReference1.blwwsSoapClient();
|
||||
boonliverpms.blwws client = new boonliverpms.blwws();
|
||||
|
||||
try
|
||||
{
|
||||
ExtraData eee = new ExtraData();
|
||||
eee.OriginalData = reqData;
|
||||
eee.RequestIP = IP;
|
||||
string sstr = JsonConvert.SerializeObject(eee);
|
||||
string RRR = HttpUtility.UrlEncode(sstr);
|
||||
var cookie = new System.Net.Cookie("order_original", RRR, "/", cookiedomain);
|
||||
client.CookieContainer = new System.Net.CookieContainer();
|
||||
client.CookieContainer.Add(cookie);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog("cookie: " + ex.Message);
|
||||
}
|
||||
|
||||
string errorMsg = "";
|
||||
bool blvResult = false;
|
||||
//①转发客控后台
|
||||
blvResult = client.CheckOut("blw_ws@2015", req.hotel_code, req.room_no, req.checkOut, ref errorMsg);
|
||||
//②转发人脸机
|
||||
//③转发宝镜系统
|
||||
if (blvResult)
|
||||
{
|
||||
return Json(new BLVEntity.Result() { code = 200, msg = "退房成功" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLog(errorMsg);
|
||||
LogHelper.WriteLog("收到checkout请求:" + reqData);
|
||||
return Json(new BLVEntity.Result() { code = 4001, msg = errorMsg }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog(ex.ToString());
|
||||
LogHelper.WriteLog("收到checkout请求:" + reqData);
|
||||
return Json(new BLVEntity.Result() { code = 4001, msg = ex.Message }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Luopan2 PMS对接
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ActionResult Luopan2ToBLV()
|
||||
{
|
||||
Request.InputStream.Position = 0;
|
||||
byte[] reqBody = new byte[Request.InputStream.Length];
|
||||
Request.InputStream.Read(reqBody, 0, reqBody.Length);
|
||||
string reqData = System.Text.Encoding.UTF8.GetString(reqBody);
|
||||
if (string.IsNullOrEmpty(reqData))
|
||||
{
|
||||
return Json(new LuopanEntity.Result() { status = 1, error_msg = "传递参数不能为空" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
try
|
||||
{
|
||||
Luopan2Entity.Root req = JsonConvert.DeserializeObject<Luopan2Entity.Root>(reqData);
|
||||
string hotelCode = System.Configuration.ConfigurationManager.AppSettings[req.hotel_id];
|
||||
if (string.IsNullOrEmpty(hotelCode))
|
||||
{
|
||||
LogHelper.WriteLog($"hotel_id({req.hotel_id})不匹配或未配置");
|
||||
return Json(new LuopanEntity.Result() { status = 1, error_msg = $"hotel_id({req.hotel_id})不匹配或未配置" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
ServiceReference1.blwwsSoapClient client = new ServiceReference1.blwwsSoapClient();
|
||||
string errorMsg = "";
|
||||
bool blvResult = false;
|
||||
StringBuilder xmlString = new StringBuilder();
|
||||
string phoneNumber = "";
|
||||
string idNumber = "";
|
||||
switch (req.type)
|
||||
{
|
||||
case "reg.checkin"://入住
|
||||
case "guest.checkin"://更新入住人
|
||||
//①转发客控后台
|
||||
if (req.guests.Count > 0)
|
||||
{
|
||||
phoneNumber = req.guests[0].mobile;
|
||||
idNumber = req.guests[0].id_card_no;
|
||||
xmlString.Append("<interface>");
|
||||
foreach (Luopan2Entity.GuestsItem guest in req.guests)
|
||||
{
|
||||
xmlString.Append("<item idtype=\"" + guest.id_card_type_id + "\" idcard = \"" + guest.id_card_no + "\" customer = \"" + guest.last_name + guest.first_name + "\" sex =\"" +
|
||||
(guest.gender_id == 0 ? "男" : "女") + "\" country =\"0\" checkindate = \"" + req.check_in_time.Value.ToString("yyyy-MM-dd HH:mm:ss") + "\"/>");
|
||||
}
|
||||
xmlString.Append("</interface>");
|
||||
}
|
||||
blvResult = client.CheckIn("blw_ws@2015", hotelCode, req.room_no, req.check_in_time.Value, xmlString.ToString(), ref errorMsg, phoneNumber, idNumber);
|
||||
//LogHelper.WriteLog($"转发BLV内部开房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
//②转发人脸机
|
||||
//③转发宝镜系统
|
||||
break;
|
||||
case "reg.checkout"://退房
|
||||
//cricsEntity.RoomStatusID = 8;
|
||||
blvResult = client.CheckOut("blw_ws@2015", hotelCode, req.room_no, req.check_out_time.Value, ref errorMsg);
|
||||
//LogHelper.WriteLog($"转发BLV内部退房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
break;
|
||||
case "reg.move"://换房
|
||||
//cricsEntity.RoomStatusID = 2;
|
||||
//先退房
|
||||
blvResult = client.CheckOut("blw_ws@2015", hotelCode, req.old_room_no, req.move_time.Value, ref errorMsg);
|
||||
//LogHelper.WriteLog($"转发BLV内部退房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
//再开房
|
||||
if (req.guests.Count > 0)
|
||||
{
|
||||
phoneNumber = req.guests[0].mobile;
|
||||
idNumber = req.guests[0].id_card_no;
|
||||
xmlString.Append("<interface>");
|
||||
foreach (Luopan2Entity.GuestsItem guest in req.guests)
|
||||
{
|
||||
xmlString.Append("<item idtype=\"" + guest.id_card_type_id + "\" idcard = \"" + guest.id_card_no + "\" customer = \"" + guest.last_name + guest.first_name + "\" sex =\"" +
|
||||
(guest.gender_id == 0 ? "男" : "女") + "\" country =\"0\" checkindate = \"" + req.check_in_time.Value.ToString("yyyy-MM-dd HH:mm:ss") + "\"/>");
|
||||
}
|
||||
xmlString.Append("</interface>");
|
||||
}
|
||||
blvResult = client.CheckIn("blw_ws@2015", hotelCode, req.new_room_no, req.check_in_time.Value, xmlString.ToString(), ref errorMsg, phoneNumber, idNumber);
|
||||
//LogHelper.WriteLog($"转发BLV内部开房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
break;
|
||||
default:
|
||||
LogHelper.WriteLog("宝莱威接口未处理,type:" + req.type);
|
||||
blvResult = true;
|
||||
break;
|
||||
}
|
||||
if (blvResult)
|
||||
{
|
||||
return Json(new LuopanEntity.Result() { status = 0, error_msg = "" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLog(errorMsg);
|
||||
LogHelper.WriteLog("收到Luopan2请求:" + reqData);
|
||||
return Json(new LuopanEntity.Result() { status = 1, error_msg = errorMsg }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog(ex.ToString());
|
||||
LogHelper.WriteLog("收到Luopan2请求:" + reqData);
|
||||
return Json(new LuopanEntity.Result() { status = 1, error_msg = ex.Message }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Luopan PMS对接
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ActionResult LuopanToBLV()
|
||||
{
|
||||
Request.InputStream.Position = 0;
|
||||
byte[] reqBody = new byte[Request.InputStream.Length];
|
||||
Request.InputStream.Read(reqBody, 0, reqBody.Length);
|
||||
string reqData = System.Text.Encoding.UTF8.GetString(reqBody);
|
||||
if (string.IsNullOrEmpty(reqData))
|
||||
{
|
||||
return Json(new LuopanEntity.Result() { status = 1, error_msg = "传递参数不能为空" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
try
|
||||
{
|
||||
LuopanEntity.Root req = JsonConvert.DeserializeObject<LuopanEntity.Root>(reqData);
|
||||
string hotelCode = System.Configuration.ConfigurationManager.AppSettings[req.HotelId];
|
||||
if (string.IsNullOrEmpty(hotelCode))
|
||||
{
|
||||
LogHelper.WriteLog($"HotelId({req.HotelId})不匹配或未配置");
|
||||
return Json(new LuopanEntity.Result() { status = 1, error_msg = $"HotelId({req.HotelId})不匹配或未配置" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
ServiceReference1.blwwsSoapClient client = new ServiceReference1.blwwsSoapClient();
|
||||
string errorMsg = "";
|
||||
bool blvResult = false;
|
||||
StringBuilder xmlString = new StringBuilder();
|
||||
string phoneNumber = "";
|
||||
string idNumber = "";
|
||||
switch (req.Action)
|
||||
{
|
||||
case "CheckIn"://入住
|
||||
if (req.GuestInfo.Count > 0)
|
||||
{
|
||||
phoneNumber = req.GuestInfo[0].Mobile;
|
||||
idNumber = req.GuestInfo[0].IDCardNo;
|
||||
xmlString.Append("<interface>");
|
||||
foreach (LuopanEntity.GuestInfo guest in req.GuestInfo)
|
||||
{
|
||||
xmlString.Append("<item idtype=\"" + guest.IDCardTypeId + "\" idcard = \"" + guest.IDCardNo + "\" customer = \"" + guest.GuestName + "\" sex =\"" +
|
||||
(guest.Gender == 0 ? "男" : "女") + "\" country =\"0\" checkindate = \"" + req.CheckInTime.ToString("yyyy-MM-dd HH:mm:ss") + "\"/>");
|
||||
}
|
||||
xmlString.Append("</interface>");
|
||||
}
|
||||
blvResult = client.CheckIn("blw_ws@2015", hotelCode, req.RoomNo, req.CheckInTime, xmlString.ToString(), ref errorMsg, phoneNumber, idNumber);
|
||||
//LogHelper.WriteLog($"转发BLV内部开房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
break;
|
||||
case "CheckOut"://退房
|
||||
blvResult = client.CheckOut("blw_ws@2015", hotelCode, req.RoomNo, req.CheckOutTime, ref errorMsg);
|
||||
//LogHelper.WriteLog($"转发BLV内部退房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
break;
|
||||
case "MoveRoom"://换房
|
||||
//先退房
|
||||
blvResult = client.CheckOut("blw_ws@2015", hotelCode, req.OldRoomNo, req.MoveTime, ref errorMsg);
|
||||
//LogHelper.WriteLog($"转发BLV内部退房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
//再开房
|
||||
if (req.GuestInfo.Count > 0)
|
||||
{
|
||||
phoneNumber = req.GuestInfo[0].Mobile;
|
||||
idNumber = req.GuestInfo[0].IDCardNo;
|
||||
xmlString.Append("<interface>");
|
||||
foreach (LuopanEntity.GuestInfo guest in req.GuestInfo)
|
||||
{
|
||||
xmlString.Append("<item idtype=\"" + guest.IDCardTypeId + "\" idcard = \"" + guest.IDCardNo + "\" customer = \"" + guest.GuestName + "\" sex =\"" +
|
||||
(guest.Gender == 0 ? "男" : "女") + "\" country =\"0\" checkindate = \"" + req.CheckInTime.ToString("yyyy-MM-dd HH:mm:ss") + "\"/>");
|
||||
}
|
||||
xmlString.Append("</interface>");
|
||||
}
|
||||
blvResult = client.CheckIn("blw_ws@2015", hotelCode, req.NewRoomNo, req.CheckInTime, xmlString.ToString(), ref errorMsg, phoneNumber, idNumber);
|
||||
//LogHelper.WriteLog($"转发BLV内部开房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
break;
|
||||
default:
|
||||
LogHelper.WriteLog("宝莱威接口未处理,Action:" + req.Action);
|
||||
blvResult = true;
|
||||
break;
|
||||
}
|
||||
if (blvResult)
|
||||
{
|
||||
return Json(new LuopanEntity.Result() { status = 0, error_msg = "" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLog(errorMsg);
|
||||
LogHelper.WriteLog("收到Luopan请求:" + reqData);
|
||||
return Json(new LuopanEntity.Result() { status = 1, error_msg = errorMsg }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog(ex.ToString());
|
||||
LogHelper.WriteLog("收到Luopan请求:" + reqData);
|
||||
return Json(new LuopanEntity.Result() { status = 1, error_msg = ex.Message }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static string GetMD5Hash(string input)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(32); // 预分配32字符空间
|
||||
using (HashAlgorithm algorithm = MD5.Create())
|
||||
{
|
||||
byte[] inputBytes = Encoding.UTF8.GetBytes(input);
|
||||
byte[] hashBytes = algorithm.ComputeHash(inputBytes);
|
||||
|
||||
foreach (byte b in hashBytes)
|
||||
{
|
||||
sb.Append(b.ToString("x2")); // 使用"x2"确保总是两位十六进制
|
||||
}
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string GetMD5(string str)
|
||||
{
|
||||
//创建MD5对象
|
||||
MD5 mD5 = MD5.Create();
|
||||
byte[] buffer = Encoding.Default.GetBytes(str);
|
||||
var MD5Buffer = mD5.ComputeHash(buffer);
|
||||
//将字节数组转换为字符串
|
||||
//法一:将字节数组中每个元素按照指定的编码格式解析成字符串
|
||||
//return Encoding.Default.GetString(MD5Buffer);(会造成乱码)
|
||||
//法二:直接将数组tostring
|
||||
//法三:直接将数组中的每个元素ToString()
|
||||
string s = "";
|
||||
for (int i = 0; i < MD5Buffer.Length; i++)
|
||||
{
|
||||
s += MD5Buffer[i].ToString("x2");//tostring中的参数x是将10进制转化为16进制
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public static DateTime ToLocalTimeDateByMilliseconds(long unix)
|
||||
{
|
||||
var dto = DateTimeOffset.FromUnixTimeMilliseconds(unix);
|
||||
return dto.ToLocalTime().DateTime;
|
||||
}
|
||||
|
||||
public static readonly string uname = ConfigurationManager.AppSettings["yanzheng_user"];
|
||||
public static readonly string upassword = ConfigurationManager.AppSettings["yanzheng_password"];
|
||||
/// <summary>
|
||||
/// cookie域
|
||||
/// </summary>
|
||||
public static readonly string cookiedomain = ConfigurationManager.AppSettings["cookiekey_domain"];
|
||||
|
||||
|
||||
|
||||
#region 一样的逻辑
|
||||
/// <summary>
|
||||
/// 瑰迈酒店PMS
|
||||
/// 一个订单可以开好多房
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ActionResult GuiMaiHotelToBLV()
|
||||
{
|
||||
return TongYi();
|
||||
}
|
||||
/// <summary>
|
||||
/// 旅智PMS
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public ActionResult LvZhiToBLV()
|
||||
{
|
||||
return TongYi();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 统一的方法
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private ActionResult TongYi()
|
||||
{
|
||||
ExtraData extradata = new ExtraData();
|
||||
string IP = Tools.GetClientIP(this.HttpContext.Request);
|
||||
extradata.RequestIP = IP;
|
||||
|
||||
var UUU = Request.Headers["authorization"];
|
||||
|
||||
string username = "boot";
|
||||
string password = "#Ba~rk4ekf2,UdCW";
|
||||
|
||||
string u3 = string.Format("{0}:{1}", username, password);
|
||||
string UUU1 = GetMD5Hash(u3).ToLower();
|
||||
LogHelper.WriteLog("同城收到的数据为:" + UUU);
|
||||
if (!UUU.ToLower().Equals(UUU1))
|
||||
{
|
||||
//return Json(new ResultAAA() { code = "500", message = "用户名 或者 密码错误" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
Request.InputStream.Position = 0;
|
||||
byte[] reqBody = new byte[Request.InputStream.Length];
|
||||
Request.InputStream.Read(reqBody, 0, reqBody.Length);
|
||||
string reqData = System.Text.Encoding.UTF8.GetString(reqBody);
|
||||
extradata.OriginalData = reqData;
|
||||
|
||||
LogHelper.WriteLog("同城收到的data为:" + reqData);
|
||||
|
||||
if (string.IsNullOrEmpty(reqData))
|
||||
{
|
||||
return Json(new ResultAAA() { code = "500", message = "传递参数不能为空" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
try
|
||||
{
|
||||
PMSEntity req = JsonConvert.DeserializeObject<PMSEntity>(reqData);
|
||||
int code = req.groupOrder.hotelCode;
|
||||
string hotelCode = System.Configuration.ConfigurationManager.AppSettings[code.ToString()];
|
||||
if (string.IsNullOrEmpty(hotelCode))
|
||||
{
|
||||
LogHelper.WriteLog($"hotelCode({hotelCode})不匹配或未配置");
|
||||
return Json(new ResultAAA() { code = "500", message = $"hotel_id({hotelCode})不匹配或未配置" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
//ServiceReference1.blwwsSoapClient client = new ServiceReference1.blwwsSoapClient();
|
||||
|
||||
boonliverpms.blwws client = new boonliverpms.blwws();
|
||||
|
||||
string cookiestr = Newtonsoft.Json.JsonConvert.SerializeObject(extradata);
|
||||
var cookie = new System.Net.Cookie("order_original", HttpUtility.UrlEncode(cookiestr), "/", cookiedomain);
|
||||
client.CookieContainer = new System.Net.CookieContainer();
|
||||
client.CookieContainer.Add(cookie);
|
||||
|
||||
|
||||
bool blvResult = false;
|
||||
string errorMsg = "";
|
||||
List<OrderItem> OrderItems = req.groupOrder.orderItems;
|
||||
foreach (OrderItem item in OrderItems)
|
||||
{
|
||||
StringBuilder xmlString = new StringBuilder();
|
||||
|
||||
string phoneNumber = "";
|
||||
string idNumber = "";
|
||||
var DDD = item.guests;
|
||||
//一个订单中 登记一下负责人的电话号码即可
|
||||
phoneNumber = DDD[0].tel;
|
||||
idNumber = DDD[0].idCardNo;
|
||||
string RoomNO = item.roomNo;
|
||||
string Check_InTime = item.checkInTime;
|
||||
DateTime check_in_time = DateTime.Now;
|
||||
check_in_time = DateTime.Parse(Check_InTime);
|
||||
switch (req.type)
|
||||
{
|
||||
case "0"://入住
|
||||
case "1"://入住
|
||||
case "4"://更新入住人
|
||||
//①转发客控后台
|
||||
if (DDD.Count > 0)
|
||||
{
|
||||
xmlString.Append("<interface>");
|
||||
foreach (var guest in DDD)
|
||||
{
|
||||
string 性别 = guest.gender;
|
||||
string idcard_type = guest.idCardType;
|
||||
string idcard_no = guest.idCardNo;
|
||||
string name = guest.name;
|
||||
|
||||
xmlString.Append("<item idtype=\"" + idcard_type + "\" idcard = \"" + idcard_no + "\" customer = \"" + name + "\" sex =\"" +
|
||||
性别 + "\" country =\"0\" checkindate = \"" + check_in_time + "\"/>");
|
||||
}
|
||||
xmlString.Append("</interface>");
|
||||
}
|
||||
|
||||
blvResult = client.CheckIn("blw_ws@2015", hotelCode, RoomNO, check_in_time, xmlString.ToString(), ref errorMsg, phoneNumber, idNumber);
|
||||
//LogHelper.WriteLog($"转发BLV内部开房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
//②转发人脸机
|
||||
//③转发宝镜系统
|
||||
break;
|
||||
case "5"://退房
|
||||
case "13"://退房
|
||||
case "11"://退房
|
||||
blvResult = client.CheckOut("blw_ws@2015", hotelCode, RoomNO, check_in_time, ref errorMsg);
|
||||
break;
|
||||
case "6"://换房
|
||||
case "7"://换房
|
||||
//先退房
|
||||
blvResult = client.CheckOut("blw_ws@2015", hotelCode, RoomNO, check_in_time, ref errorMsg);
|
||||
//LogHelper.WriteLog($"转发BLV内部退房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
//再开房
|
||||
if (DDD.Count > 0)
|
||||
{
|
||||
xmlString.Append("<interface>");
|
||||
foreach (var guest in DDD)
|
||||
{
|
||||
string 性别 = guest.gender;
|
||||
string idcard_type = guest.idCardType;
|
||||
string idcard_no = guest.idCardNo;
|
||||
string name = guest.name;
|
||||
|
||||
xmlString.Append("<item idtype=\"" + idcard_type + "\" idcard = \"" + idcard_no + "\" customer = \"" + name + "\" sex =\"" +
|
||||
性别 + "\" country =\"0\" checkindate = \"" + check_in_time + "\"/>");
|
||||
}
|
||||
xmlString.Append("</interface>");
|
||||
}
|
||||
blvResult = client.CheckIn("blw_ws@2015", hotelCode, RoomNO, check_in_time, xmlString.ToString(), ref errorMsg, phoneNumber, idNumber);
|
||||
break;
|
||||
default:
|
||||
LogHelper.WriteLog("宝莱威接口未处理,type:" + req.type);
|
||||
blvResult = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (blvResult)
|
||||
{
|
||||
return Json(new ResultAAA() { code = "200", message = "SUCCESS" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLog(errorMsg);
|
||||
LogHelper.WriteLog("收到Luopan2请求:" + reqData);
|
||||
return Json(new ResultAAA() { code = "500", message = errorMsg }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog(ex.ToString());
|
||||
LogHelper.WriteLog("收到Luopan2请求:" + reqData);
|
||||
return Json(new ResultAAA() { code = "500", message = ex.Message }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// XMS 订单信息变更推送接口
|
||||
/// 西软 艾露酒店 1968
|
||||
/// 这里面的
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public ActionResult XMSOrderPush()
|
||||
{
|
||||
try
|
||||
{
|
||||
string IP = Tools.GetClientIP(Request);
|
||||
var xrsecret = Request.Headers["xrsecret"];
|
||||
//密钥Ip202rSR132zJGKH
|
||||
//if (xrsecret.Equals("Ip202rSR132zJGKH"))
|
||||
//{
|
||||
Request.InputStream.Position = 0;
|
||||
byte[] reqBody = new byte[Request.InputStream.Length];
|
||||
Request.InputStream.Read(reqBody, 0, reqBody.Length);
|
||||
string reqData = System.Text.Encoding.UTF8.GetString(reqBody);
|
||||
if (string.IsNullOrEmpty(reqData))
|
||||
{
|
||||
return Json(new ResultAAA() { code = "500", message = "传递参数不能为空" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
LogHelper.WriteLog("XMSOrderPush:" + reqData.ToString());
|
||||
|
||||
|
||||
|
||||
var DDD = JsonConvert.DeserializeObject<XMSData>(reqData);
|
||||
|
||||
string username = "boot";
|
||||
string password = "#Ba~rk4ekf2,UdCW";
|
||||
string u3 = string.Format("{0}:{1}", username, password);
|
||||
string UUU1 = GetMD5Hash(u3);
|
||||
|
||||
//string hotelCode = System.Configuration.ConfigurationManager.AppSettings[DDD.groupid.ToString()];
|
||||
string hotelCode = DDD.groupid;
|
||||
if (string.IsNullOrEmpty(hotelCode))
|
||||
{
|
||||
LogHelper.WriteLog($"hotelCode({hotelCode})不匹配或未配置");
|
||||
return Json(new ResultAAA() { code = "500", message = $"hotel_id({hotelCode})不匹配或未配置" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
//ServiceReference1.blwwsSoapClient client = new ServiceReference1.blwwsSoapClient();
|
||||
boonliverpms.blwws client = new boonliverpms.blwws();
|
||||
|
||||
try
|
||||
{
|
||||
ExtraData eee = new ExtraData();
|
||||
eee.OriginalData = reqData;
|
||||
eee.RequestIP = IP;
|
||||
string sstr = JsonConvert.SerializeObject(eee);
|
||||
string RRR = HttpUtility.UrlEncode(sstr);
|
||||
var cookie = new System.Net.Cookie("order_original", RRR, "/", cookiedomain);
|
||||
client.CookieContainer = new System.Net.CookieContainer();
|
||||
client.CookieContainer.Add(cookie);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLog("cookie: " + ex.Message);
|
||||
}
|
||||
|
||||
bool blvResult = false;
|
||||
string errorMsg = "";
|
||||
|
||||
|
||||
|
||||
var DDD_1 = DDD.extras;
|
||||
StringBuilder xmlString = new StringBuilder();
|
||||
|
||||
|
||||
//这个PMS 不会上传 手机号和身份证号
|
||||
string idNumber = "";
|
||||
string phoneNumber = DDD_1.mobile;
|
||||
string RoomNO = DDD_1.roomno;
|
||||
|
||||
long Check_InTime = long.Parse(DDD_1.arr);
|
||||
DateTime check_in_time = DateTime.Now;
|
||||
check_in_time = ToLocalTimeDateByMilliseconds(Check_InTime);
|
||||
switch (DDD_1.sta)
|
||||
{
|
||||
case "I"://入住
|
||||
|
||||
string 性别 = "";
|
||||
string idcard_type = "";
|
||||
string idcard_no = "";
|
||||
string name = DDD_1.name;
|
||||
XDocument doc1 = new XDocument();
|
||||
var Root = new XElement("interface");
|
||||
var Ele = new XElement("item", new XAttribute("idtype", idcard_type),
|
||||
new XAttribute("idcard", idcard_no),
|
||||
new XAttribute("customer", name),
|
||||
new XAttribute("sex", 性别),
|
||||
new XAttribute("country", "0"),
|
||||
new XAttribute("checkindate", check_in_time));
|
||||
Root.Add(Ele);
|
||||
doc1.Add(Root);
|
||||
|
||||
string FxmlString = doc1.ToString();
|
||||
|
||||
//xmlString.Append("<interface>");
|
||||
//xmlString.Append("<item idtype=\"" + idcard_type + "\" idcard = \"" + idcard_no + "\" customer = \"" + name + "\" sex =\"" +
|
||||
// 性别 + "\" country =\"0\" checkindate = \"" + check_in_time + "\"/>");
|
||||
//xmlString.Append("</interface>");
|
||||
blvResult = client.CheckIn("blw_ws@2015", hotelCode, RoomNO, check_in_time, FxmlString, ref errorMsg, phoneNumber, idNumber);
|
||||
break;
|
||||
case "O"://退房
|
||||
case "R"://退房
|
||||
blvResult = client.CheckOut("blw_ws@2015", hotelCode, RoomNO, check_in_time, ref errorMsg);
|
||||
break;
|
||||
default:
|
||||
LogHelper.WriteLog("宝莱威接口未处理,type:");
|
||||
blvResult = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (blvResult)
|
||||
{
|
||||
return Json(new ResultAAA() { code = "200", message = "SUCCESS" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLog(errorMsg);
|
||||
LogHelper.WriteLog("收到 XMS 请求:" + reqData);
|
||||
return Json(new ResultAAA() { code = "500", message = errorMsg }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Json(new { code = 500, msg = ex.Message, data = new { } }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
return Json(new { code = 200, msg = "success", data = new { } }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
//{
|
||||
// "accnt":"F2506200002",
|
||||
// "original":{
|
||||
// "name":"李一"
|
||||
// },
|
||||
// "groupid":"1968",
|
||||
// "name":"李二",
|
||||
// "extras":{
|
||||
// "arr":"1750586400000",
|
||||
// "rtc":"CPC",
|
||||
// "sta":"R",
|
||||
// "rmnum":"1",
|
||||
// "roomno":"",
|
||||
// "mobile":"1212345678",
|
||||
// "name":"李二",
|
||||
// "type":"CPC",
|
||||
// "dep":"1750651200000"
|
||||
// },
|
||||
// "hotelid":"H000068"
|
||||
//}
|
||||
|
||||
|
||||
public class XMSData
|
||||
{
|
||||
public string hotelid { get; set; }
|
||||
/// <summary>
|
||||
/// 订单账号(酒店唯一)
|
||||
/// </summary>
|
||||
public string accnt { get; set; }
|
||||
|
||||
public string groupid { get; set; }
|
||||
public string name { get; set; }
|
||||
public Dictionary<string, string> original { get; set; }
|
||||
public extrasData extras { get; set; }
|
||||
}
|
||||
public class originalData
|
||||
{
|
||||
//public string name { get; set; }
|
||||
//public string mobile { get; set; }
|
||||
//public string roomno { get; set; }
|
||||
//public string type { get; set; }
|
||||
//public string rtc { get; set; }
|
||||
//public string rmnum { get; set; }
|
||||
//public string sta { get; set; }
|
||||
}
|
||||
// "arr":"1750586400000",
|
||||
// "rtc":"CPC",
|
||||
// "sta":"R",
|
||||
// "rmnum":"1",
|
||||
// "roomno":"",
|
||||
// "mobile":"1212345678",
|
||||
// "name":"李二",
|
||||
// "type":"CPC",
|
||||
// "dep":"1750651200000"
|
||||
public class extrasData
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string mobile { get; set; }
|
||||
/// <summary>
|
||||
/// 房间号
|
||||
/// </summary>
|
||||
public string roomno { get; set; }
|
||||
public string type { get; set; }
|
||||
public string rtc { get; set; }
|
||||
public string rmnum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单状态
|
||||
///Q:问询
|
||||
///X:取消预订
|
||||
///N:noshow
|
||||
///R:预订
|
||||
///I:在住
|
||||
///O:本日结账
|
||||
///S:挂账退房
|
||||
///D:昨日结账
|
||||
///H:历史订单
|
||||
/// </summary>
|
||||
public string sta { get; set; }
|
||||
public string arr { get; set; }
|
||||
public string dep { get; set; }
|
||||
}
|
||||
}
|
||||
22
BLV_API/Controllers/HomeController.cs
Normal file
22
BLV_API/Controllers/HomeController.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using BLV_API.Dal;
|
||||
using BLV_API.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace BLV_API.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
ViewBag.Title = "欢迎访问宝来威客控接口服务";
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
39
BLV_API/Controllers/ValuesController.cs
Normal file
39
BLV_API/Controllers/ValuesController.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace BLV_API.Controllers
|
||||
{
|
||||
public class ValuesController : ApiController
|
||||
{
|
||||
// GET api/values
|
||||
public IEnumerable<string> Get()
|
||||
{
|
||||
return new string[] { "value1", "value2" };
|
||||
}
|
||||
|
||||
// GET api/values/5
|
||||
public string Get(int id)
|
||||
{
|
||||
return "value";
|
||||
}
|
||||
|
||||
// POST api/values
|
||||
public void Post([FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT api/values/5
|
||||
public void Put(int id, [FromBody] string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE api/values/5
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
184
BLV_API/Controllers/testController.cs
Normal file
184
BLV_API/Controllers/testController.cs
Normal file
@@ -0,0 +1,184 @@
|
||||
using BLV_API.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlTypes;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace BLV_API.Controllers
|
||||
{
|
||||
public class testController : Controller
|
||||
{
|
||||
//// GET: test
|
||||
//public ActionResult Index()
|
||||
//{
|
||||
// return View();
|
||||
//}
|
||||
|
||||
public ActionResult LuopanToBonjing()
|
||||
{
|
||||
Request.InputStream.Position = 0;
|
||||
byte[] reqBody = new byte[Request.InputStream.Length];
|
||||
Request.InputStream.Read(reqBody, 0, reqBody.Length);
|
||||
string reqData = System.Text.Encoding.UTF8.GetString(reqBody);
|
||||
if (string.IsNullOrEmpty(reqData))
|
||||
{
|
||||
return Json(new LuopanEntity.Result() { status = 1, error_msg = "传递参数不能为空" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
try
|
||||
{
|
||||
LuopanEntity.Root req = JsonConvert.DeserializeObject<LuopanEntity.Root>(reqData);
|
||||
ServiceReference1.blwwsSoapClient client = new ServiceReference1.blwwsSoapClient();
|
||||
string errorMsg = "";
|
||||
bool blvResult;
|
||||
StringBuilder xmlString = new StringBuilder();
|
||||
string phoneNumber = "";
|
||||
string idNumber = "";
|
||||
switch (req.Action)
|
||||
{
|
||||
case "CheckIn":
|
||||
if (req.GuestInfo.Count > 0)
|
||||
{
|
||||
phoneNumber = req.GuestInfo[0].Mobile;
|
||||
idNumber = req.GuestInfo[0].IDCardNo;
|
||||
xmlString.Append("<interface>");
|
||||
foreach (LuopanEntity.GuestInfo guest in req.GuestInfo)
|
||||
{
|
||||
xmlString.Append("<item idtype=\"" + guest.IDCardTypeId + "\" idcard = \"" + guest.IDCardNo + "\" customer = \"" + guest.GuestName + "\" sex =\"" +
|
||||
(guest.Gender == 0 ? "男" : "女") + "\" country =\"0\" checkindate = \"" + req.CheckInTime.ToString("yyyy-MM-dd HH:mm:ss") + "\"/>");
|
||||
}
|
||||
xmlString.Append("</interface>");
|
||||
}
|
||||
blvResult = client.CheckIn("blw_ws@2015", req.HotelId, req.RoomNo, req.CheckInTime, xmlString.ToString(), ref errorMsg, phoneNumber, idNumber);
|
||||
LogHelper.WriteLog($"转发BLV内部开房接口,结果:{blvResult},消息:{errorMsg}");
|
||||
bool cbj= CheckInBaoJing.CheckInToBaoJing(req);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return Json(new LuopanEntity.Result() { status = 0, error_msg = "" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
return Json(new LuopanEntity.Result() { status = 1, error_msg = ex.Message }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static class CheckInBaoJing
|
||||
{
|
||||
public static bool CheckInToBaoJing(LuopanEntity.Root root)
|
||||
{
|
||||
baojinginfoCheckIn bjch = new baojinginfoCheckIn();
|
||||
//infoslist ils= new infoslist();
|
||||
bjch.hotel_id = root.HotelId;
|
||||
|
||||
bjch.room_no = root.RoomNo;
|
||||
|
||||
bjch.checkIn = root.CheckInTime;
|
||||
bjch.checkOut=root.CheckOutTime;
|
||||
bjch.is_breakfast = 0;
|
||||
bjch.breakfast = 0;
|
||||
bjch.rateCode = "";
|
||||
bjch.amount = "";
|
||||
//bjch.infos.Add(ils);
|
||||
if (root.GuestInfo.Count > 0)
|
||||
{
|
||||
foreach (var info in root.GuestInfo)
|
||||
{
|
||||
infoslist ils = new infoslist();
|
||||
ils.name= info.GuestName;
|
||||
ils.type = (info.IDCardTypeId == "身份证" ? 0 : (info.IDCardTypeId == "护照"?1:2));
|
||||
ils.idcard = info.IDCardNo;
|
||||
ils.sex = info.Gender;
|
||||
ils.address = info.Address;
|
||||
bjch.infos.Add(ils);
|
||||
}
|
||||
}
|
||||
string url = "http://www.higmkj.com:8056/api/v1/order/checkIn";
|
||||
string token = "Your token";
|
||||
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = "POST";
|
||||
request.ContentType = "application/json";
|
||||
request.Headers.Add("Authorization", "Bearer " + token);
|
||||
request.Headers.Add("hotelCode", root.HotelId);
|
||||
|
||||
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
|
||||
{
|
||||
baojinginfoCheckIn jsonPayload = bjch;
|
||||
streamWriter.Write(jsonPayload);
|
||||
}
|
||||
|
||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||
|
||||
using (var streamReader = new StreamReader(response.GetResponseStream()))
|
||||
{
|
||||
string result = streamReader.ReadToEnd();
|
||||
Console.WriteLine(result);
|
||||
}
|
||||
|
||||
//public int breakfast { get; set; }
|
||||
//public string { get; set; }
|
||||
//public string { get; set; }
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public class baojinginfoCheckIn
|
||||
{
|
||||
public baojinginfoCheckIn()
|
||||
{
|
||||
infos = new List<infoslist>();
|
||||
}
|
||||
public string hotel_id { get; set; }
|
||||
public string room_no { get; set;}
|
||||
public DateTime checkIn { get; set; }
|
||||
public DateTime checkOut { get; set; }
|
||||
public int is_breakfast { get; set; }
|
||||
public int breakfast { get;set; }
|
||||
public string rateCode { get; set; }
|
||||
public string amount { get; set; }
|
||||
public List<infoslist> infos { get; set; }
|
||||
|
||||
|
||||
}
|
||||
public class infoslist
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string mobile { get; set; }
|
||||
public int type { get; set; }
|
||||
|
||||
public string idcard { get; set; }
|
||||
public int sex { get; set; }
|
||||
public string address { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user