/// <summary>
 /// 修改下单完成页广告配置
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool UpdateAdvertisingConfig(AdvertisingConfigModel model)
 {
     using (var conn = ProcessConnection.OpenConfiguration)
     {
         return(dal.UpdateAdvertisingConfig(conn, model));
     }
 }
예제 #2
0
        /// <summary>
        /// 修改下单完成页广告配置
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UpdateAdvertisingConfig(SqlConnection conn, AdvertisingConfigModel model)
        {
            #region SQL
            string sql = @" UPDATE [Configuration].[dbo].[AdvertisingConfig] WITH(ROWLOCK)
                               SET [Title] = @Title
                                  ,[AdLocation] = @AdLocation
                                  ,[AdType] = @AdType
                                  ,[ProvinceID] = @ProvinceID
                                  ,[ProvinceName] = @ProvinceName
                                  ,[CityID] = @CityID
                                  ,[CityName] = @CityName
                                  ,[ProductLine] = @ProductLine
                                  ,[SupportedChannels] = @SupportedChannels
                                  ,[PcIconUrl] = @PcIconUrl
                                  ,[MobileIconUrl] = @MobileIconUrl
                                  ,[Slogan] = @Slogan
                                  ,[OperatingButtonText] = @OperatingButtonText
                                  ,[PcImageUrl] = @PcImageUrl
                                  ,[MobileImageUrl] = @MobileImageUrl
                                  ,[PcRoute] = @PcRoute
                                  ,[MiniProgramRoute] = @MiniProgramRoute
                                  ,[IosRoute] = @IosRoute
                                  ,[AndroidRoute] = @AndroidRoute
                                  ,[WapRoute] = @WapRoute
                                  ,[HuaweiRoute]=@HuaweiRoute
                                  ,[StartVersion] = @StartVersion
                                  ,[EndVersion] = @EndVersion
                                  ,[OnlineTime]=@OnlineTime
                                  ,[OfflineTime]=@OfflineTime
                                  ,[Status] = @Status
                                  ,[Creator] = @Creator
                                  ,[LastUpdateDateTime] = GETDATE()
                             WHERE PKID=@PKID ";
            #endregion

            return(conn.Execute(sql, model) > 0);
        }
예제 #3
0
        /// <summary>
        /// 复制/编辑广告位配置
        /// </summary>
        /// <param name="pkId"></param>
        /// <param name="isCopy"></param>
        /// <returns></returns>
        public ActionResult Edit(long pkId = 0, int isCopy = 0)
        {
            if (pkId > 0)
            {
                var    manager = new AdvertisingConfigManager();
                var    advertisingConfigInfo = manager.GetAdvertisingConfigInfo(pkId);
                string domain = swc.WebConfigurationManager.AppSettings["DoMain_image"];
                if (!string.IsNullOrEmpty(advertisingConfigInfo.MobileIconUrl))
                {
                    advertisingConfigInfo.DomainMobileIconUrl = domain + advertisingConfigInfo.MobileIconUrl;
                }
                if (!string.IsNullOrEmpty(advertisingConfigInfo.PcIconUrl))
                {
                    advertisingConfigInfo.DomainPcIconUrl = domain + advertisingConfigInfo.PcIconUrl;
                }
                if (!string.IsNullOrEmpty(advertisingConfigInfo.MobileImageUrl))
                {
                    advertisingConfigInfo.DomainMobileImageUrl = domain + advertisingConfigInfo.MobileImageUrl;
                }
                if (!string.IsNullOrEmpty(advertisingConfigInfo.PcImageUrl))
                {
                    advertisingConfigInfo.DomainPcImageUrl = domain + advertisingConfigInfo.PcImageUrl;
                }


                if (isCopy == 1)//复制时,将主键赋值成0
                {
                    advertisingConfigInfo.PKID = 0;
                }
                return(View(advertisingConfigInfo));
            }
            var model = new AdvertisingConfigModel();

            model.AdType = 1;   //文字广告
            return(View(model));
        }
