Skip to content

Commit

Permalink
Merge pull request #2964 from JeffreySu/Developer
Browse files Browse the repository at this point in the history
Developer
  • Loading branch information
JeffreySu authored Dec 2, 2023
2 parents e94b82e + 5ed4239 commit d48a07c
Show file tree
Hide file tree
Showing 62 changed files with 2,971 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,37 @@ public void DeleteMenuTest()
Assert.IsNotNull(result);
Assert.AreEqual("ok", result.errmsg);
}


[TestMethod]
public void GetCurrentSelfMenuInfoTest()
{
var appIdOrFackAccessToken = base._senparcWeixinSetting.WeixinAppId;// "75_eGhUgdbNzwM8IcroXssnKN4sP9QSWPcMJUJe5Ka3UTTisGP_UorAZYLb1UCZyQtdsp798EwLdbURX-cfdbacKB-IuDJ_QHMnjTHYANlch3h8_YRAw_oyfZ4mwf8LODdACAUXM";//错误的AccessToken

var result = CommonApi.GetCurrentSelfMenuInfo(appIdOrFackAccessToken);

Console.WriteLine(result);
if (result.ErrorCodeValue == 0)
{
Assert.IsTrue(true);
}
else
{
Assert.IsTrue(false);
}

string json = "{\"is_menu_open\":1,\"selfmenu_info\":{\"button\":[{\"type\":\"click\",\"name\":\"今日歌曲\",\"key\":\"V1001_TODAY_MUSIC\"},{\"name\":\"菜单\",\"sub_button\":{\"list\":[{\"type\":\"view\",\"name\":\"搜索\",\"url\":\"http:\\/\\/www.soso.com\\/\"},{\"type\":\"click\",\"name\":\"赞一下我们\",\"key\":\"V1001_GOOD\"}]}}]}}";
try
{
var test = Newtonsoft.Json.JsonConvert.DeserializeObject<SelfMenuConfigResult>(json);
Console.WriteLine(test);
Assert.IsTrue(true);
}
catch (Exception)
{
Assert.IsTrue(false);
throw;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ and limitations under the License.
修改标识:JaneConan - 20230417
修改描述:v16.18.10.7 修复自定义菜单实体问题
修改标识:Senparc - 20231202
修改描述:v16.20.2 fix bug: self menu onfig result. PR #2963 / Issue #2804
----------------------------------------------------------------*/

using System.Collections.Generic;
Expand Down Expand Up @@ -84,7 +87,9 @@ public class MenuFull_RootButton


public List<MenuFull_RootButton> sub_button { get; set; }

}

#endregion

#region Conditional(个性化菜单)相关
Expand All @@ -93,6 +98,38 @@ public class MenuTryMatchResult : WxJsonResult
public List<MenuFull_RootButton> button { get; set; }
}

public class SelfMenuFull_ButtonGroup
{
public List<SelfMenuFull_RootButton> button { get; set; }
}
public class SelfMenuFull_RootButton
{
public string type { get; set; }
public string key { get; set; }
public string name { get; set; }
public string url { get; set; }

public NewsInfo news_info { get; set; }

#region 小程序

public string appid { get; set; }
public string pagepath { get; set; }

#endregion

public string media_id { get; set; }

public string article_id { get; set; }


public Sub_Button sub_button { get; set; }

}
public class Sub_Button
{
public List<MenuFull_RootButton> list { get; set; }
}
/// <summary>
/// 自定义菜单配置
/// </summary>
Expand All @@ -106,7 +143,7 @@ public class SelfMenuConfigResult : WxJsonResult
/// <summary>
/// 菜单信息
/// </summary>
public MenuFull_ButtonGroup selfmenu_info { get; set; }
public SelfMenuFull_ButtonGroup selfmenu_info { get; set; }

}

Expand Down
6 changes: 3 additions & 3 deletions src/Senparc.Weixin.MP/Senparc.Weixin.MP/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public enum Event
/// 点击菜单跳转小程序的事件推送
/// </summary>
view_miniprogram,

#region 微信认证事件推送
/// <summary>
/// 资质认证成功(此时立即获得接口权限)
Expand Down Expand Up @@ -408,7 +408,7 @@ public enum Event
/// </summary>
submit_invoice_title,
#endregion

