Explorar o código

补盟主券兑换购机奖励

lcl hai 1 ano
pai
achega
9a26315485
Modificáronse 2 ficheiros con 72 adicións e 0 borrados
  1. 59 0
      AppStart/Helper/LeaderApplyCouponsHelper.cs
  2. 13 0
      Controllers/HomeController.cs

+ 59 - 0
AppStart/Helper/LeaderApplyCouponsHelper.cs

@@ -172,6 +172,65 @@ namespace MySystem
             opdb.Dispose();
         }
 
+        public void addprize(int Id)
+        { 
+            WebCMSEntities db = new WebCMSEntities();
+            OpModels.WebCMSEntities opdb = new OpModels.WebCMSEntities();
+            var query = db.LeaderReserveRecord.FirstOrDefault(m => m.Id == Id && m.Remark == "兑换机具券");
+            if(query != null)
+            {
+                JsonData ApplyList = JsonMapper.ToObject(query.SeoTitle);
+                UserRankItem orderUser = PosCouponPrizeService.Instance.GetUserLevel(query.UserId);
+                string ParentNav = orderUser.ParentNav + "," + orderUser.Id + ",";
+                string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
+                Array.Reverse(ParentNavList);
+                int index = 0;
+                bool BigLeaderFlag = false; //大盟主标记
+                decimal BuyPrize = 0; //购机奖励
+                foreach(string ParentId in ParentNavList)
+                {
+                    UserRankItem parentUser = PosCouponPrizeService.Instance.GetUserLevel(int.Parse(ParentId));
+                    index += 1;
+
+                    if(parentUser.OperateLevel > 0)
+                    {
+                        int groupCount = 0;
+                        for (int i = 0; i < ApplyList.Count; i++)
+                        {
+                            int num = Convert.ToInt32(ApplyList[i]["Num"].ToString());
+                            int Kind = Convert.ToInt32(ApplyList[i]["Type"].ToString());
+                            if(Kind == 1)
+                            {
+                                groupCount += num / 3;
+                            }
+                            else
+                            {
+                                groupCount += num / 2;
+                            }
+                        }
+                        if(PosCouponPrizeService.Instance.CheckOpReserve(opdb, groupCount, parentUser.Id))
+                        {
+                            //购机奖
+                            decimal CurBuyPrize = GetBuyPrize(parentUser);
+                            decimal GetPrize = CurBuyPrize - BuyPrize;
+                            int Kind = 0;
+                            if(query.Remark == "兑换机具券")
+                            {
+                                Kind = 101;
+                            }
+                            if(GetPrize > 0 && !db.UserAccountRecord.Any(m => m.QueryCount == Id && m.ChangeType == 128)) 
+                            {
+                                PosCouponPrizeService.Instance.OpAccount(db, Id, parentUser.Id, GetPrize, groupCount, 128, Kind);
+                            }
+                            BuyPrize = CurBuyPrize;
+                        }
+                    }
+                }
+            }
+            db.Dispose();
+            opdb.Dispose();
+        }
+
         /// <summary>
         /// 获取购机奖金额
         /// </summary>

+ 13 - 0
Controllers/HomeController.cs

@@ -471,5 +471,18 @@ namespace MySystem.Controllers
             }
             return "ok";
         }
+    
+    
+        public string addprize3()
+        {
+            List<int> ids = new List<int>();
+            foreach(int id in ids)
+            {
+                LeaderApplyCouponsHelper.Instance.addprize(id);
+            }
+            return "ok";
+        }
+    
+    
     }
 }