/// <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); }
/// <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); }