diff --git a/CoreCms.Net.Configuration/GlobalEnumVars.cs b/CoreCms.Net.Configuration/GlobalEnumVars.cs
index ea958e7a..a64931ca 100644
--- a/CoreCms.Net.Configuration/GlobalEnumVars.cs
+++ b/CoreCms.Net.Configuration/GlobalEnumVars.cs
@@ -1632,6 +1632,25 @@ namespace CoreCms.Net.Configuration
#region 短信相关=====================================================
+ ///
+ /// 短信发送平台
+ ///
+ public enum SmsType
+ {
+ ///
+ /// 凯信通
+ ///
+ [Description("凯信通")]
+ KingTto = 1,
+ ///
+ /// 阿里云
+ ///
+ [Description("阿里云")]
+ AliYun = 2,
+
+ }
+
+
///
/// 短信消息分类
///
@@ -3340,5 +3359,35 @@ namespace CoreCms.Net.Configuration
#endregion
+ #region 抽奖活动
+
+ ///
+ /// 抽奖活动类型
+ ///
+ public enum LuckyType
+ {
+ ///
+ /// 大转盘
+ ///
+ [Description("大转盘")]
+ LuckyWheel = 1,
+
+ ///
+ /// 九宫格
+ ///
+ [Description("九宫格")]
+ LuckyGrid = 2,
+
+ ///
+ /// 老虎机
+ ///
+ [Description("老虎机")]
+ SlotMachine = 3
+
+ }
+
+ #endregion
+
+
}
}
diff --git a/CoreCms.Net.Configuration/SystemSettingConstVars.cs b/CoreCms.Net.Configuration/SystemSettingConstVars.cs
index 76f74055..29ed9ee9 100644
--- a/CoreCms.Net.Configuration/SystemSettingConstVars.cs
+++ b/CoreCms.Net.Configuration/SystemSettingConstVars.cs
@@ -628,6 +628,12 @@ namespace CoreCms.Net.Configuration
/// 是否开启短信
///
public const string SmsEnabled = "smsEnabled";
+
+ ///
+ /// 短信类型
+ ///
+ public const string SmsType = "smsType";
+
///
/// 用户ID
///
@@ -664,62 +670,126 @@ namespace CoreCms.Net.Configuration
///
public const string SmsIpSendBlackList = "smsIpSendBlackList";
+ #region 凯信通短信常量
+
///
- /// 账户注册-短信内容模板
+ /// 凯信通-账户注册-短信内容模板
///
public const string SmsTplForReg = "smsTplForReg";
///
- /// 账户登录-短信内容模板
+ /// 凯信通-账户登录-短信内容模板
///
public const string SmsTplForLogin = "smsTplForLogin";
///
- /// 验证验证码-短信内容模板
+ /// 凯信通-验证验证码-短信内容模板
///
public const string SmsTplForVeri = "smsTplForVeri";
///
- /// 下单成功时-短信内容模板
+ /// 凯信通-下单成功时-短信内容模板
///
public const string SmsTplForCreateOrder = "smsTplForCreateOrder";
///
- /// 订单支付成功时-短信内容模板
+ /// 凯信通-订单支付成功时-短信内容模板
///
public const string SmsTplForOrderPayed = "smsTplForOrderPayed";
///
- /// 订单催付提醒-短信内容模板
+ /// 凯信通-订单催付提醒-短信内容模板
///
public const string SmsTplForRemindOrderPay = "smsTplForRemindOrderPay";
///
- /// 订单发货通知-短信内容模板
+ /// 凯信通-订单发货通知-短信内容模板
///
public const string SmsTplForDeliveryNotice = "smsTplForDeliveryNotice";
///
- /// 售后确认通过-短信内容模板
+ /// 凯信通-售后确认通过-短信内容模板
///
public const string SmsTplForAfterSalesPass = "smsTplForAfterSalesPass";
///
- /// 用户退款成功通知-短信内容模板
+ /// 凯信通-用户退款成功通知-短信内容模板
///
public const string SmsTplForRefundSuccess = "smsTplForRefundSuccess";
///
- /// 订单付款成功平台通知-短信内容模板
+ /// 凯信通-订单付款成功平台通知-短信内容模板
///
public const string SmsTplForSellerOrderNotice = "smsTplForSellerOrderNotice";
///
- /// 通用类型-短信内容模板
+ /// 凯信通-通用类型-短信内容模板
///
public const string SmsTplForCommon = "smsTplForCommon";
+ #endregion
+
+ #region 阿里云短信常量
+
+ ///
+ /// 阿里云-账户注册-短信内容模板
+ ///
+ public const string SmsAliYunTplForReg = "smsAliYunTplForReg";
+
+ ///
+ /// 阿里云-账户登录-短信内容模板
+ ///
+ public const string SmsAliYunTplForLogin = "smsAliYunTplForLogin";
+
+ ///
+ /// 阿里云-验证验证码-短信内容模板
+ ///
+ public const string SmsAliYunTplForVeri = "smsAliYunTplForVeri";
+
+ ///
+ /// 阿里云-下单成功时-短信内容模板
+ ///
+ public const string SmsAliYunTplForCreateOrder = "smsAliYunTplForCreateOrder";
+
+ ///
+ /// 阿里云-订单支付成功时-短信内容模板
+ ///
+ public const string SmsAliYunTplForOrderPayed = "smsAliYunTplForOrderPayed";
+
+ ///
+ /// 阿里云-订单催付提醒-短信内容模板
+ ///
+ public const string SmsAliYunTplForRemindOrderPay = "smsAliYunTplForRemindOrderPay";
+
+ ///
+ /// 阿里云-订单发货通知-短信内容模板
+ ///
+ public const string SmsAliYunTplForDeliveryNotice = "smsAliYunTplForDeliveryNotice";
+
+ ///
+ /// 阿里云-售后确认通过-短信内容模板
+ ///
+ public const string SmsAliYunTplForAfterSalesPass = "smsAliYunTplForAfterSalesPass";
+
+ ///
+ /// 阿里云-用户退款成功通知-短信内容模板
+ ///
+ public const string SmsAliYunTplForRefundSuccess = "smsAliYunTplForRefundSuccess";
+
+ ///
+ /// 阿里云-订单付款成功平台通知-短信内容模板
+ ///
+ public const string SmsAliYunTplForSellerOrderNotice = "smsAliYunTplForSellerOrderNotice";
+
+ ///
+ /// 阿里云-通用类型-短信内容模板
+ ///
+ public const string SmsAliYunTplForCommon = "smsAliYunTplForCommon";
+
+ #endregion
+
+
//网络打印机============================================================================
///
/// 是否开启
diff --git a/CoreCms.Net.Configuration/SystemSettingDictionary.cs b/CoreCms.Net.Configuration/SystemSettingDictionary.cs
index d950205c..89ede6f1 100644
--- a/CoreCms.Net.Configuration/SystemSettingDictionary.cs
+++ b/CoreCms.Net.Configuration/SystemSettingDictionary.cs
@@ -208,11 +208,14 @@ namespace CoreCms.Net.Configuration
di.Add(SystemSettingConstVars.ShowApiAppid, new DictionaryKeyValues() { sKey = "AppId", sValue = "" });
di.Add(SystemSettingConstVars.ShowApiSecret, new DictionaryKeyValues() { sKey = "授权Secret", sValue = "" });
- //凯信通短信设置
+ //短信通用设置
di.Add(SystemSettingConstVars.SmsEnabled, new DictionaryKeyValues() { sKey = "是否开启短信", sValue = "1" });
+ // 1凯信通 2阿里云
+ di.Add(SystemSettingConstVars.SmsType, new DictionaryKeyValues() { sKey = "短信类型", sValue = "1" });
+
di.Add(SystemSettingConstVars.SmsUserId, new DictionaryKeyValues() { sKey = "用户ID", sValue = "" });
- di.Add(SystemSettingConstVars.SmsAccount, new DictionaryKeyValues() { sKey = "账号", sValue = "" });
- di.Add(SystemSettingConstVars.SmsPassword, new DictionaryKeyValues() { sKey = "密码", sValue = "" });
+ di.Add(SystemSettingConstVars.SmsAccount, new DictionaryKeyValues() { sKey = "账号(AppKey)", sValue = "" });
+ di.Add(SystemSettingConstVars.SmsPassword, new DictionaryKeyValues() { sKey = "密码(AppSecret)", sValue = "" });
di.Add(SystemSettingConstVars.SmsApiUrl, new DictionaryKeyValues() { sKey = "Api地址", sValue = "http://sms.corecms.net:9999/sms.aspx" });
di.Add(SystemSettingConstVars.SmsSignature, new DictionaryKeyValues() { sKey = "短信签名", sValue = "" });
di.Add(SystemSettingConstVars.SmsIpSendNumber, new DictionaryKeyValues() { sKey = "单Ip每日发送量", sValue = "20" });
@@ -235,7 +238,7 @@ namespace CoreCms.Net.Configuration
di.Add(SystemSettingConstVars.FilesStorageAliYunBucketName, new DictionaryKeyValues() { sKey = "阿里云桶名称", sValue = "CoreShop" });
di.Add(SystemSettingConstVars.FilesStorageQiNiuBucketName, new DictionaryKeyValues() { sKey = "七牛云桶名称", sValue = "CoreShop" });
- //短信发送内容模板
+ //凯信通短信发送内容模板
di.Add(SystemSettingConstVars.SmsTplForReg, new DictionaryKeyValues() { sKey = "账户注册", sValue = "您正在注册账号,验证码是{code},请勿告诉他人。" });
di.Add(SystemSettingConstVars.SmsTplForLogin, new DictionaryKeyValues() { sKey = "账户登录", sValue = "您正在登陆账号,验证码是{code},请勿告诉他人。" });
di.Add(SystemSettingConstVars.SmsTplForVeri, new DictionaryKeyValues() { sKey = "验证验证码", sValue = "您的验证码是{code},请勿告诉他人。" });
@@ -248,6 +251,18 @@ namespace CoreCms.Net.Configuration
di.Add(SystemSettingConstVars.SmsTplForSellerOrderNotice, new DictionaryKeyValues() { sKey = "订单付款成功平台通知", sValue = "您有新的订单了,请及时处理。" });
di.Add(SystemSettingConstVars.SmsTplForCommon, new DictionaryKeyValues() { sKey = "通用类型", sValue = "欢迎您访问我们的微信小程序,有问题请联系客服。" });
+ //阿里云短信发送内容模板
+ di.Add(SystemSettingConstVars.SmsAliYunTplForReg, new DictionaryKeyValues() { sKey = "账户注册", sValue = "" });
+ di.Add(SystemSettingConstVars.SmsAliYunTplForLogin, new DictionaryKeyValues() { sKey = "账户登录", sValue = "" });
+ di.Add(SystemSettingConstVars.SmsAliYunTplForVeri, new DictionaryKeyValues() { sKey = "验证验证码", sValue = "" });
+ di.Add(SystemSettingConstVars.SmsAliYunTplForCreateOrder, new DictionaryKeyValues() { sKey = "下单成功时", sValue = "" });
+ di.Add(SystemSettingConstVars.SmsAliYunTplForOrderPayed, new DictionaryKeyValues() { sKey = "订单支付成功时", sValue = "" });
+ di.Add(SystemSettingConstVars.SmsAliYunTplForRemindOrderPay, new DictionaryKeyValues() { sKey = "订单催付提醒", sValue = "" });
+ di.Add(SystemSettingConstVars.SmsAliYunTplForDeliveryNotice, new DictionaryKeyValues() { sKey = "订单发货通知", sValue = "" });
+ di.Add(SystemSettingConstVars.SmsAliYunTplForAfterSalesPass, new DictionaryKeyValues() { sKey = "售后确认通过", sValue = "" });
+ di.Add(SystemSettingConstVars.SmsAliYunTplForRefundSuccess, new DictionaryKeyValues() { sKey = "用户退款成功通知", sValue = "" });
+ di.Add(SystemSettingConstVars.SmsAliYunTplForSellerOrderNotice, new DictionaryKeyValues() { sKey = "订单付款成功平台通知", sValue = "" });
+ di.Add(SystemSettingConstVars.SmsAliYunTplForCommon, new DictionaryKeyValues() { sKey = "通用类型", sValue = "" });
//自提运费设置
di.Add(SystemSettingConstVars.IntraCityServiceBy2KM, new DictionaryKeyValues() { sKey = "2公里内", sValue = "0" });
diff --git a/CoreCms.Net.Model/CoreCms.Net.Model.xml b/CoreCms.Net.Model/CoreCms.Net.Model.xml
index bdd98be2..69b9c80c 100644
--- a/CoreCms.Net.Model/CoreCms.Net.Model.xml
+++ b/CoreCms.Net.Model/CoreCms.Net.Model.xml
@@ -12218,26 +12218,6 @@
图片地址
-
-
- 序列
-
-
-
-
- 标题
-
-
-
-
- 排序
-
-
-
-
- 图片地址
-
-
wx返回Name/Type格式实体
@@ -12627,6 +12607,11 @@
是否开启
+
+
+ 短信类型
+
+
用户序列
@@ -12667,6 +12652,61 @@
短信发送IP黑名单
+
+
+ 阿里云-模板-账户注册
+
+
+
+
+ 阿里云-模板-账户登录
+
+
+
+
+ 阿里云-模板-验证验证码
+
+
+
+
+ 阿里云-模板-下单成功时
+
+
+
+
+ 阿里云-模板-订单支付成功时
+
+
+
+
+ 阿里云-模板-订单催付提醒
+
+
+
+
+ 阿里云-模板-订单发货通知
+
+
+
+
+ 阿里云-模板-售后确认通过
+
+
+
+
+ 阿里云-模板-用户退款成功通知
+
+
+
+
+ 阿里云-模板-订单付款成功平台通知
+
+
+
+
+ 阿里云-模板-通用类型
+
+
短信发送回调结果
diff --git a/CoreCms.Net.Model/ViewModels/Sms/SMSOptions.cs b/CoreCms.Net.Model/ViewModels/Sms/SMSOptions.cs
index 19b152fb..22afac23 100644
--- a/CoreCms.Net.Model/ViewModels/Sms/SMSOptions.cs
+++ b/CoreCms.Net.Model/ViewModels/Sms/SMSOptions.cs
@@ -21,6 +21,11 @@ namespace CoreCms.Net.Model.ViewModels.Sms
///
public bool Enabled { get; set; }
+ ///
+ /// 短信类型
+ ///
+ public int SmsType { get; set; }
+
///
/// 用户序列
///
@@ -62,6 +67,50 @@ namespace CoreCms.Net.Model.ViewModels.Sms
///
public string SmsIpSendBlackList { get; set; }
+ ///
+ /// 阿里云-模板-账户注册
+ ///
+ public string SmsAliYunTplForReg { get; set; }
+ ///
+ /// 阿里云-模板-账户登录
+ ///
+ public string SmsAliYunTplForLogin { get; set; }
+ ///
+ /// 阿里云-模板-验证验证码
+ ///
+ public string SmsAliYunTplForVeri { get; set; }
+ ///
+ /// 阿里云-模板-下单成功时
+ ///
+ public string SmsAliYunTplForCreateOrder { get; set; }
+ ///
+ /// 阿里云-模板-订单支付成功时
+ ///
+ public string SmsAliYunTplForOrderPayed { get; set; }
+ ///
+ /// 阿里云-模板-订单催付提醒
+ ///
+ public string SmsAliYunTplForRemindOrderPay { get; set; }
+ ///
+ /// 阿里云-模板-订单发货通知
+ ///
+ public string SmsAliYunTplForDeliveryNotice { get; set; }
+ ///
+ /// 阿里云-模板-售后确认通过
+ ///
+ public string SmsAliYunTplForAfterSalesPass { get; set; }
+ ///
+ /// 阿里云-模板-用户退款成功通知
+ ///
+ public string SmsAliYunTplForRefundSuccess { get; set; }
+ ///
+ /// 阿里云-模板-订单付款成功平台通知
+ ///
+ public string SmsAliYunTplForSellerOrderNotice { get; set; }
+ ///
+ /// 阿里云-模板-通用类型
+ ///
+ public string SmsAliYunTplForCommon { get; set; }
}
diff --git a/CoreCms.Net.Services/CoreCms.Net.Services.csproj b/CoreCms.Net.Services/CoreCms.Net.Services.csproj
index b746a657..e3fc9366 100644
--- a/CoreCms.Net.Services/CoreCms.Net.Services.csproj
+++ b/CoreCms.Net.Services/CoreCms.Net.Services.csproj
@@ -5,6 +5,7 @@
+
diff --git a/CoreCms.Net.Services/Message/CoreCmsSmsServices.cs b/CoreCms.Net.Services/Message/CoreCmsSmsServices.cs
index 92fcc799..db601710 100644
--- a/CoreCms.Net.Services/Message/CoreCmsSmsServices.cs
+++ b/CoreCms.Net.Services/Message/CoreCmsSmsServices.cs
@@ -22,12 +22,16 @@ using CoreCms.Net.Model.ViewModels.Sms;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Utility.Extensions;
using CoreCms.Net.Utility.Helper;
+using Essensoft.Paylink.Alipay.Domain;
+using Essensoft.Paylink.WeChatPay.V3.Domain;
using Flurl.Http;
using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Routing.Template;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SqlSugar;
+using Tea;
using static SKIT.FlurlHttpClient.Wechat.Api.Models.WxaApiUserLogSearchResponse.Types.Data.Types.RealtimeLog.Types;
@@ -126,26 +130,125 @@ namespace CoreCms.Net.Services
{
code = codeNumber
};
- switch (type)
+ if (type == "login")
{
- case "login":
+ if (smsOptions.SmsType == (int)GlobalEnumVars.SmsType.KingTto)
+ {
oldLog.contentBody = "您本次登陆的验证码是:" + codeNumber + ",请不要将验证码泄露给他人!";
oldLog.parameters = JsonConvert.SerializeObject(obj);
- break;
- default:
+ }
+ else if (smsOptions.SmsType == (int)GlobalEnumVars.SmsType.AliYun)
+ {
+ oldLog.contentBody = smsOptions.SmsAliYunTplForLogin;
+ oldLog.parameters = JsonConvert.SerializeObject(new
+ {
+ code = codeNumber.ToString()
+ });
+ }
+ }
+ else
+ {
+ if (smsOptions.SmsType == (int)GlobalEnumVars.SmsType.KingTto)
+ {
oldLog.contentBody = "您验证码是:" + codeNumber + ",请不要将验证码泄露给他人!";
oldLog.parameters = JsonConvert.SerializeObject(obj);
- break;
+ }
+ else if (smsOptions.SmsType == (int)GlobalEnumVars.SmsType.AliYun)
+ {
+ oldLog.contentBody = smsOptions.SmsAliYunTplForVeri;
+ oldLog.parameters = JsonConvert.SerializeObject(new
+ {
+ code = codeNumber.ToString()
+ });
+ }
}
await _dal.InsertAsync(oldLog);
}
- var result = await SendSms(oldLog.mobile, oldLog.contentBody, smsOptions);
+ if (smsOptions.SmsType == (int)GlobalEnumVars.SmsType.KingTto)
+ {
+ var result = await SendSms(oldLog.mobile, oldLog.contentBody, smsOptions);
- jm.status = result.IsSuccess;
- jm.msg = result.IsSuccess ? "发送成功" : result.Message;
- jm.otherData = result;
+ jm.status = result.IsSuccess;
+ jm.msg = result.IsSuccess ? "发送成功" : result.Message;
+ jm.otherData = result;
+ }
+ else if (smsOptions.SmsType == (int)GlobalEnumVars.SmsType.AliYun)
+ {
+
+ if (type == "login" && string.IsNullOrEmpty(smsOptions.SmsAliYunTplForLogin))
+ {
+ jm.msg = "阿里云登录短信模板未设置";
+ return jm;
+ }
+
+ if (type != "login" && string.IsNullOrEmpty(smsOptions.SmsAliYunTplForVeri))
+ {
+ jm.msg = "阿里云验证码短信模板未设置";
+ return jm;
+ }
+
+ var config = new AlibabaCloud.OpenApiClient.Models.Config
+ {
+ // 必填,您的 AccessKey ID
+ AccessKeyId = smsOptions.Account,
+ // 必填,您的 AccessKey Secret
+ AccessKeySecret = smsOptions.Password,
+ //Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
+ Endpoint = smsOptions.ApiUrl,
+
+ };
+ var client = new AlibabaCloud.SDK.Dysmsapi20170525.Client(config);
+
+ var sendSmsRequest = new AlibabaCloud.SDK.Dysmsapi20170525.Models.SendSmsRequest();
+ var runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
+
+ try
+ {
+ sendSmsRequest.SignName = smsOptions.Signature;
+ sendSmsRequest.PhoneNumbers = mobile;
+ sendSmsRequest.TemplateCode =
+ type == "login" ? smsOptions.SmsAliYunTplForLogin : smsOptions.SmsAliYunTplForVeri;
+ sendSmsRequest.TemplateParam = JsonConvert.SerializeObject(new
+ {
+ code = codeNumber.ToString()
+ });
+ sendSmsRequest.OutId = Guid.NewGuid().ToString();
+
+ var result = await client.SendSmsWithOptionsAsync(sendSmsRequest, runtime);
+
+ if (result.Body.Code == "OK")
+ {
+ jm.status = true;
+ jm.msg = "发送成功";
+ }
+ else
+ {
+ jm.status = false;
+ jm.msg = "发送失败:" + result.Body.Message;
+ }
+
+ jm.otherData = result;
+
+ }
+ catch (TeaException error)
+ {
+ jm.status = false;
+ jm.msg = "发送失败:" + error.Message;
+ }
+ catch (Exception _error)
+ {
+ var error = new TeaException(new Dictionary
+ {
+ { "message", _error.Message }
+ });
+
+ jm.status = false;
+ jm.msg = "发送失败:" + _error.Message;
+ jm.otherData = error.Data["Recommend"];
+ }
+ }
return jm;
}
#endregion
@@ -274,11 +377,11 @@ namespace CoreCms.Net.Services
return jm;
}
var isUsed = false;
+ string codeNumberStr = string.Empty;
if (code == GlobalEnumVars.SmsMessageTypes.Reg.ToString() || code == GlobalEnumVars.SmsMessageTypes.Login.ToString() || code == GlobalEnumVars.SmsMessageTypes.Veri.ToString())
{
var newCreateTime = DateTime.Now.AddSeconds(-60);
- var smsInfo = await _dal.QueryByClauseAsync(p =>
- p.mobile == mobile && p.code == code && p.createTime < newCreateTime && p.isUsed == false);
+ var smsInfo = await _dal.QueryByClauseAsync(p => p.mobile == mobile && p.code == code && p.createTime < newCreateTime && p.isUsed == false);
if (smsInfo != null)
{
var ts = dt - smsInfo.createTime;
@@ -288,6 +391,10 @@ namespace CoreCms.Net.Services
return jm;
}
parameters = JObject.Parse(smsInfo.parameters);
+ if (parameters.TryGetValue("code", out var parameter))
+ {
+ codeNumberStr = parameter?.ToString();
+ }
}
else
{
@@ -298,6 +405,7 @@ namespace CoreCms.Net.Services
parameters.Remove("code");
}
parameters.Add("code", codeNumber);
+ codeNumberStr = codeNumber.ToString();
}
isUsed = false;
}
@@ -309,132 +417,258 @@ namespace CoreCms.Net.Services
var str = string.Empty;
var allConfigs = await _settingServices.GetConfigDictionaries();
- if (code == GlobalEnumVars.SmsMessageTypes.Reg.ToString())
+ if (smsOptions.SmsType == (int)GlobalEnumVars.SmsType.KingTto)
{
- // 账户注册
- var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForReg);
- if (!string.IsNullOrEmpty(msg))
+
+ if (code == GlobalEnumVars.SmsMessageTypes.Reg.ToString())
{
- var sendCode = string.Empty;
- if (parameters.ContainsKey("code"))
+ // 账户注册
+ var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForReg);
+ if (!string.IsNullOrEmpty(msg))
{
- sendCode = parameters["code"]?.ToString();
+ str = msg.Replace("{code}", codeNumberStr);
}
- str = msg.Replace("{code}", sendCode);
}
- }
- else if (code == GlobalEnumVars.SmsMessageTypes.Login.ToString())
- {
- // 账户登录
- var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForLogin);
- if (!string.IsNullOrEmpty(msg))
+ else if (code == GlobalEnumVars.SmsMessageTypes.Login.ToString())
{
- var sendCode = string.Empty;
- if (parameters.ContainsKey("code"))
+ // 账户登录
+ var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForLogin);
+ if (!string.IsNullOrEmpty(msg))
{
- sendCode = parameters["code"]?.ToString();
+ str = msg.Replace("{code}", codeNumberStr);
}
- str = msg.Replace("{code}", sendCode);
}
- }
- else if (code == GlobalEnumVars.SmsMessageTypes.Veri.ToString())
- {
- // 验证验证码
- var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForVeri);
- if (!string.IsNullOrEmpty(msg))
+ else if (code == GlobalEnumVars.SmsMessageTypes.Veri.ToString())
{
- var sendCode = string.Empty;
- if (parameters.ContainsKey("code"))
+ // 验证验证码
+ var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForVeri);
+ if (!string.IsNullOrEmpty(msg))
{
- sendCode = parameters["code"]?.ToString();
+ str = msg.Replace("{code}", codeNumberStr);
}
- str = msg.Replace("{code}", sendCode);
}
- }
- else if (code == GlobalEnumVars.PlatformMessageTypes.CreateOrder.ToString())
- {
- // 订单创建
- var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForCreateOrder);
- str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
- }
- else if (code == GlobalEnumVars.PlatformMessageTypes.OrderPayed.ToString())
- {
- // 订单支付通知买家
- var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForOrderPayed);
- str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
- }
- else if (code == GlobalEnumVars.PlatformMessageTypes.RemindOrderPay.ToString())
- {
- // 未支付催单
- var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForRemindOrderPay);
- str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
- }
- else if (code == GlobalEnumVars.PlatformMessageTypes.DeliveryNotice.ToString())
- {
- // 订单发货
- var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForDeliveryNotice);
- str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
- }
- else if (code == GlobalEnumVars.PlatformMessageTypes.AfterSalesPass.ToString())
- {
- // 售后审核通过
- var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForAfterSalesPass);
- str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
- }
- else if (code == GlobalEnumVars.PlatformMessageTypes.RefundSuccess.ToString())
- {
- // 退款已处理
- var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForRefundSuccess);
- str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
- }
- else if (code == GlobalEnumVars.PlatformMessageTypes.SellerOrderNotice.ToString())
- {
- // 订单支付通知卖家
- var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForSellerOrderNotice);
- str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
- }
- else if (code == GlobalEnumVars.PlatformMessageTypes.Common.ToString())
- {
- //通用类型
- var tpl = string.Empty;
- if (parameters.ContainsKey("tpl"))
+ else if (code == GlobalEnumVars.PlatformMessageTypes.CreateOrder.ToString())
{
- tpl = parameters["tpl"]?.ToString();
- }
- str = tpl;
- if (string.IsNullOrEmpty(str))
- {
- var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForCommon);
+ // 订单创建
+ var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForCreateOrder);
str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
}
- }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.OrderPayed.ToString())
+ {
+ // 订单支付通知买家
+ var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForOrderPayed);
+ str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.RemindOrderPay.ToString())
+ {
+ // 未支付催单
+ var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForRemindOrderPay);
+ str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.DeliveryNotice.ToString())
+ {
+ // 订单发货
+ var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForDeliveryNotice);
+ str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.AfterSalesPass.ToString())
+ {
+ // 售后审核通过
+ var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForAfterSalesPass);
+ str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.RefundSuccess.ToString())
+ {
+ // 退款已处理
+ var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForRefundSuccess);
+ str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.SellerOrderNotice.ToString())
+ {
+ // 订单支付通知卖家
+ var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForSellerOrderNotice);
+ str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.Common.ToString())
+ {
+ //通用类型
+ var tpl = string.Empty;
+ if (parameters.ContainsKey("tpl"))
+ {
+ tpl = parameters["tpl"]?.ToString();
+ }
+ str = tpl;
+ if (string.IsNullOrEmpty(str))
+ {
+ var msg = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SmsTplForCommon);
+ str = !string.IsNullOrEmpty(msg) ? msg : string.Empty;
+ }
+ }
+
+ if (string.IsNullOrEmpty(str))
+ {
+ jm.msg = GlobalErrorCodeVars.Code10009;
+ return jm;
+ }
+
+ var oldLog = new CoreCmsSms();
+ oldLog.mobile = mobile;
+ oldLog.code = code;
+ oldLog.parameters = JsonConvert.SerializeObject(parameters);
+ oldLog.contentBody = str;
+ oldLog.createTime = dt;
+ oldLog.ip = ip;
+ oldLog.isUsed = isUsed;
+
+ await _dal.InsertAsync(oldLog);
+
+ var result = await SendSms(oldLog.mobile, oldLog.contentBody, smsOptions);
+
+ jm.status = result.IsSuccess;
+ jm.msg = result.IsSuccess ? "发送成功" : result.Message;
- if (string.IsNullOrEmpty(str))
- {
- jm.msg = GlobalErrorCodeVars.Code10009;
return jm;
}
+ else if (smsOptions.SmsType == (int)GlobalEnumVars.SmsType.AliYun)
+ {
+ var templateCode = string.Empty;
+ object templateParam = null;
+ if (code == GlobalEnumVars.SmsMessageTypes.Reg.ToString())
+ {
+ templateCode = smsOptions.SmsAliYunTplForReg;
+ templateParam = new
+ {
+ code = codeNumberStr
+ };
+ }
+ else if (code == GlobalEnumVars.SmsMessageTypes.Login.ToString())
+ {
+ templateCode = smsOptions.SmsAliYunTplForLogin;
+ templateParam = new
+ {
+ code = codeNumberStr
+ };
+ }
+ else if (code == GlobalEnumVars.SmsMessageTypes.Veri.ToString())
+ {
+ templateCode = smsOptions.SmsAliYunTplForVeri;
+ templateParam = new
+ {
+ code = codeNumberStr
+ };
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.CreateOrder.ToString())
+ {
+ templateCode = smsOptions.SmsAliYunTplForCreateOrder;
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.OrderPayed.ToString())
+ {
+ templateCode = smsOptions.SmsAliYunTplForOrderPayed;
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.RemindOrderPay.ToString())
+ {
+ templateCode = smsOptions.SmsAliYunTplForRemindOrderPay;
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.DeliveryNotice.ToString())
+ {
+ templateCode = smsOptions.SmsAliYunTplForDeliveryNotice;
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.AfterSalesPass.ToString())
+ {
+ templateCode = smsOptions.SmsAliYunTplForAfterSalesPass;
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.RefundSuccess.ToString())
+ {
+ templateCode = smsOptions.SmsAliYunTplForRefundSuccess;
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.SellerOrderNotice.ToString())
+ {
+ templateCode = smsOptions.SmsAliYunTplForSellerOrderNotice;
+ }
+ else if (code == GlobalEnumVars.PlatformMessageTypes.Common.ToString())
+ {
+ templateCode = smsOptions.SmsAliYunTplForCommon;
+ }
- var oldLog = new CoreCmsSms();
- oldLog.mobile = mobile;
- oldLog.code = code;
- oldLog.parameters = JsonConvert.SerializeObject(parameters);
- oldLog.contentBody = str;
- oldLog.createTime = dt;
- oldLog.ip = ip;
- oldLog.isUsed = isUsed;
+ if (string.IsNullOrEmpty(templateCode))
+ {
+ jm.msg = GlobalErrorCodeVars.Code10009;
+ return jm;
+ }
- await _dal.InsertAsync(oldLog);
+ var config = new AlibabaCloud.OpenApiClient.Models.Config
+ {
+ // 必填,您的 AccessKey ID
+ AccessKeyId = smsOptions.Account,
+ // 必填,您的 AccessKey Secret
+ AccessKeySecret = smsOptions.Password,
+ //Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
+ Endpoint = smsOptions.ApiUrl,
- var result = await SendSms(oldLog.mobile, oldLog.contentBody, smsOptions);
+ };
+ var client = new AlibabaCloud.SDK.Dysmsapi20170525.Client(config);
- jm.status = result.IsSuccess;
- jm.msg = result.IsSuccess ? "发送成功" : result.Message;
+ var sendSmsRequest = new AlibabaCloud.SDK.Dysmsapi20170525.Models.SendSmsRequest();
+ var runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
- return jm;
+ try
+ {
+ sendSmsRequest.SignName = smsOptions.Signature;
+ sendSmsRequest.PhoneNumbers = mobile;
+ sendSmsRequest.TemplateCode = templateCode;
+ sendSmsRequest.TemplateParam = JsonConvert.SerializeObject(templateParam);
+ sendSmsRequest.OutId = Guid.NewGuid().ToString();
+
+ var result = await client.SendSmsWithOptionsAsync(sendSmsRequest, runtime);
+
+ if (result.Body.Code == "OK")
+ {
+ var smsInfo = new CoreCmsSms();
+ smsInfo.mobile = mobile;
+ smsInfo.parameters = JsonConvert.SerializeObject(result);
+ smsInfo.code = code;
+ smsInfo.contentBody = templateCode;
+ smsInfo.createTime = DateTime.Now;
+ smsInfo.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
+ smsInfo.isUsed = isUsed;
+
+ await _dal.InsertAsync(smsInfo);
+
+ jm.status = true;
+ jm.msg = "发送成功";
+ }
+ else
+ {
+ jm.status = false;
+ jm.msg = "发送失败:" + result.Body.Message;
+ }
+ }
+ catch (TeaException error)
+ {
+ jm.status = false;
+ jm.msg = "发送失败:" + error.Message;
+ }
+ catch (Exception _error)
+ {
+ var error = new TeaException(new Dictionary
+ {
+ { "message", _error.Message }
+ });
+
+ jm.status = false;
+ jm.msg = "发送失败:" + _error.Message;
+ jm.otherData = error.Data["Recommend"];
+ }
+ return jm;
+
+ }
+ else
+ {
+ jm.status = false;
+ jm.msg = "未获取到发送方式";
+ return jm;
+ }
}
#endregion
-
-
}
}
diff --git a/CoreCms.Net.Services/Shop/CoreCmsSettingServices.cs b/CoreCms.Net.Services/Shop/CoreCmsSettingServices.cs
index 02213a4e..6ca6a3e6 100644
--- a/CoreCms.Net.Services/Shop/CoreCmsSettingServices.cs
+++ b/CoreCms.Net.Services/Shop/CoreCmsSettingServices.cs
@@ -215,15 +215,28 @@ namespace CoreCms.Net.Services
var settings = await GetDatas();
sms.Enabled = GetValue(SystemSettingConstVars.SmsEnabled, configs, settings).ObjectToInt(1) == 1;
+ sms.SmsType = GetValue(SystemSettingConstVars.SmsType, configs, settings).ObjectToInt(1);
sms.UserId = GetValue(SystemSettingConstVars.SmsUserId, configs, settings);
sms.Account = GetValue(SystemSettingConstVars.SmsAccount, configs, settings);
sms.Password = GetValue(SystemSettingConstVars.SmsPassword, configs, settings);
sms.Signature = GetValue(SystemSettingConstVars.SmsSignature, configs, settings);
sms.ApiUrl = GetValue(SystemSettingConstVars.SmsApiUrl, configs, settings);
- sms.SmsIpSendNumber= GetValue(SystemSettingConstVars.SmsIpSendNumber, configs, settings).ObjectToInt(20);
+ sms.SmsIpSendNumber = GetValue(SystemSettingConstVars.SmsIpSendNumber, configs, settings).ObjectToInt(20);
sms.SmsIpSendWhiteList = GetValue(SystemSettingConstVars.SmsIpSendWhiteList, configs, settings);
sms.SmsIpSendBlackList = GetValue(SystemSettingConstVars.SmsIpSendBlackList, configs, settings);
+ sms.SmsAliYunTplForReg = GetValue(SystemSettingConstVars.SmsAliYunTplForReg, configs, settings);
+ sms.SmsAliYunTplForLogin = GetValue(SystemSettingConstVars.SmsAliYunTplForLogin, configs, settings);
+ sms.SmsAliYunTplForVeri = GetValue(SystemSettingConstVars.SmsAliYunTplForVeri, configs, settings);
+ sms.SmsAliYunTplForCreateOrder = GetValue(SystemSettingConstVars.SmsAliYunTplForCreateOrder, configs, settings);
+ sms.SmsAliYunTplForOrderPayed = GetValue(SystemSettingConstVars.SmsAliYunTplForOrderPayed, configs, settings);
+ sms.SmsAliYunTplForRemindOrderPay = GetValue(SystemSettingConstVars.SmsAliYunTplForRemindOrderPay, configs, settings);
+ sms.SmsAliYunTplForDeliveryNotice = GetValue(SystemSettingConstVars.SmsAliYunTplForDeliveryNotice, configs, settings);
+ sms.SmsAliYunTplForAfterSalesPass = GetValue(SystemSettingConstVars.SmsAliYunTplForAfterSalesPass, configs, settings);
+ sms.SmsAliYunTplForRefundSuccess = GetValue(SystemSettingConstVars.SmsAliYunTplForRefundSuccess, configs, settings);
+ sms.SmsAliYunTplForSellerOrderNotice = GetValue(SystemSettingConstVars.SmsAliYunTplForSellerOrderNotice, configs, settings);
+ sms.SmsAliYunTplForCommon = GetValue(SystemSettingConstVars.SmsAliYunTplForCommon, configs, settings);
+
return sms;
}
diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/shop/message/smssetting/index.html b/CoreCms.Net.Web.Admin/wwwroot/views/shop/message/smssetting/index.html
index bb3f5472..2e9d0cbf 100644
--- a/CoreCms.Net.Web.Admin/wwwroot/views/shop/message/smssetting/index.html
+++ b/CoreCms.Net.Web.Admin/wwwroot/views/shop/message/smssetting/index.html
@@ -19,91 +19,102 @@
.layui-tab-content { padding: 15px 0; }