| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759 |
- using System;
- using System.Collections.Generic;
- using Library;
- using LitJson;
- using System.Linq;
- using System.Data;
- using System.Threading;
- using MySystem.KxsReadModels;
- namespace MySystem
- {
- public class StatTradeCheckService
- {
- public readonly static StatTradeCheckService Instance = new StatTradeCheckService();
- private StatTradeCheckService()
- { }
- // 统计交易额V2
- public void Start()
- {
- Thread th = new Thread(StartDo);
- th.IsBackground = true;
- th.Start();
- }
- public void StartDo()
- {
- while (true)
- {
- string content = RedisDbconn.Instance.RPop<string>("StatTradeCheckQueue");
- if(!string.IsNullOrEmpty(content))
- {
- StatTradeAmountDo(content);
- Thread.Sleep(1);
- }
- else
- {
- Thread.Sleep(10000);
- }
- }
- }
- public void StatTradeAmountDo(string date)
- {
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- try
- {
- int pageNum = 0;
- bool check = true;
- while(check)
- {
- string sql = "";
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---" + pageNum + "----start", "统计交易额日志");
- DataTable dt = CustomerSqlConn.dtable("select UserId,ParentNav,BrandId,BankCardType,QrPayFlag,MerHelpFlag,Version,CapFlag,VipFlag,PayType,DATE_FORMAT(CreateDate,'%Y%m%d'),sum(TradeAmount),count(Id),SnNo,TradeDate from TradeRecord where Id>20000000 and ActStatus=1 and BrandId!=14 and UserId>0 and CreateDate>='" + date + " 00:00:00' and CreateDate<='" + date + " 23:59:59' group by UserId,ParentNav,BrandId,BankCardType,QrPayFlag,MerHelpFlag,Version,CapFlag,VipFlag,PayType,DATE_FORMAT(CreateDate,'%Y%m%d'),SnNo,TradeDate order by UserId limit " + pageNum + ",500", AppConfig.Base.TmpReadSqlConn);
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---" + pageNum + "----query", "统计交易额日志");
- if(dt.Rows.Count > 0)
- {
- foreach (DataRow dr in dt.Rows)
- {
- int UserId = int.Parse(dr["UserId"].ToString());
- string SnNo = dr["SnNo"].ToString();
- string BindingTime = dr["TradeDate"].ToString();
- string ParentNav = dr["ParentNav"].ToString();
- int BrandId = int.Parse(dr["BrandId"].ToString());
- int BankCardType = int.Parse(dr["BankCardType"].ToString());
- int QrPayFlag = int.Parse(dr["QrPayFlag"].ToString());
- int MerHelpFlag = int.Parse(dr["MerHelpFlag"].ToString());
- int Version = int.Parse(dr["Version"].ToString());
- int CapFlag = int.Parse(dr["CapFlag"].ToString());
- int VipFlag = int.Parse(dr["VipFlag"].ToString());
- int PayType = int.Parse(dr["PayType"].ToString());
- string TradeDate = dr[10].ToString();
- decimal TradeAmount = decimal.Parse(dr[11].ToString());
- int TradeCount = 1;
- string TradeMonth = TradeDate.Substring(0, 6);
- ParentNav += "," + UserId + ",";
- string ParentNavString = ParentNav.Trim(',').Replace(",,", ",");
- string[] UserIdList = ParentNavString.Split(',');
- if(Version < 2)
- {
- //个人业绩
- decimal ProfitDirectDebitTradeAmt = 0;
- decimal ProfitDirectDebitCapTradeAmt = 0;
- decimal ProfitDirectDebitCapNum = 0;
- decimal HelpDirectDebitTradeAmt = 0;
- decimal HelpDirectDebitCapTradeAmt = 0;
- decimal HelpDirectDebitCapNum = 0;
- decimal NotHelpDirectDebitTradeAmt = 0;
- decimal NotHelpDirectDebitCapTradeAmt = 0;
- decimal NotHelpDirectDebitCapNum = 0;
- decimal ProfitDirectTradeAmt = 0;
- decimal HelpDirectTradeAmt = 0;
- decimal NotHelpDirectTradeAmt = 0;
- if (BankCardType == 0)
- {
- if (Version == 1)
- {
- ProfitDirectDebitTradeAmt += TradeAmount;
- if (CapFlag == 1)
- {
- ProfitDirectDebitCapTradeAmt += TradeAmount;
- ProfitDirectDebitCapNum += TradeCount;
- }
- }
- else if (MerHelpFlag == 1)
- {
- HelpDirectDebitTradeAmt += TradeAmount;
- if (CapFlag == 1)
- {
- HelpDirectDebitCapTradeAmt += TradeAmount;
- HelpDirectDebitCapNum += TradeCount;
- }
- }
- else
- {
- NotHelpDirectDebitTradeAmt += TradeAmount;
- if (CapFlag == 1)
- {
- NotHelpDirectDebitCapTradeAmt += TradeAmount;
- NotHelpDirectDebitCapNum += TradeCount;
- }
- }
- }
- else if (BankCardType != 0)
- {
- if (Version == 1)
- {
- ProfitDirectTradeAmt += TradeAmount;
- }
- else if (MerHelpFlag == 1)
- {
- HelpDirectTradeAmt += TradeAmount;
- }
- else
- {
- NotHelpDirectTradeAmt += TradeAmount;
- }
- }
- sql += InsertOrUpdate("TradeDaySummary", "ProfitDirectDebitTradeAmt,ProfitDirectDebitCapTradeAmt,ProfitDirectDebitCapNum,HelpDirectDebitTradeAmt,HelpDirectDebitCapTradeAmt,HelpDirectDebitCapNum,NotHelpDirectDebitTradeAmt,NotHelpDirectDebitCapTradeAmt,NotHelpDirectDebitCapNum,ProfitDirectTradeAmt,HelpDirectTradeAmt,NotHelpDirectTradeAmt", ProfitDirectDebitTradeAmt + "," + ProfitDirectDebitCapTradeAmt + "," + ProfitDirectDebitCapNum + "," + HelpDirectDebitTradeAmt + "," + HelpDirectDebitCapTradeAmt + "," + HelpDirectDebitCapNum + "," + NotHelpDirectDebitTradeAmt + "," + NotHelpDirectDebitCapTradeAmt + "," + NotHelpDirectDebitCapNum + "," + ProfitDirectTradeAmt + "," + HelpDirectTradeAmt + "," + NotHelpDirectTradeAmt, "UserId=" + UserId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and BrandId=" + BrandId + " and QueryCount=" + QrPayFlag + " and VipFlag=" + VipFlag + " and PayType=" + PayType + " and SeoTitle='self'");
- if (DateTime.Parse(BindingTime) < DateTime.Parse("2023-07-01 00:00:00"))
- {
- sql += InsertOrUpdate("TradeDaySummaryBefore", "ProfitDirectDebitTradeAmt,ProfitDirectDebitCapTradeAmt,ProfitDirectDebitCapNum,HelpDirectDebitTradeAmt,HelpDirectDebitCapTradeAmt,HelpDirectDebitCapNum,NotHelpDirectDebitTradeAmt,NotHelpDirectDebitCapTradeAmt,NotHelpDirectDebitCapNum,ProfitDirectTradeAmt,HelpDirectTradeAmt,NotHelpDirectTradeAmt", ProfitDirectDebitTradeAmt + "," + ProfitDirectDebitCapTradeAmt + "," + ProfitDirectDebitCapNum + "," + HelpDirectDebitTradeAmt + "," + HelpDirectDebitCapTradeAmt + "," + HelpDirectDebitCapNum + "," + NotHelpDirectDebitTradeAmt + "," + NotHelpDirectDebitCapTradeAmt + "," + NotHelpDirectDebitCapNum + "," + ProfitDirectTradeAmt + "," + HelpDirectTradeAmt + "," + NotHelpDirectTradeAmt, "UserId=" + UserId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and BrandId=" + BrandId + " and QueryCount=" + QrPayFlag + " and VipFlag=" + VipFlag + " and PayType=" + PayType + " and SeoTitle='self'");
- }
- else
- {
- sql += InsertOrUpdate("TradeDaySummaryAfter", "ProfitDirectDebitTradeAmt,ProfitDirectDebitCapTradeAmt,ProfitDirectDebitCapNum,HelpDirectDebitTradeAmt,HelpDirectDebitCapTradeAmt,HelpDirectDebitCapNum,NotHelpDirectDebitTradeAmt,NotHelpDirectDebitCapTradeAmt,NotHelpDirectDebitCapNum,ProfitDirectTradeAmt,HelpDirectTradeAmt,NotHelpDirectTradeAmt", ProfitDirectDebitTradeAmt + "," + ProfitDirectDebitCapTradeAmt + "," + ProfitDirectDebitCapNum + "," + HelpDirectDebitTradeAmt + "," + HelpDirectDebitCapTradeAmt + "," + HelpDirectDebitCapNum + "," + NotHelpDirectDebitTradeAmt + "," + NotHelpDirectDebitCapTradeAmt + "," + NotHelpDirectDebitCapNum + "," + ProfitDirectTradeAmt + "," + HelpDirectTradeAmt + "," + NotHelpDirectTradeAmt, "UserId=" + UserId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and BrandId=" + BrandId + " and QueryCount=" + QrPayFlag + " and VipFlag=" + VipFlag + " and PayType=" + PayType + " and SeoTitle='self'");
- }
- //团队业绩
- foreach(string SubUserId in UserIdList)
- {
- decimal ProfitNonDirectDebitTradeAmt = 0;
- ProfitDirectDebitCapTradeAmt = 0;
- ProfitDirectDebitCapNum = 0;
- decimal HelpNonDirectDebitTradeAmt = 0;
- HelpDirectDebitCapTradeAmt = 0;
- HelpDirectDebitCapNum = 0;
- decimal NotHelpNonDirectDebitTradeAmt = 0;
- NotHelpDirectDebitCapTradeAmt = 0;
- NotHelpDirectDebitCapNum = 0;
- decimal ProfitNonDirectTradeAmt = 0;
- decimal HelpNonDirectTradeAmt = 0;
- decimal NotHelpNonDirectTradeAmt = 0;
- if (BankCardType == 0)
- {
- if (Version == 1)
- {
- ProfitNonDirectDebitTradeAmt += TradeAmount;
- if (CapFlag == 1)
- {
- ProfitDirectDebitCapTradeAmt += TradeAmount;
- ProfitDirectDebitCapNum += TradeCount;
- }
- }
- else if (MerHelpFlag == 1)
- {
- HelpNonDirectDebitTradeAmt += TradeAmount;
- if (CapFlag == 1)
- {
- HelpDirectDebitCapTradeAmt += TradeAmount;
- HelpDirectDebitCapNum += TradeCount;
- }
- }
- else
- {
- NotHelpNonDirectDebitTradeAmt += TradeAmount;
- if (CapFlag == 1)
- {
- NotHelpDirectDebitCapTradeAmt += TradeAmount;
- NotHelpDirectDebitCapNum += TradeCount;
- }
- }
- }
- else if (BankCardType != 0)
- {
- if (Version == 1)
- {
- ProfitNonDirectTradeAmt += TradeAmount;
- }
- else if (MerHelpFlag == 1)
- {
- HelpNonDirectTradeAmt += TradeAmount;
- }
- else
- {
- NotHelpNonDirectTradeAmt += TradeAmount;
- }
- }
- sql += InsertOrUpdate("TradeDaySummary", "ProfitNonDirectDebitTradeAmt,ProfitDirectDebitCapTradeAmt,ProfitDirectDebitCapNum,HelpNonDirectDebitTradeAmt,HelpDirectDebitCapTradeAmt,HelpDirectDebitCapNum,NotHelpNonDirectDebitTradeAmt,NotHelpDirectDebitCapTradeAmt,NotHelpDirectDebitCapNum,ProfitNonDirectTradeAmt,HelpNonDirectTradeAmt,NotHelpNonDirectTradeAmt", ProfitNonDirectDebitTradeAmt + "," + ProfitDirectDebitCapTradeAmt + "," + ProfitDirectDebitCapNum + "," + HelpNonDirectDebitTradeAmt + "," + HelpDirectDebitCapTradeAmt + "," + HelpDirectDebitCapNum + "," + NotHelpNonDirectDebitTradeAmt + "," + NotHelpDirectDebitCapTradeAmt + "," + NotHelpDirectDebitCapNum + "," + ProfitNonDirectTradeAmt + "," + HelpNonDirectTradeAmt + "," + NotHelpNonDirectTradeAmt, "UserId=" + SubUserId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and BrandId=" + BrandId + " and QueryCount=" + QrPayFlag + " and VipFlag=" + VipFlag + " and PayType=" + PayType + " and SeoTitle='team'");
- if (DateTime.Parse(BindingTime) < DateTime.Parse("2023-07-01 00:00:00"))
- {
- sql += InsertOrUpdate("TradeDaySummaryBefore", "ProfitNonDirectDebitTradeAmt,ProfitDirectDebitCapTradeAmt,ProfitDirectDebitCapNum,HelpNonDirectDebitTradeAmt,HelpDirectDebitCapTradeAmt,HelpDirectDebitCapNum,NotHelpNonDirectDebitTradeAmt,NotHelpDirectDebitCapTradeAmt,NotHelpDirectDebitCapNum,ProfitNonDirectTradeAmt,HelpNonDirectTradeAmt,NotHelpNonDirectTradeAmt", ProfitNonDirectDebitTradeAmt + "," + ProfitDirectDebitCapTradeAmt + "," + ProfitDirectDebitCapNum + "," + HelpNonDirectDebitTradeAmt + "," + HelpDirectDebitCapTradeAmt + "," + HelpDirectDebitCapNum + "," + NotHelpNonDirectDebitTradeAmt + "," + NotHelpDirectDebitCapTradeAmt + "," + NotHelpDirectDebitCapNum + "," + ProfitNonDirectTradeAmt + "," + HelpNonDirectTradeAmt + "," + NotHelpNonDirectTradeAmt, "UserId=" + SubUserId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and BrandId=" + BrandId + " and QueryCount=" + QrPayFlag + " and VipFlag=" + VipFlag + " and PayType=" + PayType + " and SeoTitle='team'");
- }
- else
- {
- sql += InsertOrUpdate("TradeDaySummaryAfter", "ProfitNonDirectDebitTradeAmt,ProfitDirectDebitCapTradeAmt,ProfitDirectDebitCapNum,HelpNonDirectDebitTradeAmt,HelpDirectDebitCapTradeAmt,HelpDirectDebitCapNum,NotHelpNonDirectDebitTradeAmt,NotHelpDirectDebitCapTradeAmt,NotHelpDirectDebitCapNum,ProfitNonDirectTradeAmt,HelpNonDirectTradeAmt,NotHelpNonDirectTradeAmt", ProfitNonDirectDebitTradeAmt + "," + ProfitDirectDebitCapTradeAmt + "," + ProfitDirectDebitCapNum + "," + HelpNonDirectDebitTradeAmt + "," + HelpDirectDebitCapTradeAmt + "," + HelpDirectDebitCapNum + "," + NotHelpNonDirectDebitTradeAmt + "," + NotHelpDirectDebitCapTradeAmt + "," + NotHelpDirectDebitCapNum + "," + ProfitNonDirectTradeAmt + "," + HelpNonDirectTradeAmt + "," + NotHelpNonDirectTradeAmt, "UserId=" + SubUserId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and BrandId=" + BrandId + " and QueryCount=" + QrPayFlag + " and VipFlag=" + VipFlag + " and PayType=" + PayType + " and SeoTitle='team'");
- }
- }
- }
- else
- {
- decimal ProfitDebitTradeAmt = 0;
- decimal ProfitDebitCapTradeAmt = 0;
- decimal ProfitDebitCapNum = 0;
- decimal ProfitTradeAmt = 0;
- if (BankCardType == 0)
- {
- if (Version == 2)
- {
- ProfitDebitTradeAmt += TradeAmount;
- if (CapFlag == 1)
- {
- ProfitDebitCapTradeAmt += TradeAmount;
- ProfitDebitCapNum += TradeCount;
- }
- }
- }
- else if (BankCardType != 0)
- {
- if (Version == 2)
- {
- ProfitTradeAmt += TradeAmount;
- }
- }
- sql += InsertOrUpdate("TradeDaySummary2", "ProfitDebitTradeAmt,ProfitDebitCapTradeAmt,ProfitDebitCapNum,ProfitTradeAmt", ProfitDebitTradeAmt + "," + ProfitDebitCapTradeAmt + "," + ProfitDebitCapNum + "," + ProfitTradeAmt, "UserId=" + UserId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and BrandId=" + BrandId + " and QueryCount=" + QrPayFlag + " and VipFlag=" + VipFlag + " and PayType=" + PayType + " and SeoTitle='self'");
- if (DateTime.Parse(BindingTime) < DateTime.Parse("2023-07-01 00:00:00"))
- {
- sql += InsertOrUpdate("TradeDaySummary2Before", "ProfitDebitTradeAmt,ProfitDebitCapTradeAmt,ProfitDebitCapNum,ProfitTradeAmt", ProfitDebitTradeAmt + "," + ProfitDebitCapTradeAmt + "," + ProfitDebitCapNum + "," + ProfitTradeAmt, "UserId=" + UserId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and BrandId=" + BrandId + " and QueryCount=" + QrPayFlag + " and VipFlag=" + VipFlag + " and PayType=" + PayType + " and SeoTitle='self'");
- }
- else
- {
- sql += InsertOrUpdate("TradeDaySummary2After", "ProfitDebitTradeAmt,ProfitDebitCapTradeAmt,ProfitDebitCapNum,ProfitTradeAmt", ProfitDebitTradeAmt + "," + ProfitDebitCapTradeAmt + "," + ProfitDebitCapNum + "," + ProfitTradeAmt, "UserId=" + UserId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and BrandId=" + BrandId + " and QueryCount=" + QrPayFlag + " and VipFlag=" + VipFlag + " and PayType=" + PayType + " and SeoTitle='self'");
- }
- foreach(string SubUserId in UserIdList)
- {
- sql += InsertOrUpdate("TradeDaySummary2", "ProfitDebitTradeAmt,ProfitDebitCapTradeAmt,ProfitDebitCapNum,ProfitTradeAmt", ProfitDebitTradeAmt + "," + ProfitDebitCapTradeAmt + "," + ProfitDebitCapNum + "," + ProfitTradeAmt, "UserId=" + SubUserId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and BrandId=" + BrandId + " and QueryCount=" + QrPayFlag + " and VipFlag=" + VipFlag + " and PayType=" + PayType + " and SeoTitle='team'");
- if (DateTime.Parse(BindingTime) < DateTime.Parse("2023-07-01 00:00:00"))
- {
- sql += InsertOrUpdate("TradeDaySummary2Before", "ProfitDebitTradeAmt,ProfitDebitCapTradeAmt,ProfitDebitCapNum,ProfitTradeAmt", ProfitDebitTradeAmt + "," + ProfitDebitCapTradeAmt + "," + ProfitDebitCapNum + "," + ProfitTradeAmt, "UserId=" + SubUserId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and BrandId=" + BrandId + " and QueryCount=" + QrPayFlag + " and VipFlag=" + VipFlag + " and PayType=" + PayType + " and SeoTitle='team'");
- }
- else
- {
- sql += InsertOrUpdate("TradeDaySummary2After", "ProfitDebitTradeAmt,ProfitDebitCapTradeAmt,ProfitDebitCapNum,ProfitTradeAmt", ProfitDebitTradeAmt + "," + ProfitDebitCapTradeAmt + "," + ProfitDebitCapNum + "," + ProfitTradeAmt, "UserId=" + SubUserId + " and TradeMonth='" + TradeMonth + "' and TradeDate='" + TradeDate + "' and BrandId=" + BrandId + " and QueryCount=" + QrPayFlag + " and VipFlag=" + VipFlag + " and PayType=" + PayType + " and SeoTitle='team'");
- }
- }
- }
- }
- pageNum += 1;
- }
- else
- {
- check = false;
- }
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---" + pageNum + "----end", "统计交易额日志");
- // function.WriteLog(sql, "SQL脚本");
- CustomerSqlConn.op(sql, AppConfig.Base.SqlConn);
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "---" + pageNum + "----fiinsh\n\n", "统计交易额日志");
- }
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计交易额异常");
- }
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- }
- List<string> rediskeys = new List<string>();
- public string InsertOrUpdate(string table, string fields, string vals, string condition)
- {
- string sql = "";
- // string check = RedisDbconn.Instance.Get<string>("statreset:" + table + ":" + function.MD5_16(condition));
- // if(string.IsNullOrEmpty(check))
- if(!rediskeys.Contains(table + ":" + function.MD5_16(condition)))
- {
- rediskeys.Add(table + ":" + function.MD5_16(condition));
- // RedisDbconn.Instance.Set("statreset:" + table + ":" + function.MD5_16(condition), fields + "#cut#" + vals);
- // RedisDbconn.Instance.SetExpire("statreset:" + table + ":" + function.MD5_16(condition), 3600);
- string[] conditionList = condition.Split(new string[]{ " and " }, StringSplitOptions.None);
- foreach(string sub in conditionList)
- {
- string[] subCondition = sub.Split('=');
- fields += "," + subCondition[0];
- vals += "," + subCondition[1];
- }
- sql = "insert into " + table + " (" + fields + ") values (" + vals + ");\n";
- }
- else
- {
- string setVals = "";
- string[] fieldList = fields.Split(',');
- string[] valList = vals.Split(',');
- for (int i = 0; i < fieldList.Length; i++)
- {
- setVals += fieldList[i] + "=" + fieldList[i] + "+" + valList[i] + ",";
- }
- sql = "update " + table + " set " + setVals.TrimEnd(',') + " where " + condition + ";\n";
- }
- return sql;
- }
- public void StartCheck()
- {
- Thread th = new Thread(StartCheckDo);
- th.IsBackground = true;
- th.Start();
- }
- public void StartCheckDo()
- {
- while (true)
- {
- string content = RedisDbconn.Instance.RPop<string>("StatTradeCheck2Queue");
- if(!string.IsNullOrEmpty(content))
- {
- StatTradeAmountCheck2Do(content);
- StatTradeAmountCheck2BeforeDo(content);
- StatTradeAmountCheck2AfterDo(content);
-
- StatTradeAmountCheckDo(content);
- StatTradeAmountCheckBeforeDo(content);
- StatTradeAmountCheckAfterDo(content);
- Thread.Sleep(100);
- }
- else
- {
- Thread.Sleep(10000);
- }
- }
- }
- public void StatTradeAmountCheckDo(string date)
- {
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- try
- {
- date = date.Replace("-", "");
- WebCMSEntities db = new WebCMSEntities();
- List<TradeDaySummary> list = db.TradeDaySummary.Where(m => m.TradeDate == date).ToList();
- List<int> uids = list.Select(m => m.UserId).Distinct().ToList();
- var users = db.Users.Select(m => new { m.Id, m.ParentNav }).Where(m => uids.Contains(m.Id)).ToList();
- db.Dispose();
- foreach(TradeDaySummary sub in list.Where(m => m.SeoTitle == "team").ToList())
- {
- string puidstr = "," + sub.UserId + ",";
- List<int> subuids = users.Where(m => m.Id == sub.UserId || m.ParentNav.Contains(puidstr)).ToList().Select(m => m.Id).ToList();
- bool op = list.Any(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount);
- if(op)
- {
- decimal ProfitDirectTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDirectTradeAmt);
- decimal HelpDirectTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.HelpDirectTradeAmt);
- decimal NotHelpDirectTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.NotHelpDirectTradeAmt);
- decimal ProfitDirectDebitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDirectDebitTradeAmt);
- decimal ProfitDirectDebitCapTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDirectDebitCapTradeAmt);
- decimal ProfitDirectDebitCapNum = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDirectDebitCapNum);
- decimal HelpDirectDebitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.HelpDirectDebitTradeAmt);
- decimal HelpDirectDebitCapTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.HelpDirectDebitCapTradeAmt);
- decimal HelpDirectDebitCapNum = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.HelpDirectDebitCapNum);
- decimal NotHelpDirectDebitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.NotHelpDirectDebitTradeAmt);
- decimal NotHelpDirectDebitCapTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.NotHelpDirectDebitCapTradeAmt);
- decimal NotHelpDirectDebitCapNum = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.NotHelpDirectDebitCapNum);
-
- string setField = "";
- if(sub.ProfitNonDirectTradeAmt != ProfitDirectTradeAmt)
- {
- setField += "ProfitNonDirectTradeAmt=" + ProfitDirectTradeAmt + ",";
- }
- if(sub.HelpNonDirectTradeAmt != HelpDirectTradeAmt)
- {
- setField += "HelpNonDirectTradeAmt=" + HelpDirectTradeAmt + ",";
- }
- if(sub.NotHelpNonDirectTradeAmt != NotHelpDirectTradeAmt)
- {
- setField += "NotHelpNonDirectTradeAmt=" + NotHelpDirectTradeAmt + ",";
- }
- if(sub.ProfitNonDirectDebitTradeAmt != ProfitDirectDebitTradeAmt)
- {
- setField += "ProfitNonDirectDebitTradeAmt=" + ProfitDirectDebitTradeAmt + ",";
- }
- if(sub.ProfitDirectDebitCapTradeAmt != ProfitDirectDebitCapTradeAmt)
- {
- setField += "ProfitDirectDebitCapTradeAmt=" + ProfitDirectDebitCapTradeAmt + ",";
- }
- if(sub.ProfitDirectDebitCapNum != ProfitDirectDebitCapNum)
- {
- setField += "ProfitDirectDebitCapNum=" + ProfitDirectDebitCapNum + ",";
- }
- if(sub.HelpNonDirectDebitTradeAmt != HelpDirectDebitTradeAmt)
- {
- setField += "HelpNonDirectDebitTradeAmt=" + HelpDirectDebitTradeAmt + ",";
- }
- if(sub.HelpDirectDebitCapTradeAmt != HelpDirectDebitCapTradeAmt)
- {
- setField += "HelpDirectDebitCapTradeAmt=" + HelpDirectDebitCapTradeAmt + ",";
- }
- if(sub.HelpDirectDebitCapNum != HelpDirectDebitCapNum)
- {
- setField += "HelpDirectDebitCapNum=" + HelpDirectDebitCapNum + ",";
- }
- if(sub.NotHelpNonDirectDebitTradeAmt != NotHelpDirectDebitTradeAmt)
- {
- setField += "NotHelpNonDirectDebitTradeAmt=" + NotHelpDirectDebitTradeAmt + ",";
- }
- if(sub.NotHelpDirectDebitCapTradeAmt != NotHelpDirectDebitCapTradeAmt)
- {
- setField += "NotHelpDirectDebitCapTradeAmt=" + NotHelpDirectDebitCapTradeAmt + ",";
- }
- if(sub.NotHelpDirectDebitCapNum != NotHelpDirectDebitCapNum)
- {
- setField += "NotHelpDirectDebitCapNum=" + NotHelpDirectDebitCapNum + ",";
- }
- if(!string.IsNullOrEmpty(setField))
- {
- function.WriteLog("UserId:" + sub.UserId + "; TradeDate:" + sub.TradeDate + "; BrandId:" + sub.BrandId + ";", "交易不一致的创客");
- function.WriteLog("update TradeDaySummary set " + setField.TrimEnd(',') + " where Id=" + sub.Id, "要执行的sql脚本");
- }
- }
- }
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计交易额异常");
- }
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- }
- public void StatTradeAmountCheckBeforeDo(string date)
- {
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- try
- {
- date = date.Replace("-", "");
- WebCMSEntities db = new WebCMSEntities();
- List<TradeDaySummaryBefore> list = db.TradeDaySummaryBefore.Where(m => m.TradeDate == date).ToList();
- List<int> uids = list.Select(m => m.UserId).Distinct().ToList();
- var users = db.Users.Select(m => new { m.Id, m.ParentNav }).Where(m => uids.Contains(m.Id)).ToList();
- db.Dispose();
- foreach(TradeDaySummaryBefore sub in list.Where(m => m.SeoTitle == "team").ToList())
- {
- string puidstr = "," + sub.UserId + ",";
- List<int> subuids = users.Where(m => m.Id == sub.UserId || m.ParentNav.Contains(puidstr)).ToList().Select(m => m.Id).ToList();
- bool op = list.Any(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount);
- if(op)
- {
- decimal ProfitDirectTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDirectTradeAmt);
- decimal HelpDirectTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.HelpDirectTradeAmt);
- decimal NotHelpDirectTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.NotHelpDirectTradeAmt);
- decimal ProfitDirectDebitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDirectDebitTradeAmt);
- decimal ProfitDirectDebitCapTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDirectDebitCapTradeAmt);
- decimal ProfitDirectDebitCapNum = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDirectDebitCapNum);
- decimal HelpDirectDebitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.HelpDirectDebitTradeAmt);
- decimal HelpDirectDebitCapTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.HelpDirectDebitCapTradeAmt);
- decimal HelpDirectDebitCapNum = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.HelpDirectDebitCapNum);
- decimal NotHelpDirectDebitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.NotHelpDirectDebitTradeAmt);
- decimal NotHelpDirectDebitCapTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.NotHelpDirectDebitCapTradeAmt);
- decimal NotHelpDirectDebitCapNum = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.NotHelpDirectDebitCapNum);
-
- string setField = "";
- if(sub.ProfitNonDirectTradeAmt != ProfitDirectTradeAmt)
- {
- setField += "ProfitNonDirectTradeAmt=" + ProfitDirectTradeAmt + ",";
- }
- if(sub.HelpNonDirectTradeAmt != HelpDirectTradeAmt)
- {
- setField += "HelpNonDirectTradeAmt=" + HelpDirectTradeAmt + ",";
- }
- if(sub.NotHelpNonDirectTradeAmt != NotHelpDirectTradeAmt)
- {
- setField += "NotHelpNonDirectTradeAmt=" + NotHelpDirectTradeAmt + ",";
- }
- if(sub.ProfitNonDirectDebitTradeAmt != ProfitDirectDebitTradeAmt)
- {
- setField += "ProfitNonDirectDebitTradeAmt=" + ProfitDirectDebitTradeAmt + ",";
- }
- if(sub.ProfitDirectDebitCapTradeAmt != ProfitDirectDebitCapTradeAmt)
- {
- setField += "ProfitDirectDebitCapTradeAmt=" + ProfitDirectDebitCapTradeAmt + ",";
- }
- if(sub.ProfitDirectDebitCapNum != ProfitDirectDebitCapNum)
- {
- setField += "ProfitDirectDebitCapNum=" + ProfitDirectDebitCapNum + ",";
- }
- if(sub.HelpNonDirectDebitTradeAmt != HelpDirectDebitTradeAmt)
- {
- setField += "HelpNonDirectDebitTradeAmt=" + HelpDirectDebitTradeAmt + ",";
- }
- if(sub.HelpDirectDebitCapTradeAmt != HelpDirectDebitCapTradeAmt)
- {
- setField += "HelpDirectDebitCapTradeAmt=" + HelpDirectDebitCapTradeAmt + ",";
- }
- if(sub.HelpDirectDebitCapNum != HelpDirectDebitCapNum)
- {
- setField += "HelpDirectDebitCapNum=" + HelpDirectDebitCapNum + ",";
- }
- if(sub.NotHelpNonDirectDebitTradeAmt != NotHelpDirectDebitTradeAmt)
- {
- setField += "NotHelpNonDirectDebitTradeAmt=" + NotHelpDirectDebitTradeAmt + ",";
- }
- if(sub.NotHelpDirectDebitCapTradeAmt != NotHelpDirectDebitCapTradeAmt)
- {
- setField += "NotHelpDirectDebitCapTradeAmt=" + NotHelpDirectDebitCapTradeAmt + ",";
- }
- if(sub.NotHelpDirectDebitCapNum != NotHelpDirectDebitCapNum)
- {
- setField += "NotHelpDirectDebitCapNum=" + NotHelpDirectDebitCapNum + ",";
- }
- if(!string.IsNullOrEmpty(setField))
- {
- function.WriteLog("UserId:" + sub.UserId + "; TradeDate:" + sub.TradeDate + "; BrandId:" + sub.BrandId + ";", "交易不一致的创客");
- function.WriteLog("update TradeDaySummaryBefore set " + setField.TrimEnd(',') + " where Id=" + sub.Id, "要执行的sql脚本");
- }
- }
- }
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计交易额异常");
- }
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- }
- public void StatTradeAmountCheckAfterDo(string date)
- {
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- try
- {
- date = date.Replace("-", "");
- WebCMSEntities db = new WebCMSEntities();
- List<TradeDaySummaryAfter> list = db.TradeDaySummaryAfter.Where(m => m.TradeDate == date).ToList();
- List<int> uids = list.Select(m => m.UserId).Distinct().ToList();
- var users = db.Users.Select(m => new { m.Id, m.ParentNav }).Where(m => uids.Contains(m.Id)).ToList();
- db.Dispose();
- foreach(TradeDaySummaryAfter sub in list.Where(m => m.SeoTitle == "team").ToList())
- {
- string puidstr = "," + sub.UserId + ",";
- List<int> subuids = users.Where(m => m.Id == sub.UserId || m.ParentNav.Contains(puidstr)).ToList().Select(m => m.Id).ToList();
- bool op = list.Any(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount);
- if(op)
- {
- decimal ProfitDirectTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDirectTradeAmt);
- decimal HelpDirectTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.HelpDirectTradeAmt);
- decimal NotHelpDirectTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.NotHelpDirectTradeAmt);
- decimal ProfitDirectDebitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDirectDebitTradeAmt);
- decimal ProfitDirectDebitCapTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDirectDebitCapTradeAmt);
- decimal ProfitDirectDebitCapNum = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDirectDebitCapNum);
- decimal HelpDirectDebitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.HelpDirectDebitTradeAmt);
- decimal HelpDirectDebitCapTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.HelpDirectDebitCapTradeAmt);
- decimal HelpDirectDebitCapNum = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.HelpDirectDebitCapNum);
- decimal NotHelpDirectDebitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.NotHelpDirectDebitTradeAmt);
- decimal NotHelpDirectDebitCapTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.NotHelpDirectDebitCapTradeAmt);
- decimal NotHelpDirectDebitCapNum = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.NotHelpDirectDebitCapNum);
-
- string setField = "";
- if(sub.ProfitNonDirectTradeAmt != ProfitDirectTradeAmt)
- {
- setField += "ProfitNonDirectTradeAmt=" + ProfitDirectTradeAmt + ",";
- }
- if(sub.HelpNonDirectTradeAmt != HelpDirectTradeAmt)
- {
- setField += "HelpNonDirectTradeAmt=" + HelpDirectTradeAmt + ",";
- }
- if(sub.NotHelpNonDirectTradeAmt != NotHelpDirectTradeAmt)
- {
- setField += "NotHelpNonDirectTradeAmt=" + NotHelpDirectTradeAmt + ",";
- }
- if(sub.ProfitNonDirectDebitTradeAmt != ProfitDirectDebitTradeAmt)
- {
- setField += "ProfitNonDirectDebitTradeAmt=" + ProfitDirectDebitTradeAmt + ",";
- }
- if(sub.ProfitDirectDebitCapTradeAmt != ProfitDirectDebitCapTradeAmt)
- {
- setField += "ProfitDirectDebitCapTradeAmt=" + ProfitDirectDebitCapTradeAmt + ",";
- }
- if(sub.ProfitDirectDebitCapNum != ProfitDirectDebitCapNum)
- {
- setField += "ProfitDirectDebitCapNum=" + ProfitDirectDebitCapNum + ",";
- }
- if(sub.HelpNonDirectDebitTradeAmt != HelpDirectDebitTradeAmt)
- {
- setField += "HelpNonDirectDebitTradeAmt=" + HelpDirectDebitTradeAmt + ",";
- }
- if(sub.HelpDirectDebitCapTradeAmt != HelpDirectDebitCapTradeAmt)
- {
- setField += "HelpDirectDebitCapTradeAmt=" + HelpDirectDebitCapTradeAmt + ",";
- }
- if(sub.HelpDirectDebitCapNum != HelpDirectDebitCapNum)
- {
- setField += "HelpDirectDebitCapNum=" + HelpDirectDebitCapNum + ",";
- }
- if(sub.NotHelpNonDirectDebitTradeAmt != NotHelpDirectDebitTradeAmt)
- {
- setField += "NotHelpNonDirectDebitTradeAmt=" + NotHelpDirectDebitTradeAmt + ",";
- }
- if(sub.NotHelpDirectDebitCapTradeAmt != NotHelpDirectDebitCapTradeAmt)
- {
- setField += "NotHelpDirectDebitCapTradeAmt=" + NotHelpDirectDebitCapTradeAmt + ",";
- }
- if(sub.NotHelpDirectDebitCapNum != NotHelpDirectDebitCapNum)
- {
- setField += "NotHelpDirectDebitCapNum=" + NotHelpDirectDebitCapNum + ",";
- }
- if(!string.IsNullOrEmpty(setField))
- {
- function.WriteLog("UserId:" + sub.UserId + "; TradeDate:" + sub.TradeDate + "; BrandId:" + sub.BrandId + ";", "交易不一致的创客");
- function.WriteLog("update TradeDaySummaryAfter set " + setField.TrimEnd(',') + " where Id=" + sub.Id, "要执行的sql脚本");
- }
- }
- }
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计交易额异常");
- }
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- }
- public void StatTradeAmountCheck2Do(string date)
- {
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- try
- {
- date = date.Replace("-", "");
- WebCMSEntities db = new WebCMSEntities();
- List<TradeDaySummary2> list = db.TradeDaySummary2.Where(m => m.TradeDate == date).ToList();
- List<int> uids = list.Select(m => m.UserId).Distinct().ToList();
- var users = db.Users.Select(m => new { m.Id, m.ParentNav }).Where(m => uids.Contains(m.Id)).ToList();
- db.Dispose();
- foreach(TradeDaySummary2 sub in list.Where(m => m.SeoTitle == "team").ToList())
- {
- string puidstr = "," + sub.UserId + ",";
- List<int> subuids = users.Where(m => m.Id == sub.UserId || m.ParentNav.Contains(puidstr)).ToList().Select(m => m.Id).ToList();
- bool op = list.Any(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount);
- if(op)
- {
- decimal ProfitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitTradeAmt);
- decimal ProfitDebitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDebitTradeAmt);
- decimal ProfitDebitCapTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDebitCapTradeAmt);
- decimal ProfitDebitCapNum = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDebitCapNum);
- if(sub.ProfitTradeAmt != ProfitTradeAmt || sub.ProfitDebitTradeAmt != ProfitDebitTradeAmt || sub.ProfitDebitCapTradeAmt != ProfitDebitCapTradeAmt || sub.ProfitDebitCapNum != ProfitDebitCapNum)
- {
- function.WriteLog("UserId:" + sub.UserId + "; TradeDate:" + sub.TradeDate + "; BrandId:" + sub.BrandId + "; ProfitTradeAmt:" + sub.ProfitTradeAmt + "-" + ProfitTradeAmt + "; ProfitDebitTradeAmt:" + sub.ProfitDebitTradeAmt + "-" + ProfitDebitTradeAmt + "; ProfitDebitCapTradeAmt:" + sub.ProfitDebitCapTradeAmt + "-" + ProfitDebitCapTradeAmt + "; ProfitDebitCapNum:" + sub.ProfitDebitCapNum + "-" + ProfitDebitCapNum + ";", "交易不一致的创客");
- function.WriteLog("update TradeDaySummary2 set ProfitTradeAmt=" + ProfitTradeAmt + ",ProfitDebitTradeAmt=" + ProfitDebitTradeAmt + ",ProfitDebitCapTradeAmt=" + ProfitDebitCapTradeAmt + ",ProfitDebitCapNum=" + ProfitDebitCapNum + " where Id=" + sub.Id, "要执行的sql脚本");
- }
- }
- }
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计交易额异常");
- }
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- }
- public void StatTradeAmountCheck2BeforeDo(string date)
- {
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- try
- {
- date = date.Replace("-", "");
- WebCMSEntities db = new WebCMSEntities();
- List<TradeDaySummary2Before> list = db.TradeDaySummary2Before.Where(m => m.TradeDate == date).ToList();
- List<int> uids = list.Select(m => m.UserId).Distinct().ToList();
- var users = db.Users.Select(m => new { m.Id, m.ParentNav }).Where(m => uids.Contains(m.Id)).ToList();
- db.Dispose();
- foreach(TradeDaySummary2Before sub in list.Where(m => m.SeoTitle == "team").ToList())
- {
- string puidstr = "," + sub.UserId + ",";
- List<int> subuids = users.Where(m => m.Id == sub.UserId || m.ParentNav.Contains(puidstr)).ToList().Select(m => m.Id).ToList();
- bool op = list.Any(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount);
- if(op)
- {
- decimal ProfitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitTradeAmt);
- decimal ProfitDebitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDebitTradeAmt);
- decimal ProfitDebitCapTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDebitCapTradeAmt);
- decimal ProfitDebitCapNum = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDebitCapNum);
- if(sub.ProfitTradeAmt != ProfitTradeAmt || sub.ProfitDebitTradeAmt != ProfitDebitTradeAmt || sub.ProfitDebitCapTradeAmt != ProfitDebitCapTradeAmt || sub.ProfitDebitCapNum != ProfitDebitCapNum)
- {
- function.WriteLog("UserId:" + sub.UserId + "; TradeDate:" + sub.TradeDate + "; BrandId:" + sub.BrandId + "; ProfitTradeAmt:" + sub.ProfitTradeAmt + "-" + ProfitTradeAmt + "; ProfitDebitTradeAmt:" + sub.ProfitDebitTradeAmt + "-" + ProfitDebitTradeAmt + "; ProfitDebitCapTradeAmt:" + sub.ProfitDebitCapTradeAmt + "-" + ProfitDebitCapTradeAmt + "; ProfitDebitCapNum:" + sub.ProfitDebitCapNum + "-" + ProfitDebitCapNum + ";", "交易不一致的创客");
- function.WriteLog("update TradeDaySummary2Before set ProfitTradeAmt=" + ProfitTradeAmt + ",ProfitDebitTradeAmt=" + ProfitDebitTradeAmt + ",ProfitDebitCapTradeAmt=" + ProfitDebitCapTradeAmt + ",ProfitDebitCapNum=" + ProfitDebitCapNum + " where Id=" + sub.Id, "要执行的sql脚本");
- }
- }
- }
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计交易额异常");
- }
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- }
- public void StatTradeAmountCheck2AfterDo(string date)
- {
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- try
- {
- date = date.Replace("-", "");
- WebCMSEntities db = new WebCMSEntities();
- List<TradeDaySummary2After> list = db.TradeDaySummary2After.Where(m => m.TradeDate == date).ToList();
- List<int> uids = list.Select(m => m.UserId).Distinct().ToList();
- var users = db.Users.Select(m => new { m.Id, m.ParentNav }).Where(m => uids.Contains(m.Id)).ToList();
- db.Dispose();
- foreach(TradeDaySummary2After sub in list.Where(m => m.SeoTitle == "team").ToList())
- {
- string puidstr = "," + sub.UserId + ",";
- List<int> subuids = users.Where(m => m.Id == sub.UserId || m.ParentNav.Contains(puidstr)).ToList().Select(m => m.Id).ToList();
- bool op = list.Any(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount);
- if(op)
- {
- decimal ProfitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitTradeAmt);
- decimal ProfitDebitTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDebitTradeAmt);
- decimal ProfitDebitCapTradeAmt = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDebitCapTradeAmt);
- decimal ProfitDebitCapNum = list.Where(m => subuids.Contains(m.UserId) && m.BrandId == sub.BrandId && m.TradeDate == sub.TradeDate && m.SeoTitle == "self" && m.PayType == sub.PayType && m.VipFlag == sub.VipFlag && m.QueryCount == sub.QueryCount).Sum(m => m.ProfitDebitCapNum);
- if(sub.ProfitTradeAmt != ProfitTradeAmt || sub.ProfitDebitTradeAmt != ProfitDebitTradeAmt || sub.ProfitDebitCapTradeAmt != ProfitDebitCapTradeAmt || sub.ProfitDebitCapNum != ProfitDebitCapNum)
- {
- function.WriteLog("UserId:" + sub.UserId + "; TradeDate:" + sub.TradeDate + "; BrandId:" + sub.BrandId + "; ProfitTradeAmt:" + sub.ProfitTradeAmt + "-" + ProfitTradeAmt + "; ProfitDebitTradeAmt:" + sub.ProfitDebitTradeAmt + "-" + ProfitDebitTradeAmt + "; ProfitDebitCapTradeAmt:" + sub.ProfitDebitCapTradeAmt + "-" + ProfitDebitCapTradeAmt + "; ProfitDebitCapNum:" + sub.ProfitDebitCapNum + "-" + ProfitDebitCapNum + ";", "交易不一致的创客");
- function.WriteLog("update TradeDaySummary2After set ProfitTradeAmt=" + ProfitTradeAmt + ",ProfitDebitTradeAmt=" + ProfitDebitTradeAmt + ",ProfitDebitCapTradeAmt=" + ProfitDebitCapTradeAmt + ",ProfitDebitCapNum=" + ProfitDebitCapNum + " where Id=" + sub.Id, "要执行的sql脚本");
- }
- }
- }
- }
- catch (Exception ex)
- {
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计交易额异常");
- }
- function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计交易额日志");
- }
- }
- }
|