|
|
@@ -25,7 +25,7 @@ namespace MySystem
|
|
|
{
|
|
|
while (true)
|
|
|
{
|
|
|
- string content = RedisDbconn.Instance.RPop<string>("SycnProfitQueue");
|
|
|
+ string content = RedisDbconn.Instance.RPop<string>("SycnProfitQueue2");
|
|
|
if (!string.IsNullOrEmpty(content))
|
|
|
{
|
|
|
try
|
|
|
@@ -64,154 +64,103 @@ namespace MySystem
|
|
|
{
|
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
|
OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
|
|
|
- bool op = true;
|
|
|
- while (op)
|
|
|
+ OtherMySqlConn.op("insert into ProfitRecord (CreateDate,CreateMan,SeoTitle,ParentNav,BrandId,UserId,DirectFlag,ProfitAmount) select now(),'root','" + date + "',(select ParentNav from Users where Id=p.UserId)," + BrandId + ",UserId,ProfitType,sum(CreditTradeProfit+DebitNonTradeCapProfit+DebitTradeCapProfit) from ProfitRewardRecord p where CheckStatus=0 and BrandId=" + BrandId + " and UserId>0 and TradeMonth='" + date + "' group by UserId,ProfitType order by UserId");
|
|
|
+ DataTable dt = OtherMySqlConn.dtable("select UserId,sum(CreditTradeProfit+DebitNonTradeCapProfit+DebitTradeCapProfit) from ProfitRewardRecord where CheckStatus=0 and BrandId=" + BrandId + " and UserId>0 and TradeMonth='" + date + "' group by UserId");
|
|
|
+ function.WriteLog("分润:" + BrandId + ":" + dt.Rows.Count, "同步分润数据");
|
|
|
+ int index = 0;
|
|
|
+ foreach (DataRow dr in dt.Rows)
|
|
|
{
|
|
|
- string ids = "";
|
|
|
- DataTable idsDt = OtherMySqlConn.dtable("select Id from ProfitRewardRecord where CheckStatus=0 and BrandId=" + BrandId + " and TradeMonth='" + date + "' order by Id limit 500");
|
|
|
- if (idsDt.Rows.Count > 0)
|
|
|
+ index += 1;
|
|
|
+ int UserId = int.Parse(dr["UserId"].ToString());
|
|
|
+ decimal ProfitMoney = decimal.Parse(dr[1].ToString());
|
|
|
+ try
|
|
|
{
|
|
|
- foreach (DataRow idsDr in idsDt.Rows)
|
|
|
+ string IdBrand = UserId + "_" + BrandId;
|
|
|
+ UserMachineData MachineData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
|
|
|
+ if (MachineData == null)
|
|
|
{
|
|
|
- ids += idsDr["Id"].ToString() + ",";
|
|
|
- }
|
|
|
- DataTable dt = OtherMySqlConn.dtable("select UserId,ProfitType,sum(CreditTradeProfit+DebitNonTradeCapProfit+DebitTradeCapProfit+QrCreditTradeProfit) from ProfitRewardRecord where ids in (" + ids.TrimEnd(',') + ") group by UserId,ProfitType");
|
|
|
- function.WriteLog("分润:" + BrandId + ":" + dt.Rows.Count, "同步分润数据");
|
|
|
- int index = 0;
|
|
|
- foreach (DataRow dr in dt.Rows)
|
|
|
- {
|
|
|
- index += 1;
|
|
|
- int UserId = int.Parse(dr["UserId"].ToString());
|
|
|
- ulong ProfitType = ulong.Parse(dr["ProfitType"].ToString());
|
|
|
- decimal ProfitMoney = decimal.Parse(dr[2].ToString());
|
|
|
- var tran = db.Database.BeginTransaction();
|
|
|
- try
|
|
|
- {
|
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
- ProfitRecord profit = db.ProfitRecord.FirstOrDefault(m => m.UserId == UserId && m.BrandId == BrandId && m.SeoTitle == date);
|
|
|
- if (profit == null)
|
|
|
- {
|
|
|
- profit = db.ProfitRecord.Add(new ProfitRecord()
|
|
|
- {
|
|
|
- CreateDate = DateTime.Now,
|
|
|
- CreateMan = SysUserName,
|
|
|
- SeoTitle = date,
|
|
|
- ParentNav = user.ParentNav,
|
|
|
- BrandId = BrandId,
|
|
|
- UserId = UserId,
|
|
|
- DirectFlag = ProfitType,
|
|
|
- }).Entity;
|
|
|
- db.SaveChanges();
|
|
|
- }
|
|
|
- profit.ProfitAmount += ProfitMoney;
|
|
|
- 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.TradeProfit += ProfitMoney;
|
|
|
- db.SaveChanges();
|
|
|
- tran.Commit();
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
+ MachineData = db.UserMachineData.Add(new UserMachineData()
|
|
|
{
|
|
|
- function.WriteLog(DateTime.Now.ToString() + "\n" + UserId + "," + ProfitType + "," + ProfitMoney + "\n" + ex.ToString(), "同步到余额异常");
|
|
|
- tran.Rollback();
|
|
|
- }
|
|
|
- function.WriteLog(index.ToString(), "同步分润数据");
|
|
|
+ IdBrand = IdBrand,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
}
|
|
|
- OtherMySqlConn.op("update ProfitRewardRecord set CheckStatus=1 where ids in (" + ids.TrimEnd(',') + ")");
|
|
|
+ MachineData.TradeProfit += ProfitMoney;
|
|
|
+ db.SaveChanges();
|
|
|
}
|
|
|
- else
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- op = false;
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + UserId + "," + ProfitMoney + "\n" + ex.ToString(), "同步到余额异常");
|
|
|
}
|
|
|
+ function.WriteLog(index.ToString(), "同步分润数据");
|
|
|
}
|
|
|
+ OtherMySqlConn.op("update ProfitRewardRecord set CheckStatus=1 where CheckStatus=0 and BrandId=" + BrandId + " and UserId>0 and TradeMonth='" + date + "'");
|
|
|
+
|
|
|
db.Dispose();
|
|
|
}
|
|
|
private void DoTradeProfit2(int BrandId, string date, string SysUserName)
|
|
|
{
|
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
|
OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
|
|
|
- bool op = true;
|
|
|
- while (op)
|
|
|
+
|
|
|
+ DataTable dt = OtherMySqlConn.dtable("select UserId,DirectFlag,ProfitAmount from ProfitRecord where BrandId=" + BrandId + " and SeoTitle='" + date + "' and Version=0 and UserId>0");
|
|
|
+ function.WriteLog("分润:" + BrandId + ":" + dt.Rows.Count, "同步分润数据");
|
|
|
+ int index = 0;
|
|
|
+ foreach (DataRow dr in dt.Rows)
|
|
|
{
|
|
|
- DataTable idsDt = OtherMySqlConn.dtable("select Id from ProfitRecord where BrandId=" + BrandId + " and SeoTitle='" + date + "' and Version=0 and UserId>0 order by Id limit 500");
|
|
|
- if (idsDt.Rows.Count > 0)
|
|
|
+ index += 1;
|
|
|
+ int UserId = int.Parse(dr["UserId"].ToString());
|
|
|
+ int DirectFlag = int.Parse(dr["DirectFlag"].ToString());
|
|
|
+ decimal ProfitAmount = decimal.Parse(dr["ProfitAmount"].ToString());
|
|
|
+ var tran = db.Database.BeginTransaction();
|
|
|
+ try
|
|
|
{
|
|
|
- string ids = "";
|
|
|
- foreach (DataRow idsDr in idsDt.Rows)
|
|
|
+ UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
|
|
|
+ if (account == null)
|
|
|
{
|
|
|
- ids += idsDr["Id"].ToString() + ",";
|
|
|
- }
|
|
|
- DataTable dt = OtherMySqlConn.dtable("select UserId,DirectFlag,ProfitAmount from ProfitRecord where Id in (" + ids.TrimEnd(',') + ")");
|
|
|
- function.WriteLog("分润:" + BrandId + ":" + dt.Rows.Count, "同步分润数据");
|
|
|
- int index = 0;
|
|
|
- foreach (DataRow dr in dt.Rows)
|
|
|
- {
|
|
|
- index += 1;
|
|
|
- int UserId = int.Parse(dr["UserId"].ToString());
|
|
|
- int DirectFlag = int.Parse(dr["DirectFlag"].ToString());
|
|
|
- decimal ProfitAmount = decimal.Parse(dr["ProfitAmount"].ToString());
|
|
|
- var tran = db.Database.BeginTransaction();
|
|
|
- try
|
|
|
- {
|
|
|
- UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
|
|
|
- if (account == null)
|
|
|
- {
|
|
|
- account = db.UserAccount.Add(new UserAccount()
|
|
|
- {
|
|
|
- Id = UserId,
|
|
|
- UserId = UserId,
|
|
|
- }).Entity;
|
|
|
- db.SaveChanges();
|
|
|
- }
|
|
|
- decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
|
|
|
- decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
|
|
|
- decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
|
|
|
- account.BalanceAmount += ProfitAmount;
|
|
|
- account.TotalAmount += ProfitAmount;
|
|
|
- decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
|
|
|
- decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
|
|
|
- decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
|
|
|
- UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
|
|
|
- {
|
|
|
- CreateDate = DateTime.Now,
|
|
|
- UpdateDate = DateTime.Now,
|
|
|
- UserId = UserId, //创客
|
|
|
- ProductType = BrandId,
|
|
|
- ChangeType = 1, //变动类型
|
|
|
- ChangeAmount = ProfitAmount, //变更金额
|
|
|
- BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
- AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
- BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
- AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
- BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
- AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
|
- Remark = DirectFlag == 1 ? "直拓商户分润" : "品牌推广服务费",
|
|
|
- }).Entity;
|
|
|
- db.SaveChanges();
|
|
|
- tran.Commit();
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
+ account = db.UserAccount.Add(new UserAccount()
|
|
|
{
|
|
|
- function.WriteLog(DateTime.Now.ToString() + "\n" + UserId + "," + ProfitAmount + "\n" + ex.ToString(), "同步到余额异常");
|
|
|
- tran.Rollback();
|
|
|
- }
|
|
|
- function.WriteLog(index.ToString(), "同步分润数据");
|
|
|
+ Id = UserId,
|
|
|
+ UserId = UserId,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
}
|
|
|
- OtherMySqlConn.dtable("update ProfitRecord set Version=1 where Id in (" + ids.TrimEnd(',') + ")");
|
|
|
+ decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
|
|
|
+ decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
|
|
|
+ decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
|
|
|
+ account.BalanceAmount += ProfitAmount;
|
|
|
+ account.TotalAmount += ProfitAmount;
|
|
|
+ decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
|
|
|
+ decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
|
|
|
+ decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
|
|
|
+ UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+ UpdateDate = DateTime.Now,
|
|
|
+ UserId = UserId, //创客
|
|
|
+ ProductType = BrandId,
|
|
|
+ ChangeType = 1, //变动类型
|
|
|
+ ChangeAmount = ProfitAmount, //变更金额
|
|
|
+ BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
+ AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
+ BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
+ AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
+ BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
+ AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
|
+ Remark = DirectFlag == 1 ? "直拓商户分润" : "品牌推广服务费",
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ tran.Commit();
|
|
|
}
|
|
|
- else
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- op = false;
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + UserId + "," + ProfitAmount + "\n" + ex.ToString(), "同步到余额异常");
|
|
|
+ tran.Rollback();
|
|
|
}
|
|
|
+ function.WriteLog(index.ToString(), "同步分润数据");
|
|
|
}
|
|
|
+ OtherMySqlConn.dtable("update ProfitRecord set Version=1 where BrandId=" + BrandId + " and SeoTitle='" + date + "' and Version=0 and UserId>0");
|
|
|
+
|
|
|
db.Dispose();
|
|
|
}
|
|
|
|
|
|
@@ -221,57 +170,39 @@ namespace MySystem
|
|
|
{
|
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
|
OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
|
|
|
- bool op = true;
|
|
|
- while (op)
|
|
|
+
|
|
|
+ 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, "同步补贴数据");
|
|
|
+ int index = 0;
|
|
|
+ foreach (DataRow dr in dt.Rows)
|
|
|
{
|
|
|
- DataTable idsDt = OtherMySqlConn.dtable("select Id from ProfitSubsidyDetail where Status=0 and BrandId=" + BrandId + " and TradeMonth='" + date + "' order by Id limit 500");
|
|
|
- if (idsDt.Rows.Count > 0)
|
|
|
+ index += 1;
|
|
|
+ int UserId = int.Parse(dr["SubsidyUserId"].ToString());
|
|
|
+ decimal ProfitMoney = decimal.Parse(dr[1].ToString());
|
|
|
+ try
|
|
|
{
|
|
|
- string ids = "";
|
|
|
- foreach (DataRow idsDr in idsDt.Rows)
|
|
|
+ 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)
|
|
|
{
|
|
|
- ids += idsDr["Id"].ToString() + ",";
|
|
|
- }
|
|
|
- DataTable dt = OtherMySqlConn.dtable("select SubsidyUserId,sum(SubsidyProfitRate) from ProfitSubsidyDetail where Id in (" + ids.TrimEnd(',') + ") GROUP BY SubsidyUserId");
|
|
|
- function.WriteLog("补贴:" + BrandId + ":" + dt.Rows.Count, "同步分润数据");
|
|
|
- int index = 0;
|
|
|
- foreach (DataRow dr in dt.Rows)
|
|
|
- {
|
|
|
- index += 1;
|
|
|
- int UserId = int.Parse(dr["SubsidyUserId"].ToString());
|
|
|
- decimal ProfitMoney = decimal.Parse(dr[1].ToString());
|
|
|
- var tran = db.Database.BeginTransaction();
|
|
|
- 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();
|
|
|
- tran.Commit();
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
+ MachineData = db.UserMachineData.Add(new UserMachineData()
|
|
|
{
|
|
|
- function.WriteLog(DateTime.Now.ToString() + "\n" + UserId + "," + ProfitMoney + "\n" + ex.ToString(), "同步到补贴异常");
|
|
|
- tran.Rollback();
|
|
|
- }
|
|
|
- function.WriteLog(index.ToString(), "同步分润数据");
|
|
|
+ IdBrand = IdBrand,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
}
|
|
|
- OtherMySqlConn.dtable("update ProfitSubsidyDetail set Status=1 where Id in (" + ids.TrimEnd(',') + ")");
|
|
|
+ MachineData.OtherProfit += ProfitMoney;
|
|
|
+ db.SaveChanges();
|
|
|
}
|
|
|
- else
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- op = false;
|
|
|
+ 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 + "'");
|
|
|
+
|
|
|
db.Dispose();
|
|
|
}
|
|
|
|
|
|
@@ -279,80 +210,65 @@ namespace MySystem
|
|
|
{
|
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
|
OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
|
|
|
- bool op = true;
|
|
|
- while (op)
|
|
|
+
|
|
|
+ DataTable dt = OtherMySqlConn.dtable("select SubsidyUserId,sum(SubsidyProfitRate) from ProfitSubsidyDetail where Status=1 and BrandId=" + BrandId + " and TradeMonth='" + date + "' GROUP BY SubsidyUserId");
|
|
|
+ function.WriteLog("补贴:" + BrandId + ":" + dt.Rows.Count, "同步补贴数据");
|
|
|
+ int index = 0;
|
|
|
+ foreach (DataRow dr in dt.Rows)
|
|
|
{
|
|
|
- DataTable idsDt = OtherMySqlConn.dtable("select Id from ProfitSubsidyDetail where Status=1 and BrandId=" + BrandId + " and TradeMonth='" + date + "' order by Id limit 500");
|
|
|
- if (idsDt.Rows.Count > 0)
|
|
|
+ index += 1;
|
|
|
+ int UserId = int.Parse(dr["SubsidyUserId"].ToString());
|
|
|
+ decimal ProfitMoney = decimal.Parse(dr[1].ToString());
|
|
|
+ var tran = db.Database.BeginTransaction();
|
|
|
+ try
|
|
|
{
|
|
|
- string ids = "";
|
|
|
- foreach (DataRow idsDr in idsDt.Rows)
|
|
|
+ Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
+ UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
|
|
|
+ if (account == null)
|
|
|
{
|
|
|
- ids += idsDr["Id"].ToString() + ",";
|
|
|
- }
|
|
|
- DataTable dt = OtherMySqlConn.dtable("select SubsidyUserId,sum(SubsidyProfitRate) from ProfitSubsidyDetail where Id in (" + ids.TrimEnd(',') + ") GROUP BY SubsidyUserId");
|
|
|
- function.WriteLog("补贴:" + BrandId + ":" + dt.Rows.Count, "同步分润数据");
|
|
|
- int index = 0;
|
|
|
- foreach (DataRow dr in dt.Rows)
|
|
|
- {
|
|
|
- index += 1;
|
|
|
- int UserId = int.Parse(dr["SubsidyUserId"].ToString());
|
|
|
- decimal ProfitMoney = decimal.Parse(dr[1].ToString());
|
|
|
- var tran = db.Database.BeginTransaction();
|
|
|
- try
|
|
|
- {
|
|
|
- Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
|
|
|
- UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
|
|
|
- if (account == null)
|
|
|
- {
|
|
|
- account = db.UserAccount.Add(new UserAccount()
|
|
|
- {
|
|
|
- Id = UserId,
|
|
|
- UserId = UserId,
|
|
|
- }).Entity;
|
|
|
- db.SaveChanges();
|
|
|
- }
|
|
|
- decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
|
|
|
- decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
|
|
|
- decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
|
|
|
- account.BalanceAmount += ProfitMoney;
|
|
|
- account.TotalAmount += ProfitMoney;
|
|
|
- decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
|
|
|
- decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
|
|
|
- decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
|
|
|
- UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
|
|
|
- {
|
|
|
- CreateDate = DateTime.Now,
|
|
|
- UpdateDate = DateTime.Now,
|
|
|
- UserId = UserId, //创客
|
|
|
- ProductType = BrandId,
|
|
|
- ChangeType = 111, //变动类型
|
|
|
- ChangeAmount = ProfitMoney, //变更金额
|
|
|
- BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
- AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
- BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
- AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
- BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
- AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
|
- Remark = "直拓商户补贴",
|
|
|
- }).Entity;
|
|
|
- db.SaveChanges();
|
|
|
- tran.Commit();
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
+ account = db.UserAccount.Add(new UserAccount()
|
|
|
{
|
|
|
- function.WriteLog(DateTime.Now.ToString() + "\n" + UserId + "," + ProfitMoney + "\n" + ex.ToString(), "同步到补贴异常");
|
|
|
- tran.Rollback();
|
|
|
- }
|
|
|
- function.WriteLog(index.ToString(), "同步分润数据");
|
|
|
+ Id = UserId,
|
|
|
+ UserId = UserId,
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
}
|
|
|
- OtherMySqlConn.dtable("update ProfitSubsidyDetail set Status=2 where Id in (" + ids.TrimEnd(',') + ")");
|
|
|
+ decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
|
|
|
+ decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
|
|
|
+ decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
|
|
|
+ account.BalanceAmount += ProfitMoney;
|
|
|
+ account.TotalAmount += ProfitMoney;
|
|
|
+ decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
|
|
|
+ decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
|
|
|
+ decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
|
|
|
+ UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+ UpdateDate = DateTime.Now,
|
|
|
+ UserId = UserId, //创客
|
|
|
+ ProductType = BrandId,
|
|
|
+ ChangeType = 111, //变动类型
|
|
|
+ ChangeAmount = ProfitMoney, //变更金额
|
|
|
+ BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
+ AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
+ BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
+ AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
+ BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
+ AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
|
+ Remark = "直拓商户补贴",
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ tran.Commit();
|
|
|
}
|
|
|
- else
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- op = false;
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + UserId + "," + ProfitMoney + "\n" + ex.ToString(), "同步到补贴异常");
|
|
|
+ tran.Rollback();
|
|
|
}
|
|
|
+ function.WriteLog(index.ToString(), "同步补贴数据");
|
|
|
}
|
|
|
+ OtherMySqlConn.dtable("update ProfitSubsidyDetail set Status=2 where Status=1 and BrandId=" + BrandId + " and TradeMonth='" + date + "'");
|
|
|
+
|
|
|
db.Dispose();
|
|
|
}
|
|
|
}
|