/// <summary> /// 申请提现 /// </summary> public ActionResult ApplyMoney() { try { User user = GetUserInfo(); if (user == null) { return(Json(new { result = false, message = "用户信息验证失败", code = Enum_ErrorCode.UnLogin }, JsonRequestBehavior.AllowGet)); } if (db.Exists <ApplyMoney>(x => x.CreateUserNumber == user.Number && x.Status == Enum_Status.Audit)) { return(Json(new { result = false, message = "已申请,申请后5个工作日内发放完毕" }, JsonRequestBehavior.AllowGet)); } //打赏金额 var orderMoney = db.Find <Order>(x => x.ToUserNumber == user.Number && x.Status == Enum_Status.Approved).Sum(x => x.Price); //红包金额 var redMoney = db.Find <Red>(x => x.ToUserNumber == user.Number && x.Status == Enum_Status.Approved).Sum(x => x.Price); //提现次数 var applyCount = db.Find <ApplyMoney>(x => x.CreateUserNumber == user.Number && x.Status == Enum_Status.Approved).Count; //剩余赏金 user.Money = orderMoney + redMoney - applyCount * Apply_Money * 100; if (user.Money < 0) { user.Money = 0; } else { user.Money = user.Money / 100; } if (user.Money < Apply_Money) { return(Json(new { result = false, message = "账户余额不足" + Apply_Money + "元,暂时无法提现" }, JsonRequestBehavior.AllowGet)); } var name = ZNRequest.GetString("Name"); var account = ZNRequest.GetString("Account"); ApplyMoney model = new ApplyMoney(); model.Account = account; model.AccountName = name; model.CreateUserNumber = user.Number; model.Status = Enum_Status.Audit; model.CreateDate = DateTime.Now; model.CreateIP = Tools.GetClientIP; var result = Tools.SafeInt(db.Add <ApplyMoney>(model)) > 0; if (result) { return(Json(new { result = true, message = "申请成功,5个工作日内发放完毕" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { LogHelper.ErrorLoger.Error("SystemController_ApplyMoney:" + ex.Message); } return(Json(new { result = false, message = "申请失败" }, JsonRequestBehavior.AllowGet)); }
public ActionResult EditArticleTemp() { try { var ArticleID = ZNRequest.GetInt("ArticleID"); var Template = ZNRequest.GetInt("Template"); var result = new SubSonic.Query.Update <Article>(provider).Set("Template").EqualTo(Template).Where <Article>(x => x.ID == ArticleID).Execute() > 0; if (result) { //取消自定义模板启用 string ArticleNumber = ZNRequest.GetString("ArticleNumber"); if (!string.IsNullOrWhiteSpace(ArticleNumber) && Template != 1) { var list = db.Find <Background>(x => x.ArticleNumber == ArticleNumber && x.IsUsed == Enum_Used.Approved).ToList(); if (list.Count > 0) { list.ForEach(x => { x.IsUsed = Enum_Used.Audit; }); db.UpdateMany <Background>(list); } } return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { LogHelper.ErrorLoger.Error("ArticleController_EditArticleTemp:" + ex.Message); } return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet)); }
public ActionResult Home() { var openid = ZNRequest.GetString("openid"); var nickname = ZNRequest.GetString("nickname"); //用户昵称 var avatar = ZNRequest.GetString("headimgurl"); //用户头像 //判断微信浏览器跳转授权 //string userAgent = Request.UserAgent; //if (userAgent.ToLower().Contains("micromessenger") && string.IsNullOrWhiteSpace(openid) && // string.IsNullOrWhiteSpace(nickname) && string.IsNullOrWhiteSpace(avatar)) //{ // var url = System.Web.HttpContext.Current.Request.Url.ToString(); // url = url.Replace("&", "godlike"); // var redirectUrl1 = "wx974a5cbcb4a85bc7"; // var redirectUrl2 = "http://wx.51pinzhi.cn/wx_new/api/WeixinApi/GetPrivilege"; // var redirectUrl3 = "iwx_wxd944a4e7e4fbb864"; // var redirectUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + redirectUrl1 + "&redirect_uri=" + redirectUrl2 + "?backurl=" + url + "&response_type=code&scope=snsapi_userinfo&state=" + redirectUrl3 + "#wechat_redirect"; // ViewBag.Url = redirectUrl; // Response.Redirect(redirectUrl); //} var url2 = System.Web.HttpContext.Current.Server.UrlEncode("http://www.baidu.com"); //https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx3b2ef7c18241c20f&redirect_uri=http%3a%2f%2fwww.baidu.com&response_type=code&scope=snsapi_userinfo&state=123456&connect_redirect=1#wechat_redirect return(Json(true)); }
public IHttpActionResult CheckDirty() { ApiResult result = new ApiResult(); try { var title = UrlDecode(ZNRequest.GetString("Title")); if (ProcessSqlStr(title)) { result.message = "存在违禁词"; return(Json <ApiResult>(result)); } var dirtyword = AppHelper.HasDirtyWord(title); if (!string.IsNullOrWhiteSpace(dirtyword)) { result.message = "您输入的内容含有敏感内容[" + dirtyword + "],请检查后重试哦"; return(Json <ApiResult>(result)); } result.result = true; result.message = ""; return(Json <ApiResult>(result)); } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_System_CheckDirty:" + ex.Message); result.message = ex.Message; } return(Json <ApiResult>(result)); }
public string FollowsAll() { ApiResult result = new ApiResult(); try { var CreateUserNumber = ZNRequest.GetString("CreateUserNumber"); if (string.IsNullOrWhiteSpace(CreateUserNumber)) { result.message = "参数异常"; return(JsonConvert.SerializeObject(result)); } var CurrUserNumber = ZNRequest.GetString("CurrUserNumber"); if (string.IsNullOrWhiteSpace(CurrUserNumber)) { CurrUserNumber = CreateUserNumber; } var pager = new Pager(); var query = new SubSonic.Query.Select(provider).From <Fan>().Where <Fan>(x => x.CreateUserNumber == CreateUserNumber); var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.message = new { records = recordCount, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var list = query.Paged(pager.Index, pager.Size).OrderDesc("ID").ExecuteTypedList <Fan>(); var array = list.Select(x => x.ToUserNumber).Distinct().ToList(); var users = new SubSonic.Query.Select(provider, "ID", "NickName", "Avatar", "Cover", "Signature", "Number").From <User>().Where <User>(x => x.Status == Enum_Status.Approved).And("Number").In(array.ToArray()).ExecuteTypedList <User>(); var follows = db.Find <Fan>(x => x.CreateUserNumber == CurrUserNumber).ToList(); var newlist = (from l in list join u in users on l.ToUserNumber equals u.Number select new { ID = l.ID, CreateDate = FormatTime(l.CreateDate), UserID = u.ID, Cover = u.Cover, NickName = u.NickName, Signature = u.Signature, Avatar = u.Avatar, Number = u.Number, IsFollow = follows.Exists(x => x.ToUserNumber == u.Number) ? 1 : 0 }).ToList(); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Fan_FollowsAll:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string Info() { ApiResult result = new ApiResult(); try { var number = ZNRequest.GetString("Number"); if (string.IsNullOrWhiteSpace(number)) { result.message = "信息异常"; return(JsonConvert.SerializeObject(result)); } Background model = db.Single <Background>(x => x.Number == number); if (model == null) { model = new Background(); } result.result = true; result.message = model; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Background_Info" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string ToUser_1_3() { ApiResult result = new ApiResult(); try { var UserNumber = ZNRequest.GetString("UserNumber"); if (string.IsNullOrWhiteSpace(UserNumber)) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var query = new SubSonic.Query.Select(provider).From <Order>().Where <Order>(x => x.Status == Enum_Status.Approved); query = query.And("CreateUserNumber").IsEqualTo(UserNumber); var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var pager = new Pager(); var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var list = query.Paged(pager.Index, pager.Size).OrderDesc("ID").ExecuteTypedList <Order>(); var userarray = list.Select(x => x.ToUserNumber).Distinct().ToList(); var allusers = new SubSonic.Query.Select(provider, "ID", "NickName", "Avatar", "Number", "Cover").From <User>().And("Number").In(userarray.ToArray()).ExecuteTypedList <User>(); List <OrdersJson> newlist = new List <OrdersJson>(); list.ForEach(x => { var user = allusers.FirstOrDefault(y => y.Number == x.ToUserNumber); if (user != null) { OrdersJson model = new OrdersJson(); model.ID = x.ID; model.CreateDate = x.CreateDate.ToString("yyyy-MM-dd hh:mm:ss"); model.Price = x.Price; model.UserID = user.ID; model.UserNumber = user.Number; model.UserAvatar = user.Avatar; model.UserName = user.NickName; model.UserCover = user.Cover; newlist.Add(model); } }); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Order_ToUser_1_3:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
/// <summary> /// 打开红包 /// </summary> public ActionResult OpenRed() { try { var usernumber = ZNRequest.GetString("usernumber"); var number = ZNRequest.GetString("number"); if (string.IsNullOrWhiteSpace(number)) { return(Json(new { result = false, message = "参数异常" }, JsonRequestBehavior.AllowGet)); } var model = db.Single <Red>(x => x.ToUserNumber == usernumber && x.Number == number && x.Status == Enum_Red.Audit); if (model == null) { return(Json(new { result = false, message = "红包已领取" }, JsonRequestBehavior.AllowGet)); } model.Status = Enum_Red.Approved; db.Update <Red>(model); return(Json(new { result = true, message = "" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { LogHelper.ErrorLoger.Error("Red_OpenRed:" + ex.Message); return(Json(new { result = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public string ALL() { ApiResult result = new ApiResult(); try { var title = ZNRequest.GetString("Title"); var text = ZNRequest.GetString("Text"); string clientId = "557e5625f84c82517457c43024b03b0c"; PushHelper message = new PushHelper(new List <string>() { clientId }); var beginTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var endTime = DateTime.Now.AddHours(2).ToString("yyyy-MM-dd HH:mm:ss"); //string msg1 = message.PushMessageToSingleByNotificationTemplate("XXX - 单用户", "您有新的任务,点击查看!", "", "", "", beginTime, endTime); //string msg2 = message.PushMessageToListByNotificationTemplate("XXX - 多用户", "您有新的任务,点击查看!", "", "", "", beginTime, endTime); string msg3 = message.PushTemplate(Enum_Push.All, "XXX - APP应用", "您有新的任务,点击查看啊!", "", "", "{id:1}", beginTime, endTime); } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_UserLog_Edit" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
/// <summary> /// 校验短信验证码 /// </summary> public ActionResult CheckSMSCode() { string mobile = ZNRequest.GetString("Mobile"); string code = ZNRequest.GetString("Code"); string sms = ZNRequest.GetString("SMS"); if (string.IsNullOrWhiteSpace(mobile) || string.IsNullOrWhiteSpace(code)) { return(Json(new { result = false, message = "参数异常" }, JsonRequestBehavior.AllowGet)); } try { var value = CookieHelper.GetCookieValue("SMS"); if (value == mobile + sms + code) { CookieHelper.ClearCookie("SMS"); return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { LogHelper.ErrorLoger.Error("SystemController_CheckSMSCode:" + ex.Message); } return(Json(new { result = false, message = "验证码错误" }, JsonRequestBehavior.AllowGet)); }
public string SearchMenuList() { ApiResult result = new ApiResult(); try { var list = new List <Music>(); var url = ZNRequest.GetString("url"); if (string.IsNullOrWhiteSpace(url)) { result.result = true; result.message = new { currpage = 1, records = 0, totalpage = 1, list = list }; return(JsonConvert.SerializeObject(result)); } //http://mp3.sogou.comtiny/diss?diss_id=1138337852&query=卖场音乐:每次进店都有种要上T台的感觉!&diss_name=卖场音乐:每次进店都有种要上T台的感觉! url = "http://mp3.sogou.com" + url; WebClient wc = new WebClient(); byte[] pageSourceBytes = wc.DownloadData(new Uri(url)); string source = Encoding.GetEncoding("GBK").GetString(pageSourceBytes); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(source); HtmlNodeCollection listNodes = doc.DocumentNode.SelectSingleNode("//ul[@id='music_list']").SelectNodes("li"); foreach (HtmlNode node in listNodes) { var param = node.Attributes["param"].Value.Trim(); var parts = param.Replace("[", "").Replace("]", "").Replace("#", "").Split(','); var music = new Music(); music.ID = Tools.SafeInt(parts[6]); music.Name = parts[3]; music.Author = parts[5]; music.Remark = parts[7]; music.Cover = "http://imgcache.qq.com/music/photo/album_300/" + parts[6].Substring(parts[6].Length - 2) + "/300_albumpic_" + music.ID + "_0.jpg"; music.FileUrl = parts[2]; list.Add(music); } result.result = true; result.message = new { currpage = 1, records = listNodes.Count, totalpage = 1, list = list }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Music_SearchMenuList:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public ActionResult Recommend() { try { var UserNumber = ZNRequest.GetString("UserNumber"); var ArticleNumber = ZNRequest.GetString("ArticleNumber"); var ArticlePower = ZNRequest.GetInt("ArticlePower"); if (string.IsNullOrWhiteSpace(UserNumber) || string.IsNullOrWhiteSpace(ArticleNumber)) { return(Json(new { result = false, message = "参数异常" }, JsonRequestBehavior.AllowGet)); } //判断文章权限,公开的才可以投稿 var article = db.Single <Article>(x => x.Number == ArticleNumber); if (article == null) { return(Json(new { result = false, message = "文章信息异常" }, JsonRequestBehavior.AllowGet)); } if (article.TypeID == 0) { return(Json(new { result = false, message = "请选择文章分类" }, JsonRequestBehavior.AllowGet)); } if (article.ArticlePower != Enum_ArticlePower.Public) { if (ArticlePower != Enum_ArticlePower.Public) { return(Json(new { result = false, message = "公开文章才可以投稿哦" }, JsonRequestBehavior.AllowGet)); } } var time = DateTime.Now.AddDays(-1); var log = db.Single <ArticleRecommend>(x => x.CreateUserNumber == UserNumber && x.ArticleNumber == ArticleNumber && x.CreateDate > time); if (log != null) { return(Json(new { result = false, message = "每天只有1次投稿机会,上次投稿时间为:" + log.CreateDate.ToString("yyyy-MM-dd hh:mm:ss") }, JsonRequestBehavior.AllowGet)); } //修改文章投稿记录 var result = new SubSonic.Query.Update <Article>(provider).Set("Submission").EqualTo(Enum_Submission.Audit).Set("ArticlePower").EqualTo(Enum_ArticlePower.Public).Where <Article>(x => x.ID == article.ID).Execute() > 0; ArticleRecommend model = new ArticleRecommend(); model.ArticleNumber = ArticleNumber; model.CreateUserNumber = UserNumber; model.CreateDate = DateTime.Now; model.CreateIP = Tools.GetClientIP; model.Status = Enum_Status.Audit; result = Tools.SafeInt(db.Add <ArticleRecommend>(model)) > 0; if (result) { return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { LogHelper.ErrorLoger.Error("ArticleController_Recommend:" + ex.Message); } return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet)); }
public string Edit() { ApiResult result = new ApiResult(); try { User user = GetUserInfo(); if (user == null) { result.message = EnumBase.GetDescription(typeof(Enum_ErrorCode), Enum_ErrorCode.UnLogin); result.code = Enum_ErrorCode.UnLogin; return(JsonConvert.SerializeObject(result)); } var ToUserNumber = ZNRequest.GetString("ToUserNumber"); if (string.IsNullOrWhiteSpace(ToUserNumber)) { result.message = "参数异常"; return(JsonConvert.SerializeObject(result)); } var exist = db.Exists <Black>(x => x.CreateUserNumber == user.Number && x.ToUserNumber == ToUserNumber); if (exist) { user.Follows = db.Find <Fan>(x => x.CreateUserNumber == user.Number).Count; result.result = true; result.message = user.Follows; } Black model = new Black(); model.ToUserNumber = ToUserNumber; model.CreateDate = DateTime.Now; model.CreateUserNumber = user.Number; model.CreateIP = Tools.GetClientIP; var success = Tools.SafeInt(db.Add <Black>(model)) > 0; if (success) { //取消关注 var fan = db.Single <Fan>(x => x.CreateUserNumber == user.Number && x.ToUserNumber == ToUserNumber); if (fan != null) { db.Delete <Fan>(fan.ID); } user.Follows = db.Find <Fan>(x => x.CreateUserNumber == user.Number).Count; result.result = true; result.message = user.Follows; } } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Black_Edit:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string All() { ApiResult result = new ApiResult(); try { var CreateUserNumber = ZNRequest.GetString("CreateUserNumber"); if (string.IsNullOrWhiteSpace(CreateUserNumber)) { result.message = "参数异常"; return(JsonConvert.SerializeObject(result)); } var pager = new Pager(); var query = new SubSonic.Query.Select(provider).From <Black>().Where <Black>(x => x.CreateUserNumber == CreateUserNumber); var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.message = new { records = recordCount, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var list = query.OrderDesc("ID").ExecuteTypedList <Black>(); var array = list.Select(x => x.ToUserNumber).ToArray(); var users = new SubSonic.Query.Select(provider, "ID", "NickName", "Avatar", "Signature", "Number", "Cover").From <User>().Where("Number").In(array).ExecuteTypedList <User>(); var newlist = (from b in list join u in users on b.ToUserNumber equals u.Number select new BlackJson { ID = b.ID, CreateDate = b.CreateDate.ToString("yyyy-MM-dd"), UserID = u.ID, Number = u.Number, NickName = u.NickName, Avatar = u.Avatar, Signature = u.Signature, Cover = u.Cover }).ToList(); result.result = true; result.message = new { currpage = 1, records = newlist.Count, totalpage = 1, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Black_All:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string Search() { ApiResult result = new ApiResult(); try { var pager = new Pager(); var query = new SubSonic.Query.Select(provider).From <Article>().Where <Article>(x => x.Status == Enum_Status.Approved && x.ArticlePower == Enum_ArticlePower.Public && x.Submission >= Enum_Submission.Approved); var title = SqlFilter(ZNRequest.GetString("Title")); if (!string.IsNullOrWhiteSpace(title)) { query.And("Title").IsNotNull().And("Title").Like("%" + title + "%"); } var UserNumber = ZNRequest.GetString("UserNumber"); if (!string.IsNullOrWhiteSpace(UserNumber)) { var black = db.Find <Black>(x => x.CreateUserNumber == UserNumber); if (black.Count > 0) { var userids = black.Select(x => x.ToUserNumber).ToArray(); query = query.And("CreateUserNumber").NotIn(userids); } } var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.result = true; result.message = new { records = recordCount, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var list = query.Paged(pager.Index, pager.Size).OrderDesc(new string[] { "Recommend", "Views" }).ExecuteTypedList <Article>(); List <ArticleJson> newlist = ArticleListInfo(list, UserNumber); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Article_Search:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string Used() { ApiResult result = new ApiResult(); try { User user = GetUserInfo(); if (user == null) { result.message = EnumBase.GetDescription(typeof(Enum_ErrorCode), Enum_ErrorCode.UnLogin); result.code = Enum_ErrorCode.UnLogin; return(JsonConvert.SerializeObject(result)); } var number = ZNRequest.GetString("Number"); if (string.IsNullOrWhiteSpace(number)) { result.message = "参数异常"; return(JsonConvert.SerializeObject(result)); } var model = db.Single <Background>(x => x.Number == number); if (model == null) { result.message = "信息异常"; return(JsonConvert.SerializeObject(result)); } model.IsUsed = Enum_Used.Approved; var success = db.Update <Background>(model) > 0; if (success) { //取消启用 var list = db.Find <Background>(x => x.ArticleNumber == model.ArticleNumber && x.Number != model.Number && x.IsUsed == Enum_Used.Approved).ToList(); if (list.Count > 0) { list.ForEach(x => { x.IsUsed = Enum_Used.Audit; }); db.UpdateMany <Background>(list); } result.result = true; result.message = model.Number; } } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Background_Edit" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string Article() { ApiResult result = new ApiResult(); try { var UserNumber = ZNRequest.GetString("UserNumber"); if (string.IsNullOrWhiteSpace(UserNumber)) { result.message = "参数异常"; return(JsonConvert.SerializeObject(result)); } var fans = db.Find <Fan>(x => x.CreateUserNumber == UserNumber).ToList(); if (fans.Count == 0) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var pager = new Pager(); var query = new SubSonic.Query.Select(provider).From <Article>().Where <Article>(x => x.Status == Enum_Status.Approved); query = query.And("ArticlePower").In(new int[] { Enum_ArticlePower.Public, Enum_ArticlePower.Password }); query.And("CreateUserNumber").In(fans.Select(x => x.ToUserNumber).ToArray()); var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.message = new { records = recordCount, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var list = query.Paged(pager.Index, pager.Size).OrderDesc(new string[] { "ID" }).ExecuteTypedList <Article>(); List <ArticleJson> newlist = ArticleListInfo(list, UserNumber); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Fan_Article:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string Apply_1_3() { ApiResult result = new ApiResult(); try { var UserNumber = ZNRequest.GetString("UserNumber"); if (string.IsNullOrWhiteSpace(UserNumber)) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var query = new SubSonic.Query.Select(provider).From <ApplyMoney>().Where <ApplyMoney>(x => x.Status == Enum_Status.Approved); query = query.And("CreateUserNumber").IsEqualTo(UserNumber); var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var pager = new Pager(); var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var list = query.Paged(pager.Index, pager.Size).OrderDesc("ID").ExecuteTypedList <ApplyMoney>(); List <OrdersJson> newlist = new List <OrdersJson>(); list.ForEach(x => { OrdersJson model = new OrdersJson(); model.ID = x.ID; model.CreateDate = x.CreateDate.ToString("yyyy-MM-dd hh:mm:ss"); model.Price = Tools.SafeInt(System.Configuration.ConfigurationManager.AppSettings["applymoney"]) * 100; newlist.Add(model); }); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Order_Apply_1_3:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string Edit() { ApiResult result = new ApiResult(); try { User user = GetUserInfo(); if (user == null) { result.message = EnumBase.GetDescription(typeof(Enum_ErrorCode), Enum_ErrorCode.UnLogin); result.code = Enum_ErrorCode.UnLogin; return(JsonConvert.SerializeObject(result)); } var number = ZNRequest.GetString("ArticleNumber"); var url = ZNRequest.GetString("ShowyUrl"); if (string.IsNullOrWhiteSpace(number)) { result.message = "参数异常"; return(JsonConvert.SerializeObject(result)); } ArticleCustom model = db.Single <ArticleCustom>(x => x.ArticleNumber == number); if (model == null) { model = new ArticleCustom(); model.ArticleNumber = number; } model.ShowyUrl = url; var success = false; if (model.ID == 0) { success = Tools.SafeInt(db.Add <ArticleCustom>(model)) > 0; } else { success = db.Update <ArticleCustom>(model) > 0; } if (success) { result.result = true; result.message = "success"; } } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_ArticleCustom_Edit" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
/// <summary> /// 支付宝支付 /// </summary> public ActionResult AliPay() { var result = new ResultJson(); bool verifyResult = false; string strResult = ""; SortedDictionary <string, string> sArray = new SortedDictionary <string, string>(); Notify aliNotify = new Notify(); verifyResult = aliNotify.Verify(sArray, ZNRequest.GetString("notify_id"), ZNRequest.GetString("sign")); foreach (KeyValuePair <string, string> kvp in sArray) { strResult += kvp.Key; strResult += ":"; strResult += kvp.Value; strResult += "\r\n"; } //记录文本日志 //LogHelper.InfoLoger.Info("NotifyController_AliPay:" + "支付通知参数:" + strResult); if (verifyResult && !string.IsNullOrWhiteSpace(strResult)) { //商户订单号 string oid = sArray["out_trade_no"]; //支付宝交易号 string trade_no = sArray["trade_no"]; //商品名称 var subject = sArray["subject"]; //支付价格 var price = sArray["price"]; //交易状态 string trade_status = sArray["trade_status"]; var order = db.Single <Order>(x => x.OrderNumber == oid); if (trade_status == "TRADE_FINISHED" && order != null) { //更新订单状态 order.Status = Enum_Status.Approved; db.Update <Order>(order); } } return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 清除推送信息 /// </summary> public ActionResult Clear() { var number = ZNRequest.GetString("number"); var pushtype = ZNRequest.GetInt("pushtype"); if (string.IsNullOrWhiteSpace(number)) { return(Json(false, JsonRequestBehavior.AllowGet)); } var list = new List <PushLog>(); list = logdb.Find <PushLog>(x => x.PushType == pushtype && x.Number == number).ToList(); logdb.DeleteMany <PushLog>(list); return(Json(true, JsonRequestBehavior.AllowGet)); }
public string TemporaryUser() { ApiResult result = new ApiResult(); try { var number = ZNRequest.GetString("Number"); if (string.IsNullOrWhiteSpace(number)) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var list = db.Find <User>(x => x.RelatedNumber == number).OrderBy(x => x.UserRole).ThenBy(x => x.ID).ToList(); var pager = new Pager(); var recordCount = list.Count; if (recordCount == 0) { result.message = new { records = 0, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var newlist = (from l in list select new { ID = l.ID, NickName = l.NickName, Signature = l.Signature, Avatar = l.Avatar, Cover = l.Cover, Number = l.Number, CreateDate = l.CreateDate.ToString("yyyy-MM-dd") }).ToList(); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_User_TemporaryUser" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
/// <summary> /// 管理员打赏红包 /// </summary> public ActionResult AdminRed() { try { var number = ZNRequest.GetString("number"); if (string.IsNullOrWhiteSpace(number)) { return(Json(new { result = false, message = "参数异常" }, JsonRequestBehavior.AllowGet)); } var exist = db.Find <Red>(x => x.ToUserNumber == number && x.RedType == Enum_RedType.Admin).ToList().Exists(x => x.CreateDate.ToString("yyyyMMdd") == DateTime.Now.ToString("yyyyMMdd")); if (exist) { return(Json(new { result = false, message = "今日已打赏红包" }, JsonRequestBehavior.AllowGet)); } var model = new Red(); model.ToUserNumber = number; model.Price = ZNRequest.GetInt("price"); if (model.Price <= 0 || model.Price > 500) { model.Price = new Random().Next(10, 500); if (model.Price <= 0) { model.Price = 10; } if (model.Price > 500) { model.Price = 500; } } model.Status = Enum_Red.Audit; model.Number = Guid.NewGuid().ToString("N"); model.RedType = Enum_RedType.Admin; model.CreateDate = DateTime.Now; db.Add <Red>(model); //推送消息 new AppHelper().Push(model.ToUserNumber, 0, "", "", Enum_PushType.Red); //用户新增红包 return(Json(new { result = true, message = model.Price }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { LogHelper.ErrorLoger.Error("Red_AdminRed:" + ex.Message); return(Json(new { result = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public string Import() { ApiResult result = new ApiResult(); try { User user = GetUserInfo(); if (user == null) { result.message = EnumBase.GetDescription(typeof(Enum_ErrorCode), Enum_ErrorCode.UnLogin); result.code = Enum_ErrorCode.UnLogin; return(JsonConvert.SerializeObject(result)); } var urls = ZNRequest.GetString("Url"); var number = ZNRequest.GetString("ArticleNumber"); if (string.IsNullOrWhiteSpace(urls)) { result.message = "信息异常"; return(JsonConvert.SerializeObject(result)); } var list = new List <ArticlePartJson>(); var url = urls.Split(',').ToList(); url.ForEach(x => { var model = new ArticlePart(); model.Introduction = x; model.IntroExpand = string.Empty; model.ArticleNumber = number; model.Types = Enum_ArticlePart.Pic; model.CreateUserNumber = user.Number; model.CreateIP = Tools.GetClientIP; model.CreateDate = DateTime.Now; model.Status = Enum_Status.Audit; model.SortID = 0; var id = Tools.SafeInt(db.Add <ArticlePart>(model)); list.Add(new ArticlePartJson(id, x)); }); result.result = true; result.message = list; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_ArticlePart_Import" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
public string All() { ApiResult result = new ApiResult(); try { var CreateUserNumber = ZNRequest.GetString("CreateUserNumber"); if (string.IsNullOrWhiteSpace(CreateUserNumber)) { result.message = "参数异常"; return(JsonConvert.SerializeObject(result)); } var CurrUserNumber = ZNRequest.GetString("CurrUserNumber"); if (string.IsNullOrWhiteSpace(CurrUserNumber)) { CurrUserNumber = CreateUserNumber; } var pager = new Pager(); var query = new SubSonic.Query.Select(provider).From <Keep>().Where <Keep>(x => x.CreateUserNumber == CreateUserNumber); var recordCount = query.GetRecordCount(); if (recordCount == 0) { result.message = new { records = recordCount, totalpage = 1 }; return(JsonConvert.SerializeObject(result)); } var totalPage = recordCount % pager.Size == 0 ? recordCount / pager.Size : recordCount / pager.Size + 1; var list = query.Paged(pager.Index, pager.Size).OrderDesc("ID").ExecuteTypedList <Keep>(); var articles = new SubSonic.Query.Select(provider, "ID", "Number", "Title", "TypeID", "Cover", "Views", "Goods", "CreateUserNumber", "CreateDate", "ArticlePower", "ArticlePowerPwd", "Recommend", "City", "Province", "Submission").From <Article>().Where("Number").In(list.Select(x => x.ArticleNumber).ToArray()).And("Status").IsNotEqualTo(Enum_Status.Audit).OrderDesc(new string[] { "Recommend", "ID" }).ExecuteTypedList <Article>(); List <ArticleJson> newlist = ArticleListInfo(articles, CurrUserNumber); result.result = true; result.message = new { currpage = pager.Index, records = recordCount, totalpage = totalPage, list = newlist }; } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Keep_All:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }
/// <summary> /// 登陆红包 /// </summary> public ActionResult LoginRed() { try { var number = ZNRequest.GetString("number"); if (string.IsNullOrWhiteSpace(number)) { return(Json(new { result = false, message = "参数异常" }, JsonRequestBehavior.AllowGet)); } var model = db.Single <Red>(x => x.ToUserNumber == number && x.RedType == Enum_RedType.Login); if (model != null) { if (model.Status == Enum_Red.Approved) { return(Json(new { result = false, message = "已领取红包" }, JsonRequestBehavior.AllowGet)); } } if (model == null) { model = new Red(); model.ToUserNumber = number; model.Price = new Random().Next(10, 500); if (model.Price <= 0) { model.Price = 10; } if (model.Price > 500) { model.Price = 500; } model.Status = Enum_Red.Audit; model.Number = Guid.NewGuid().ToString("N"); model.RedType = Enum_RedType.Login; model.CreateDate = DateTime.Now; db.Add <Red>(model); } //用户新增红包 return(Json(new { result = true, message = model.Price, number = model.Number }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { LogHelper.ErrorLoger.Error("Red_LoginRed:" + ex.Message); return(Json(new { result = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 文章恢复 /// </summary> public ActionResult Revoke() { try { var ArticleNumber = ZNRequest.GetString("ArticleNumber"); var result = new SubSonic.Query.Update <Article>(provider).Set("Status").EqualTo(Enum_Status.Approved).Set("UpdateDate").EqualTo(DateTime.Now).Where <Article>(x => x.Number == ArticleNumber).Execute() > 0; if (result) { return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { LogHelper.ErrorLoger.Error("Article_Revoke:" + ex.Message); } return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 获取推送信息 /// </summary> public ActionResult All() { var number = ZNRequest.GetString("number"); if (string.IsNullOrWhiteSpace(number)) { return(Json(new { result = false, message = "" }, JsonRequestBehavior.AllowGet)); } var list = logdb.Find <PushLog>(x => x.Number == number).GroupBy(x => x.PushType).ToList(); var newlist = (from l in list select new { PushType = l.Key, PushCount = l.Count() }).ToList(); return(Json(new { result = true, message = newlist }, JsonRequestBehavior.AllowGet)); }
public ActionResult EditBackground() { try { var ArticleID = ZNRequest.GetInt("ArticleID"); var background = ZNRequest.GetString("Background"); var result = new SubSonic.Query.Update <Article>(provider).Set("Background").EqualTo(background).Where <Article>(x => x.ID == ArticleID).Execute() > 0; if (result) { return(Json(new { result = true, message = "成功" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { LogHelper.ErrorLoger.Error("ArticleController_EditBackground:" + ex.Message); } return(Json(new { result = false, message = "失败" }, JsonRequestBehavior.AllowGet)); }
public string Delete() { ApiResult result = new ApiResult(); try { User user = GetUserInfo(); if (user == null) { result.message = EnumBase.GetDescription(typeof(Enum_ErrorCode), Enum_ErrorCode.UnLogin); result.code = Enum_ErrorCode.UnLogin; return(JsonConvert.SerializeObject(result)); } var number = ZNRequest.GetString("Number"); var model = db.Single <Background>(x => x.Number == number); if (model == null) { result.message = "背景信息验证失败"; return(JsonConvert.SerializeObject(result)); } if (model.CreateUserNumber != user.Number) { result.code = Enum_ErrorCode.NoPower; result.message = "没有权限"; return(JsonConvert.SerializeObject(result)); } var success = db.Delete <Background>(model.ID) > 0; if (success) { result.result = true; result.message = model; } else { result.message = "删除失败"; } } catch (Exception ex) { LogHelper.ErrorLoger.Error("Api_Background_Delete:" + ex.Message); result.message = ex.Message; } return(JsonConvert.SerializeObject(result)); }