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