/// <summary> /// 发送微信模板消息 /// </summary> /// <param name="data"></param> /// <param name="openId"></param> public void GetSuccessSendWXMessage(BonusReceiveInfo data, string openId) { var user = data.Himall_Members; #region 发送模板消息 //TODO:DZY[150914]此处功能需要整理,暂时只是实现功能 var msgdata = new WX_MSGGetCouponModel(); msgdata.first.value = "您好,您已成功领取现金红包。!"; msgdata.first.color = "#000000"; msgdata.toName.value = user != null ? user.Nick : "微信会员"; msgdata.toName.color = "#000000"; msgdata.gift.value = "现金" + data.Price.ToString() + "元"; msgdata.gift.color = "#FF0000"; msgdata.time.value = data.ReceiveTime.Value.ToString("yyyy-MM-dd HH:mm"); msgdata.time.color = "#FF0000"; msgdata.remark.value = "红包领取成功会直接计入预存款,可消费与提现。"; msgdata.remark.color = "#000000"; //处理url var _iwxtser = Himall.ServiceProvider.Instance <IWXMsgTemplateService> .Create; string url = _iwxtser.GetMessageTemplateShowUrl(Himall.Core.Plugins.Message.MessageTypeEnum.ReceiveBonus); var wxmsgtmpl = _iwxtser.GetWeiXinMsgTemplate(Himall.Core.Plugins.Message.MessageTypeEnum.ReceiveBonus); var siteSetting = Himall.ServiceProvider.Instance <ISiteSettingService> .Create.GetSiteSettings(); if (wxmsgtmpl != null) { if (!string.IsNullOrWhiteSpace(wxmsgtmpl.TemplateId) && wxmsgtmpl.IsOpen) { Himall.ServiceProvider.Instance <IWXApiService> .Create.SendMessageByTemplate(siteSetting.WeixinAppId, siteSetting.WeixinAppSecret, openId, wxmsgtmpl.TemplateId, "#000000", url, msgdata); } } #endregion }
public void GetSuccessSendWXMessage(BonusReceiveInfo data, string openId, string url) { WX_MSGGetCouponModel wXMSGGetCouponModel = new WX_MSGGetCouponModel(); wXMSGGetCouponModel.first.@value = "领取红包成功!"; wXMSGGetCouponModel.first.color = "#000000"; wXMSGGetCouponModel.keyword1.@value = "现金红包(1个)"; wXMSGGetCouponModel.keyword1.color = "#000000"; WX_MSGItemBaseModel wXMSGItemBaseModel = wXMSGGetCouponModel.keyword2; decimal price = data.Price; wXMSGItemBaseModel.@value = string.Concat(price.ToString(), "元"); wXMSGGetCouponModel.keyword2.color = "#FF0000"; wXMSGGetCouponModel.remark.@value = "红包领取成功会直接计入预存款,可消费与提现。"; wXMSGGetCouponModel.remark.color = "#000000"; SiteSettingsInfo siteSettings = Instance <ISiteSettingService> .Create.GetSiteSettings(); Instance <IWXApiService> .Create.SendMessageByTemplate(siteSettings.WeixinAppId, siteSettings.WeixinAppSecret, openId, siteSettings.WX_MSGGetCouponTemplateId, "#000000", url, wXMSGGetCouponModel); }