UserAmountSummary.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 UserAmountSummary
  9. {
  10. public readonly static UserAmountSummary Instance = new UserAmountSummary();
  11. public UserAmountSummary()
  12. { }
  13. public decimal GetTrade(int UserId, string kind = "self")
  14. {
  15. decimal amt = 0;
  16. WebCMSEntities db = new WebCMSEntities();
  17. bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.SeoTitle == kind);
  18. if (check)
  19. {
  20. if (kind == "self")
  21. {
  22. amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.SeoTitle == kind).Sum(m => m.TotalAmount);
  23. }
  24. else if (kind == "team")
  25. {
  26. amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.SeoTitle == kind).Sum(m => m.TotalAmount);
  27. }
  28. }
  29. db.Dispose();
  30. return amt;
  31. }
  32. public decimal GetTradeByMonth(int UserId, string TradeMonth, string kind = "self")
  33. {
  34. decimal amt = 0;
  35. WebCMSEntities db = new WebCMSEntities();
  36. bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeMonth == TradeMonth &&m.SeoTitle == kind);
  37. if (check)
  38. {
  39. if (kind == "self")
  40. {
  41. amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == TradeMonth &&m.SeoTitle == kind).Sum(m => m.TotalAmount);
  42. }
  43. else if (kind == "team")
  44. {
  45. amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == TradeMonth &&m.SeoTitle == kind).Sum(m => m.TotalAmount);
  46. }
  47. }
  48. db.Dispose();
  49. return amt;
  50. }
  51. public decimal GetTradeByDate(int UserId, string TradeDate, string kind = "self")
  52. {
  53. decimal amt = 0;
  54. WebCMSEntities db = new WebCMSEntities();
  55. bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeDate == TradeDate &&m.SeoTitle == kind);
  56. if (check)
  57. {
  58. if (kind == "self")
  59. {
  60. amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeDate == TradeDate &&m.SeoTitle == kind).Sum(m => m.TotalAmount);
  61. }
  62. else if (kind == "team")
  63. {
  64. amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeDate == TradeDate &&m.SeoTitle == kind).Sum(m => m.TotalAmount);
  65. }
  66. }
  67. db.Dispose();
  68. return amt;
  69. }
  70. }
  71. }