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

+ 408 - 3
AppStart/Helper/AlipayPayBack2Service.cs

@@ -72,12 +72,417 @@ namespace MySystem
                 foreach (string idString in ids)
                 {
                     int OrderId = int.Parse(idString);
-                    DoOrder(db, OrderId);
+                    DoOrderV2(db, OrderId);
                 }
             }
             db.Dispose();
         }
 
+        #region 新订单流程
+        public void DoOrderV2(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;
+                if(order.ParentOrderId > 0)
+                {
+                    int total = db.Orders.Count(m => m.ParentOrderId == order.ParentOrderId);
+                    int paycount = db.Orders.Count(m => m.ParentOrderId == order.ParentOrderId && m.Status > 0);
+                    if(paycount + 1 >= total)
+                    {
+                        order = db.Orders.FirstOrDefault(m => m.Id == order.ParentOrderId && m.Status == 0);
+                        if (order != null)
+                        {
+                            order.Status = 2;
+                            order.PayDate = DateTime.Now;
+                            order.PayStatus = 1;
+                            OrderId = order.Id;
+                        }
+                    }
+                }
+                db.SaveChanges();
+                if(order.ParentOrderId > 0)
+                {
+                    return;
+                }
+
+                OrderProduct pro = db.OrderProduct.FirstOrDefault(m => m.OrderId == OrderId);
+                if (pro != null)
+                {
+                    if(order.ErpMode > 0)
+                    {
+                        pro.ProductId = order.ProductId;
+                    }
+                    List<int> couponIds = new List<int>();
+                    if (pro.ProductId == 10 || pro.ProductId == 11 || pro.ProductId == 27 || pro.ProductId == 28)
+                    {
+                        order.Status = 2;
+                        int BuyCount = pro.ProductCount;
+                        int Kind = 0;
+                        if (pro.ProductId == 10)
+                        {
+                            Kind = 1;
+                        }
+                        else if (pro.ProductId == 11)
+                        {
+                            Kind = 2;
+                        }
+                        else if (pro.ProductId == 28)
+                        {
+                            Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId && m.LeaderLevel == 0);
+                            if(user != null)
+                            {
+                                user.LeaderLevel = 1;
+                            }
+                        }
+                        else if (pro.ProductId == 27)
+                        {
+                            Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId && m.LeaderLevel < 2);
+                            if(user != null)
+                            {
+                                user.LeaderLevel = 2;
+                            }
+                        }
+                        if(Kind <= 2 && pro.ProductId == 10 || pro.ProductId == 11)
+                        {
+                            // 购买600一组机具券,返券
+                            int CouponCount = 0;
+                            if(Kind == 1)
+                            {
+                                CouponCount = 3 * pro.ProductCount;
+                            }
+                            else if(Kind == 2)
+                            {
+                                CouponCount = 2 * pro.ProductCount;
+                            }
+                            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(CouponCount).ToList();
+                            foreach (var coupon in coupons) // TODO: 数量多的话,会慢
+                            {
+                                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 + ",";
+                                    couponIds.Add(coupon.Id);
+                                }
+                            }
+                            order.SnNos = Codes.TrimEnd(',');
+                        }
+                        db.SaveChanges();
+                        if (pro.ProductId == 27 || pro.ProductId == 28)
+                        {
+                            //充值盟主储备金
+                            OpReserve(db, order, order.UserId, order.TotalPrice, 1);
+                        }
+                    }
+
+                    //推荐下单奖励
+                    if (pro.ProductId == 10 || pro.ProductId == 11)
+                    {
+                        bool checkPrize = db.UserAccountRecord.Any(m => m.QueryCount == OrderId);
+                        function.WriteLog("OrderId:" + OrderId, "推荐下单奖励监控日志");
+                        function.WriteLog("checkPrize:" + checkPrize, "推荐下单奖励监控日志");
+                        if (!checkPrize)
+                        {
+                            Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId);
+                            if (user != null)
+                            {
+                                bool directPrize = false; //直推奖标记
+                                bool bigLeaderPrize = false; //大盟主券标记
+                                bool buyPrize = false; //返100购机奖励标记
+                                int leaderFlag = 0; //返600备用金标记
+                                if(user.LeaderLevel > 0)
+                                {
+                                    UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == order.UserId) ?? new UserAccount();
+                                    if(acccount.LeaderReserve >= order.TotalPrice)
+                                    {
+                                        if(order.PayMode == 4)
+                                        {
+                                            //扣减备用金
+                                            OpReserve(db, order, order.UserId, order.TotalPrice, 2, 0, "商城购机");
+                                            //返回到余额
+                                            // OpAccount(db, order, order.UserId, order.TotalPrice / pro.ProductCount, pro.ProductCount);
+                                        }
+                                    }
+                                    //获得100元奖励
+                                    OpAccount(db, order, order.UserId, 100, pro.ProductCount);
+                                    //推荐奖励
+                                    DirectPrize(db, order.Id, order.UserId, pro.ProductCount);
+                                    //推荐下单上级获得30天的机具循环天数
+                                    var posList = db.PosMachinesTwo.Select(m => new { m.Id, m.UserId, m.BindingState, m.RecycEndDate }).Where(m => m.UserId == order.UserId && 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();
+                                    if(user.LeaderLevel == 2)
+                                    {
+                                        if(couponIds.Count > 0)
+                                        {
+                                            foreach(int couponId in couponIds)
+                                            {
+                                                PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
+                                                if(coupon != null)
+                                                {
+                                                    coupon.LeaderUserId = user.Id;
+                                                }
+                                            }
+                                            db.SaveChanges();
+                                        }
+                                    }
+                                    else
+                                    {
+                                        int PUserId = user.ParentUserId;
+                                        while(PUserId > 0)
+                                        {
+                                            Users puser = db.Users.FirstOrDefault(m => m.Id == PUserId) ?? new Users();
+                                            if(puser.LeaderLevel == 2)
+                                            {
+                                                UserAccount acc = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id) ?? new UserAccount();
+                                                if(acc.LeaderReserve >= order.TotalPrice)
+                                                {
+                                                    //扣减备用金
+                                                    OpReserve(db, order, puser.Id, order.TotalPrice, 2, order.UserId, "购机奖励");
+                                                    //返回到余额
+                                                    OpAccount(db, order, puser.Id, order.TotalPrice / pro.ProductCount, pro.ProductCount);
+                                                }
+                                                PUserId = 0;
+                                            }
+                                            else
+                                            {
+                                                PUserId = puser.ParentUserId;
+                                            }
+                                        }
+                                    }
+                                    return;
+                                }
+                                int ParentUserId = user.ParentUserId;
+                                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("machineCount:" + machineCount, "推荐下单奖励监控日志");
+                                    function.WriteLog("ActiveCount:" + ActiveCount, "推荐下单奖励监控日志");
+                                    if ((machineCount + ActiveCount + couponCount >= 3 || puser.LeaderLevel > 0) && !directPrize)
+                                    {
+                                        function.WriteLog("满足条件", "推荐下单奖励监控日志");
+                                        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();
+                                        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();
+                                        directPrize = true;
+                                    }
+                                    if(puser.LeaderLevel > 0)
+                                    {
+                                        UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id) ?? new UserAccount();
+                                        if(acccount.LeaderReserve >= order.TotalPrice && !buyPrize)
+                                        {
+                                            //购机奖励
+                                            OpAccount(db, order, puser.Id, 100, pro.ProductCount);
+                                            buyPrize = true;
+                                        }
+                                        if(acccount.LeaderReserve >= order.TotalPrice && puser.LeaderLevel > leaderFlag)
+                                        {
+                                            //扣减备用金
+                                            OpReserve(db, order, puser.Id, order.TotalPrice, 2, order.UserId, "购机奖励");
+                                            //返回到余额
+                                            OpAccount(db, order, puser.Id, order.TotalPrice / pro.ProductCount, pro.ProductCount);
+                                            leaderFlag = puser.LeaderLevel;
+                                        }
+                                        //如果是大盟主,则标记大盟主标签
+                                        if(couponIds.Count > 0 && puser.LeaderLevel == 2 && acccount.LeaderReserve >= order.TotalPrice && !bigLeaderPrize)
+                                        {
+                                            foreach(int couponId in couponIds)
+                                            {
+                                                PosCoupons coupon = db.PosCoupons.FirstOrDefault(m => m.Id == couponId);
+                                                if(coupon != null)
+                                                {
+                                                    coupon.LeaderUserId = puser.Id;
+                                                }
+                                            }
+                                            db.SaveChanges();
+                                            bigLeaderPrize = true;
+                                        }
+                                    }
+                                    ParentUserId = puser.ParentUserId;
+                                }
+                            }
+                        }
+                        function.WriteLog("\r\n\r\n", "推荐下单奖励监控日志");
+                    }
+                }
+                else
+                {
+                    if(order.ProductId > 0 && order.ErpMode > 0)
+                    {
+                        //盟主储备金-升级/购买 ErpMode:1-升级,2-购买
+                        if(order.ErpMode > 0)
+                        {
+                            Users user = db.Users.FirstOrDefault(m => m.Id == order.UserId);
+                            if(user != null)
+                            {
+                                if(order.ErpMode == 1)
+                                {
+                                    user.LeaderLevel = 2;
+                                    db.SaveChanges();
+                                }
+                                OpReserve(db, order, order.UserId, order.TotalPrice, 1);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        //操作储备金
+        public void OpReserve(WebCMSEntities db, Orders order, int UserId, decimal Money, int ChangeType, int SourceUserId = 0, string Remark = "储备金购买")
+        {
+            UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
+            if (account == null)
+            {
+                account = db.UserAccount.Add(new UserAccount()
+                {
+                    Id = UserId,
+                    UserId = UserId,
+                }).Entity;
+                db.SaveChanges();
+            }
+            decimal BeforeAmount = account.LeaderReserve; //变更前总金额
+            if(ChangeType == 1)
+            {
+                account.LeaderReserve += Money;
+            }
+            else
+            {
+                account.LeaderReserve -= Money;
+            }
+            decimal AfterAmount = account.LeaderReserve; //变更后总金额
+            LeaderReserveRecord add = db.LeaderReserveRecord.Add(new LeaderReserveRecord()
+            {
+                CreateDate = DateTime.Now,
+                ChangeType = ChangeType,
+                OrderId = order.Id,
+                Remark = Remark,
+                AfterAmt = AfterAmount,
+                BeforeAmt = BeforeAmount,
+                ChangeAmt = Money,
+                TradeDate = DateTime.Now.ToString("yyyyMMdd"),
+                TradeMonth = DateTime.Now.ToString("yyyyMM"),
+                UserId = UserId,
+                SourceUserId = SourceUserId,
+            }).Entity;
+            db.SaveChanges();
+        }
+        //操作余额
+        public void OpAccount(WebCMSEntities db, Orders order, int UserId, decimal Money, int Count = 1)
+        {
+            UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
+            if (account == null)
+            {
+                account = db.UserAccount.Add(new UserAccount()
+                {
+                    Id = UserId,
+                    UserId = UserId,
+                }).Entity;
+                db.SaveChanges();
+            }
+            int ChangeType = 0;
+            if(Money == 600)
+            {
+                ChangeType = 117;
+            }
+            else if(Money == 100)
+            {
+                ChangeType = 118;
+            }
+            decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
+            decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
+            decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
+            account.BalanceAmount += Money * Count;
+            account.TotalAmount += Money * Count;
+            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 = UserId, //创客
+                ChangeType = ChangeType, //变动类型
+                ChangeAmount = Money * Count, //变更金额
+                BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
+                AfterTotalAmount = AfterTotalAmount, //变更后总金额
+                BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
+                AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
+                BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
+                AfterBalanceAmount = AfterBalanceAmount, //变更后余额
+                QueryCount = order.Id,
+            }).Entity;
+            db.SaveChanges();
+        }
+        public void DirectPrize(WebCMSEntities db, int OrderId, int UserId, int Count = 1)
+        {
+            UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == UserId);
+            if (account == null)
+            {
+                account = db.UserAccount.Add(new UserAccount()
+                {
+                    Id = UserId,
+                    UserId = UserId,
+                }).Entity;
+                db.SaveChanges();
+            }
+            decimal BeforeTotalAmount = account.TotalAmount; //变更前总金额
+            decimal BeforeFreezeAmount = account.FreezeAmount; //变更前冻结金额
+            decimal BeforeBalanceAmount = account.BalanceAmount; //变更前余额
+            account.BalanceAmount += 100 * Count;
+            account.TotalAmount += 100 * Count;
+            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 = UserId, //创客
+                ChangeType = 112, //变动类型
+                ChangeAmount = 100 * Count, //变更金额
+                BeforeTotalAmount = BeforeTotalAmount, //变更前总金额
+                AfterTotalAmount = AfterTotalAmount, //变更后总金额
+                BeforeFreezeAmount = BeforeFreezeAmount, //变更前冻结金额
+                AfterFreezeAmount = AfterFreezeAmount, //变更后冻结金额
+                BeforeBalanceAmount = BeforeBalanceAmount, //变更前余额
+                AfterBalanceAmount = AfterBalanceAmount, //变更后余额
+                QueryCount = OrderId,
+            }).Entity;
+            db.SaveChanges();
+        }
+
+        #endregion
+
+        #region 老订单流程
         public void DoOrder(WebCMSEntities db, int OrderId)
         {
             Orders order = db.Orders.FirstOrDefault(m => m.Id == OrderId && m.Status == 0);
@@ -333,14 +738,12 @@ namespace MySystem
                 }
             }
         }
