/// <summary> /// 微信支付 /// </summary> /// <param name="id">订单号</param> /// <returns></returns> public ActionResult Pay(string id) { var order = BLLNews.GetNewsDetailsByOrderNo(id); ViewBag.OrderNo = id; if (Request.IsAjaxRequest()) { if (order == null || order.pay_status == 1) { return(JsonResult(Model.Enum.APIErrCode.OperateFail, "订单无效或已经支付")); } string Ip = Request.UserHostAddress; string openId = BLLUser.GetLoginUserInfo().openid; string notiUrl = Request.Url.Scheme + "://" + Request.Url.Authority + "/WX/PayNotify";//通知地址 bool isRequestSuccess = false; var payRequest = BLLWeixin.WXPay(order.order_no, order.total.Value, openId, Ip, notiUrl, out isRequestSuccess); if (isRequestSuccess) { return(JsonResult(Model.Enum.APIErrCode.Success, "OK", payRequest)); } else { return(JsonResult(Model.Enum.APIErrCode.OperateFail)); } } else { return(View()); } }
/// <summary> /// 微信支付 /// </summary> /// <param name="id">订单号</param> /// <returns></returns> public ActionResult SetTopPay(int id, int set_top, decimal money) { string msg = ""; string orderNo = ""; string type = set_top == 1 ? "分类置顶" : "全站置顶"; var authenticationUser = BLLAuthentication.GetAuthenticationUser(); bool result = BLLNewsOrder.Add(new ht_news_order() { news_id = id, type = type, value = set_top.ToString(), money = money, pay = "微信", add_userid = authenticationUser.id }, out msg, out orderNo); if (!result) { return(JsonResult(Model.Enum.APIErrCode.OperateFail, msg)); } string Ip = Request.UserHostAddress; string openId = BLLUser.GetLoginUserInfo().openid; string notiUrl = Request.Url.Scheme + "://" + Request.Url.Authority + "/WX/PayNotify";//通知地址 bool isRequestSuccess = false; var payRequest = BLLWeixin.WXPay(orderNo, money, openId, Ip, notiUrl, out isRequestSuccess, string.Format("{1}订单号:{0}", orderNo, type)); if (isRequestSuccess) { return(JsonResult(Model.Enum.APIErrCode.Success, "OK", payRequest)); } else { return(JsonResult(Model.Enum.APIErrCode.OperateFail)); } }