Browse Source

no message

xingzai 6 months ago
parent
commit
792518b16c
4 changed files with 95 additions and 0 deletions
  1. 10 0
      controllers/order.go
  2. 56 0
      models/micro_roadshow.go
  3. 3 0
      models/order/order.go
  4. 26 0
      services/micro_roadshow.go

+ 10 - 0
controllers/order.go

@@ -442,12 +442,19 @@ func (this *OrderController) UserOrderList() {
 	}
 
 	var activityIds []int
+	//音视频时长
+	var activityVivoIds []int
 	for _, v := range list {
 		if v.Source == utils.CYGX_OBJ_ACTIVITY {
 			activityIds = append(activityIds, v.SourceId)
 		}
+		if v.OrderType == 3 {
+			activityVivoIds = append(activityVivoIds, v.SourceId)
+		}
 	}
 
+	mapActivityVivo := services.GetActivityVivoByActivityIds(activityIds)
+
 	activityLabelKeyword := services.GetActivityOrderListLabelKeywordByActivityIds(activityIds)
 
 	for _, v := range list {
@@ -491,6 +498,9 @@ func (this *OrderController) UserOrderList() {
 			item.LabelKeywordImgLink = utils.LABEL_ICO_3
 			item.LabelKeyword = activityLabelKeyword[v.SourceId]
 		}
+		if v.OrderType == 3 {
+			item.PlaySeconds = mapActivityVivo[v.SourceId]
+		}
 		item.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
 		resp.List = append(resp.List, item)
 	}

+ 56 - 0
models/micro_roadshow.go

@@ -630,3 +630,59 @@ type MicroRoadshowCollectReq struct {
 	SourceId   int `description:"资源ID"`
 	SourceType int `description:"视频来源: 1-音频; 2-活动视频; 3-微路演视频 (不传默认为1)"`
 }
+
+func GetMicroRoadShowVideoPageListByActivityIds(activityIds []int) (list []*MicroRoadShowPageList, err error) {
+	lenArr := len(activityIds)
+	if lenArr == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	var sql string
+	//活动音频1
+	sql += `
+			SELECT
+			a.activity_voice_id AS id,
+			a.activity_id AS source_id,
+			a.voice_name AS title,
+			a.voice_url AS resource_url,
+			1 AS type,
+			b.activity_time AS publish_time,
+			b.chart_permission_id,
+			b.chart_permission_name,
+			a.voice_play_seconds AS play_seconds,
+			a.background_img,
+			"" AS industry_name,
+			0 AS  industry_id,
+			a.share_img,
+			a.file_type as activity_file_type,
+			a.activity_id 
+		FROM
+			cygx_activity_voice AS a
+			JOIN cygx_activity AS b ON a.activity_id = b.activity_id  WHERE 1= 1   AND a.activity_id IN (` + utils.GetOrmInReplace(lenArr) + `) `
+
+	//活动视频2
+	sql += `  UNION ALL `
+	sql += `
+		SELECT
+			a.video_id AS id,
+			a.activity_id AS source_id,
+			a.video_name AS title,
+			a.video_url AS resource_url,
+			2 AS type,
+	    	b.activity_time as publish_time,
+			b.chart_permission_id,
+			b.chart_permission_name,
+			a.video_duration AS play_seconds,
+			a.background_img,
+			"" AS industry_name,
+			0 AS  industry_id,
+			a.share_img,
+			a.file_type as activity_file_type,
+			a.activity_id
+		FROM
+			cygx_activity_video as a
+			INNER JOIN cygx_activity as b on a.activity_id = b.activity_id WHERE 1= 1   AND a.activity_id IN (` + utils.GetOrmInReplace(lenArr) + `) `
+	sql += ` ORDER BY publish_time DESC`
+	_, err = o.Raw(sql, activityIds, activityIds).QueryRows(&list)
+	return
+}

+ 3 - 0
models/order/order.go

@@ -103,6 +103,8 @@ type CygxOrderResp struct {
 	CreateTime       time.Time `comment:"创建时间"`
 	ModifyTime       time.Time `comment:"修改时间"`
 	RegisterPlatform int       `comment:"来源 1小程序,2:网页"`
+	PlaySeconds      string    `description:"音视频时长"`
+	OrderType        int       `comment:"订单类型,1:畅读卡订单,2:单场付费订单"`
 	StartDate        time.Time `comment:"开始时间"`
 	EndDate          time.Time `comment:"结束时间"`
 }
@@ -138,6 +140,7 @@ type OrderListResp struct {
 	OrderStatusText     string  `comment:"订单状态描述"`
 	LabelKeywordImgLink string  `comment:"标签关键词ico"`
 	LabelKeyword        string  `comment:"标签关键词"`
+	PlaySeconds         string  `description:"音视频时长"`
 	StartDate           string  `comment:"开始日期"`
 	EndDate             string  `comment:"结束日期"`
 }

+ 26 - 0
services/micro_roadshow.go

@@ -850,3 +850,29 @@ func AddAllCygxVoiceAndVideoHistory(user *models.WxUserItem, sourceId, sourceTyp
 	}
 	return
 }
+
+// 根据活动ID获取对应音视频时长
+func GetActivityVivoByActivityIds(activityIds []int) (mapResp map[int]string) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("根据活动ID获取对应音视频时长  GetActivityVivoByActivityIds,失败,活动ID:"+fmt.Sprint(activityIds)+err.Error(), 2)
+		}
+	}()
+
+	lenArr := len(activityIds)
+	if lenArr == 0 {
+		return
+	}
+
+	list, e := models.GetMicroRoadShowVideoPageListByActivityIds(activityIds)
+	if e != nil {
+		err = errors.New("GetIndustrialManagementNewList, Err: " + e.Error())
+		return
+	}
+	mapResp = make(map[int]string, 0)
+	for _, v := range list {
+		mapResp[v.ActivityId] = v.PlaySeconds
+	}
+	return
+}