Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WxOpen v3.15.3 1、添加商户客户参数(BusinessId) 2、单独为小程序添加“客服输入状态”接口,支持商户客户参… #2630

Merged
merged 1 commit into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace Senparc.Weixin.MP.AdvancedAPIs
/// <summary>
/// 客服接口
/// </summary>
[NcApiBind(NeuChar.PlatformType.WeChat_OfficialAccount,true)]
[NcApiBind(NeuChar.PlatformType.WeChat_OfficialAccount, true)]
public static class CustomApi
{
/// <summary>
Expand Down Expand Up @@ -513,7 +513,7 @@ public static WxJsonResult SendCard(string accessTokenOrAppId, string openId, st
/// <param name="kfAccount"></param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static WxJsonResult SendMiniProgramPage(string accessTokenOrAppId, string openId, string title, string appid, string pagepath, string thumb_media_id, string kfAccount="", int timeOut = Config.TIME_OUT)
public static WxJsonResult SendMiniProgramPage(string accessTokenOrAppId, string openId, string title, string appid, string pagepath, string thumb_media_id, string kfAccount = "", int timeOut = Config.TIME_OUT)
{
object data = null;
if (kfAccount.IsNullOrWhiteSpace())
Expand All @@ -525,8 +525,8 @@ public static WxJsonResult SendMiniProgramPage(string accessTokenOrAppId, string
miniprogrampage = new
{
title = title,
appid=appid,
pagepath= pagepath,
appid = appid,
pagepath = pagepath,
thumb_media_id = thumb_media_id
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ and limitations under the License.
API地址:https://developers.weixin.qq.com/miniprogram/dev/api/custommsg/conversation.html
*/

using Senparc.CO2NET.Extensions;
using Senparc.CO2NET.Helpers.Serializers;
using Senparc.NeuChar;
using Senparc.Weixin.CommonAPIs;
using Senparc.Weixin.Entities;
Expand All @@ -49,10 +51,36 @@ namespace Senparc.Weixin.WxOpen.AdvancedAPIs
[NcApiBind(NeuChar.PlatformType.WeChat_MiniProgram, true)]
public class CustomApi
{
/* 商户客户参数文档: https://developers.weixin.qq.com/miniprogram/introduction/custom.html#%E6%8E%A5%E6%94%B6%E6%B6%88%E6%81%AF%E6%8E%A8%E9%80%81 */

/// <summary>
/// 客服消息统一请求地址格式
/// </summary>
public static readonly string UrlFormat = Config.ApiMpHost + "/cgi-bin/message/custom/send?access_token={0}";
public static readonly string UrlFormat_Send = Config.ApiMpHost + "/cgi-bin/message/custom/send?access_token={0}";
public static readonly string UrlFormat_Send_Business = Config.ApiMpHost + "/cgi-bin/message/custom/business/send?access_token={0}";
public static readonly string UrlFormat_Typing = Config.ApiMpHost + "/cgi-bin/message/custom/typing?access_token={0}";
public static readonly string UrlFormat_Typing_Business = Config.ApiMpHost + "/cgi-bin/message/custom/business/typing?access_token={0}";


/// <summary>
/// 根据 BusinessId 获取 Send 接口的 UrlFormat
/// </summary>
/// <param name="businessId"></param>
/// <returns></returns>
private static string GetSendUrlFormat(string businessId = null)
{
return businessId.IsNullOrEmpty() ? UrlFormat_Send : UrlFormat_Send_Business;
}

/// <summary>
/// 根据 BusinessId 获取 Typing 接口的 UrlFormat
/// </summary>
/// <param name="businessId"></param>
/// <returns></returns>
private static string GetTypingUrlFormat(string businessId = null)
{
return businessId.IsNullOrEmpty() ? UrlFormat_Typing : UrlFormat_Typing_Business;
}

#region 同步方法

Expand All @@ -63,9 +91,10 @@ public class CustomApi
/// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
/// <param name="openId">普通用户(openid)</param>
/// <param name="content">文本消息内容</param>
/// <param name="businessId">添加 businessId 参数,则发送到子商户</param>
/// <param name="timeOut">代理请求超时时间(毫秒)</param>
/// <returns></returns>
public static WxJsonResult SendText(string accessTokenOrAppId, string openId, string content,
public static WxJsonResult SendText(string accessTokenOrAppId, string openId, string content, string businessId = null,
int timeOut = Config.TIME_OUT)
{
object data = null;
Expand All @@ -76,12 +105,15 @@ public static WxJsonResult SendText(string accessTokenOrAppId, string openId, st
text = new
{
content = content
}
},
businessid = businessId
};

return WxOpenApiHandlerWapper.TryCommonApi(accessToken =>
{
return CommonJsonSend.Send(accessToken, UrlFormat, data, timeOut: timeOut);
var urlFormat = GetSendUrlFormat(businessId);
var jsonSetting = new JsonSetting() { IgnoreNulls = true };
return CommonJsonSend.Send(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);

}, accessTokenOrAppId);
}
Expand Down Expand Up @@ -109,7 +141,7 @@ public static WxJsonResult SendImage(string accessTokenOrAppId, string openId, s

return WxOpenApiHandlerWapper.TryCommonApi(accessToken =>
{
return CommonJsonSend.Send(accessToken, UrlFormat, data, timeOut: timeOut);
return CommonJsonSend.Send(accessToken, UrlFormat_Send, data, timeOut: timeOut);

}, accessTokenOrAppId);
}
Expand Down Expand Up @@ -143,7 +175,7 @@ public static WxJsonResult SendLink(string accessTokenOrAppId, string openId, st

return WxOpenApiHandlerWapper.TryCommonApi(accessToken =>
{
return CommonJsonSend.Send(accessToken, Senparc.Weixin.MP.AdvancedAPIs.CustomApi.UrlFormat, data, timeOut: timeOut);
return CommonJsonSend.Send(accessToken, UrlFormat_Send, data, timeOut: timeOut);

}, accessTokenOrAppId);

Expand Down Expand Up @@ -177,7 +209,36 @@ public static WxJsonResult SendMiniProgramPage(string accessTokenOrAppId, string

return WxOpenApiHandlerWapper.TryCommonApi(accessToken =>
{
return CommonJsonSend.Send(accessToken, Senparc.Weixin.MP.AdvancedAPIs.CustomApi.UrlFormat, data, timeOut: timeOut);
return CommonJsonSend.Send(accessToken, UrlFormat_Send, data, timeOut: timeOut);

}, accessTokenOrAppId);
}

/// <summary>
/// 客服输入状态
/// </summary>
/// <param name="accessTokenOrAppId"></param>
/// <param name="touser">普通用户(openid)</param>
/// <param name="typingStatus">"Typing":对用户下发“正在输入"状态 "CancelTyping":取消对用户的”正在输入"状态</param>
/// <param name="businessId">添加 businessId 参数,则发送到子商户</param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static WxJsonResult GetTypingStatus(string accessTokenOrAppId, string touser, string typingStatus, string businessId = null, int timeOut = Config.TIME_OUT)
{
return WxOpenApiHandlerWapper.TryCommonApi(accessToken =>
{
var urlFormat = GetTypingUrlFormat(businessId);

var data = new
{
touser = touser,
command = typingStatus,
businessid = businessId
};

var jsonSetting = new JsonSetting() { IgnoreNulls = true };

return CommonJsonSend.Send<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting);

}, accessTokenOrAppId);
}
Expand All @@ -192,10 +253,10 @@ public static WxJsonResult SendMiniProgramPage(string accessTokenOrAppId, string
/// <param name="accessTokenOrAppId">AccessToken或AppId(推荐使用AppId,需要先注册)</param>
/// <param name="openId">普通用户(openid)</param>
/// <param name="content">文本消息内容</param>
/// <param name="businessId">添加 businessId 参数,则发送到子商户</param>
/// <param name="timeOut">代理请求超时时间(毫秒)</param>
/// <returns></returns>
public static async Task<WxJsonResult> SendTextAsync(string accessTokenOrAppId, string openId, string content,
int timeOut = Config.TIME_OUT)
public static async Task<WxJsonResult> SendTextAsync(string accessTokenOrAppId, string openId, string content, string businessId = null, int timeOut = Config.TIME_OUT)
{
object data = null;
data = new
Expand All @@ -205,12 +266,15 @@ public static async Task<WxJsonResult> SendTextAsync(string accessTokenOrAppId,
text = new
{
content = content
}
},
businessid = businessId
};

return await WxOpenApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
return await CommonJsonSend.SendAsync(accessToken, UrlFormat, data, timeOut: timeOut).ConfigureAwait(false);
var urlFormat = GetSendUrlFormat(businessId);
var jsonSetting = new JsonSetting() { IgnoreNulls = true };
return await CommonJsonSend.SendAsync(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting).ConfigureAwait(false);

}, accessTokenOrAppId);
}
Expand Down Expand Up @@ -239,7 +303,7 @@ public static async Task<WxJsonResult> SendImageAsync(string accessTokenOrAppId,

return await WxOpenApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
return await CommonJsonSend.SendAsync(accessToken, UrlFormat, data, timeOut: timeOut).ConfigureAwait(false);
return await CommonJsonSend.SendAsync(accessToken, UrlFormat_Send, data, timeOut: timeOut).ConfigureAwait(false);

}, accessTokenOrAppId);
}
Expand Down Expand Up @@ -273,7 +337,7 @@ public static async Task<WxJsonResult> SendLinkAsync(string accessTokenOrAppId,

return await WxOpenApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
return await CommonJsonSend.SendAsync(accessToken, Senparc.Weixin.MP.AdvancedAPIs.CustomApi.UrlFormat, data, timeOut: timeOut).ConfigureAwait(false);
return await CommonJsonSend.SendAsync(accessToken, UrlFormat_Send, data, timeOut: timeOut).ConfigureAwait(false);

}, accessTokenOrAppId).ConfigureAwait(false);

Expand Down Expand Up @@ -307,10 +371,40 @@ public static async Task<WxJsonResult> SendMiniProgramPageAsync(string accessTok

return await WxOpenApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
return await CommonJsonSend.SendAsync(accessToken, Senparc.Weixin.MP.AdvancedAPIs.CustomApi.UrlFormat, data, timeOut: timeOut).ConfigureAwait(false);
return await CommonJsonSend.SendAsync(accessToken, UrlFormat_Send, data, timeOut: timeOut).ConfigureAwait(false);

}, accessTokenOrAppId).ConfigureAwait(false);
}

