public ActionResult Edit(long id, string title, string desc, string contact, string wechat) { ResultInfo ri = new ResultInfo(); if (id > 0) { var adcache = (List <AD>)CSharpCacheHelper.Get(APPConst.AD); var model = adcache.First(a => { return(a.ADID == id); }); if (model == null) { ri.Msg = "广告信息不存在!"; } else if (model.IsDelete == 0) { model.ADTitle = title; model.ADMsg = desc; model.ADContact = contact; model.ADWeChat = wechat; ri = ADBLL.Instance.Update(model); } else { ri.Msg = "广告已被删除"; } adcache.Remove(adcache.First(a => { return(a.ADID == model.ADID); })); adcache.Add(model); CSharpCacheHelper.Set(APPConst.AD, adcache, APPConst.ExpriseTime.Day2); } else { ri.Msg = "异常"; } return(Result(ri)); }
public ActionResult Info(long id) { ResultInfo ri = new ResultInfo(); if (id > 0) { var adcache = (List <AD>)CSharpCacheHelper.Get(APPConst.AD); var model = adcache.First(a => { return(a.ADID == id); }); if (model == null) { ri.Msg = "广告信息不存在!"; } else if (model.IsDelete == 0) { ri.Ok = true; ri.Data = new { title = model.ADTitle, desc = model.ADMsg, contact = model.ADContact, wechat = model.ADWeChat }; } else { ri.Msg = "广告已被删除"; } } else { ri.Msg = "异常"; } return(Result(ri)); }
public List <ClickMsg> FindALL(int isdelete = -1) { List <ClickMsg> list; var objs = CSharpCacheHelper.Get(APPConst.ClickMsgs); if (objs == null) { list = ModelConvertHelper <ClickMsg> .ConvertToList(dal.FindALL()); CSharpCacheHelper.Set(APPConst.ClickMsgs, list, APPConst.ExpriseTime.Week1); } else { list = (List <ClickMsg>)objs; } if (isdelete == -1) { return(list); } else if (isdelete == 0) { return(list.Where(a => { return a.IsDelete == 0; }).ToList()); } else { return(list.Where(a => { return a.IsDelete == 1; }).ToList()); } }
public void Add_ClickMsg(ClickMsg model) { var list = ClickMsgBLL.Instance.FindALL(); list.Add(model); CSharpCacheHelper.Set(APPConst.ClickMsgs, list, APPConst.ExpriseTime.Week1); }
/// <summary> /// 获取网站所有客服 /// </summary> /// <returns></returns> public CustomerVM GetCustomers() { var list = new CustomerVM(); var cache = CSharpCacheHelper.Get(APPConst.Customoer); if (cache == null) { var type1 = CustomerEnumType.QQ.GetHashCode(); var type2 = CustomerEnumType.WeChar.GetHashCode(); var type3 = CustomerEnumType.WeChar_GZH.GetHashCode(); var dt = dal.GetCustomers(); var request = ModelConvertHelper <Customer> .ConvertToList(dt).OrderByDescending(a => a.CreateTime).ToList(); list.QQs = request.Where(a => a.Type == type1).ToList(); list.WXs = request.Where(a => a.Type == type2).ToList(); list.GZHs = request.Where(a => a.Type == type3).ToList(); CSharpCacheHelper.Set(APPConst.Customoer, list, APPConst.ExpriseTime.Week1); return(list); } else { return((CustomerVM)cache); } }
public void Update_ClickMsg(ClickMsg model) { var list = ClickMsgBLL.Instance.FindALL(); var newlist = list.Where(a => { return(a.ClickMsgId != model.ClickMsgId); }).ToList(); newlist.Add(model); CSharpCacheHelper.Set(APPConst.ClickMsgs, newlist, APPConst.ExpriseTime.Week1); }
public int Get_NewShowCount() { var val = CSharpCacheHelper.Get(APPConst.NewShowCount); if (val == null) { var config = ConfigHelper.AppSettings(APPConst.NewShowCount).ToInt32(); Set_NewShowCount(config); return(config); } else { return(Convert.ToInt32(val)); } }
public int Get_TagRandomNumber() { var val = CSharpCacheHelper.Get(APPConst.TagRandomNumber); if (val == null) { var config = ConfigHelper.AppSettings(APPConst.TagRandomNumber).ToInt32(); Set_TagRandomNumber(config); return(config); } else { return(Convert.ToInt32(val)); } }
public List <Slide> GetALLSlider() { var sliders = CSharpCacheHelper.Get(APPConst.Slider); if (sliders == null) { var list = FindALL(); CSharpCacheHelper.Set(APPConst.Slider, list, APPConst.ExpriseTime.Day2); return(list); } else { return((List <Slide>)sliders); } }
/// <summary> /// 获取用户皮肤设置(缓存) /// </summary> /// <returns></returns> public string GetUserSkin(long userid) { string key = "skin-{0}".FormatWith(userid); object skin = CSharpCacheHelper.Get(key); if (skin == null) { string skin_ = UserExtBLL.Instance.GetExtInfo(userid).UserCenterSkin; if (skin_.IsNullOrEmpty()) { skin_ = "skin-default"; } CSharpCacheHelper.Set(key, skin_, 240); return(skin_); } return(skin.ToString()); //return "skin-default"; }
/// <summary> /// 按类目查询所有条目 /// </summary> /// <param name="enumType">类型</param> /// <param name="sort">是否排序</param> /// <returns></returns> public List <BBSEnum> Query(int enumType, bool sort = false) { string key = "MenuCache_{0}".FormatWith(enumType); //缓存设置 var cachevalue = CSharpCacheHelper.Get(key); if (cachevalue == null) { DataTable dt = dal.Query(enumType, sort); var list = ModelConvertHelper <BBSEnum> .ConvertToList(dt); CSharpCacheHelper.Set(key, list, 120); return(list.OrderBy(a => a.SortIndex).ToList()); } else { return((cachevalue as List <BBSEnum>).OrderBy(a => a.SortIndex).ToList()); } }
public List <AD> GetALLAD(int count = 0) { List <AD> list = null; object ads = CSharpCacheHelper.Get(APPConst.AD); if (ads == null) { list = SearchAll(); CSharpCacheHelper.Set(APPConst.AD, list, APPConst.ExpriseTime.Day2); return(count > 0 ? list.Take(count).ToList() : list); } if (count > 0) { return(((List <AD>)ads).OrderByDescending(a => a.CreateTime).Take(count).ToList()); } else { return((List <AD>)ads); } }
//private string CreateOrder(decimal fee, long id, int type, string desc, string seq, int count, SqlTransaction tran, out int result, out string payorderid) //{ // result = 0; // string msg = string.Empty; // var bll = BXTOrderBLL.Instance; // var now = DateTime.Now; // payorderid = seq + id.ToString() + now.ToString("yyyyMMddHHmmssfff") + type.ToString(); // BXTOrder order = new BXTOrder() // { // Fee = fee * count,//计算总费用 // CreateTime = now, // CreateUser = UserID.ToString(), // IsDelete = 0, // IsPay = 0, // ItemID = id, // OrderType = type, // OrerDesc = desc, // PayOrderID = payorderid, // BuyCount = count, // }; // if ((result = bll.Add(order, tran)) <= 0) // { // msg = "创建订单时失败,请重试!"; // } // return msg; //} #endregion #region 公用订单删除 //private void OrderDelete(int primaryId) //{ // var bll = BXTOrderBLL.Instance; // BXTOrder model = bll.GetModel(primaryId); // if (model != null) // { // model.IsDelete = 1; // bll.Update(model); // } //} #endregion #endregion #region 更新用户购买情况 //public string UpdateBuyInfo() //{ // var giftTypeList = new[] { 2, 4, 8 }.ToList(); // List<object> errorList = new List<object>(); // var bxtOrders = DB.BXTOrder.OrderBy(x => x.CreateTime).ToList(); // foreach (var bxtOrder in bxtOrders) // { // var tradeNo = bxtOrder.PayOrderID; // var payResult = TradeQuery("9812hrhy9/.~oijo", tradeNo); // if (payResult.TradeStatus == "TRADE_SUCCESS" // || payResult.TradeStatus == "TRADE_FINISHED") // { // var orderType = bxtOrder.OrderType; // if (!orderType.HasValue) // { // errorList.Add(tradeNo); // continue; // } // if (!giftTypeList.Contains(orderType.Value)) // { // errorList.Add(tradeNo); // continue; // } // var buyerUserId = bxtOrder.CreateUser.ToInt64(); // var payCbLog = // DB.PayCBLog.FirstOrDefault(x => x.TradeNo == tradeNo); // var userGifts = DB.UserGift // .Where(x => x.BuyUserID == buyerUserId) // .ToList() // .OrderBy(x => x.BuyTime) // .ToList(); // var userGift = // userGifts.FirstOrDefault(x => // x.BuyTime.Value.ToString("yyyy-MM-dd HH") // == bxtOrder.CreateTime.Value.ToString("yyyy-MM-dd HH")); // if (userGift == null) // { // errorList.Add(tradeNo); // continue; // } // var userGiftTime = userGift.BuyTime; // var bxtOrderTime = bxtOrder.CreateTime; // if (payCbLog == null && bxtOrder.IsPay == 0) // { // continue; // } // if (userGift.IsPay == 1 && payCbLog.IsPay == 1) // { // continue; // } // if (payCbLog.IsPay != 1) // { // payCbLog.IsPay = 1; // } // if (userGift.IsPay != 1) // { // userGift.IsPay = 1; // } // } // else // { // errorList.Add(new // { // tradeNo, // payResult = new // { // payResult.SubMsg, // payResult.SubCode, // payResult.TradeStatus, // payResult.TradeNo // } // }); // } // } // DB.SaveChanges(); // return JsonHelper.ToJson(errorList); //} #endregion #region 支付宝交易查询 ///// <summary> ///// 支付宝交易查询 ///// </summary> ///// <param name="tradeNo"></param> ///// <param name="outTradeNo"></param> ///// <returns></returns> //public AlipayTradeQueryResponse TradeQuery(string key, string outTradeNo, string tradeNo = null) //{ // if (key != "9812hrhy9/.~oijo") return null; // DefaultAopClient client = new DefaultAopClient(AliPayConfig.gatewayUrl, AliPayConfig.app_id, AliPayConfig.private_key, "json", "1.0", AliPayConfig.sign_type, AliPayConfig.alipay_public_key, AliPayConfig.charset, false); // AlipayTradeQueryModel alipayTradeQueryModel = new AlipayTradeQueryModel(); // alipayTradeQueryModel.OutTradeNo = outTradeNo; // alipayTradeQueryModel.TradeNo = tradeNo; // AlipayTradeQueryRequest request = new AlipayTradeQueryRequest(); // request.SetBizModel(alipayTradeQueryModel); // AlipayTradeQueryResponse response = null; // try // { // response = client.Execute(request); // } // catch (Exception e) // { // } // AlipayTradeFastpayRefundQueryModel alipayTradeFastpayRefundQueryModel = new AlipayTradeFastpayRefundQueryModel(); // alipayTradeFastpayRefundQueryModel.OutTradeNo = outTradeNo; // alipayTradeFastpayRefundQueryModel.OutRequestNo = outTradeNo; // AlipayTradeFastpayRefundQueryRequest alipayTradeFastpayRefundQueryRequest = new AlipayTradeFastpayRefundQueryRequest(); // alipayTradeFastpayRefundQueryRequest.SetBizModel(alipayTradeFastpayRefundQueryModel); // var refundQueryResponse = client.Execute(alipayTradeFastpayRefundQueryRequest); // return response; // //return JsonHelper.ToJson(new // //{ // // api = "交易信息查询", // // status = response.TradeStatus == "TRADE_SUCCESS" ? "支付成功" : response.TradeStatus, // // response.TradeStatus, // // response.BuyerPayAmount, // // response, // // refundQueryResponse, // //}); //} #endregion #region 更新通知 public void UpdateNotice() { var notices = DB.Notice.ToList(); CSharpCacheHelper.Set("notices", notices); var payCbLogs = DB.PayCBLog.OrderByDescending(x => x.CallBackTime).ToList(); foreach (var payCbLog in payCbLogs) { var body = //"{\"gmt_create" + "gmt_create" + payCbLog.Memo .Replace("\r\n", "") .Split(new string[] { "两者签名一致" }, StringSplitOptions.RemoveEmptyEntries)[0] .Split(new[] { "开始获取参数组:" }, StringSplitOptions.RemoveEmptyEntries)[0] .Split(new[] { "gmt_create" }, StringSplitOptions.RemoveEmptyEntries)[0] .Replace("{\"", ""); AliPayNotify(body); Thread.Sleep(10 * 1000); } }
/// <summary> /// 判断用户是否为VIP标签 /// </summary> /// <param name="userid"></param> /// <returns></returns> public bool IsVIP(long userid) { string key = "isVip_" + userid; object value = CSharpCacheHelper.Get(key); if (value == null) { var ext = UserExtBLL.Instance.GetExtInfo(userid); if (ext != null) { CSharpCacheHelper.Set(key, ext.VIP > 0, APPConst.ExpriseTime.Week1); return(ext.VIP > 0); } else { return(false); } } else { return((bool)value); } }
public ActionResult ADPV(long id, int number) { ResultInfo ri = new ResultInfo(); if (id > 0) { if (number > -1) { var adcache = (List <AD>)CSharpCacheHelper.Get(APPConst.AD); var model = adcache.First(a => { return(a.ADID == id); }); if (model.IsDelete == 0) { model.ADViewCount = number; ADBLL.Instance.Update(model); ri.Ok = true; ri.Data = new { title = model.ADTitle, contact = model.ADContact, wechat = model.ADWeChat }; adcache.Remove(adcache.First(a => { return(a.ADID == id); })); adcache.Add(model); CSharpCacheHelper.Set(APPConst.AD, adcache, APPConst.ExpriseTime.Day2); } } else { ri.Msg = "浏览量咋能为负呢?"; } } else { ri.Msg = "数据源异常"; } return(Result(ri)); }
public ActionResult Delete(long id) { ResultInfo ri = new ResultInfo(); if (id > 0) { var adcache = (List <AD>)CSharpCacheHelper.Get(APPConst.AD); var model = adcache.First(a => { return(a.ADID == id); }); if (model != null) { if (model.IsDelete == 0) { model.IsDelete = 1; ri = ADBLL.Instance.Update(model); if (ri.Ok) { adcache.Remove(adcache.First(a => { return(a.ADID == id); })); adcache.Add(model); CSharpCacheHelper.Set(APPConst.AD, adcache, APPConst.ExpriseTime.Day2); } } else { ri.Msg = "广告已被删除"; } } else { ri.Msg = "广告信息不存在"; } } else { ri.Msg = "异常"; } return(Result(ri)); }
public ActionResult AddPV(long id) { ResultInfo ri = new ResultInfo(); var adcache = (List <AD>)CSharpCacheHelper.Get(APPConst.AD); var model = adcache.First(a => { return(a.ADID == id); }); if (model.IsDelete == 0) { model.ADViewCount += 1; ADBLL.Instance.Update(model); ri.Ok = true; //ri.Data = model; ri.Data = new { title = model.ADTitle, contact = model.ADContact, wechat = model.ADWeChat }; adcache.Remove(adcache.First(a => { return(a.ADID == id); })); adcache.Add(model); CSharpCacheHelper.Set(APPConst.AD, adcache, APPConst.ExpriseTime.Day2); } return(Result(ri)); }
public void Set_TagRandomNumber(int number) { CSharpCacheHelper.Set(APPConst.TagRandomNumber, number, APPConst.ExpriseTime.Month1); }
public void Set_NewShowCount(int number) { CSharpCacheHelper.Set(APPConst.NewShowCount, number, APPConst.ExpriseTime.Month1); }
public void Delete_ClickMsg(ClickMsg model) { var list = ClickMsgBLL.Instance.FindALL(); CSharpCacheHelper.Set(APPConst.ClickMsgs, list.Where(a => { return(a.ClickMsgId == model.ClickMsgId); }).ToList(), APPConst.ExpriseTime.Week1); }
/// <summary> /// 下载附件 /// </summary> /// <param name="mt">类型 1 帖子附件下载 2 文章附件下载</param> /// <param name="md">主ID 如帖子的ID 10000</param> /// <param name="ad">附件ID</param> /// <returns></returns> public ActionResult Index(int mt, long md, Guid ad) { var canDown = false; string fileName = string.Empty; string filepath = string.Empty; if (mt > 0 && md > 0 && ad != Guid.Empty) { long authorId = 0; //判断帖子是否存在 if (mt == AttachEnumType.BBS.GetHashCode()) { var model = DB.Question.FirstOrDefault(a => a.IsDelete == 0 && a.QuestionId == md); if (model != null) { canDown = true; authorId = model.UserID.Value; } } else { var model = DB.Article.FirstOrDefault(a => a.IsDelete == 0 && a.ArticleId == md); if (model != null) { canDown = true; authorId = model.UserID.Value; } } if (canDown) { //判断附件是否存在 var attachInfo = DB.AttachMent.FirstOrDefault(a => a.AttachMentId == ad && a.MainId == md && a.MainType == mt); if (attachInfo != null) { //判断是否需要付费下载 ,作者自己可以下载 if (attachInfo.IsFee && authorId != UserID) { //判断用户是否已付费 canDown = DB.AttachMentBuyLog.FirstOrDefault(a => a.AttachMentId == ad && a.BuyerId == UserID && a.MainID == md) != null; //如果用户没有付费,则先付费,后下载 if (!canDown) { //开启事务 var tran = DB.Database.BeginTransaction(); try { //扣除下载费用并记录 var result = _scoreService.HasEnoughCoinAndSubCoin(attachInfo.FeeType == 10 ? 1 : 2, attachInfo.Fee, UserID, CoinSourceEnum.DownAttachMent); if (result.Item1) { canDown = true; //记录购买附件 DB.AttachMentBuyLog.Add(new AttachMentBuyLog() { AttachMentId = ad, BuyerId = UserID, CreateTime = DateTime.Now, MainID = md, MainType = mt }); //给作者增加 积分 _scoreService.AddScoreOrCoin(authorId, attachInfo.FeeType == 10 ? 1 : 2, attachInfo.Fee, CoinSourceEnum.UserDownAttachMent); DB.SaveChanges(); tran.Commit(); } else { tran.Rollback(); return(Content(result.Item2)); } } catch (Exception e) { tran.Rollback(); canDown = false; return(Content("下载出错,请重试!")); } } } if (canDown) { fileName = attachInfo.FileName; filepath = attachInfo.FilePath; //1天内重复下载不计次数 string key = $"down_{attachInfo.AttachMentId}_{UserID}"; var cache = CSharpCacheHelper.Get <bool>(key, false); if (!cache) { CSharpCacheHelper.Set(key, true, APPConst.ExpriseTime.Day1); attachInfo.DownCount++; DB.SaveChanges(); } } } } } if (canDown) { return(File(new FileStream(Server.MapPath(filepath), FileMode.Open), "text/plain", fileName)); } else { return(Content("你无法下载此资源!")); } }