using Business.TK;
using Common;
using M55128_rec.Business.TK;
using M55128_rec.Models.ViewModels.TrendChartModel;
using Models;
using Models.Entity.LottomatBaseDB;
using Models.Views;
using Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace M55128_rec.Business.ZS
{
public static class ZSapiBLL
{
static ZSapiBLL()
{
}
///
/// 走势图名称,值为"QGC", "DFC", "GPC11X5", "GPCK3", "GPCKL12", "GPCKLSF" , "GPCQTC",注意:高频彩请传(GPC),高频彩下面的分类请传对应代码
///
/// //如果传入为 GPC 的话,就默认返回高频彩11选5相关数据
public static List GetTrendChartNewsList(string lotteryType)
{
if (lotteryType== "GPC")
{
lotteryType = "GPC11X5";
}
List res = new List();
try
{
//如果传入为 GPC 的话,就默认返回高频彩11选5相关数据
List data = DataItemBLL.GetDataItemListbyEnCode(lotteryType);
//dataItemCache.GetDataItemList(arg.Category.Equals("GPC") ? "GPC11X5" : arg.Category).OrderBy(n => n.SortCode).ToList();
string[] ids = data.Select(d => d.ItemDetailId).ToArray();
List listexp = new List();
listexp.Add(new EExpression("IsDelete", "=", 0));
listexp.Add(new EExpression("IsStick", "=", 1));
listexp.Add(new EExpression("CategoryId", EnumExpression.In, ids.ToList()));
//获取该分类下符合要求的数据
List trendChartEntities = TrendChartBLL.GetList("SortCode", listexp);
//TrendChartBll.GetPageList(n => n.IsDelete == false && n.IsStick == true && ids.Contains(n.CategoryId)).OrderBy(n => n.SortCode).ToList();
if (trendChartEntities.Count > 0)
{
//组装父级相关属性
TrendChart_Preview previewItem = new TrendChart_Preview
{
TrendChartType = lotteryType,
ItemName = DataItemBLL.GetBaseDataItemListbyEnCode(lotteryType).ItemName
};
//根据分类ID进行分组
List idlist = trendChartEntities.Select(w => w.CategoryId).ToList();
IEnumerable> group = trendChartEntities.GroupBy(t => t.CategoryId);
List dataItemlist = DataItemBLL.GetListbyItemId(idlist);
List temp = new List();
foreach (IGrouping chartEntities in group)
{
//分类ID
string key = chartEntities.Key;
//获取分类信息
var dataItemEntity = dataItemlist.SingleOrDefault(w => w.ItemDetailId == key);
List trendChartPreviewItems = new List();
//组装项目相关属性
TempTrendChartPreviewItem item = new TempTrendChartPreviewItem
{
TrendChartChildType = dataItemEntity.ItemValue,
TrendChartChildName = dataItemEntity.ItemName
};
//组装具体信息
foreach (Base_TrendChart entity in chartEntities)
{
TrendChartPreviewItem p = new TrendChartPreviewItem
{
Title = entity.Title,
TrendChartUrl = entity.TrendChartUrl,
TrendChartUrlId=entity.PK.ToString()
};
trendChartPreviewItems.Add(p);
}
item.TrendChartPreviewItem = trendChartPreviewItems;
temp.Add(item);
}
previewItem.TrendChartPreviewItems = temp;
res.Add(previewItem);
}
}
catch (Exception ee)
{
LogHelper.Error(typeof(ZSapiBLL), ee.Message + "GetTrendChartNewsList");
}
return res;
}
}
}