/// <summary>
/// 【异步方法】客服输入状态
/// </summary>
/// <param name="accessTokenOrAppId"></param>
/// <param name="touser">普通用户(openid)</param>
/// <param name="typingStatus">"Typing":对用户下发“正在输入"状态 "CancelTyping":取消对用户的”正在输入"状态</param>
/// <param name="businessId">添加 businessId 参数,则发送到子商户</param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static async Task<WxJsonResult> GetTypingStatusAsync(string accessTokenOrAppId, string touser, string typingStatus, string businessId = null, int timeOut = Config.TIME_OUT)
{
return await WxOpenApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
var urlFormat = GetTypingUrlFormat(businessId);

var data = new
{
touser = touser,
command = typingStatus,
businessid = businessId
};

var jsonSetting = new JsonSetting() { IgnoreNulls = true };

return await CommonJsonSend.SendAsync<WxJsonResult>(accessToken, urlFormat, data, timeOut: timeOut, jsonSetting: jsonSetting).ConfigureAwait(false);

}, accessTokenOrAppId);
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,9 @@ and limitations under the License.

----------------------------------------------------------------*/

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Senparc.NeuChar;
using Senparc.Weixin.CommonAPIs;
using Senparc.Weixin.Entities;
using Senparc.Weixin.Helpers;
using Senparc.Weixin.HttpUtility;
using Senparc.Weixin.MP;
using System.Threading.Tasks;

