123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435 |
- package cygx
- import (
- "fmt"
- "gopkg.in/gomail.v2"
- "hongze/hz_crm_api/models/cygx"
- "sort"
- "strings"
- )
- func SendResearchSummaryEmail(detail *cygx.DetailCygxResearchSummaryRep, touser []string) bool {
-
-
-
-
-
- m := gomail.NewMessage()
- m.SetHeader("From", "hzcygx@hzinsights.com ")
-
- var user []string
- user = append(user, "zqliu@hzinsights.com ")
- user = append(user, "tshen@hzinsights.com ")
- user = append(user, "hdong@hzinsights.com ")
- user = append(user, "cxzhang@hzinsights.com ")
- m.SetHeader("Bcc", user...)
- m.SetHeader("Subject", detail.Title)
- date := strings.ReplaceAll(detail.Title, "月", "/")
- date = strings.ReplaceAll(date, "日", "")
- date = strings.ReplaceAll(date, "至", "-")
- titleArr := strings.Split(date, "(")
- title := "【" + titleArr[0] + "】" + titleArr[1]
- title = strings.ReplaceAll(title, ")", "")
- title = strings.ReplaceAll(title, "(", "")
- head := "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Document</title>\n <style>\n * {\n padding: 0;\n margin: 0;\n }\n a {\n text-decoration: none;\n }\n\n a:hover {\n text-decoration: underline;\n }\n div {\n box-sizing: border-box;\n }\n h4 {\n color: #ff0c15;\n margin-bottom: 10px;\n }\n .title-content {\n margin: 6px 0;\n }\n .link {\n display: block;\n margin: 5px 0 35px;\n }\n </style>\n </head>\n " +
- "<body>\n <!-- 深度报告篇 、产业调研纪要篇 、晨会精华篇 -->\n "
- div := " <div class=\"box\">\n <p style=\"font-size: 16px;\">Dear All,</p>\n\n<p style=\"font-size: 16px; margin-left: 60px;\">以下是弘则研究" + title + ",供您参考。</p>"
- allBody := ""
- bodyMap := make(map[string]string)
- {
-
- sectionBody := ""
- report := " <br /><br /><h4>深度报告篇</h4>\n "
-
- body := ""
- list := cygx.RSList{}
- list = detail.ListSdbg
- sort.Sort(list)
- i := 0
- for _, item := range list {
- var industry string
- var secondBody string
- if len(item.List) > 0 {
- if i > 0 {
- industry += "<br />"
- }
- industry += " <p><strong>【" + item.ChartPermissionName + "】</strong></p>\n "
- for _, log := range item.List {
- sdbgBody := strings.TrimRight(log.Body, "<br />")
- sdbgLink := " <a href=" + log.ReportLink + " class=\"link\" style=\"color: #1534e7\">" + log.ReportLink + "</a>\n </div>\n\n "
- thirdBody := sdbgBody + sdbgLink
- secondBody += thirdBody
-
-
-
-
-
-
- }
- i++
- }
- body += industry + secondBody
- }
- if body != "" {
- sectionBody = report + body
- bodyMap[detail.SortSdbg] = sectionBody
- }
- }
- {
- sectionBody := ""
-
- report := " <br /><br /><h4>产业调研纪要</h4>\n "
-
- body := ""
- list := cygx.RSList{}
- list = detail.ListCydyjy
- sort.Sort(list)
- i := 0
- for _, item := range list {
- var industry string
- var secondBody string
- if len(item.List) > 0 {
- if i > 0 {
- industry += "<br />"
- }
- industry += " <p><strong>【" + item.ChartPermissionName + "】</strong></p>\n "
- for _, log := range item.List {
- sdbgBody := strings.TrimRight(log.Body, "<br />")
- sdbgLink := " <a href=" + log.ReportLink + " class=\"link\" style=\"color: #1534e7\">" + log.ReportLink + "</a>\n </div>\n\n "
- thirdBody := sdbgBody + sdbgLink
- secondBody += thirdBody
-
-
-
-
-
-
- }
- i++
- }
- body += industry + secondBody
- }
- if body != "" {
- sectionBody = report + body
- bodyMap[detail.SortCydyjy] = sectionBody
- }
- }
- {
- sectionBody := ""
- report := " <br /><br /><h4>上市公司调研纪要</h4>\n "
-
- body := ""
- list := cygx.RSList{}
- list = detail.ListSsgs
- sort.Sort(list)
- i := 0
- for _, item := range list {
- var industry string
- var secondBody string
- if len(item.List) > 0 {
- if i > 0 {
- industry += "<br />"
- }
- industry += " <p><strong>【" + item.ChartPermissionName + "】</strong></p>\n "
- for _, log := range item.List {
- sdbgBody := strings.TrimRight(log.Body, "<br />")
- sdbgLink := " <a href=" + log.ReportLink + " class=\"link\" style=\"color: #1534e7\">" + log.ReportLink + "</a>\n </div>\n\n "
- thirdBody := sdbgBody + sdbgLink
- secondBody += thirdBody
-
-
-
-
-
-
- }
- i++
- }
- body += industry + secondBody
- }
- if body != "" {
- sectionBody = report + body
- bodyMap[detail.SortSsgs] = sectionBody
- }
- }
- {
- sectionBody := ""
- report := " <br /><br /><h4>事件点评</h4>\n "
-
- body := ""
- i := 0
- for _, item := range detail.ListSjdp {
- var industry string
- if i > 0 {
- industry += "<br />"
- }
- var secondBody string
- sdbgBody := strings.TrimRight(item.Body, "<br />")
- sdbgLink := " <a href=\"\" class=\"link\" style=\"color: #1534e7\">" + item.ReportLink + "</a>\n </div>\n\n "
- thirdBody := sdbgBody + sdbgLink
- secondBody += thirdBody
-
-
-
-
-
-
- body += industry + secondBody
- i++
- }
- if body != "" {
- sectionBody = report + body
- bodyMap[detail.SortSjdp] = sectionBody
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {
- sectionBody := ""
- report := " <br /><br /><h4>本周晨会精华</h4>\n "
-
- body := ""
- list := cygx.RSList{}
- list = detail.ListBzchjh
- sort.Sort(list)
- i := 0
- for _, item := range list {
- var industry string
- var secondBody string
- if len(item.List) > 0 {
- if i > 0 {
- industry += "<br />"
- }
- industry += " <p><strong>【" + item.ChartPermissionName + "】</strong></p>\n "
- for _, log := range item.List {
- sdbgBody := strings.TrimRight(log.Body, "<br />")
- sdbgLink := " <a href=" + log.ReportLink + " class=\"link\" style=\"color: #1534e7\">" + log.ReportLink + "</a>\n </div>\n\n "
- thirdBody := sdbgBody + sdbgLink
- secondBody += thirdBody
-
-
-
-
-
-
- }
- i++
- }
- body += industry + secondBody
- }
- if body != "" {
- sectionBody = report + body
- bodyMap[detail.SortBzchjh] = sectionBody
- }
- }
- for i := 'A'; i <= 'Z'; i++ {
- k := fmt.Sprintf("%c", i)
- allBody += bodyMap[k]
- }
- bodyEnd := " </body>\n</html>"
- m.SetBody("text/html", head+div+allBody+bodyEnd)
- d := gomail.NewDialer("smtp.mxhichina.com", 465, "hzcygx@hzinsights.com", "Hzinsights2024")
- if err := d.DialAndSend(m); err != nil {
- return false
- }
- return true
- }
- func SendMinutesSummaryEmail(detail *cygx.DetailCygxMinutesSummaryRep, touser []string) bool {
-
-
-
-
-
- m := gomail.NewMessage()
- m.SetHeader("From", "hzcygx@hzinsights.com ")
-
- var user []string
- user = append(user, "zqliu@hzinsights.com ")
- user = append(user, "tshen@hzinsights.com ")
- user = append(user, "hdong@hzinsights.com ")
- user = append(user, "cxzhang@hzinsights.com ")
- m.SetHeader("To", user...)
- m.SetHeader("Subject", detail.Title)
- head := "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>Document</title>\n <style>\n * {\n padding: 0;\n margin: 0;\n }\n a {\n text-decoration: none;\n }\n\n a:hover {\n text-decoration: underline;\n }\n div {\n box-sizing: border-box;\n }\n h4 {\n color: #ff0c15;\n margin-bottom: 10px;\n }\n .title-content {\n margin: 6px 0;\n }\n .link {\n display: block;\n margin: 5px 0 35px;\n }\n </style>\n </head>\n " +
- "<body>\n <!-- 深度报告篇 、产业调研纪要篇 、晨会精华篇 -->\n "
- div := " <div class=\"box\">\n "
- allBody := ""
- bodyMap := make(map[string]string)
- {
- sectionBody := ""
-
- report := " <br /><br /><h4>产业调研纪要</h4>\n "
- body := ""
- list := cygx.RSList{}
- list = detail.ListCydyjy
- sort.Sort(list)
- i := 0
- for _, item := range list {
- var industry string
- var secondBody string
- if len(item.List) > 0 {
- if i > 0 {
- industry += "<br />"
- }
- industry += " <p><strong>【" + item.ChartPermissionName + "】</strong></p>\n "
- for _, log := range item.List {
- sdbgBody := strings.TrimRight(log.Body, "<br />")
-
- first := strings.Index(sdbgBody, "#")
- second := strings.Index(sdbgBody[first+1:], "#") + first + 1
- d := strings.Index(sdbgBody, "</span>")
- if d < second {
- d = strings.Index(sdbgBody, "</span>")
- }
- if second != -1 {
- pre := sdbgBody[:second]
- company := sdbgBody[second:d]
- sdbgBody = pre + " <span style=\"color: #ff1720\">" + company + "</span>\n </div>\n " + sdbgBody[d:]
- }
- sdbgLink := " <a href=" + log.ReportLink + " class=\"link\" style=\"color: #1534e7\">" + log.ReportLink + "</a>\n </div>\n\n "
- thirdBody := sdbgBody + sdbgLink
- secondBody += thirdBody
-
-
-
-
-
-
- }
- i++
- }
- body += industry + secondBody
- }
- if body != "" {
- sectionBody = report + body
- bodyMap[detail.SortCydyjy] = sectionBody
- }
- }
- {
- sectionBody := ""
- report := " <br /><br /><h4>上市公司调研纪要</h4>\n "
-
- body := ""
- list := cygx.RSList{}
- list = detail.ListSsgs
- sort.Sort(list)
- i := 0
- for _, item := range list {
- var industry string
- var secondBody string
- if len(item.List) > 0 {
- if i > 0 {
- industry += "<br />"
- }
- industry += " <p><strong>【" + item.ChartPermissionName + "】</strong></p>\n "
- for _, log := range item.List {
- sdbgBody := strings.TrimRight(log.Body, "<br />")
- sdbgLink := " <a href=" + log.ReportLink + " class=\"link\" style=\"color: #1534e7\">" + log.ReportLink + "</a>\n </div>\n\n "
- thirdBody := sdbgBody + sdbgLink
- secondBody += thirdBody
-
-
-
-
-
-
- }
- i++
- }
- body += industry + secondBody
- }
- if body != "" {
- sectionBody = report + body
- bodyMap[detail.SortSsgs] = sectionBody
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- for i := 'A'; i <= 'Z'; i++ {
- k := fmt.Sprintf("%c", i)
- allBody += bodyMap[k]
- }
- bodyEnd := " </body>\n</html>"
- m.SetBody("text/html", head+div+allBody+bodyEnd)
- d := gomail.NewDialer("smtp.mxhichina.com", 465, "hzcygx@hzinsights.com", "Hzinsights2024")
- if err := d.DialAndSend(m); err != nil {
- return false
- }
- return true
- }
|