1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- 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 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, TradeAmount, 0)),sum(if(PayMode=2, TradeAmount, 0)),sum(TradeAmount),sum(QueryCount) from MerchantAmountSummay where MerchantId=1 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, TradeAmount, 0)),sum(if(PayMode=2, TradeAmount, 0)),sum(TradeAmount),sum(QueryCount) from MerchantAmountSummay where MerchantId=1 group by TradeMonth order by TradeMonth desc limit " + skipNum + "," + PageSize, AppConfig.Base.SqlConnStr);
- return dt;
- }
- }
- }
|