diff --git a/src/Shentun.Sms.Application.Contracts/SmsTasks/CreateSmsTaskDto.cs b/src/Shentun.Sms.Application.Contracts/SmsTasks/CreateSmsTaskDto.cs
index 3370bba..ab6090c 100644
--- a/src/Shentun.Sms.Application.Contracts/SmsTasks/CreateSmsTaskDto.cs
+++ b/src/Shentun.Sms.Application.Contracts/SmsTasks/CreateSmsTaskDto.cs
@@ -82,5 +82,10 @@ namespace Shentun.Sms.SmsTasks
/// 发送者用户名
///
public string? SenderName { get; set; }
+
+ ///
+ /// 短信模板ID
+ ///
+ public string TemplateId { get; set; }
}
}
diff --git a/src/Shentun.Sms.Application/Jobs/SmsSendJob.cs b/src/Shentun.Sms.Application/Jobs/SmsSendJob.cs
index 40f40ac..2b50e2c 100644
--- a/src/Shentun.Sms.Application/Jobs/SmsSendJob.cs
+++ b/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);
}
diff --git a/src/Shentun.Sms.Application/Jobs/SmsTaskJob.cs b/src/Shentun.Sms.Application/Jobs/SmsTaskJob.cs
index eecee93..76e2528 100644
--- a/src/Shentun.Sms.Application/Jobs/SmsTaskJob.cs
+++ b/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);
diff --git a/src/Shentun.Sms.Application/SmsTasks/SmsTaskAppService.cs b/src/Shentun.Sms.Application/SmsTasks/SmsTaskAppService.cs
index f86fa34..e774d22 100644
--- a/src/Shentun.Sms.Application/SmsTasks/SmsTaskAppService.cs
+++ b/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);
diff --git a/src/Shentun.Sms.Domain/SmsSends/SmsSendManager.cs b/src/Shentun.Sms.Domain/SmsSends/SmsSendManager.cs
index 5c1304a..29ab9d1 100644
--- a/src/Shentun.Sms.Domain/SmsSends/SmsSendManager.cs
+++ b/src/Shentun.Sms.Domain/SmsSends/SmsSendManager.cs
@@ -128,7 +128,9 @@ namespace Shentun.Sms.SmsSends
///
///
///
- public void SmsSendAsync(SmsSend smsSend, string CountryCode, string Content)
+ ///
+ ///
+ 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';
diff --git a/src/Shentun.Sms.HttpApi.Host/appsettings.json b/src/Shentun.Sms.HttpApi.Host/appsettings.json
index 0ec1c3d..a489549 100644
--- a/src/Shentun.Sms.HttpApi.Host/appsettings.json
+++ b/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": {
diff --git a/src/Shentun.Sms.Service/Sms/AliyunSms.cs b/src/Shentun.Sms.Service/Sms/AliyunSms.cs
index f9d4fb5..2c93df0 100644
--- a/src/Shentun.Sms.Service/Sms/AliyunSms.cs
+++ b/src/Shentun.Sms.Service/Sms/AliyunSms.cs
@@ -30,7 +30,7 @@ namespace Shentun.Sms.Service.Sms
///
/// 手机号前+86
///
- 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
diff --git a/src/Shentun.Sms.Service/Sms/SmsBase.cs b/src/Shentun.Sms.Service/Sms/SmsBase.cs
index 4f2c094..142159f 100644
--- a/src/Shentun.Sms.Service/Sms/SmsBase.cs
+++ b/src/Shentun.Sms.Service/Sms/SmsBase.cs
@@ -13,7 +13,8 @@ namespace Shentun.Sms.Service.Sms
///
/// 手机号码
/// 模板参数,跟模板ID对应的参数个数要一致
- public abstract void Send(string[] phoneNumbers, string[] templateParam);
+ /// 模板Id
+ public abstract void Send(string[] phoneNumbers, string[] templateParam, string templateId);
}
}
diff --git a/src/Shentun.Sms.Service/Sms/TencentSms.cs b/src/Shentun.Sms.Service/Sms/TencentSms.cs
index db9d85a..4ab5728 100644
--- a/src/Shentun.Sms.Service/Sms/TencentSms.cs
+++ b/src/Shentun.Sms.Service/Sms/TencentSms.cs
@@ -32,7 +32,8 @@ namespace Shentun.Sms.Service.Sms
///
/// 手机号前+86
///
- public override void Send(string[] phoneNumbers, string[] templateParam)
+ /// 模板ID
+ public override void Send(string[] phoneNumbers, string[] templateParam, string templateId)
{
/* 必要步骤:
* 实例化一个认证对象,入参需要传入腾讯云账户密钥对secretId,secretKey。
@@ -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 对应模板的变量个数保持一致,若无模板参数,则设置为空 */