瀏覽代碼

调整机具券逻辑
推荐下单奖励100
修改开机奖励

lichunlei 3 年之前
父節點
當前提交
bad36405f6

+ 97 - 5
AppStart/Helper/AlipayPayBack2Service.cs

@@ -35,7 +35,7 @@ namespace MySystem
                 }
                 else
                 {
-                    function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "public_service");
+                    function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "商城订单支付回调异常");
                 }
             }
         }
@@ -80,18 +80,46 @@ namespace MySystem
                         db.SaveChanges();
                         RedisDbconn.Instance.Set("Orders:" + order.Id, order);
 
+                        //机具券逻辑
                         OrderProduct pro = db.OrderProduct.FirstOrDefault(m => m.OrderId == OrderId);
                         if (pro != null)
                         {
-                            KqProducts brand = db.KqProducts.FirstOrDefault(m => m.Sort == pro.ProductId);
-                            if (brand != 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.ProductPrice == 200) Kind = 1;
-                                if(pro.ProductPrice == 300) Kind = 2;
+                                if (pro.ProductId == 10)
+                                {
+                                    Kind = 1;
+                                }
+                                else if (pro.ProductId == 11)
+                                {
+                                    Kind = 2;
+                                }
+                                else if (pro.ProductId == 12)
+                                {
+                                    if (pro.NormId == "12")
+                                    { 
+                                        Kind = 1;
+                                    }
+                                    else if (pro.NormId == "13")
+                                    { 
+                                        Kind = 2;
+                                    }
+                                }
+                                else if (pro.ProductId == 13)
+                                {
+                                    if (pro.NormId == "14")
+                                    { 
+                                        Kind = 1;
+                                    }
+                                    else if (pro.NormId == "15")
+                                    { 
+                                        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)
@@ -143,6 +171,70 @@ namespace MySystem
                                 db.SaveChanges();
                                 RedisDbconn.Instance.Clear("Orders:" + order.Id);
                             }
+
+                            //推荐下单奖励
+                            if (pro.ProductId == 10 || pro.ProductId == 11)
+                            {
+                                bool SelfBuy = db.OrderProduct.Any(m => m.UserId == order.UserId && m.OrderId != OrderId && (m.ProductId == 10 || m.ProductId == 11));
+                                if (!SelfBuy)
+                                {
+                                    Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId);
+                                    if (user != null)
+                                    {
+                                        int ParentUserId = user.ParentUserId;
+                                        bool ParentBuy = db.OrderProduct.Any(m => m.UserId == ParentUserId && (m.ProductId == 10 || m.ProductId == 11));
+                                        if (ParentBuy)
+                                        {
+                                            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();
+                                        }
+                                    }
+                                }
+                            }
                         }
                     }
                 }

+ 3 - 3
AppStart/Helper/StatService.cs

@@ -650,9 +650,9 @@ namespace MySystem
                                             {
                                                 int machineCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.PosSnType == 0); //判断是否拥有3台购买机
                                                 int ActiveCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.ActivationState == 1); //判断是否拥有3台激活机(不限购买或赠送)
-                                                int BigCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.BrandId == 3); //判断是否拥有2台大机
-                                                int BigActiveCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.ActivationState == 1 && m.BrandId == 3); //判断是否拥有2台激活大机(不限购买或赠送)
-                                                if (machineCount >= 3 || ActiveCount >= 3 || BigCount >= 2 || BigActiveCount >= 2)
+                                                // int BigCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.BrandId == 3); //判断是否拥有2台大机
+                                                // int BigActiveCount = db.PosMachinesTwo.Count(m => m.UserId == puser.Id && m.ActivationState == 1 && m.BrandId == 3); //判断是否拥有2台激活大机(不限购买或赠送)
+                                                if (machineCount >= 3 || ActiveCount >= 3)
                                                 {
                                                     int pTopUserId = 0;
                                                     if (!string.IsNullOrEmpty(puser.ParentNav))

二進制
bin/release/netcoreapp3.0/MySystem.dll


二進制
bin/release/netcoreapp3.0/MySystem.pdb


二進制
obj/release/netcoreapp3.0/MySystem.dll


二進制
obj/release/netcoreapp3.0/MySystem.pdb