Browse Source

0815

master
wxd 2 years ago
parent
commit
922b5f8b09
  1. 5
      src/Shentun.Sms.Application.Contracts/SmsTasks/CreateSmsTaskDto.cs
  2. 2
      src/Shentun.Sms.Application/Jobs/SmsSendJob.cs
  3. 2
      src/Shentun.Sms.Application/Jobs/SmsTaskJob.cs
  4. 2
      src/Shentun.Sms.Application/SmsTasks/SmsTaskAppService.cs
  5. 6
      src/Shentun.Sms.Domain/SmsSends/SmsSendManager.cs
  6. 3
      src/Shentun.Sms.HttpApi.Host/appsettings.json
  7. 2
      src/Shentun.Sms.Service/Sms/AliyunSms.cs
  8. 3
      src/Shentun.Sms.Service/Sms/SmsBase.cs
  9. 8
      src/Shentun.Sms.Service/Sms/TencentSms.cs

5
src/Shentun.Sms.Application.Contracts/SmsTasks/CreateSmsTaskDto.cs

@ -82,5 +82,10 @@ namespace Shentun.Sms.SmsTasks
/// 发送者用户名
/// </summary>
public string? SenderName { get; set; }
/// <summary>
/// 短信模板ID
/// </summary>
public string TemplateId { get; set; }
}
}

2
src/Shentun.Sms.Application/Jobs/SmsSendJob.cs

@ -70,7 +70,7 @@ namespace Shentun.Sms.Jobs
{
string CountryCode = item.CountryCode;
string Content = item.Content;
_smsSendManager.SmsSendAsync(item.a, CountryCode, Content);
_smsSendManager.SmsSendAsync(item.a, CountryCode, Content, "");
smsSendUpdateList.Add(item.a);
}

2
src/Shentun.Sms.Application/Jobs/SmsTaskJob.cs

@ -126,7 +126,7 @@ namespace Shentun.Sms.Jobs
string[] templateParam = smsTask.Content.Trim('|').Split("|", StringSplitOptions.RemoveEmptyEntries);
smsBase.Send(phoneNumber, templateParam);
smsBase.Send(phoneNumber, templateParam, "");
smsSendList.Add(smsSendEntity);

2
src/Shentun.Sms.Application/SmsTasks/SmsTaskAppService.cs

@ -210,7 +210,7 @@ namespace Shentun.Sms.SmsTasks
smsSendEntity = _smsSendManager.CreateAsync(smsSendEntity);
_smsSendManager.SmsSendAsync(smsSendEntity, smsTaskEntity.CountryCode, smsTaskEntity.Content);
_smsSendManager.SmsSendAsync(smsSendEntity, smsTaskEntity.CountryCode, smsTaskEntity.Content, input.TemplateId);
smsTaskEntity = await _smsTaskRepository.InsertAsync(smsTaskEntity, true);
smsSendEntity = await _smsSendRepository.InsertAsync(smsSendEntity);

6
src/Shentun.Sms.Domain/SmsSends/SmsSendManager.cs

@ -128,7 +128,9 @@ namespace Shentun.Sms.SmsSends
/// </summary>
/// <param name="smsSend"></param>
/// <param name="CountryCode"></param>
public void SmsSendAsync(SmsSend smsSend, string CountryCode, string Content)
/// <param name="Content"></param>
/// <param name="templateId"></param>
public void SmsSendAsync(SmsSend smsSend, string CountryCode, string Content,string templateId)
{
if (!string.IsNullOrEmpty(CountryCode) && !string.IsNullOrEmpty(smsSend.MobileTelephone))
{
@ -138,7 +140,7 @@ namespace Shentun.Sms.SmsSends
string[] templateParam = Content.Trim('|').Split("|", StringSplitOptions.RemoveEmptyEntries);
smsBase.Send(phoneNumber, templateParam);
smsBase.Send(phoneNumber, templateParam, templateId);
}
smsSend.IsActive = 'N';
smsSend.IsComplete = 'Y';

3
src/Shentun.Sms.HttpApi.Host/appsettings.json

@ -5,7 +5,7 @@
"RedirectAllowedUrls": ""
},
"ConnectionStrings": {
"Default": "Host=62.156.10.86;Port=5432;Database=ShentunSms;User ID=postgres;Password=st123;"
"Default": "Host=140.143.162.39;Port=5432;Database=ShentunSms;User ID=postgres;Password=shentun123;"
},
"AuthServer": {
"Authority": "http://localhost:9630",
@ -47,6 +47,7 @@
"SmsSdkAppid": "1400452290", // ID
"SignName": "长沙神豚科技", //
"TemplateId": "785039", //ID
"NoticeTemplateId": "2238651", //ID
"Timeout": 60 //
},
"AliyunSms": {

2
src/Shentun.Sms.Service/Sms/AliyunSms.cs

@ -30,7 +30,7 @@ namespace Shentun.Sms.Service.Sms
/// </summary>
/// <param name="phoneNumbers">手机号前+86</param>
/// <param name="templateParam"></param>
public override void Send(string[] phoneNumbers, string[] templateParam)
public override void Send(string[] phoneNumbers, string[] templateParam,string templateId)
{
AlibabaCloud.SDK.Dysmsapi20170525.Client client = CreateClient();
AlibabaCloud.SDK.Dysmsapi20170525.Models.SendSmsRequest sendSmsRequest = new AlibabaCloud.SDK.Dysmsapi20170525.Models.SendSmsRequest

3
src/Shentun.Sms.Service/Sms/SmsBase.cs

@ -13,7 +13,8 @@ namespace Shentun.Sms.Service.Sms
/// </summary>
/// <param name="phoneNumbers">手机号码</param>
/// <param name="templateParam">模板参数,跟模板ID对应的参数个数要一致</param>
public abstract void Send(string[] phoneNumbers, string[] templateParam);
/// <param name="templateId">模板Id</param>
public abstract void Send(string[] phoneNumbers, string[] templateParam, string templateId);
}
}

8
src/Shentun.Sms.Service/Sms/TencentSms.cs

@ -32,7 +32,8 @@ namespace Shentun.Sms.Service.Sms
/// </summary>
/// <param name="phoneNumbers">手机号前+86</param>
/// <param name="templateParam"></param>
public override void Send(string[] phoneNumbers, string[] templateParam)
/// <param name="templateId">模板ID</param>
public override void Send(string[] phoneNumbers, string[] templateParam, string templateId)
{
/*
* secretIdsecretKey
@ -102,9 +103,12 @@ namespace Shentun.Sms.Service.Sms
req.SignName = _tencentSmsConfig["TencentSms:SignName"];
if (string.IsNullOrWhiteSpace(templateId))
templateId = _tencentSmsConfig["TencentSms:TemplateId"];
/* 模板 ID: 必须填写已审核通过的模板 ID */
// 模板 ID 可前往 [国内短信](https://console.cloud.tencent.com/smsv2/csms-template) 或 [国际/港澳台短信](https://console.cloud.tencent.com/smsv2/isms-template) 的正文模板管理查看
req.TemplateId = _tencentSmsConfig["TencentSms:TemplateId"];
req.TemplateId = templateId;
/* 模板参数: 模板参数的个数需要与 TemplateId 对应模板的变量个数保持一致,若无模板参数,则设置为空 */

Loading…
Cancel
Save