change sms template code
This commit is contained in:
@@ -72,39 +72,39 @@ func (s *AliSMSService) SendBalanceAlert(ctx context.Context, phone string, bala
|
||||
request.PhoneNumbers = phone
|
||||
request.SignName = s.config.SignName
|
||||
|
||||
var templateCode string
|
||||
var templateParam string
|
||||
var templateCode string = "SMS_500565339"
|
||||
// var templateParam string
|
||||
|
||||
if alertType == "low_balance" {
|
||||
// 低余额预警也使用欠费预警模板
|
||||
templateCode = "SMS_494605047" // 阿里云欠费预警模板
|
||||
// if alertType == "low_balance" {
|
||||
// // 低余额预警也使用欠费预警模板
|
||||
// templateCode = "SMS_500565339" // 阿里云欠费预警模板
|
||||
|
||||
// 使用传入的企业名称,如果没有则使用默认值
|
||||
name := "天远数据用户"
|
||||
if len(enterpriseName) > 0 && enterpriseName[0] != "" {
|
||||
name = enterpriseName[0]
|
||||
}
|
||||
// // 使用传入的企业名称,如果没有则使用默认值
|
||||
// name := "天远数据用户"
|
||||
// if len(enterpriseName) > 0 && enterpriseName[0] != "" {
|
||||
// name = enterpriseName[0]
|
||||
// }
|
||||
|
||||
templateParam = fmt.Sprintf(`{"name":"%s","time":"%s","money":"%.2f"}`,
|
||||
name, time.Now().Format("2006-01-02 15:04:05"), threshold)
|
||||
} else if alertType == "arrears" {
|
||||
// 欠费预警模板
|
||||
templateCode = "SMS_494605047" // 阿里云欠费预警模板
|
||||
// templateParam = fmt.Sprintf(`{"name":"%s","time":"%s","money":"%.2f"}`,
|
||||
// name, time.Now().Format("2006-01-02 15:04:05"), threshold)
|
||||
// } else if alertType == "arrears" {
|
||||
// // 欠费预警模板
|
||||
// templateCode = "SMS_500565339" // 阿里云欠费预警模板
|
||||
|
||||
// 使用传入的企业名称,如果没有则使用默认值
|
||||
name := "天远数据用户"
|
||||
if len(enterpriseName) > 0 && enterpriseName[0] != "" {
|
||||
name = enterpriseName[0]
|
||||
}
|
||||
// // 使用传入的企业名称,如果没有则使用默认值
|
||||
// name := "天远数据用户"
|
||||
// if len(enterpriseName) > 0 && enterpriseName[0] != "" {
|
||||
// name = enterpriseName[0]
|
||||
// }
|
||||
|
||||
templateParam = fmt.Sprintf(`{"name":"%s","time":"%s","money":"%.2f"}`,
|
||||
name, time.Now().Format("2006-01-02 15:04:05"), balance)
|
||||
} else {
|
||||
return fmt.Errorf("不支持的预警类型: %s", alertType)
|
||||
}
|
||||
// templateParam = fmt.Sprintf(`{"name":"%s","time":"%s","money":"%.2f"}`,
|
||||
// name, time.Now().Format("2006-01-02 15:04:05"), balance)
|
||||
// } else {
|
||||
// return fmt.Errorf("不支持的预警类型: %s", alertType)
|
||||
// }
|
||||
|
||||
request.TemplateCode = templateCode
|
||||
request.TemplateParam = templateParam
|
||||
// request.TemplateParam = templateParam
|
||||
|
||||
response, err := s.client.SendSms(request)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user