UsersDbconn.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections.Generic;
  3. using Library;
  4. using System.Linq;
  5. using MySystem.MainModels;
  6. namespace MySystem
  7. {
  8. public class UsersDbconn
  9. {
  10. public readonly static UsersDbconn Instance = new UsersDbconn();
  11. #region 获取单个字段
  12. public Users Get(int Id)
  13. {
  14. // string key = "Users:" + Id;
  15. // if (RedisDbconn.Instance.Exists(key))
  16. // {
  17. // Users obj = RedisDbconn.Instance.Get<Users>(key);
  18. // if (obj != null)
  19. // {
  20. // return obj;
  21. // }
  22. // }
  23. WebCMSEntities db = new WebCMSEntities();
  24. Users order = db.Users.FirstOrDefault(m => m.Id == Id);
  25. if (order != null)
  26. {
  27. // RedisDbconn.Instance.Set(key, order);
  28. // RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(1800, 5400));
  29. }
  30. db.Dispose();
  31. return order;
  32. }
  33. //个人新增创客
  34. public int GetNewUserCount(int UserId, string TradeMonthOrDate = "")
  35. {
  36. int count = 0;
  37. WebCMSEntities db = new WebCMSEntities();
  38. if(string.IsNullOrEmpty(TradeMonthOrDate))
  39. {
  40. bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.SeoTitle == "self");
  41. if (check)
  42. {
  43. count = db.PullnewSummary.Where(m => m.UserId == UserId && m.SeoTitle == "self").Sum(m => m.RecUserAuthNum);
  44. }
  45. }
  46. else
  47. {
  48. if(TradeMonthOrDate.Length == 8)
  49. {
  50. bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.StatDate == TradeMonthOrDate && m.SeoTitle == "self");
  51. if (check)
  52. {
  53. count = db.PullnewSummary.Where(m => m.UserId == UserId && m.StatDate == TradeMonthOrDate && m.SeoTitle == "self").Sum(m => m.RecUserAuthNum);
  54. }
  55. }
  56. else
  57. {
  58. bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.StatMonth == TradeMonthOrDate && m.SeoTitle == "self");
  59. if (check)
  60. {
  61. count = db.PullnewSummary.Where(m => m.UserId == UserId && m.StatMonth == TradeMonthOrDate && m.SeoTitle == "self").Sum(m => m.RecUserAuthNum);
  62. }
  63. }
  64. }
  65. db.Dispose();
  66. return count;
  67. }
  68. //团队新增创客
  69. public int GetTeamNewUserCount(int UserId, string TradeMonthOrDate = "")
  70. {
  71. int count = 0;
  72. WebCMSEntities db = new WebCMSEntities();
  73. if(string.IsNullOrEmpty(TradeMonthOrDate))
  74. {
  75. bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.SeoTitle == "team");
  76. if (check)
  77. {
  78. count = db.PullnewSummary.Where(m => m.UserId == UserId && m.SeoTitle == "team").Sum(m => m.RecUserAuthNum);
  79. }
  80. }
  81. else
  82. {
  83. if(TradeMonthOrDate.Length == 8)
  84. {
  85. bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.StatDate == TradeMonthOrDate && m.SeoTitle == "team");
  86. if (check)
  87. {
  88. count = db.PullnewSummary.Where(m => m.UserId == UserId && m.StatDate == TradeMonthOrDate && m.SeoTitle == "team").Sum(m => m.RecUserAuthNum);
  89. }
  90. }
  91. else
  92. {
  93. bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.StatMonth == TradeMonthOrDate && m.SeoTitle == "team");
  94. if (check)
  95. {
  96. count = db.PullnewSummary.Where(m => m.UserId == UserId && m.StatMonth == TradeMonthOrDate && m.SeoTitle == "team").Sum(m => m.RecUserAuthNum);
  97. }
  98. }
  99. }
  100. db.Dispose();
  101. return count;
  102. }
  103. #endregion
  104. }
  105. }