初始化
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,67 @@
|
||||
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);
|
||||
LogHelper.WriteLog("收到请求:" + reqData);
|
||||
try
|
||||
{
|
||||
LuopanEntity.Root request = JsonConvert.DeserializeObject<LuopanEntity.Root>(reqData);
|
||||
ServiceReference1.blwwsSoapClient client = new ServiceReference1.blwwsSoapClient();
|
||||
switch (request.Action)
|
||||
{
|
||||
case "CheckIn"://入住
|
||||
string errorMsg = "";
|
||||
//string xmlString1 = "<interface><item idtype=\"0\" idcard = \"" + txtIDNumber.Text.Trim() + "\" customer = \"" + txtName.Text.Trim() + "\" sex =\"女\" country =\"0\" checkindate = \"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\"/></interface>";
|
||||
StringBuilder xmlString = new StringBuilder();
|
||||
xmlString.Append("<interface>");
|
||||
foreach (LuopanEntity.GuestInfo guest in request.GuestInfo)
|
||||
{
|
||||
xmlString.Append("<item idtype=" + guest.IDCardTypeId + " idcard ='" + guest.IDCardNo + "' customer='" + guest.GuestName + "' sex='" +
|
||||
(guest.Gender == 0 ? "男" : "女") + "' country=0 checkindate='" + request.CheckInTime.ToString("yyyy-MM-dd HH:mm:ss") + "'\\>");
|
||||
}
|
||||
xmlString.Append("</interface>");
|
||||
bool result = client.CheckIn("blw_ws@2015", request.HotelId, request.RoomNo, request.CheckInTime, xmlString.ToString(), ref errorMsg, request.GuestInfo[0].Mobile, request.GuestInfo[0].IDCardNo);
|
||||
break;
|
||||
case "CheckOut"://退房
|
||||
break;
|
||||
case "MoveRoom"://换房
|
||||
break;
|
||||
case "Extend"://续住
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user