UserTradeDaySummaryDbconn.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 UserTradeDaySummaryDbconn
  9. {
  10. public readonly static UserTradeDaySummaryDbconn Instance = new UserTradeDaySummaryDbconn();
  11. public UserTradeDaySummaryDbconn()
  12. { }
  13. // TODO:读取很慢,感觉redis没生效
  14. #region 获取单个字段
  15. //个人业绩
  16. public decimal GetTrade(int UserId, string kind = "self")
  17. {
  18. decimal amt = 0;
  19. WebCMSEntities db = new WebCMSEntities();
  20. bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.SeoTitle == kind);
  21. if (check)
  22. {
  23. if (kind == "self")
  24. {
  25. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
  26. }
  27. else if (kind == "team")
  28. {
  29. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
  30. }
  31. }
  32. // RedisDbconn.Instance.Set(key, amt);
  33. db.Dispose();
  34. return amt;
  35. }
  36. public decimal GetDateTrade(int UserId, string TradeDate, string kind = "self")
  37. {
  38. decimal amt = 0;
  39. WebCMSEntities db = new WebCMSEntities();
  40. bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.TradeDate == TradeDate && m.SeoTitle == kind);
  41. if (check)
  42. {
  43. if (kind == "self")
  44. {
  45. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.TradeDate == TradeDate && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
  46. }
  47. else if (kind == "team")
  48. {
  49. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.TradeDate == TradeDate && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
  50. }
  51. }
  52. // RedisDbconn.Instance.Set(key, amt);
  53. db.Dispose();
  54. return amt;
  55. }
  56. public decimal GetMonthTrade(int UserId, string TradeMonth, string kind = "self")
  57. {
  58. decimal amt = 0;
  59. WebCMSEntities db = new WebCMSEntities();
  60. bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.SeoTitle == kind);
  61. if (check)
  62. {
  63. if (kind == "self")
  64. {
  65. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
  66. }
  67. else if (kind == "team")
  68. {
  69. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
  70. }
  71. }
  72. // RedisDbconn.Instance.Set(key, amt);
  73. db.Dispose();
  74. return amt;
  75. }
  76. public decimal GetDateTradeForBrand(int UserId, string TradeDate, int BrandId, string kind = "self")
  77. {
  78. decimal amt = 0;
  79. WebCMSEntities db = new WebCMSEntities();
  80. bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.BrandId == BrandId && m.TradeDate == TradeDate && m.
  81. SeoTitle == kind);
  82. if (check)
  83. {
  84. if (kind == "self")
  85. {
  86. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.BrandId == BrandId && m.TradeDate == TradeDate && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
  87. }
  88. else if (kind == "team")
  89. {
  90. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.BrandId == BrandId && m.TradeDate == TradeDate && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
  91. }
  92. }
  93. // RedisDbconn.Instance.Set(key, amt);
  94. db.Dispose();
  95. return amt;
  96. }
  97. public decimal GetMonthTradeForBrand(int UserId, string TradeMonth, int BrandId, string kind = "self")
  98. {
  99. decimal amt = 0;
  100. WebCMSEntities db = new WebCMSEntities();
  101. bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.BrandId == BrandId && m.TradeMonth == TradeMonth && m.SeoTitle == kind);
  102. if (check)
  103. {
  104. if (kind == "self")
  105. {
  106. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.BrandId == BrandId && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
  107. }
  108. else if (kind == "team")
  109. {
  110. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.BrandId == BrandId && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
  111. }
  112. }
  113. // RedisDbconn.Instance.Set(key, amt);
  114. db.Dispose();
  115. return amt;
  116. }
  117. public decimal GetDateTradeForCloud(int UserId, string TradeDate, int QrPayFlag, string kind = "self")
  118. {
  119. decimal amt = 0;
  120. WebCMSEntities db = new WebCMSEntities();
  121. bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.QueryCount == QrPayFlag && m.TradeDate == TradeDate && m.SeoTitle == kind);
  122. if (check)
  123. {
  124. if (kind == "self")
  125. {
  126. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.QueryCount == QrPayFlag && m.TradeDate == TradeDate && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
  127. }
  128. else if (kind == "team")
  129. {
  130. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.QueryCount == QrPayFlag && m.TradeDate == TradeDate && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
  131. }
  132. }
  133. // RedisDbconn.Instance.Set(key, amt);
  134. db.Dispose();
  135. return amt;
  136. }
  137. public decimal GetMonthTradeForCloud(int UserId, string TradeMonth, int QrPayFlag, string kind = "self")
  138. {
  139. decimal amt = 0;
  140. WebCMSEntities db = new WebCMSEntities();
  141. bool check = db.TradeDaySummary.Any(m => m.UserId == UserId && m.QueryCount == QrPayFlag && m.TradeMonth == TradeMonth && m.
  142. SeoTitle == kind);
  143. if (check)
  144. {
  145. if (kind == "self")
  146. {
  147. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.QueryCount == QrPayFlag && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.HelpDirectTradeAmt + m.HelpDirectDebitTradeAmt + m.NotHelpDirectTradeAmt + m.NotHelpDirectDebitTradeAmt + m.ProfitDirectTradeAmt + m.ProfitDirectDebitTradeAmt);
  148. }
  149. else if (kind == "team")
  150. {
  151. amt = db.TradeDaySummary.Where(m => m.UserId == UserId && m.QueryCount == QrPayFlag && m.TradeMonth == TradeMonth && m.SeoTitle == kind).Sum(m => m.HelpNonDirectTradeAmt + m.HelpNonDirectDebitTradeAmt + m.NotHelpNonDirectTradeAmt + m.NotHelpNonDirectDebitTradeAmt + m.ProfitNonDirectTradeAmt + m.ProfitNonDirectDebitTradeAmt);
  152. }
  153. }
  154. // RedisDbconn.Instance.Set(key, amt);
  155. db.Dispose();
  156. return amt;
  157. }
  158. #endregion
  159. }
  160. }