UsersDbconn.cs 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. WebCMSEntities db = new WebCMSEntities();
  15. Users order = db.Users.FirstOrDefault(m => m.Id == Id);
  16. if (order != null)
  17. {
  18. }
  19. db.Dispose();
  20. return order;
  21. }
  22. //个人新增创客
  23. public int GetNewUserCount(int UserId, string TradeMonthOrDate = "")
  24. {
  25. int count = 0;
  26. WebCMSEntities db = new WebCMSEntities();
  27. if(string.IsNullOrEmpty(TradeMonthOrDate))
  28. {
  29. bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.SeoTitle == "self");
  30. if (check)
  31. {
  32. count = db.PullnewSummary.Where(m => m.UserId == UserId && m.SeoTitle == "self").Sum(m => m.RecUserAuthNum);
  33. }
  34. }
  35. else
  36. {
  37. if(TradeMonthOrDate.Length == 8)
  38. {
  39. bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.StatDate == TradeMonthOrDate && m.SeoTitle == "self");
  40. if (check)
  41. {
  42. count = db.PullnewSummary.Where(m => m.UserId == UserId && m.StatDate == TradeMonthOrDate && m.SeoTitle == "self").Sum(m => m.RecUserAuthNum);
  43. }
  44. }
  45. else
  46. {
  47. bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.StatMonth == TradeMonthOrDate && m.SeoTitle == "self");
  48. if (check)
  49. {
  50. count = db.PullnewSummary.Where(m => m.UserId == UserId && m.StatMonth == TradeMonthOrDate && m.SeoTitle == "self").Sum(m => m.RecUserAuthNum);
  51. }
  52. }
  53. }
  54. db.Dispose();
  55. return count;
  56. }
  57. //团队新增创客
  58. public int GetTeamNewUserCount(int UserId, string TradeMonthOrDate = "")
  59. {
  60. int count = 0;
  61. WebCMSEntities db = new WebCMSEntities();
  62. if(string.IsNullOrEmpty(TradeMonthOrDate))
  63. {
  64. bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.SeoTitle == "team");
  65. if (check)
  66. {
  67. count = db.PullnewSummary.Where(m => m.UserId == UserId && m.SeoTitle == "team").Sum(m => m.RecUserAuthNum);
  68. }
  69. }
  70. else
  71. {
  72. if(TradeMonthOrDate.Length == 8)
  73. {
  74. bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.StatDate == TradeMonthOrDate && m.SeoTitle == "team");
  75. if (check)
  76. {
  77. count = db.PullnewSummary.Where(m => m.UserId == UserId && m.StatDate == TradeMonthOrDate && m.SeoTitle == "team").Sum(m => m.RecUserAuthNum);
  78. }
  79. }
  80. else
  81. {
  82. bool check = db.PullnewSummary.Any(m => m.UserId == UserId && m.StatMonth == TradeMonthOrDate && m.SeoTitle == "team");
  83. if (check)
  84. {
  85. count = db.PullnewSummary.Where(m => m.UserId == UserId && m.StatMonth == TradeMonthOrDate && m.SeoTitle == "team").Sum(m => m.RecUserAuthNum);
  86. }
  87. }
  88. }
  89. db.Dispose();
  90. return count;
  91. }
  92. #endregion
  93. }
  94. }