package services import ( "fmt" "eta/eta_api/models" "eta/eta_api/services/alarm_msg" "eta/eta_api/utils" "strconv" "time" ) //func init() { // report, _ := models.GetReportById(572) // SendReportToThs(report) //} // SendReportToEmail 发送报告邮件 func SendReportToEmail(report *models.ReportDetail) (err error) { if utils.BusinessCode != utils.BusinessCodeRelease && utils.BusinessCode != utils.BusinessCodeSandbox { // 客户不做报告邮件推送 return } fmt.Println("SendReportToEmail") defer func() { if err != nil { //fmt.Println(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "发送消息至同花顺失败 ErrMsg:"+err.Error(), utils.EmailSendToUsers) go alarm_msg.SendAlarmMsg("发送报告至邮件失败,SendReportToEmail ErrMsg:"+err.Error(), 3) //go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "SendReportToEmail ErrMsg:"+err.Error(), utils.EmailSendToUsers) } }() toUser := `` jumpUrl := `` if utils.RunMode == "debug" { //toUser = `glji@hzinsights.com` toUser = `317699326@qq.com` jumpUrl = "http://rddpweb.brilliantstart.cn/reportdtl?id=1578" + strconv.Itoa(report.Id) } else { toUser = "lijun011112@gtjas.com" jumpUrl = "https://ficc.hzinsights.com/reportdtl?id=" + strconv.Itoa(report.Id) } createDate, err := time.Parse(utils.FormatDateTime, report.CreateTime) createDateFrom := createDate.Format("060102") emailBody := ` Email

弘则研报:` + report.Title + "_" + createDateFrom + `

你好,

今日报告已推送。

报告类型:` + report.ClassifyNameFirst + `

报告标题:` + report.Title + `

报告链接:弘则研究

` fmt.Println("start SendReportToEmail") result, err := utils.SendEmailByHz("弘则研报报告", emailBody, toUser) fmt.Println("send result:", result, err) return } // SendReportMiniToThs 发送报告-研报小程序到同花顺 func SendReportMiniToThs(report *models.ReportDetail) (err error) { defer func() { if err != nil { go alarm_msg.SendAlarmMsg("SendReportMiniToThs 发送报告-研报小程序到同花顺失败, ReportId:"+strconv.Itoa(report.Id)+", ErrMsg:"+err.Error(), 3) //go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "SendReportMiniToThs发送报告至同花顺失败, ReportId:" + strconv.Itoa(report.Id) + ", ErrMsg:" + err.Error(), utils.EmailSendToUsers) } }() if report.HasChapter == 0 { go SendReportToEmail(report) } return }