初始化
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<gcServer enabled="true" />
|
||||
<gcConcurrent enabled="false" />
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.CodeAnalysis" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.9.0.0" newVersion="2.9.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.CodeAnalysis.CSharp" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.9.0.0" newVersion="2.9.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.CodeAnalysis.VisualBasic" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.9.0.0" newVersion="2.9.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.2.3.0" newVersion="1.2.3.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Console" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Diagnostics.FileVersionInfo" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Diagnostics.StackTrace" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IO.Pipes" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.4.3.0" newVersion="1.4.3.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Thread" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Security.Principal.Windows" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Xml.ReaderWriter" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IO.Compression" publicKeyToken="b77a5c561934e089" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.2.0" newVersion="4.1.2.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Xml.XPath.XDocument" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.IO.FileSystem" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -0,0 +1,215 @@
|
||||
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.Text;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace BLV_API.Controllers
|
||||
{
|
||||
public class ApiController : Controller
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
ViewBag.Title = "宝来威客控与PMS对接API";
|
||||
return View();
|
||||
}
|
||||
/// <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:
|
||||
errorMsg = "宝莱威接口未处理,Action:" + req.Action;
|
||||
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);
|
||||
}
|
||||
}
|
||||
/// <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.ToString("yyyy-MM-dd HH:mm:ss") + "\"/>");
|
||||
}
|
||||
xmlString.Append("</interface>");
|
||||
}
|
||||
blvResult = client.CheckIn("blw_ws@2015", hotelCode, req.room_no, req.check_in_time, 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, 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:
|
||||
errorMsg = "宝莱威接口未处理,type:" + req.type;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user