瀏覽代碼

普通创客只能获得一次推荐奖励
添加海科标记判断

lichunlei 2 年之前
父節點
當前提交
08d1dbfba0
共有 3 個文件被更改,包括 16 次插入439 次删除
  1. 13 430
      AppStart/Helper/AlipayPayBack2Service.cs
  2. 3 3
      AppStart/Helper/StatService.cs
  3. 0 6
      Controllers/HomeController.cs

+ 13 - 430
AppStart/Helper/AlipayPayBack2Service.cs

@@ -279,7 +279,19 @@ namespace MySystem
                                     if ((machineCount + ActiveCount + couponCount >= 3 || puser.LeaderLevel > 0) && !directPrize)
                                     {
                                         function.WriteLog("满足条件", "推荐下单奖励监控日志");
-                                        DirectPrize(db, order.Id, ParentUserId, pro.ProductCount);
+                                        if(puser.LeaderLevel == 0) // 非盟主直推奖励,每个上级创客只能获得一次
+                                        {
+                                            bool check = db.UserAccountRecord.Any(m => m.UserId == ParentUserId && m.ChangeType == 112);
+                                            if(!check)
+                                            {
+                                                DirectPrize(db, order.Id, ParentUserId, pro.ProductCount);
+                                            }
+                                        }
+                                        else
+                                        {
+                                            // 盟主直推奖励,可以每次下单获得
+                                            DirectPrize(db, order.Id, ParentUserId, pro.ProductCount);
+                                        }
 
                                         //推荐下单上级获得30天的机具循环天数
                                         var posList = db.PosMachinesTwo.Select(m => new { m.Id, m.UserId, m.BindingState, m.RecycEndDate }).Where(m => m.UserId == ParentUserId && m.BindingState == 0 && m.RecycEndDate != null).ToList();
@@ -496,434 +508,5 @@ namespace MySystem
 
         #endregion
 
-        #region 老订单流程
-        public void DoOrder(WebCMSEntities db, int OrderId)
-        {
-            Orders order = db.Orders.FirstOrDefault(m => m.Id == OrderId && m.Status == 0);
-            if (order != null)
-            {
-                order.Status = 1;
-                order.PayDate = DateTime.Now;
-                order.PayStatus = 1;
-                db.SaveChanges();
-                RedisDbconn.Instance.Set("Orders:" + order.Id, order);
-
-                //机具券逻辑
-                OrderProduct pro = db.OrderProduct.FirstOrDefault(m => m.OrderId == OrderId);
-                if (pro != null)
-                {
-                    if (pro.ProductId == 10 || pro.ProductId == 11 || pro.ProductId == 12 || pro.ProductId == 13)
-                    {
-                        order.Status = 2;
-                        db.SaveChanges();
-                        int BuyCount = pro.ProductCount;
-                        int Kind = 0;
-                        if (pro.ProductId == 10)
-                        {
-                            Kind = 1;
-                        }
-                        else if (pro.ProductId == 11)
-                        {
-                            Kind = 2;
-                        }
-                        else if (pro.ProductId == 12)
-                        {
-                            if (pro.NormDetail == "电签POS")
-                            {
-                                Kind = 1;
-                            }
-                            else if (pro.NormDetail == "大POS")
-                            {
-                                Kind = 2;
-                            }
-                        }
-                        else if (pro.ProductId == 13)
-                        {
-                            if (pro.NormDetail == "300电签POS")
-                            {
-                                Kind = 1;
-                            }
-                            else if (pro.NormDetail == "200大POS")
-                            {
-                                Kind = 2;
-                            }
-                            else if (pro.NormDetail == "50大机券+225电签券")
-                            {
-                                Kind = 3;
-                            }
-                            else if (pro.NormDetail == "100大机券+150电签券")
-                            {
-                                Kind = 4;
-                            }
-                            else if (pro.NormDetail == "150大机券+75电签券")
-                            {
-                                Kind = 5;
-                            }
-                        }
-                        string Codes = "";
-                        if(Kind > 2)
-                        {
-                            Dictionary<int, int> couponData = new Dictionary<int, int>();
-                            if(Kind == 3)
-                            {
-                                couponData.Add(1, 225); //电签数量
-                                couponData.Add(2, 50); //大机数量
-                            }
-                            else if(Kind == 4)
-                            {
-                                couponData.Add(1, 150); //电签数量
-                                couponData.Add(2, 100); //大机数量
-                            }
-                            else if(Kind == 5)
-                            {
-                                couponData.Add(1, 75); //电签数量
-                                couponData.Add(2, 150); //大机数量
-                            }
-                            foreach(int kindNum in couponData.Keys)
-                            {
-                                int BuyCountByKind = couponData[kindNum];
-                                var coupons = db.PosCoupons.Where(m => m.IsLock == 0 && m.IsUse == 0 && m.UserId == 0 && m.QueryCount == kindNum).OrderBy(m => m.Id).Take(BuyCountByKind).ToList();
-                                foreach (var coupon in coupons)
-                                {
-                                    PosCoupons item = db.PosCoupons.FirstOrDefault(m => m.Id == coupon.Id);
-                                    if (item != null)
-                                    {
-                                        item.CreateDate = DateTime.Now;
-                                        item.UserId = order.UserId;
-                                        item.UpdateDate = DateTime.Now.AddDays(180);
-                                        if (pro.ProductId == 13)
-                                        {
-                                            item.LeaderUserId = order.UserId;
-                                        }
-                                        Codes += item.ExchangeCode + ",";
-                                    }
-                                }
-                            }
-                        }
-                        else
-                        {
-                            var coupons = db.PosCoupons.Where(m => m.IsLock == 0 && m.IsUse == 0 && m.UserId == 0 && m.QueryCount == Kind).OrderBy(m => m.Id).Take(BuyCount).ToList();
-                            foreach (var coupon in coupons)
-                            {
-                                PosCoupons item = db.PosCoupons.FirstOrDefault(m => m.Id == coupon.Id);
-                                if (item != null)
-                                {
-                                    item.CreateDate = DateTime.Now;
-                                    item.UserId = order.UserId;
-                                    item.UpdateDate = DateTime.Now.AddDays(180);
-                                    if (pro.ProductId == 13)
-                                    {
-                                        item.LeaderUserId = order.UserId;
-                                    }
-                                    Codes += item.ExchangeCode + ",";
-                                }
-                            }
-                        }
-                        order.SnNos = Codes.TrimEnd(',');
-                        string ChangeRecordNo = "SC" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
-                        PosCouponForUser forUser = db.PosCouponForUser.FirstOrDefault(m => m.Id == order.UserId);
-                        if (forUser == null)
-                        {
-                            forUser = db.PosCouponForUser.Add(new PosCouponForUser()
-                            {
-                                Id = order.UserId,
-                            }).Entity;
-                            db.SaveChanges();
-                        }
-                        int BeforeOut = forUser.OutNum;
-                        int BeforeTotal = forUser.TotalNum;
-                        int BeforeStock = forUser.StockNum;
-                        forUser.TotalNum += BuyCount;
-                        forUser.StockNum += BuyCount;
-                        int AfterOut = forUser.OutNum;
-                        int AfterTotal = forUser.TotalNum;
-                        int AfterStock = forUser.StockNum;
-                        PosCouponOrders stat = db.PosCouponOrders.Add(new PosCouponOrders()
-                        {
-                            QueryCount = Kind,
-                            CreateDate = DateTime.Now,
-                            ChangeKind = 1,
-                            ChangeCount = BuyCount,
-                            AfterOut = AfterOut,
-                            AfterTotal = AfterTotal,
-                            AfterStock = AfterStock,
-                            BeforeOut = BeforeOut,
-                            BeforeTotal = BeforeTotal,
-                            BeforeStock = BeforeStock,
-                            OrderNo = ChangeRecordNo,
-                            ToUserId = order.UserId,
-                            FromUserId = 0,
-                        }).Entity;
-                        db.SaveChanges();
-                        RedisDbconn.Instance.Clear("Orders:" + order.Id);
-                    }
-
-                    //推荐下单奖励
-                    if (pro.ProductId == 10 || pro.ProductId == 11)
-                    {
-                        bool checkPrize = db.UserAccountRecord.Any(m => m.QueryCount == OrderId);
-                        int SelfBuy = 0;
-                        OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
-                        DataTable stat = OtherMySqlConn.dtable("select count(Id) from Orders where Id in (select OrderId from OrderProduct where UserId=" + order.UserId + " and (ProductId=10 or ProductId=11)) and Status>0 and TotalPrice>0");
-                        if (stat.Rows.Count > 0)
-                        {
-                            SelfBuy = int.Parse(function.CheckInt(stat.Rows[0][0].ToString()));
-                        }
-                        // OtherMySqlConn.connstr = ;
-                        function.WriteLog("OrderId:" + OrderId, "推荐下单奖励监控日志");
-                        function.WriteLog("checkPrize:" + checkPrize, "推荐下单奖励监控日志");
-                        function.WriteLog("SelfBuy:" + SelfBuy, "推荐下单奖励监控日志");
-                        if (SelfBuy == 1 && !checkPrize)
-                        {
-                            Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId);
-                            if (user != null)
-                            {
-                                int ParentUserId = user.ParentUserId;
-                                while(ParentUserId > 0)
-                                {
-                                    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("machineCount:" + machineCount, "推荐下单奖励监控日志");
-                                    function.WriteLog("ActiveCount:" + ActiveCount, "推荐下单奖励监控日志");
-                                    if (machineCount + ActiveCount + couponCount >= 3)
-                                    {
-                                        function.WriteLog("满足条件", "推荐下单奖励监控日志");
-                                        UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == ParentUserId);
-                                        if (account == null)
-                                        {
-                                            account = db.UserAccount.Add(new UserAccount()
-                                            {
-                                                Id = ParentUserId,
-                                                UserId = ParentUserId,
-                                            }).Entity;
-                                            db.SaveChanges();
-                                        }
-                                        decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
-                                        decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
-                                        decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
-                                        account.BalanceAmount += 100;
-                                        account.TotalAmount += 100;
-                                        decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
-                                        decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
-                                        decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
-                                        UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
-                                        {
-                                            CreateDate = DateTime.Now,
-                                            UpdateDate = DateTime.Now,
-                                            UserId = ParentUserId, //创客
-                                            ChangeType = 112, //变动类型
-                                            ChangeAmount = 100, //变更金额
-                                            BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
-                                            AfterTotalAmount = AfterTotalAmount, //变更后总金额
-                                            BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
-                                            AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
-                                            BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
-                                            AfterBalanceAmount = AfterBalanceAmount, //变更后余额
-                                            QueryCount = OrderId,
-                                        }).Entity;
-                                        db.SaveChanges();
-                                        RedisDbconn.Instance.Set("UserAccount:" + ParentUserId, account);
-
-                                        //推荐下单上级获得30天的机具循环天数
-                                        var posList = db.PosMachinesTwo.Select(m => new { m.Id, m.UserId, m.BindingState, m.RecycEndDate }).Where(m => m.UserId == ParentUserId && m.BindingState == 0 && m.RecycEndDate != null).ToList();
-                                        foreach (var subPos in posList)
-                                        {
-                                            PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == subPos.Id);
-                                            if (pos != null)
-                                            {
-                                                pos.RecycEndDate = pos.RecycEndDate.Value.AddDays(30);
-                                            }
-                                        }
-                                        db.SaveChanges();
-                                        ParentUserId = 0;
-                                    }
-                                    else
-                                    {
-                                        Users puser = db.Users.FirstOrDefault(m => m.Id == ParentUserId) ?? new Users();
-                                        ParentUserId = puser.ParentUserId;
-                                    }
-                                }
-                            }
-                        }
-                        function.WriteLog("\r\n\r\n", "推荐下单奖励监控日志");
-                    }
-                }
-            }
-        }
-        public void checkOrder(int OrderId)
-        {
-            WebCMSEntities db = new WebCMSEntities();
-            DoOrder(db, OrderId);
-            db.Dispose();
-        }
-        public void addcoupon(int OrderId)
-        {
-            WebCMSEntities db = new WebCMSEntities();
-            Orders order = db.Orders.FirstOrDefault(m => m.Id == OrderId);
-            if (order != null)
-            {
-                //机具券逻辑
-                OrderProduct pro = db.OrderProduct.FirstOrDefault(m => m.OrderId == OrderId);
-                if (pro != null)
-                {
-                    if (pro.ProductId == 10 || pro.ProductId == 11 || pro.ProductId == 12 || pro.ProductId == 13)
-                    {
-                        int BuyCount = pro.ProductCount;
-                        int Kind = 0;
-                        if (pro.ProductId == 10)
-                        {
-                            Kind = 1;
-                        }
-                        else if (pro.ProductId == 11)
-                        {
-                            Kind = 2;
-                        }
-                        else if (pro.ProductId == 12)
-                        {
-                            if (pro.NormDetail == "电签POS")
-                            { 
-                                Kind = 1;
-                            }
-                            else if (pro.NormDetail == "大POS")
-                            { 
-                                Kind = 2;
-                            }
-                        }
-                        else if (pro.ProductId == 13)
-                        {
-                            if (pro.NormDetail == "电签POS")
-                            { 
-                                Kind = 1;
-                            }
-                            else if (pro.NormDetail == "大POS")
-                            { 
-                                Kind = 2;
-                            }
-                        }
-                        string Codes = "";
-                        var coupons = db.PosCoupons.Where(m => m.IsLock == 0 && m.IsUse == 0 && m.UserId == 0 && m.QueryCount == Kind).OrderBy(m => m.Id).Take(BuyCount).ToList();
-                        foreach (var coupon in coupons)
-                        {
-                            PosCoupons item = db.PosCoupons.FirstOrDefault(m => m.Id == coupon.Id);
-                            if (item != null)
-                            {
-                                item.CreateDate = DateTime.Now;
-                                item.UserId = order.UserId;
-                                item.UpdateDate = DateTime.Now.AddDays(180);
-                                Codes += item.ExchangeCode + ",";
-                            }
-                        }
-                        order.SnNos = Codes.TrimEnd(',');
-                        string ChangeRecordNo = "SC" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
-                        PosCouponForUser forUser = db.PosCouponForUser.FirstOrDefault(m => m.Id == order.UserId);
-                        if (forUser == null)
-                        {
-                            forUser = db.PosCouponForUser.Add(new PosCouponForUser()
-                            {
-                                Id = order.UserId,
-                            }).Entity;
-                            db.SaveChanges();
-                        }
-                        int BeforeOut = forUser.OutNum;
-                        int BeforeTotal = forUser.TotalNum;
-                        int BeforeStock = forUser.StockNum;
-                        forUser.TotalNum += BuyCount;
-                        forUser.StockNum += BuyCount;
-                        int AfterOut = forUser.OutNum;
-                        int AfterTotal = forUser.TotalNum;
-                        int AfterStock = forUser.StockNum;
-                        PosCouponOrders stat = db.PosCouponOrders.Add(new PosCouponOrders()
-                        {
-                            QueryCount = Kind,
-                            CreateDate = DateTime.Now,
-                            ChangeKind = 1,
-                            ChangeCount = BuyCount,
-                            AfterOut = AfterOut,
-                            AfterTotal = AfterTotal,
-                            AfterStock = AfterStock,
-                            BeforeOut = BeforeOut,
-                            BeforeTotal = BeforeTotal,
-                            BeforeStock = BeforeStock,
-                            OrderNo = ChangeRecordNo,
-                            ToUserId = order.UserId,
-                            FromUserId = 0,
-                        }).Entity;
-                        db.SaveChanges();
-                        RedisDbconn.Instance.Clear("Orders:" + order.Id);
-                    }
-
-                    //推荐下单奖励
-                    if (pro.ProductId == 10 || pro.ProductId == 11)
-                    {
-                        int SelfBuy = db.OrderProduct.Count(m => m.UserId == order.UserId && m.OrderId != OrderId && (m.ProductId == 10 || m.ProductId == 11));
-                        if (SelfBuy == 1)
-                        {
-                            Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId);
-                            if (user != null)
-                            {
-                                int ParentUserId = user.ParentUserId;
-                                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张券
-                                if (machineCount + ActiveCount + couponCount >= 3)
-                                {
-                                    UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == ParentUserId);
-                                    if (account == null)
-                                    {
-                                        account = db.UserAccount.Add(new UserAccount()
-                                        {
-                                            Id = ParentUserId,
-                                            UserId = ParentUserId,
-                                        }).Entity;
-                                        db.SaveChanges();
-                                    }
-                                    decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
-                                    decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
-                                    decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
-                                    account.BalanceAmount += 100;
-                                    account.TotalAmount += 100;
-                                    decimal AfterTotalAmount = account.TotalAmount; //变更后总金额
-                                    decimal AfterFreezeAmount = account.FreezeAmount; //变更后冻结金额
-                                    decimal AfterBalanceAmount = account.BalanceAmount; //变更后余额
-                                    UserAccountRecord userAccountRecord = db.UserAccountRecord.Add(new UserAccountRecord()
-                                    {
-                                        CreateDate = DateTime.Now,
-                                        UpdateDate = DateTime.Now,
-                                        UserId = ParentUserId, //创客
-                                        ChangeType = 112, //变动类型
-                                        ChangeAmount = 100, //变更金额
-                                        BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
-                                        AfterTotalAmount = AfterTotalAmount, //变更后总金额
-                                        BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
-                                        AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
-                                        BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
-                                        AfterBalanceAmount = AfterBalanceAmount, //变更后余额
-                                    }).Entity;
-                                    db.SaveChanges();
-                                    RedisDbconn.Instance.Set("UserAccount:" + ParentUserId, account);
-
-                                    //推荐下单上级获得30天的机具循环天数
-                                    var posList = db.PosMachinesTwo.Select(m => new { m.Id, m.UserId, m.BindingState, m.RecycEndDate }).Where(m => m.UserId == ParentUserId && m.BindingState == 0 && m.RecycEndDate != null);
-                                    foreach (var subPos in posList)
-                                    {
-                                        PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == subPos.Id);
-                                        if (pos != null)
-                                        {
-                                            pos.RecycEndDate = pos.RecycEndDate.Value.AddDays(30);
-                                        }
-                                    }
-                                    db.SaveChanges();
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-            db.Dispose();
-        }
-    
-        #endregion
     }
 }

+ 3 - 3
AppStart/Helper/StatService.cs

@@ -272,7 +272,7 @@ namespace MySystem
                             TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
                         }
                         decimal ActPrize = decimal.Parse(function.CheckNum(pos.SeoKeyword));
