using System; using System.Collections.Generic; using Library; using System.Linq; using MySystem.MainModels; namespace MySystem { public class UserTradeStat { public readonly static UserTradeStat Instance = new UserTradeStat(); public UserTradeStat() { } public decimal Amount(int UserId, string DateOrMonth, string kind = "self") { decimal amt = 0; WebCMSEntities db = new WebCMSEntities(); if(DateOrMonth.Length == 8) { bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeDate == DateOrMonth && m.SeoTitle == kind); if (check) { amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeDate == DateOrMonth && m.SeoTitle == kind).Sum(m => m.TotalAmount); } } else { bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeMonth == DateOrMonth && m.SeoTitle == kind); if (check) { amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == DateOrMonth && m.SeoTitle == kind).Sum(m => m.TotalAmount); } } db.Dispose(); return amt; } public int Count(int UserId, string DateOrMonth, string kind = "self") { int amt = 0; WebCMSEntities db = new WebCMSEntities(); if(DateOrMonth.Length == 8) { bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeDate == DateOrMonth && m.SeoTitle == kind); if (check) { amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeDate == DateOrMonth && m.SeoTitle == kind).Sum(m => m.TradeCount); } } else { bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeMonth == DateOrMonth && m.SeoTitle == kind); if (check) { amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == DateOrMonth && m.SeoTitle == kind).Sum(m => m.TradeCount); } } db.Dispose(); return amt; } public decimal Amount(int UserId, string DateOrMonth, int PayMode, string kind = "self") { decimal amt = 0; WebCMSEntities db = new WebCMSEntities(); if(DateOrMonth.Length == 8) { bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.PayMode == PayMode && m.TradeDate == DateOrMonth && m.SeoTitle == kind); if (check) { amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.PayMode == PayMode && m.TradeDate == DateOrMonth && m.SeoTitle == kind).Sum(m => m.TotalAmount); } } else { bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.PayMode == PayMode && m.TradeMonth == DateOrMonth && m.SeoTitle == kind); if (check) { amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.PayMode == PayMode && m.TradeMonth == DateOrMonth && m.SeoTitle == kind).Sum(m => m.TotalAmount); } } db.Dispose(); return amt; } public int Count(int UserId, string DateOrMonth, int PayMode, string kind = "self") { int amt = 0; WebCMSEntities db = new WebCMSEntities(); if(DateOrMonth.Length == 8) { bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.PayMode == PayMode && m.TradeDate == DateOrMonth && m.SeoTitle == kind); if (check) { amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.PayMode == PayMode && m.TradeDate == DateOrMonth && m.SeoTitle == kind).Sum(m => m.TradeCount); } } else { bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.PayMode == PayMode && m.TradeMonth == DateOrMonth && m.SeoTitle == kind); if (check) { amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.PayMode == PayMode && m.TradeMonth == DateOrMonth && m.SeoTitle == kind).Sum(m => m.TradeCount); } } db.Dispose(); return amt; } public decimal Amount(int UserId, string DateOrMonth, int PayMode, int IsAct, string kind = "self") { decimal amt = 0; WebCMSEntities db = new WebCMSEntities(); if(DateOrMonth.Length == 8) { bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeDate == DateOrMonth && m.SeoTitle == kind); if (check) { amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeDate == DateOrMonth && m.SeoTitle == kind).Sum(m => m.TotalAmount); } } else { bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeMonth == DateOrMonth && m.SeoTitle == kind); if (check) { amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeMonth == DateOrMonth && m.SeoTitle == kind).Sum(m => m.TotalAmount); } } db.Dispose(); return amt; } public int Count(int UserId, string DateOrMonth, int PayMode, int IsAct, string kind = "self") { int amt = 0; WebCMSEntities db = new WebCMSEntities(); if(DateOrMonth.Length == 8) { bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeDate == DateOrMonth && m.SeoTitle == kind); if (check) { amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeDate == DateOrMonth && m.SeoTitle == kind).Sum(m => m.TradeCount); } } else { bool check = db.UserAmountSummary.Any(m => m.UserId == UserId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeMonth == DateOrMonth && m.SeoTitle == kind); if (check) { amt = db.UserAmountSummary.Where(m => m.UserId == UserId && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeMonth == DateOrMonth && m.SeoTitle == kind).Sum(m => m.TradeCount); } } db.Dispose(); return amt; } } }