-
         public void checkOrder(int OrderId)
         {
             WebCMSEntities db = new WebCMSEntities();
             DoOrder(db, OrderId);
             db.Dispose();
         }
-
         public void addcoupon(int OrderId)
         {
             WebCMSEntities db = new WebCMSEntities();
@@ -506,5 +909,7 @@ namespace MySystem
             }
             db.Dispose();
         }
+    
+        #endregion
     }
 }

+ 2 - 2
AppStart/Helper/BalancePayBackService.cs

@@ -59,7 +59,7 @@ namespace MySystem
                     TotalPrice = 0.01M;
                 }
                 string ProductName = "";
-                List<OrderProduct> orderPros = db.OrderProduct.Where(m=>m.OrderId == OrderId).ToList();
+                List<OrderProduct> orderPros = db.OrderProduct.Where(m => m.OrderId == OrderId).ToList();
                 foreach(OrderProduct orderPro in orderPros)
                 {
                     ProductName += orderPro.ProductName + ",";
@@ -98,7 +98,7 @@ namespace MySystem
                             Remark = "购买" + ProductName,
                         }).Entity;
                         db.SaveChanges();
-                        AlipayPayBack2Service.Instance.DoOrder(db, OrderId);
+                        AlipayPayBack2Service.Instance.DoOrderV2(db, OrderId);
                     }
                 }
             }