-                        if (pos.BrandId == 1 || pos.BrandId == 3 || pos.BrandId == 4 || pos.BrandId == 5 || pos.BrandId == 6)
+                        if (pos.BrandId == 1 || pos.BrandId == 3 || pos.BrandId == 4 || pos.BrandId == 5 || pos.BrandId == 6 || pos.BrandId == 8 || pos.BrandId == 9)
                         {
                             ActPrize = ActPrize / 100;
                         }
@@ -498,7 +498,7 @@ namespace MySystem
                         TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
                     }
                     decimal ActPrize = decimal.Parse(function.CheckNum(merchant.SeoKeyword));
-                    if (pos.BrandId == 1 || pos.BrandId == 3)
+                    if (pos.BrandId == 1 || pos.BrandId == 3 || pos.BrandId == 4 || pos.BrandId == 5 || pos.BrandId == 6 || pos.BrandId == 8 || pos.BrandId == 9)
                     {
                         ActPrize = ActPrize / 100;
                     }
@@ -1013,7 +1013,7 @@ namespace MySystem
                     DateTime TradeDate = trade.CreateDate.Value;
                     string TradeMonth = TradeDate.ToString("yyyyMM");
                     decimal FeeAmount = trade.FeeAmount; //流量费
-                    if (trade.ProductType == "1" || trade.ProductType == "4" || trade.ProductType == "6")
+                    if (trade.ProductType == "1" || trade.ProductType == "4" || trade.ProductType == "6" || trade.ProductType == "8" || trade.ProductType == "9")
                     {
                         FeeAmount = FeeAmount / 100;
                     }

+ 0 - 6
Controllers/HomeController.cs

@@ -169,12 +169,6 @@ namespace MySystem.Controllers
             return "ok";
         }
 
-        public string checkOrder(int id)
-        {
-            AlipayPayBack2Service.Instance.checkOrder(id);
-            return "ok";
-        }
-
         public string scanBind()
         {
             SpModels.WebCMSEntities spdb = new SpModels.WebCMSEntities();