lichunlei 3 лет назад
Родитель
Сommit
dc1c6d438b
4 измененных файлов с 78 добавлено и 20 удалено
  1. 11 0
      AppStart/Tables/RecommendPriceList.cs
  2. 60 13
      Controllers/HomeController.cs
  3. 5 5
      Startup.cs
  4. 2 2
      appsettings.json

+ 11 - 0
AppStart/Tables/RecommendPriceList.cs

@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+namespace MySystem
+{
+    public class RecommendPriceList
+    {
+        public int UserId { get; set; }
+        public int ActCount { get; set; }
+        public decimal TradeAmount { get; set; }
+    }
+}

+ 60 - 13
Controllers/HomeController.cs

@@ -48,12 +48,13 @@ namespace MySystem.Controllers
 
 
 
-        // 推荐王奖励
+        // 推荐王奖励666 // TODO:待完善
         public string InvitePrize666(string month)
         {
             DateTime start = DateTime.Parse(month + "-01 00:00:00");
             DateTime end = start.AddMonths(1);
             string TradeMonth = start.ToString("yyyyMM");
+            List<RecommendPriceList> userdic = new List<RecommendPriceList>();
             WebCMSEntities db = new WebCMSEntities();
             //判断当月是否下单
             bool checkOrder = db.Orders.Any(m => m.PayDate >= start && m.PayDate < end && m.Status > 0 && m.TotalPrice == 66);
@@ -63,27 +64,73 @@ namespace MySystem.Controllers
                 List<int> uids = db.Orders.Where(m => m.PayDate >= start && m.PayDate < end && m.Status > 0 && m.TotalPrice == 66).ToList().Select(m => m.UserId).Distinct().ToList();
                 foreach(int uid in uids)
                 {
-                    decimal tradeAmt = 0; //机具总交易额
-                    int actPosCount = 0; //激活机具数量
-                    //查询当前创客所属机具
-                    var posList = db.PosMachinesTwo.Select(m => new { m.ActivationState, m.ActivationTime, m.BuyUserId, m.BindMerchantId }).Where(m => m.BuyUserId == uid && m.ActivationState == 1 && m.ActivationTime >= start && m.ActivationTime < end).ToList();
-                    if(posList.Count > 0)
+                    int ActCount = 0;
+                    List<Users> users = db.Users.Where(m => m.ParentUserId == uid && m.AuthFlag == 1 && m.AuthDate >= start).ToList();
+                    foreach(Users user in users)
                     {
-                        actPosCount = posList.Count;
-                        foreach(var pos in posList)
+                        int BeforeActCount = db.PosMachinesTwo.Count(m => m.BuyUserId == user.Id && m.ActivationState == 1 && m.ActivationTime < start);
+                        if(BeforeActCount == 0)
                         {
-                            //查询机具交易额
-                            bool checkTrade = db.PosMerchantTradeSummay.Any(m => m.MerchantId == pos.BindMerchantId && m.TradeMonth == TradeMonth);
-                            if(checkTrade)
+                            decimal tradeAmt = 0; //机具总交易额
+                            int actPosCount = 0; //激活机具数量
+                            //查询当前创客所属机具
+                            var posList = db.PosMachinesTwo.Select(m => new { m.ActivationState, m.ActivationTime, m.BuyUserId, m.BindMerchantId }).Where(m => m.BuyUserId == user.Id && m.ActivationState == 1 && m.ActivationTime >= start && m.ActivationTime < end).ToList();
+                            if(posList.Count > 0)
                             {
-                                tradeAmt = db.PosMerchantTradeSummay.Where(m => m.MerchantId == pos.BindMerchantId && m.TradeMonth == TradeMonth).Sum(m => m.TradeAmount);                     
+                                actPosCount = posList.Count;
+                                foreach(var pos in posList)
+                                {
+                                    //查询机具交易额
+                                    bool checkTrade = db.PosMerchantTradeSummay.Any(m => m.MerchantId == pos.BindMerchantId && m.TradeMonth == TradeMonth);
+                                    if(checkTrade)
+                                    {
+                                        tradeAmt += db.PosMerchantTradeSummay.Where(m => m.MerchantId == pos.BindMerchantId && m.TradeMonth == TradeMonth).Sum(m => m.TradeAmount);
+                                    }
+                                }                                
+                                decimal AvgTradeAmount = tradeAmt / actPosCount;
+                                if(AvgTradeAmount >= 30000 && actPosCount >= 3)
+                                {
+                                    ActCount += 1;
+                                }
                             }
                         }
                     }
+                    RecommendPriceList item = userdic.FirstOrDefault(m => m.UserId == uid);
+                    if(item != null)
+                    {
+                        item.ActCount += ActCount;
+                    }
+                    else
+                    {
+                        userdic.Add(new RecommendPriceList()
+                        {
+                            UserId = uid,
+                            ActCount = ActCount,
+                        });
+                    }
+                }
+            }
+            string html = "<table>";
+            foreach(RecommendPriceList item in userdic)
+            {
+                string status = "未达标";
+                if(item.ActCount >= 6)
+                {
+                    status = "已达标";
                 }
+                Users user = db.Users.FirstOrDefault(m => m.Id == item.UserId) ?? new Users();
+                int subCount = db.Users.Count(m => m.ParentUserId == item.UserId && m.AuthFlag == 1 && m.AuthDate >= start);
+                html += "<tr>";
+                html += "<td>" + user.MakerCode + "</td>"; //创客编号
+                html += "<td>" + user.RealName + "</td>"; //创客姓名
+                html += "<td>" + subCount + "</td>"; //推荐总数
+                html += "<td>" + item.ActCount + "</td>"; //成功推荐数
+                html += "<td>" + status + "</td>"; //是否达标
+                html += "</tr>";
             }
