|
@@ -1,5 +1,6 @@
|
|
|
using Hotline.Settings;
|
|
|
using Hotline.Share.Dtos.Snapshot;
|
|
|
+using Hotline.Share.Tools;
|
|
|
using Hotline.ThirdAccountDomainServices.Interfaces;
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
using Senparc.CO2NET.Extensions;
|
|
@@ -27,6 +28,7 @@ public class WeChatService : IThirdIdentiyService, IScopeDependency
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+ GetWebApiHost(dto.WebApiHost);
|
|
|
var result = await SnsApi.JsCode2JsonAsync(dto.AppId, dto.Secret, dto.LoginCode);
|
|
|
_systemLog.Add("微信获取Token", dto, status: 1, executeResult: result.ToJson());
|
|
|
if (result.errcode != ReturnCode.请求成功) throw UserFriendlyException.SameMessage("获取微信用户信息失败");
|
|
@@ -47,6 +49,7 @@ public class WeChatService : IThirdIdentiyService, IScopeDependency
|
|
|
/// <returns></returns>
|
|
|
public async Task<ThirdPhoneOutDto> GetPhoneNumberAsync(ThirdTokenDto dto, CancellationToken token)
|
|
|
{
|
|
|
+ GetWebApiHost(dto.WebApiHost);
|
|
|
await AccessTokenContainer.RegisterAsync(dto.AppId, dto.Secret);
|
|
|
_logger.LogInformation($"GetPhoneNumberAsync: {dto.ToJson()}");
|
|
|
var result = await BusinessApi.GetUserPhoneNumberAsync(dto.AppId, dto.TelCode);
|
|
@@ -61,4 +64,10 @@ public class WeChatService : IThirdIdentiyService, IScopeDependency
|
|
|
PhoneNumber = result.phone_info?.phoneNumber,
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
+ private void GetWebApiHost(string? webApiHost)
|
|
|
+ {
|
|
|
+ if (webApiHost.NotNullOrEmpty())
|
|
|
+ Config.ApiMpHost = webApiHost;
|
|
|
+ }
|
|
|
}
|