예제 #1
0
        public DataTable GetDistributorsCommosion(int userId, DistributorGrade grade)
        {
            string    query            = string.Format("SELECT sum(OrderTotal) AS OrderTotal,sum(CommTotal) AS CommTotal from dbo.Hishop_Commissions where UserId={0} AND ReferralUserId in (select UserId from aspnet_Distributors  WHERE (ReferralPath LIKE '{0}|%' OR ReferralPath LIKE '%|{0}|%' OR ReferralPath LIKE '%|{0}' OR ReferralPath='{0}') and GradeId={1})", userId, (int)grade);
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query);
            DataSet   set = this.database.ExecuteDataSet(sqlStringCommand);

            if ((set == null) || (set.Tables.Count <= 0))
            {
                return(null);
            }
            return(set.Tables[0]);
        }
예제 #2
0
        public int GetDistributorNum(DistributorGrade grade)
        {
            int    num   = 0;
            string query = string.Format("SELECT COUNT(*) FROM aspnet_Distributors where ReferralPath LIKE '{0}|%' OR ReferralPath LIKE '%|{0}|%' OR ReferralPath LIKE '%|{0}' OR ReferralPath='{0}'", Globals.GetCurrentMemberUserId());

            if (grade != DistributorGrade.All)
            {
                query = query + " AND GradeId=" + ((int)grade);
            }
            DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query);

            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    num = (int)reader[0];
                    reader.Close();
                }
            }
            return(num);
        }
예제 #3
0
        public static IList <string> BatchCreateMembers(IList <string> distributornames, int referruserId, string wid, string createtype = "1")
        {
            string           referralPath     = string.Empty;
            IList <string>   list             = new List <string>();
            DistributorGrade threeDistributor = DistributorGrade.ThreeDistributor;

            if (referruserId > 0)
            {
                referralPath = new DistributorsDao().GetDistributorInfo(referruserId).ReferralPath;
                if (string.IsNullOrEmpty(referralPath))
                {
                    referralPath     = referruserId.ToString();
                    threeDistributor = DistributorGrade.TowDistributor;
                }
                else if (referralPath.Contains("|"))
                {
                    referralPath = referralPath.Split(new char[] { '|' })[1] + "|" + referruserId.ToString();
                }
                else
                {
                    referralPath = referralPath + "|" + referruserId.ToString();
                }
            }
            foreach (string str2 in distributornames)
            {
                MemberInfo member     = new MemberInfo();
                string     generateId = Globals.GetGenerateId();
                member.GradeId        = new MemberGradeDao().GetDefaultMemberGrade(wid);
                member.UserName       = str2;
                member.CreateDate     = DateTime.Now;
                member.UserBindName   = str2;
                member.SessionId      = generateId;
                member.SessionEndTime = DateTime.Now.AddDays(10);
                member.Password       = HiCryptographer.Md5Encrypt("888888");
                if ((new MemberDao().GetusernameMember(str2, wid) == null) && new MemberDao().CreateMember(member))
                {
                    DistributorsInfo distributor = new DistributorsInfo {
                        UserId             = new MemberDao().GetusernameMember(str2, wid).UserId,
                        RequestAccount     = "",
                        StoreName          = str2,
                        StoreDescription   = "",
                        BackImage          = "",
                        Logo               = "",
                        DistributorGradeId = threeDistributor
                    };
                    distributor.UserId.ToString();
                    distributor.ReferralPath = referralPath;
                    distributor.ParentUserId = new int?(Convert.ToInt32(referruserId));
                    DistributorGradeInfo isDefaultDistributorGradeInfo = new DistributorsDao().GetIsDefaultDistributorGradeInfo();
                    distributor.DistriGradeId = isDefaultDistributorGradeInfo.GradeId;
                    if (new DistributorsDao().CreateDistributor(distributor) && (createtype == "1"))
                    {
                        list.Add(str2);
                    }
                }
                else if (createtype == "2")
                {
                    list.Add(str2);
                }
            }
            return(list);
        }
예제 #4
0
 public static DataTable GetDistributorsCommosion(int userId, DistributorGrade distributorgrade)
 {
     return(new DistributorsDao().GetDistributorsCommosion(userId, distributorgrade));
 }
예제 #5
0
 public static int GetDistributorNum(DistributorGrade grade)
 {
     return(new DistributorsDao().GetDistributorNum(grade));
 }