namespace Senparc.Weixin.WxOpen.AdvancedAPIs.DataCube
{
Expand All @@ -63,7 +54,7 @@ public static class DataCubeApi
/// <param name="beginDate">结束日期,限定查询1天数据,end_date允许设置的最大值为昨日,如:20170312</param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static GetWeAnalysisAppidDailySummaryTrendResultJson GetWeAnalysisAppidDailySummaryTrend(string accessTokenOrAppId,string beginDate, string endDate, int timeOut = Config.TIME_OUT)
public static GetWeAnalysisAppidDailySummaryTrendResultJson GetWeAnalysisAppidDailySummaryTrend(string accessTokenOrAppId, string beginDate, string endDate, int timeOut = Config.TIME_OUT)
{
return WxOpenApiHandlerWapper.TryCommonApi(accessToken =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ and limitations under the License.
using Senparc.Weixin.CommonAPIs;
using Senparc.Weixin.Entities;
using Senparc.Weixin.Entities.TemplateMessage;
using Senparc.Weixin.MP;
using System.Threading.Tasks;

namespace Senparc.Weixin.WxOpen.AdvancedAPIs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ and limitations under the License.
API:https://mp.weixin.qq.com/debug/wxadoc/dev/api/notice.html#接口说明
*/

using System;
using System.Threading.Tasks;
using Senparc.NeuChar;
using Senparc.Weixin.CommonAPIs;
using Senparc.Weixin.Entities;
using Senparc.Weixin.MP;
using System;
using System.Threading.Tasks;

namespace Senparc.Weixin.WxOpen.AdvancedAPIs.Template
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,17 @@ and limitations under the License.

----------------------------------------------------------------*/

using System;
using System.IO;
using System.Threading.Tasks;
using Senparc.Weixin.CommonAPIs;
using Senparc.Weixin.Entities;
using Senparc.CO2NET.Extensions;
using Senparc.CO2NET.HttpUtility;
using Senparc.Weixin.MP;
using Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp.WxAppJson;
using Senparc.CO2NET.Helpers;
using Senparc.CO2NET.Helpers.Serializers;
using System.Collections.Generic;
using Senparc.CO2NET.HttpUtility;
using Senparc.NeuChar;
using Senparc.Weixin.CommonAPIs;
using Senparc.Weixin.Entities;
using Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp.WxAppJson;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

namespace Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ and limitations under the License.


创建标识:Senparc - 20170106

修改标识:Senparc - 20220504
修改描述:v3.15.2 添加小程序隐私权限审核结果推送


----------------------------------------------------------------*/

Expand All @@ -45,5 +49,10 @@ public override RequestMsgType MsgType
/// 文本消息内容
/// </summary>
public string Content { get; set; }

/// <summary>
/// 代表消息是从子商户的会话中过来的
/// </summary>
public string BusinessId { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
using Senparc.NeuChar.Exceptions;
using Senparc.NeuChar.MessageHandlers;
using Senparc.Weixin.WxOpen.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Senparc.Weixin.WxOpen.MessageHandlers
{
public class WxOpenMessageEntityEnlightener : MessageEntityEnlightener
public class WxOpenMessageEntityEnlightener : MessageEntityEnlightener
{
public static MessageEntityEnlightener Instance = new WxOpenMessageEntityEnlightener(NeuChar.PlatformType.WeChat_MiniProgram);

Expand Down
Loading