lichunlei il y a 2 ans
Parent
commit
46b1b35b0f

+ 18 - 4
AppStart/Helper/AlipayPayBack2Service.cs

@@ -148,8 +148,18 @@ namespace MySystem
                         }
                         if(Kind <= 2 && pro.ProductId == 10 || pro.ProductId == 11)
                         {
+                            // 购买600一组机具券,返券
+                            int CouponCount = 0;
+                            if(Kind == 1)
+                            {
+                                CouponCount = 3;
+                            }
+                            else if(Kind == 2)
+                            {
+                                CouponCount = 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();
+                            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)
                             {
                                 PosCoupons item = db.PosCoupons.FirstOrDefault(m => m.Id == coupon.Id);
@@ -213,7 +223,9 @@ namespace MySystem
                                     db.SaveChanges();
                                     return;
                                 }
-                                bool directPrize = false;
+                                bool directPrize = false; //直推奖标记
+                                bool bigLeaderPrize = false; //大盟主券标记
+                                bool buyPrize = false; //返600盟主备用标记
                                 int ParentUserId = user.ParentUserId;
                                 while(ParentUserId > 0)
                                 {
@@ -245,7 +257,7 @@ namespace MySystem
                                     if(puser.LeaderLevel > 0)
                                     {
                                         UserAccount acccount = db.UserAccount.FirstOrDefault(m => m.Id == puser.Id) ?? new UserAccount();
-                                        if(acccount.LeaderReserve >= order.TotalPrice)
+                                        if(acccount.LeaderReserve >= order.TotalPrice && !buyPrize)
                                         {
                                             //扣减备用金
                                             OpReserve(db, order, puser.Id, order.TotalPrice, 0, order.UserId, "购机奖励");
@@ -253,9 +265,10 @@ namespace MySystem
                                             OpAccount(db, order, puser.Id, order.TotalPrice);
                                             //购机奖励
                                             OpAccount(db, order, puser.Id, 100);
+                                            buyPrize = true;
                                         }
                                         //如果是大盟主,则标记大盟主标签
-                                        if(couponIds.Count > 0 && puser.LeaderLevel == 2)
+                                        if(couponIds.Count > 0 && puser.LeaderLevel == 2 && !bigLeaderPrize)
                                         {
                                             foreach(int couponId in couponIds)
                                             {
@@ -266,6 +279,7 @@ namespace MySystem
                                                 }
                                             }
                                             db.SaveChanges();
+                                            bigLeaderPrize = true;
                                         }
                                     }
                                     ParentUserId = puser.ParentUserId;

+ 1 - 1
AppStart/Helper/Profit/ProfitHelperV2.cs

@@ -19,7 +19,7 @@ namespace MySystem
         
         #region 获取分润规则Id
 
-        private int GetLevelKindId(int BrandId, int Help, int BankCardType)
+        public int GetLevelKindId(int BrandId, int Help, int BankCardType)
         {
             return RedisDbconn.Instance.Get<int>("pobjlv:kid:" + BrandId + ":" + Help + ":" + BankCardType);
         }

+ 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;
+        }
     }
 }