Browse Source

调整升级逻辑

lcl 6 tháng trước cách đây
mục cha
commit
65452e0109
2 tập tin đã thay đổi với 48 bổ sung35 xóa
  1. 22 11
      AppStart/Helper/Profit/ProfitHelperV2.cs
  2. 26 24
      AppStart/Helper/StatService.cs

+ 22 - 11
AppStart/Helper/Profit/ProfitHelperV2.cs

@@ -7,6 +7,7 @@ using Library;
 using System.Threading;
 using Microsoft.Extensions.Hosting;
 using System.Threading.Tasks;
+using Microsoft.AspNetCore.Components.Forms;
 
 namespace MySystem
 {
@@ -40,17 +41,27 @@ namespace MySystem
                 string content = RedisDbconn.Instance.RPop<string>("DoProfitQueue");
                 if(!string.IsNullOrEmpty(content) && DateTime.Now.Day < 26)
                 {
-                    // StatProfiting();
-                    // StatSimProfiting();
-                    ProfitSimBeforeHelper.Instance.StatSimProfiting();
-                    ProfitSimAfterHelper.Instance.StatSimProfiting();
-                    ProfitBeforeHelper.Instance.StatProfiting();
-                    ProfitAfterHelper.Instance.StatProfiting();
-                    HelpProfitHelper.Instance.StatProfitEveryDay(DateTime.Now.AddMonths(-1).ToString("yyyyMM")); //助利宝分润
-                    ProfitWifiHelper.Instance.StatProfiting();
-                    // ProfitWifiBeforeHelper.Instance.StatProfiting();
-                    // ProfitWifiAfterHelper.Instance.StatProfiting();
-                    // ProfitCheckHelper.Instance.Start();
+                    if(RedisDbconn.Instance.Get<string>("EveryMonthLevelFlag") == "1" && RedisDbconn.Instance.Get<string>("EveryMonthProfitFlag") == "1")
+                    {
+                        string ids = "";
+                        List<int> uids = RedisDbconn.Instance.GetList<int>("EveryMonthLevelUserId");
+                        foreach(int uid in uids)
+                        {
+                            ids += uid + ",";
+                        }
+                        CustomerSqlConn.op("update Users" + DateTime.Now.ToString("yyyyMM") + " set UserLevel=1 where Id in (" + ids.TrimEnd(',') + ")", MysqlConn.StatSqlConnStr);
+                        // StatProfiting();
+                        // StatSimProfiting();
+                        ProfitSimBeforeHelper.Instance.StatSimProfiting();
+                        ProfitSimAfterHelper.Instance.StatSimProfiting();
+                        ProfitBeforeHelper.Instance.StatProfiting();
+                        ProfitAfterHelper.Instance.StatProfiting();
+                        HelpProfitHelper.Instance.StatProfitEveryDay(DateTime.Now.AddMonths(-1).ToString("yyyyMM")); //助利宝分润
+                        ProfitWifiHelper.Instance.StatProfiting();
+                        // ProfitWifiBeforeHelper.Instance.StatProfiting();
+                        // ProfitWifiAfterHelper.Instance.StatProfiting();
+                        // ProfitCheckHelper.Instance.Start();
+                    }
                 }
                 else
                 {

+ 26 - 24
AppStart/Helper/StatService.cs

@@ -2194,6 +2194,9 @@ namespace MySystem
                         op = false;
                     }
                 }
+
+                RedisDbconn.Instance.AddList("DoTableEveryMonthQueue", "1");
+                
                 //查找K0创客,如果商城下单购买一组机具券,则预设为K1
                 List<int> productIds = new List<int>();
                 productIds.Add(10);
@@ -2202,38 +2205,36 @@ namespace MySystem
                 startid = 0;
                 while(op)
                 {
+                    List<int> userIds = rdb.Orders.Where(m => m.Status > 0 && productIds.Contains(m.ProductId)).ToList().Select(m => m.UserId).ToList();
                     var users = rdb.Users.Select(m => new { m.Id, m.AuthFlag, m.UserLevel }).Where(m => m.Id > startid && m.AuthFlag == 1 && m.UserLevel == 0).OrderBy(m => m.Id).Take(50).ToList();
                     if(users.Count > 0)
                     {
                         foreach (var subuser in users)
                         {
-                            bool hasOrder = rdb.Orders.Any(m => m.UserId == subuser.Id && m.Status > 0 && productIds.Contains(m.ProductId));
-                            if(hasOrder)
+                            // Utils.Instance.LeaderPreUserLevel(subuser.Id, 1, DateTime.Parse("2025-01-01 00:00:00"));
+                            db.UserRank.Add(new UserRank()
                             {
-                                Utils.Instance.LeaderPreUserLevel(subuser.Id, 1, DateTime.Parse("2025-01-01 00:00:00"));
-                                db.UserRank.Add(new UserRank()
-                                {
-                                    CreateDate = DateTime.Now,
-                                    UpdateDate = DateTime.Now,
-                                    UserId = subuser.Id, //创客
-                                    WhiteRank = 0,
-                                    Rank = 1, //当前等级
-                                    StatYear = DateTime.Now.Year, //统计年份
-                                    StatMonth = DateTime.Now.Month, //统计月份
-                                    TradeAmt = 0, //团队交易总额
-                                    UpgradeFlag = 1, //升级标识
-                                    OperateDate = DateTime.Now, //操作时间
-                                    Status = 1,
-                                });
-                                Users user = db.Users.FirstOrDefault(m => m.Id == subuser.Id);
-                                if(user != null)
-                                {
-                                    user.Version = 3;
-                                }
-                                db.SaveChanges();
+                                CreateDate = DateTime.Now,
+                                UpdateDate = DateTime.Now,
+                                UserId = subuser.Id, //创客
+                                WhiteRank = 0,
+                                Rank = 1, //当前等级
+                                StatYear = DateTime.Now.Year, //统计年份
+                                StatMonth = DateTime.Now.Month, //统计月份
+                                TradeAmt = 0, //团队交易总额
+                                UpgradeFlag = 1, //升级标识
+                                OperateDate = DateTime.Now, //操作时间
+                                Status = 1,
+                            });
+                            Users user = db.Users.FirstOrDefault(m => m.Id == subuser.Id);
+                            if(user != null)
+                            {
+                                user.Version = 3;
                             }
                             startid = subuser.Id;
+                            RedisDbconn.Instance.AddList("EveryMonthLevelUserId", subuser.Id);
                         }
+                        db.SaveChanges();
                     }
                     else
                     {
@@ -2251,7 +2252,8 @@ namespace MySystem
             mpmaindb.Dispose();
             mpmaindb2.Dispose();
 
-            RedisDbconn.Instance.AddList("DoTableEveryMonthQueue", "1");
+            RedisDbconn.Instance.Set("EveryMonthLevelFlag", "1");
+            RedisDbconn.Instance.AddList("DoProfitQueue", "1");
         }