Example #1
0
        public UserGradeConfig GetGrade(Guid gradeId)
        {
            var userGrades = GetUserGradeList();
            var grade      = userGrades.FirstOrDefault(e => e.Id == gradeId);

            if (grade == null)
            {
                grade = new UserGradeConfig();
            }

            return(grade);
        }
Example #2
0
        public IList <UserGradeConfig> GetUserGradeList()
        {
            var userGrades = Resolve <IAlaboAutoConfigService>()
                             .GetList <UserGradeConfig>(r => r.Status == Status.Normal);

            if (userGrades.Count == 0)
            {
                var userType = Resolve <IAlaboAutoConfigService>().GetList <UserTypeConfig>()
                               .FirstOrDefault(r => r.TypeClass == UserTypeEnum.Member);
                var gradeConfig = new UserGradeConfig();
                if (userType != null)
                {
                    gradeConfig.Id = userType.Id;
                }

                gradeConfig.SetDefault();
                userGrades = Resolve <IAlaboAutoConfigService>()
                             .GetList <UserGradeConfig>(r => r.Status == Status.Normal);
            }

            return(userGrades);
        }
Example #3
0
        /// <summary>
        ///     设置默认值
        /// </summary>
        public void SetDefault()
        {
            var list = Ioc.Resolve <IAutoConfigService>().GetList <UserLevelConfig>();

            if (list.Count == 0)
            {
                var configs = new List <UserLevelConfig>();

                var config = new UserLevelConfig {
                    Name          = "普通",
                    Price         = 0m,
                    DeliveryPrice = 0m,
                    PreferePrice  = 0m,
                    PremiumPrice  = 300m,
                    Id            = Guid.Parse("E0000000-1479-49BD-BFC7-E00000000001"),
                    Intro         = "笔卡消费级别"
                };
                configs.Add(config);

                config = new UserLevelConfig {
                    Name          = "笔卡",
                    Price         = 1000m,
                    DeliveryPrice = 25m,
                    PreferePrice  = 5,
                    PremiumPrice  = 300,
                    Id            = Guid.Parse("E0000000-1479-49BD-BFC7-E00000000002"),
                    Intro         = "笔卡消费级别"
                };
                configs.Add(config);

                config = new UserLevelConfig {
                    Name          = "墨卡",
                    Price         = 2680m,
                    DeliveryPrice = 30m,
                    PreferePrice  = 10,
                    PremiumPrice  = 1072,
                    Id            = Guid.Parse("E0000000-1479-49BD-BFC7-E00000000003"),
                    Intro         = "墨卡消费级别"
                };
                configs.Add(config);

                config = new UserLevelConfig {
                    Name          = "纸卡",
                    Price         = 8800,
                    DeliveryPrice = 40,
                    PreferePrice  = 10,
                    PremiumPrice  = 4400,
                    Id            = Guid.Parse("E0000000-1479-49BD-BFC7-E00000000004"),
                    Intro         = "纸卡消费级别"
                };
                configs.Add(config);

                config = new UserLevelConfig {
                    Name          = "砚卡",
                    Price         = 26800,
                    DeliveryPrice = 50,
                    PreferePrice  = 10,
                    PremiumPrice  = 1608,
                    Id            = Guid.Parse("E0000000-1479-49BD-BFC7-E00000000005"),
                    Intro         = "砚卡消费级别"
                };
                configs.Add(config);

                config = new UserLevelConfig {
                    Name          = "合伙人",
                    Price         = 200000,
                    DeliveryPrice = 60,
                    PreferePrice  = 20,
                    PremiumPrice  = 160000,
                    Id            = Guid.Parse("E0000000-1479-49BD-BFC7-E00000000006"),
                    Intro         = "合伙人消费级别"
                };
                configs.Add(config);

                var autoConfig = new AutoConfig {
                    Type        = config.GetType().FullName,
                    LastUpdated = DateTime.Now,
                    Value       = JsonConvert.SerializeObject(configs)
                };
                Ioc.Resolve <IAutoConfigService>().AddOrUpdate(autoConfig);
            }

            var userGrades = Ioc.Resolve <IAutoConfigService>().GetList <UserGradeConfig>();

            if (userGrades.Count < 1)
            {
                var config = new UserGradeConfig {
                    Id        = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366000"),
                    Name      = "书生",
                    Icon      = "/wwwroot/static/images/GradeIcon/User01.png",
                    IsDefault = true
                };
                userGrades.Add(config);

                config = new UserGradeConfig {
                    Id         = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366001"),
                    Name       = "秀才",
                    Icon       = "/wwwroot/static/images/GradeIcon/User02.png",
                    IsDefault  = false,
                    Contribute = 10
                };
                userGrades.Add(config);

                config = new UserGradeConfig {
                    Id         = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366002"),
                    Name       = "举人",
                    Icon       = "/wwwroot/static/images/GradeIcon/User03.png",
                    IsDefault  = false,
                    Contribute = 100
                };
                userGrades.Add(config);

                config = new UserGradeConfig {
                    Id        = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366003"),
                    Name      = "贡士",
                    Icon      = "/wwwroot/static/images/GradeIcon/User01.png",
                    IsDefault = true
                };
                userGrades.Add(config);

                config = new UserGradeConfig {
                    Id         = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366004"),
                    Name       = "进士",
                    Icon       = "/wwwroot/static/images/GradeIcon/User02.png",
                    IsDefault  = false,
                    Contribute = 1000
                };
                userGrades.Add(config);

                config = new UserGradeConfig {
                    Id         = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366005"),
                    Name       = "状元",
                    Icon       = "/wwwroot/static/images/GradeIcon/User03.png",
                    IsDefault  = false,
                    Contribute = 10000
                };
                userGrades.Add(config);

                config = new UserGradeConfig {
                    Id         = Guid.Parse("72be65e6-3000-414d-972e-1a3d4a366006"),
                    Name       = "大学士",
                    Icon       = "/wwwroot/static/images/GradeIcon/User03.png",
                    IsDefault  = false,
                    Contribute = 100000
                };
                userGrades.Add(config);

                var autoConfig = new AutoConfig {
                    Type        = config.GetType().FullName,
                    LastUpdated = DateTime.Now,
                    Value       = JsonConvert.SerializeObject(userGrades)
                };
                Ioc.Resolve <IAutoConfigService>().AddOrUpdate(autoConfig);
            }
        }
Example #4
0
        public void AddOrUpdate_AutoConfig_test()
        {
            UserGradeConfig config = new UserGradeConfig();

            config.SetDefault();
        }