+ 69 - 0
AppStart/Helper/ReservePayBackService.cs

@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Data;
+using System.Threading;
+using MySystem.PxcModels;
+using Library;
+using LitJson;
+
+namespace MySystem
+{
+    public class ReservePayBackService
+    {
+        public readonly static ReservePayBackService Instance = new ReservePayBackService();
+        private ReservePayBackService()
+        { }
+
+        public void Start()
+        {
+            Thread th = new Thread(dosomething);
+            th.IsBackground = true;
+            th.Start();
+        }
+        
+        private void dosomething()
+        {
+            while (true)
+            {
+                try
+                {
+                    string content = RedisDbconn.Instance.RPop<string>("ReservePayQueue");
+                    if (!string.IsNullOrEmpty(content))
+                    {
+                        sloveAlipayCallBack(content);
+                    }
+                    else
+                    {
+                        Thread.Sleep(2000);
+                    }
+                }
+                catch (Exception ex)
+                {
+                    function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "商城订单余额支付异常");
+                    Thread.Sleep(2000);
+                }
+            }
+        }
+
+        public void sloveAlipayCallBack(string content)
+        {
+            int OrderId = int.Parse(function.CheckInt(content));
+            WebCMSEntities db = new WebCMSEntities();
+            Orders order = db.Orders.FirstOrDefault(m => m.Id == OrderId && m.PayMode == 4 && m.PayStatus == 0);
+            if (order != null)
+            {
+                decimal TotalPrice = order.TotalPrice;
+                UserAccount account = db.UserAccount.FirstOrDefault(m => m.Id == order.UserId);
+                if (account != null)
+                {
+                    if(account.LeaderReserve >= TotalPrice)
+                    {
+                        AlipayPayBack2Service.Instance.DoOrderV2(db, OrderId);
+                    }
+                }
+            }
+            db.Dispose();
+        }
+    }
+}

