|
|
@@ -50,7 +50,7 @@ namespace MySystem
|
|
|
string startId = function.ReadInstance("/TradeRecord/Id3.txt");
|
|
|
if (string.IsNullOrEmpty(startId))
|
|
|
{
|
|
|
- startId = "2750000";
|
|
|
+ startId = "30000000";
|
|
|
}
|
|
|
DataTable idsDt = OtherMySqlConn.dtable("select Id from TradeRecord where Id>=" + startId + " and ActStatus=1 and CreateDate>='2022-09-05 00:00:00' and MerchantId in (select MerchantId from HelpProfitMerIds) and SeoTitle='HelpProfit' and QueryCount>0 and QueryCount<3 order by Id limit 50");
|
|
|
if (idsDt.Rows.Count > 0)
|
|
|
@@ -138,6 +138,92 @@ namespace MySystem
|
|
|
function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "实时执行助利宝交易额日志");
|
|
|
}
|
|
|
|
|
|
+ public void StatTradeForHelpProfit(string month)
|
|
|
+ {
|
|
|
+ OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
|
|
|
+ function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "实时执行助利宝交易额日志");
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string startId = function.ReadInstance("/TradeRecord/Id3.txt");
|
|
|
+ if (string.IsNullOrEmpty(startId))
|
|
|
+ {
|
|
|
+ startId = "30000000";
|
|
|
+ }
|
|
|
+ string start = month + "-01 00:00:00";
|
|
|
+ string end = DateTime.Parse(start).AddMonths(1).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
+ DataTable selfDt = OtherMySqlConn.dtable("select MerchantId,DATE_FORMAT(CreateDate,'%Y%m%d'),sum(TradeAmount) from TradeRecord where Id>=" + startId + " and ActStatus=1 and CreateDate>='" + start + "' and CreateDate<'" + end + "' and MerchantId in (select MerchantId from HelpProfitMerIds) and SeoTitle='HelpProfit' group by MerchantId,DATE_FORMAT(CreateDate,'%Y%m%d')");
|
|
|
+ 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 TradeDate = selfDr[1].ToString();
|
|
|
+ string TradeMonth = TradeDate.Substring(0, 6);
|
|
|
+ decimal TradeAmount = decimal.Parse(selfDr[2].ToString());
|
|
|
+ HelpProfitMerIds merIds = db.HelpProfitMerIds.FirstOrDefault(m => m.MerchantId == MerchantId) ?? new HelpProfitMerIds();
|
|
|
+ bool Check = CheckAmount(db, MerchantId, merIds.UserId, TradeMonth);
|
|
|
+ if (Check)
|
|
|
+ {
|
|
|
+ decimal MoreAmount = TradeAmount * 0.01M;
|
|
|
+ int random = function.get_Random(0, 10000);
|
|
|
+ // if(MoreAmount > 1 && random < 5000)
|
|
|
+ // {
|
|
|
+ MoreAmount = decimal.Parse(function.CheckInt(MoreAmount.ToString().Split(".")[0]));
|
|
|
+ // }
|
|
|
+ HelpProfitMerTradeSummay selfStat = db.HelpProfitMerTradeSummay.FirstOrDefault(m => m.MerchantId == MerchantId && m.TradeMonth == TradeMonth && m.TradeDate == TradeDate);
|
|
|
+ if (selfStat == null)
|
|
|
+ {
|
|
|
+ selfStat = db.HelpProfitMerTradeSummay.Add(new HelpProfitMerTradeSummay()
|
|
|
+ {
|
|
|
+ TradeMonth = TradeMonth,
|
|
|
+ TradeDate = TradeDate,
|
|
|
+ MerchantId = MerchantId,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ selfStat.TradeAmount += TradeAmount + MoreAmount;
|
|
|
+
|
|
|
+ HelpProfitMerTradeMonthSummay monthStat = db.HelpProfitMerTradeMonthSummay.FirstOrDefault(m => m.MerchantId == MerchantId && m.TradeMonth == TradeMonth);
|
|
|
+ if (monthStat == null)
|
|
|
+ {
|
|
|
+ monthStat = db.HelpProfitMerTradeMonthSummay.Add(new HelpProfitMerTradeMonthSummay()
|
|
|
+ {
|
|
|
+ TradeMonth = TradeMonth,
|
|
|
+ MerchantId = MerchantId,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ monthStat.TradeAmount += TradeAmount + MoreAmount;
|
|
|
+
|
|
|
+ HelpProfitAmountSummary amountStat = db.HelpProfitAmountSummary.FirstOrDefault(m => m.UserId == merIds.UserId && m.TradeMonth == TradeMonth);
|
|
|
+ if (amountStat == null)
|
|
|
+ {
|
|
|
+ amountStat = db.HelpProfitAmountSummary.Add(new HelpProfitAmountSummary()
|
|
|
+ {
|
|
|
+ TradeMonth = TradeMonth,
|
|
|
+ UserId = merIds.UserId,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ amountStat.TradeAmount += TradeAmount + MoreAmount;
|
|
|
+
|
|
|
+ StatTradeAmountEverDayForUser(db, merIds.UserId, TradeAmount + MoreAmount, TradeDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function.WritePage("/TradeRecord/", "Id3.txt", startId);
|
|
|
+ }
|
|
|
+ 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", "实时执行助利宝交易额日志");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
public void AddUserHelpProfit()
|
|
|
@@ -300,7 +386,7 @@ namespace MySystem
|
|
|
{
|
|
|
StartUserTradeGo();
|
|
|
}
|
|
|
- Thread.Sleep(30000);
|
|
|
+ // Thread.Sleep(30000);
|
|
|
}
|
|
|
}
|
|
|
public void StartUserTradeGo()
|