MerchantAmountSummary.cs 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 DataTable GetTradeListByDate(int MerchantId, string TradeMonth, int PageNum, int PageSize)
  63. {
  64. int skipNum = 0;
  65. if (PageNum > 1)
  66. {
  67. skipNum = PageSize * (PageNum - 1);
  68. }
  69. DataTable dt = CustomerSqlConn.dtable("select TradeDate,sum(if(PayMode=1, TradeAmount, 0)),sum(if(PayMode=2, TradeAmount, 0)),sum(TradeAmount),sum(QueryCount) from MerchantAmountSummay where MerchantId=1 and TradeMonth='" + TradeMonth + "' group by TradeDate order by TradeDate desc limit " + skipNum + "," + PageSize, AppConfig.Base.SqlConnStr);
  70. return dt;
  71. }
  72. public DataTable GetTradeListByMonth(int MerchantId, int PageNum, int PageSize)
  73. {
  74. int skipNum = 0;
  75. if (PageNum > 1)
  76. {
  77. skipNum = PageSize * (PageNum - 1);
  78. }
  79. DataTable dt = CustomerSqlConn.dtable("select TradeMonth,sum(if(PayMode=1, TradeAmount, 0)),sum(if(PayMode=2, TradeAmount, 0)),sum(TradeAmount),sum(QueryCount) from MerchantAmountSummay where MerchantId=1 group by TradeMonth order by TradeMonth desc limit " + skipNum + "," + PageSize, AppConfig.Base.SqlConnStr);
  80. return dt;
  81. }
  82. }
  83. }