예제 #6
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            /*
             * //实例会员信息j
             * MemberInfo member = new MemberInfo();
             * string generateId = Globals.GetGenerateId();
             * member.GradeId = new MemberGradeDao().GetDefaultMemberGrade();
             * member.UserName = this.txtUserName.Text.Trim();
             * member.CreateDate = DateTime.Now;
             * member.SessionId = generateId;
             * member.SessionEndTime = DateTime.Now.AddYears(10);
             * member.Password = HiCryptographer.Md5Encrypt("888888");
             * if ((new MemberDao().GetusernameMember(member.UserName) == null) && new MemberDao().CreateMember(member))
             * {
             *  //根据推荐人获取相关信息
             *  string referralPath = string.Empty;
             *  string agentPath = string.Empty;
             *  string distributorname = this.txtReferralUserId.Text;
             *  int referruserId = MemberHelper.IsExiteDistributorNames(distributorname);
             *  DistributorGrade threeDistributor = DistributorGrade.ThreeDistributor;
             *  if (referruserId > 0)
             *  {
             *      referralPath = new DistributorsDao().GetDistributorInfo(referruserId).ReferralPath;
             *      agentPath = string.IsNullOrEmpty(referralPath) ? referruserId.ToString() : referralPath + "|" + referruserId.ToString();
             *      if (string.IsNullOrEmpty(referralPath))
             *      {
             *          referralPath = referruserId.ToString();
             *          threeDistributor = DistributorGrade.TowDistributor;
             *      }
             *      else if (referralPath.Contains("|"))
             *      {
             *          referralPath = referralPath.Split(new char[] { '|' })[1] + "|" + referruserId.ToString();
             *      }
             *      else
             *      {
             *          referralPath = referralPath + "|" + referruserId.ToString();
             *      }
             *  }
             *
             *  //实例分销商信息
             *  DistributorsInfo distributor = new DistributorsInfo
             *  {
             *      UserId = new MemberDao().GetusernameMember(member.UserName).UserId,
             *      RequestAccount = "",
             *      StoreName = txtStoreName.Text.Trim(),
             *      StoreDescription = "",
             *      BackImage = "",
             *      Logo = "",
             *      DistributorGradeId = threeDistributor,
             *      IsAgent = 1,
             *      AgentGradeId = int.Parse(ddlAgentGrade.SelectedValue.ToString()),
             *      AgentPath = agentPath
             *  };
             *  distributor.UserId.ToString();
             *  distributor.ReferralPath = referralPath;
             *  distributor.ParentUserId = new int?(Convert.ToInt32(referruserId));
             *  DistributorGradeInfo isDefaultDistributorGradeInfo = new DistributorsDao().GetIsDefaultDistributorGradeInfo();
             *  distributor.DistriGradeId = isDefaultDistributorGradeInfo.GradeId;
             *  if (new DistributorsDao().CreateAgent(distributor))
             *  {
             *      this.ShowMsgAndReUrl("添加成功!", true, "../distributor/distributorlist.aspx?isagent=1");
             *  }
             * }
             * else
             * {
             *  this.ShowMsg(string.Format("账号【{0}】已存在", member.UserName), false);
             * }
             */

            if (btnCreate.Text == "返 回")
            {
                Response.Redirect("../member/ManageMembersEx.aspx");
                return;
            }
            //判断自己的店铺名是否重复
            string           myStoreName = txtStoreName.Text.Trim();
            DistributorsInfo info        = DistributorsBrower.GetDistributorInfo(Request.QueryString["userId"].ToInt());

            if (MemberHelper.IsExiteDistributorNames(myStoreName) > 0 && info == null)//如果同名,则不能继续,否则取出来的id就是同名的代理商id了
            {
                this.ShowMsg("您的店铺名重复!", false);
                return;
            }

            //根据推荐人获取相关信息
            string referralPath    = string.Empty;
            string agentPath       = string.Empty;
            string distributorname = this.txtReferralUserId.Text;
            int    referruserId    = MemberHelper.IsExiteDistributorNames(distributorname);

            DistributorGrade threeDistributor = DistributorGrade.ThreeDistributor;

            if (referruserId > 0)
            {
                referralPath = new DistributorsDao().GetDistributorInfo(referruserId).ReferralPath;
                agentPath    = string.IsNullOrEmpty(referralPath) ? referruserId.ToString() : referralPath + "|" + referruserId.ToString();
                if (string.IsNullOrEmpty(referralPath))
                {
                    referralPath     = referruserId.ToString();
                    threeDistributor = DistributorGrade.TowDistributor;
                }
                else if (referralPath.Contains("|"))
                {
                    referralPath = referralPath.Split(new char[] { '|' })[1] + "|" + referruserId.ToString();
                }
                else
                {
                    referralPath = referralPath + "|" + referruserId.ToString();
                }
            }
            else if (referruserId == 0)//如果没有推荐商,ReferralUserid就是自己
            {
                referruserId = int.Parse(Request.QueryString["userId"]);
            }

            //获取会员信息、分销信息
            MemberInfo       member      = MemberHelper.GetMember(int.Parse(Request.QueryString["userId"]));
            DistributorsInfo distributor = VShopHelper.GetUserIdDistributors(member.UserId);

            //升级会员为代理
            if (distributor == null)
            {
                DistributorGradeInfo isDefaultDistributorGradeInfo = new DistributorsDao().GetIsDefaultDistributorGradeInfo();
                distributor = new DistributorsInfo
                {
                    UserId             = new MemberDao().GetusernameMember(member.UserName).UserId,
                    RequestAccount     = "",
                    StoreName          = txtStoreName.Text.Trim(),
                    StoreDescription   = "",
                    BackImage          = "",
                    Logo               = "",
                    DistributorGradeId = threeDistributor,
                    IsAgent            = 1,
                    DistriGradeId      = isDefaultDistributorGradeInfo.GradeId,
                    AgentGradeId       = int.Parse(ddlAgentGrade.SelectedValue.ToString()),
                    AgentPath          = agentPath,
                    ReferralPath       = referralPath,
                    ParentUserId       = new int?(Convert.ToInt32(referruserId)),
                    ReferralUserId     = referruserId //
                };
                new DistributorsDao().CreateAgent(distributor);
            }
            else
            {
                //升级分销为代理
                string where = "UserId=" + distributor.UserId;
                DataTable dtData          = DistributorsBrower.GetDistributorsByWhere(where);
                string    oldReferralPath = (dtData.Rows[0]["ReferralPath"] == DBNull.Value) ? "" : dtData.Rows[0]["ReferralPath"].ToString();
                dtData.Rows[0]["IsAgent"]      = 1;
                dtData.Rows[0]["AgentGradeId"] = int.Parse(ddlAgentGrade.SelectedValue.ToString());
                if (!CustomConfigHelper.Instance.SelectServerAgent && referruserId == 0)
                {
                    dtData.Rows[0]["AgentPath"]      = agentPath;
                    dtData.Rows[0]["ReferralPath"]   = referralPath;
                    dtData.Rows[0]["ReferralUserid"] = referruserId;//referraluserid更新
                    //DistributorsBrower.CommitDistributors(dtData);

                    //找到所有的子
                    dtData.PrimaryKey = new DataColumn[] { dtData.Columns["UserID"] };
                    FindCurrDistributorChild(distributor.UserId, dtData);
                    agentPath = (agentPath == "") ? distributor.UserId.ToString() : (agentPath + "|" + distributor.UserId.ToString());

                    //设置所属的 代理商
                    foreach (DataRow dr in dtData.Rows)
                    {
                        //清除缓存
                        DistributorsBrower.RemoveDistributorCache(dr["userid"].ToInt());

                        //自己已经设置过
                        if (distributor.UserId == dr["UserID"].ToInt())
                        {
                            continue;
                        }

                        //设置所属代理
                        dr["AgentPath"] = agentPath;
                    }

                    //设置所属的 店铺
                    where = string.Format("1=1 AND (ReferralPath LIKE '{0}|%' OR ReferralPath LIKE '%|{0}|%' OR ReferralPath LIKE '%|{0}' OR ReferralPath='{0}')"
                                          , distributor.UserId);
                    DataRow[] rowsChildDistributor = dtData.Select(where);
                    foreach (DataRow dr in dtData.Rows)
                    {
                        if (oldReferralPath != "")
                        {
                            string currReferralPath = dr["ReferralPath"].ToString();
                            if (currReferralPath.IndexOf(oldReferralPath) == 0)
                            {
                                if (referralPath == "")
                                {
                                    currReferralPath = distributor.UserId.ToString();
                                }
                                else
                                {
                                    //替换前缀
                                    currReferralPath = referralPath + "|" + currReferralPath.Split('|')[currReferralPath.Split('|').Length - 1];
                                }
                                dr["ReferralPath"] = currReferralPath;
                            }
                        }
                    }
                }
                //保存到数据库
                DistributorsBrower.CommitDistributors(dtData);
            }
            this.ShowMsgAndReUrl("升级成功!", true, "../member/ManageMembersEx.aspx");
        }
