|
|
@@ -93,18 +93,6 @@ namespace MySystem
|
|
|
MoreAmount = decimal.Parse(function.CheckInt(MoreAmount.ToString().Split(".")[0]));
|
|
|
// }
|
|
|
selfStat.TradeAmount += TradeAmount + MoreAmount;
|
|
|
-
|
|
|
- HelpProfitAmountSummary profitStat = db.HelpProfitAmountSummary.FirstOrDefault(m => m.UserId == merIds.UserId && m.TradeMonth == TradeMonth);
|
|
|
- if (profitStat == null)
|
|
|
- {
|
|
|
- profitStat = db.HelpProfitAmountSummary.Add(new HelpProfitAmountSummary()
|
|
|
- {
|
|
|
- TradeMonth = TradeMonth,
|
|
|
- UserId = merIds.UserId,
|
|
|
- }).Entity;
|
|
|
- db.SaveChanges();
|
|
|
- }
|
|
|
- profitStat.TradeAmount += TradeAmount;
|
|
|
}
|
|
|
}
|
|
|
OtherMySqlConn.op("update TradeRecord set QueryCount=3 where Id in (" + ids.TrimEnd(',') + ")");
|
|
|
@@ -124,6 +112,52 @@ namespace MySystem
|
|
|
function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "实时执行助利宝交易额日志");
|
|
|
}
|
|
|
|
|
|
+ public void StatTradeAmountTmp()
|
|
|
+ {
|
|
|
+ OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "实时执行助利宝交易额日志");
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
+ using (var tran = db.Database.BeginTransaction())
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ DataTable selfDt = OtherMySqlConn.dtable("select MerchantId,DATE_FORMAT(CreateDate,'%Y%m'),sum(TradeAmount) from TradeRecord where CreateDate>='2022-09-05 00:00:00' and MerchantId in (select MerchantId from HelpProfitMerIds) and SeoTitle='HelpProfit' group by MerchantId,DATE_FORMAT(CreateDate,'%Y%m') order by MerchantId,DATE_FORMAT(CreateDate,'%Y%m')");
|
|
|
+ if (selfDt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ function.WriteLog("统计人数:" + selfDt.Rows.Count + "\n\n", "实时执行助利宝交易额日志");
|
|
|
+ foreach (DataRow selfDr in selfDt.Rows)
|
|
|
+ {
|
|
|
+ int MerchantId = int.Parse(selfDr["MerchantId"].ToString());
|
|
|
+ string TradeMonth = selfDr[1].ToString();
|
|
|
+ decimal TradeAmount = decimal.Parse(selfDr[2].ToString());
|
|
|
+ HelpProfitMerIds merIds = db.HelpProfitMerIds.FirstOrDefault(m => m.MerchantId == MerchantId) ?? new HelpProfitMerIds();
|
|
|
+ HelpProfitAmountSummary profitStat = db.HelpProfitAmountSummary.FirstOrDefault(m => m.UserId == merIds.UserId && m.TradeMonth == TradeMonth);
|
|
|
+ if (profitStat == null)
|
|
|
+ {
|
|
|
+ int Month = db.HelpProfitAmountSummary.Count(m => m.UserId == merIds.UserId && Convert.ToInt32(m.TradeMonth) <= Convert.ToInt32(TradeMonth));
|
|
|
+ profitStat = db.HelpProfitAmountSummary.Add(new HelpProfitAmountSummary()
|
|
|
+ {
|
|
|
+ TradeMonth = TradeMonth,
|
|
|
+ UserId = merIds.UserId,
|
|
|
+ QueryCount = Month + 1,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ profitStat.TradeAmount += TradeAmount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ db.SaveChanges();
|
|
|
+ tran.Commit();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ tran.Rollback();
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "实时执行助利宝交易额2异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ db.Dispose();
|
|
|
+ }
|
|
|
+
|
|
|
// 统计创客商机台数
|
|
|
public void StartUserTrade()
|
|
|
{
|
|
|
@@ -135,11 +169,11 @@ namespace MySystem
|
|
|
{
|
|
|
while (true)
|
|
|
{
|
|
|
- if (DateTime.Now.Hour >= 3)
|
|
|
- {
|
|
|
+ // if (DateTime.Now.Hour >= 3)
|
|
|
+ // {
|
|
|
StartUserTradeGo();
|
|
|
- }
|
|
|
- Thread.Sleep(30000);
|
|
|
+ // }
|
|
|
+ Thread.Sleep(3000);
|
|
|
}
|
|
|
}
|
|
|
public void StartUserTradeGo()
|
|
|
@@ -177,15 +211,22 @@ namespace MySystem
|
|
|
HelpProfitAmountSummary selfStat = db.HelpProfitAmountSummary.FirstOrDefault(m => m.UserId == UserId && m.TradeMonth == TradeMonth);
|
|
|
if (selfStat == null)
|
|
|
{
|
|
|
+ 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;
|
|
|
- selfStat.MaxAmount += EveryMonthFixedVal()[selfStat.QueryCount] * MerCount;
|
|
|
+ int Month = selfStat.QueryCount;
|
|
|
+ if(Month > 24)
|
|
|
+ {
|
|
|
+ Month = 24;
|
|
|
+ }
|
|
|
+ selfStat.MaxAmount += EveryMonthFixedVal()[Month] * MerCount;
|
|
|
}
|
|
|
OtherMySqlConn.op("update HelpProfitMerchantForUser set Status=1 where Id in (" + ids.TrimEnd(',') + ")");
|
|
|
function.WritePage("/TradeRecord/", "HelpProfitMerchantForUserId.txt", startId);
|
|
|
@@ -236,30 +277,30 @@ namespace MySystem
|
|
|
{
|
|
|
Dictionary<int, decimal> obj = new Dictionary<int, decimal>();
|
|
|
obj.Add(0, 0M);
|
|
|
- obj.Add(1, 7M);
|
|
|
- obj.Add(2, 6M);
|
|
|
- obj.Add(3, 5M);
|
|
|
- obj.Add(4, 4M);
|
|
|
- obj.Add(5, 3M);
|
|
|
- obj.Add(6, 3M);
|
|
|
- obj.Add(7, 2.7M);
|
|
|
- obj.Add(8, 2.5M);
|
|
|
- obj.Add(9, 2M);
|
|
|
- obj.Add(10, 1.7M);
|
|
|
- obj.Add(11, 1.4M);
|
|
|
- obj.Add(12, 1.4M);
|
|
|
- obj.Add(13, 1.3M);
|
|
|
- obj.Add(14, 1.2M);
|
|
|
- obj.Add(15, 1.2M);
|
|
|
- obj.Add(16, 1M);
|
|
|
- obj.Add(17, 0.8M);
|
|
|
- obj.Add(18, 0.7M);
|
|
|
- obj.Add(19, 0.6M);
|
|
|
- obj.Add(20, 0.5M);
|
|
|
- obj.Add(21, 0.4M);
|
|
|
- obj.Add(22, 0.3M);
|
|
|
- obj.Add(23, 0.2M);
|
|
|
- obj.Add(24, 0.1M);
|
|
|
+ obj.Add(1, 70000M);
|
|
|
+ obj.Add(2, 60000M);
|
|
|
+ obj.Add(3, 50000M);
|
|
|
+ obj.Add(4, 40000M);
|
|
|
+ obj.Add(5, 30000M);
|
|
|
+ obj.Add(6, 30000M);
|
|
|
+ obj.Add(7, 27000M);
|
|
|
+ obj.Add(8, 25000M);
|
|
|
+ obj.Add(9, 20000M);
|
|
|
+ obj.Add(10, 17000M);
|
|
|
+ obj.Add(11, 14000M);
|
|
|
+ obj.Add(12, 14000M);
|
|
|
+ obj.Add(13, 13000M);
|
|
|
+ obj.Add(14, 12000M);
|
|
|
+ obj.Add(15, 12000M);
|
|
|
+ obj.Add(16, 10000M);
|
|
|
+ obj.Add(17, 8000M);
|
|
|
+ obj.Add(18, 7000M);
|
|
|
+ obj.Add(19, 6000M);
|
|
|
+ obj.Add(20, 5000M);
|
|
|
+ obj.Add(21, 4000M);
|
|
|
+ obj.Add(22, 3000M);
|
|
|
+ obj.Add(23, 2000M);
|
|
|
+ obj.Add(24, 1000M);
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
@@ -277,91 +318,82 @@ namespace MySystem
|
|
|
{
|
|
|
if (DateTime.Now.Hour > 0 && DateTime.Now.Hour < 3)
|
|
|
{
|
|
|
- ResetMaxTradeAmountGo();
|
|
|
+ string TradeMonth = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
|
|
|
+ ResetMaxTradeAmountGo(TradeMonth);
|
|
|
}
|
|
|
Thread.Sleep(30000);
|
|
|
}
|
|
|
}
|
|
|
- public void ResetMaxTradeAmountGo()
|
|
|
+ public void ResetMaxTradeAmountGo(string TradeMonth)
|
|
|
{
|
|
|
- while(true)
|
|
|
+ try
|
|
|
{
|
|
|
- try
|
|
|
+ string CheckExist = function.ReadInstance("/HelpProfitAmountSummary/" + TradeMonth + ".txt");
|
|
|
+ if(string.IsNullOrEmpty(CheckExist))
|
|
|
{
|
|
|
- string TradeMonth = DateTime.Now.ToString("yyyyMM");
|
|
|
- string CheckExist = function.ReadInstance("/HelpProfitAmountSummary/" + TradeMonth + ".txt");
|
|
|
- if(string.IsNullOrEmpty(CheckExist))
|
|
|
+ function.WritePage("/HelpProfitAmountSummary/", TradeMonth + ".txt", DateTime.Now.ToString());
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
+ OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
|
|
|
+ DataTable userlist = OtherMySqlConn.dtable("select * from HelpProfitAmountSummary where TradeMonth='" + TradeMonth + "'");
|
|
|
+ foreach (DataRow user in userlist.Rows)
|
|
|
{
|
|
|
- function.WritePage("/HelpProfitAmountSummary/", TradeMonth + ".txt", DateTime.Now.ToString());
|
|
|
- string StartDate = DateTime.Now.ToString("yyyy-MM") + "-01 00:00:00";
|
|
|
- string EndDate = DateTime.Now.AddMonths(1).ToString("yyyy-MM") + "-01 00:00:00";
|
|
|
- WebCMSEntities db = new WebCMSEntities();
|
|
|
- OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
|
|
|
- DataTable userlist = OtherMySqlConn.dtable("select DISTINCT UserId from HelpProfitMerchantForUser order by UserId desc");
|
|
|
- foreach (DataRow user in userlist.Rows)
|
|
|
+ int Id = int.Parse(user["Id"].ToString());
|
|
|
+ int UserId = int.Parse(user["UserId"].ToString());
|
|
|
+ int Month = int.Parse(user["QueryCount"].ToString());
|
|
|
+ if(Month > 24)
|
|
|
+ {
|
|
|
+ Month = 24;
|
|
|
+ }
|
|
|
+ decimal MonthAmount1 = 0; //本月额度
|
|
|
+ decimal MonthAmount2 = 0; //上月额度
|
|
|
+ decimal MonthAmount3 = 0; //上上月额度
|
|
|
+ if(Month > 0)
|
|
|
+ {
|
|
|
+ MonthAmount1 = EveryMonthFixedVal()[Month]; //上月额度
|
|
|
+ }
|
|
|
+ if(Month > 1)
|
|
|
+ {
|
|
|
+ MonthAmount2 = EveryMonthFixedVal()[Month - 1]; //上月额度
|
|
|
+ }
|
|
|
+ if(Month > 2)
|
|
|
+ {
|
|
|
+ MonthAmount3 = EveryMonthFixedVal()[Month - 2]; //上上月额度
|
|
|
+ }
|
|
|
+ List<int> MerCounts = new List<int>(); //近2月月台数,不包含当月
|
|
|
+ int MerCount1 = 0; //本月台数
|
|
|
+ int MerCount2 = 0; //上月台数
|
|
|
+ int MerCount3 = 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);
|
|
|
+ }
|
|
|
+ if(MerCounts.Count > 0)
|
|
|
+ {
|
|
|
+ MerCount1 = MerCounts[0];
|
|
|
+ }
|
|
|
+ if(MerCounts.Count > 1)
|
|
|
+ {
|
|
|
+ MerCount2 = MerCounts[1];
|
|
|
+ }
|
|
|
+ if(MerCounts.Count > 2)
|
|
|
+ {
|
|
|
+ MerCount3 = MerCounts[2];
|
|
|
+ }
|
|
|
+ decimal MaxTradeAmount = MerCount1 * MonthAmount1 + MerCount2 * MonthAmount2 + MerCount3 * MonthAmount3; //当月最大交易总额
|
|
|
+ HelpProfitAmountSummary selfStat = db.HelpProfitAmountSummary.FirstOrDefault(m => m.Id == Id);
|
|
|
+ if(selfStat != null)
|
|
|
{
|
|
|
- int UserId = int.Parse(user[0].ToString());
|
|
|
- int Month = db.HelpProfitAmountSummary.Count(m => m.UserId == UserId);
|
|
|
- if(Month > 24)
|
|
|
- {
|
|
|
- Month = 24;
|
|
|
- }
|
|
|
- decimal MonthAmount2 = 0; //上月额度
|
|
|
- decimal MonthAmount3 = 0; //上上月额度
|
|
|
- if(Month > 1)
|
|
|
- {
|
|
|
- MonthAmount2 = EveryMonthFixedVal()[Month - 1]; //上月额度
|
|
|
- }
|
|
|
- if(Month > 2)
|
|
|
- {
|
|
|
- MonthAmount3 = EveryMonthFixedVal()[Month - 2]; //上上月额度
|
|
|
- }
|
|
|
- List<int> MerCounts = new List<int>(); //近2月月台数,不包含当月
|
|
|
- int MerCount2 = 0; //上月台数
|
|
|
- int MerCount3 = 0; //上上月台数
|
|
|
- List<HelpProfitAmountSummary> Summarys = db.HelpProfitAmountSummary.Where(m => m.UserId == UserId).OrderByDescending(m => m.TradeMonth).ToList();
|
|
|
- foreach(HelpProfitAmountSummary Summary in Summarys)
|
|
|
- {
|
|
|
- if(Summary.MerCount > 0 && MerCounts.Count < 3)
|
|
|
- {
|
|
|
- MerCounts.Add(Summary.MerCount);
|
|
|
- }
|
|
|
- if(MerCounts.Count >= 3)
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if(MerCounts.Count > 0)
|
|
|
- {
|
|
|
- MerCount2 = MerCounts[0];
|
|
|
- }
|
|
|
- if(MerCounts.Count > 1)
|
|
|
- {
|
|
|
- MerCount3 = MerCounts[1];
|
|
|
- }
|
|
|
- decimal MaxTradeAmount = MerCount2 * MonthAmount2 + MerCount3 * MonthAmount3; //当月最大交易总额
|
|
|
- HelpProfitAmountSummary selfStat = db.HelpProfitAmountSummary.FirstOrDefault(m => m.UserId == UserId && m.TradeMonth == TradeMonth);
|
|
|
- if (selfStat == null)
|
|
|
- {
|
|
|
- selfStat = db.HelpProfitAmountSummary.Add(new HelpProfitAmountSummary()
|
|
|
- {
|
|
|
- TradeMonth = TradeMonth,
|
|
|
- UserId = UserId,
|
|
|
- QueryCount = Month,
|
|
|
- }).Entity;
|
|
|
- db.SaveChanges();
|
|
|
- }
|
|
|
selfStat.MaxAmount = MaxTradeAmount;
|
|
|
}
|
|
|
- db.SaveChanges();
|
|
|
- db.Dispose();
|
|
|
}
|
|
|
+ db.SaveChanges();
|
|
|
+ db.Dispose();
|
|
|
}
|
|
|
- catch(Exception ex)
|
|
|
- {
|
|
|
- function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "每月重置最大交易总额异常");
|
|
|
- }
|
|
|
- Thread.Sleep(600000);
|
|
|
+ }
|
|
|
+ catch(Exception ex)
|
|
|
+ {
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "每月重置最大交易总额异常");
|
|
|
}
|
|
|
}
|
|
|
|