ZSapiBLL.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using Business.TK;
  2. using Common;
  3. using M55128_rec.Business.TK;
  4. using M55128_rec.Models.ViewModels.TrendChartModel;
  5. using Models;
  6. using Models.Entity.LottomatBaseDB;
  7. using Models.Views;
  8. using Services;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Web;
  13. namespace M55128_rec.Business.ZS
  14. {
  15. public static class ZSapiBLL
  16. {
  17. static ZSapiBLL()
  18. {
  19. }
  20. /// <summary>
  21. /// 走势图名称,值为"QGC", "DFC", "GPC11X5", "GPCK3", "GPCKL12", "GPCKLSF" , "GPCQTC",注意:高频彩请传(GPC),高频彩下面的分类请传对应代码
  22. /// </summary>
  23. /// <param name="lotteryType"> //如果传入为 GPC 的话,就默认返回高频彩11选5相关数据</param>
  24. public static List<TrendChart_Preview> GetTrendChartNewsList(string lotteryType)
  25. {
  26. if (lotteryType== "GPC")
  27. {
  28. lotteryType = "GPC11X5";
  29. }
  30. List<TrendChart_Preview> res = new List<TrendChart_Preview>();
  31. try
  32. {
  33. //如果传入为 GPC 的话,就默认返回高频彩11选5相关数据
  34. List<DataItemModel> data = DataItemBLL.GetDataItemListbyEnCode(lotteryType);
  35. //dataItemCache.GetDataItemList(arg.Category.Equals("GPC") ? "GPC11X5" : arg.Category).OrderBy(n => n.SortCode).ToList();
  36. string[] ids = data.Select(d => d.ItemDetailId).ToArray();
  37. List<EExpression> listexp = new List<EExpression>();
  38. listexp.Add(new EExpression("IsDelete", "=", 0));
  39. listexp.Add(new EExpression("IsStick", "=", 1));
  40. listexp.Add(new EExpression("CategoryId", EnumExpression.In, ids.ToList()));
  41. //获取该分类下符合要求的数据
  42. List<Base_TrendChart> trendChartEntities = TrendChartBLL.GetList("SortCode", listexp);
  43. //TrendChartBll.GetPageList(n => n.IsDelete == false && n.IsStick == true && ids.Contains(n.CategoryId)).OrderBy(n => n.SortCode).ToList();
  44. if (trendChartEntities.Count > 0)
  45. {
  46. //组装父级相关属性
  47. TrendChart_Preview previewItem = new TrendChart_Preview
  48. {
  49. TrendChartType = lotteryType,
  50. ItemName = DataItemBLL.GetBaseDataItemListbyEnCode(lotteryType).ItemName
  51. };
  52. //根据分类ID进行分组
  53. List<string> idlist = trendChartEntities.Select(w => w.CategoryId).ToList();
  54. IEnumerable<IGrouping<string, Base_TrendChart>> group = trendChartEntities.GroupBy(t => t.CategoryId);
  55. List<Base_DataItemDetail> dataItemlist = DataItemBLL.GetListbyItemId(idlist);
  56. List<TempTrendChartPreviewItem> temp = new List<TempTrendChartPreviewItem>();
  57. foreach (IGrouping<string, Base_TrendChart> chartEntities in group)
  58. {
  59. //分类ID
  60. string key = chartEntities.Key;
  61. //获取分类信息
  62. var dataItemEntity = dataItemlist.SingleOrDefault(w => w.ItemDetailId == key);
  63. List<TrendChartPreviewItem> trendChartPreviewItems = new List<TrendChartPreviewItem>();
  64. //组装项目相关属性
  65. TempTrendChartPreviewItem item = new TempTrendChartPreviewItem
  66. {
  67. TrendChartChildType = dataItemEntity.ItemValue,
  68. TrendChartChildName = dataItemEntity.ItemName
  69. };
  70. //组装具体信息
  71. foreach (Base_TrendChart entity in chartEntities)
  72. {
  73. TrendChartPreviewItem p = new TrendChartPreviewItem
  74. {
  75. Title = entity.Title,
  76. TrendChartUrl = entity.TrendChartUrl,
  77. TrendChartUrlId=entity.PK.ToString()
  78. };
  79. trendChartPreviewItems.Add(p);
  80. }
  81. item.TrendChartPreviewItem = trendChartPreviewItems;
  82. temp.Add(item);
  83. }
  84. previewItem.TrendChartPreviewItems = temp;
  85. res.Add(previewItem);
  86. }
  87. }
  88. catch (Exception ee)
  89. {
  90. LogHelper.Error(typeof(ZSapiBLL), ee.Message + "GetTrendChartNewsList");
  91. }
  92. return res;
  93. }
  94. }
  95. }