예제 #4
0
 /// <summary>
 /// 新增下单完成页广告配置
 /// </summary>
 /// <param name="conn"></param>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool AddAdvertisingConfig(SqlConnection conn, AdvertisingConfigModel model)
 {
     #region SQL
     string sql = @"
                     INSERT INTO [Configuration].[dbo].[AdvertisingConfig] WITH(ROWLOCK)
                                ([Title]
                                ,[AdLocation]
                                ,[AdType]
                                ,[ProvinceID]
                                ,[ProvinceName]
                                ,[CityID]
                                ,[CityName]
                                ,[ProductLine]
                                ,[SupportedChannels]
                                ,[PcIconUrl]
                                ,[MobileIconUrl]
                                ,[Slogan]
                                ,[OperatingButtonText]
                                ,[PcImageUrl]
                                ,[MobileImageUrl]
                                ,[PcRoute]
                                ,[MiniProgramRoute]
                                ,[IosRoute]
                                ,[AndroidRoute]
                                ,[WapRoute]
                                ,[HuaweiRoute]
                                ,[StartVersion]
                                ,[EndVersion]
                                ,[OnlineTime]
                                ,[OfflineTime]
                                ,[Status]
                                ,[Creator])
                          VALUES
                                (@Title
                                ,@AdLocation
                                ,@AdType
                                ,@ProvinceID
                                ,@ProvinceName
                                ,@CityID
                                ,@CityName
                                ,@ProductLine
                                ,@SupportedChannels
                                ,@PcIconUrl
                                ,@MobileIconUrl
                                ,@Slogan
                                ,@OperatingButtonText
                                ,@PcImageUrl
                                ,@MobileImageUrl
                                ,@PcRoute
                                ,@MiniProgramRoute
                                ,@IosRoute
                                ,@AndroidRoute
                                ,@WapRoute
                                ,@HuaweiRoute
                                ,@StartVersion
                                ,@EndVersion
                                ,@OnlineTime
                                ,@OfflineTime
                                ,@STATUS
                                ,@Creator);
                     SELECT CAST(SCOPE_IDENTITY() as int);";
     #endregion
     model.PKID = conn.Query <int>(sql, model).FirstOrDefault();
     if (model.PKID > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #5
0
        /// <summary>
        /// 新增/复制/编辑广告
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult AddAdvertisingConfig(AdvertisingConfigModel model)
        {
            var manager = new AdvertisingConfigManager();

            if (!string.IsNullOrEmpty(model.StartVersion))
            {
                Version startVersion;
                if (!Version.TryParse(model.StartVersion, out startVersion))
                {
                    return(Content(JsonConvert.SerializeObject(new
                    {
                        state = "failure",
                        message = "开始版本的类型有误",
                        data = ""
                    })));
                }
            }
            if (!string.IsNullOrEmpty(model.EndVersion))
            {
                Version endVersion;
                if (!Version.TryParse(model.EndVersion, out endVersion))
                {
                    return(Content(JsonConvert.SerializeObject(new
                    {
                        state = "failure",
                        message = "结束版本的类型有误",
                        data = ""
                    })));
                }
            }
            //根据区域信息和产品线判断配置是否存在
            var exsitConfigInfo = manager.GetAdvertisingConfigInfo(model.ProvinceID, model.CityID, model.ProductLine, model.AdType);

            if (exsitConfigInfo != null && exsitConfigInfo.PKID != model.PKID)
            {
                exsitConfigInfo.Status = 0;//禁用
                manager.UpdateAdvertisingConfig(exsitConfigInfo);
                #region 日志记录
                using (var client = new ConfigLogClient())
                {
                    var response = client.InsertDefaultLogQueue("CommonConfigLog", JsonConvert.SerializeObject(new
                    {
                        ObjectId    = model.PKID,
                        ObjectType  = "AdvertisingConfig",
                        BeforeValue = "",
                        AfterValue  = JsonConvert.SerializeObject(exsitConfigInfo),
                        Remark      = "禁用广告配置",
                        Creator     = User.Identity.Name,
                    }));
                }
                #endregion
            }
            //新增
            if (model.PKID == 0)
            {
                model.AdLocation = 1;//下单完成页
                model.Status     = 1;
                model.Creator    = User.Identity.Name;
                manager.AddAdvertisingConfig(model);
                #region 日志记录
                using (var client = new ConfigLogClient())
                {
                    var response = client.InsertDefaultLogQueue("CommonConfigLog", JsonConvert.SerializeObject(new
                    {
                        ObjectId    = model.PKID,
                        ObjectType  = "AdvertisingConfig",
                        BeforeValue = "",
                        AfterValue  = JsonConvert.SerializeObject(model),
                        Remark      = "新增广告配置",
                        Creator     = User.Identity.Name,
                    }));
                }
                #endregion
            }
            //编辑
            else
            {
                var configInfo = manager.GetAdvertisingConfigInfo(model.PKID);
                model.AdLocation = configInfo.AdLocation;; //下单完成页
                model.Status     = 1;                      //启用
                model.Creator    = configInfo.Creator;
                manager.UpdateAdvertisingConfig(model);
                #region 日志记录
                using (var client = new ConfigLogClient())
                {
                    var response = client.InsertDefaultLogQueue("CommonConfigLog", JsonConvert.SerializeObject(new
                    {
                        ObjectId    = model.PKID,
                        ObjectType  = "AdvertisingConfig",
                        BeforeValue = JsonConvert.SerializeObject(configInfo),
                        AfterValue  = JsonConvert.SerializeObject(model),
                        Remark      = "修改广告配置",
                        Creator     = User.Identity.Name,
                    }));
                }
                #endregion
            }
            //等待1秒,写库同步到读库
            Thread.Sleep(1000);
            return(Content(JsonConvert.SerializeObject(new
            {
                state = "success",
                message = "操作成功",
                data = ""
            })));
        }