You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
2.4 KiB
54 lines
2.4 KiB
using BBWY.Common.Http;
|
|
using BBWY.Common.Models;
|
|
using Newtonsoft.Json;
|
|
using System.Net.Http;
|
|
|
|
namespace BBWY.Server.Business
|
|
{
|
|
public class QYMessageCenterBusiness : IDenpendency
|
|
{
|
|
|
|
private RestApiService restApiService;
|
|
public QYMessageCenterBusiness(RestApiService restApiService)
|
|
{
|
|
this.restApiService = restApiService;
|
|
}
|
|
|
|
public void SendMessage(string channel, string teamId, string shopId, string appCode, string title, string content, string senderId, string recevierId)
|
|
{
|
|
SendMessage(channel, teamId, shopId, appCode, title, content, string.Empty, senderId, recevierId, false);
|
|
}
|
|
|
|
public void SendMessage(string channel, string teamId, string shopId, string appCode, string title, string content, string customTypeCode, string senderId, string recevierId)
|
|
{
|
|
SendMessage(channel, teamId, shopId, appCode, title, content, customTypeCode, senderId, recevierId, false);
|
|
}
|
|
|
|
public void SendMessage(string channel, string teamId, string shopId, string appCode, string title, object jsonContent, string customTypeCode, string senderId, string recevierId)
|
|
{
|
|
SendMessage(channel, teamId, shopId, appCode, title, JsonConvert.SerializeObject(jsonContent), customTypeCode, senderId, recevierId, true);
|
|
}
|
|
|
|
private void SendMessage(string channel, string teamId, string shopId, string appCode, string title, string content, string customTypeCode, string senderId, string recevierId, bool isJsonMsg)
|
|
{
|
|
var httpResult = restApiService.SendRequest("http://api.msg.qiyue666.com", "api/message/send", new
|
|
{
|
|
appCode,
|
|
channel,
|
|
teamId,
|
|
shopId,
|
|
title,
|
|
content,
|
|
customTypeCode,
|
|
senderId,
|
|
recevierId,
|
|
isJsonMsg
|
|
}, null, HttpMethod.Post);
|
|
if ((httpResult.StatusCode != System.Net.HttpStatusCode.OK))
|
|
throw new BusinessException($"QYMessageCenterBusiness SendMessage HttpCode {httpResult.StatusCode}");
|
|
var response = JsonConvert.DeserializeObject<BBWY.Common.Models.ApiResponse>(httpResult.Content);
|
|
if (!response.Success)
|
|
throw new BusinessException($"QYMessageCenterBusiness SendMessage {response.Msg}");
|
|
}
|
|
}
|
|
}
|
|
|