|  | @@ -3,6 +3,7 @@ using OASystem.Domain;
 | 
	
		
			
				|  |  |  using OASystem.Domain.Dtos.Groups;
 | 
	
		
			
				|  |  |  using OASystem.Domain.Dtos.Resource;
 | 
	
		
			
				|  |  |  using OASystem.Domain.Entities.Resource;
 | 
	
		
			
				|  |  | +using OASystem.Domain.ViewModels.Groups;
 | 
	
		
			
				|  |  |  using OASystem.Domain.ViewModels.Resource;
 | 
	
		
			
				|  |  |  using System;
 | 
	
		
			
				|  |  |  using System.Collections.Generic;
 | 
	
	
		
			
				|  | @@ -71,140 +72,5 @@ namespace OASystem.Infrastructure.Repositories.Resource
 | 
	
		
			
				|  |  |                  return result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        public async Task<Result> QueryHotelData(QueryHotelDataDto dto)
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | -            Result result = new Result() { Code = -2, Msg = "未知错误" };
 | 
	
		
			
				|  |  | -            try
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                string sqlWhere = string.Empty;
 | 
	
		
			
				|  |  | -                if (!string.IsNullOrWhiteSpace(dto.Name))
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    sqlWhere += string.Format(@" And Name like '%{0}%'", dto.Name);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if (!string.IsNullOrWhiteSpace(dto.City) && dto.City != "全部")
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    sqlWhere += string.Format(@" And City like '%{0}%'", dto.City);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if (!string.IsNullOrWhiteSpace(dto.Contact))
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    sqlWhere += string.Format(@" And Contact like '%{0}%'", dto.Contact);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if (!string.IsNullOrWhiteSpace(dto.ContactPhone))
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    sqlWhere += string.Format(@" And ContactPhone like '%{0}%'", dto.ContactPhone);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                sqlWhere += string.Format(@" And IsDel={0}", 0);
 | 
	
		
			
				|  |  | -                if (!string.IsNullOrEmpty(sqlWhere.Trim()))
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    Regex r = new Regex("And");
 | 
	
		
			
				|  |  | -                    sqlWhere = r.Replace(sqlWhere, "Where", 1);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if (dto.PortType == 1)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    string sql = string.Format(@"select * from Res_HotelData {0}", sqlWhere);
 | 
	
		
			
				|  |  | -                    List<Res_HotelData> HotelDataData = await _sqlSugar.SqlQueryable<Res_HotelData>(sql).ToListAsync();
 | 
	
		
			
				|  |  | -                    if (HotelDataData.Count == 0)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        return result = new Result() { Code = -1, Msg = "暂无数据" };
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    HotelDataData = HotelDataData.OrderByDescending(x => x.CreateTime).ToList();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    if (dto.PageSize == 0 && dto.PageIndex == 0)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        return result = new Result()
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            Code = 0,
 | 
	
		
			
				|  |  | -                            Msg = "查询成功",
 | 
	
		
			
				|  |  | -                            Data = HotelDataData,
 | 
	
		
			
				|  |  | -                        };
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        int count = HotelDataData.Count;
 | 
	
		
			
				|  |  | -                        float totalPage = (float)count / dto.PageSize;//总页数
 | 
	
		
			
				|  |  | -                        if (totalPage == 0) totalPage = 1;
 | 
	
		
			
				|  |  | -                        else totalPage = (int)Math.Ceiling((double)totalPage);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                        List<Res_HotelData> _HotelData = new List<Res_HotelData>();
 | 
	
		
			
				|  |  | -                        for (int i = 0; i < dto.PageSize; i++)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
 | 
	
		
			
				|  |  | -                            if (RowIndex < HotelDataData.Count)
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                _HotelData.Add(HotelDataData[RowIndex]);
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                            else
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                break;
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        return result = new Result()
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            Code = 0,
 | 
	
		
			
				|  |  | -                            Msg = "查询成功",
 | 
	
		
			
				|  |  | -                            Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _HotelData },
 | 
	
		
			
				|  |  | -                        };
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else if (dto.PortType == 2)
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    string sql = string.Format(@"select * from Res_HotelData {0}", sqlWhere);
 | 
	
		
			
				|  |  | -                    List<Res_HotelData> HotelDataData = await _sqlSugar.SqlQueryable<Res_HotelData>(sql).ToListAsync();
 | 
	
		
			
				|  |  | -                    if (HotelDataData.Count == 0)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        return result = new Result() { Code = -1, Msg = "暂无数据" };
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    HotelDataData = HotelDataData.OrderByDescending(x => x.CreateTime).ToList();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                    if (dto.PageSize == 0 && dto.PageIndex == 0)
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        return result = new Result()
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            Code = 0,
 | 
	
		
			
				|  |  | -                            Msg = "查询成功",
 | 
	
		
			
				|  |  | -                            Data = HotelDataData,
 | 
	
		
			
				|  |  | -                        };
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    else
 | 
	
		
			
				|  |  | -                    {
 | 
	
		
			
				|  |  | -                        int count = HotelDataData.Count;
 | 
	
		
			
				|  |  | -                        float totalPage = (float)count / dto.PageSize;//总页数
 | 
	
		
			
				|  |  | -                        if (totalPage == 0) totalPage = 1;
 | 
	
		
			
				|  |  | -                        else totalPage = (int)Math.Ceiling((double)totalPage);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                        List<Res_HotelData> _HotelData = new List<Res_HotelData>();
 | 
	
		
			
				|  |  | -                        for (int i = 0; i < dto.PageSize; i++)
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
 | 
	
		
			
				|  |  | -                            if (RowIndex < HotelDataData.Count)
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                _HotelData.Add(HotelDataData[RowIndex]);
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                            else
 | 
	
		
			
				|  |  | -                            {
 | 
	
		
			
				|  |  | -                                break;
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                        return result = new Result()
 | 
	
		
			
				|  |  | -                        {
 | 
	
		
			
				|  |  | -                            Code = 0,
 | 
	
		
			
				|  |  | -                            Msg = "查询成功",
 | 
	
		
			
				|  |  | -                            Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _HotelData },
 | 
	
		
			
				|  |  | -                        };
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                else
 | 
	
		
			
				|  |  | -                {
 | 
	
		
			
				|  |  | -                    return result = new Result() { Code = -2, Msg = "请传入PortType参数!1:Web,2:Android,3:IOS" };
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            catch (Exception)
 | 
	
		
			
				|  |  | -            {
 | 
	
		
			
				|  |  | -                return result;
 | 
	
		
			
				|  |  | -                throw;
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |