|
@@ -1182,7 +1182,7 @@ namespace MySystem
|
|
|
public void StartEverDayDo()
|
|
|
{
|
|
|
DateTime end = DateTime.Parse("2022-06-06 00:00:00");
|
|
|
- DateTime check = DateTime.Parse("2022-03-11");
|
|
|
+ DateTime check = DateTime.Parse("2022-04-30");
|
|
|
while (check <= end)
|
|
|
{
|
|
|
StatTradeAmountEverDay(check.ToString("yyyy-MM-dd"));
|
|
@@ -1751,8 +1751,8 @@ namespace MySystem
|
|
|
}
|
|
|
public void StartPosActNumFor()
|
|
|
{
|
|
|
- DateTime end = DateTime.Parse("2022-05-26 00:00:00");
|
|
|
- DateTime check = DateTime.Parse("2022-03-11");
|
|
|
+ DateTime end = DateTime.Parse("2022-06-06 00:00:00");
|
|
|
+ DateTime check = DateTime.Parse("2022-05-27");
|
|
|
while (check <= end)
|
|
|
{
|
|
|
StartPosActNumDo(check.ToString("yyyy-MM-dd"));
|
|
@@ -1862,8 +1862,8 @@ namespace MySystem
|
|
|
}
|
|
|
public void StartNewUserNumFor()
|
|
|
{
|
|
|
- DateTime end = DateTime.Parse("2022-05-26 00:00:00");
|
|
|
- DateTime check = DateTime.Parse("2022-02-20");
|
|
|
+ DateTime end = DateTime.Parse("2022-06-06 00:00:00");
|
|
|
+ DateTime check = DateTime.Parse("2022-05-27");
|
|
|
while (check <= end)
|
|
|
{
|
|
|
StartNewUserNumDo(check.ToString("yyyy-MM-dd"));
|
|
@@ -1958,6 +1958,124 @@ namespace MySystem
|
|
|
|
|
|
|
|
|
|
|
|
+ // 每天统计头一天的收益
|
|
|
+ public void StatProfit(string date)
|
|
|
+ {
|
|
|
+ OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
|
|
|
+ Thread th = new Thread(StatProfitDo);
|
|
|
+ th.IsBackground = true;
|
|
|
+ th.Start();
|
|
|
+ }
|
|
|
+ public void StatProfitDo()
|
|
|
+ {
|
|
|
+ DateTime end = DateTime.Parse("2022-06-06 00:00:00");
|
|
|
+ DateTime check = DateTime.Parse("2022-03-18");
|
|
|
+ while (check <= end)
|
|
|
+ {
|
|
|
+ StatProfitEverDay(check.ToString("yyyy-MM-dd"));
|
|
|
+ Thread.Sleep(1000);
|
|
|
+ check = check.AddDays(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ public void StatProfitEverDay(object sender)
|
|
|
+ {
|
|
|
+ string date = sender.ToString();
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "执行昨天收益日志");
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string TradeDate = date.Replace("-", "");
|
|
|
+ string TradeMonth = TradeDate.Substring(0, 6);
|
|
|
+ string start = date + " 00:00:00";
|
|
|
+ string end = DateTime.Parse(date).AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00";
|
|
|
+ string startId = "0";
|
|
|
+ List<string> uids = new List<string>();
|
|
|
+ DataTable startDt = OtherMySqlConn.dtable("select min(Id) from UserAccountRecord where CreateDate>='" + start + "'");
|
|
|
+ if (startDt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ startId = startDt.Rows[0][0].ToString();
|
|
|
+ }
|
|
|
+ function.WriteLog(startId + "\n\n", "执行昨天收益日志");
|
|
|
+ DataTable userDt = OtherMySqlConn.dtable("select Id,ParentNav from Users where Id in (select DISTINCT UserId from UserAccountRecord where Id>=" + startId + " and CreateDate>='" + start + "' and CreateDate<'" + end + "')");
|
|
|
+ function.WriteLog("交易人数:" + userDt.Rows.Count + "\n\n", "执行昨天收益日志");
|
|
|
+ foreach (DataRow userDr in userDt.Rows)
|
|
|
+ {
|
|
|
+ int UserId = int.Parse(userDr["Id"].ToString());
|
|
|
+ string ParentNav = userDr["ParentNav"].ToString();
|
|
|
+ function.WriteLog(UserId + ":" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "执行昨天收益日志");
|
|
|
+ DataTable selfdt = OtherMySqlConn.dtable("select ChangeType,ProductType,sum(ChangeAmount) from UserAccountRecord where Id>=" + startId + " and CreateDate>='" + start + "' and CreateDate<'" + end + "' and UserId=" + UserId + " group by ChangeType,ProductType");
|
|
|
+ function.WriteLog(UserId + ":" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "执行昨天收益日志");
|
|
|
+ foreach (DataRow selfDr in selfdt.Rows)
|
|
|
+ {
|
|
|
+ int ChangeType = int.Parse(selfDr["ChangeType"].ToString());
|
|
|
+ int ProductType = int.Parse(selfDr["ProductType"].ToString());
|
|
|
+ decimal ProfitAmount = decimal.Parse(selfDr[2].ToString());
|
|
|
+ UserRebateDetail selfStat = db.UserRebateDetail.FirstOrDefault(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.TradeDate == TradeDate && m.RebateType == ChangeType && m.ProductType == ProductType && m.SeoTitle == "self");
|
|
|
+ if (selfStat == null)
|
|
|
+ {
|
|
|
+ selfStat = db.UserRebateDetail.Add(new UserRebateDetail()
|
|
|
+ {
|
|
|
+ UserId = UserId,
|
|
|
+ TradeMonth = TradeMonth,
|
|
|
+ TradeDate = TradeDate,
|
|
|
+ RebateType = ChangeType,
|
|
|
+ ProductType = ProductType,
|
|
|
+ SeoTitle = "self",
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ selfStat.CreditRewardAmount += ProfitAmount;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrEmpty(ParentNav))
|
|
|
+ {
|
|
|
+ ParentNav += "," + UserId + ",";
|
|
|
+ string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
|
|
|
+ foreach (string NavUserIdString in ParentNavList)
|
|
|
+ {
|
|
|
+ if (!uids.Contains(NavUserIdString + start))
|
|
|
+ {
|
|
|
+ uids.Add(NavUserIdString + start);
|
|
|
+ int NavUserId = int.Parse(NavUserIdString);
|
|
|
+ function.WriteLog(NavUserId + ":team:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "执行昨天收益日志");
|
|
|
+ DataTable teamDt = OtherMySqlConn.dtable("select ChangeType,ProductType,sum(ChangeAmount) from UserAccountRecord where Id>=" + startId + " and CreateDate>='" + start + "' and CreateDate<'" + end + "' and UserId in (select Id from Users where ParentNav like '%," + NavUserId + ",%' or Id=" + NavUserId + ") group by ChangeType,ProductType");
|
|
|
+ function.WriteLog(NavUserId + ":team:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "执行昨天收益日志");
|
|
|
+ foreach (DataRow teamDr in teamDt.Rows)
|
|
|
+ {
|
|
|
+ int ChangeType = int.Parse(teamDr["ChangeType"].ToString());
|
|
|
+ int ProductType = int.Parse(teamDr["ProductType"].ToString());
|
|
|
+ decimal ProfitAmount = decimal.Parse(teamDr[2].ToString());
|
|
|
+ UserRebateDetail teamStat = db.UserRebateDetail.FirstOrDefault(m => m.UserId == NavUserId && m.TradeMonth == TradeMonth && m.TradeDate == TradeDate && m.RebateType == ChangeType && m.ProductType == ProductType && m.SeoTitle == "team");
|
|
|
+ if (teamStat == null)
|
|
|
+ {
|
|
|
+ teamStat = db.UserRebateDetail.Add(new UserRebateDetail()
|
|
|
+ {
|
|
|
+ UserId = NavUserId,
|
|
|
+ TradeMonth = TradeMonth,
|
|
|
+ TradeDate = TradeDate,
|
|
|
+ RebateType = ChangeType,
|
|
|
+ ProductType = ProductType,
|
|
|
+ SeoTitle = "team",
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ teamStat.CreditRewardAmount += ProfitAmount;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "统计昨天收益异常");
|
|
|
+ }
|
|
|
+ db.Dispose();
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "执行昨天收益日志");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|