Browse Source

盈利期分润

lichunlei 2 years ago
parent
commit
f16259d184
1 changed files with 70 additions and 1 deletions
  1. 70 1
      AppStart/Helper/Profit/ProfitHelperV2.cs

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

@@ -410,7 +410,7 @@ namespace MySystem
                 string sqlstr = "";
                 if (BankCardType == 1)
                 {
-                    sqlstr = "select UserId,QueryCount,sum(HelpDirectTradeAmt),sum(NotHelpDirectTradeAmt) from TradeDaySummary where Id>2194000 and TradeDate='" + Date + "' and SeoTitle='self' and BrandId=" + BrandId + " group by UserId,QueryCount having sum(HelpDirectTradeAmt)>0 or sum(NotHelpDirectTradeAmt)>0 order by UserId" + LimitString;
+                    sqlstr = "select UserId,QueryCount,sum(HelpDirectTradeAmt),sum(NotHelpDirectTradeAmt),sum(ProfitHelpDirectTradeAmt) from TradeDaySummary where Id>2194000 and TradeDate='" + Date + "' and SeoTitle='self' and BrandId=" + BrandId + " group by UserId,QueryCount having sum(HelpDirectTradeAmt)>0 or sum(NotHelpDirectTradeAmt)>0 or sum(ProfitHelpDirectTradeAmt)>0 order by UserId" + LimitString;
                 }
                 if (BankCardType == 0)
                 {
@@ -464,6 +464,7 @@ namespace MySystem
                                 function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":贷记卡", "分润监控日志");
                                 decimal HelpDirectTradeAmt = decimal.Parse(dr[2].ToString()); //贷记卡扶持期交易额
                                 decimal NotHelpDirectTradeAmt = decimal.Parse(dr[3].ToString()); //贷记卡稳定期交易额
+                                decimal ProfitHelpDirectTradeAmt = decimal.Parse(dr[4].ToString()); //贷记卡盈利期期交易额
                                 int maxLevel = obj.MaxLevel; //最大等级
                                 decimal diffLevelProfit = 0;  //等级级差
                                 int curLevel = 0; //当前层级的会员等级
@@ -662,6 +663,74 @@ namespace MySystem
                                             curLevel = UserLevel;
                                         }
                                     }
+                                    function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":盈利期:" + ProfitHelpDirectTradeAmt, "分润监控日志");
+                                    if (ProfitHelpDirectTradeAmt > 0)
+                                    {
+                                        level = 0;
+                                        curLevel = 0;
+                                        diffLevelProfit = 0;  //等级级差
+                                        foreach (string UserIdString in ParentNavList)
+                                        {
+                                            level += 1;
+                                            int uid = int.Parse(UserIdString);
+                                            Users user = dbnew.Users.FirstOrDefault(m => m.Id == uid) ?? new Users();
+                                            int UserLevel = user.UserLevel; //当前会员等级
+                                            UserRankWhite rank = dbnew.UserRankWhite.FirstOrDefault(m => m.Id == user.Id && m.CreateDate < ThisMonth && m.UpdateDate > now);
+                                            if (rank != null)
+                                            {
+                                                if (rank.Rank > UserLevel)
+                                                {
+                                                    UserLevel = rank.Rank;
+                                                }
+                                            }
+                                            if (curLevel == maxLevel) //判断当前创客是否有直推的激活机具,并且在活动时间内
+                                            {
+                                                break;
+                                            }
+                                            if (UserLevel <= maxLevel && UserLevel > curLevel)
+                                            {
+                                                int LevelKindId = GetLevelKindId(BrandId, 2, 1);
+                                                ProfitObjectLevels objlevel = RedisDbconn.Instance.Get<ProfitObjectLevels>("pobjlv" + LevelKindId + ":" + UserLevel); //获取当前等级参数
+                                                if (objlevel != null)
+                                                {
+                                                    decimal getLevelProfit = 0;  //等级分润
+                                                    if (objlevel.Percents > 0)
+                                                    {
+                                                        getLevelProfit += ProfitHelpDirectTradeAmt * objlevel.Percents;
+                                                    }
+                                                    if (objlevel.AddProfitVal > 0)
+                                                    {
+                                                        getLevelProfit += objlevel.AddProfitVal;
+                                                    }
+                                                    decimal money = getLevelProfit;
+                                                    getLevelProfit -= diffLevelProfit;
+                                                    if (objlevel.LevelDiff == 1)  //判断是否有级差
+                                                    {
+                                                        diffLevelProfit = money;
+                                                    }
+                                                    if (getLevelProfit >= obj.MinProfitVal)
+                                                    {
+                                                        result.Add(new ProfitResult()
+                                                        {
+                                                            UserId = user.Id,
+                                                            UserNav = user.ParentNav,
+                                                            Money = PublicFunction.NumberFormat(getLevelProfit),
+                                                            ProfitRate = objlevel.Percents,
+                                                            Message = "交易分润",
+                                                            BankCardType = BankCardType,
+                                                            QrPayFlag = QrPayFlag,
+                                                            BrandId = BrandId,
+                                                            DirectFlag = selfUser.Id == user.Id ? 1 : 0,
+                                                            IsSubsidy = 0,
+                                                            TradeAmount = ProfitHelpDirectTradeAmt,
+                                                            HelpFlag = 0,
+                                                        });
+                                                    }
+                                                }
+                                            }
+                                            curLevel = UserLevel;
+                                        }
+                                    }
                                 }
                             }
                             function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + ":over", "分润监控日志");