+            html += "</table>";
             db.Dispose();
-            return "";
+            return html;
         }
 
         // 创客达标返600

+ 5 - 5
Startup.cs

@@ -133,11 +133,11 @@ namespace MySystem
                     pattern: "{controller=Home}/{action=Index}/{Id?}");
             });
 
-            ResetUserTradeService.Instance.Start();
-            ResetMerchantTradeService.Instance.Start();
-            SycnProfitServiceV2.Instance.Start();
-            ExcelHelper.Instance.Start();
-            TestHelper.Instance.Start();
+            // ResetUserTradeService.Instance.Start();
+            // ResetMerchantTradeService.Instance.Start();
+            // SycnProfitServiceV2.Instance.Start();
+            // ExcelHelper.Instance.Start();
+            // TestHelper.Instance.Start();
         }
 
 

+ 2 - 2
appsettings.json

@@ -16,8 +16,8 @@
     "DbSchemeUrl": "",
     "Host": "http://test.bs.kexiaoshuang.com/",
     "Database": "KxsMainServer",
-    "SqlConnStr": "server=47.109.31.237;port=3306;user=KxsMainServer;password=Rw2imhXQQt5ODWIF;database=KxsMainServer;charset=utf8;",
-    "StatSqlConnStr": "server=47.109.31.237;port=3306;user=KxsMainServer;password=Rw2imhXQQt5ODWIF;database=KxsMainServer;charset=utf8;ConnectionTimeout=600;DefaultCommandTimeout=600;",
+    "SqlConnStr": "server=47.108.231.170;port=3306;user=KxsMain;password=mzeqjriUWore0dwT;database=KxsMainServer;charset=utf8;",
+    "StatSqlConnStr": "server=47.108.231.170;port=3306;user=KxsMain;password=mzeqjriUWore0dwT;database=KxsMainServer;charset=utf8;ConnectionTimeout=600;DefaultCommandTimeout=600;",
     "BsSqlConnStr": "server=47.109.31.237;port=3306;user=KxsBsServer;password=wyA1bEhi6aAkN8SB;database=KxsBsServer;charset=utf8;",
     "SpSqlConnStr": "server=47.109.31.237;port=3306;user=KxsSpServer;password=jJ9qKsvwWgQA9xWG;database=KxsSpServer;charset=utf8;",
     "CashSqlConnStr": "server=47.109.31.237;port=3306;user=KxsCashServer;password=LNGvM18W6SaIGKBC;database=KxsCashServer;charset=utf8;",