using Business.KJH; using Cache; using Cache.Cache; using Common; using JobService; using KJH55128_Rec.Business.TrendChart; using KJH55128_Rec.ViewModels; using Models; using Models.Entity.LotteryNumDB; using Models.Views; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace KJH55128_Rec.Business { public static class KJApiBLL { // private static LogHelper log = null; static KJApiBLL() { JobMange jobMange= new JobMange(); jobMange.JobStart(); // log = new LogHelper(); } public static List GetLottery() { List list = new List(); try { list = LotteryCache.GetLottery(); } catch (Exception ee) { LogHelper.Error(typeof(KJApiBLL), ee.Message + "GetLottery"); } return list; } public static LotteryData GetLottery(string typename) { return LotteryCache.GetLottery(typename); } public static KaijiangDetailsEntity GetKaijiangEntity(string type, string id) { try { return KJBLL.GetKaijiangEntity(type, id); } catch (Exception ee) { LogHelper.Error(typeof(KJApiBLL), ee.Message + ":GetKaijiangEntity(string type, string id)"); return null; } } /// /// 获取几天以内的开奖历史数据 /// /// /// /// public static List GetLotteryList(string lotterytype, int day, int num, string order, Dictionary param, int count = 0, Boolean isdesc = true,bool kjhOrsjh = false) { try { Dictionary dict = new Dictionary(); List data = new List(); if (day > 0) { data = LotteryCache.GetLotteryList(lotterytype, day); } else if (count > 0) { data = LotteryCache.GetTopNumList(lotterytype, order, count, isdesc); } else { data = LotteryCache.GetLotteryList(lotterytype, param); } List result = new List(); List detaillist = new List(); for (int i = 0; i < data.Count; i++) { LotteryViewModel tmp = new LotteryViewModel() { NextOpenTime = data[i].NextOpenTime, MoneyPond = data[i].MoneyPond, OpenTime = data[i].OpenTime, SkipDate = data[i].SkipDate, StartHour = data[i].StartHour, StartMinute = data[i].StartMinute, MoneyCount = data[i].MoneyCount, TimesPerDay = data[i].TimesPerDay, RedBall = data[i].RedBall, RuleId = data[i].RuleId, MenuName = data[i].MenuName, LotteryName = data[i].LotteryName, KJTime = data[i].KJTime, LotteryText = data[i].LotteryText, LotteryType = data[i].LotteryType, KaiJiHao = data[i].KaiJiHao, Interval = data[i].Interval, ShiJiHao = data[i].ShiJiHao, BallCount = data[i].BallCount, BlueBall = data[i].BlueBall, DaXiaoZJZ = data[i].DaXiaoZJZ, Term = data[i].Term, HasLotteryZS = data[i].HasLotteryZS, Details = null, ID = data[i].ID, ZhongZhi = 14, HKBall = HongKongHelper.GetHongKongLotteryAttr(data[i].RedBall.ToList()) }; var lottery = Enum.Parse(typeof(SCCLottery), data[i].LotteryType); var lotteryttext = EnumHelper.GetLotteryText((SCCLottery)lottery); tmp.LotteryText = lotteryttext; var detials = data[i].Details; //tmp.Results = reslist as List; //开奖详情转换 if (data[i].ResultsList != null) { var enumer = data[i].ResultsList.GetEnumerator(); List tmpresult = new List(); while (enumer.MoveNext()) { LotteryViewModel.LotteryResults tmplr = new LotteryViewModel.LotteryResults() { Count = enumer.Current.Count, LevelName = enumer.Current.LevelName, Money = enumer.Current.Money }; tmpresult.Add(tmplr); } tmp.Results = tmpresult;//开奖内容添加进去 } foreach (var item in detials) { if (item.Label == "大小比") { tmp.daxiao = item.Value; } else if (item.Label == "三区比") { tmp.sanqu = item.Value; } else if (item.Label == "012路个数比") { tmp.zotgsb = item.Value; } else if (item.Label == "大小形态") { tmp.dxxt = String.Join(",", item.Value.ToCharArray()); } else if (item.Label == "奇偶形态") { tmp.jioxt = String.Join(",", item.Value.ToCharArray()); } else if (item.Label == "质合比") { tmp.zihebi = item.Value; } else if (item.Label == "奇偶比") { tmp.jio = item.Value; } else if (item.Label == "跨度") { tmp.kuadu = item.Value; } else if (item.Label == "和值") { tmp.hezhi = item.Value; } else { LotteryViewModel.LotteryDetail tmpd = new LotteryViewModel.LotteryDetail() { Label = item.Label, Value = item.Value }; detaillist.Add(tmpd); } } tmp.Details = detaillist; detaillist = new List(); if (lotterytype == SCCLottery.QG_FCSSQ.ToString()) { tmp.shama = @"http://zx.55128.cn/ssq/ssqyc_list/42.htm"; tmp.danma = @"http://zx.55128.cn/ssq/ssqdm_list/52.htm"; tmp.zoushi = @"http://www.55128.cn/zs/4_26.htm"; tmp.gongju = @"http://www.55128.cn/tool/ssq_ss.aspx"; } if (lotterytype == SCCLottery.QG_FC3D.ToString()) { tmp.shama = @"http://zx.55128.cn/3dsm/38.htm"; tmp.danma = @"http://zx.55128.cn/3ddm/29.htm"; tmp.zoushi = @"http://www.55128.cn/zs/1_1.htm"; tmp.gongju = @"http://www.55128.cn/tool/3dss.aspx"; tmp.yuce = @"http://zx.55128.cn/3d/3dyc_list/15.htm"; } if (lotterytype == SCCLottery.QG_TCP3.ToString()) { tmp.shama = @"http://zx.55128.cn/p3/p3sm_list/40.htm"; tmp.danma = @"http://zx.55128.cn/p3/p3dm_list/48.htm"; tmp.zoushi = @"http://www.55128.cn/zs/2_14.htm"; tmp.gongju = @"http://www.55128.cn/tool/p3ss.aspx"; tmp.yuce = "http://zx.55128.cn/p3/p3yc_list/23.htm"; } if (lotterytype == SCCLottery.QG_TCDLT.ToString()) { tmp.zoushi = @"http://www.55128.cn/zs/12_96.htm"; tmp.gongju = @"http://www.55128.cn/tool/dlt_qss.aspx"; } result.Add(tmp); } return result; } catch (Exception ee) { return null; } } public static List GetLotteryListKaiJiHao(string lotterytype, int day, int num, string order, Dictionary param, int count = 0, Boolean isdesc = true) { var data = GetLotteryList(lotterytype, day, num, order, param, count, isdesc,true); if (data== null) { return new List(); } List list = new List(); foreach (var item in data) { KaiJiHaoAdShijihaoHModel kaijianghao = new KaiJiHaoAdShijihaoHModel() { BallCount = item.BallCount, BlueBall = item.BlueBall, daxiao = item.daxiao, Details = item.Details, HasLotteryZS = item.HasLotteryZS, hezhi = item.hezhi, ID = item.ID, jio = item.jio, LotteryName = item.LotteryName, LotteryText = item.LotteryText, LotteryType = item.LotteryType, MenuName = item.MenuName, NextOpenTime = item.NextOpenTime, OpenTime = item.OpenTime, RedBall = item.RedBall, RuleId = item.RuleId, Term = item.Term, yuce = item.yuce, ZhongZhi = item.ZhongZhi, KJTime=item.KJTime }; List detaillist = new List(); KaiJiHaoAdShijihaoHModel kaijihao = new KaiJiHaoAdShijihaoHModel(); if (!string.IsNullOrEmpty(item.KaiJiHao)) { var ary = Array.ConvertAll(item.KaiJiHao.Split(',').ToArray(), s => int.Parse(s)); var item2 = KJBLL.GetLotteryData(lotterytype, int.Parse(item.Term.ToString()), DateTime.Parse(item.OpenTime), item.ID, ary, null, "", item.KaiJiHao == null ? "" : item.KaiJiHao == null ? "" : item.KaiJiHao, item.ShiJiHao); kaijihao = new KaiJiHaoAdShijihaoHModel() { BallCount = item2.BallCount, BlueBall = item2.BlueBall, // daxiao = item2.daxiao, //Details = item2.Details, HasLotteryZS = item2.HasLotteryZS, //hezhi = item2.hezhi, ID = item2.ID, // jio = item2.jio, LotteryName = item2.LotteryName, LotteryText = item2.LotteryText, LotteryType = item2.LotteryType, MenuName = item2.MenuName, NextOpenTime = item2.NextOpenTime, OpenTime = item2.OpenTime, RedBall = item2.RedBall, RuleId = item2.RuleId, Term = item2.Term, // yuce = item2.yuce, ZhongZhi = 14 }; var detials = item2.Details; foreach (var itemdetials in detials) { if (itemdetials.Label == "大小比") { kaijihao.daxiao = itemdetials.Value; } else if (itemdetials.Label == "奇偶比") { kaijihao.jio = itemdetials.Value; } else if (itemdetials.Label == "和值") { kaijihao.hezhi = itemdetials.Value; } else { LotteryViewModel.LotteryDetail tmpd = new LotteryViewModel.LotteryDetail() { Label = itemdetials.Label, Value = itemdetials.Value }; detaillist.Add(tmpd); } } kaijihao.Details = detaillist; } detaillist = new List(); list.Add(new LotteryKaiJiHaoAdShijihaoHModel() { Kaijianghao = kaijianghao, Kaijihao = kaijihao }); } return list; } public static List GetLotteryListShiJiHao(string lotterytype, int day, int num, string order, Dictionary param, int count = 0, Boolean isdesc = true) { try { var data = GetLotteryList(lotterytype, day, num, order, param, count, isdesc, true); List list = new List(); foreach (var item in data) { KaiJiHaoAdShijihaoHModel kaijianghao = new KaiJiHaoAdShijihaoHModel() { BallCount = item.BallCount, BlueBall = item.BlueBall, daxiao = item.daxiao, Details = item.Details, HasLotteryZS = item.HasLotteryZS, hezhi = item.hezhi, ID = item.ID, jio = item.jio, LotteryName = item.LotteryName, LotteryText = item.LotteryText, LotteryType = item.LotteryType, MenuName = item.MenuName, NextOpenTime = item.NextOpenTime, OpenTime = item.OpenTime, RedBall = item.RedBall, RuleId = item.RuleId, Term = item.Term, yuce = item.yuce, ZhongZhi = item.ZhongZhi, KJTime = item.KJTime }; KaiJiHaoAdShijihaoHModel shijihao = new KaiJiHaoAdShijihaoHModel(); List detaillist = new List(); if (!string.IsNullOrEmpty(item.ShiJiHao)) { var ary = Array.ConvertAll(item.ShiJiHao.Split(',').ToArray(), s => int.Parse(s)); var item2 = KJBLL.GetLotteryData(lotterytype, int.Parse(item.Term.ToString()), DateTime.Parse(item.OpenTime), item.ID, ary, null, "", item.KaiJiHao == null ? "" : item.KaiJiHao == null ? "" : item.KaiJiHao, item.ShiJiHao); shijihao = new KaiJiHaoAdShijihaoHModel() { BallCount = item2.BallCount, BlueBall = item2.BlueBall, // daxiao = item2.daxiao, //Details = item2.Details, HasLotteryZS = item2.HasLotteryZS, //hezhi = item2.hezhi, ID = item2.ID, // jio = item2.jio, LotteryName = item2.LotteryName, LotteryText = item2.LotteryText, LotteryType = item2.LotteryType, MenuName = item2.MenuName, NextOpenTime = item2.NextOpenTime, OpenTime = item2.OpenTime, RedBall = item2.RedBall, RuleId = item2.RuleId, Term = item2.Term, // yuce = item2.yuce, ZhongZhi = 14 }; var detials = item2.Details; foreach (var itemdetials in detials) { if (itemdetials.Label == "大小比") { shijihao.daxiao = itemdetials.Value; } else if (itemdetials.Label == "奇偶比") { shijihao.jio = itemdetials.Value; } else if (itemdetials.Label == "和值") { shijihao.hezhi = itemdetials.Value; } else { LotteryViewModel.LotteryDetail tmpd = new LotteryViewModel.LotteryDetail() { Label = itemdetials.Label, Value = itemdetials.Value }; detaillist.Add(tmpd); } } shijihao.Details = detaillist; } detaillist = new List(); list.Add(new LotteryKaiJiHaoAdShijihaoHModel() { Kaijianghao = kaijianghao, Shijihao = shijihao }); } return list; } catch (Exception ee) { LogHelper.Error(typeof(KJApiBLL), ee.Message + "GetLotteryListShiJiHao"); return null; } } /// /// 彩票类型集合 /// /// public static List TypeList() { try { List list = new List(); list = LotteryCache.GetLotteryType(); return list; } catch (Exception ee) { LogHelper.Error(typeof(KJApiBLL), ee.Message + ":TypeList"); return null; } } /// /// 彩种集合(包括倒计时、推荐链接) /// /// 筛选彩种 /// 得到筛选彩种集合 public static List GetLotteryAdTJ(List types) { try { List list = new List(); var data = LotteryCache.GetLotteryListAdKjTimeCache(); list = data.Where(w => types.Contains(w.LotteryType)).ToList(); //添加走势图 var datadetails = DataItemDetailCache.GetDataItemModelDetailCache(); for (int i = 0; i < list.Count; i++) { string type = list[i].LotteryType; EnumZXCid typezs; if (Enum.TryParse(type, out typezs)) { if (list[i].MenuName == "qgc") { var tools = TrendChastApiBLL.GetTrendChartChache( (int)typezs,(int)EnumZXTid.工具); var zoushis = TrendChastApiBLL.GetTrendChartChache((int)typezs, (int)EnumZXTid.走势图); zoushis.AddRange(tools); List trs = new List(); foreach (var item in zoushis) { if ( !string.IsNullOrEmpty(item.Url) && (!item.Name.Contains("手机"))) { TrendChartIem tmp = new TrendChartIem() { Text = item.Name, UrlStr = item.Url, }; trs.Add(tmp); } } list[i].Charts = trs; } else { var zoushis = TrendChastApiBLL.GetTrendChartChache((int)typezs, (int)EnumZXTid.走势图); List trs = new List(); foreach (var item in zoushis) { if (!string.IsNullOrEmpty(item.Url)&&(!item.Name.Contains("手机"))) { TrendChartIem tmp = new TrendChartIem() { Text = item.Name, UrlStr = item.Url, }; trs.Add(tmp); } } list[i].Charts = trs; } } //添加sortcode if (ZSlotterType.TypeOfNameDict.Keys.Contains(list[i].LotteryType)) { var sort=datadetails.SingleOrDefault(w => w.ItemValue == ZSlotterType.TypeOfNameDict[list[i].LotteryType]); if (sort != null) { list[i].SortCode = sort.SortCode.Value; } } } //foreach (string type in types) //{ // LotteryData temp = new LotteryData(); // temp = data.Find(d => d.LotteryType == type); // list.Add(temp); //} return list.OrderBy(d=>d.SortCode).ToList(); } catch (Exception ee) { LogHelper.Error(typeof(KJApiBLL), "GetLotteryAdTJ" + ee.Message); return null; } } /// /// 某个彩种(包括倒计时、推荐链接)详情 /// /// 筛选彩种code /// 得到筛选彩种的详情 public static LotteryData GetLotteryAdTJ(string type) { try { //LotteryData model = new LotteryData(); //var data = LotteryCache.GetLotteryListAdKjTimeCache().ToList(); //model = data.FirstOrDefault(d => d.LotteryType == type); //return model; return LotteryCache.GetLotteryListAdKjTimeCache(type); } catch (Exception ee) { LogHelper.Error(typeof(KJApiBLL), ee.Message + ":GetLotteryAdTJ(string type)"); return null; } } /// /// header数据组装 /// /// public static List getHeaderNav() { List data = new List(); try { var list = TypeList(); //全国彩 //var qgc = list.Where(d => d.MenuName == "qgc") // .Select(d => new LotteryItems(d.Name, "qgc", d.TypeCode, d.ZSTypeCode)) // .ToList(); ////地方彩 //var dfc = list.Where(d => d.MenuName == "dfc") // .Select(d => new LotteryItems(d.Name, "dfc", d.TypeCode, d.ZSTypeCode)) // .ToList(); ////11x5 //var l11x5 = list.Where(d => d.MenuName == "c11x5") // .Select(d => new LotteryItems(d.Name, "gpc", d.TypeCode, d.ZSTypeCode)) // .ToList(); ////k3 //var lk3 = list.Where(d => d.MenuName == "k3") // .Select(d => new LotteryItems(d.Name, "gpc", d.TypeCode, d.ZSTypeCode)) // .ToList(); ////kl12 //var lKL12 = list.Where(d => d.MenuName == "kl12") // .Select(d => new LotteryItems(d.Name, "gpc", d.TypeCode, d.ZSTypeCode)) // .ToList(); ////klsf //var lKLSF = list.Where(d => d.MenuName == "klsf") // .Select(d => new LotteryItems(d.Name, "gpc", d.TypeCode, d.ZSTypeCode)) // .ToList(); ////时时彩 //var ssc = list.Where(d => d.MenuName == "ssc") // .Select(d => new LotteryItems(d.Name, "gpc", d.TypeCode, d.ZSTypeCode)) // .ToList(); //其他彩 //var qtc = list.Where(d => d.MenuName == "qt") // .Select(d => new LotteryItems(d.Name, "gpc", d.TypeCode, d.ZSTypeCode)) // .ToList(); List qgcc = new List(); List dfcc = new List(); List qtcc = new List(); List sscc = new List(); List lKLSFc = new List(); List lKL12c = new List(); List lk3c = new List(); List l11x5c = new List(); if (list!=null) { foreach (var item in list) { if (item.MenuName== "qgc") { LotteryItems tmp = new LotteryItems(item.Name, "qgc", item.TypeCode, item.ZSTypeCode); qgcc.Add(tmp); } if (item.MenuName == "dfc") { LotteryItems tmp = new LotteryItems(item.Name, "dfc", item.TypeCode, item.ZSTypeCode); dfcc.Add(tmp); } if (item.MenuName == "c11x5") { LotteryItems tmp = new LotteryItems(item.Name, "gpc", item.TypeCode, item.ZSTypeCode); l11x5c.Add(tmp); } if (item.MenuName == "k3") { LotteryItems tmp = new LotteryItems(item.Name, "gpc", item.TypeCode, item.ZSTypeCode); lk3c.Add(tmp); } if (item.MenuName == "kl12") { LotteryItems tmp = new LotteryItems(item.Name, "gpc", item.TypeCode, item.ZSTypeCode); lKL12c.Add(tmp); } if (item.MenuName == "klsf") { LotteryItems tmp = new LotteryItems(item.Name, "gpc", item.TypeCode, item.ZSTypeCode); lKLSFc.Add(tmp); } if (item.MenuName == "ssc") { LotteryItems tmp = new LotteryItems(item.Name, "gpc", item.TypeCode, item.ZSTypeCode); sscc.Add(tmp); } if (item.MenuName == "qt") { LotteryItems tmp = new LotteryItems(item.Name, "gpc", item.TypeCode, item.ZSTypeCode); qtcc.Add(tmp); } } } data.Add(new ViewLotteryType("全国彩", "QGC", qgcc)); data.Add(new ViewLotteryType("地方彩", "DFC", dfcc)); data.Add(new ViewLotteryType("11选5", "GPC11X5", l11x5c)); data.Add(new ViewLotteryType("快3", "GPCK3", lk3c)); data.Add(new ViewLotteryType("快乐十二", "GPCKL12", lKL12c)); data.Add(new ViewLotteryType("快乐十分", "GPCKLSF", lKLSFc)); data.Add(new ViewLotteryType("时时彩", "GPCSSC", sscc)); data.Add(new ViewLotteryType("其他彩种", "GPCQTC", qtcc)); } catch (Exception ee) { LogHelper.Error(typeof(KJApiBLL), ee.Message + ":getHeaderNav"); } return data; } /// /// 获取页面TDK /// /// /// public static TDKModel GetTDK(string TDKType) { try { var query = TDKDataCache.GetTDKId(TDKType); if (query != null) { TDKModel tdk = new TDKModel(); tdk.Description = query.Description; tdk.Keywords = query.Keywords; tdk.Title = query.Title; tdk.Tags = query.Tags; return tdk; } return null; } catch (Exception e) { LogHelper.Error(typeof(KJApiBLL), "GetTDK" + e.Message); return null; } } } }