|
|
@@ -21,11 +21,11 @@ namespace MySystem
|
|
|
Thread th = new Thread(StartResetMerchantDo);
|
|
|
th.IsBackground = true;
|
|
|
th.Start();
|
|
|
-
|
|
|
+
|
|
|
Thread thUser = new Thread(StartResetUserSelfDo);
|
|
|
thUser.IsBackground = true;
|
|
|
thUser.Start();
|
|
|
-
|
|
|
+
|
|
|
Thread thUserTeam = new Thread(StartResetUserTeamDo);
|
|
|
thUserTeam.IsBackground = true;
|
|
|
thUserTeam.Start();
|
|
|
@@ -39,7 +39,7 @@ namespace MySystem
|
|
|
while (true)
|
|
|
{
|
|
|
string content = RedisDbconn.Instance.RPop<string>("ResetMerchantStatDataQueue2");
|
|
|
- if(!string.IsNullOrEmpty(content))
|
|
|
+ if (!string.IsNullOrEmpty(content))
|
|
|
{
|
|
|
StatResetMerchantAmount(content);
|
|
|
}
|
|
|
@@ -54,6 +54,7 @@ namespace MySystem
|
|
|
string endDate = jsonObj["EndDate"].ToString();
|
|
|
function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "重置商户交易额日志");
|
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
|
+ string conn = Library.ConfigurationManager.AppSettings["StatSqlConnStr2"].ToString();
|
|
|
KxsMainModels.WebCMSEntities maindb = new KxsMainModels.WebCMSEntities();
|
|
|
using (var tran = db.Database.BeginTransaction())
|
|
|
{
|
|
|
@@ -63,6 +64,15 @@ namespace MySystem
|
|
|
if (selfDt.Rows.Count > 0)
|
|
|
{
|
|
|
function.WriteLog("统计人数:" + selfDt.Rows.Count + "\n\n", "重置商户交易额日志");
|
|
|
+ var ResetDate = "";
|
|
|
+ bool check = false; //重置统计表数据开关
|
|
|
+ decimal NonActAmounts = 0;
|
|
|
+ decimal ActAmounts = 0;
|
|
|
+ decimal AliPayInFactAmounts = 0;
|
|
|
+ decimal WeChatInfactAmounts = 0;
|
|
|
+ int OderCounts = 0;
|
|
|
+ decimal InFactAmounts = 0;
|
|
|
+ decimal TradeAmounts = 0;
|
|
|
foreach (DataRow selfDr in selfDt.Rows)
|
|
|
{
|
|
|
int MerchantId = int.Parse(selfDr["MerchantId"].ToString());
|
|
|
@@ -73,7 +83,6 @@ namespace MySystem
|
|
|
int TradeCount = int.Parse(selfDr[5].ToString());
|
|
|
decimal ActualAmount = decimal.Parse(selfDr[6].ToString());
|
|
|
string TradeMonth = TradeDate.Substring(0, 6);
|
|
|
-
|
|
|
//商户交易额
|
|
|
MerchantAmountSummay merchantStat = db.MerchantAmountSummay.FirstOrDefault(m => m.MerchantId == MerchantId && m.IsAct == IsAct && m.TradeMonth == TradeMonth && m.TradeDate == TradeDate && m.PayMode == PayMode);
|
|
|
if (merchantStat == null)
|
|
|
@@ -88,6 +97,50 @@ namespace MySystem
|
|
|
}).Entity;
|
|
|
db.SaveChanges();
|
|
|
}
|
|
|
+ var LastDate = ResetDate; //上次重置时间
|
|
|
+ if (ResetDate == "")
|
|
|
+ {
|
|
|
+ LastDate = TradeDate;
|
|
|
+ }
|
|
|
+ ResetDate = TradeDate; //覆盖重置时间
|
|
|
+ if (LastDate == TradeDate)
|
|
|
+ {
|
|
|
+ OderCounts += TradeCount;
|
|
|
+ TradeAmounts += TradeAmount;
|
|
|
+ if (IsAct == 0) NonActAmounts += TradeAmount;
|
|
|
+ if (IsAct == 1) ActAmounts += TradeAmount;
|
|
|
+ if (PayMode == 1) AliPayInFactAmounts += ActualAmount;
|
|
|
+ if (PayMode == 2) WeChatInfactAmounts += ActualAmount;
|
|
|
+ if (IsAct == 1) InFactAmounts += TradeAmount;
|
|
|
+ if (selfDt.Rows.Count == 1)
|
|
|
+ {
|
|
|
+ CustomerSqlConn.op("UPDATE MerchantTradeSummary" + LastDate + " SET NonActAmount=" + NonActAmounts + ",ActAmount=" + ActAmounts + ",AliPayInFactAmount=" + AliPayInFactAmounts + ",WeChatInfactAmount=" + WeChatInfactAmounts + ",OderCount=" + OderCounts + ",InFactAmount=" + InFactAmounts + ",TradeAmount=" + TradeAmounts + " WHERE MerchantId=" + MerchantId + "", conn);
|
|
|
+ CustomerSqlConn.op("UPDATE MerchantTradeSummaryList" + TradeMonth + " NonActAmount=" + NonActAmounts + ",ActAmount=" + ActAmounts + ",AliPayInFactAmount=" + AliPayInFactAmounts + ",WeChatInfactAmount=" + WeChatInfactAmounts + ",OderCount=" + OderCounts + ",InFactAmount=" + InFactAmounts + ",TradeAmount=" + TradeAmounts + " WHERE MerchantId=" + MerchantId + " AND TradeDate='" + LastDate + "'", conn);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ check = true;
|
|
|
+ if (check)
|
|
|
+ {
|
|
|
+ if (check)
|
|
|
+ {
|
|
|
+ CustomerSqlConn.op("UPDATE MerchantTradeSummary" + LastDate + " SET NonActAmount=" + NonActAmounts + ",ActAmount=" + ActAmounts + ",AliPayInFactAmount=" + AliPayInFactAmounts + ",WeChatInfactAmount=" + WeChatInfactAmounts + ",OderCount=" + OderCounts + ",InFactAmount=" + InFactAmounts + ",TradeAmount=" + TradeAmounts + " WHERE MerchantId=" + MerchantId + "", conn);
|
|
|
+ CustomerSqlConn.op("UPDATE MerchantTradeSummaryList" + TradeMonth + " NonActAmount=" + NonActAmounts + ",ActAmount=" + ActAmounts + ",AliPayInFactAmount=" + AliPayInFactAmounts + ",WeChatInfactAmount=" + WeChatInfactAmounts + ",OderCount=" + OderCounts + ",InFactAmount=" + InFactAmounts + ",TradeAmount=" + TradeAmounts + " WHERE MerchantId=" + MerchantId + " AND TradeDate='" + LastDate + "'", conn);
|
|
|
+ check = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (check == false)
|
|
|
+ {
|
|
|
+ OderCounts = TradeCount;
|
|
|
+ TradeAmounts = TradeAmount;
|
|
|
+ if (IsAct == 0) NonActAmounts = TradeAmount;
|
|
|
+ if (IsAct == 1) ActAmounts = TradeAmount;
|
|
|
+ if (PayMode == 1) AliPayInFactAmounts = ActualAmount;
|
|
|
+ if (PayMode == 2) WeChatInfactAmounts = ActualAmount;
|
|
|
+ if (IsAct == 1) InFactAmounts = TradeAmount;
|
|
|
+ }
|
|
|
+ }
|
|
|
merchantStat.TradeAmount = TradeAmount;
|
|
|
merchantStat.TradeCount = TradeCount;
|
|
|
merchantStat.TotalActual = ActualAmount;
|
|
|
@@ -112,7 +165,7 @@ namespace MySystem
|
|
|
while (true)
|
|
|
{
|
|
|
string content = RedisDbconn.Instance.RPop<string>("ResetSnStatDataQueue2");
|
|
|
- if(!string.IsNullOrEmpty(content))
|
|
|
+ if (!string.IsNullOrEmpty(content))
|
|
|
{
|
|
|
StatResetSnAmount(content);
|
|
|
}
|
|
|
@@ -185,7 +238,7 @@ namespace MySystem
|
|
|
while (true)
|
|
|
{
|
|
|
string content = RedisDbconn.Instance.RPop<string>("ResetUserSelfStatDataQueue2");
|
|
|
- if(!string.IsNullOrEmpty(content))
|
|
|
+ if (!string.IsNullOrEmpty(content))
|
|
|
{
|
|
|
StatResetUserSelfAmount(content);
|
|
|
}
|
|
|
@@ -240,10 +293,10 @@ namespace MySystem
|
|
|
db.SaveChanges();
|
|
|
|
|
|
string ParentNav = user.ParentNav + "," + userId + ",";
|
|
|
- if(!string.IsNullOrEmpty(ParentNav))
|
|
|
+ if (!string.IsNullOrEmpty(ParentNav))
|
|
|
{
|
|
|
string[] ParentNavList = ParentNav.Replace(",,", ",").Trim(',').Split(',');
|
|
|
- foreach(string id in ParentNavList)
|
|
|
+ foreach (string id in ParentNavList)
|
|
|
{
|
|
|
string reqdata = "{\"UserId\":\"" + id + "\",\"StartDate\":\"" + startDate + "\",\"EndDate\":\"" + endDate + "\"}";
|
|
|
RedisDbconn.Instance.AddList("ResetUserTeamStatDataQueue2", reqdata);
|
|
|
@@ -269,7 +322,7 @@ namespace MySystem
|
|
|
while (true)
|
|
|
{
|
|
|
string content = RedisDbconn.Instance.RPop<string>("ResetUserTeamStatDataQueue2");
|
|
|
- if(!string.IsNullOrEmpty(content))
|
|
|
+ if (!string.IsNullOrEmpty(content))
|
|
|
{
|
|
|
StatResetUserTeamAmount(content);
|
|
|
}
|
|
|
@@ -291,7 +344,7 @@ namespace MySystem
|
|
|
{
|
|
|
string subUserId = "0";
|
|
|
var subusers = maindb.Users.Select(m => new { m.Id, m.ParentUserId }).Where(m => m.ParentUserId == userId).ToList();
|
|
|
- foreach(var subuser in subusers)
|
|
|
+ foreach (var subuser in subusers)
|
|
|
{
|
|
|
subUserId += "," + subuser.Id;
|
|
|
}
|