Yuebon.Messages/Yuebon.Messages.Core/Messenger.cs
(开头部分) 19KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using Senparc.Weixin.Entities;
using Yuebon.Commons.Core.App;
using Yuebon.Commons.Helpers;
using Yuebon.Commons.Json;
using Yuebon.Commons.Models;
using Yuebon.Messages.IServices;
using Yuebon.Messages.Models;
using Yuebon.Security.Application;
using Yuebon.Security.IServices;
using Yuebon.Security.Models;
using Yuebon.SMS.AliYun;
using Yuebon.WeChat.CommonService.SubscribeMessage.WxApplet;
namespace Yuebon.Messages.Application
{
public static class Messenger
{
static IMessageTemplatesService messageTemplatesService = Appsettings.GetService<IMessageTemplatesService>();
static IMemberMessageBoxService memberMessageBoxService = Appsettings.GetService<IMemberMessageBoxService>();
static IMemberSubscribeMsgService memberSubscribeMsgService = Appsettings.GetService<IMemberSubscribeMsgService>();
static IUserService userService = Appsettings.GetService<IUserService>();
/// <summary>
/// 留言提醒
/// </summary>
/// <param name="userId">接收者(用户)的 userId</param>
/// <param name="text">留言内容,20个以内字符</param>
/// <param name="date">留言时间,4小时制时间格式(支持+年月日) 例如:15:01,或:2019年10月1日 15:01</param>
/// <param name="page">点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。</param>
public static CommonResult SendCommentNotice(long userId, string text,string date,string page="")
{
CommonResult result = new CommonResult();
User user = new UserApp().GetUserById(userId);
if (user != null && !string.IsNullOrEmpty(text))
{
MessageTemplates template = messageTemplatesService.GetByMessageType("CommentNotice");
if (!string.IsNullOrEmpty(template.InnerMessageSubject) && !string.IsNullOrEmpty(template.InnerMessageBody) && template.SendInnerMessage)
{
MemberMessageBox memberMessageBox = new MemberMessageBox();
memberMessageBox.Id = IdGeneratorHelper.IdSnowflake();
memberMessageBox.IsRead = false;
memberMessageBox.Sernder = "系统消息";
memberMessageBox.Accepter = userId;
memberMessageBox.MsgContent = string.Format(template.InnerMessageBody, text, date);
memberMessageBoxService.Insert(memberMessageBox);
}
if (!string.IsNullOrEmpty(template.WxAppletSubscribeTemplateId) && template.UseInWxApplet)
{
MemberSubscribeMsg memberSubscribeMsg= memberSubscribeMsgService.GetByMessageTemplateIdAndUser(template.Id,userId, "WxApplet");
if(memberSubscribeMsg.SubscribeStatus == "accept") {
UserOpenIds userOpenIds = new UserApp().GetUserOpenIdById(userId, "yuebon.openid.wxapplet");
if (userOpenIds != null )
{
WxJsonResult wxJsonResult = WxAppletSubscribeMessage.SendCommentNotice(userOpenIds.OpenId, template.WxAppletSubscribeTemplateId, text, date, page);
result.ErrCode = wxJsonResult.errcode.ToString();
result.ErrMsg = wxJsonResult.errmsg;
}
}
else
{
后面还有 322 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。