瀏覽代碼

增加yb路演视频推送客群

xiexiaoyuan 2 年之前
父節點
當前提交
2cc0f02401
共有 2 個文件被更改,包括 62 次插入0 次删除
  1. 35 0
      models/yb/Road_video.go
  2. 27 0
      services/report_push.go

+ 35 - 0
models/yb/Road_video.go

@@ -0,0 +1,35 @@
+package yb
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+// RoadVideo 路演视频
+type RoadVideo struct {
+	RoadVideoId int       `orm:"column(road_video_id);pk" description:"视频ID"`
+	Title            string    `description:"视频标题"`
+	CoverImgUrl      string    `description:"封面图地址"`
+	VideoUrl         string    `description:"视频地址"`
+	VideoSeconds     string    `description:"视频时长,单位秒"`
+	PublishState     int       `description:"发布状态:0-待发布 1-已发布"`
+	SendThsState     int       `description:"客群消息推送状态:0-待推送 1-已推送"`
+	IsDeleted        int       `description:"是否已删除 0-否 1-是"`
+	PublishTime      time.Time `description:"发布时间"`
+	SendThsTime      time.Time `description:"推送客群时间"`
+	CreateTime       time.Time `description:"提问时间"`
+	ModifyTime       time.Time `description:"修改时间"`
+	DeleteTime       time.Time `description:"删除时间"`
+}
+
+func (item *RoadVideo) TableName() string {
+	return "yb_road_video"
+}
+
+// GetRoadVideoById 主键获取视频
+func GetRoadVideoById(videoId int) (item *RoadVideo, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM yb_road_video WHERE road_video_id = ? AND is_deleted = 0 LIMIT 1`
+	err = o.Raw(sql, videoId).QueryRow(&item)
+	return
+}

+ 27 - 0
services/report_push.go

@@ -172,6 +172,11 @@ func SendToThs(sendDetailId, reportId int, reportType string) (err error) {
 		if tmpErr != nil {
 			err = tmpErr
 		}
+	case "研报线上路演":
+		tmpErr := SendYbRoadVideoToThs(reportId)
+		if tmpErr != nil {
+			err = tmpErr
+		}
 	case "研报价格驱动":
 		tmpErr := SendYbPriceDrivenToThs(reportId)
 		if tmpErr != nil {
@@ -538,6 +543,28 @@ func SendYbCommunityVideoToThs(videoId int) (err error) {
 	return
 }
 
+// SendYbRoadVideoToThs 推送研报路演视频客群消息
+func SendYbRoadVideoToThs(videoId int) (err error) {
+	defer func() {
+		if err != nil {
+			go alarm_msg.SendAlarmMsg("SendYbRoadVideoToThs-延时任务发送报告至同花顺失败, RoadVideoId:"+strconv.Itoa(videoId)+", ErrMsg:"+err.Error(), 3)
+		}
+	}()
+	video, e := yb.GetRoadVideoById(videoId)
+	if e != nil {
+		err = errors.New("获取视频信息失败, Err:" + e.Error())
+		return
+	}
+	permissionName := "宏观" // 所有客群都推
+	title := video.Title
+	jumpUrl := fmt.Sprint(utils.WxYbAppId+`/pages/roadShowVideo/videoList?videoId=`, videoId)
+	logoUrl := `https://hongze.oss-cn-shanghai.aliyuncs.com/hzyj.png`
+	// 推送至同花顺
+	dataType := "2"
+	err = SendThs(title, permissionName, title, jumpUrl, logoUrl, dataType)
+	return
+}
+
 // SendYbVoiceBroadcastToThs 推送研报小程序语音播报客群消息
 func SendYbVoiceBroadcastToThs(voiceId int) (err error) {
 	defer func() {