MpStatDbconn.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using Library;
  4. using System.Data;
  5. using MySystem.MainModels;
  6. namespace MySystem
  7. {
  8. public class MpStatDbconn
  9. {
  10. public readonly static MpStatDbconn Instance = new MpStatDbconn();
  11. public MpStatDbconn()
  12. { }
  13. #region 统计交易额
  14. public decimal GetTrade(int UserId, string TradeDateOrMonth, int IsAct, string kind = "self")
  15. {
  16. string timeField = TradeDateOrMonth.Length == 8 ? "TradeDate" : "TradeMonth";
  17. DataTable dt = CustomerSqlConn.dtable("select sum(TotalAmount) from UserAmountSummary where UserId=" + UserId + " and " + timeField + "='" + TradeDateOrMonth + "' and IsAct=" + IsAct + " and SeoTitle='" + kind + "'", AppConfig.Base.MpSqlConn);
  18. if (dt.Rows.Count > 0)
  19. {
  20. return decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
  21. }
  22. return 0M;
  23. }
  24. public decimal GetTrade(int UserId, int IsAct, string kind = "self")
  25. {
  26. DataTable dt = CustomerSqlConn.dtable("select sum(TotalAmount) from UserAmountSummary where UserId=" + UserId + " and IsAct=" + IsAct + " and SeoTitle='" + kind + "'", AppConfig.Base.MpSqlConn);
  27. if(dt.Rows.Count > 0)
  28. {
  29. return decimal.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
  30. }
  31. return 0M;
  32. }
  33. #endregion
  34. #region 统计激活数
  35. public int GetActCountByDate(int UserId, string TradeDateOrMonth, string kind = "self")
  36. {
  37. string timeField = TradeDateOrMonth.Length == 8 ? "SeoKeyword" : "TradeMonth";
  38. DataTable dt = CustomerSqlConn.dtable("select sum(ActiveBuddyMerStatus) from UserTradeMonthSummary where UserId=" + UserId + " and " + timeField + "='" + TradeDateOrMonth + "' and SeoTitle='" + kind + "'", AppConfig.Base.MpSqlConn);
  39. if (dt.Rows.Count > 0)
  40. {
  41. return int.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
  42. }
  43. return 0;
  44. }
  45. public int GetActCount(int UserId, string kind = "self")
  46. {
  47. DataTable dt = CustomerSqlConn.dtable("select sum(ActiveBuddyMerStatus) from UserTradeMonthSummary where UserId=" + UserId + " and SeoTitle='" + kind + "'", AppConfig.Base.MpSqlConn);
  48. if(dt.Rows.Count > 0)
  49. {
  50. return int.Parse(function.CheckNum(dt.Rows[0][0].ToString()));
  51. }
  52. return 0;
  53. }
  54. #endregion
  55. }
  56. }