ziwen 2 жил өмнө
parent
commit
df6bf596d2

+ 32 - 0
models/yb/yb_voice_broadcast.go

@@ -0,0 +1,32 @@
+package yb
+
+import "github.com/beego/beego/v2/client/orm"
+
+type VoiceBroadcast struct {
+	BroadcastId      int    `gorm:"primaryKey;column:broadcast_id;type:int(11)" description:"语音ID"`
+	BroadcastName    string `description:"语音名称"`
+	SectionId        int    `description:"语音分类ID"`
+	SectionName      string `description:"语音分类名称"`
+	VarietyId        int    `description:"品种id"`
+	VarietyName      string `description:"品种名称"`
+	AuthorId         int    `description:"作者id"`
+	Author           string `description:"作者"`
+	ImgUrl           string `description:"背景图url"`
+	VoiceUrl         string `description:"音频url"`
+	VoicePlaySeconds string `description:"音频时长"`
+	VoiceSize        string `description:"音频大小"`
+	CreateTime       string `description:"创建时间"`
+}
+
+// TableName get sql table name.获取数据库表名
+func (m *VoiceBroadcast) TableName() string {
+	return "yb_voice_broadcast"
+}
+
+
+func GetBroadcastById(broadcastId int) (item *VoiceBroadcast, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM yb_voice_broadcast WHERE broadcast_id = ? LIMIT 1`
+	err = o.Raw(sql, broadcastId).QueryRow(&item)
+	return
+}

+ 27 - 0
services/report_push.go

@@ -176,6 +176,11 @@ func SendToThs(sendDetailId, reportId int, reportType string) (err error) {
 		if tmpErr != nil {
 			err = tmpErr
 		}
+	case "语音播报":
+		tmpErr := SendYbVoiceBroadcastToThs(reportId)
+		if tmpErr != nil {
+			err = tmpErr
+		}
 	default:
 		err = errors.New("异常类型")
 	}
@@ -531,4 +536,26 @@ func SendYbCommunityVideoToThs(videoId int) (err error) {
 	dataType := "2"
 	err = SendThs(title, permissionName, title, jumpUrl, logoUrl, dataType)
 	return
+}
+
+// SendYbVoiceBroadcastToThs 推送研报小程序语音播报客群消息
+func SendYbVoiceBroadcastToThs(voiceId int) (err error) {
+	defer func() {
+		if err != nil {
+			go alarm_msg.SendAlarmMsg("SendYbCommunityVideoToThs-延时任务发送报告至同花顺失败, voiceBroadcastId:"+strconv.Itoa(voiceId)+", ErrMsg:"+err.Error(), 3)
+		}
+	}()
+	voice, e := yb.GetBroadcastById(voiceId)
+	if e != nil {
+		err = errors.New("获取语音播报信息失败, Err:" + e.Error())
+		return
+	}
+	permissionName := "宏观"	// 所有客群都推
+	title := voice.BroadcastName
+	jumpUrl := fmt.Sprint(utils.WxYbAppId + `/pages/voice/voice?voiceId=`, voiceId)
+	logoUrl := `https://hongze.oss-cn-shanghai.aliyuncs.com/hzyj.png`
+	// 推送至同花顺
+	dataType := "2"
+	err = SendThs(title, permissionName, title, jumpUrl, logoUrl, dataType)
+	return
 }