123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 |
- /*
- * 交易日汇总
- */
- 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();
- /// <summary>
- /// 查询列表
- /// </summary>
- /// <param name="relationData">关联表</param>
- /// <param name="condition">查询条件(sql语句)</param>
- /// <param name="count">总数(输出)</param>
- /// <param name="page">页码</param>
- /// <param name="limit">每页条数</param>
- /// <returns></returns>
- public static List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, out int count, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
- {
- List<string> fields = new List<string>(); //要显示的列
- 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<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("TradeDaySummary", relationData, orderBy, page, limit, condition, fields);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- count = int.Parse(obj["count"].ToString());
- return diclist;
- }
- public static List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
- {
- List<string> fields = new List<string>(); //要显示的列
- 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<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("TradeDaySummary", relationData, orderBy, page, limit, condition, fields);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- return diclist;
- }
- /// <summary>
- /// 查询一条记录
- /// </summary>
- /// <param name="Id">主键Id</param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 查询创客交易额
- /// </summary>
- /// <param name="UserId"></param>
- /// <param name="sTradeDate"></param>
- /// <param name="eTradeDate"></param>
- /// <param name="BrandId"></param>
- /// <returns></returns>
- public static Dictionary<string, object> 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<string, object> obj = new Dictionary<string, object>();
- 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;
- }
- /// <summary>
- /// 查询创客交易额统计
- /// </summary>
- /// <param name="UserId"></param>
- /// <param name="Con"></param>
- /// <param name="Cons"></param>
- /// <returns></returns>
- public static Dictionary<string, object> 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<string, object> obj = new Dictionary<string, object>();
- 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;
- }
- /// <summary>
- /// 查询记录数
- /// </summary>
- /// <param name="Id">主键Id</param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 查询是否存在
- /// </summary>
- /// <param name="Id">主键Id</param>
- /// <returns></returns>
- public static bool Exist(int Id)
- {
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.TradeDaySummary.Any(m => m.Id == Id);
- db.Dispose();
- return check;
- }
- /// <summary>
- /// 添加数据
- /// </summary>
- /// <param name="Fields">要设置的字段</param>
- /// <returns></returns>
- public static AppResultJson Add(Dictionary<string, object> 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 };
- }
- /// <summary>
- /// 修改数据
- /// </summary>
- /// <param name="Fields">要设置的字段</param>
- /// <param name="Id">主键Id</param>
- public static AppResultJson Edit(Dictionary<string, object> 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 };
- }
- /// <summary>
- /// 逻辑删除
- /// </summary>
- /// <param name="Id">主键Id</param>
- public static void Remove(int Id)
- {
- Dictionary<string, object> fields = new Dictionary<string, object>();
- fields.Add("Status", -1);
- new DbService(AppConfig.Base.mainTables, _conn).Edit("TradeDaySummary", fields, Id);
- }
- /// <summary>
- /// 删除数据
- /// </summary>
- /// <param name="Id">主键Id</param>
- public static void Delete(int Id)
- {
- new DbService(AppConfig.Base.mainTables, _conn).Delete("TradeDaySummary", Id);
- }
- /// <summary>
- /// 排序
- /// </summary>
- /// <param name="Id">主键Id</param>
- /// <param name="Sort">排序序号</param>
- public static void Sort(int Id, int Sort)
- {
- new DbService(AppConfig.Base.mainTables, _conn).Sort("TradeDaySummary", Sort, Id);
- }
- /// <summary>
- /// 导入数据
- /// </summary>
- /// <param name="ExcelData">json数据</param>
- 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();
- }
- /// <summary>
- /// 导出excel表格
- /// </summary>
- /// <param name="fields">查询条件(单个字段)</param>
- /// <param name="condition">查询条件(sql语句)</param>
- /// <returns></returns>
- // public static void ExportExcel(List<RelationData> relationData, string condition)
- // {
- // }
- }
- }
|