|
@@ -27,8 +27,27 @@ func SendAdminMobileVerifyCode(source int, mobile, areaCode string) (ok bool, er
|
|
|
err = fmt.Errorf("新增验证码记录失败, Err: %s", e.Error())
|
|
|
return
|
|
|
}
|
|
|
+ // 获取配置好的短信模版
|
|
|
+ smsCond := ` AND conf_key = ? `
|
|
|
+ smsPars := make([]interface{}, 0)
|
|
|
+ smsPars = append(smsPars, "LoginSmsTpId")
|
|
|
+ conf := new(models.BusinessConf)
|
|
|
+ _, e := conf.GetItemByCondition(smsCond, smsPars)
|
|
|
+ if e != nil {
|
|
|
+ if e.Error() == utils.ErrNoRow() {
|
|
|
+ err = fmt.Errorf("请先配置短信模版")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = fmt.Errorf("获取短信模版失败, Err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
- tplId := utils.SmsNewLoginTplId
|
|
|
+ //tplId := utils.SmsNewLoginTplId
|
|
|
+ tplId := conf.ConfVal
|
|
|
+ if tplId == "" {
|
|
|
+ err = fmt.Errorf("请先配置短信模版")
|
|
|
+ return
|
|
|
+ }
|
|
|
if areaCode == "86" {
|
|
|
ok = SendSmsCode(mobile, verifyCode, tplId)
|
|
|
} else {
|
|
@@ -79,24 +98,44 @@ func SendAdminEmailVerifyCode(source int, email string) (ok bool, err error) {
|
|
|
}
|
|
|
|
|
|
// 获取邮箱模板
|
|
|
- confKey := "admin_verify_code_email_tmp"
|
|
|
- confTmp, e := company.GetConfigDetailByCode(confKey)
|
|
|
+ // 获取配置好的短信模版
|
|
|
+ cond := ` AND (conf_key = ? OR conf_key = ?)`
|
|
|
+ pars := make([]interface{}, 0)
|
|
|
+ pars = append(pars, "LoginEmailTemplateSubject", "LoginEmailTemplateContent")
|
|
|
+ busiConf := new(models.BusinessConf)
|
|
|
+ emailConfList, e := busiConf.GetItemsByCondition(cond, pars, []string{"conf_val"}, "")
|
|
|
if e != nil {
|
|
|
- err = fmt.Errorf("获取邮件模板失败, Err: %s", e.Error())
|
|
|
+ if e.Error() == utils.ErrNoRow() {
|
|
|
+ err = fmt.Errorf("请先邮件模版")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = fmt.Errorf("获取邮件模版失败, Err: %s", e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var emaiContent, emailSubject string
|
|
|
+ for _, v := range emailConfList {
|
|
|
+ if v.ConfKey == "LoginEmailTemplateContent" {
|
|
|
+ emaiContent = v.ConfVal
|
|
|
+ } else if v.ConfKey == "LoginEmailTemplateSubject" {
|
|
|
+ emailSubject = v.ConfVal
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if emailSubject == "" {
|
|
|
+ err = fmt.Errorf("请先邮件模版主题")
|
|
|
return
|
|
|
}
|
|
|
- if confTmp.ConfigValue == `` {
|
|
|
- err = fmt.Errorf("邮件模板为空, 不可推送")
|
|
|
+ if emaiContent == "" {
|
|
|
+ err = fmt.Errorf("请先邮件模版内容")
|
|
|
return
|
|
|
}
|
|
|
|
|
|
req := new(EnglishReportSendEmailRequest)
|
|
|
- req.Subject = "弘则研究登录验证"
|
|
|
+ req.Subject = emailSubject
|
|
|
req.Email = email
|
|
|
req.FromAlias = conf.FromAlias
|
|
|
// 填充模板
|
|
|
t := time.Now().Format("2006年01月02日")
|
|
|
- ct := confTmp.ConfigValue
|
|
|
+ ct := emaiContent
|
|
|
ct = strings.Replace(ct, "{{VERIFY_CODE}}", verifyCode, 1)
|
|
|
ct = strings.Replace(ct, "{{EXPIRED_MINUTE}}", strconv.Itoa(utils.VerifyCodeExpireMinute), 1)
|
|
|
ct = strings.Replace(ct, "{{DATE_TIME}}", t, 1)
|