/// <summary> /// 获取消息记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public JsonResult GetSendRecordDetail(long id) { var messageinfo = WXMsgTemplateApplication.GetSendMessageRecordById(id); if (messageinfo == null || messageinfo.Id <= 0) { return(Json(new { success = false, msg = "消息记录不存在" })); } return(Json(new { success = true, model = messageinfo })); }
/// <summary> /// 微信图片 /// </summary> /// <param name="mediaid"></param> /// <returns></returns> public ActionResult GetMedia(string mediaid) { var siteSetting = SiteSettingApplication.SiteSettings; if (string.IsNullOrWhiteSpace(siteSetting.WeixinAppId)) { throw new MallException("未配置微信公众号"); } MemoryStream stream = new MemoryStream(); WXMsgTemplateApplication.GetMedia(mediaid, siteSetting.WeixinAppId, siteSetting.WeixinAppSecret, stream); return(File(stream.ToArray(), "Image/png")); }
public JsonResult GetWXMaterialList(int pageIdx, int pageSize) { var siteSetting = SiteSettingApplication.SiteSettings; if (string.IsNullOrWhiteSpace(siteSetting.WeixinAppId)) { throw new MallException("未配置微信公众号"); } var offset = (pageIdx - 1) * pageSize; var list = WXMsgTemplateApplication.GetMediaMsgTemplateList(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret, offset, pageSize); return(Json(list)); }
public JsonResult GetSendRecords(int page, int rows, SendRecordQuery query) { query.PageNo = page; query.PageSize = rows; var pageModel = WXMsgTemplateApplication.GetSendRecords(query); var model = pageModel.Models.ToList().Select(e => new { MsgType = e.MessageType.ToDescription(), SendTime = e.SendTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), SendToUser = e.ToUserLabel, CurrentCouponCount = e.CurrentCouponCount, CurrentUseCouponCount = e.CurrentUseCouponCount, SendState = e.SendState == 1 ? "发送成功" : "发送失败" }); return(Json(new { rows = model, total = pageModel.Total })); }
public object GetPaymentList(string orderId) { CheckUserLogin(); var mobilePayments = Core.PluginsManagement.GetPlugins <IPaymentPlugin>(true).Where(item => item.Biz.SupportPlatforms.Contains(Core.PlatformType.WeiXinSmallProg)); string webRoot = Core.Helper.WebHelper.GetScheme() + "://" + Core.Helper.WebHelper.GetHost(); string urlPre = webRoot + "/m-" + Core.PlatformType.Android + "/Payment/"; //获取待支付的所有订单 var orderService = ServiceProvider.Instance <IOrderService> .Create; var orders = orderService.GetOrders(orderId.Split(',').Select(t => long.Parse(t))).Where(r => r.OrderStatus == Entities.OrderInfo.OrderOperateStatus.WaitPay); var totalAmount = orders.Sum(t => t.OrderTotalAmount - t.CapitalAmount); //获取所有订单中的商品名称 string productInfos = GetProductNameDescriptionFromOrders(orders); string[] strIds = orderId.Split(','); string notifyPre = urlPre + "Notify/", returnPre = webRoot + "/m-" + Core.PlatformType.Android + "/Member/PaymentToOrders?ids=" + orderId; var orderPayModel = strIds.Select(item => new Entities.OrderPayInfo { PayId = 0, OrderId = long.Parse(item) }); //保存支付订单 var payid = orderService.SaveOrderPayInfo(orderPayModel, Core.PlatformType.WeiXinSmallProg); var ids = payid.ToString(); var models = mobilePayments.ToArray().Select(item => { string url = string.Empty; try { url = item.Biz.GetRequestUrl(returnPre, notifyPre + item.PluginInfo.PluginId.Replace(".", "-") + "/", ids, totalAmount, productInfos, CurrentUserOpenId); } catch (Exception ex) { Core.Log.Error("获取支付方式错误:", ex); } //适配小程序接口,从支付插件里解析出相应参数 //字符串格式:prepayId:234320480,partnerid:32423489,nonceStr=dslkfjsld #region 适配小程序接口,从支付插件里解析出相应参数 var prepayId = string.Empty; var nonceStr = string.Empty; var timeStamp = string.Empty; var sign = string.Empty; if (!string.IsNullOrWhiteSpace(url)) { var paras = url.Split(','); foreach (var str in paras) { var keyValuePair = str.Split(':'); if (keyValuePair.Length == 2) { switch (keyValuePair[0]) { case "prepayId": prepayId = keyValuePair[1]; break; case "nonceStr": nonceStr = keyValuePair[1]; break; case "timeStamp": timeStamp = keyValuePair[1]; break; case "sign": sign = keyValuePair[1]; break; } } } } #endregion return(new { prepayId = prepayId, nonceStr = nonceStr, timeStamp = timeStamp, sign = sign }); }); var model = models.FirstOrDefault(); if (null == model) { return(Json(new int[0])); } if (!string.IsNullOrEmpty(model.prepayId)) { Entities.WXAppletFormDataInfo info = new Entities.WXAppletFormDataInfo(); info.EventId = Convert.ToInt64(MessageTypeEnum.OrderPay); info.EventTime = DateTime.Now; info.EventValue = orderId; info.ExpireTime = DateTime.Now.AddDays(7); info.FormId = model.prepayId; WXMsgTemplateApplication.AddWXAppletFromData(info); } return(Json(model)); }