MerchantAmountSummary.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using System.Collections.Generic;
  3. using Library;
  4. using System.Linq;
  5. using System.Data;
  6. using MySystem.MainModels;
  7. namespace MySystem
  8. {
  9. public class MerchantAmountSummary
  10. {
  11. public readonly static MerchantAmountSummary Instance = new MerchantAmountSummary();
  12. public MerchantAmountSummary()
  13. { }
  14. public decimal GetTrade(int MerchantId)
  15. {
  16. decimal amt = 0;
  17. WebCMSEntities db = new WebCMSEntities();
  18. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId);
  19. if (check)
  20. {
  21. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId).Sum(m => m.TradeAmount);
  22. }
  23. db.Dispose();
  24. return amt;
  25. }
  26. public decimal GetTradeByMonth(int MerchantId, string TradeMonth)
  27. {
  28. decimal amt = 0;
  29. WebCMSEntities db = new WebCMSEntities();
  30. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.TradeMonth == TradeMonth);
  31. if (check)
  32. {
  33. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.TradeMonth == TradeMonth).Sum(m => m.TradeAmount);
  34. }
  35. db.Dispose();
  36. return amt;
  37. }
  38. public decimal GetTradeByDate(int MerchantId, string TradeDate)
  39. {
  40. decimal amt = 0;
  41. WebCMSEntities db = new WebCMSEntities();
  42. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.TradeDate == TradeDate);
  43. if (check)
  44. {
  45. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.TradeDate == TradeDate).Sum(m => m.TradeAmount);
  46. }
  47. db.Dispose();
  48. return amt;
  49. }
  50. public decimal GetTradeByMode(int MerchantId, int PayMode, string TradeDate)
  51. {
  52. decimal amt = 0;
  53. WebCMSEntities db = new WebCMSEntities();
  54. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeDate == TradeDate);
  55. if (check)
  56. {
  57. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeDate == TradeDate).Sum(m => m.TradeAmount);
  58. }
  59. db.Dispose();
  60. return amt;
  61. }
  62. public decimal GetActualTradeByDate(int MerchantId, string TradeDate)
  63. {
  64. decimal amt = 0;
  65. WebCMSEntities db = new WebCMSEntities();
  66. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.TradeDate == TradeDate);
  67. if (check)
  68. {
  69. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.TradeDate == TradeDate).Sum(m => m.TotalActual);
  70. }
  71. db.Dispose();
  72. return amt;
  73. }
  74. public decimal GetActualTradeByMode(int MerchantId, int PayMode, string TradeDate)
  75. {
  76. decimal amt = 0;
  77. WebCMSEntities db = new WebCMSEntities();
  78. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeDate == TradeDate);
  79. if (check)
  80. {
  81. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeDate == TradeDate).Sum(m => m.TotalActual);
  82. }
  83. db.Dispose();
  84. return amt;
  85. }
  86. public DataTable GetTradeListByDate(int MerchantId, string TradeMonth, int PageNum, int PageSize)
  87. {
  88. int skipNum = 0;
  89. if (PageNum > 1)
  90. {
  91. skipNum = PageSize * (PageNum - 1);
  92. }
  93. DataTable dt = CustomerSqlConn.dtable("select TradeDate,sum(if(PayMode=1, TotalActual, 0)),sum(if(PayMode=2, TotalActual, 0)),sum(TotalActual),sum(TradeCount),sum(TradeAmount) from MerchantAmountSummay where MerchantId=" + MerchantId + " and TradeMonth='" + TradeMonth + "' group by TradeDate order by TradeDate desc limit " + skipNum + "," + PageSize, AppConfig.Base.SqlConnStr);
  94. return dt;
  95. }
  96. public DataTable GetTradeListByMonth(int MerchantId, int PageNum, int PageSize)
  97. {
  98. int skipNum = 0;
  99. if (PageNum > 1)
  100. {
  101. skipNum = PageSize * (PageNum - 1);
  102. }
  103. DataTable dt = CustomerSqlConn.dtable("select TradeMonth,sum(if(PayMode=1, TotalActual, 0)),sum(if(PayMode=2, TotalActual, 0)),sum(TotalActual),sum(TradeCount),sum(TradeAmount) from MerchantAmountSummay where MerchantId=" + MerchantId + " group by TradeMonth order by TradeMonth desc limit " + skipNum + "," + PageSize, AppConfig.Base.SqlConnStr);
  104. return dt;
  105. }
  106. }
  107. }