示例#1
0
        public void DateChange(HttpContext context, string jsonDate)
        {
            #region  ** 参数验证 **

            JsonData jd_data = JsonMapper.ToObject(jsonDate);
            if (jd_data == null || jd_data.Count < 1)
            {
                throw new PMSException("参数不能为空");
            }

            DateTime StartDate = DateTime.Now;
            JsonData jd        = new JsonData();
            jd["code"] = 1;
            string json = "";
            string day  = CommonUse.ParamVal(jd_data, "Day", "当前日期", false, false);
            if (day != "")
            {
                jd["Date"] = StartDate.ToString("yyyy年MM月dd日");
                json       = jd.ToJson();

                // 统一输出
                PMSResponse.WirterString(json);
                return;
            }

            string date   = CommonUse.ParamVal(jd_data, "Date", "起始日期", true, true);
            string type   = CommonUse.ParamVal(jd_data, "Type", "变动类型", true, true);
            int    UpDown = CommonHelper.GetInt(CommonUse.ParamVal(jd_data, "UpDown", "调整方式", true, true), 1);

            #endregion

            switch (type)
            {
            case "1":
                StartDate  = Convert.ToDateTime(date).AddDays(UpDown);
                jd["Date"] = StartDate.ToString("yyyy年MM月dd日");
                break;

            case "2":
                StartDate  = Convert.ToDateTime(date + "01日").AddMonths(UpDown);
                jd["Date"] = StartDate.ToString("yyyy年MM月");
                break;

            case "3":
                StartDate  = Convert.ToDateTime(date + "01月01日").AddYears(UpDown);
                jd["Date"] = StartDate.ToString("yyyy年");
                break;

            default:
                jd["code"]    = 0;
                jd["message"] = "变动类型错误!";
                break;
            }
            json = jd.ToJson();

            // 统一输出
            PMSResponse.WirterString(json);
        }
示例#2
0
        public void GetRoomPriceCode(HttpContext context, string jsonDate)
        {
            #region  ** 参数验证 **

            JsonData jd_data = JsonMapper.ToObject(jsonDate);
            if (jd_data == null || jd_data.Count < 1)
            {
                throw new PMSException("参数不能为空");
            }

            string   HotelCode = CommonUse.ParamVal(jd_data, "HotelCode", "酒店编号", true, true);
            string[] keyValue  = DESEncrypt.Decrypt(HotelCode).Split(',');
            if (keyValue.Length != 2)
            {
                throw new PMSException("错误的酒店编号,请核对后重试");
            }

            #endregion

            string adminHotelId = keyValue[0];
            string hotelId      = keyValue[1];

            if (!DataFactory.CheckSqlIsOpen(adminHotelId, CommonHelper.GetInt(hotelId)))//数据库是否能连接
            {
                throw new PMSException("数据库连接失败,请验证网络是否正常");
            }

            StringBuilder sql = new StringBuilder();
            sql.Append("SELECT plan0 RoomPriceCode,desc0 RoomPriceName FROM CS_FJBMB");
            DataTable dt = DataFactory.SqlDataBase(adminHotelId, hotelId).GetDataTableBySQL(sql);

            JsonData jd = new JsonData();//返回JsonData
            if (dt != null && dt.Rows.Count > 0)
            {
                JsonData jdData = new JsonData();//DataTable值
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    JsonData jdList = new JsonData();
                    jdList["RoomPriceCode"] = dt.Rows[i]["RoomPriceCode"].ToString();
                    jdList["RoomPriceName"] = dt.Rows[i]["RoomPriceName"].ToString();
                    jdData.Add(jdList);
                }
                jd["code"] = 1;
                jd["data"] = jdData;
            }
            else
            {
                jd["code"]    = 0;
                jd["message"] = "未查询到房价码!";
            }
            string json = jd.ToJson();
            // 统一输出
            PMSResponse.WirterString(json);
        }
