Explorar el Código

领导人达标奖

lcl hace 2 años
padre
commit
3c47d9a15c
Se han modificado 1 ficheros con 51 adiciones y 53 borrados
  1. 51 53
      AppStart/Helper/LeaderCompPrizeHelper.cs

+ 51 - 53
AppStart/Helper/LeaderCompPrizeHelper.cs

@@ -49,8 +49,8 @@ namespace MySystem
 
         public void Ready(string curMonth)
         {
-            // CustomerSqlConn.op("delete from LeaderCompTradeStat;delete from LeaderCompTmp;delete from LeaderCompPrize;delete from LeaderCompAddTrade;", MysqlConn.SqlConnStr);
-            // doSomething(curMonth, curMonth);
+            CustomerSqlConn.op("delete from LeaderCompTradeStat;delete from LeaderCompTmp;delete from LeaderCompPrize;delete from LeaderCompAddTrade;", MysqlConn.SqlConnStr);
+            doSomething(curMonth, curMonth);
             SendPrize(curMonth, curMonth);
         }
 
@@ -66,60 +66,58 @@ namespace MySystem
 
                 //统计交易增量
                 function.WriteLog(DateTime.Now.ToString(), "领导人达标奖励日志");
-
-
                 
                 //创客团队交易额
-                // string sql = "";
-                // int num = 0;
-                // DataTable dt = CustomerSqlConn.dtable("select UserId,sum(HelpNonDirectTradeAmt + NotHelpNonDirectTradeAmt + ProfitNonDirectTradeAmt + HelpNonDirectDebitTradeAmt + NotHelpNonDirectDebitTradeAmt + ProfitNonDirectDebitTradeAmt) Amt from TradeDaySummary where Id>=15055757 and TradeMonth='" + month + "' and SeoTitle='team' and UserId>0 group by UserId", MysqlConn.ReadSqlConnStr);
-                // foreach(DataRow dr in dt.Rows)
-                // {
-                //     int UserId = int.Parse(dr["UserId"].ToString());
-                //     decimal TradeAmount = decimal.Parse(dr["Amt"].ToString());
-                //     //码牌团队交易额(直联)
-                //     bool check = mpmaindb.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1);
-                //     if (check)
-                //     {
-                //         TradeAmount += mpmaindb.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1).Sum(m => m.TotalAmount) * 4;
-                //     }
-                //     check = mpmaindb.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1);
-                //     if (check)
-                //     {
-                //         TradeAmount += mpmaindb.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1).Sum(m => m.TotalAmount);
-                //     }
-                //     //码牌团队交易额(银联)
-                //     check = mpmaindb2.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1);
-                //     if (check)
-                //     {
-                //         TradeAmount += mpmaindb2.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1).Sum(m => m.TotalAmount) * 4;
-                //     }
-                //     check = mpmaindb2.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1);
-                //     if (check)
-                //     {
-                //         TradeAmount += mpmaindb2.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1).Sum(m => m.TotalAmount);
-                //     }
-                //     //广电卡扶持期按1万/张计入职级
-                //     check = db.UserTradeMonthSummary.Any(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.BrandId == 14);
-                //     if (check)
-                //     {
-                //         TradeAmount += db.UserTradeMonthSummary.Where(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.BrandId == 14).Sum(m => m.ActiveBuddyMerStatus) * 10000;
-                //     }
-                //     sql += "insert into LeaderCompTradeStat (CreateDate,UserId,StatMonth,TradeAmount) values (now(), " + UserId + ", '" + month + "-" + checkMonth + "', " + TradeAmount + ");\n";
-                //     num += 1;
-                //     if(num >= 200)
-                //     {
-                //         CustomerSqlConn.op(sql, MysqlConn.SqlConnStr);
-                //         sql = "";
-                //         num = 0;
-                //     }
-                // }
+                string sql = "";
+                int num = 0;
+                DataTable dt = CustomerSqlConn.dtable("select UserId,sum(HelpNonDirectTradeAmt + NotHelpNonDirectTradeAmt + ProfitNonDirectTradeAmt + HelpNonDirectDebitTradeAmt + NotHelpNonDirectDebitTradeAmt + ProfitNonDirectDebitTradeAmt) Amt from TradeDaySummary where Id>=15055757 and TradeMonth='" + month + "' and SeoTitle='team' and UserId>0 group by UserId", MysqlConn.ReadSqlConnStr);
+                foreach(DataRow dr in dt.Rows)
+                {
+                    int UserId = int.Parse(dr["UserId"].ToString());
+                    decimal TradeAmount = decimal.Parse(dr["Amt"].ToString());
+                    //码牌团队交易额(直联)
+                    bool check = mpmaindb.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1);
+                    if (check)
+                    {
+                        TradeAmount += mpmaindb.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1).Sum(m => m.TotalAmount) * 4;
+                    }
+                    check = mpmaindb.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1);
+                    if (check)
+                    {
+                        TradeAmount += mpmaindb.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1).Sum(m => m.TotalAmount);
+                    }
+                    //码牌团队交易额(银联)
+                    check = mpmaindb2.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1);
+                    if (check)
+                    {
+                        TradeAmount += mpmaindb2.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1).Sum(m => m.TotalAmount) * 4;
+                    }
+                    check = mpmaindb2.UserAmountSummary.Any(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1);
+                    if (check)
+                    {
+                        TradeAmount += mpmaindb2.UserAmountSummary.Where(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.IsAct == 1).Sum(m => m.TotalAmount);
+                    }
+                    //广电卡扶持期按1万/张计入职级
+                    check = db.UserTradeMonthSummary.Any(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.BrandId == 14);
+                    if (check)
+                    {
+                        TradeAmount += db.UserTradeMonthSummary.Where(m => m.UserId == UserId && m.TradeMonth == month && m.SeoTitle == "team" && m.BrandId == 14).Sum(m => m.ActiveBuddyMerStatus) * 10000;
+                    }
+                    sql += "insert into LeaderCompTradeStat (CreateDate,UserId,StatMonth,TradeAmount) values (now(), " + UserId + ", '" + month + "-" + checkMonth + "', " + TradeAmount + ");\n";
+                    num += 1;
+                    if(num >= 200)
+                    {
+                        CustomerSqlConn.op(sql, MysqlConn.SqlConnStr);
+                        sql = "";
+                        num = 0;
+                    }
+                }
 
-                // if(!string.IsNullOrEmpty(sql))
-                // {
-                //     CustomerSqlConn.op(sql, MysqlConn.SqlConnStr);
-                // }
-                // CustomerSqlConn.op("update LeaderCompTradeStat leader set ParentUserId=case when (select ParentUserId from Users where Id=leader.UserId) is null then 0 else (select ParentUserId from Users where Id=leader.UserId) end,ParentNav=(select ParentNav from Users where Id=leader.UserId) where StatMonth='" + MonthString + "' and UserId>1", MysqlConn.SqlConnStr);
+                if(!string.IsNullOrEmpty(sql))
+                {
+                    CustomerSqlConn.op(sql, MysqlConn.SqlConnStr);
+                }
+                CustomerSqlConn.op("update LeaderCompTradeStat leader set ParentUserId=case when (select ParentUserId from Users where Id=leader.UserId) is null then 0 else (select ParentUserId from Users where Id=leader.UserId) end,ParentNav=(select ParentNav from Users where Id=leader.UserId) where StatMonth='" + MonthString + "' and UserId>1", MysqlConn.SqlConnStr);
 
                 function.WriteLog("start-----" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "领导人达标奖励日志");