using Aop.Api.Domain; using ApiTools.Core; using Furion; using Furion.HttpRemote; using log4net.Core; using MediatR; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ApiTools.Application { public class WxmpSubscribMessageCommandHandler( ILogger logger, WxmpUtils utils, IHttpRemoteService httpRemoteService ) : IRequestHandler, IRequestHandler { private readonly ILogger logger = logger; private readonly WxmpUtils utils = utils; private readonly IHttpRemoteService httpRemoteService = httpRemoteService; /// /// 微信小程序发送订阅消息 /// /// /// /// public async Task Handle(SendWxmpSubscribMessageCommand request, CancellationToken cancellationToken) { await utils.WxmpSendSubscribMessage(new WxmpSendSubscribMessageRequest { Data = request.Data, TemplateId = request.TemplateId, Page = request.Page, WxmpCode = request.WxmpCode, Touser = request.Touser, }); return Guid.Empty; } /// /// 微信小程序订阅消息通知 /// /// /// /// public async Task Handle(WxmpSubscribMessageNotifyCommand request, CancellationToken cancellationToken) { var env = App.GetConfig("Environment"); if (env == "Product") { try { var json = request.ToJson(); await httpRemoteService.PostAsStringAsync("http://118.178.252.28:8780/api/common/wxmp/wxmpSubscribMessageNotify", builder => builder.SetJsonContent(json)); } catch { } } return true; } } }