示例#3
0
        public void SmsCode(HttpContext context, string jsonDate)
        {
            #region  ** 参数验证 **

            JsonData jd_data = JsonMapper.ToObject(jsonDate);
            if (jd_data == null || jd_data.Count < 1)
            {
                throw new PMSException("参数不能为空");
            }

            string phone = CommonUse.ParamVal(jd_data, "Phone", "手机号码", true, true);
            int    num   = CommonHelper.GetInt(CommonUse.ParamVal(jd_data, "SmsType", "短信类型", true, true));//类型 1 登录验证,3 免费注册,5忘记密码

            JsonData jd = new JsonData();
            if (!ValidateUtil.IsValidMobile(phone))
            {
                jd["code"]    = 0;
                jd["message"] = "请输入正确的手机号码!";
            }

            Random ran_int = new Random();
            string code    = ran_int.Next(1000, 9999).ToString();
            if (SendSms(phone, code, num, "1"))
            {
                jd["code"] = 1;
                jd["data"] = "";
            }
            else
            {
                jd["code"]    = 0;
                jd["message"] = "请输入正确的手机号码!";
            }
            #endregion

            string json = jd.ToJson();

            // 统一输出
            PMSResponse.WirterString(json);
        }
示例#4
0
        public void Supervise(HttpContext context, string jsonDate)
        {
            #region  ** 参数验证 **

            JsonData jd_data = JsonMapper.ToObject(jsonDate);
            if (jd_data == null || jd_data.Count < 1)
            {
                throw new PMSException("参数不能为空");
            }
            string HotelCode = CommonUse.ParamVal(jd_data, "HotelCode", "酒店编号", true, true);
            string sign      = CommonUse.ParamVal(jd_data, "Sign", "签名", true, true);
            string sign_new  = Md5Helper.MD5(HotelCode, 32);
            if (sign.ToLower() != sign_new.ToLower())
            {
                throw new PMSException("签名验证失败!");
            }
            string[] keyValue = DESEncrypt.Decrypt(HotelCode).Split(',');
            if (keyValue.Length < 2)
            {
                throw new PMSException("错误的酒店编号,请核对后重试");
            }

            int pageIndex = CommonHelper.GetInt(CommonUse.ParamVal(jd_data, "PageIndex", "当前页", true, true));
            int DataType  = CommonHelper.GetInt(CommonUse.ParamVal(jd_data, "DataType", "数据类型", false, false));
            #endregion

            string adminHotelId = keyValue[0];
            string hotelId      = keyValue[1];
            string userId       = keyValue[2];
            if (DataType > 1)//数据类型不为0表示为数据查询数据库读取
            {
                adminHotelId = "1010142";
                hotelId      = "0";
            }
            if (!DataFactory.CheckSqlIsOpen(adminHotelId, CommonHelper.GetInt(hotelId)))//数据库是否能连接
            {
                throw new PMSException("数据库连接失败,请验证网络是否正常");
            }

            int      PageSize = 20;
            int      doCount  = 0;
            int      more     = 0;
            JsonData jd       = new JsonData(); //返回JsonData
            JsonData jdData   = new JsonData(); //DataTable值
            #region ** 获取数据值 **
            try
            {
                StringBuilder sql = new StringBuilder();
                sql.Append(@"
                SELECT  rq ,
                        jglb ,
                        xh ,
                        jglr
                FROM    XX_JGXJCX
                ");
                IList <SqlParam> lParam = new List <SqlParam>();
                if (DataType > 1)
                {
                    sql.Append(" WHERE jdid = @jdid ");
                    lParam.Add(new SqlParam("@jdid", DataType));
                }
                sql.Append(" ORDER BY rq DESC ");
                DataTable dt = DataFactory.SqlDataBase(adminHotelId, hotelId).GetDataTableBySQL(sql);

                if (dt != null && dt.Rows.Count > 0)
                {
                    doCount = dt.Rows.Count;
                    int pi_ps = (pageIndex - 1) * PageSize;
                    int pi_dc = pi_ps + PageSize;
                    if (pi_dc > doCount)
                    {
                        pi_dc = doCount;
                    }
                    more = doCount - pi_dc;//更多剩余数
                    more = more > 0 ? more : 0;
                    if (pi_dc > doCount)
                    {
                        pi_dc = doCount;
                    }
                    for (int i = pi_ps; i < pi_dc; i++)
                    {
                        JsonData jdList = new JsonData();                        //
                        jdList["Time"]     = dt.Rows[i]["rq"].ToString();        //时间
                        jdList["Type"]     = dt.Rows[i]["jglb"].ToString();;     //类型
                        jdList["Operator"] = "00" + dt.Rows[i]["xh"].ToString(); //操作人
                        jdList["Content"]  = dt.Rows[i]["jglr"].ToString();      //操作内容
                        jdData.Add(jdList);
                    }
                }
            }
            catch
            {
            }
            #endregion

            jd["code"]  = 1;
            jd["count"] = doCount; //数量
            jd["more"]  = more;    //更多剩余数
            jd["data"]  = jdData.IsArray ? jdData : false;

            string json = jd.ToJson();
            // 统一输出
            PMSResponse.WirterString(json);
        }
示例#5
0
        public void RevenueMonth(HttpContext context, string jsonDate)
        {
            #region  ** 参数验证 **

            JsonData jd_data = JsonMapper.ToObject(context.Server.UrlDecode(jsonDate));
            if (jd_data == null || jd_data.Count < 1)
            {
                throw new PMSException("参数不能为空");
            }
            string HotelCode = CommonUse.ParamVal(jd_data, "HotelCode", "酒店编号", true, true);
            string sign      = CommonUse.ParamVal(jd_data, "Sign", "签名", true, true);
            string sign_new  = Md5Helper.MD5(HotelCode, 32);
            if (sign.ToLower() != sign_new.ToLower())
            {
                throw new PMSException("签名验证失败!");
            }
            string[] keyValue = DESEncrypt.Decrypt(HotelCode).Split(',');
            if (keyValue.Length < 2)
            {
                throw new PMSException("错误的酒店编号,请核对后重试");
            }

            string date = CommonUse.ParamVal(jd_data, "Date", "时间", true, true);
            string type = CommonUse.ParamVal(jd_data, "Type", "时间类型", true, true);

            int DataType = CommonHelper.GetInt(CommonUse.ParamVal(jd_data, "DataType", "数据类型", false, false));

            #endregion

            string adminHotelId = keyValue[0];
            string hotelId      = keyValue[1];
            string userId       = keyValue[2];
            if (DataType > 1)//数据类型不为0表示为数据查询数据库读取
            {
                adminHotelId = "1010142";
                hotelId      = "0";
            }
            if (!DataFactory.CheckSqlIsOpen(adminHotelId, CommonHelper.GetInt(hotelId)))//数据库是否能连接
            {
                throw new PMSException("数据库连接失败,请验证网络是否正常");
            }
            DateTime StartDate = Convert.ToDateTime("2010-01-01");
            DateTime EndDate   = DateTime.Now.AddDays(1);
            string   json      = "";
            switch (type)
            {
            case "1":
                StartDate = Convert.ToDateTime(date + "01日");
                EndDate   = StartDate.AddMonths(1);
                json      = MonthData(adminHotelId, hotelId, StartDate.ToString("yyyy-MM-dd"), EndDate.ToString("yyyy-MM-dd"), DataType);
                break;

            case "2":
                StartDate = Convert.ToDateTime(date + "01月01日");
                EndDate   = StartDate.AddYears(1);
                json      = YearData(adminHotelId, hotelId, StartDate.ToString("yyyy-MM-dd"), EndDate.ToString("yyyy-MM-dd"), DataType);
                break;

            case "3":
                json = AllData(adminHotelId, hotelId, DataType);
                break;

            default:
                break;
            }
            if (json == "")
            {
                JsonData jd = new JsonData();//返回JsonData
                jd["code"]    = 0;
                jd["message"] = "没有找到您要找的数据!";
                json          = jd.ToJson();
            }
            // 统一输出
            PMSResponse.WirterString(json);
        }
示例#6
0
        public void Truth(HttpContext context, string jsonDate)
        {
            #region  ** 参数验证 **

            JsonData jd_data = JsonMapper.ToObject(jsonDate);
            if (jd_data == null || jd_data.Count < 1)
            {
                throw new PMSException("参数不能为空");
            }

            string HotelCode = CommonUse.ParamVal(jd_data, "HotelCode", "酒店编号", true, true);
            string sign      = CommonUse.ParamVal(jd_data, "Sign", "签名", true, true);
            string sign_new  = Md5Helper.MD5(HotelCode, 32);
            if (sign.ToLower() != sign_new.ToLower())
            {
                throw new PMSException("签名验证失败!");
            }
            string[] keyValue = DESEncrypt.Decrypt(HotelCode).Split(',');
            if (keyValue.Length < 2)
            {
                throw new PMSException("错误的酒店编号,请核对后重试");
            }

            string date     = CommonUse.ParamVal(jd_data, "Date", "时间", true, true);
            string type     = CommonUse.ParamVal(jd_data, "Type", "时间类型", true, true);
            string sd       = CommonUse.ParamVal(jd_data, "StartDate", "开始日期", false, false);
            string ed       = CommonUse.ParamVal(jd_data, "EndDate", "结束日期", false, false);
            int    DataType = CommonHelper.GetInt(CommonUse.ParamVal(jd_data, "DataType", "数据类型", false, false));

            #endregion

            string adminHotelId = keyValue[0];
            string hotelId      = keyValue[1];
            string userId       = keyValue[2];
            if (DataType > 1)//数据类型不为0表示为数据查询数据库读取
            {
                adminHotelId = "1010142";
                hotelId      = "0";
            }
            if (!DataFactory.CheckSqlIsOpen(adminHotelId, CommonHelper.GetInt(hotelId)))//数据库是否能连接
            {
                throw new PMSException("数据库连接失败,请验证网络是否正常");
            }

            int SalesMoney      = 0;
            int SalesAccumulate = 0;
            int SaleNight       = 0;
            int RentalRate      = 0;
            int AveragePrice    = 0;
            int RevPAR          = 0;

            int StayIn        = 0;
            int GetRoom       = 0;
            int RetreatRoom   = 0;
            int Arrivals      = 0;
            int Repair        = 0;
            int EstimateMoney = 0;

            DateTime StartDate = Convert.ToDateTime("2010-01-01");
            DateTime EndDate   = DateTime.Now.AddDays(1);

            DateTime sdAccumulate = Convert.ToDateTime("2010-01-01");
            DateTime edAccumulate = DateTime.Now.AddDays(1);

            switch (type)
            {
            case "1":
                StartDate = Convert.ToDateTime(date);
                EndDate   = StartDate.AddDays(1);

                sdAccumulate = Convert.ToDateTime(StartDate.ToString("yyyy-MM-01"));
                edAccumulate = Convert.ToDateTime(StartDate.AddMonths(1).ToString("yyyy-MM-01"));
                break;

            case "2":
                StartDate    = Convert.ToDateTime(date + "01日");
                EndDate      = StartDate.AddMonths(1);
                sdAccumulate = Convert.ToDateTime(StartDate.ToString("yyyy-01-01"));
                edAccumulate = Convert.ToDateTime(StartDate.AddYears(1).ToString("yyyy-01-01"));
                break;

            case "3":
                StartDate = Convert.ToDateTime(date + "01月01日");
                EndDate   = StartDate.AddYears(1);
                break;

            case "4":
                try
                {
                    sdAccumulate = StartDate = Convert.ToDateTime(sd);
                    edAccumulate = EndDate = Convert.ToDateTime(ed).AddDays(1);
                }
                catch
                {
                    throw new PMSException("自定义时间格式错误!");
                }
                break;

            default:
                break;
            }
            #region ** 获取数据值 **
            try
            {
                DataTable dt    = GetSales(DataType, adminHotelId, hotelId, StartDate, EndDate);
                DataTable dtAcc = GetSales(DataType, adminHotelId, hotelId, sdAccumulate, edAccumulate);
                if (dt != null && dt.Rows.Count > 0)
                {
                    int days = CommonHelper.GetInt(dt.Rows[0]["dayNum"].ToString());
                    SalesMoney      = CommonHelper.GetInt(dt.Rows[0]["yysr"].ToString());
                    SalesAccumulate = CommonHelper.GetInt(dtAcc.Rows[0]["yysr"].ToString());
                    SaleNight       = CommonHelper.GetInt(dt.Rows[0]["fws"].ToString());
                    RentalRate      = CommonHelper.GetInt(dt.Rows[0]["czl"].ToString()) / days;
                    AveragePrice    = CommonHelper.GetInt(dt.Rows[0]["pjfj"].ToString()) / days;
                    RevPAR          = CommonHelper.GetInt(dt.Rows[0]["repar"].ToString()) / days;
                }

                DataTable dt_day = GetDayNumber(DataType, adminHotelId, hotelId, StartDate, EndDate);
                if (dt_day != null && dt_day.Rows.Count > 0)
                {
                    StayIn        = CommonHelper.GetInt(dt_day.Rows[0]["dqzzs"].ToString());
                    GetRoom       = CommonHelper.GetInt(dt_day.Rows[0]["jrkfs"].ToString());
                    RetreatRoom   = CommonHelper.GetInt(dt_day.Rows[0]["jrtfs"].ToString());
                    Arrivals      = CommonHelper.GetInt(dt_day.Rows[0]["jryd"].ToString());
                    Repair        = CommonHelper.GetInt(dt_day.Rows[0]["jrwx"].ToString());
                    EstimateMoney = CommonHelper.GetInt(dt_day.Rows[0]["yjjrsr"].ToString());
                }
            }
            catch
            {
            }
            #endregion

            JsonData jd     = new JsonData();            //返回JsonData
            JsonData jdData = new JsonData();            //DataTable值

            jdData["SalesMoney"]      = SalesMoney;      //营收
            jdData["SalesAccumulate"] = SalesAccumulate; //累计
            jdData["SaleNight"]       = SaleNight;       //房晚数
            jdData["RentalRate"]      = RentalRate;      //出租率
            jdData["AveragePrice"]    = AveragePrice;    //平均房价
            jdData["RevPAR"]          = RevPAR;          //RevPAR

            jdData["StayIn"]        = StayIn;            //在住数
            jdData["GetRoom"]       = GetRoom;           //开房
            jdData["RetreatRoom"]   = RetreatRoom;       //退房
            jdData["Arrivals"]      = Arrivals;          //预抵
            jdData["Repair"]        = Repair;            //维修房
            jdData["EstimateMoney"] = EstimateMoney;     //预计房租收入

            jd["code"] = 1;
            jd["data"] = jdData;

            string json = jd.ToJson();
            // 统一输出
            PMSResponse.WirterString(json);
        }
示例#7
0
        public void GetRoomStateView(HttpContext context, string jsonDate)
        {
            #region  ** 解码酒店编号 **

            JsonData jd_data = JsonMapper.ToObject(jsonDate);
            if (jd_data == null || jd_data.Count < 1)
            {
                throw new PMSException("参数不能为空");
            }
            string HotelCode = CommonUse.ParamVal(jd_data, "HotelCode", "酒店编号", true, true);
            string sign      = CommonUse.ParamVal(jd_data, "Sign", "签名", true, true);
            string sign_new  = Md5Helper.MD5(HotelCode, 32);
            if (sign.ToLower() != sign_new.ToLower())
            {
                throw new PMSException("签名验证失败!");
            }

            string[] keyValue = DESEncrypt.Decrypt(HotelCode).Split(',');
            if (keyValue.Length < 2)
            {
                throw new PMSException("错误的酒店编号,请核对后重试");
            }
            int DataType = CommonHelper.GetInt(CommonUse.ParamVal(jd_data, "DataType", "数据类型", false, false));
            #endregion

            string adminHotelId = keyValue[0];
            string hotelId      = keyValue[1];
            string userId       = keyValue[2];
            if (DataType > 1)//数据类型不为0表示为数据查询数据库读取
            {
                adminHotelId = "1010142";
                hotelId      = "0";
            }
            if (!DataFactory.CheckSqlIsOpen(adminHotelId, CommonHelper.GetInt(hotelId)))//数据库是否能连接
            {
                throw new PMSException("数据库连接失败,请验证网络是否正常");
            }

            StringBuilder sql = new StringBuilder();
            sql.Append("select * from XX_SSFTB where 1=1 ");

            IList <SqlParam> lParam = new List <SqlParam>();
            if (DataType > 1)
            {
                sql.Append(" AND jdid = @jdid ");
                lParam.Add(new SqlParam("@jdid", DataType));
            }
            sql.Append(" order by fh asc ");

            DataTable dt = DataFactory.SqlDataBase(adminHotelId, hotelId).GetDataTableBySQL(sql, lParam.ToArray());

            JsonData jd = new JsonData();//返回JsonData
            if (dt != null && dt.Rows.Count > 0)
            {
                string   GuestNum    = dt.Rows.Count.ToString();
                JsonData jdData      = new JsonData(); //DataTable值
                JsonData jdTotalData = new JsonData(); //DataTable值
                int      ZS          = 0;
                int      OC          = 0;
                int      VC          = 0;
                int      VD          = 0;
                int      BC          = 0;
                int      OOO         = 0;
                int      LR          = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ZS++;
                    JsonData jdList     = new JsonData();
                    string   StateStyle = "";
                    string   ftcode     = dt.Rows[i]["fjzt"].ToString().Trim();
                    if (ftcode == "OC" || ftcode == "OD")//在住房
                    {
                        OC++;
                        StateStyle = "zaizhu";
                    }
                    //else if (ftcode == "OD")//在住脏房
                    //{
                    //    ftname = "在住脏房";
                    //    StateStyle = "zhuzang";
                    //}
                    else if (ftcode == "VD")//空脏房
                    {
                        VD++;
                        StateStyle = "kongzang";
                    }
                    else if (ftcode == "VC")//空洁房
                    {
                        VC++;
                        StateStyle = "kongjie";
                    }
                    else if (ftcode == "BC" || ftcode == "BD" || ftcode == "CMD" || ftcode == "CMC")//预抵净房
                    {
                        BC++;
                        StateStyle = "yudijing";
                    }
                    //else if (ftcode == "CMD")//预抵脏房
                    //{
                    //    StateStyle = "yudizang";
                    //}
                    //else if (ftcode == "BD")//预抵脏房
                    //{
                    //    StateStyle = "yudizang";
                    //}
                    //else if (ftcode == "CMC")//预抵净房
                    //{
                    //    StateStyle = "yudijing";
                    //}
                    else if (ftcode == "OOO" || ftcode == "OOS")//维修房
                    {
                        OOO++;
                        StateStyle = "weixiu";
                    }
                    //else if (ftcode == "OOS")//维护房
                    //{
                    //    StateStyle = "weihu";
                    //}
                    else if (ftcode == "GO")//预离房
                    {
                        StateStyle = "yuli";
                    }
                    else if (ftcode == "LR" || ftcode == "LC")//锁房
                    {
                        LR++;
                        StateStyle = "suo";
                    }
                    //else if (ftcode == "LC")//锁房
                    //{
                    //    StateStyle = "suo";
                    //}

                    jdList["RoomNumber"] = dt.Rows[i]["fh"].ToString(); //房间号
                    jdList["StateStyle"] = StateStyle;                  //房间样式
                    jdList["RoomState"]  = ftcode;                      //房间状态代码
                    jdData.Add(jdList);
                }
                JsonData jdhj = new JsonData();
                jdhj["RoomState"]  = "ZS"; //房间状态
                jdhj["RoomNumber"] = ZS;   //房态数量
                jdTotalData.Add(jdhj);
                //
                jdhj = new JsonData();
                jdhj["RoomState"]  = "OC"; //房间状态
                jdhj["RoomNumber"] = OC;   //房态数量
                jdTotalData.Add(jdhj);
                //
                jdhj = new JsonData();
                jdhj["RoomState"]  = "VC"; //房间状态
                jdhj["RoomNumber"] = VC;   //房态数量
                jdTotalData.Add(jdhj);
                //
                jdhj = new JsonData();
                jdhj["RoomState"]  = "VD"; //房间状态
                jdhj["RoomNumber"] = VD;   //房态数量
                jdTotalData.Add(jdhj);
                //
                jdhj = new JsonData();
                jdhj["RoomState"]  = "BC"; //房间状态
                jdhj["RoomNumber"] = BC;   //房态数量
                jdTotalData.Add(jdhj);
                //
                jdhj = new JsonData();
                jdhj["RoomState"]  = "OOO"; //房间状态
                jdhj["RoomNumber"] = OOO;   //房态数量
                jdTotalData.Add(jdhj);
                //
                jdhj = new JsonData();
                jdhj["RoomState"]  = "LR"; //房间状态
                jdhj["RoomNumber"] = LR;   //房态数量
                jdTotalData.Add(jdhj);

                jd["code"]      = 1;
                jd["data"]      = jdData.IsArray ? jdData : false;
                jd["TotalData"] = jdTotalData.IsArray ? jdTotalData : false;
                int or = Convert.ToInt32((Convert.ToDouble(OC) / Convert.ToDouble(ZS)) * 1000);
                jd["OccupancyRate"] = or / 10;
            }
            else
            {
                jd["code"]    = 0;
                jd["message"] = "未查询到相关信息!";
            }
            string json = jd.ToJson();
            // 统一输出
            PMSResponse.WirterString(json);
        }
