public ActionResult Open() { string url = ""; bool isMicromessenger = StringHelper.GetUserAgent().ToLower().Contains("micromessenger"); int payType = 0; string pt = UrlParameterHelper.GetParams("pt"); if (!string.IsNullOrEmpty(pt) && int.TryParse(pt, out payType) && payType == 13) { if (isMicromessenger) //微信支付(公众号) { url = "/user/order/paynow/open1"; } else //微信支付(手机网页) { url = "/user/order/paynow/index2"; } } else //其它支付 { url = "/user/order/paynow/index"; } return(Redirect(GetPayUrl(url, pt))); }
protected bool VerifyRedirectToken(string novelId, out int code, out Constants.Novel.ChapterDirection direction, int timeout = 0) { if (ChapterContext.IsToken) { code = 0; direction = Constants.Novel.ChapterDirection.none; string token = UrlParameterHelper.GetParams("t"); string timeStamp = UrlParameterHelper.GetParams("s"); string random = UrlParameterHelper.GetParams("r"); if (string.IsNullOrEmpty(token) || string.IsNullOrEmpty(timeStamp) || string.IsNullOrEmpty(random)) { return(false); } return(ChapterContext.VerifyRedirectToken(token, novelId, timeStamp, random, out code, out direction, timeout)); } else { code = StringHelper.ToInt(UrlParameterHelper.GetParams("chapterCode")); if (!EnumHelper.TryParsebyName <Constants.Novel.ChapterDirection>(UrlParameterHelper.GetParams("direction"), out direction)) { direction = Constants.Novel.ChapterDirection.none; } return(true); } }
private IEnumerable <AD> GetADList(int classId, int novelId, int pageSize) { string where = "and a.ClassId = @classId and a.fid <> @novelId"; string orderby = " order by a.onlinetime desc, a.sortid desc "; int adIndex = UrlParameterHelper.GetParams("dx").ToInt(); adIndex = (adIndex > 0) ? adIndex : 1; int rowCount = 0; var adList = DataContext.TryCache <IEnumerable <AD> >(string.Format("{0}{1}{2}_ChapterDetail_AD", classId, pageSize, adIndex), () => { return(_adService.GetPagerList(where, orderby, adIndex, pageSize, out rowCount, new { classId, novelId })); }, 60); rowCount = DataContext.TryCache <int>(string.Format("{0}{1}{2}_ChapterDetail_AD_RowCount", classId, pageSize, adIndex), () => { return(rowCount); }, 60); if (!adList.IsNullOrEmpty <AD>()) { ViewBag.AdIndex = (adIndex >= (int)Math.Ceiling((double)rowCount / pageSize)) ? 1 : adIndex + 1; } return(adList); }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); Code = UrlParameterHelper.GetParams("code"); State = UrlParameterHelper.GetParams("state"); ReturnUrl = UrlParameterHelper.GetDecodingParams("returnurl"); }
public ActionResult Index() { Com.WxPayAPI.Log.Info(this.GetType().ToString(), "WxPayController Index"); string wxJsApiParam = ""; ErrorMessage errorMessage = ErrorMessage.失败; int payType = 0; string orderId = ""; int money = 0; int userType = 0; if (PayContext.VerifyPayOrderInfo(1, out errorMessage, out payType, out orderId, out money, out userType)) { string host = StringHelper.GetHost(); string path = Request.Path; string queryString = Request.Url.Query; Com.WxPayAPI.JsApiPay jsApiPay = new Com.WxPayAPI.JsApiPay(host, path, queryString); string openid = UrlParameterHelper.GetParams("openid"); //检测是否给当前页面传递了相关参数 if (string.IsNullOrEmpty(openid) || money <= 0) { Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面传参出错,请返回重试" + "</span>"); Com.WxPayAPI.Log.Error(this.GetType().ToString(), "This page have not get params, cannot be inited, exit..."); return(View()); } //若传递了相关参数,则调统一下单接口,获得后续相关接口的入口参数 jsApiPay.OpenId = openid; jsApiPay.Total_Fee = money; //JSAPI支付预处理 try { string body = string.Concat(SiteSection.Html.SiteName, "-", SiteSection.Html.FeeName); Com.WxPayAPI.WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(body, orderId); wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数 Com.WxPayAPI.Log.Debug(this.GetType().ToString(), "wxJsApiParam : " + wxJsApiParam); //在页面上显示订单信息 //Response.Write("<span style='color:#00CD00;font-size:20px'>订单详情:</span><br/>"); //Response.Write("<span style='color:#00CD00;font-size:20px'>" + unifiedOrderResult.ToPrintStr() + "</span>"); } catch { Response.Write("<span style='color:#FF0000;font-size:20px'>" + "下单失败,请返回重试" + "</span>"); } } ViewData.Model = wxJsApiParam; return(View()); }
public ActionResult AllAudioPackage() { string url = ""; ErrorMessage errorMessage = ErrorMessage.失败; PackageOrderInfo model = new PackageOrderInfo(); model = GetLogInfo(model) as PackageOrderInfo; model.UserName = currentUser.UserName; model.Fee = SiteSection.Audio.AllPackageFee; model.Cash = SiteSection.Audio.AllPackageFee; model.Status = (int)Constants.Status.yes; model.OrderTime = DateTime.Now; model.AutoRenew = 0; model.Balance = 0; model.BeginTime = DateTime.Now; model.EndTime = DateTime.Now; model.FeeId = 0; model.Integral = 0; model.OrderCode = ""; model.OrderContentType = 2; model.PackageId = 0; model.PackageTitle = ""; model.PayChannel = 0; model.Rebate = 0; model.RebateExpression = ""; model.RebateFee = 0; model.CancelTime = DateTime.Now; int result = _orderService.OrderPackage(model); if (EnumHelper.TryParsebyValue <ErrorMessage>(result, out errorMessage)) { switch (errorMessage) { case ErrorMessage.成功: url = NovelId > 0 ? ChapterContext.GetUrl("/chapter/detail", NovelId, ChapterCode, channelId: RouteChannelId) : "/"; break; case ErrorMessage.余额不足: url = StringHelper.GetReturnUrl("/order/recharge", UrlParameterHelper.GetParams("returnUrl"), channelId: RouteChannelId); break; case ErrorMessage.已包月: url = ChapterContext.GetUrl("/chapter/detail", NovelId, ChapterCode, channelId: RouteChannelId); break; case ErrorMessage.用户不存在: url = DataContext.GetErrorUrl(ErrorMessage.用户不存在, channelId: RouteChannelId); break; } } return(Redirect(url)); }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); NovelId = StringHelper.ToInt(UrlParameterHelper.GetParams("novelId")); if (!VerifyRedirectToken(StringHelper.ToString(NovelId), out ChapterCode, out ChapterDirection) || NovelId <= 0 || ChapterCode < 0) { ChapterCode = 0; ChapterDirection = Constants.Novel.ChapterDirection.none; } }
public ChapterRedirectManage(int chapterRedirectTimeout = 0) { string nid = UrlParameterHelper.GetParams("novelId"); if (!string.IsNullOrEmpty(nid) && !VerifyRedirectToken(nid, out _chapterCode, out _chapterDirection, chapterRedirectTimeout) || _chapterCode < 0) { _chapterCode = 0; _chapterDirection = Constants.Novel.ChapterDirection.none; } _novelId = StringHelper.ToInt(nid); }
protected void InitializeChapterPager() { MinMaxChapterCode = UrlParameterHelper.GetParams("c"); if (!string.IsNullOrEmpty(MinMaxChapterCode) && ChapterContext.VerifyRangeToken(MinMaxChapterCode, out MinChapterCode, out MaxChapterCode, ChapterCodeRangeTimeout) && MinChapterCode >= 0 && MaxChapterCode >= MinChapterCode) { ResetChapterCode(ChapterDirection); } else { SetChapterCodeRange(); } }
private string GetReplyTextUrl(string url, out string replyText) { replyText = ""; string rp = UrlParameterHelper.GetParams("rp"); if (!string.IsNullOrEmpty(rp) && ChapterContext.VerifyReplyText(rp, out replyText)) { url = StringHelper.SpliceUrl(url, "rp", rp); } return(url); }
private string GetReplyTextUrl(string url, out string replyText) { replyText = ""; string rp = UrlParameterHelper.GetParams("rp"); if (!string.IsNullOrEmpty(rp)) { ChapterContext.VerifyReplyText(rp, out replyText); IDictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("rp", rp); url = StringHelper.SpliceUrl(url, dict); } return(url); }
/// <summary> /// 获取头信息 /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <param name="paramType"></param> /// <returns></returns> protected bool IsHeader(string name, out string value, out ParamType paramType) { value = ""; paramType = ParamType.none; if (string.IsNullOrEmpty(name)) { return(false); } try { value = StringHelper.FilterIllegalParameter(HttpContext.Request.Headers[name]); if (!string.IsNullOrEmpty(value)) { paramType = ParamType.header; } } catch { } if (string.IsNullOrEmpty(value)) { try { value = GetRouteData(name); if (!string.IsNullOrEmpty(value)) { paramType = ParamType.route; } } catch { } } if (string.IsNullOrEmpty(value)) { try { value = UrlParameterHelper.GetParams(name); if (!string.IsNullOrEmpty(value)) { paramType = ParamType.param; } } catch { } } return(!string.IsNullOrEmpty(value) && paramType != ParamType.none); }
private string GetPayUrl(string url, string pt) { string userType = UrlParameterHelper.GetParams("ut"); string money = UrlParameterHelper.GetParams("money"); string otn = UrlParameterHelper.GetParams("otn"); //string returnUrl = UrlParameterHelper.GetDecodingParams("returnUrl"); //string state = ""; //if (!string.IsNullOrEmpty(returnUrl)) //{ // state = Guid.NewGuid().ToString("N"); // ReturnUrlHelper.SetSession("NowPay_ReturnUrl", state, returnUrl); //} //return string.Format("{0}?ut={1}&money={2}&pt={3}&otn={4}&st={5}", url, userType, money, pt, otn, state); return(string.Format("{0}?ut={1}&money={2}&pt={3}&otn={4}", url, userType, money, pt, otn)); }
protected override void SetChapterCodeRange() { string MinMaxChapterCode = UrlParameterHelper.GetParams("cc"); if (!string.IsNullOrEmpty(MinMaxChapterCode)) { int min = 0; int max = 0; string[] chapterCode = MinMaxChapterCode.Split('_'); if (chapterCode != null && chapterCode.Length == 2 && int.TryParse(chapterCode[0], out min) && min >= 0 && int.TryParse(chapterCode[1], out max) && max >= 0) { SetChapterCode(min, max); } } }
private string GetChannelId(AuthorizationContext filterContext, string name) { if (string.IsNullOrEmpty(name)) { return(""); } string value = string.Empty; try { value = StringHelper.FilterIllegalParameter(filterContext.HttpContext.Request.Headers[name]); } catch { } if (string.IsNullOrEmpty(value)) { try { value = UrlParameterHelper.GetParams(name); } catch { } } if (string.IsNullOrEmpty(value)) { try { RouteData data = filterContext.RouteData; if (data != null) { RouteValueDictionary values = data.Values; if (values != null && values.Count > 0) { value = StringHelper.ToString(values[name]); } } } catch { } } return(value); }
public ChapterPagerManage(Func <int, ChapterCodeRange> func, bool isCustomRange = false, int chapterCodeRangeTimeout = 0, int chapterRedirectTimeout = 0) : base(chapterRedirectTimeout) { if (NovelId <= 0) { return; } string chapterCodeRange = string.Empty; if (isCustomRange && !string.IsNullOrEmpty(chapterCodeRange = UrlParameterHelper.GetParams("cc"))) { int min = 0; int max = 0; string[] range = chapterCodeRange.Split('_'); if (!range.IsNullOrEmpty() && range.Length == 2 && int.TryParse(range[0], out min) && min >= 0 && int.TryParse(range[1], out max) && max >= 0) { Set(min, max); } } else { _chapterCodeRange = UrlParameterHelper.GetParams("c"); if (!string.IsNullOrEmpty(_chapterCodeRange) && ChapterContext.VerifyRangeToken(_chapterCodeRange, out _minChapterCode, out _maxChapterCode, chapterCodeRangeTimeout)) { Reset(); } else { if (func != null) { ChapterCodeRange range = func(NovelId); if (!range.IsNullOrEmpty <ChapterCodeRange>()) { Set(range.MinChapterCode, range.MaxChapterCode); } } } } }
/// <summary> /// 验证充值订单信息 /// </summary> /// <param name="minMoney">最低充值金额(如:0.1元、0.01元)</param> /// <param name="errorMessage">错误信息</param> /// <param name="payType">充值类型</param> /// <param name="orderId">订单号</param> /// <param name="money">充值金额</param> /// <param name="userType"></param> /// <returns></returns> public static bool VerifyPayOrderInfo(int minMoney, out ErrorMessage errorMessage, out int payType, out string orderId, out int money, out int userType) { errorMessage = ErrorMessage.成功; payType = 0; orderId = string.Empty; money = StringHelper.ToInt(UrlParameterHelper.GetParams("money")); //单位:分 userType = StringHelper.ToInt(UrlParameterHelper.GetParams("ut")); //默认:至少20元;大于0:任意金额; string pt = UrlParameterHelper.GetParams("pt"); string otn = UrlParameterHelper.GetParams("otn"); int orderMoney = 0; if (!VerifyOrderId(otn, money, out orderId, out orderMoney)) { errorMessage = ErrorMessage.支付参数错误; } else if (!string.IsNullOrEmpty(pt) && int.TryParse(pt, out payType) && payType <= 0) { errorMessage = ErrorMessage.支付类型为空; } else if (money <= 0) { errorMessage = ErrorMessage.金额为空; } else if (money <= 1999) { errorMessage = ErrorMessage.最低充值20元; } else { money = (userType == 0 ? money : minMoney); } return(errorMessage == ErrorMessage.成功); }
protected void SetSessionHeaderInfo() { ReadSessionHeaderInfo(); string channelId = ""; ParamType paramType = ParamType.none; if (IsHeader(Constants.HttpHeader.CHANNEL_ID, out channelId, out paramType)) { if (paramType == ParamType.route) { SaveSessionHeaderInfoFromRoute(channelId); } else { #region HeaderInfo Session string promotionCode = UrlParameterHelper.GetParams("pmc"); if (!string.IsNullOrEmpty(promotionCode)) { SaveSessionHeaderInfo(channelId, promotionCode); } else { SaveSessionHeaderInfo(channelId, ""); } #endregion HeaderInfo Session } } #region SetHeaderInfo(); #endregion }
public ActionResult Detail() { string hideUrl = ""; if (ChapterContext.VerifyRedirect(NovelId, ChapterCode, ChapterDirection, out hideUrl, SiteSection.Chapter.IsRedirectWeChat)) { return(Redirect(hideUrl)); } SetReadMode(); Novel novel = _bookService.GetNovel(NovelId); if (novel != null && novel.Id > 0) { InitializeChapterPager(); Chapter chapter = _chapterService.GetChapter(NovelId, ChapterCode, ChapterDirection, out ChapterCode); if (chapter != null && chapter.Id > 0 && IsRead(_orderService)) { #region bool isPreChapterCode = false; bool isNextChapterCode = false; string url = GetChapterPager("/chapter/detail", ChapterCode, out isPreChapterCode, out isNextChapterCode); #endregion #region 推荐阅读 //推荐阅读 - 轮循广告 int adClassId = RecSection.BookChapterDetail.Ad; IEnumerable <AD> adList = GetADList(adClassId, novel.Id, 3); #endregion //阅读记录 ReadLog(currentUser.UserName, chapter.NovelId, chapter.Id, chapter.ChapterCode); //最近阅读日志 RecentReadContext.Save(novel, chapter.ChapterName, ChapterCode, RouteChannelId, currentUser.UserId); //是否收藏 bool isMark = _bookmarkService.Exists(NovelId, currentUser.UserName); //漫画目录 IEnumerable <ExtendChapterView> extendChapterList = GetExtendChapterList(novel); //千字价格 int chapterWordSizeFee = GetChapterWordSizeFee(novel.ChapterWordSizeFee); //章节正文 string chapterContent = GetContent(novel.ContentType, chapter.ChapterName, novel.FilePath, chapter.FileName); ChapterDetailView detailView = new ChapterDetailView() { Novel = new SimpleResponse <Novel>(true, novel), Chapter = new SimpleResponse <Chapter>(true, chapter), ChapterFee = GetFee(chapter.WordSize, chapterWordSizeFee), ChapterContent = chapterContent, IsPreChapterCode = isPreChapterCode, IsNextChapterCode = isNextChapterCode, PreChapterUrl = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.pre, channelId: RouteChannelId), NextChapterUrl = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.next, channelId: RouteChannelId), AdList = new SimpleResponse <IEnumerable <AD> >(!adList.IsNullOrEmpty <AD>(), adList), IsMark = isMark, ExtendChapterList = new SimpleResponse <IEnumerable <ExtendChapterView> >(!extendChapterList.IsNullOrEmpty <ExtendChapterView>(), extendChapterList), ChapterAudioUrl = GetAudioUrl(novel.ContentType, chapter.FileName), HitUrl = GetHitUrl(), ShowQrCodeMinChapterCode = StringHelper.ToInt(UrlParameterHelper.GetParams("qrdx")) }; if (novel.ContentType == (int)Constants.Novel.ContentType.漫画) { return(View("/views/cartoonchapter/detail.cshtml", detailView)); } else if (novel.ContentType == (int)Constants.Novel.ContentType.听书) { return(View("/views/audiochapter/detail.cshtml", detailView)); } else { return(View(detailView)); } } else { if (novel.FeeType == (int)Constants.Novel.FeeType.chapter || novel.FeeType == (int)Constants.Novel.FeeType.novelchapter) { return(Redirect(ChapterContext.GetUrl("/preorder/chapter", NovelId, ChapterCode, channelId: RouteChannelId))); } else if (novel.FeeType == (int)Constants.Novel.FeeType.novel) { return(Redirect(ChapterContext.GetUrl("/preorder/novel", NovelId, ChapterCode, channelId: RouteChannelId))); } } } return(Redirect(DataContext.GetErrorUrl(ErrorMessage.小说不存在, channelId: RouteChannelId))); }
public ActionResult Detail() { #region string absoluteUrl = ""; if (EnvSettings.Domain.IsInvalid(out absoluteUrl)) { return(Redirect(absoluteUrl)); } #endregion SetReadMode(); Novel novel = _bookService.GetNovel(NovelId); if (novel != null && novel.Id > 0) { InitializeChapterPager(); Chapter chapter = _chapterService.GetChapter(NovelId, ChapterCode, ChapterDirection, out ChapterCode); if (chapter != null && chapter.Id > 0 && IsRead(_orderService)) { #region bool isPreChapterCode = false; bool isNextChapterCode = false; string url = GetChapterPager("/chapter/detail", ChapterCode, out isPreChapterCode, out isNextChapterCode); #endregion #region 推荐阅读 //推荐阅读 - 轮循广告 int adClassId = RecSection.BookChapterDetail.Ad; IEnumerable <AD> adList = GetADList(adClassId, novel.Id, 3); #endregion //阅读记录 ReadLog(currentUser.UserName, chapter.NovelId, chapter.Id, chapter.ChapterCode); //最近阅读日志 RecentReadContext.Save(novel, chapter.ChapterName, ChapterCode, RouteChannelId, currentUser.UserId); //是否收藏 bool isMark = _bookmarkService.Exists(NovelId, currentUser.UserName); //漫画目录 IEnumerable <ExtendChapterView> extendChapterList = GetExtendChapterList(novel); // 千字价格 int chapterWordSizeFee = GetChapterWordSizeFee(novel.ChapterWordSizeFee); //正文中插入用户信息 string encryptInfo = string.IsNullOrEmpty(currentUser.UserName) ? null : string.Concat("16", ";", currentUser.UserName.Substring(1)); ChapterDetailView detailView = new ChapterDetailView() { Novel = new SimpleResponse <Novel>(true, novel), Chapter = new SimpleResponse <Chapter>(true, chapter), ChapterFee = GetFee(chapter.WordSize, chapterWordSizeFee), ChapterContent = StringHelper.ConvertAndSignTxt((novel.ContentType == (int)Constants.Novel.ContentType.小说) ? FileHelper.ReadFile(FileHelper.MergePath("\\", new string[] { novel.FilePath, chapter.FileName }), chapter.ChapterName) : "", Constants.SecurityKey.userAESId.ToLower(), encryptInfo), IsPreChapterCode = isPreChapterCode, IsNextChapterCode = isNextChapterCode, PreChapterUrl = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.pre, channelId: RouteChannelId), NextChapterUrl = ChapterContext.GetUrl(url, NovelId, ChapterCode, Constants.Novel.ChapterDirection.next, channelId: RouteChannelId), AdList = new SimpleResponse <IEnumerable <AD> >(!adList.IsNullOrEmpty <AD>(), adList), IsMark = isMark, ExtendChapterList = new SimpleResponse <IEnumerable <ExtendChapterView> >(!extendChapterList.IsNullOrEmpty <ExtendChapterView>(), extendChapterList), ChapterAudioUrl = GetAudioUrl(novel.ContentType, chapter.FileName), HitUrl = GetHitUrl(), ShowQrCodeMinChapterCode = StringHelper.ToInt(UrlParameterHelper.GetParams("qrdx")) }; if (novel.ContentType == (int)Constants.Novel.ContentType.漫画) { return(View("/views/cartoonchapter/detail.cshtml", detailView)); } else if (novel.ContentType == (int)Constants.Novel.ContentType.听书) { return(View("/views/audiochapter/detail.cshtml", detailView)); } else { return(View(detailView)); } } else { if (novel.FeeType == (int)Constants.Novel.FeeType.chapter || novel.FeeType == (int)Constants.Novel.FeeType.novelchapter) { return(Redirect(ChapterContext.GetUrl("/preorder/chapter", NovelId, ChapterCode, channelId: RouteChannelId))); } else if (novel.FeeType == (int)Constants.Novel.FeeType.novel) { return(Redirect(ChapterContext.GetUrl("/preorder/novel", NovelId, ChapterCode, channelId: RouteChannelId))); } } } return(Redirect(DataContext.GetErrorUrl(ErrorMessage.小说不存在, channelId: RouteChannelId))); }
public ActionResult Index3() { string result = ""; ErrorMessage errorMessage = ErrorMessage.失败; string url = StringHelper.GetHost(); if (string.IsNullOrEmpty(url)) { errorMessage = ErrorMessage.订单初始化失败; return(Redirect(string.Format("/error/index?errCode={0}&returnUrl=", (int)errorMessage).GetChannelRouteUrl(RouteChannelId))); } int payType = 0; string orderId = ""; int money = 0; int userType = 0; if (PayContext.VerifyPayOrderInfo(10, out errorMessage, out payType, out orderId, out money, out userType) && payType == 13 && StringHelper.GetUserAgent().ToLower().Contains("micromessenger")) { string OpenId = UrlParameterHelper.GetParams("OpenId"); if (!string.IsNullOrEmpty(OpenId)) { string appId = NowPayConfig.WeChatQrCodeAppId; string appKey = NowPayConfig.WeChatQrCodeAppKey; string callbackUrl = NowPayConfig.NewCallbackUrl; string notifyUrl = string.Format("http://{0}/user/order/paynow/notify", url); string frontNotifyUrl = string.Format("http://{0}/user/order/paynow/result", url); SortedDictionary <string, string> dict = new SortedDictionary <string, string>(); dict.Add("funcode", "WP001"); //功能码(定值:WP001)(必填) dict.Add("appId", appId); //商户应用唯一标识(字符,长度1-40)(必填) dict.Add("mhtOrderNo", orderId); //商户订单号(字符,长度1-40)(必填) dict.Add("mhtOrderName", GetName(money)); //商户商品名称(字符,长度1-40)(必填) dict.Add("mhtOrderType", "01"); //商户交易类型(01普通消费)(字符,长度1-40)(必填) dict.Add("mhtCurrencyType", "156"); //商户订单币种类型(156人民币)(字符,长度3)(必填) dict.Add("mhtOrderAmt", StringHelper.ToString(money)); //商户订单交易金额(单位(人民币):分)(数字,长度22)(必填) dict.Add("mhtOrderDetail", "充值"); //商户订单详情(字符,长度0-200)(必填) dict.Add("mhtOrderTimeOut", "3600"); //商户订单超时时间(60~3600秒,默认3600)(数字,长度4)(必填) dict.Add("mhtOrderStartTime", DateTime.Now.ToString("yyyyMMddHHmmss")); //商户订单开始时间 yyyyMMddHHmmss(字符,长度14)(必填) dict.Add("notifyUrl", notifyUrl); //商户后台通知URL(HTTP协议或者HTTPS协议,POST方式提交报文)(字符,长度1-200)(必填) dict.Add("frontNotifyUrl", frontNotifyUrl); //商户前台通知URL(HTTP协议或者HTTPS协议,POST方式提交报文)(字符,长度1-200)(必填) dict.Add("mhtCharset", "UTF-8"); //商户字符编码(字符,长度1-16)(必填) dict.Add("deviceType", "08"); //设备类型(06手机网页)(字符,长度2)(必填) dict.Add("outputType", "1"); //输出类型(二维码 = 1) dict.Add("payChannelType", payType.ToString()); //用户所选渠道类型(如果为空则直接使用现在支付收银台页面,如果不为空则直接跳转至支付渠道(银联或者支付宝等))(字符,长度2) dict.Add("mhtReserved", ""); //商户保留域(给商户使用的字段,商户可以对交易进行标记,现在支付将原样返回)(字符,长度100) dict.Add("consumerId", StringHelper.ToString(currentUser.UserId)); //消费者ID(消费者在商户系统的ID,非必填,但是推荐填写,以便于辅助数据分析)(字符,长度40) dict.Add("consumerName", ""); //消费者名称(消费者在商户系统的名称,非必填,但是推荐填写,以便于辅助数据分析)(字符,长度40) dict.Add("mhtSignType", "MD5"); //商户签名方法(定值:MD5)(必填) dict.Add("mhtSignature", GetSign(appKey, dict)); //商户数据签名(MAX64TEXT)(必填) HttpSendInfo sendInfo = new HttpSendInfo(); sendInfo.Method = "POST"; sendInfo.Url = callbackUrl; sendInfo.Data = GetPostData(dict); HttpReceiveInfo receiveInfo = new HttpReceiveInfo(); if (HttpHelper.Send(sendInfo, out receiveInfo)) { //报文日志 //Log(this.Server.UrlDecode(sendInfo.Data)); result = GetTnUrl3(receiveInfo.Result); } } } ViewData.Model = result; ViewBag.OrderId = orderId; return(View()); }
public ActionResult Novel() { string url = ""; Novel novelInfo = _bookService.GetNovel(NovelId, (int)Constants.Status.yes); if (!novelInfo.IsNullOrEmpty <Novel>() && novelInfo.Id > 0) { ErrorMessage errorMessage = ErrorMessage.失败; switch (novelInfo.FeeType) { case (int)Constants.Novel.FeeType.novel: case (int)Constants.Novel.FeeType.novelchapter: int result = Novel(novelInfo); if (EnumHelper.TryParsebyValue <ErrorMessage>(result, out errorMessage)) { switch (errorMessage) { case ErrorMessage.成功: url = ChapterContext.GetUrl("/chapter/detail", NovelId, ChapterCode, channelId: RouteChannelId); break; case ErrorMessage.余额不足: url = StringHelper.GetReturnUrl("/order/recharge", UrlParameterHelper.GetParams("returnUrl"), channelId: RouteChannelId); break; case ErrorMessage.已购买过该小说: url = ChapterContext.GetUrl("/chapter/detail", NovelId, ChapterCode, channelId: RouteChannelId); break; case ErrorMessage.用户不存在: url = DataContext.GetErrorUrl(ErrorMessage.用户不存在, channelId: RouteChannelId); break; case ErrorMessage.小说不存在: url = DataContext.GetErrorUrl(ErrorMessage.小说不存在, channelId: RouteChannelId); break; case ErrorMessage.小说章节不存在: url = DataContext.GetErrorUrl(ErrorMessage.小说章节不存在, channelId: RouteChannelId); break; case ErrorMessage.该小说标价有误无法购买: url = DataContext.GetErrorUrl(ErrorMessage.该小说标价有误无法购买, channelId: RouteChannelId); break; case ErrorMessage.该小说无法按本计费: url = DataContext.GetErrorUrl(ErrorMessage.该小说无法按本计费, channelId: RouteChannelId); break; default: url = DataContext.GetErrorUrl(ErrorMessage.未知错误, channelId: RouteChannelId); break; } } break; case (int)Constants.Novel.FeeType.chapter: url = ChapterContext.GetUrl("/preorder/chapter", NovelId, ChapterCode, channelId: RouteChannelId); break; } } return(Redirect(url)); }