105 lines
3.4 KiB
C#
105 lines
3.4 KiB
C#
|
|
using Models;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
|
|||
|
|
namespace SERVER.LIB
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 大部分方法已经弃用
|
|||
|
|
/// </summary>
|
|||
|
|
public class HOTEL_GROUPHelp
|
|||
|
|
{
|
|||
|
|
static List<TBL_HOTEL_GROUP_INFO> data => CacheData.TBL_HOTEL_GROUP_INFO;
|
|||
|
|
static List<TBL_HOTEL_BASIC_INFO> tBL_HOTEL_s => CacheData.TBL_HOTEL_BASIC_INFO;
|
|||
|
|
|
|||
|
|
public static List<TBL_HOTEL_GROUP_INFO> Children(int data)
|
|||
|
|
{
|
|||
|
|
List<TBL_HOTEL_GROUP_INFO> res = new List<TBL_HOTEL_GROUP_INFO>();
|
|||
|
|
var resdata = CacheData.TBL_HOTEL_GROUP_INFO.Where(x => x.PARENT_ID == data).ToList();
|
|||
|
|
res.AddRange(resdata);
|
|||
|
|
foreach (var item in resdata)
|
|||
|
|
{
|
|||
|
|
res.AddRange(Children(item.HOTEL_GROUP_ID));
|
|||
|
|
}
|
|||
|
|
return res;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static List<TBL_HOTEL_GROUP_INFO> GetTreemap(IList<HotelDataItem> dataItems)
|
|||
|
|
{
|
|||
|
|
List<TBL_HOTEL_GROUP_INFO> treemaps = new List<TBL_HOTEL_GROUP_INFO>();
|
|||
|
|
|
|||
|
|
foreach (var tump in dataItems)
|
|||
|
|
{
|
|||
|
|
if (treemaps.FirstOrDefault(X => X.HOTEL_GROUP_ID == tump.HotelGroupsId) == null)
|
|||
|
|
{
|
|||
|
|
treemaps.AddRange(Parent(tump.HotelGroupsId));
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
return treemaps.GroupBy(x => x.HOTEL_GROUP_ID).Select(y => y.First()).ToList();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static List<TBL_HOTEL_GROUP_INFO> Parent(int ID)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
List<TBL_HOTEL_GROUP_INFO> res = new List<TBL_HOTEL_GROUP_INFO>();
|
|||
|
|
var item = data.Single(x => x.HOTEL_GROUP_ID == ID);
|
|||
|
|
res.Add(item);
|
|||
|
|
if (item.PARENT_ID != 0)
|
|||
|
|
{
|
|||
|
|
res.AddRange(Parent(item.PARENT_ID));
|
|||
|
|
}
|
|||
|
|
return res.GroupBy(x => x.HOTEL_GROUP_ID).Select(y => y.First()).ToList();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public static List<TBL_HOTEL_BASIC_INFO> GetHotels(List<HotelsItem> hoteldata, int GroupId)
|
|||
|
|
{
|
|||
|
|
List<TBL_HOTEL_BASIC_INFO> res = new List<TBL_HOTEL_BASIC_INFO>();
|
|||
|
|
var Group = Children(GroupId);
|
|||
|
|
foreach (var item in Group)
|
|||
|
|
{
|
|||
|
|
res.AddRange(GetHotels(item.HOTEL_GROUP_ID).Where(x=> hoteldata.FirstOrDefault(y=>y.HotelId == x.IDOLD)!=null));
|
|||
|
|
}
|
|||
|
|
res = res.GroupBy(x => x.HOTEL_ID).Select(y => y.First()).ToList();
|
|||
|
|
for (int i = 0; i < res.Count; i++)
|
|||
|
|
{
|
|||
|
|
throw new Exception();
|
|||
|
|
}
|
|||
|
|
throw new Exception();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
// 获取酒店组下面的所有直属酒店
|
|||
|
|
public static IEnumerable< TBL_HOTEL_BASIC_INFO > GetHotels( int GroupId)
|
|||
|
|
{
|
|||
|
|
return tBL_HOTEL_s.Where(x => x.HOTEL_GROUP == GroupId);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static string Getgrouppath(TBL_HOTEL_BASIC_INFO hot )
|
|||
|
|
{
|
|||
|
|
string res = string.Empty;
|
|||
|
|
int group = hot.HOTEL_GROUP;
|
|||
|
|
while (true)
|
|||
|
|
{
|
|||
|
|
if(group == 0)
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
if (res == string.Empty)
|
|||
|
|
{
|
|||
|
|
res += data.First(X => X.HOTEL_GROUP_ID == group).HOTEL_GROUP_NAME;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
res += "-";
|
|||
|
|
res += data.First(X => X.HOTEL_GROUP_ID == group).HOTEL_GROUP_NAME;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return res;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|