|
|
@@ -40,7 +40,68 @@ namespace MySystem
|
|
|
Thread.Sleep(30000);
|
|
|
}
|
|
|
}
|
|
|
- public void StatTradeAmountEverDayV2()
|
|
|
+
|
|
|
+ //补交易额
|
|
|
+ public void StartOther()
|
|
|
+ {
|
|
|
+ Thread th = new Thread(StartOtherV2Do);
|
|
|
+ th.IsBackground = true;
|
|
|
+ th.Start();
|
|
|
+ }
|
|
|
+ public void StartOtherV2Do()
|
|
|
+ {
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ string content = RedisDbconn.Instance.RPop<string>("AddTradeRecordByPosIdQueue");
|
|
|
+ if(!string.IsNullOrEmpty(content))
|
|
|
+ {
|
|
|
+ int PosId = int.Parse(function.CheckInt(content));
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
+ PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == PosId && m.ActivationState == 1);
|
|
|
+ if(pos != null)
|
|
|
+ {
|
|
|
+ var Trades = db.TradeRecord.Select(m => new { m.Id, m.SnNo, m.CreateDate, m.ActStatus, m.MerchantId, m.BrandId, m.TradeAmount }).Where(m => m.SnNo == pos.PosSn && m.CreateDate <= pos.ActivationTime && m.ActStatus == 0).ToList();
|
|
|
+ foreach(var Trade in Trades)
|
|
|
+ {
|
|
|
+ //补创客交易
|
|
|
+ StatTradeAmountEverDayV2(Trade.Id);
|
|
|
+
|
|
|
+ //补商户交易
|
|
|
+ if(Trade.CreateDate.Value < DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"))
|
|
|
+ {
|
|
|
+ string StatDate = Trade.CreateDate.Value.ToString("yyyyMMdd");
|
|
|
+ string StatMonth = StatDate.Substring(0, 6);
|
|
|
+ PosMerchantTradeSummay stat = db.PosMerchantTradeSummay.FirstOrDefault(m => m.BrandId == Trade.BrandId && m.MerchantId == Trade.MerchantId && m.TradeMonth == StatMonth && m.TradeDate == StatDate);
|
|
|
+ if(stat == null)
|
|
|
+ {
|
|
|
+ stat = db.PosMerchantTradeSummay.Add(new PosMerchantTradeSummay()
|
|
|
+ {
|
|
|
+ BrandId = Trade.BrandId,
|
|
|
+ MerchantId = Trade.MerchantId,
|
|
|
+ TradeMonth = StatMonth,
|
|
|
+ TradeDate = StatDate,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ stat.TradeAmount += Trade.TradeAmount;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+
|
|
|
+ //交易记录设置标记(已执行,激活标记为已激活)
|
|
|
+ CustomerSqlConn.op("update TradeRecord set QueryCount=1,ActStatus=1 where Id=" + Trade.Id, AppConfig.Base.SqlConn);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ db.Dispose();
|
|
|
+ Thread.Sleep(1000);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Thread.Sleep(60000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void StatTradeAmountEverDayV2(int Id = 0)
|
|
|
{
|
|
|
OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
|
|
|
function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "实时执行交易额V2日志");
|
|
|
@@ -54,14 +115,22 @@ namespace MySystem
|
|
|
{
|
|
|
startId = "867041";
|
|
|
}
|
|
|
- DataTable idsDt = OtherMySqlConn.dtable("select Id from TradeRecord where Id>=" + startId + " and QueryCount=0 order by Id limit 50");
|
|
|
+ string sql = "select Id from TradeRecord where Id>=" + startId + " and QueryCount=0 and ActStatus=1 order by Id limit 50";
|
|
|
+ if(Id > 0)
|
|
|
+ {
|
|
|
+ sql = "select Id from TradeRecord where Id=" + Id;
|
|
|
+ }
|
|
|
+ DataTable idsDt = OtherMySqlConn.dtable(sql);
|
|
|
if(idsDt.Rows.Count > 0)
|
|
|
{
|
|
|
string ids = "";
|
|
|
foreach (DataRow idsDr in idsDt.Rows)
|
|
|
{
|
|
|
ids += idsDr["Id"].ToString() + ",";
|
|
|
- startId = idsDr["Id"].ToString();
|
|
|
+ if(Id == 0)
|
|
|
+ {
|
|
|
+ startId = idsDr["Id"].ToString();
|
|
|
+ }
|
|
|
}
|
|
|
DataTable selfDt = OtherMySqlConn.dtable("select UserId,ParentNav,BrandId,BankCardType,QrPayFlag,MerHelpFlag,Version,CapFlag,VipFlag,PayType,DATE_FORMAT(CreateDate,'%Y%m%d'),sum(TradeAmount),count(Id) from TradeRecord where Id in (" + ids.TrimEnd(',') + ") group by UserId,ParentNav,BrandId,BankCardType,QrPayFlag,MerHelpFlag,Version,CapFlag,VipFlag,PayType,DATE_FORMAT(CreateDate,'%Y%m%d')");
|
|
|
if (selfDt.Rows.Count > 0)
|
|
|
@@ -233,7 +302,10 @@ namespace MySystem
|
|
|
RedisDbconn.Instance.AddList("StatTradeAmountQueue", Newtonsoft.Json.JsonConvert.SerializeObject(statData));
|
|
|
}
|
|
|
OtherMySqlConn.op("update TradeRecord set QueryCount=1 where Id in (" + ids.TrimEnd(',') + ")");
|
|
|
- function.WritePage("/TradeRecord/", "Id.txt", startId);
|
|
|
+ if(Id == 0)
|
|
|
+ {
|
|
|
+ function.WritePage("/TradeRecord/", "Id.txt", startId);
|
|
|
+ }
|
|
|
}
|
|
|
db.SaveChanges();
|
|
|
}
|