Esempio n. 1
0
        public static Agent CheckLogin(string mobile, string password)
        {
            Agent userEntity = AgentLogic.FindEntity(t => t.c_mobile == mobile);

            if (userEntity != null)
            {
                if (userEntity.c_state >= 1)
                {
                    string dbPassword = userEntity.c_login_pwd;
                    if (dbPassword == password)
                    {
                        return(userEntity);
                    }
                    else
                    {
                        throw new Exception("密码不正确,请重新输入");
                    }
                }
                else
                {
                    throw new Exception("账户未审核,请等待审核通过");
                }
            }
            else
            {
                throw new Exception("账户不存在,请重新输入");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 代理等级提升判断并执行
        /// </summary>
        /// <param name="RecomAgent">需要判断升级的代理商</param>
        /// <returns></returns>
        public static bool  IsLevelUpWithCondition(Agent RecomAgent)
        {
            bool result = false;

            using (DistributionContext context = new DistributionContext())
            {
                context.SaveChanges();
                if (RecomAgent.c_agnet_type == (int)AgentType.Exp)
                {
                    return(result);
                }
                int currentLevel = (int)RecomAgent.c_levle;                                                        //当前等级
                int maxLevel     = (int)context.t_level_config.Where(t => t.c_is_delete == 0).Max(t => t.c_level); //当前系统的最高级别
                if (currentLevel == maxLevel)
                {
                    return(result);
                }

                var list = context.t_level_config.Where(f => f.c_is_delete == 0 && f.c_level == (currentLevel + 1));
                if (list.Count() > 0)
                {
                    //升级所需条件配置
                    LevelConfig config      = list.First();
                    var         list_direct = context.t_agent_relation.Where(f => f.c_parent_id == RecomAgent.c_id && f.ChildrenAgent.c_agnet_type != (int)AgentType.Exp);//直推人数
                    if (list_direct.Count() < config.c_need_nums)
                    {
                        result = false;
                    }
                    else
                    {
                        //达到相应等级的人数
                        int levelCount = list_direct.Where(f => f.ChildrenAgent.c_levle >= config.c_need_level && f.ChildrenAgent.c_agnet_type != (int)AgentType.Exp).Count();
                        if (config.c_need_level == null)
                        {
                            RecomAgent.c_levle = currentLevel + 1;
                            AgentLogic.UpdateEntity(RecomAgent);
                            result = true;
                        }
                        else if (levelCount >= config.c_level_num)
                        {
                            RecomAgent.c_levle = currentLevel + 1;
                            AgentLogic.UpdateEntity(RecomAgent);
                            result = true;
                        }
                    }
                }
                var plist = context.t_agent_relation.Where(f => f.c_child_id == RecomAgent.c_id).ToList();
                if (plist.Count() > 0)
                {
                    Agent pAg = plist.FirstOrDefault().ParentAgent;
                    IsLevelUpWithCondition(pAg);
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }