Exemplo n.º 1
0
        /// <summary>
        /// 获取全部推广人数
        /// </summary>
        /// <param name="UserId">用Id</param>
        /// <returns>返回推广人数</returns>
        public Double GetAllSpreadCount(int UserId)
        {
            GameUserServers gus = new GameUserServers();
            GameUser        gu  = gus.GetGameUser(UserId);

            try
            {
                if (gu.IsSpreader == 1)
                {
                    string         sql = "select count(*) from game_users where source=@UserId";
                    SqlParameter[] sp  = new SqlParameter[] {
                        new SqlParameter("@UserId", UserId)
                    };
                    return(db.ExecuteScalar(sql, sp));
                }
                else if (gu.IsSpreader == 2)
                {
                    Double          SpreadCount = 0;
                    List <GameUser> list        = new List <GameUser>();
                    list = gus.GetSpreadUser(UserId);
                    list.Add(gu);
                    foreach (GameUser gameuser in list)
                    {
                        string         sql = "select count(*) from game_users where source=@UserId";
                        SqlParameter[] sp  = new SqlParameter[] {
                            new SqlParameter("@UserId", gameuser.Id)
                        };
                        SpreadCount += db.ExecuteScalar(sql, sp);
                    }
                    return(SpreadCount);
                }
                else
                {
                    return(0);
                }
            }
            catch (SqlException ex)
            {
                throw new Exception("数据库异常!原因:" + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("未知异常!原因:" + ex.Message);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取推广员的推广总额
        /// </summary>
        /// <param name="UserId">用户Id</param>
        /// <returns>返回总金额</returns>
        public Double GetSumMoney(int UserId, string WhereStr)
        {
            GameUserServers gus = new GameUserServers();
            GameUser        gu  = gus.GetGameUser(UserId);

            try
            {
                if (gu.IsSpreader == 1)
                {
                    string sql = "select ISNULL(sum(o.paymoney),0) from orders as o, game_users as gu where o.username in" +
                                 "(select username from game_users where source=@UserId)and o.state=2 and o.orderno like 'G%' and o.username=gu.username and o.gameid = gu.reggame and gu.isspreader=0 " + WhereStr;
                    SqlParameter[] sp = new SqlParameter[] {
                        new SqlParameter("@UserId", UserId)
                    };
                    return(db.ExecuteScalar(sql, sp));
                }
                else if (gu.IsSpreader == 2)
                {
                    Double          SpreadMoney = 0;
                    List <GameUser> list        = new List <GameUser>();
                    list = gus.GetSpreadUser(UserId);
                    foreach (GameUser gameuser in list)
                    {
                        SpreadMoney += GetSumMoney(gameuser.Id, WhereStr);
                    }
                    return(SpreadMoney);
                }
                else
                {
                    string         sql = "select ISNULL(sum(o.paymoney),0) from orders as o, game_users as gu where o.username=@UserName and o.state=2 and o.orderno like 'G%' and o.username=gu.username and o.gameid = gu.reggame and gu.isspreader=0 " + WhereStr;
                    SqlParameter[] sp  = new SqlParameter[] {
                        new SqlParameter("@UserName", gu.UserName)
                    };
                    return(db.ExecuteScalar(sql, sp));
                }
            }
            catch (SqlException ex)
            {
                throw new Exception("数据库异常!原因:" + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("未知异常!原因:" + ex.Message);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取全部推广人数
        /// </summary>
        /// <param name="UserId">用Id</param>
        /// <returns>返回推广人数</returns>
        public Double GetAllSpreadCount(int UserId)
        {
            GameUserServers gus = new GameUserServers();
            GameUser gu = gus.GetGameUser(UserId);
            try
            {
                if (gu.IsSpreader == 1)
                {
                    string sql = "select count(*) from game_users where source=@UserId";
                    SqlParameter[] sp = new SqlParameter[] {
                     new SqlParameter("@UserId",UserId)
                    };
                    return db.ExecuteScalar(sql, sp);
                }
                else if (gu.IsSpreader == 2)
                {
                    Double SpreadCount = 0;
                    List<GameUser> list = new List<GameUser>();
                    list = gus.GetSpreadUser(UserId);
                    list.Add(gu);
                    foreach (GameUser gameuser in list)
                    {
                        string sql = "select count(*) from game_users where source=@UserId";
                        SqlParameter[] sp = new SqlParameter[] {
                         new SqlParameter("@UserId",gameuser.Id)
                        };
                        SpreadCount += db.ExecuteScalar(sql, sp);
                    }
                    return SpreadCount;
                }
                else
                {
                    return 0;
                }

            }
            catch (SqlException ex)
            {
                throw new Exception("数据库异常!原因:" + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("未知异常!原因:" + ex.Message);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 获取推广员的推广总额
 /// </summary>
 /// <param name="UserId">用户Id</param>
 /// <returns>返回总金额</returns>
 public Double GetSumMoney(int UserId, string WhereStr)
 {
     GameUserServers gus = new GameUserServers();
     GameUser gu = gus.GetGameUser(UserId);
     try
     {
         if (gu.IsSpreader == 1)
         {
             string sql = "select ISNULL(sum(o.paymoney),0) from orders as o, game_users as gu where o.username in" +
                             "(select username from game_users where source=@UserId)and o.state=2 and o.orderno like 'G%' and o.username=gu.username and o.gameid = gu.reggame and gu.isspreader=0 " + WhereStr;
             SqlParameter[] sp = new SqlParameter[]{
                    new SqlParameter("@UserId",UserId)
                };
             return db.ExecuteScalar(sql, sp);
         }
         else if (gu.IsSpreader == 2)
         {
             Double SpreadMoney = 0;
             List<GameUser> list = new List<GameUser>();
             list = gus.GetSpreadUser(UserId);
             foreach (GameUser gameuser in list)
             {
                 SpreadMoney += GetSumMoney(gameuser.Id, WhereStr);
             }
             return SpreadMoney;
         }
         else
         {
             string sql = "select ISNULL(sum(o.paymoney),0) from orders as o, game_users as gu where o.username=@UserName and o.state=2 and o.orderno like 'G%' and o.username=gu.username and o.gameid = gu.reggame and gu.isspreader=0 " + WhereStr;
             SqlParameter[] sp = new SqlParameter[]{
                    new SqlParameter("@UserName",gu.UserName)
                };
             return db.ExecuteScalar(sql, sp);
         }
     }
     catch (SqlException ex)
     {
         throw new Exception("数据库异常!原因:" + ex.Message);
     }
     catch (Exception ex)
     {
         throw new Exception("未知异常!原因:" + ex.Message);
     }
 }