#region 订阅通知
/// <summary>
/// 用户操作订阅通知弹窗 场景:用户在图文等场景内订阅通知的操作
Expand All @@ -423,7 +423,7 @@ public enum Event
/// <summary>
/// 发送订阅通知 场景:调用 bizsend 接口发送通知
/// </summary>
subscribe_msg_sent_event
subscribe_msg_sent_event,
#endregion
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ public virtual async Task<IResponseMessageBase> OnEventRequestAsync(IRequestMess
break;

#endregion

#region 微信电子发票
case Event.user_authorize_invoice:
responseMessage = await OnEvent_User_Authorize_InvoiceAsync(RequestMessage as RequestMessageEvent_User_Authorize_Invoice).ConfigureAwait(false);
break;
#endregion


default:
throw new Exceptions.UnknownRequestMsgTypeException("未知的Event下属请求信息", null);
}
Expand Down Expand Up @@ -735,6 +735,7 @@ public virtual async Task<IResponseMessageBase> OnEvent_Submit_Invoice_TitleAsyn
return await DefaultAsyncMethod(requestMessage, () => OnEvent_Submit_Invoice_Title(requestMessage)).ConfigureAwait(false);
}
#endregion

#region 订阅通知
/// <summary>
/// 用户管理订阅通知
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public virtual IResponseMessageBase OnEventRequest(IRequestMessageEventBase requ
responseMessage = OnEvent_Subscribe_Msg_SentRequest(RequestMessage as RequestMessageEvent_Subscribe_Msg_Sent);
break;


#region 卡券回调

case Event.giftcard_pay_done:
Expand Down Expand Up @@ -237,6 +236,7 @@ public virtual IResponseMessageBase OnEventRequest(IRequestMessageEventBase requ
// responseMessage = OnEvent_WeAppAuditFailRequest(RequestMessage as RequestMessageEvent_WeAppAuditFail);
// break;
#endregion

#region 微信电子发票
case Event.user_authorize_invoice:
responseMessage = OnEvent_User_Authorize_Invoice(RequestMessage as RequestMessageEvent_User_Authorize_Invoice);
Expand All @@ -245,6 +245,7 @@ public virtual IResponseMessageBase OnEventRequest(IRequestMessageEventBase requ
responseMessage = OnEvent_Submit_Invoice_Title(RequestMessage as RequestMessageEvent_Submit_Invoice_Title);
break;
#endregion

default:
throw new Exceptions.UnknownRequestMsgTypeException("未知的Event下属请求信息", null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0;netstandard2.1</TargetFrameworks>
<Version>16.20.1</Version>
<Version>16.20.2</Version>
<AssemblyName>Senparc.Weixin.MP</AssemblyName>
<RootNamespace>Senparc.Weixin.MP</RootNamespace>
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
Expand Down Expand Up @@ -527,6 +527,7 @@
v16.18.14 JSSDKHelper.GetNoncestr() 弃用 MD5 加密方法
v16.19.0 MessageHandler 和客服接口支持长文本自动切割后连续发送
v16.20.1 添加 TemplateApi.AddTemplate() 参数
v16.20.2 fix bug: self menu onfig result. PR #2963 / Issue #2804
</PackageReleaseNotes>
<RepositoryUrl>https://github.com/JeffreySu/WeiXinMPSDK</RepositoryUrl>
</PropertyGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/Senparc.Weixin.MP/Senparc.WeixinTests/BaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ namespace Senparc.WeixinTests
/// </summary>
public class BaseTest
{
protected static IServiceProvider _serviceProvider;
protected static SenparcSetting _senparcSetting;
protected static SenparcWeixinSetting _senparcWeixinSetting;
protected IServiceProvider _serviceProvider;
protected SenparcSetting _senparcSetting;
protected SenparcWeixinSetting _senparcWeixinSetting;

public BaseTest()
{
Expand Down Expand Up @@ -85,7 +85,7 @@ protected void RegisterStart()
/// <summary>
/// 注册 IServiceCollection 和 MemoryCache
/// </summary>
public static void RegisterServiceCollection()
public void RegisterServiceCollection()
{
var serviceCollection = new ServiceCollection();
var configBuilder = new ConfigurationBuilder();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Text;
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Senparc.WeixinTests.vs2017.CommonApis
{
Expand All @@ -11,11 +9,12 @@ public class CommonJsonSendTests : BaseTest
[TestMethod]
public void SendThrowTest()
{
var fakeAccessToken = "22_q1nIlrqQ1brYqvp-8xPV3eIWWSJ9LU_qCxs3AaTMVjv74WyD1XDovWi4SkMX6xfykOCMoobaVpzu-lspCsCWIo5u6DGw31tS3ZmFw4q7wEDkXOmBaTtCeQuhlvhsalkenoRCKTLckTnVCkXbTWZlCJANQT1";//错误的AccessToken
var appIdOrFackAccessToken = base._senparcWeixinSetting.WeixinAppId;// "22_q1nIlrqQ1brYqvp-8xPV3eIWWSJ9LU_qCxs3AaTMVjv74WyD1XDovWi4SkMX6xfykOCMoobaVpzu-lspCsCWIo5u6DGw31tS3ZmFw4q7wEDkXOmBaTtCeQuhlvhsalkenoRCKTLckTnVCkXbTWZlCJANQT1";//错误的AccessToken

try
{
//Senparc.Weixin.Config.ThrownWhenJsonResultFaild = true;//抛出异常(默认就是true)
var result = Senparc.Weixin.MP.AdvancedAPIs.UrlApi.ShortUrl(fakeAccessToken, "long2short", "https://sdk.weixin.senparc.com");
var result = Senparc.Weixin.MP.AdvancedAPIs.UrlApi.ShortUrl(appIdOrFackAccessToken, "long2short", "https://sdk.weixin.senparc.com");
Console.WriteLine("不应该到达这里");
Assert.Fail();//不应该到达这里
}
Expand All @@ -28,10 +27,11 @@ public void SendThrowTest()


Senparc.Weixin.Config.ThrownWhenJsonResultFaild = false;//不抛出异常
var result2 = Senparc.Weixin.MP.AdvancedAPIs.UrlApi.ShortUrl(fakeAccessToken, "long2short", "https://sdk.weixin.senparc.com");
var result2 = Senparc.Weixin.MP.AdvancedAPIs.UrlApi.ShortUrl(appIdOrFackAccessToken, "long2short", "https://sdk.weixin.senparc.com");
Console.WriteLine(result2);

Senparc.Weixin.Config.ThrownWhenJsonResultFaild = true;//还原
}

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0;netstandard2.1</TargetFrameworks>
<Version>4.17.0</Version>
<Version>4.17.1</Version>
<AssemblyName>Senparc.Weixin.Open</AssemblyName>
<RootNamespace>Senparc.Weixin.Open</RootNamespace>
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
Expand Down Expand Up @@ -219,7 +219,8 @@
v4.16.0
1、处理三方推送消息枚举
2、添加“小程序发货信息管理服务”
</PackageReleaseNotes>
v4.17.1 新增“小程序微信认证”功能
</PackageReleaseNotes>
<RepositoryUrl>https://github.com/JeffreySu/WeiXinMPSDK</RepositoryUrl>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public class SearchStatusApi
/// <param name="accessToken"></param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static GetWxaSearchStatusResultJson GetWxaSearchStatus(string accessToken, int timeOut = Config.TIME_OUT)
public static GetWxaSearchStatusJsonResult GetWxaSearchStatus(string accessToken, int timeOut = Config.TIME_OUT)
{
var url = string.Format(Config.ApiMpHost + "/wxa/getwxasearchstatus?access_token={0}", accessToken.AsUrlData());
return CommonJsonSend.Send<GetWxaSearchStatusResultJson>(null, url, null, CommonJsonSendType.GET, timeOut);
return CommonJsonSend.Send<GetWxaSearchStatusJsonResult>(null, url, null, CommonJsonSendType.GET, timeOut);
}

/// <summary>
Expand All @@ -82,10 +82,10 @@ public static WxJsonResult ChangeWxaSearchStatus(string accessToken, int status,
/// <param name="accessToken"></param>
/// <param name="timeOut"></param>
/// <returns></returns>
public static async Task<GetWxaSearchStatusResultJson> GetWxaSearchStatusAsync(string accessToken, int timeOut = Config.TIME_OUT)
public static async Task<GetWxaSearchStatusJsonResult> GetWxaSearchStatusAsync(string accessToken, int timeOut = Config.TIME_OUT)
{
var url = string.Format(Config.ApiMpHost + "/wxa/getwxasearchstatus?access_token={0}", accessToken.AsUrlData());
return await CommonJsonSend.SendAsync<GetWxaSearchStatusResultJson>(null, url, null, CommonJsonSendType.GET, timeOut);
return await CommonJsonSend.SendAsync<GetWxaSearchStatusJsonResult>(null, url, null, CommonJsonSendType.GET, timeOut);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Senparc.Weixin.Open.WxaAPIs.SearchStatus
/// <summary>
/// 获取搜索状态返回类型
/// </summary>
public class GetWxaSearchStatusResultJson : WxJsonResult
public class GetWxaSearchStatusJsonResult : WxJsonResult
{
/// <summary>
/// 1 表示不可搜索,0 表示可搜索
Expand Down
Loading

0 comments on commit d48a07c

Please sign in to comment.