123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- 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;
- }
- }
- }
|