+ 61 - 0
Controllers/HomeController.cs

@@ -960,5 +960,66 @@ namespace MySystem.Controllers
             }
         }
         
+
+
+
+        //重置交易额,重置分润(直营)
+        // /home/resetProfit?uid=120687&m=2022-06&bid=1
+        public string resetProfit(int uid, string m, int bid)
+        {
+            string result = "";
+            OtherMySqlConn.connstr = "server=47.109.31.237;port=3306;user=KxsMainServer2;password=FrW8ZfxlcaVdm1r0;database=KxsMainServer2;charset=utf8;";
+            DateTime start = DateTime.Parse(m + "-01 00:00:00");
+            DateTime end = start.AddMonths(1);
+            decimal ProfitAmt = 0;
+            while(start < end)
+            {
+                DateTime endDay = start.AddDays(1);
+                DataTable dt = OtherMySqlConn.dtable("select sum(HelpDirectTradeAmt) as HelpDirectTradeAmt,sum(NotHelpDirectTradeAmt) as NotHelpDirectTradeAmt from TradeDaySummary where UserId=" + uid + " and TradeDate='" + start.ToString("yyyyMMdd") + "' and SeoTitle='self' and BrandId=" + bid);
+                if(dt.Rows.Count > 0)
+                {
+                    decimal HelpDirectTradeAmt = decimal.Parse(function.CheckNum(dt.Rows[0]["HelpDirectTradeAmt"].ToString()));
+                    decimal NotHelpDirectTradeAmt = decimal.Parse(function.CheckNum(dt.Rows[0]["NotHelpDirectTradeAmt"].ToString()));
+                    result += "扶持期:" + HelpDirectTradeAmt + ",稳定期:" + NotHelpDirectTradeAmt + ";\n";
+                    dt = OtherMySqlConn.dtable("select sum(if(MerHelpFlag=1,TradeAmount,0)) as HelpAmt,sum(if(MerHelpFlag=0,TradeAmount,0)) as NotHelpAmt from TradeRecord where CreateDate>='" + start.ToString("yyyy-MM-dd HH:mm:ss") + "' and CreateDate<'" + endDay.ToString("yyyy-MM-dd HH:mm:ss") + "' and UserId=" + uid + " and BrandId=" + bid);
+                    if(dt.Rows.Count > 0)
+                    {
+                        decimal HelpAmt = decimal.Parse(function.CheckNum(dt.Rows[0]["HelpAmt"].ToString()));
+                        decimal NotHelpAmt = decimal.Parse(function.CheckNum(dt.Rows[0]["NotHelpAmt"].ToString()));
+                        result += "update TradeDaySummary set HelpDirectTradeAmt=" + HelpAmt + ",NotHelpDirectTradeAmt=" + NotHelpAmt + " where UserId=" + uid + " and TradeDate='" + start.ToString("yyyyMMdd") + "' and SeoTitle='self' and BrandId=" + bid + ";\n\n";
+                        dt = OtherMySqlConn.dtable("select UserLevel from Users where Id=" + uid + "");
+                        if(dt.Rows.Count > 0)
+                        {
+                            int UserLevel = int.Parse(function.CheckInt(dt.Rows[0]["UserLevel"].ToString()));
+                            dt = OtherMySqlConn.dtable("select Rank from UserRankWhite where Id=" + uid + "");
+                            if(dt.Rows.Count > 0)
+                            {
+                                UserLevel = int.Parse(function.CheckInt(dt.Rows[0]["Rank"].ToString()));
+                            }
+                            int LevelKindId = ProfitHelperV2.Instance.GetLevelKindId(bid, 1, 1);
+                            ProfitObjectLevels objlevel = RedisDbconn.Instance.Get<ProfitObjectLevels>("pobjlv" + LevelKindId + ":" + UserLevel) ?? new ProfitObjectLevels();
+                            ProfitAmt += HelpAmt * objlevel.Percents;
+                            LevelKindId = ProfitHelperV2.Instance.GetLevelKindId(bid, 0, 1);
+                            objlevel = RedisDbconn.Instance.Get<ProfitObjectLevels>("pobjlv" + LevelKindId + ":" + UserLevel) ?? new ProfitObjectLevels();
+                            ProfitAmt += NotHelpAmt * objlevel.Percents;
+                        }
+                    }
+                }
+                start = start.AddDays(1);
+            }
+            DataTable dt2 = OtherMySqlConn.dtable("select Id,ProfitAmount from ProfitRecord where UserId=" + uid + " and SeoTitle='" + m.Replace("-", "") + "' and DirectFlag=1 and BrandId=" + bid);
+            if(dt2.Rows.Count > 0)
+            {
+                int Id = int.Parse(function.CheckInt(dt2.Rows[0]["Id"].ToString()));
+                decimal ProfitAmount = decimal.Parse(function.CheckNum(dt2.Rows[0]["ProfitAmount"].ToString()));
+                result += "当前分润:" + ProfitAmount + ";\n";
+                if(ProfitAmount != ProfitAmt)
+                {
+                    result += "update ProfitRecord set ProfitAmount=" + ProfitAmt + " where UserId=" + uid + " and SeoTitle='" + m.Replace("-", "") + "' and DirectFlag=1 and BrandId=" + bid + ";\n";
+                }
+            }
+            OtherMySqlConn.connstr = "";
+            return result;
+        }
     }
 }