示例#8
0
        public void SettleReport(HttpContext context, string jsonDate)
        {
            #region  ** 解码酒店编号 **

            JsonData jd_data = JsonMapper.ToObject(jsonDate);
            if (jd_data == null || jd_data.Count < 1)
            {
                throw new PMSException("参数不能为空");
            }
            string HotelCode = CommonUse.ParamVal(jd_data, "HotelCode", "酒店编号", true, true);
            string date      = CommonUse.ParamVal(jd_data, "Date", "日期", true, true);
            string sign      = CommonUse.ParamVal(jd_data, "Sign", "签名", true, true);

            string sign_new = Md5Helper.MD5(HotelCode + date, 32);
            if (sign.ToLower() != sign_new.ToLower())
            {
                throw new PMSException("签名验证失败!");
            }

            string[] keyValue = DESEncrypt.Decrypt(HotelCode).Split(',');
            if (keyValue.Length < 2)
            {
                throw new PMSException("错误的酒店编号,请核对后重试");
            }
            int DataType = CommonHelper.GetInt(CommonUse.ParamVal(jd_data, "DataType", "数据类型", false, false));
            #endregion


            DateTime startDate    = CommonHelper.GetDateTime(date);
            DateTime endDate      = startDate.AddDays(1);
            string   adminHotelId = keyValue[0];
            string   hotelId      = keyValue[1];
            string   userId       = keyValue[2];
            if (DataType > 1)//数据类型不为0表示为数据查询数据库读取
            {
                adminHotelId = "1010142";
                hotelId      = "0";
            }
            if (!DataFactory.CheckSqlIsOpen(adminHotelId, CommonHelper.GetInt(hotelId)))//数据库是否能连接
            {
                throw new PMSException("数据库连接失败!");
            }

            StringBuilder sql = new StringBuilder();
            sql.Append(@"
            SELECT  jdid ,
                    xmdesc ,
                    je
            FROM    [view_yyjssrb]
            WHERE   rq >= @startDate
                    AND rq < @endDate
            ");

            JsonData         jdData = new JsonData();//DataTable值
            IList <SqlParam> lParam = new List <SqlParam>();
            lParam.Add(new SqlParam("@startDate", startDate));
            lParam.Add(new SqlParam("@endDate", endDate));
            if (DataType > 1)
            {
                sql.Append(" AND jdid = @jdid ");
                lParam.Add(new SqlParam("@jdid", DataType));
            }
            //sql.Append(" ORDER BY xmlb ASC ");

            DataTable dt = DataFactory.SqlDataBase(adminHotelId, hotelId).GetDataTableBySQL(sql, lParam.ToArray());
            JsonData  jd = new JsonData();//返回JsonData
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    JsonData jdList = new JsonData();
                    jdList["ItemName"]     = dt.Rows[i]["xmdesc"].ToString();    //项目名称
                    jdList["SurplusMoney"] = Convert.ToDouble(dt.Rows[i]["je"]); //余额
                    jdData.Add(jdList);
                }
                jd["code"] = 1;
                jd["data"] = jdData.IsArray ? jdData : false;
            }
            else
            {
                jd["code"]    = 0;
                jd["message"] = "未查询到相关信息!";
            }
            string json = jd.ToJson();
            // 统一输出
            PMSResponse.WirterString(json);
        }