|
|
@@ -40,11 +40,13 @@ namespace MySystem
|
|
|
{
|
|
|
DoTradeProfit(BrandId, date, SysUserName);
|
|
|
DoSubsidyProfit(BrandId, date);
|
|
|
+ DoHelpProfit(date);
|
|
|
}
|
|
|
else if (OpType == 1)
|
|
|
{
|
|
|
DoTradeProfit2(BrandId, date, SysUserName);
|
|
|
DoSubsidyProfit2(BrandId, date);
|
|
|
+ DoHelpProfit2(date);
|
|
|
}
|
|
|
function.WriteLog(DateTime.Now.ToString() + "\r\n\r\n", "同步分润数据");
|
|
|
}
|
|
|
@@ -271,5 +273,88 @@ namespace MySystem
|
|
|
|
|
|
db.Dispose();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ #region 助力宝分润展示
|
|
|
+
|
|
|
+ private void DoHelpProfit(string month)
|
|
|
+ {
|
|
|
+ OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
|
|
|
+ OtherMySqlConn.dtable("update HelpProfitReward set Status=1 where Status=0 and TradeMonth='" + month + "'");
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 助力宝分润到账
|
|
|
+
|
|
|
+ private void DoHelpProfit2(string month)
|
|
|
+ {
|
|
|
+ WebCMSEntities db = new WebCMSEntities();
|
|
|
+ OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
|
|
|
+
|
|
|
+ DataTable dt = OtherMySqlConn.dtable("select UserId,RewardType,sum(CreditRewardAmount),sum(CreditTradeAmt) from HelpProfitReward where Status=1 and TradeMonth='" + month + "' GROUP BY UserId,RewardType");
|
|
|
+ function.WriteLog("数量:" + dt.Rows.Count, "同步助力宝分润数据");
|
|
|
+ int index = 0;
|
|
|
+ foreach (DataRow dr in dt.Rows)
|
|
|
+ {
|
|
|
+ index += 1;
|
|
|
+ int UserId = int.Parse(dr["UserId"].ToString());
|
|
|
+ int RewardType = int.Parse(dr["RewardType"].ToString());
|
|
|
+ decimal ProfitMoney = decimal.Parse(dr[2].ToString());
|
|
|
+ decimal TradeAmt = decimal.Parse(dr[3].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 = 101,
|
|
|
+ ChangeType = 111, //变动类型
|
|
|
+ ChangeAmount = ProfitMoney, //变更金额
|
|
|
+ BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
|
|
|
+ AfterTotalAmount = AfterTotalAmount, //变更后总金额
|
|
|
+ BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
|
|
|
+ AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
|
|
|
+ BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
|
|
|
+ AfterBalanceAmount = AfterBalanceAmount, //变更后余额
|
|
|
+ Remark = user.RealName.Substring(0, 1) + "**:" + DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + "交易" + TradeAmt.ToString("f2"),
|
|
|
+ }).Entity;
|
|
|
+ db.SaveChanges();
|
|
|
+ tran.Commit();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ function.WriteLog(DateTime.Now.ToString() + "\n" + UserId + "," + ProfitMoney + "\n" + ex.ToString(), "同步助利宝分润异常");
|
|
|
+ tran.Rollback();
|
|
|
+ }
|
|
|
+ function.WriteLog(index.ToString(), "同步补贴数据");
|
|
|
+ }
|
|
|
+ OtherMySqlConn.dtable("update HelpProfitReward set Status=2 where Status=1 and TradeMonth='" + month + "'");
|
|
|
+
|
|
|
+ db.Dispose();
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|