Pārlūkot izejas kodu

修复普通创客获得推荐奖励机制

lichunlei 2 gadi atpakaļ
vecāks
revīzija
6f77abf59c
1 mainītis faili ar 14 papildinājumiem un 4 dzēšanām
  1. 14 4
      AppStart/Helper/AlipayPayBack2Service.cs

+ 14 - 4
AppStart/Helper/AlipayPayBack2Service.cs

@@ -267,30 +267,41 @@ namespace MySystem
                                     return;
                                 }
                                 int ParentUserId = user.ParentUserId;
+                                List<int> proids = new List<int>();
+                                proids.Add(10);
+                                proids.Add(11);
                                 while(ParentUserId > 0)
                                 {
                                     Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
                                     int machineCount = db.PosMachinesTwo.Count(m => m.UserId == ParentUserId && m.PosSnType == 0); //判断是否拥有3台购买机
                                     int ActiveCount = db.PosMachinesTwo.Count(m => m.UserId == ParentUserId && m.ActivationState == 1); //判断是否拥有3台激活机(不限购买或赠送)
                                     int couponCount = db.PosCoupons.Count(m => m.UserId == ParentUserId && m.IsUse == 0); //判断是否拥有3张券
-                                    function.WriteLog("MakerCode:" + user.MakerCode, "推荐下单奖励监控日志");
+                                    function.WriteLog("MakerCode:" + puser.MakerCode, "推荐下单奖励监控日志");
                                     function.WriteLog("machineCount:" + machineCount, "推荐下单奖励监控日志");
                                     function.WriteLog("ActiveCount:" + ActiveCount, "推荐下单奖励监控日志");
                                     if ((machineCount + ActiveCount + couponCount >= 3 || puser.LeaderLevel > 0) && !directPrize)
                                     {
                                         function.WriteLog("满足条件", "推荐下单奖励监控日志");
-                                        if(puser.LeaderLevel == 0) // 非盟主直推奖励,每个上级创客只能获得一次
+                                        if(puser.LeaderLevel == 0) // 非盟主直推奖励,每个创客第一次下单,上级可得
                                         {
-                                            bool check = db.UserAccountRecord.Any(m => m.UserId == ParentUserId && m.ChangeType == 112);
+                                            List<int> oids = new List<int>();
+                                            var orderpros = db.OrderProduct.Select(m => new { m.OrderId,m.UserId,m.ProductId }).Where(m => m.UserId == order.UserId && proids.Contains(m.ProductId)).ToList();
+                                            foreach(var orderpro in orderpros)
+                                            {
+                                                oids.Add(orderpro.OrderId);
+                                            }
+                                            bool check = db.Orders.Any(m => oids.Contains(m.Id) && m.Status > 0);
                                             if(!check)
                                             {
                                                 DirectPrize(db, order.Id, ParentUserId, pro.ProductCount);
+                                                directPrize = true;
                                             }
                                         }
                                         else
                                         {
                                             // 盟主直推奖励,可以每次下单获得
                                             DirectPrize(db, order.Id, ParentUserId, pro.ProductCount);
+                                            directPrize = true;
                                         }
 
                                         //推荐下单上级获得30天的机具循环天数
@@ -304,7 +315,6 @@ namespace MySystem
                                             }
                                         }
                                         db.SaveChanges();
-                                        directPrize = true;
                                     }
                                     if(puser.LeaderLevel > 0)
                                     {