public void OrderUser(string orderId, int UserId, int OrderLvId) { AgentuserBll userBll = new AgentuserBll(); OrdersAgentsBll bll = new OrdersAgentsBll(); OrdersAgentsEntity OAEntity = new OrdersAgentsEntity(); OAEntity.OrderId = orderId; OAEntity.UserId = UserId; int ThreeId = 0; int TwoId = 0; int OneId = 0; int InOneId = 0; if (OrderLvId == 3) { AgentuserEntity UserEntity = userBll.selectById(UserId); int UserPid = UserEntity.UserPid; AgentuserEntity PidEntity = userBll.selectById(UserPid); int PidLv = PidEntity.LvId; if (PidLv == 2) //如果上级是大总 { ThreeId = UserId; //总代 TwoId = UserPid; //大总 OneId = PidEntity.UserPid; //大牌 AgentuserEntity PPidEntity = userBll.selectById(PidEntity.UserPid); //大牌信息 InOneId = PPidEntity.Inviter; //大牌邀请人 } else//如果上级是大牌 { ThreeId = UserId; TwoId = 0; OneId = UserPid; //大牌 InOneId = PidEntity.Inviter; //大牌邀请人 } } if (OrderLvId == 2) { AgentuserEntity UserEntity = userBll.selectById(UserId); int UserPid = UserEntity.UserPid; AgentuserEntity PidEntity = userBll.selectById(UserPid); ThreeId = 0; TwoId = UserId; OneId = UserPid; //大牌 InOneId = PidEntity.Inviter; //大牌邀请人 } if (OrderLvId == 1) { AgentuserEntity UserEntity = userBll.selectById(UserId); ThreeId = 0; TwoId = 0; OneId = UserId; InOneId = UserEntity.Inviter; } OAEntity.ThreeId = ThreeId; OAEntity.TwoId = TwoId; OAEntity.OneId = OneId; OAEntity.InOneId = InOneId; bll.add(OAEntity); }
public void DowngradeVerifyEntity(int UserId) { AgentuserBll userbll = new AgentuserBll(); AgentuserEntity userentity = userbll.selectById(UserId); int LvId = userentity.LvId; if (LvId <= 2) { int YesOrNo = DowngradeVerify(UserId, LvId); //添加降级列表 进入降级列表里面 if (YesOrNo == 0) { DowngradeAgentsBll downBll = new DowngradeAgentsBll(); DowngradeAgentsEntity Yesentity = downBll.selectByUserId(UserId); int NowLvId = LvId; int DowngradeLvId = LvId + 1; if (Yesentity == null) { DowngradeAgentsEntity entity = new DowngradeAgentsEntity(); UserlvBll lvBll = new UserlvBll(); UserlvEntity NowLvEntity = lvBll.selectById(NowLvId); UserlvEntity DowngradeLvEntity = lvBll.selectById(DowngradeLvId); entity.Name = userentity.Name; entity.UserId = UserId; entity.Mobile = userentity.LoginName; entity.NowLvId = NowLvId; entity.NowLvName = NowLvEntity.Name; entity.DowngradeLvId = DowngradeLvId; entity.DowngradeLvName = DowngradeLvEntity.Name; downBll.add(entity); } } } }
//查询下级所有代理 public AgentuserListViewModel AgentList(int UserId) { AgentuserBll ueserbll = new AgentuserBll(); List <AgentuserEntity> userListentity = new List <AgentuserEntity>(); string whereSql = " State=1" + " and UserPid=" + UserId;//id是上级ID state是已经审核状态 userListentity = ueserbll.selectByWhere(whereSql); AgentuserListViewModel listAgentuser = new AgentuserListViewModel(); listAgentuser.AgentuserList = new List <AgentuserViewModel>(); foreach (var item in userListentity) { AgentuserViewModel viewModelUser = new AgentuserViewModel(); viewModelUser.Id = item.Id; //下级Id viewModelUser.LvId = item.LvId; //下级等级Id SelectAuditList(item.Id, listAgentuser); listAgentuser.AgentuserList.Add(viewModelUser); } return(listAgentuser); }
public void AgentReupEntityUserId(int UserId, int Inviter, int UserPid) { AgentuserBll bll = new AgentuserBll(); AgentuserEntity entity = bll.selectById(UserId); AgentReupBll Reupbll = new AgentReupBll(); AgentReupEntity renupEntity = new AgentReupEntity(); renupEntity.InviterId = Inviter; AgentuserEntity InviterEntity = bll.selectById(Inviter);//上级信息 renupEntity.InviterLvId = InviterEntity.LvId; renupEntity.UserId = entity.Id; renupEntity.ThreeId = entity.Id; AgentuserEntity PidEntity = bll.selectById(UserPid); //上级信息 if (PidEntity.LvId == 2) //如果上级是大总 { renupEntity.TwoId = UserPid; //大总 renupEntity.OneId = PidEntity.UserPid; //大牌 AgentuserEntity PPidEntity = bll.selectById(PidEntity.UserPid); renupEntity.InoneId = PPidEntity.Inviter; } if (PidEntity.LvId == 1) // 如果上级是大牌 { renupEntity.TwoId = 0; //大总 renupEntity.OneId = UserPid; //大牌 renupEntity.InoneId = PidEntity.Inviter; } Reupbll.add(renupEntity); }
public List <AgentuserEntity> AgentList(string OneList) { AgentuserBll ueserbll = new AgentuserBll(); List <AgentuserEntity> userListentity = new List <AgentuserEntity>(); string whereSql = " State=1" + " and UserPid in (" + OneList + ")";//id是上级ID state是已经审核状态 userListentity = ueserbll.selectByWhere(whereSql); List <AgentuserEntity> listAgentuser = new List <AgentuserEntity>(); foreach (var item in userListentity) { AgentuserEntity viewModelUser = new AgentuserEntity(); viewModelUser.Id = item.Id; //下级Id viewModelUser.LvId = item.LvId; //下级等级Id SelectAuditList(item.Id, listAgentuser); listAgentuser.Add(viewModelUser); } return(listAgentuser); }
/// <summary> /// 判断是否符合当前的等级条件 如果是0 说明不满足 /// </summary> /// <param name="UserId">用户Id</param> /// <param name="LvId">当前等级Id</param> /// <returns></returns> private int DowngradeVerify(int UserId, int LvId) { UpConditionBll Upbll = new UpConditionBll(); AgentuserBll userbll = new AgentuserBll(); AgentuserEntity userentity = userbll.selectById(UserId); int YeworNo = 0; if (LvId == 2) { UpConditionEntity upEntity = new UpConditionEntity(); upEntity = Upbll.selectById(LvId); int Upthree = upEntity.Upthree; string threewhere = "Inviter=" + UserId + " and LvId=3 and State=1"; List <AgentuserEntity> listUser = userbll.selectByWhere(threewhere); //直接邀请的人数 总代人数 string otherwhere = "StarInviter=" + UserId + " and LvId<3 and State=1"; //自己邀请 且等级在总代以上的人员 List <AgentuserEntity> listotherUser = userbll.selectByWhere(otherwhere); int UsrtNum = listUser.Count; int UserotherNum = listotherUser.Count; int UsrtNumTotal = UsrtNum + UserotherNum; if (UsrtNumTotal >= Upthree) { YeworNo = 1; } } if (LvId == 1) { UpConditionEntity upEntity = new UpConditionEntity(); upEntity = Upbll.selectById(LvId); int Upthree = upEntity.Upthree; //总代个数 条件 int Uptwo = upEntity.Uptwo; //大总个数 条件 string threewhere = "Inviter=" + UserId + " and LvId=3 and State=1"; string twowhere = "Inviter=" + UserId + " and LvId=2 and State=1"; string otherwhere = "StarInviter=" + UserId + " and LvId=1 and State=1"; List <AgentuserEntity> listthreeUser = userbll.selectByWhere(threewhere); //直线总代个数 List <AgentuserEntity> listtwoUser = userbll.selectByWhere(twowhere); //直线大总个数 List <AgentuserEntity> listotherUser = userbll.selectByWhere(otherwhere); //已经升级到大牌 int TotalOneandtwo = TotalUserOneandtwo(UserId); int UserthreeNum = listthreeUser.Count; //直线总代 int UsertwoNum = listtwoUser.Count; //直线大总 int UserotherNum = listotherUser.Count; //自己邀请 且是大牌 int AllUptwo = UserotherNum + UsertwoNum; //自己升级到大总和大牌总和 if (AllUptwo > 0 && UserthreeNum + UserotherNum + UsertwoNum >= Upthree + Uptwo) { YeworNo = 1; } if (TotalOneandtwo >= Uptwo && UserthreeNum + UserotherNum + UsertwoNum >= Upthree) { YeworNo = 1; } } return(YeworNo); }
public LvUserIdEntity SearchLvlistEntity(int UserId) { AgentuserBll userBll = new AgentuserBll(); AgentuserEntity userEntity = new AgentuserEntity(); userEntity = userBll.selectById(UserId); int UserLvId = userEntity.LvId; int UserPid = userEntity.UserPid; int LvtwoUserId = 0; int LvoneUserId = 0; int InlvoneUserId = 0; if (UserLvId <= 3) { if (UserLvId == 3) { AgentuserEntity userPidEntity = userBll.selectById(UserPid); //上级信息 int UserPidLvid = userPidEntity.LvId; //上级等级Id if (UserPidLvid == 2) //如果上级是大总 //三个参数 大总 Id 大牌Id 和大牌邀请人Id { //说明: //1、userPidEntity 是上级(大总)信息 //2、userPPidEntity 是大总上级信息(大牌) //3、UserPid 大总Id UserPidPid是大总得上级Id(大牌) int UserPidPid = userPidEntity.UserPid; //上级的上级Id userPPidEntity.Inviter是大牌邀请人Id AgentuserEntity userPPidEntity = userBll.selectById(UserPidPid); //查询大总得上级(大牌) LvtwoUserId = UserPid; //大总Id LvoneUserId = UserPidPid; //大牌Id InlvoneUserId = userPPidEntity.Inviter; //大牌邀请人Id } if (UserPidLvid == 1) //如果上级是大牌 大牌Id 大牌邀请人Id { LvoneUserId = UserPid; //大牌Id InlvoneUserId = userPidEntity.Inviter; //大牌邀请人Id } } if (UserLvId == 2) //大牌Id 大牌邀请人Id { AgentuserEntity userPidEntity = userBll.selectById(UserPid); //上级信息(大牌) LvoneUserId = UserPid; //大牌Id InlvoneUserId = userPidEntity.Inviter; //大牌邀请人Id } } LvUserIdEntity lvUser = new LvUserIdEntity(); lvUser.UserId = UserId; lvUser.LvtwoUserId = LvtwoUserId; lvUser.LvoneUserId = LvoneUserId; lvUser.InlvoneUserId = InlvoneUserId; return(lvUser); }
private void SelectInListEntity(int Id, List <AgentuserEntity> listAgentuser) { AgentuserBll ueserbll = new AgentuserBll(); List <AgentuserEntity> userentity = new List <AgentuserEntity>(); string whereSql = " State=1" + " and UserPid=" + Id;//id是上级ID state是已经审核状态 userentity = ueserbll.selectByWhere(whereSql); foreach (var item in userentity) { SelectInListEntity(item.Id, listAgentuser); listAgentuser.Add(item); } }
//查询直接下线的代理人数(直线) public int AgentNum(int LvId, int UserId) { AgentuserBll bll = new AgentuserBll(); List <AgentuserEntity> listEntity = new List <AgentuserEntity>(); string Where = " LvId=" + LvId + "and State=1 and Inviter=" + UserId; listEntity = bll.selectByWhere(Where); int Num = 0; foreach (var item in listEntity) { Num++; } return(Num); }
private List <AgentuserEntity> PAlllvThree(int UserId, List <AgentuserEntity> ListAll) { AgentuserBll bll = new AgentuserBll(); List <AgentuserEntity> ListOne = new List <AgentuserEntity>(); string lvthreewhere = "Inviter=" + UserId + " and LvId=3 and State=1"; ListOne = bll.selectByWhere(lvthreewhere); foreach (var item in ListOne) { ListAll.Add(item); PAlllvThree(item.Id, ListAll); } return(ListAll); }
public string ListUser(string OneList) { string sqlWhere = "State=1 and UserPid in (" + OneList + ")"; AgentuserBll userBll = new AgentuserBll(); List <AgentuserEntity> ListoneEntity = AgentList(OneList); string ListUserId = string.Empty; ListUserId += OneList + ","; foreach (var item in ListoneEntity) { ListUserId += item.Id + ","; } ListUserId = ListUserId.Substring(0, ListUserId.Length - 1); return(ListUserId); }
public void SelectAuditList(int Id, List <AgentuserEntity> listAgentuser) { AgentuserBll ueserbll = new AgentuserBll(); List <AgentuserEntity> userentity = new List <AgentuserEntity>(); string whereSql = " State=1" + " and UserPid=" + Id;//id是上级ID state是已经审核状态 userentity = ueserbll.selectByWhere(whereSql); foreach (var item in userentity) { AgentuserEntity viewModel = new AgentuserEntity(); viewModel.Id = item.Id; //下级Id viewModel.LvId = item.LvId; //下级等级Id SelectAuditList(item.Id, listAgentuser); listAgentuser.Add(viewModel); } }
public List <AgentuserEntity> PidAgent(int LvEid, int UserId, List <AgentuserEntity> list) { //1.得到与用户相关的代理信息 //下级代理 //第一步查询所有能大总高级的代理 UserId和总代; //********条件************** string Where = "LvId>" + LvEid + " and State=1 and UserPid=" + UserId; AgentuserBll bll = new AgentuserBll(); List <AgentuserEntity> listEntity = new List <AgentuserEntity>(); listEntity = bll.selectByWhere(Where); foreach (var item in listEntity) { int UserPid = item.Id; list.Add(item); PidAgent(LvEid, UserPid, list); } return(list); }
private List <AgentuserEntity> StarInviterIdingListEntity(int StarInviter, List <AgentuserEntity> MyUserList) { string whereStarInviter = " State=1 and StarInviter=" + "'" + StarInviter + "'"; AgentuserBll Bll = new AgentuserBll(); List <AgentuserEntity> listUserEntity = Bll.selectByWhere(whereStarInviter); foreach (var item in listUserEntity) { if (item.LvId > 1) { MyUserList.Add(item); StarInviterIdingListEntity(item.Id, MyUserList); } else { MyUserList.Add(item); //大牌 } } return(MyUserList); }
//逻辑 1、假如是总代 寻找下级 自己邀请 切上级是自己 public List <AgentuserEntity> InvListEntity(int UserId) { AgentuserBll ueserbll = new AgentuserBll(); List <AgentuserEntity> userListentity = new List <AgentuserEntity>(); string whereSql = " State=1" + " and UserPid=" + UserId;//id是上级ID state是已经审核状态 userListentity = ueserbll.selectByWhere(whereSql); List <AgentuserEntity> listAgentuser = new List <AgentuserEntity>(); foreach (var item in userListentity) { AgentuserEntity viewModelUser = new AgentuserEntity(); SelectInListEntity(item.Id, listAgentuser); listAgentuser.Add(item); } return(listAgentuser); }
public List <AgentuserEntity> SStarInviterId(int StarInviter, List <AgentuserEntity> AlllistUserEntity) { string whereStarInviter = " State=1 and StarInviter=" + "'" + StarInviter + "'"; AgentuserBll Bll = new AgentuserBll(); List <AgentuserEntity> listUserEntity = Bll.selectByWhere(whereStarInviter); foreach (var item in listUserEntity) { if (item.LvId > 1) { AlllistUserEntity.Add(item); SStarInviterId(item.Id, AlllistUserEntity); } else { AlllistUserEntity.Add(item);//自己邀请的代理 下面的代理 当时大牌得时候记录 升级条件 但是不在进行遍历查询 } } return(AlllistUserEntity); }
//找到所有与自己有关的代理 public List <AgentuserEntity> StarInviterId(int StarInviter) { //第一步 寻找自己邀请的所有代理 string whereStarInviter = " State=1 and StarInviter=" + "'" + StarInviter + "'"; AgentuserBll Bll = new AgentuserBll(); List <AgentuserEntity> listUserEntity = Bll.selectByWhere(whereStarInviter);//自己邀请的所有代理 包含小代理 List <AgentuserEntity> AlllistUserEntity = new List <AgentuserEntity>(); foreach (var item in listUserEntity) { if (item.LvId > 1) { AlllistUserEntity.Add(item); SStarInviterId(item.Id, AlllistUserEntity);//自己邀请的所有代理 包含小代理 他们要求的所有代理包含小代理 } else { AlllistUserEntity.Add(item); } } return(AlllistUserEntity); }
public int Query(int id, int lvid) { AgentuserBll bll = new AgentuserBll(); AgentuserEntity entity = new AgentuserEntity(); entity = bll.selectById(id); int UserId = 0; if (entity.LvId < lvid) { UserId = id; } else if (entity.LvId == lvid) { UserId = entity.UserPid; } else { UserId = Query(entity.UserPid, lvid); } return(UserId); }
public int PUser(int id, int lvid) { AgentuserBll bll = new AgentuserBll(); AgentuserEntity entity = new AgentuserEntity(); entity = bll.selectById(id); int PUserid = 0; if (entity.LvId < lvid) { PUserid = entity.Id; } else if (entity.LvId == lvid) { PUserid = entity.UserPid; } else { PUser(entity.UserPid, lvid); } return(PUserid); }
/// <summary> /// 把升级信息写入数据库 /// </summary> /// <param name="UserId"></param> /// <param name="LvId"></param> /// <returns></returns> public UpAgentsEntity UpagentUserEntity(int UserId, int LvId) { UpConditionBll Upbll = new UpConditionBll(); AgentuserBll userbll = new AgentuserBll(); AgentuserEntity userentity = userbll.selectById(UserId); UserBalanceBll balbll = new UserBalanceBll(); AgentuserUptagBll uptagbll = new AgentuserUptagBll(); UserlvBll lvbll = new UserlvBll(); UpAgentsEntity TableEntity = new UpAgentsEntity(); if (LvId > 3) { int Uppid = 3; UserBalanceEntity blentity = balbll.selectById(UserId); UpConditionEntity upthreeEntity = new UpConditionEntity(); upthreeEntity = Upbll.selectById(Uppid); double PayMoney = upthreeEntity.PayMoney; if (blentity != null) { double BalancePrice = blentity.BalancePrice; int ReNum = blentity.ReNum; if (BalancePrice >= PayMoney) { int UserPid = Query(UserId, Uppid); UserlvEntity nowlvEntity = lvbll.selectById(LvId); UserlvEntity pulvEntity = lvbll.selectById(Uppid); TableEntity.LvName = nowlvEntity.Name; TableEntity.UpingName = pulvEntity.Name; TableEntity.Name = userentity.Name; TableEntity.Mobile = userentity.Mobile; TableEntity.UserId = UserId; TableEntity.UpingLvid = Uppid; AgentReupEntityUserId(UserId, userentity.Inviter, UserPid); } } } if (LvId == 3) { int Upid = LvId - 1; int UserPid = Query(UserId, Upid); UserlvEntity nowlvEntity = lvbll.selectById(LvId); UserlvEntity pulvEntity = lvbll.selectById(Upid); TableEntity.LvName = nowlvEntity.Name; TableEntity.UpingName = pulvEntity.Name; TableEntity.Name = userentity.Name; TableEntity.Mobile = userentity.Mobile; TableEntity.UserId = UserId; TableEntity.UpingLvid = Upid; } if (LvId == 2) { int Upid = LvId - 1; UserlvEntity nowlvEntity = lvbll.selectById(LvId); UserlvEntity pulvEntity = lvbll.selectById(Upid); TableEntity.LvName = nowlvEntity.Name; TableEntity.UpingName = pulvEntity.Name; TableEntity.Name = userentity.Name; TableEntity.Mobile = userentity.Mobile; TableEntity.UserId = UserId; TableEntity.UpingLvid = Upid; } return(TableEntity); }
/// <summary> /// 是否满足升级条件 /// </summary> /// <param name="UserId"></param> /// <param name="LvId"></param> /// <returns></returns> public int judgeUpagentUser(int UserId, int LvId) { UpConditionBll Upbll = new UpConditionBll(); AgentuserBll userbll = new AgentuserBll(); AgentuserEntity userentity = userbll.selectById(UserId); AgentuserEntity upuserentity = new AgentuserEntity(); AgentuserUptagBll uptagbll = new AgentuserUptagBll(); UserlvBll lvbll = new UserlvBll(); UpAgentsEntity TableEntity = new UpAgentsEntity(); int YeworNo = 0; if (LvId > 3) { UserBalanceBll balbll = new UserBalanceBll(); UserBalanceEntity blentity = balbll.selectById(UserId); UpConditionEntity upthreeEntity = new UpConditionEntity(); int Uthreepid = 3; upthreeEntity = Upbll.selectById(Uthreepid); double PayMoney = upthreeEntity.PayMoney; if (blentity != null) { int UserPid = Query(UserId, Uthreepid); double BalancePrice = blentity.BalancePrice; int ReNum = blentity.ReNum; if (BalancePrice >= PayMoney) { YeworNo = 1; } } } if (LvId == 3) { UpConditionEntity upEntity = new UpConditionEntity(); int Upid = LvId - 1; upEntity = Upbll.selectById(Upid); int Upthree = upEntity.Upthree; string lvthreewhere = "Inviter=" + UserId + " and LvId=3 and State=1"; List <AgentuserEntity> listUser = userbll.selectByWhere(lvthreewhere); //直接邀请的人数 List <AgentuserEntity> JlistUser = AlllvThree(UserId); //间接人数和直接总合 string otherwhere = "StarInviter=" + UserId + " and LvId<3 and State=1"; List <AgentuserEntity> listotherUser = userbll.selectByWhere(otherwhere); if (listUser != null) { int UsrtNum = 0; foreach (var item in listUser) { UsrtNum++; } int UserotherNum = 0; if (listotherUser != null) { foreach (var itemother in listotherUser) { UserotherNum++; } } int UsrtNumTotal = UsrtNum + UserotherNum; if (UsrtNumTotal >= Upthree) { YeworNo = 1; } } } if (LvId == 2) { UpConditionEntity upEntity = new UpConditionEntity(); int Upid = LvId - 1; upEntity = Upbll.selectById(Upid); int Upthree = upEntity.Upthree; //总代个数 条件 int Uptwo = upEntity.Uptwo; //大总个数 条件 string lvthreewhere = "Inviter=" + UserId + " and LvId=3 and State=1"; string twowhere = "Inviter=" + UserId + " and LvId=2 and State=1"; string otherwhere = "StarInviter=" + UserId + " and LvId=1 and State=1"; List <AgentuserEntity> listthreeUser = userbll.selectByWhere(lvthreewhere); //直线总代个数 List <AgentuserEntity> listtwoUser = userbll.selectByWhere(twowhere); //直线大总个数 List <AgentuserEntity> listotherUser = userbll.selectByWhere(otherwhere); //直线邀请人 已经升级到大牌 List <AgentuserEntity> Listtwoall = AlllvTwo(UserId); int AllListtwoal = AllUserTwoandOne(UserId); if (listthreeUser != null && listtwoUser != null) { int UserthreeNum = 0; //直线总代个数 foreach (var itemtree in listthreeUser) { UserthreeNum++; } int UsertwoNum = 0;//已经升级到大总个数 foreach (var itemtwo in listtwoUser) { UsertwoNum++; } int UserotherNum = 0;//已经升级到大牌个数 if (listotherUser != null) { foreach (var itemother in listotherUser) { UserotherNum++; } } int AllUptwo = UserotherNum + UsertwoNum; //自己升级到大总和大牌总和 //满足升条件 1、总代+大总 +大牌个数>=10 也就是说 //1、大总和大牌 必须大于0 // 满足升级大牌得条件 //总代 直线 9 +1大总或者大牌 if (AllUptwo > 0 && UserthreeNum + UserotherNum + UsertwoNum >= Upthree + Uptwo) { YeworNo = 1; } if (AllListtwoal >= Uptwo && UserthreeNum + UserotherNum + UsertwoNum >= Upthree) { YeworNo = 1; } } } return(YeworNo); }
public void DowngradeVerify(int UserId, int NowLvId, int DowngradeLvId) { AgentuserBll userbll = new AgentuserBll(); AgentuserEntity userentity = userbll.selectById(UserId); AgentuserEntity UpEntity = new AgentuserEntity(); UpEntity.Id = userentity.Id; UpEntity.Name = userentity.Name; UpEntity.LoginName = userentity.LoginName; UpEntity.Password = userentity.Password; UpEntity.Email = userentity.Email; UpEntity.State = userentity.State; UpEntity.ProvinceId = userentity.ProvinceId; UpEntity.CityId = userentity.CityId; UpEntity.DistrictId = userentity.DistrictId; UpEntity.Address = userentity.Address; UpEntity.Createtime = userentity.Createtime; UpEntity.Inviter = userentity.Inviter; UpEntity.AuthorizationNum = userentity.AuthorizationNum; UpEntity.IdentityCard = userentity.IdentityCard; UpEntity.IdentityCardPic = userentity.IdentityCardPic; UpEntity.HeadPic = userentity.HeadPic; UpEntity.WechatId = userentity.WechatId; UpEntity.LvId = DowngradeLvId;//降级后的等级 UpEntity.Type = userentity.Type; UpEntity.AuthorizationTime = userentity.AuthorizationTime; UpEntity.StarInviter = userentity.StarInviter; UpEntity.Mobile = userentity.Mobile; UpEntity.ShopName = userentity.ShopName; if (NowLvId == 1) //现在是大牌 降级为大总 { int UserPid = userentity.Inviter; //原来的大牌的邀请人 就是降级后的上级 //1.自己旗下的总代 包括间接总代 都不用变 //2.自己旗下的大总 大总的上级 全部变成UserPid 其他信息不变 //3.自己明一下的大牌 邀请人变成 UserPid; //1.查询自己旗下的大总(条件) "UserPid=UserId and LvId=2" string MylvTwo = "LvId=2 and State=1 and UserPid=" + "'" + UserId + "'"; //旗下所有大总 邀请人不变 string MylvOne = "Inviter=" + UserId + " and LvId=1 and State=1"; // 旗下大牌 List <AgentuserEntity> MyTwoListEntity = userbll.selectByWhere(MylvTwo); List <AgentuserEntity> MyOneListEntity = userbll.selectByWhere(MylvOne); foreach (var item in MyTwoListEntity) { AgentuserEntity mytwoentity = new AgentuserEntity(); mytwoentity.Id = item.Id; mytwoentity.Name = item.Name; mytwoentity.LoginName = item.LoginName; mytwoentity.Password = item.Password; mytwoentity.Email = item.Email; mytwoentity.State = item.State; mytwoentity.ProvinceId = item.ProvinceId; mytwoentity.CityId = item.CityId; mytwoentity.DistrictId = item.DistrictId; mytwoentity.Address = item.Address; mytwoentity.Createtime = item.Createtime; mytwoentity.Inviter = item.Inviter; mytwoentity.AuthorizationNum = item.AuthorizationNum; mytwoentity.AuthorizationPic = item.AuthorizationPic; mytwoentity.IdentityCard = item.IdentityCard; mytwoentity.IdentityCardPic = item.IdentityCardPic; mytwoentity.HeadPic = item.HeadPic; mytwoentity.WechatId = item.WechatId; mytwoentity.LvId = item.LvId; mytwoentity.UserPid = UserPid; mytwoentity.Type = item.Type; mytwoentity.AuthorizationTime = item.AuthorizationTime; mytwoentity.StarInviter = item.StarInviter; mytwoentity.Mobile = item.Mobile; mytwoentity.ShopName = item.ShopName; userbll.Update(mytwoentity, item.Id); } foreach (var item in MyOneListEntity) { AgentuserEntity myoneentity = new AgentuserEntity(); myoneentity.Id = item.Id; myoneentity.Name = item.Name; myoneentity.LoginName = item.LoginName; myoneentity.Password = item.Password; myoneentity.Email = item.Email; myoneentity.State = item.State; myoneentity.ProvinceId = item.ProvinceId; myoneentity.CityId = item.CityId; myoneentity.DistrictId = item.DistrictId; myoneentity.Address = item.Address; myoneentity.Createtime = item.Createtime; myoneentity.Inviter = UserPid; myoneentity.AuthorizationNum = item.AuthorizationNum; myoneentity.AuthorizationPic = item.AuthorizationPic; myoneentity.IdentityCard = item.IdentityCard; myoneentity.IdentityCardPic = item.IdentityCardPic; myoneentity.HeadPic = item.HeadPic; myoneentity.WechatId = item.WechatId; myoneentity.LvId = item.LvId; myoneentity.UserPid = item.UserPid; myoneentity.Type = item.Type; myoneentity.AuthorizationTime = item.AuthorizationTime; myoneentity.StarInviter = item.StarInviter; myoneentity.Mobile = item.Mobile; myoneentity.ShopName = item.ShopName; userbll.Update(myoneentity, item.Id); } UpEntity.UserPid = UserPid; //降级后的上级 string authorizationpic = "AuthorizationImage.jpg"; //图片名称 string filesavePathName = string.Empty; string ex = Path.GetExtension(authorizationpic); filesavePathName = DateTime.Now.ToString("yyyyMMddHHmmssffff") + ex; string AuthorizationImage = ConfigurationManager.AppSettings["AuthorizationImage"]; //母版图片路径 string UploadAuthorizationImage = ConfigurationManager.AppSettings["UploadAuthorizationImage"]; //授权图片上传保存路径 string localPath = Path.Combine(HttpRuntime.AppDomainAppPath, AuthorizationImage); //读取路径 string savePath = Path.Combine(HttpRuntime.AppDomainAppPath, UploadAuthorizationImage) + filesavePathName; //保存路径 string filePathName = string.Empty; filePathName = localPath + authorizationpic; //授权母版图片路径 Image image = Image.FromFile(filePathName); //找到图片 Bitmap bitmap = new Bitmap(image, image.Width, image.Height); bitmap.Save(savePath, ImageFormat.Jpeg); //保存图片:新路径 //****************这里是处理授权图片的操作结束***************// UpEntity.AuthorizationPic = filesavePathName; UserlvBll lvbll = new UserlvBll(); UserlvEntity lventity = lvbll.selectById(DowngradeLvId); string time = DateTime.Now.ToString("D"); string atime = DateTime.Now.AddYears(1).ToString("D"); string strTime = time + " 至 " + atime; UpEntity.AuthorizationTime = strTime; string LvName = lventity.Name; string Time = DateTime.Now.ToString("yyyy年MM月dd日"); AuthorizationText Addtext = new AuthorizationText(); Addtext.AuthorizationRefreshAddText(filesavePathName, userentity.Name, userentity.Mobile, userentity.AuthorizationNum, userentity.IdentityCard, userentity.WechatId, LvName, Time); // AuthorizationRefreshAddTestToImg(filesavePathName, userentity.Name, userentity.LoginName, userentity.AuthorizationNum, userentity.IdentityCard, userentity.WechatId, LvName); userbll.Update(UpEntity, UserId); } //逻辑分析 1.降级之前是大总 降级的部分 //1、原来大总 名下的 总代转移给上级(大牌) //2、原来的大总邀请的大总 本来只是自己的邀请 上级并不是自己 所以并不需要进行改变 //3、总结:只需要转移旗下的总代 把总代的上级 转移给上级 至于小代理 本来就是自己 // 旗下的 所有不发生任何变化 间接发展的总代 其实也通过我的下级查询已经转移了 所有 // 只需把旗下总代的上级Id由自己变成为我原来的上级; if (NowLvId == 2) //现在是大总 降级为总代 { int UserPid = userentity.UserPid; string MyallSqlWhere = "LvId=3 and State=1 and UserPid=" + "'" + UserId + "'"; //旗下所有大总 邀请人不变 List <AgentuserEntity> MyListEntity = userbll.selectByWhere(MyallSqlWhere); foreach (var item in MyListEntity) { AgentuserEntity myentity = new AgentuserEntity(); myentity.Id = item.Id; myentity.Name = item.Name; myentity.LoginName = item.LoginName; myentity.Password = item.Password; myentity.Email = item.Email; myentity.State = item.State; myentity.ProvinceId = item.ProvinceId; myentity.CityId = item.CityId; myentity.DistrictId = item.DistrictId; myentity.Address = item.Address; myentity.Createtime = item.Createtime; myentity.Inviter = item.Inviter; myentity.AuthorizationNum = item.AuthorizationNum; myentity.AuthorizationPic = item.AuthorizationPic; myentity.IdentityCard = item.IdentityCard; myentity.IdentityCardPic = item.IdentityCardPic; myentity.HeadPic = item.HeadPic; myentity.WechatId = item.WechatId; myentity.LvId = item.LvId; myentity.UserPid = UserPid; myentity.Type = item.Type; myentity.AuthorizationTime = item.AuthorizationTime; myentity.StarInviter = item.StarInviter; myentity.Mobile = item.Mobile; myentity.ShopName = item.ShopName; userbll.Update(myentity, item.Id); } UpEntity.UserPid = UserPid; //降级后的上级 string authorizationpic = "AuthorizationImage.jpg"; //图片名称 string filesavePathName = string.Empty; string ex = Path.GetExtension(authorizationpic); filesavePathName = DateTime.Now.ToString("yyyyMMddHHmmssffff") + ex; string AuthorizationImage = ConfigurationManager.AppSettings["AuthorizationImage"]; //母版图片路径 string UploadAuthorizationImage = ConfigurationManager.AppSettings["UploadAuthorizationImage"]; //授权图片上传保存路径 string localPath = Path.Combine(HttpRuntime.AppDomainAppPath, AuthorizationImage); //读取路径 string savePath = Path.Combine(HttpRuntime.AppDomainAppPath, UploadAuthorizationImage) + filesavePathName; //保存路径 string filePathName = string.Empty; filePathName = localPath + authorizationpic; //授权母版图片路径 Image image = Image.FromFile(filePathName); //找到图片 Bitmap bitmap = new Bitmap(image, image.Width, image.Height); bitmap.Save(savePath, ImageFormat.Jpeg); //保存图片:新路径 //****************这里是处理授权图片的操作结束***************// UpEntity.AuthorizationPic = filesavePathName; UserlvBll lvbll = new UserlvBll(); UserlvEntity lventity = lvbll.selectById(DowngradeLvId); string time = DateTime.Now.ToString("D"); string atime = DateTime.Now.AddYears(1).ToString("D"); string strTime = time + " 至 " + atime; UpEntity.AuthorizationTime = strTime; string LvName = lventity.Name; string Time = DateTime.Now.ToString("yyyy年MM月dd日"); AuthorizationText Addtext = new AuthorizationText(); Addtext.AuthorizationRefreshAddText(filesavePathName, userentity.Name, userentity.Mobile, userentity.AuthorizationNum, userentity.IdentityCard, userentity.WechatId, LvName, Time); userbll.Update(UpEntity, UserId); } }