public ActionResult Index(CCY_WxConfig wxConfig) { if (Request.HttpMethod.ToUpper() == MethodType.GET) { var wechat = Manager.Get(); if (wechat == null) { wechat = new CCY_WxConfig(); } return(View(wechat)); } else { wxConfig.sAppId = wxConfig.sAppId.Trim(); wxConfig.sAppSecret = wxConfig.sAppSecret.Trim(); wxConfig.sMchId = wxConfig.sMchId.Trim(); wxConfig.sPayKey = wxConfig.sPayKey.Trim(); wxConfig.sNotifyUrl = wxConfig.sNotifyUrl.Trim(); if (Manager.Save(wxConfig)) {//保存成功写入Redis缓存 string sKey = "WxConfig"; RedisHelper.SetKey(RedisCacheType.SystemConfig, sKey, wxConfig); result.success = true; } else { result.info = "保存失败"; } return(Json(result)); } }
/// <summary> /// 保存微信供公众号设置 /// </summary> /// <param name="WeChat"></param> /// <returns></returns> public override bool Save(CCY_WxConfig wxConfig) { if (string.IsNullOrEmpty(wxConfig.ID)) {//添加 wxConfig.ID = GuidHelper.NewGuidString(); string sSql = @"INSERT INTO dbo.CCY_WxConfig( ID ,sName ,sAppId ,sAppSecret ,sMchId ,sPayKey ,sNotifyUrl ) VALUES ( @ID ,@sName ,@sAppId ,@sAppSecret ,@sMchId ,@sPayKey ,@sNotifyUrl )"; return(excute.ExcuteSql(sSql, wxConfig) == 1); } else {//编辑 string sSql = @"Update dbo.CCY_WxConfig set sName=@sName, sAppId=@sAppId, sAppSecret=@sAppSecret, sMchId=@sMchId, sPayKey=@sPayKey, sNotifyUrl=@sNotifyUrl where ID=@ID"; return(excute.ExcuteSql(sSql, wxConfig) == 1); } }
/// <summary> /// 保存微信供公众号设置 /// </summary> /// <param name="WeChat"></param> /// <returns></returns> public abstract bool Save(CCY_WxConfig wxConfig);