MerchantTradeStat.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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 MerchantTradeStat
  9. {
  10. public readonly static MerchantTradeStat Instance = new MerchantTradeStat();
  11. public MerchantTradeStat()
  12. { }
  13. public decimal Amount(int MerchantId, string DateOrMonth)
  14. {
  15. decimal amt = 0;
  16. WebCMSEntities db = new WebCMSEntities();
  17. if(DateOrMonth.Length == 8)
  18. {
  19. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.TradeDate == DateOrMonth);
  20. if (check)
  21. {
  22. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.TradeDate == DateOrMonth).Sum(m => m.TradeAmount);
  23. }
  24. }
  25. else
  26. {
  27. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.TradeMonth == DateOrMonth);
  28. if (check)
  29. {
  30. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.TradeMonth == DateOrMonth).Sum(m => m.TradeAmount);
  31. }
  32. }
  33. db.Dispose();
  34. return amt;
  35. }
  36. public int Count(int MerchantId, string DateOrMonth)
  37. {
  38. int amt = 0;
  39. WebCMSEntities db = new WebCMSEntities();
  40. if(DateOrMonth.Length == 8)
  41. {
  42. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.TradeDate == DateOrMonth);
  43. if (check)
  44. {
  45. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.TradeDate == DateOrMonth).Sum(m => m.TradeCount);
  46. }
  47. }
  48. else
  49. {
  50. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.TradeMonth == DateOrMonth);
  51. if (check)
  52. {
  53. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.TradeMonth == DateOrMonth).Sum(m => m.TradeCount);
  54. }
  55. }
  56. db.Dispose();
  57. return amt;
  58. }
  59. public decimal Amount(int MerchantId, string DateOrMonth, int PayMode)
  60. {
  61. decimal amt = 0;
  62. WebCMSEntities db = new WebCMSEntities();
  63. if(DateOrMonth.Length == 8)
  64. {
  65. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeDate == DateOrMonth);
  66. if (check)
  67. {
  68. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeDate == DateOrMonth).Sum(m => m.TradeAmount);
  69. }
  70. }
  71. else
  72. {
  73. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeMonth == DateOrMonth);
  74. if (check)
  75. {
  76. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeMonth == DateOrMonth).Sum(m => m.TradeAmount);
  77. }
  78. }
  79. db.Dispose();
  80. return amt;
  81. }
  82. public int Count(int MerchantId, string DateOrMonth, int PayMode)
  83. {
  84. int amt = 0;
  85. WebCMSEntities db = new WebCMSEntities();
  86. if(DateOrMonth.Length == 8)
  87. {
  88. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeDate == DateOrMonth);
  89. if (check)
  90. {
  91. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeDate == DateOrMonth).Sum(m => m.TradeCount);
  92. }
  93. }
  94. else
  95. {
  96. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeMonth == DateOrMonth);
  97. if (check)
  98. {
  99. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeMonth == DateOrMonth).Sum(m => m.TradeCount);
  100. }
  101. }
  102. db.Dispose();
  103. return amt;
  104. }
  105. public decimal Amount(int MerchantId, string DateOrMonth, int PayMode, int IsAct)
  106. {
  107. decimal amt = 0;
  108. WebCMSEntities db = new WebCMSEntities();
  109. if(DateOrMonth.Length == 8)
  110. {
  111. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeDate == DateOrMonth);
  112. if (check)
  113. {
  114. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeDate == DateOrMonth).Sum(m => m.TradeAmount);
  115. }
  116. }
  117. else
  118. {
  119. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeMonth == DateOrMonth);
  120. if (check)
  121. {
  122. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeMonth == DateOrMonth).Sum(m => m.TradeAmount);
  123. }
  124. }
  125. db.Dispose();
  126. return amt;
  127. }
  128. public int Count(int MerchantId, string DateOrMonth, int PayMode, int IsAct)
  129. {
  130. int amt = 0;
  131. WebCMSEntities db = new WebCMSEntities();
  132. if(DateOrMonth.Length == 8)
  133. {
  134. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeDate == DateOrMonth);
  135. if (check)
  136. {
  137. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeDate == DateOrMonth).Sum(m => m.TradeCount);
  138. }
  139. }
  140. else
  141. {
  142. bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeMonth == DateOrMonth);
  143. if (check)
  144. {
  145. amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeMonth == DateOrMonth).Sum(m => m.TradeCount);
  146. }
  147. }
  148. db.Dispose();
  149. return amt;
  150. }
  151. }
  152. }