|
|
@@ -173,7 +173,7 @@ namespace MySystem
|
|
|
{
|
|
|
StartUserTradeGo();
|
|
|
}
|
|
|
- Thread.Sleep(3000);
|
|
|
+ Thread.Sleep(30000);
|
|
|
}
|
|
|
}
|
|
|
public void StartUserTradeGo()
|
|
|
@@ -185,53 +185,61 @@ namespace MySystem
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- string startId = function.ReadInstance("/TradeRecord/HelpProfitMerchantForUserId.txt");
|
|
|
- if (string.IsNullOrEmpty(startId))
|
|
|
- {
|
|
|
- startId = "0";
|
|
|
- }
|
|
|
- DataTable idsDt = OtherMySqlConn.dtable("select Id from HelpProfitMerchantForUser where Id>=" + startId + " and Status=0 order by Id limit 50");
|
|
|
- if (idsDt.Rows.Count > 0)
|
|
|
+ bool op = true;
|
|
|
+ while(op)
|
|
|
{
|
|
|
- string ids = "";
|
|
|
- foreach (DataRow idsDr in idsDt.Rows)
|
|
|
+ string startId = function.ReadInstance("/TradeRecord/HelpProfitMerchantForUserId.txt");
|
|
|
+ if (string.IsNullOrEmpty(startId))
|
|
|
{
|
|
|
- ids += idsDr["Id"].ToString() + ",";
|
|
|
- startId = idsDr["Id"].ToString();
|
|
|
+ startId = "0";
|
|
|
}
|
|
|
- DataTable selfDt = OtherMySqlConn.dtable("select UserId,DATE_FORMAT(CreateDate,'%Y%m'),count(Id) from HelpProfitMerchantForUser where Id in (" + ids.TrimEnd(',') + ") group by UserId,DATE_FORMAT(CreateDate,'%Y%m')");
|
|
|
- if (selfDt.Rows.Count > 0)
|
|
|
+ DataTable idsDt = OtherMySqlConn.dtable("select Id from HelpProfitMerchantForUser where Id>=" + startId + " and Status=0 order by Id limit 50");
|
|
|
+ if (idsDt.Rows.Count > 0)
|
|
|
{
|
|
|
- function.WriteLog("统计人数:" + selfDt.Rows.Count + "\n\n", "实时统计助利宝创客交易额日志");
|
|
|
- foreach (DataRow selfDr in selfDt.Rows)
|
|
|
+ string ids = "";
|
|
|
+ foreach (DataRow idsDr in idsDt.Rows)
|
|
|
{
|
|
|
- int UserId = int.Parse(selfDr["UserId"].ToString());
|
|
|
- string TradeMonth = selfDr[1].ToString();
|
|
|
- int MerCount = int.Parse(selfDr[2].ToString());
|
|
|
- HelpProfitAmountSummary selfStat = db.HelpProfitAmountSummary.FirstOrDefault(m => m.UserId == UserId && m.TradeMonth == TradeMonth);
|
|
|
- if (selfStat == null)
|
|
|
+ ids += idsDr["Id"].ToString() + ",";
|
|
|
+ startId = idsDr["Id"].ToString();
|
|
|
+ }
|
|
|
+ DataTable selfDt = OtherMySqlConn.dtable("select UserId,DATE_FORMAT(CreateDate,'%Y%m'),count(Id) from HelpProfitMerchantForUser where Id in (" + ids.TrimEnd(',') + ") group by UserId,DATE_FORMAT(CreateDate,'%Y%m')");
|
|
|
+ if (selfDt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ function.WriteLog("统计人数:" + selfDt.Rows.Count + "\n\n", "实时统计助利宝创客交易额日志");
|
|
|
+ foreach (DataRow selfDr in selfDt.Rows)
|
|
|
{
|
|
|
- int CheckMonth = db.HelpProfitAmountSummary.Count(m => m.UserId == UserId && Convert.ToInt32(m.TradeMonth) <= Convert.ToInt32(TradeMonth));
|
|
|
- selfStat = db.HelpProfitAmountSummary.Add(new HelpProfitAmountSummary()
|
|
|
+ int UserId = int.Parse(selfDr["UserId"].ToString());
|
|
|
+ string TradeMonth = selfDr[1].ToString();
|
|
|
+ int MerCount = int.Parse(selfDr[2].ToString());
|
|
|
+ HelpProfitAmountSummary selfStat = db.HelpProfitAmountSummary.FirstOrDefault(m => m.UserId == UserId && m.TradeMonth == TradeMonth);
|
|
|
+ if (selfStat == null)
|
|
|
{
|
|
|
- TradeMonth = TradeMonth,
|
|
|
- UserId = UserId,
|
|
|
- QueryCount = CheckMonth + 1,
|
|
|
- }).Entity;
|
|
|
- db.SaveChanges();
|
|
|
- }
|
|
|
- selfStat.MerCount += MerCount;
|
|
|
- int Month = selfStat.QueryCount;
|
|
|
- if(Month > 24)
|
|
|
- {
|
|
|
- Month = 24;
|
|
|
+ int CheckMonth = db.HelpProfitAmountSummary.Count(m => m.UserId == UserId && Convert.ToInt32(m.TradeMonth) <= Convert.ToInt32(TradeMonth));
|
|
|
+ selfStat = db.HelpProfitAmountSummary.Add(new HelpProfitAmountSummary()
|
|
|
+ {
|
|
|
+ TradeMonth = TradeMonth,
|
|
|
+ UserId = UserId,
|
|
|
+ QueryCount = CheckMonth + 1,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ selfStat.MerCount += MerCount;
|
|
|
+ int Month = selfStat.QueryCount;
|
|
|
+ if(Month > 24)
|
|
|
+ {
|
|
|
+ Month = 24;
|
|
|
+ }
|
|
|
+ selfStat.MaxAmount += EveryMonthFixedVal()[Month] * MerCount;
|
|
|
}
|
|
|
- selfStat.MaxAmount += EveryMonthFixedVal()[Month] * MerCount;
|
|
|
+ OtherMySqlConn.op("update HelpProfitMerchantForUser set Status=1 where Id in (" + ids.TrimEnd(',') + ")");
|
|
|
+ function.WritePage("/TradeRecord/", "HelpProfitMerchantForUserId.txt", startId);
|
|
|
}
|
|
|
- OtherMySqlConn.op("update HelpProfitMerchantForUser set Status=1 where Id in (" + ids.TrimEnd(',') + ")");
|
|
|
- function.WritePage("/TradeRecord/", "HelpProfitMerchantForUserId.txt", startId);
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ op = false;
|
|
|
}
|
|
|
- db.SaveChanges();
|
|
|
}
|
|
|
tran.Commit();
|
|
|
}
|
|
|
@@ -360,14 +368,18 @@ namespace MySystem
|
|
|
{
|
|
|
MonthAmount3 = EveryMonthFixedVal()[Month - 2]; //上上月额度
|
|
|
}
|
|
|
- List<int> MerCounts = new List<int>(); //近2月月台数,不包含当月
|
|
|
+ List<int> MerCounts = new List<int>(); //近3月月台数,包含当月
|
|
|
+ List<decimal> MaxTradeAmounts = new List<decimal>(); //近3月最大额度,包含当月
|
|
|
int MerCount1 = 0; //本月台数
|
|
|
int MerCount2 = 0; //上月台数
|
|
|
int MerCount3 = 0; //上上月台数
|
|
|
+ decimal PreMaxTradeAmount = 0; //上月最大额度
|
|
|
+ decimal PreTradeAmount = 0; //上月创客交易额
|
|
|
List<HelpProfitAmountSummary> Summarys = db.HelpProfitAmountSummary.Where(m => m.UserId == UserId && Convert.ToInt32(m.TradeMonth) <= Convert.ToInt32(TradeMonth)).OrderByDescending(m => m.TradeMonth).Take(3).ToList();
|
|
|
foreach(HelpProfitAmountSummary Summary in Summarys)
|
|
|
{
|
|
|
MerCounts.Add(Summary.MerCount);
|
|
|
+ MaxTradeAmounts.Add(Summary.MaxAmount);
|
|
|
}
|
|
|
if(MerCounts.Count > 0)
|
|
|
{
|
|
|
@@ -376,12 +388,20 @@ namespace MySystem
|
|
|
if(MerCounts.Count > 1)
|
|
|
{
|
|
|
MerCount2 = MerCounts[1];
|
|
|
+ PreMaxTradeAmount = MaxTradeAmounts[1];
|
|
|
+ string PreMonthString = DateTime.Parse(TradeMonth.Substring(0, 4) + "-" + TradeMonth.Substring(4, 2) + "-01").AddMonths(-1).ToString("yyyyMM");
|
|
|
+ DataTable dt = OtherMySqlConn.dtable("SELECT SUM(TradeAmount) TradeAmount FROM HelpProfitMerTradeSummay WHERE MerchantId IN(SELECT MerchantId FROM HelpProfitMerIds WHERE UserId=" + UserId + ") AND TradeMonth=" + PreMonthString + "");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ PreTradeAmount = decimal.Parse(function.CheckNum(dt.Rows[0]["TradeAmount"].ToString()));
|
|
|
+ }
|
|
|
}
|
|
|
if(MerCounts.Count > 2)
|
|
|
{
|
|
|
MerCount3 = MerCounts[2];
|
|
|
}
|
|
|
decimal MaxTradeAmount = MerCount1 * MonthAmount1 + MerCount2 * MonthAmount2 + MerCount3 * MonthAmount3; //当月最大交易总额
|
|
|
+ MaxTradeAmount = PreMaxTradeAmount - PreTradeAmount + MaxTradeAmount; //上月最大额度-实际交易额+本月最大交易额
|
|
|
HelpProfitAmountSummary selfStat = db.HelpProfitAmountSummary.FirstOrDefault(m => m.UserId == UserId && m.TradeMonth == TradeMonth);
|
|
|
if(selfStat == null)
|
|
|
{
|