예제 #7
0
 public static DataTable GetDistributorsCommosion(int userId, DistributorGrade distributorgrade)
 {
     return new DistributorsDao().GetDistributorsCommosion(userId, distributorgrade);
 }
예제 #8
0
 public static int GetDistributorNum(DistributorGrade grade)
 {
     return new DistributorsDao().GetDistributorNum(grade);
 }
예제 #9
0
        private void btnCreate_Click(object sender, System.EventArgs e)
        {
            //实例会员信息
            MemberInfo member     = new MemberInfo();
            string     generateId = Globals.GetGenerateId();

            member.GradeId        = new MemberGradeDao().GetDefaultMemberGrade();
            member.UserName       = this.txtUserName.Text.Trim();
            member.CreateDate     = DateTime.Now;
            member.SessionId      = generateId;
            member.SessionEndTime = DateTime.Now.AddYears(10);
            member.Password       = HiCryptographer.Md5Encrypt("888888");
            if ((new MemberDao().GetusernameMember(member.UserName) == null) && new MemberDao().CreateMember(member))
            {
                //根据推荐人获取相关信息
                string           referralPath     = string.Empty;
                string           agentPath        = string.Empty;
                string           distributorname  = this.txtReferralUserId.Text;
                int              referruserId     = MemberHelper.IsExiteDistributorNames(distributorname);
                DistributorGrade threeDistributor = DistributorGrade.ThreeDistributor;
                if (referruserId > 0)
                {
                    referralPath = new DistributorsDao().GetDistributorInfo(referruserId).ReferralPath;
                    agentPath    = string.IsNullOrEmpty(referralPath) ? referruserId.ToString() : referralPath + "|" + referruserId.ToString();
                    if (string.IsNullOrEmpty(referralPath))
                    {
                        referralPath     = referruserId.ToString();
                        threeDistributor = DistributorGrade.TowDistributor;
                    }
                    else if (referralPath.Contains("|"))
                    {
                        referralPath = referralPath.Split(new char[] { '|' })[1] + "|" + referruserId.ToString();
                    }
                    else
                    {
                        referralPath = referralPath + "|" + referruserId.ToString();
                    }
                }

                //实例分销商信息
                DistributorsInfo distributor = new DistributorsInfo
                {
                    UserId             = new MemberDao().GetusernameMember(member.UserName).UserId,
                    RequestAccount     = "",
                    StoreName          = txtStoreName.Text.Trim(),
                    StoreDescription   = "",
                    BackImage          = "",
                    Logo               = "",
                    DistributorGradeId = threeDistributor,
                    IsAgent            = 1,
                    AgentGradeId       = int.Parse(ddlAgentGrade.SelectedValue.ToString()),
                    AgentPath          = agentPath
                };
                distributor.UserId.ToString();
                distributor.ReferralPath = referralPath;
                distributor.ParentUserId = new int?(Convert.ToInt32(referruserId));
                DistributorGradeInfo isDefaultDistributorGradeInfo = new DistributorsDao().GetIsDefaultDistributorGradeInfo();
                distributor.DistriGradeId = isDefaultDistributorGradeInfo.GradeId;
                if (new DistributorsDao().CreateAgent(distributor))
                {
                    this.ShowMsgAndReUrl("添加成功!", true, "../distributor/distributorlist.aspx?isagent=1");
                }
            }
            else
            {
                this.ShowMsg(string.Format("账号【{0}】已存在", member.UserName), false);
            }
        }