+ 16 - 15
Startup.cs

@@ -90,8 +90,8 @@ namespace MySystem
             // services.AddHostedService<PopService>();
             // services.AddHostedService<SycnSpTimer>(); //同步SP数据
 
-            services.AddHostedService<TimerStatTimer>(); //实时统计创客、激活商户数
-            services.AddHostedService<PosTradeStatTimer>(); // 统计头天的交易额、商户型创客、激活奖励、开机奖励
+            // services.AddHostedService<TimerStatTimer>(); //实时统计创客、激活商户数
+            // services.AddHostedService<PosTradeStatTimer>(); // 统计头天的交易额、商户型创客、激活奖励、开机奖励
             services.AddHostedService<AlipayPayBack2Timer>(); //支付宝回调处理
 
             //services.AddHttpContextAccessor();
@@ -190,20 +190,21 @@ namespace MySystem
             // TradeStatTimer2.Instance.Start(); //交易统计
 
             //必须打开的
-            ActiveRewardTimer.Instance.Start(); //实时处理激活记录
-            TradeStatTimer.Instance.Start(); //交易统计
-            ChangePosTimer.Instance.Start(); //售后换新执行机具数据转移
-            MakeReferenceQrCodeService.Instance.StartListen(); //生成创客邀请二维码
-            SycnSpBindService.Instance.Start(); //同步SP绑定数据
-            SycnSpMerchantService.Instance.Start(); //同步SP商户数据
-            SycnSpActiveService.Instance.Start(); //同步SP激活数据
-            SycnSpTradeService.Instance.Start(); //同步SP交易数据
-            SycnSpChangeBindService.Instance.Start(); //同步SP换绑数据
-            SycnSpUnBindService.Instance.Start(); //同步SP解绑数据
-            RedPackageHelper.Instance.Start(); //每天生成300个红包
-            RedPackageHelper.Instance.StartStatTop10(); //红包活动统计排行
-            RedPackageHelper.Instance.StartSendPrize(); //红包活动发奖
+            // ActiveRewardTimer.Instance.Start(); //实时处理激活记录
+            // TradeStatTimer.Instance.Start(); //交易统计
+            // ChangePosTimer.Instance.Start(); //售后换新执行机具数据转移
+            // MakeReferenceQrCodeService.Instance.StartListen(); //生成创客邀请二维码
+            // SycnSpBindService.Instance.Start(); //同步SP绑定数据
+            // SycnSpMerchantService.Instance.Start(); //同步SP商户数据
+            // SycnSpActiveService.Instance.Start(); //同步SP激活数据
+            // SycnSpTradeService.Instance.Start(); //同步SP交易数据
+            // SycnSpChangeBindService.Instance.Start(); //同步SP换绑数据
+            // SycnSpUnBindService.Instance.Start(); //同步SP解绑数据
+            // RedPackageHelper.Instance.Start(); //每天生成300个红包
+            // RedPackageHelper.Instance.StartStatTop10(); //红包活动统计排行
+            // RedPackageHelper.Instance.StartSendPrize(); //红包活动发奖
             BalancePayBackService.Instance.Start(); //余额支付队列
+            ReservePayBackService.Instance.Start(); //储备金支付队列
             LeaderPrizeService.Instance.Start(); //大盟主奖励发奖
             MessageCenterService.Instance.Start(); // 消息队列
             //必须打开的