123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- using System;
- using System.Collections.Generic;
- using Library;
- using System.Linq;
- using System.Data;
- using MySystem.MainModels;
- namespace MySystem
- {
- public class MerchantAmountSummary
- {
- public readonly static MerchantAmountSummary Instance = new MerchantAmountSummary();
- public MerchantAmountSummary()
- { }
- public decimal GetTrade(int MerchantId)
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId);
- if (check)
- {
- amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId).Sum(m => m.TradeAmount);
- }
- db.Dispose();
- return amt;
- }
- public decimal GetTradeByMonth(int MerchantId, string TradeMonth)
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.TradeMonth == TradeMonth);
- if (check)
- {
- amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.TradeMonth == TradeMonth).Sum(m => m.TradeAmount);
- }
- db.Dispose();
- return amt;
- }
- public decimal GetTradeByDate(int MerchantId, string TradeDate)
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.TradeDate == TradeDate);
- if (check)
- {
- amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.TradeDate == TradeDate).Sum(m => m.TradeAmount);
- }
- db.Dispose();
- return amt;
- }
- public decimal GetTradeByMode(int MerchantId, int PayMode, string TradeDate)
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeDate == TradeDate);
- if (check)
- {
- amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeDate == TradeDate).Sum(m => m.TradeAmount);
- }
- db.Dispose();
- return amt;
- }
- public decimal GetActualTradeByDate(int MerchantId, string TradeDate)
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.TradeDate == TradeDate);
- if (check)
- {
- amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.TradeDate == TradeDate).Sum(m => m.TotalActual);
- }
- db.Dispose();
- return amt;
- }
- public decimal GetActualTradeByMode(int MerchantId, int PayMode, string TradeDate)
- {
- decimal amt = 0;
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.MerchantAmountSummay.Any(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeDate == TradeDate);
- if (check)
- {
- amt = db.MerchantAmountSummay.Where(m => m.MerchantId == MerchantId && m.PayMode == PayMode && m.TradeDate == TradeDate).Sum(m => m.TotalActual);
- }
- db.Dispose();
- return amt;
- }
- public DataTable GetTradeListByDate(int MerchantId, string TradeMonth, int PageNum, int PageSize)
- {
- int skipNum = 0;
- if (PageNum > 1)
- {
- skipNum = PageSize * (PageNum - 1);
- }
- DataTable dt = CustomerSqlConn.dtable("select TradeDate,sum(if(PayMode=1, TotalActual, 0)),sum(if(PayMode=2, TotalActual, 0)),sum(TotalActual),sum(TradeCount),sum(TradeAmount) from MerchantAmountSummay where MerchantId=" + MerchantId + " and TradeMonth='" + TradeMonth + "' group by TradeDate order by TradeDate desc limit " + skipNum + "," + PageSize, AppConfig.Base.SqlConnStr);
- return dt;
- }
- public DataTable GetTradeListByMonth(int MerchantId, int PageNum, int PageSize)
- {
- int skipNum = 0;
- if (PageNum > 1)
- {
- skipNum = PageSize * (PageNum - 1);
- }
- DataTable dt = CustomerSqlConn.dtable("select TradeMonth,sum(if(PayMode=1, TotalActual, 0)),sum(if(PayMode=2, TotalActual, 0)),sum(TotalActual),sum(TradeCount),sum(TradeAmount) from MerchantAmountSummay where MerchantId=" + MerchantId + " group by TradeMonth order by TradeMonth desc limit " + skipNum + "," + PageSize, AppConfig.Base.SqlConnStr);
- return dt;
- }
- }
- }
|