예제 #10
0
        public static IList <string> BatchCreateMembers(IList <string> distributornames, int referruserId, string createtype = "1")
        {
            string           text  = string.Empty;
            string           text2 = string.Empty;
            IList <string>   list  = new List <string>();
            DistributorGrade distributorGradeId = DistributorGrade.ThreeDistributor;

            if (referruserId > 0)
            {
                text2 = new DistributorsDao().GetDistributorInfo(referruserId).ReferralPath;
                if (string.IsNullOrEmpty(text2))
                {
                    text2 = referruserId.ToString();
                    distributorGradeId = DistributorGrade.TowDistributor;
                }
                else if (text2.Contains("|"))
                {
                    text2 = text2.Split(new char[]
                    {
                        '|'
                    })[1] + "|" + referruserId.ToString();
                }
                else
                {
                    text2 = text2 + "|" + referruserId.ToString();
                }
            }
            foreach (string current in distributornames)
            {
                Hidistro.Entities.Members.MemberInfo memberInfo = new Hidistro.Entities.Members.MemberInfo();
                string generateId = Globals.GetGenerateId();
                memberInfo.GradeId        = new MemberGradeDao().GetDefaultMemberGrade();
                memberInfo.UserName       = current;
                memberInfo.CreateDate     = DateTime.Now;
                memberInfo.UserBindName   = current;
                memberInfo.SessionId      = generateId;
                memberInfo.ReferralUserId = Convert.ToInt32(referruserId);
                memberInfo.SessionEndTime = DateTime.Now.AddYears(10);
                memberInfo.Password       = HiCryptographer.Md5Encrypt("888888");
                memberInfo.UserHead       = "/templates/common/images/user.png";
                if (new MemberDao().GetusernameMember(current) == null && new MemberDao().CreateMember(memberInfo))
                {
                    DistributorsInfo distributorsInfo = new DistributorsInfo();
                    distributorsInfo.UserId             = new MemberDao().GetusernameMember(current).UserId;
                    distributorsInfo.RequestAccount     = "";
                    distributorsInfo.StoreName          = current;
                    distributorsInfo.StoreDescription   = "";
                    distributorsInfo.BackImage          = "";
                    distributorsInfo.Logo               = "";
                    distributorsInfo.DistributorGradeId = distributorGradeId;
                    text = distributorsInfo.UserId.ToString();
                    distributorsInfo.ReferralPath = text2;
                    distributorsInfo.ParentUserId = new int?(Convert.ToInt32(referruserId));
                    DistributorGradeInfo isDefaultDistributorGradeInfo = new DistributorsDao().GetIsDefaultDistributorGradeInfo();
                    distributorsInfo.DistriGradeId = isDefaultDistributorGradeInfo.GradeId;
                    if (new DistributorsDao().CreateDistributor(distributorsInfo) && createtype == "1")
                    {
                        list.Add(current);
                    }
                }
                else if (createtype == "2")
                {
                    list.Add(current);
                }
            }
            return(list);
        }
