/*
* 交易日汇总
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using MySystem.Models.Main;
using Library;
using LitJson;
namespace MySystem.Service.Main
{
public class TradeDaySummaryService
{
static string _conn = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
///
/// 查询列表
///
/// 关联表
/// 查询条件(sql语句)
/// 总数(输出)
/// 页码
/// 每页条数
///
public static List> List(List relationData, string condition, out int count, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
{
List fields = new List(); //要显示的列
fields.Add("Id");
fields.Add("CreateDate"); //添加时间
fields.Add("Status"); //状态
fields.Add("UserId"); //创客
fields.Add("TradeDate"); //交易日
fields.Add("TradeMonth"); //交易月
fields.Add("NotHelpDirectTradeAmt"); //直营商户交易总额(非扶持期)
fields.Add("NotHelpNonDirectTradeAmt"); //非直营商户交易总额(非扶持期)
fields.Add("NotHelpDirectCreditTradeAmt"); //直营贷记卡交易总额(非扶持期)
fields.Add("NotHelpNonDirectCreditTradeAmt"); //非直营贷记卡交易总额(非扶持期)
fields.Add("NotHelpDirectQrCreditTradeAmt"); //直营云闪付贷记卡交易额(非扶持期)
fields.Add("NotHelpNonDirectQrCreditTradeAmt"); //非直营云闪付贷记卡交易额(非扶持期)
fields.Add("NotHelpDirectNonQrCreditTradeAmt"); //直营非云闪付贷记卡交易额(非扶持期)
fields.Add("NotHelpNonDirectNonQrCreditTradeAmt"); //非直营非云闪付贷记卡交易额(非扶持期)
fields.Add("NotHelpDirectDebitTradeAmt"); //直营商户借记卡交易总额(非扶持期)
fields.Add("NotHelpDirectDebitCapTradeAmt"); //直营商户借记卡封顶交易总金额(非扶持期)
fields.Add("NotHelpDirectDebitCapNum"); //直营商户借记卡封顶交易总数(非扶持期)
fields.Add("NotHelpNonDirectDebitTradeAmt"); //非直营商户借记卡交易总额(非扶持期)
fields.Add("NotHelpNonDirectDebitCapTradeAmt"); //非直营商户借记卡封顶交易总金额(非扶持期)
fields.Add("NotHelpNonDirectDebitCapNum"); //非直营商户借记卡封顶交易总数(非扶持期)
fields.Add("NotHelpDirectQrDebitTradeAmt"); //直营云闪付非封顶借记卡(非扶持期)
fields.Add("NotHelpNonDirectQrDebitTradeAmt"); //非直营云闪付非封顶借记卡(非扶持期)
fields.Add("NotHelpDirectNonQrDebitTradeAmt"); //直营非云闪付非封顶借记卡(非扶持期)
fields.Add("NotHelpNonDirectNonQrDebitTradeAmt"); //非直营非云闪付非封顶借记卡(非扶持期)
fields.Add("HelpDirectTradeAmt"); //直营商户交易总额(扶持期)
fields.Add("HelpNonDirectTradeAmt"); //非直营商户交易总额(扶持期)
fields.Add("HelpDirectCreditTradeAmt"); //直营贷记卡交易总额(扶持期)
fields.Add("HelpNonDirectCreditTradeAmt"); //非直营贷记卡交易总额(扶持期)
fields.Add("HelpDirectQrCreditTradeAmt"); //直营云闪付贷记卡交易额(扶持期)
fields.Add("HelpNonDirectQrCreditTradeAmt"); //非直营云闪付贷记卡交易额(扶持期)
fields.Add("HelpDirectNonQrCreditTradeAmt"); //直营非云闪付贷记卡交易额(扶持期)
fields.Add("HelpNonDirectNonQrCreditTradeAmt"); //非直营非云闪付贷记卡交易额(扶持期)
fields.Add("HelpDirectDebitTradeAmt"); //直营商户借记卡交易总额(扶持期)
fields.Add("HelpDirectDebitCapTradeAmt"); //直营商户借记卡封顶交易总金额(扶持期)
fields.Add("HelpDirectDebitCapNum"); //直营商户借记卡封顶交易总数(扶持期)
fields.Add("HelpNonDirectDebitTradeAmt"); //非直营商户借记卡交易总额(扶持期)
fields.Add("HelpNonDirectDebitCapTradeAmt"); //非直营商户借记卡封顶交易总金额(扶持期)
fields.Add("HelpNonDirectDebitCapNum"); //非直营商户借记卡封顶交易总数(扶持期)
fields.Add("HelpDirectQrDebitTradeAmt"); //直营云闪付非封顶借记卡(扶持期)
fields.Add("HelpNonDirectQrDebitTradeAmt"); //非直营云闪付非封顶借记卡(扶持期)
fields.Add("HelpDirectNonQrDebitTradeAmt"); //直营非云闪付非封顶借记卡(扶持期)
fields.Add("HelpNonDirectNonQrDebitTradeAmt"); //非直营非云闪付非封顶借记卡(扶持期)
fields.Add("VipFlag"); //会员标记
fields.Add("PayType"); //支付方式
fields.Add("ProfitDirectTradeAmt"); //直营商户交易总额(盈利期)
fields.Add("ProfitNonDirectTradeAmt"); //非直营商户交易总额(盈利期)
fields.Add("ProfitDirectCreditTradeAmt"); //直营贷记卡交易总额(盈利期)
fields.Add("ProfitNonDirectCreditTradeAmt"); //非直营贷记卡交易总额(盈利期)
fields.Add("ProfitDirectQrCreditTradeAmt"); //直营云闪付贷记卡交易额(盈利期)
fields.Add("ProfitNonDirectQrCreditTradeAmt"); //非直营云闪付贷记卡交易额(盈利期)
fields.Add("ProfitDirectNonQrCreditTradeAmt"); //直营非云闪付贷记卡交易额(盈利期)
fields.Add("ProfitNonDirectNonQrCreditTradeAmt"); //非直营非云闪付贷记卡交易额(盈利期)
fields.Add("ProfitDirectDebitTradeAmt"); //直营商户借记卡交易总额(盈利期)
fields.Add("ProfitDirectDebitCapTradeAmt"); //直营商户借记卡封顶交易总金额(盈利期)
fields.Add("ProfitDirectDebitCapNum"); //直营商户借记卡封顶交易总数(盈利期)
fields.Add("ProfitNonDirectDebitTradeAmt"); //非直营商户借记卡交易总额(盈利期)
fields.Add("ProfitNonDirectDebitCapTradeAmt"); //非直营商户借记卡封顶交易总金额(盈利期)
fields.Add("ProfitNonDirectDebitCapNum"); //非直营商户借记卡封顶交易总数(盈利期)
fields.Add("ProfitDirectQrDebitTradeAmt"); //直营云闪付非封顶借记卡(盈利期)
fields.Add("ProfitNonDirectQrDebitTradeAmt"); //非直营云闪付非封顶借记卡(盈利期)
fields.Add("ProfitDirectNonQrDebitTradeAmt"); //直营非云闪付非封顶借记卡(盈利期)
fields.Add("ProfitNonDirectNonQrDebitTradeAmt"); //非直营非云闪付非封顶借记卡(盈利期)
Dictionary obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("TradeDaySummary", relationData, orderBy, page, limit, condition, fields);
List> diclist = obj["data"] as List>;
count = int.Parse(obj["count"].ToString());
return diclist;
}
public static List> List(List relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
{
List fields = new List(); //要显示的列
fields.Add("Id");
fields.Add("CreateDate"); //添加时间
fields.Add("Status"); //状态
fields.Add("UserId"); //创客
fields.Add("TradeDate"); //交易日
fields.Add("TradeMonth"); //交易月
fields.Add("NotHelpDirectTradeAmt"); //直营商户交易总额(非扶持期)
fields.Add("NotHelpNonDirectTradeAmt"); //非直营商户交易总额(非扶持期)
fields.Add("NotHelpDirectCreditTradeAmt"); //直营贷记卡交易总额(非扶持期)
fields.Add("NotHelpNonDirectCreditTradeAmt"); //非直营贷记卡交易总额(非扶持期)
fields.Add("NotHelpDirectQrCreditTradeAmt"); //直营云闪付贷记卡交易额(非扶持期)
fields.Add("NotHelpNonDirectQrCreditTradeAmt"); //非直营云闪付贷记卡交易额(非扶持期)
fields.Add("NotHelpDirectNonQrCreditTradeAmt"); //直营非云闪付贷记卡交易额(非扶持期)
fields.Add("NotHelpNonDirectNonQrCreditTradeAmt"); //非直营非云闪付贷记卡交易额(非扶持期)
fields.Add("NotHelpDirectDebitTradeAmt"); //直营商户借记卡交易总额(非扶持期)
fields.Add("NotHelpDirectDebitCapTradeAmt"); //直营商户借记卡封顶交易总金额(非扶持期)
fields.Add("NotHelpDirectDebitCapNum"); //直营商户借记卡封顶交易总数(非扶持期)
fields.Add("NotHelpNonDirectDebitTradeAmt"); //非直营商户借记卡交易总额(非扶持期)
fields.Add("NotHelpNonDirectDebitCapTradeAmt"); //非直营商户借记卡封顶交易总金额(非扶持期)
fields.Add("NotHelpNonDirectDebitCapNum"); //非直营商户借记卡封顶交易总数(非扶持期)
fields.Add("NotHelpDirectQrDebitTradeAmt"); //直营云闪付非封顶借记卡(非扶持期)
fields.Add("NotHelpNonDirectQrDebitTradeAmt"); //非直营云闪付非封顶借记卡(非扶持期)
fields.Add("NotHelpDirectNonQrDebitTradeAmt"); //直营非云闪付非封顶借记卡(非扶持期)
fields.Add("NotHelpNonDirectNonQrDebitTradeAmt"); //非直营非云闪付非封顶借记卡(非扶持期)
fields.Add("HelpDirectTradeAmt"); //直营商户交易总额(扶持期)
fields.Add("HelpNonDirectTradeAmt"); //非直营商户交易总额(扶持期)
fields.Add("HelpDirectCreditTradeAmt"); //直营贷记卡交易总额(扶持期)
fields.Add("HelpNonDirectCreditTradeAmt"); //非直营贷记卡交易总额(扶持期)
fields.Add("HelpDirectQrCreditTradeAmt"); //直营云闪付贷记卡交易额(扶持期)
fields.Add("HelpNonDirectQrCreditTradeAmt"); //非直营云闪付贷记卡交易额(扶持期)
fields.Add("HelpDirectNonQrCreditTradeAmt"); //直营非云闪付贷记卡交易额(扶持期)
fields.Add("HelpNonDirectNonQrCreditTradeAmt"); //非直营非云闪付贷记卡交易额(扶持期)
fields.Add("HelpDirectDebitTradeAmt"); //直营商户借记卡交易总额(扶持期)
fields.Add("HelpDirectDebitCapTradeAmt"); //直营商户借记卡封顶交易总金额(扶持期)
fields.Add("HelpDirectDebitCapNum"); //直营商户借记卡封顶交易总数(扶持期)
fields.Add("HelpNonDirectDebitTradeAmt"); //非直营商户借记卡交易总额(扶持期)
fields.Add("HelpNonDirectDebitCapTradeAmt"); //非直营商户借记卡封顶交易总金额(扶持期)
fields.Add("HelpNonDirectDebitCapNum"); //非直营商户借记卡封顶交易总数(扶持期)
fields.Add("HelpDirectQrDebitTradeAmt"); //直营云闪付非封顶借记卡(扶持期)
fields.Add("HelpNonDirectQrDebitTradeAmt"); //非直营云闪付非封顶借记卡(扶持期)
fields.Add("HelpDirectNonQrDebitTradeAmt"); //直营非云闪付非封顶借记卡(扶持期)
fields.Add("HelpNonDirectNonQrDebitTradeAmt"); //非直营非云闪付非封顶借记卡(扶持期)
fields.Add("VipFlag"); //会员标记
fields.Add("PayType"); //支付方式
fields.Add("ProfitDirectTradeAmt"); //直营商户交易总额(盈利期)
fields.Add("ProfitNonDirectTradeAmt"); //非直营商户交易总额(盈利期)
fields.Add("ProfitDirectCreditTradeAmt"); //直营贷记卡交易总额(盈利期)
fields.Add("ProfitNonDirectCreditTradeAmt"); //非直营贷记卡交易总额(盈利期)
fields.Add("ProfitDirectQrCreditTradeAmt"); //直营云闪付贷记卡交易额(盈利期)
fields.Add("ProfitNonDirectQrCreditTradeAmt"); //非直营云闪付贷记卡交易额(盈利期)
fields.Add("ProfitDirectNonQrCreditTradeAmt"); //直营非云闪付贷记卡交易额(盈利期)
fields.Add("ProfitNonDirectNonQrCreditTradeAmt"); //非直营非云闪付贷记卡交易额(盈利期)
fields.Add("ProfitDirectDebitTradeAmt"); //直营商户借记卡交易总额(盈利期)
fields.Add("ProfitDirectDebitCapTradeAmt"); //直营商户借记卡封顶交易总金额(盈利期)
fields.Add("ProfitDirectDebitCapNum"); //直营商户借记卡封顶交易总数(盈利期)
fields.Add("ProfitNonDirectDebitTradeAmt"); //非直营商户借记卡交易总额(盈利期)
fields.Add("ProfitNonDirectDebitCapTradeAmt"); //非直营商户借记卡封顶交易总金额(盈利期)
fields.Add("ProfitNonDirectDebitCapNum"); //非直营商户借记卡封顶交易总数(盈利期)
fields.Add("ProfitDirectQrDebitTradeAmt"); //直营云闪付非封顶借记卡(盈利期)
fields.Add("ProfitNonDirectQrDebitTradeAmt"); //非直营云闪付非封顶借记卡(盈利期)
fields.Add("ProfitDirectNonQrDebitTradeAmt"); //直营非云闪付非封顶借记卡(盈利期)
fields.Add("ProfitNonDirectNonQrDebitTradeAmt"); //非直营非云闪付非封顶借记卡(盈利期)
Dictionary obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("TradeDaySummary", relationData, orderBy, page, limit, condition, fields);
List> diclist = obj["data"] as List>;
return diclist;
}
///
/// 查询一条记录
///
/// 主键Id
///
public static TradeDaySummary Query(int Id)
{
WebCMSEntities db = new WebCMSEntities();
TradeDaySummary editData = db.TradeDaySummary.FirstOrDefault(m => m.Id == Id) ?? new TradeDaySummary();
db.Dispose();
return editData;
}
///
/// 查询创客交易额
///
///
///
///
///
///
public static Dictionary GetMonthTradeForBrand(int UserId, string sTradeDate, string eTradeDate, int BrandId)
{
WebCMSEntities db = new WebCMSEntities();
string condition = " and Status>-1";
string cons = " and Status>=-1";
//产品类型
if (!string.IsNullOrEmpty(BrandId.ToString()) && BrandId > 0)
{
condition += " and BrandId =" + BrandId;
cons += " and BrandId =" + BrandId;
}
//创客Id
if (!string.IsNullOrEmpty(UserId.ToString()))
{
condition += " and UserId =" + UserId;
}
//开始时间
if (!string.IsNullOrEmpty(sTradeDate) && !string.IsNullOrEmpty(eTradeDate))
{
condition += " and TradeDate >=" + Convert.ToInt32(sTradeDate) + " and TradeDate <=" + Convert.ToInt32(eTradeDate);
cons += " and SeoKeyword >=" + Convert.ToInt32(sTradeDate) + " and SeoKeyword <=" + Convert.ToInt32(eTradeDate);
}
//结束时间
else
{
var start = DateTime.Now.ToString("yyyyMM") + "01";
condition += " and TradeDate >=" + Convert.ToInt32(start) + " and TradeDate <=" + Convert.ToInt32(eTradeDate);
cons += " and SeoKeyword >=" + Convert.ToInt32(start) + " and SeoKeyword <=" + Convert.ToInt32(eTradeDate);
}
//扶持期
decimal TotalAmtfc = 0;
decimal DAmtfc = 0;
decimal JAmtfc = 0;
decimal JfAmtfc = 0;
int JCountfc = 0;
decimal YAmtfc = 0;
//稳定期
decimal TotalAmtwd = 0;
decimal DAmtwd = 0;
decimal JAmtwd = 0;
decimal JfAmtwd = 0;
int JCountwd = 0;
decimal YAmtwd = 0;
//盈利期
decimal TotalAmtyl = 0;
decimal DAmtyl = 0;
decimal JAmtyl = 0;
decimal JfAmtyl = 0;
int JCountyl = 0;
decimal YAmtyl = 0;
int BCount = 0;
int ACount = 0;
int PBCount = 0;
int PACount = 0;
int TBCount = 0;
int TACount = 0;
Dictionary obj = new Dictionary();
DataTable dt = CustomerSqlConn.dtable("SELECT Sum(HelpNonDirectTradeAmt + HelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,HelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitTradeAmt - HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,HelpNonDirectTradeAmt,0)),Sum(NotHelpNonDirectTradeAmt + NotHelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,NotHelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitTradeAmt - NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,NotHelpNonDirectTradeAmt,0)),Sum(ProfitNonDirectTradeAmt + ProfitNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,ProfitNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitTradeAmt - ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,ProfitNonDirectTradeAmt,0))from TradeDaySummary where SeoTitle = 'team'" + condition, AppConfig.Base.SqlConnStr);
if (dt.Rows.Count > 0)
{
TotalAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
DAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
JAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][2].ToString()));
JfAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][3].ToString()));
JCountfc = Convert.ToInt32(function.CheckInt(dt.Rows[0][4].ToString()));
YAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][5].ToString()));
TotalAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][6].ToString()));
DAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][7].ToString()));
JAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][8].ToString()));
JfAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][9].ToString()));
JCountwd = Convert.ToInt32(function.CheckInt(dt.Rows[0][10].ToString()));
YAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][11].ToString()));
TotalAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][12].ToString()));
DAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][13].ToString()));
JAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][14].ToString()));
JfAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][15].ToString()));
JCountyl = Convert.ToInt32(function.CheckInt(dt.Rows[0][16].ToString()));
YAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][17].ToString()));
}
//统计激活数(个人、团队)
dt = CustomerSqlConn.dtable("SELECT SUM(if(SeoTitle='team',ActiveBuddyMerStatus,0)) FROM UserTradeMonthSummary WHERE UserId= '" + UserId + "'" + cons, AppConfig.Base.SqlConnStr);
if (dt.Rows.Count > 0)
{
TACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
}
obj.Add("TotalAmtfc", TotalAmtfc);
obj.Add("DAmtfc", DAmtfc);
obj.Add("JAmtfc", JAmtfc);
obj.Add("JfAmtfc", JfAmtfc);
obj.Add("JCountfc", JCountfc);
obj.Add("YAmtfc", YAmtfc);
obj.Add("TotalAmtwd", TotalAmtwd);
obj.Add("DAmtwd", DAmtwd);
obj.Add("JAmtwd", JAmtwd);
obj.Add("JfAmtwd", JfAmtwd);
obj.Add("JCountwd", JCountwd);
obj.Add("YAmtwd", YAmtwd);
obj.Add("TotalAmtyl", TotalAmtyl);
obj.Add("DAmtyl", DAmtyl);
obj.Add("JAmtyl", JAmtyl);
obj.Add("JfAmtyl", JfAmtyl);
obj.Add("JCountyl", JCountyl);
obj.Add("YAmtyl", YAmtyl);
obj.Add("BCount", BCount);
obj.Add("ACount", ACount);
obj.Add("PBCount", PBCount);
obj.Add("PACount", PACount);
obj.Add("TBCount", TBCount);
obj.Add("TACount", TACount);
db.Dispose();
return obj;
}
///
/// 查询创客交易额统计
///
///
///
///
///
public static Dictionary GetSumTitleMonthTrade(int UserId, string Con, string Cons)
{
WebCMSEntities db = new WebCMSEntities();
//个人
//扶持期
decimal TotalAmtfc = 0;
decimal DAmtfc = 0;
decimal JAmtfc = 0;
decimal JfAmtfc = 0;
int JCountfc = 0;
decimal YAmtfc = 0;
//稳定期
decimal TotalAmtwd = 0;
decimal DAmtwd = 0;
decimal JAmtwd = 0;
decimal JfAmtwd = 0;
int JCountwd = 0;
decimal YAmtwd = 0;
//盈利期
decimal TotalAmtyl = 0;
decimal DAmtyl = 0;
decimal JAmtyl = 0;
decimal JfAmtyl = 0;
int JCountyl = 0;
decimal YAmtyl = 0;
//团队
//扶持期
decimal TotalAmtfc1 = 0;
decimal DAmtfc1 = 0;
decimal JAmtfc1 = 0;
decimal JfAmtfc1 = 0;
int JCountfc1 = 0;
decimal YAmtfc1 = 0;
//稳定期
decimal TotalAmtwd1 = 0;
decimal DAmtwd1 = 0;
decimal JAmtwd1 = 0;
decimal JfAmtwd1 = 0;
int JCountwd1 = 0;
decimal YAmtwd1 = 0;
//盈利期
decimal TotalAmtyl1 = 0;
decimal DAmtyl1 = 0;
decimal JAmtyl1 = 0;
decimal JfAmtyl1 = 0;
int JCountyl1 = 0;
decimal YAmtyl1 = 0;
int PBCount = 0;
int PACount = 0;
int TBCount = 0;
int TACount = 0;
Dictionary obj = new Dictionary();
DataTable dt = CustomerSqlConn.dtable("SELECT Sum(HelpDirectTradeAmt + HelpDirectDebitTradeAmt),Sum(if (QueryCount = 0,HelpDirectTradeAmt,0)),Sum(if (QueryCount = 0,HelpDirectDebitTradeAmt - HelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpDirectDebitCapNum,0)),Sum(if (QueryCount = 1,HelpDirectTradeAmt,0)),Sum(NotHelpDirectTradeAmt + NotHelpDirectDebitTradeAmt),Sum(if (QueryCount = 0,NotHelpDirectTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpDirectDebitTradeAmt - NotHelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpDirectDebitCapNum,0)),Sum(if (QueryCount = 1,NotHelpDirectTradeAmt,0)),Sum(ProfitDirectTradeAmt + ProfitDirectDebitTradeAmt),Sum(if (QueryCount = 0,ProfitDirectTradeAmt,0)),Sum(if (QueryCount = 0,ProfitDirectDebitTradeAmt - ProfitDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitDirectDebitCapNum,0)),Sum(if (QueryCount = 1,ProfitDirectTradeAmt,0))from TradeDaySummary where SeoTitle = 'self' and UserId =" + UserId + "" + Con, AppConfig.Base.SqlConnStr);
if (dt.Rows.Count > 0)
{
TotalAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][0].ToString()));
DAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][1].ToString()));
JAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][2].ToString()));
JfAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][3].ToString()));
JCountfc = Convert.ToInt32(function.CheckInt(dt.Rows[0][4].ToString()));
YAmtfc = Convert.ToDecimal(function.CheckNum(dt.Rows[0][5].ToString()));
TotalAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][6].ToString()));
DAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][7].ToString()));
JAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][8].ToString()));
JfAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][9].ToString()));
JCountwd = Convert.ToInt32(function.CheckInt(dt.Rows[0][10].ToString()));
YAmtwd = Convert.ToDecimal(function.CheckNum(dt.Rows[0][11].ToString()));
TotalAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][12].ToString()));
DAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][13].ToString()));
JAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][14].ToString()));
JfAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][15].ToString()));
JCountyl = Convert.ToInt32(function.CheckInt(dt.Rows[0][16].ToString()));
YAmtyl = Convert.ToDecimal(function.CheckNum(dt.Rows[0][17].ToString()));
}
//统计激活数(个人、团队)
dt = CustomerSqlConn.dtable("SELECT SUM(if(SeoTitle='self',ActiveBuddyMerStatus,0)),SUM(if(SeoTitle='team',ActiveBuddyMerStatus,0)) FROM UserTradeMonthSummary WHERE UserId= " + UserId + "" + Cons, AppConfig.Base.SqlConnStr);
if (dt.Rows.Count > 0)
{
PACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][0].ToString()));
TACount = Convert.ToInt32(function.CheckNum(dt.Rows[0][1].ToString()));
}
DataTable dts = CustomerSqlConn.dtable("SELECT Sum(HelpNonDirectTradeAmt + HelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,HelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitTradeAmt - HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,HelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,HelpNonDirectTradeAmt,0)),Sum(NotHelpNonDirectTradeAmt + NotHelpNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,NotHelpNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitTradeAmt - NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,NotHelpNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,NotHelpNonDirectTradeAmt,0)),Sum(ProfitNonDirectTradeAmt + ProfitNonDirectDebitTradeAmt),Sum(if (QueryCount = 0,ProfitNonDirectTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitTradeAmt - ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapTradeAmt,0)),Sum(if (QueryCount = 0,ProfitNonDirectDebitCapNum,0)),Sum(if (QueryCount = 1,ProfitNonDirectTradeAmt,0))from TradeDaySummary where SeoTitle = 'team' and UserId =" + UserId + "" + Con, AppConfig.Base.SqlConnStr);
if (dts.Rows.Count > 0)
{
TotalAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][0].ToString()));
DAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][1].ToString()));
JAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][2].ToString()));
JfAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][3].ToString()));
JCountfc1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][4].ToString()));
YAmtfc1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][5].ToString()));
TotalAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][6].ToString()));
DAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][7].ToString()));
JAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][8].ToString()));
JfAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][9].ToString()));
JCountwd1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][10].ToString()));
YAmtwd1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][11].ToString()));
TotalAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][12].ToString()));
DAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][13].ToString()));
JAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][14].ToString()));
JfAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][15].ToString()));
JCountyl1 = Convert.ToInt32(function.CheckInt(dts.Rows[0][16].ToString()));
YAmtyl1 = Convert.ToDecimal(function.CheckNum(dts.Rows[0][17].ToString()));
}
obj.Add("TotalAmtfc", TotalAmtfc);
obj.Add("DAmtfc", DAmtfc);
obj.Add("JAmtfc", JAmtfc);
obj.Add("JfAmtfc", JfAmtfc);
obj.Add("JCountfc", JCountfc);
obj.Add("YAmtfc", YAmtfc);
obj.Add("TotalAmtwd", TotalAmtwd);
obj.Add("DAmtwd", DAmtwd);
obj.Add("JAmtwd", JAmtwd);
obj.Add("JfAmtwd", JfAmtwd);
obj.Add("JCountwd", JCountwd);
obj.Add("YAmtwd", YAmtwd);
obj.Add("TotalAmtyl", TotalAmtyl);
obj.Add("DAmtyl", DAmtyl);
obj.Add("JAmtyl", JAmtyl);
obj.Add("JfAmtyl", JfAmtyl);
obj.Add("JCountyl", JCountyl);
obj.Add("YAmtyl", YAmtyl);
obj.Add("TotalAmtfc1", TotalAmtfc1);
obj.Add("DAmtfc1", DAmtfc1);
obj.Add("JAmtfc1", JAmtfc1);
obj.Add("JfAmtfc1", JfAmtfc1);
obj.Add("JCountfc1", JCountfc1);
obj.Add("YAmtfc1", YAmtfc1);
obj.Add("TotalAmtwd1", TotalAmtwd1);
obj.Add("DAmtwd1", DAmtwd1);
obj.Add("JAmtwd1", JAmtwd1);
obj.Add("JfAmtwd1", JfAmtwd1);
obj.Add("JCountwd1", JCountwd1);
obj.Add("YAmtwd1", YAmtwd1);
obj.Add("TotalAmtyl1", TotalAmtyl1);
obj.Add("DAmtyl1", DAmtyl1);
obj.Add("JAmtyl1", JAmtyl1);
obj.Add("JfAmtyl1", JfAmtyl1);
obj.Add("JCountyl1", JCountyl1);
obj.Add("YAmtyl1", YAmtyl1);
obj.Add("PBCount", PBCount);
obj.Add("PACount", PACount);
obj.Add("TBCount", TBCount);
obj.Add("TACount", TACount);
db.Dispose();
return obj;
}
///
/// 查询记录数
///
/// 主键Id
///
public static int Count(string condition = "")
{
int result = 0;
DataTable dt = CustomerSqlConn.dtable("select count(Id) from TradeDaySummary where 1=1" + condition, _conn);
if (dt.Rows.Count > 0)
{
result = int.Parse(function.CheckInt(dt.Rows[0][0].ToString()));
}
return result;
}
///
/// 查询是否存在
///
/// 主键Id
///
public static bool Exist(int Id)
{
WebCMSEntities db = new WebCMSEntities();
bool check = db.TradeDaySummary.Any(m => m.Id == Id);
db.Dispose();
return check;
}
///
/// 添加数据
///
/// 要设置的字段
///
public static AppResultJson Add(Dictionary fields, bool check = true)
{
if (check)
{
}
int Id = new DbService(AppConfig.Base.mainTables, _conn).Add("TradeDaySummary", fields, 0);
return new AppResultJson() { Status = "1", Data = Id };
}
///
/// 修改数据
///
/// 要设置的字段
/// 主键Id
public static AppResultJson Edit(Dictionary fields, int Id, bool check = true)
{
if (check)
{
}
new DbService(AppConfig.Base.mainTables, _conn).Edit("TradeDaySummary", fields, Id);
return new AppResultJson() { Status = "1", Data = Id };
}
///
/// 逻辑删除
///
/// 主键Id
public static void Remove(int Id)
{
Dictionary fields = new Dictionary();
fields.Add("Status", -1);
new DbService(AppConfig.Base.mainTables, _conn).Edit("TradeDaySummary", fields, Id);
}
///
/// 删除数据
///
/// 主键Id
public static void Delete(int Id)
{
new DbService(AppConfig.Base.mainTables, _conn).Delete("TradeDaySummary", Id);
}
///
/// 排序
///
/// 主键Id
/// 排序序号
public static void Sort(int Id, int Sort)
{
new DbService(AppConfig.Base.mainTables, _conn).Sort("TradeDaySummary", Sort, Id);
}
///
/// 导入数据
///
/// json数据
public static void Import(string ExcelData)
{
WebCMSEntities db = new WebCMSEntities();
JsonData list = JsonMapper.ToObject(ExcelData);
for (int i = 1; i < list.Count; i++)
{
JsonData dr = list[i];
db.TradeDaySummary.Add(new TradeDaySummary()
{
CreateDate = DateTime.Now,
UpdateDate = DateTime.Now,
});
db.SaveChanges();
}
db.Dispose();
}
///
/// 导出excel表格
///
/// 查询条件(单个字段)
/// 查询条件(sql语句)
///
// public static void ExportExcel(List relationData, string condition)
// {
// }
}
}