|
|
@@ -25,7 +25,7 @@ namespace MySystem
|
|
|
{
|
|
|
while (true)
|
|
|
{
|
|
|
- string content = RedisDbconn.Instance.RPop<string>("SycnProfitQueue2");
|
|
|
+ string content = RedisDbconn.Instance.RPop<string>("SycnProfitQueue3");
|
|
|
if (!string.IsNullOrEmpty(content))
|
|
|
{
|
|
|
try
|
|
|
@@ -38,7 +38,7 @@ namespace MySystem
|
|
|
string SysUserName = data[3];
|
|
|
if (OpType == 0)
|
|
|
{
|
|
|
- DoTradeProfit(BrandId, date, SysUserName);
|
|
|
+ // DoTradeProfit(BrandId, date, SysUserName);
|
|
|
DoSubsidyProfit(BrandId, date);
|
|
|
}
|
|
|
else if (OpType == 1)
|
|
|
@@ -182,7 +182,7 @@ namespace MySystem
|
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
|
OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
|
|
|
|
|
|
- OtherMySqlConn.op("insert into SubsidyRecord (CreateDate,CreateMan,SeoTitle,ParentNav,BrandId,UserId,ProfitAmount) select now(),'root','" + date + "',(select ParentNav from Users where Id=p.SubsidyUserId)," + BrandId + ",SubsidyUserId,sum(SubsidyProfitRate) from ProfitSubsidyDetail p where Status=0 and BrandId=" + BrandId + " and TradeMonth='" + date + "' GROUP BY SubsidyUserId");
|
|
|
+ OtherMySqlConn.op("insert into SubsidyRecord (CreateDate,SeoKeyword,SeoTitle,ParentNav,BrandId,UserId,ProfitAmount) select now(),'root','" + date + "',(select ParentNav from Users where Id=p.SubsidyUserId)," + BrandId + ",SubsidyUserId,sum(SubsidyProfitRate) from ProfitSubsidyDetail p where Status=0 and BrandId=" + BrandId + " and TradeMonth='" + date + "' GROUP BY SubsidyUserId");
|
|
|
|
|
|
DataTable dt = OtherMySqlConn.dtable("select SubsidyUserId,sum(SubsidyProfitRate) from ProfitSubsidyDetail where Status=0 and BrandId=" + BrandId + " and TradeMonth='" + date + "' GROUP BY SubsidyUserId");
|
|
|
function.WriteLog("补贴:" + BrandId + ":" + dt.Rows.Count, "同步补贴数据");
|
|
|
@@ -194,25 +194,13 @@ namespace MySystem
|
|
|
decimal ProfitMoney = decimal.Parse(dr[1].ToString());
|
|
|
try
|
|
|
{
|
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
- string IdBrand = UserId + "_" + BrandId;
|
|
|
- UserMachineData MachineData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
|
|
|
- if (MachineData == null)
|
|
|
- {
|
|
|
- MachineData = db.UserMachineData.Add(new UserMachineData()
|
|
|
- {
|
|
|
- IdBrand = IdBrand,
|
|
|
- }).Entity;
|
|
|
- db.SaveChanges();
|
|
|
- }
|
|
|
- MachineData.OtherProfit += ProfitMoney;
|
|
|
- db.SaveChanges();
|
|
|
+ string content = UserId + "|" + BrandId + "|" + ProfitMoney + "|" + index;
|
|
|
+ RedisDbconn.Instance.AddList("DoSubsidyProfitQueue", content);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
function.WriteLog(DateTime.Now.ToString() + "\n" + UserId + "," + ProfitMoney + "\n" + ex.ToString(), "同步到补贴异常");
|
|
|
}
|
|
|
- function.WriteLog(index.ToString(), "同步补贴数据");
|
|
|
}
|
|
|
OtherMySqlConn.dtable("update ProfitSubsidyDetail set Status=1 where Status=0 and BrandId=" + BrandId + " and TradeMonth='" + date + "'");
|
|
|
|
|
|
@@ -379,5 +367,66 @@ namespace MySystem
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public void StartSubsidy()
|
|
|
+ {
|
|
|
+ Thread th = new Thread(StartSubsidyDo);
|
|
|
+ th.IsBackground = true;
|
|
|
+ th.Start();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void StartSubsidyDo()
|
|
|
+ {
|
|
|
+ while (true)
|
|
|
+ {
|
|
|
+ string content = RedisDbconn.Instance.RPop<string>("DoSubsidyProfitQueue");
|
|
|
+ if (!string.IsNullOrEmpty(content))
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string[] data = content.Split('|');
|
|
|
+ int UserId = int.Parse(data[0]);
|
|
|
+ int BrandId = int.Parse(data[1]);
|
|
|
+ decimal ProfitMoney = decimal.Parse(data[2]);
|
|
|
+ int index = int.Parse(data[3]);
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
+ Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
+ string IdBrand = UserId + "_" + BrandId;
|
|
|
+ UserMachineData MachineData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
|
|
|
+ if (MachineData == null)
|
|
|
+ {
|
|
|
+ MachineData = db.UserMachineData.Add(new UserMachineData()
|
|
|
+ {
|
|
|
+ IdBrand = IdBrand,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ MachineData.OtherProfit += ProfitMoney;
|
|
|
+ db.SaveChanges();
|
|
|
+ function.WriteLog(index.ToString() + "--" + DateTime.Now.ToString(), "同步补贴数据");
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "同步补贴队列数据异常");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Thread.Sleep(1000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|