|
@@ -3,10 +3,11 @@ package services
|
|
import (
|
|
import (
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"errors"
|
|
"errors"
|
|
- "fmt"
|
|
|
|
"eta/eta_api/models"
|
|
"eta/eta_api/models"
|
|
|
|
+ "eta/eta_api/models/company"
|
|
"eta/eta_api/services/alarm_msg"
|
|
"eta/eta_api/services/alarm_msg"
|
|
"eta/eta_api/utils"
|
|
"eta/eta_api/utils"
|
|
|
|
+ "fmt"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"net/http"
|
|
"strconv"
|
|
"strconv"
|
|
@@ -38,7 +39,7 @@ func SendMiniProgramReportWxMsg(reportId int) (err error) {
|
|
}()
|
|
}()
|
|
utils.FileLog.Info("%s", "services SendMsg")
|
|
utils.FileLog.Info("%s", "services SendMsg")
|
|
|
|
|
|
- report, err := models.GetReportById(reportId)
|
|
|
|
|
|
+ report, err := models.GetReportByReportId(reportId)
|
|
if err != nil {
|
|
if err != nil {
|
|
msg = "GetReportInfo Err:" + err.Error()
|
|
msg = "GetReportInfo Err:" + err.Error()
|
|
return
|
|
return
|
|
@@ -61,30 +62,31 @@ func SendMiniProgramReportWxMsg(reportId int) (err error) {
|
|
//}
|
|
//}
|
|
|
|
|
|
var openIdArr []string
|
|
var openIdArr []string
|
|
- if report.ClassifyIdSecond <= 0 {
|
|
|
|
|
|
+ if report.HasChapter == 1 { // 如果是章节,那就推送所有用户
|
|
openIdArr, err = models.GetOpenIdArr()
|
|
openIdArr, err = models.GetOpenIdArr()
|
|
if err != nil {
|
|
if err != nil {
|
|
msg = "get GetOpenIdArr err:" + err.Error()
|
|
msg = "get GetOpenIdArr err:" + err.Error()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- classify, err := models.GetClassifyById(report.ClassifyIdSecond)
|
|
|
|
|
|
+ minClassifyId, err := getMinClassifyId(report)
|
|
|
|
+ if err != nil {
|
|
|
|
+ msg = "获取报告的最小分类失败 err:" + err.Error()
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 判断分类是否存在
|
|
|
|
+ _, err = models.GetClassifyById(minClassifyId)
|
|
if err != nil {
|
|
if err != nil {
|
|
msg = "获取报告分类失败 err:" + err.Error()
|
|
msg = "获取报告分类失败 err:" + err.Error()
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
- if classify.IsMassSend == 1 {
|
|
|
|
- openIdArr, err = models.GetOpenIdArr()
|
|
|
|
- if err != nil {
|
|
|
|
- msg = "get GetOpenIdArr err:" + err.Error()
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- openIdArr, err = models.GetOpenIdArrByClassifyNameSecond(report.ClassifyNameSecond)
|
|
|
|
- if err != nil {
|
|
|
|
- msg = "GetOpenIdArrByClassifyNameSecond err:" + err.Error()
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ // 获取该分类关联的openid列表
|
|
|
|
+ openIdArr, err = models.GetOpenIdArrByClassifyNameSecond(minClassifyId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ msg = "GetOpenIdArrByClassifyNameSecond err:" + err.Error()
|
|
|
|
+ return err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -102,7 +104,7 @@ func SendMiniProgramReportWxMsg(reportId int) (err error) {
|
|
first := fmt.Sprintf("Hi,最新一期%s已上线,欢迎查看", report.ClassifyNameFirst)
|
|
first := fmt.Sprintf("Hi,最新一期%s已上线,欢迎查看", report.ClassifyNameFirst)
|
|
keyword1 := title
|
|
keyword1 := title
|
|
keyword2 := report.Title
|
|
keyword2 := report.Title
|
|
- keyword3 := report.PublishTime
|
|
|
|
|
|
+ keyword3 := report.PublishTime.Format(utils.FormatDateTime)
|
|
keyword4 := report.Abstract
|
|
keyword4 := report.Abstract
|
|
|
|
|
|
//sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
//sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
|
|
@@ -116,7 +118,14 @@ func SendMiniProgramReportWxMsg(reportId int) (err error) {
|
|
//sendMap["data"] = sendData
|
|
//sendMap["data"] = sendData
|
|
|
|
|
|
var wxAppPath string
|
|
var wxAppPath string
|
|
- if report.ChapterType == utils.REPORT_TYPE_WEEK {
|
|
|
|
|
|
+ weekClassifyId, err := company.GetReportClassifyIdByConfigKey("report_week_classify_id")
|
|
|
|
+ if err != nil {
|
|
|
|
+ msg = "获取周报ID配置失败:" + err.Error()
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 周报走这个逻辑,我也不清楚为什么,原先就是这样(2024-6-20 16:46:07)
|
|
|
|
+ if report.ClassifyIdFirst == weekClassifyId {
|
|
wxAppPath = fmt.Sprintf("pages-report/chapterList?reportId=%s", reportIdStr)
|
|
wxAppPath = fmt.Sprintf("pages-report/chapterList?reportId=%s", reportIdStr)
|
|
} else {
|
|
} else {
|
|
wxAppPath = fmt.Sprintf("pages-report/reportDetail?reportId=%s", reportIdStr)
|
|
wxAppPath = fmt.Sprintf("pages-report/reportDetail?reportId=%s", reportIdStr)
|