예제 #11
0
 public DataTable GetDistributorsCommosion(int userId, DistributorGrade grade)
 {
     string query = string.Format("SELECT sum(OrderTotal) AS OrderTotal,sum(CommTotal) AS CommTotal from dbo.Hishop_Commissions where UserId={0} AND ReferralUserId in (select UserId from aspnet_Distributors  WHERE (ReferralPath LIKE '{0}|%' OR ReferralPath LIKE '%|{0}|%' OR ReferralPath LIKE '%|{0}' OR ReferralPath='{0}') and GradeId={1})", userId, (int) grade);
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query);
     DataSet set = this.database.ExecuteDataSet(sqlStringCommand);
     if ((set == null) || (set.Tables.Count <= 0))
     {
         return null;
     }
     return set.Tables[0];
 }
예제 #12
0
 public int GetDistributorNum(DistributorGrade grade)
 {
     int num = 0;
     string query = string.Format("SELECT COUNT(*) FROM aspnet_Distributors where ReferralPath LIKE '{0}|%' OR ReferralPath LIKE '%|{0}|%' OR ReferralPath LIKE '%|{0}' OR ReferralPath='{0}'", Globals.GetCurrentMemberUserId());
     if (grade != DistributorGrade.All)
     {
         query = query + " AND GradeId=" + ((int) grade);
     }
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query);
     using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
     {
         if (reader.Read())
         {
             num = (int) reader[0];
             reader.Close();
         }
     }
     return num;
 }