Merge branch 'main' of http://1.117.67.95:3000/team/tyapi-server
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi"
|
"github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
@@ -72,39 +71,39 @@ func (s *AliSMSService) SendBalanceAlert(ctx context.Context, phone string, bala
|
|||||||
request.PhoneNumbers = phone
|
request.PhoneNumbers = phone
|
||||||
request.SignName = s.config.SignName
|
request.SignName = s.config.SignName
|
||||||
|
|
||||||
var templateCode string
|
var templateCode string = "SMS_500565339"
|
||||||
var templateParam string
|
// var templateParam string
|
||||||
|
|
||||||
if alertType == "low_balance" {
|
// if alertType == "low_balance" {
|
||||||
// 低余额预警也使用欠费预警模板
|
// // 低余额预警也使用欠费预警模板
|
||||||
templateCode = "SMS_494605047" // 阿里云欠费预警模板
|
// templateCode = "SMS_500565339" // 阿里云欠费预警模板
|
||||||
|
|
||||||
// 使用传入的企业名称,如果没有则使用默认值
|
// // 使用传入的企业名称,如果没有则使用默认值
|
||||||
name := "天远数据用户"
|
// name := "天远数据用户"
|
||||||
if len(enterpriseName) > 0 && enterpriseName[0] != "" {
|
// if len(enterpriseName) > 0 && enterpriseName[0] != "" {
|
||||||
name = enterpriseName[0]
|
// name = enterpriseName[0]
|
||||||
}
|
// }
|
||||||
|
|
||||||
templateParam = fmt.Sprintf(`{"name":"%s","time":"%s","money":"%.2f"}`,
|
// templateParam = fmt.Sprintf(`{"name":"%s","time":"%s","money":"%.2f"}`,
|
||||||
name, time.Now().Format("2006-01-02 15:04:05"), threshold)
|
// name, time.Now().Format("2006-01-02 15:04:05"), threshold)
|
||||||
} else if alertType == "arrears" {
|
// } else if alertType == "arrears" {
|
||||||
// 欠费预警模板
|
// // 欠费预警模板
|
||||||
templateCode = "SMS_494605047" // 阿里云欠费预警模板
|
// templateCode = "SMS_500565339" // 阿里云欠费预警模板
|
||||||
|
|
||||||
// 使用传入的企业名称,如果没有则使用默认值
|
// // 使用传入的企业名称,如果没有则使用默认值
|
||||||
name := "天远数据用户"
|
// name := "天远数据用户"
|
||||||
if len(enterpriseName) > 0 && enterpriseName[0] != "" {
|
// if len(enterpriseName) > 0 && enterpriseName[0] != "" {
|
||||||
name = enterpriseName[0]
|
// name = enterpriseName[0]
|
||||||
}
|
// }
|
||||||
|
|
||||||
templateParam = fmt.Sprintf(`{"name":"%s","time":"%s","money":"%.2f"}`,
|
// templateParam = fmt.Sprintf(`{"name":"%s","time":"%s","money":"%.2f"}`,
|
||||||
name, time.Now().Format("2006-01-02 15:04:05"), balance)
|
// name, time.Now().Format("2006-01-02 15:04:05"), balance)
|
||||||
} else {
|
// } else {
|
||||||
return fmt.Errorf("不支持的预警类型: %s", alertType)
|
// return fmt.Errorf("不支持的预警类型: %s", alertType)
|
||||||
}
|
// }
|
||||||
|
|
||||||
request.TemplateCode = templateCode
|
request.TemplateCode = templateCode
|
||||||
request.TemplateParam = templateParam
|
// request.TemplateParam = templateParam
|
||||||
|
|
||||||
response, err := s.client.SendSms(request)
|
response, err := s.client.SendSms(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user