Эх сурвалжийг харах

增加补发小盟主15000返现方法
修复每天1000个商机的bug

lichunlei 2 жил өмнө
parent
commit
b4e52602cf

+ 43 - 37
AppStart/Helper/AlipayPayBack2Service.cs

@@ -208,43 +208,7 @@ namespace MySystem
                         }
                         if (pro.ProductId == 28) //购买小盟主,给上级大盟主返储备金
                         {
-                            int LeaderUserId = order.UserId;
-                            int level = 0;
-                            while(LeaderUserId > 0)
-                            {
-                                level += 1;
-                                Users user = db.Users.FirstOrDefault(m => m.Id == LeaderUserId);
-                                if(user != null)
-                                {
-                                    if(user.LeaderLevel == 2 && level > 1)
-                                    {
-                                        UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == LeaderUserId);
-                                        if(account != null)
-                                        {
-                                            if(account.LeaderReserve >= order.TotalPrice)
-                                            {
-                                                OpReserve(db, order, LeaderUserId, order.TotalPrice, 2, 0, "推荐小盟主");
-                                                OpLeaderAccount(db, order, LeaderUserId, order.TotalPrice);
-                                            }
-                                            else
-                                            {
-                                                decimal LeaderReserve = account.LeaderReserve;
-                                                OpReserve(db, order, LeaderUserId, LeaderReserve, 2, 0, "推荐小盟主");
-                                                OpLeaderAccount(db, order, LeaderUserId, LeaderReserve);
-                                            }
-                                        }
-                                        LeaderUserId = 0;
-                                    }
-                                    else
-                                    {
-                                        LeaderUserId = user.ParentUserId;
-                                    }
-                                }
-                                else
-                                {
-                                    LeaderUserId = 0;
-                                }
-                            }
+                            LeaderBack(db, order);
                         }
                     }
 
@@ -463,6 +427,48 @@ namespace MySystem
             }
         }
 
+        //小盟主购买逻辑
+        public void LeaderBack(WebCMSEntities db, Orders order)
+        {
+            int LeaderUserId = order.UserId;
+            int level = 0;
+            while(LeaderUserId > 0)
+            {
+                level += 1;
+                Users user = db.Users.FirstOrDefault(m => m.Id == LeaderUserId);
+                if(user != null)
+                {
+                    if(user.LeaderLevel == 2 && level > 1)
+                    {
+                        UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == LeaderUserId);
+                        if(account != null)
+                        {
+                            if(account.LeaderReserve >= order.TotalPrice)
+                            {
+                                OpReserve(db, order, LeaderUserId, order.TotalPrice, 2, 0, "推荐小盟主");
+                                OpLeaderAccount(db, order, LeaderUserId, order.TotalPrice);
+                            }
+                            else
+                            {
+                                decimal LeaderReserve = account.LeaderReserve;
+                                OpReserve(db, order, LeaderUserId, LeaderReserve, 2, 0, "推荐小盟主");
+                                OpLeaderAccount(db, order, LeaderUserId, LeaderReserve);
+                            }
+                        }
+                        LeaderUserId = 0;
+                    }
+                    else
+                    {
+                        LeaderUserId = user.ParentUserId;
+                    }
+                }
+                else
+                {
+                    LeaderUserId = 0;
+                }
+            }
+        }
+
         //操作储备金
         public void OpReserve(WebCMSEntities db, Orders order, int UserId, decimal Money, int ChangeType, int SourceUserId = 0, string Remark = "储备金购买")
         {

+ 1 - 1
AppStart/Helper/Profit/HelpProfitPreMerchantHelper.cs

@@ -54,7 +54,7 @@ namespace MySystem
                 function.WritePage("/PublicParam/", "HelpProfitMerCount.txt", GetCount);
             }
             RedisDbconn.Instance.Clear("HelpProfitMerchantIds");
-            DataTable dt = OtherMySqlConn.dtable("SELECT MerchantId,sum FROM( SELECT MerchantId,BrandId,SUM(TradeAmount) sum FROM PosMerchantTradeSummay WHERE MerchantId not in (select MerchantId from HelpProfitMerIds) AND TradeMonth in ('" + Month1 + "','" + Month2 + "','" + Month3 + "') GROUP BY MerchantId)a WHERE a.sum/3 >= 35000 and a.sum/3 <= 50000 limit " + GetCount);
+            DataTable dt = OtherMySqlConn.dtable("SELECT MerchantId,sum FROM( SELECT MerchantId,SUM(TradeAmount) sum FROM PosMerchantTradeSummay WHERE MerchantId not in (select MerchantId from HelpProfitMerIds) AND TradeMonth in ('" + Month1 + "','" + Month2 + "','" + Month3 + "') GROUP BY MerchantId)a WHERE a.sum/3 >= 35000 and a.sum/3 <= 50000 limit " + GetCount);
             foreach(DataRow dr in dt.Rows)
             {
                 RedisDbconn.Instance.AddList("HelpProfitMerchantIds", int.Parse(function.CheckInt(dr["MerchantId"].ToString())));

+ 12 - 0
Controllers/HomeController.cs

@@ -136,6 +136,18 @@ namespace MySystem.Controllers
             StatService.Instance.doFluxRecord(date);
             return "ok";
         }
+        // 补发小盟主15000返现
+        public string LeaderBack(int oid)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            Orders order = db.Orders.FirstOrDefault(m => m.Id == oid);
+            if(order != null)
+            {
+                AlipayPayBack2Service.Instance.LeaderBack(db, order);
+            }
+            db.Dispose();
+            return "ok";
+        }
         public string chkactprize(int Id = 0)
         {
             if (Id > 0)