/// <summary>
        /// 兑换码模板详情
        /// </summary>
        /// <param name="configId"></param>
        /// <returns></returns>
        public ActionResult TmplDetail(Guid id = default(Guid))
        {
            var config       = id != Guid.Empty ? manager.GetRedemptionCodeConfig(id) : null;
            var groupIdModel = manager.GetGroupSettingByGroupId(config.GroupId ?? Guid.NewGuid());
            var serverType   = 0;

            if (groupIdModel != null && !string.IsNullOrEmpty(groupIdModel.AppId))
            {
                var appinfo = manager.GetThirdAppSettingsDetailByGroupId(groupIdModel.AppId);
                if (appinfo != null)
                {
                    switch (appinfo.BigCustomerStatus)
                    {
                    case "Informal":    //测试
                        serverType = 1;
                        break;

                    default:
                        serverType = 0;
                        break;
                    }
                }
            }
            ViewData["Data"]       = config ?? new RedemptionConfig();
            ViewData["ServerType"] = serverType;
            return(View());
        }
Пример #2
0
        public ActionResult AddOrUpdateRedemptionCodeConfig(RedemptionConfig config)
        {
            #region validated
            if (config == null ||
                string.IsNullOrWhiteSpace(config.Name) ||
                config.CooperateId <= 0 ||
                string.IsNullOrWhiteSpace(config.CooperateName) ||
                config.EffectiveDay <= 0 ||
                config.AtLeastNum <= 0 || config.AtMostNum <= 0)
            {
                return(Json(new { status = false, msg = "配置不能为空,参数错误" }));
            }
            config.GenerateType = string.Equals(config.GenerateType, BATCH_TYPE, StringComparison.OrdinalIgnoreCase) ?
                                  BATCH_TYPE :
                                  (string.Equals(config.GenerateType, INTERFACE_TYPE, StringComparison.OrdinalIgnoreCase) ? INTERFACE_TYPE : string.Empty);
            if (string.IsNullOrEmpty(config.GenerateType))
            {
                return(Json(new { status = false, msg = "生成类型有误,请重试" }));
            }

            config.Name             = config.Name.Trim();
            config.SettlementMethod = string.Equals(BATCH_PRESETTLED, config.SettlementMethod, StringComparison.OrdinalIgnoreCase) ?
                                      BATCH_PRESETTLED : string.Empty;

            var exists = manager.IsExistsRedemptionConfig(config);
            if (exists)
            {
                return(Json(new { status = false, msg = "已存在相同名称的配置" }));
            }
            if (config.GroupId != null)
            {
                var isUpdate     = config.ConfigId != Guid.Empty;
                var groupSetting = manager.GetGroupSettingByGroupId(config.GroupId ?? Guid.Empty);
                if (groupSetting == null)
                {
                    return(Json(new { status = false, msg = $"所选群组不存在:{config.GroupId}" }));
                }


                var RedeemMrCodeConfigs = manager.GetRedeemMrCodeConfigs(config.ConfigId);
                if (groupSetting.SendCodeType == 1 && config.IsActive)//自动发码
                {
                    var groupConfigs = manager.GetRedemptionConfigsGroupId(config.GroupId ?? Guid.Empty);
                    if (!isUpdate && groupConfigs != null && groupConfigs.Any())
                    {
                        return(Json(new { status = false, msg = "所选群组为自动发码,已经存在一个套餐=》自动发码群组只能有一个套餐" }));
                    }
                    if (isUpdate && groupConfigs != null && groupConfigs.Count() >= 1 && groupConfigs.Any(a => a.ConfigId != config.ConfigId))
                    {
                        return(Json(new { status = false, msg = "所选群组为自动发码,已经存在一个套餐=》自动发码群组只能有一个套餐" }));
                    }
                }
                if (RedeemMrCodeConfigs != null && RedeemMrCodeConfigs.Any(a => !a.IsRequired))
                {
                    return(Json(new { status = false, msg = "配置了群组的模板,模板详情内容都应该必选" }));
                }
            }
            #endregion

            config.CreateUser = User.Identity.Name;
            var result = config.ConfigId != Guid.Empty ?
                         manager.UpdateRedemptionCodeConfig(config) :
                         manager.AddRedemptionCodeConfig(config);
            return(Json(new { status = result }));
        }