Browse Source

Merge branch 'mfyx_3.6' of http://8.136.199.33:3000/cxzhang/hongze_web_mfyx

xingzai 6 months ago
parent
commit
a27e036cd1

+ 123 - 33
controllers/activity.go

@@ -780,6 +780,8 @@ func (this *ActivityNoLoginController) Detail() {
 		return
 	}
 	resp.IsResearchSpecial = isResearchSpecial
+	var mapActivityId []int
+	mapActivityId = append(mapActivityId, activityId)
 	if havePower {
 		resp.HasPermission = 1
 		//permissionArr := make([]string, 0)
@@ -864,34 +866,6 @@ func (this *ActivityNoLoginController) Detail() {
 		}
 		detailResp.Listndustrial = industrialList
 
-		//处理音频回放
-		var mapActivityId []int
-		mapActivityId = append(mapActivityId, activityId)
-		mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
-			return
-		}
-		if mapActivityVoice[activityId] != nil {
-			detailResp.FileType = 1
-			detailResp.AudioLink = true
-			detailResp.VoiceDetail = mapActivityVoice[activityId]
-		}
-		//处理视频回放
-		mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
-			return
-		}
-
-		if mapActivityVideo[activityId] != nil {
-			detailResp.FileType = 2
-			detailResp.AudioLink = true
-			detailResp.VideoDetail = mapActivityVideo[activityId]
-		}
-
 		//处理不同的报名方式按钮回显
 		mapActivitySignup, err := services.GetActivitySignupResp(mapActivityId, user)
 		if err != nil {
@@ -913,21 +887,39 @@ func (this *ActivityNoLoginController) Detail() {
 		resp.HasPermission = hasPermission
 		resp.SellerName = sellerName
 		resp.SellerMobile = sellerMobile
-
 		resp.IsShowWxPay = utils.IS_SHOW_WX_PAY                                                      //是否展示微信支付按钮
 		resp.IsCompanyApply = services.GetUserApplyRecordCountByCompanyIdPay(user.CompanyId)         //获取客户是否有过历史申请记录
 		resp.IsNeedBusinessCard = services.GetCygxUserBusinessCardCount(user.UserId, user.CompanyId) //是否需要上传名片
 	}
+
+	//处理音频回放
+	mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
+		return
+	}
+
 	// 判断是否属于研选类型的活动
 	if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
 		resp.IsResearch = true
 	}
 
-	if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
-		resp.GoodsList = services.GetUserGoodsCardList() //日卡月卡商品信息
+	//已结束的活动,音视频作为商品的价格处理
+	if activityInfo.ActiveState == "3" {
+		resp.GoodsList = services.GetGoodsInfoByActivityVivo(activityInfo)              //音视频回放商品信息
+		resp.VivoPoints = services.GetActivityVivoPoints(activityInfo, user, havePower) //单场活动信息
+		if resp.VivoPoints.PointPermission == 2 || resp.VivoPoints.PointPermission == 3 {
+			resp.IsShowWxPay = utils.IS_SHOW_WX_PAY //是否展示微信支付按钮
+		}
+		resp.OrderCode, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivtyVivo(uid, activityId) //截止支付时间倒计时
 	} else {
-		resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo)                                             //单场活动信息
-		resp.OrderCode, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivty(uid, activityId) //截止支付时间倒计时
+		if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
+			resp.GoodsList = services.GetUserGoodsCardList() //日卡月卡商品信息
+		} else {
+			resp.GoodsList = services.GetGoodsInfoByActivity(activityInfo)                                             //单场活动信息
+			resp.OrderCode, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivty(uid, activityId) //截止支付时间倒计时
+		}
 	}
 
 	if len(resp.GoodsList) == 0 {
@@ -949,6 +941,26 @@ func (this *ActivityNoLoginController) Detail() {
 	}
 	detailResp.ShareImg = services.GetActivityShareImg(activityInfo)
 	detailResp.AuthInfo.HasPermission = resp.HasPermission
+
+	if mapActivityVoice[activityId] != nil {
+		detailResp.FileType = 1
+		detailResp.AudioLink = true
+		detailResp.VoiceDetail = mapActivityVoice[activityId]
+	}
+	//处理视频回放
+	mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
+		return
+	}
+
+	if mapActivityVideo[activityId] != nil {
+		detailResp.FileType = 2
+		detailResp.AudioLink = true
+		detailResp.VideoDetail = mapActivityVideo[activityId]
+	}
+
 	resp.Detail = detailResp
 	br.Ret = 200
 	br.Success = true
@@ -2817,3 +2829,81 @@ func (this *ActivityController) CheckAsk() {
 	br.Success = true
 	br.Data = resp
 }
+
+// @Title 查看音视频扣点接口
+// @Description 查看音视频扣点接口
+// @Param	request	body models.ActivityIdRep true "type json string"
+// @Success Ret=200 {object}
+// @router /vivo_point_record [post]
+func (this *ActivityController) VivoPointRecord() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+
+	var req models.ActivityIdRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+
+	total, err := models.GetCygxActivityVivoPointRecordCount(activityId, user.UserId)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,获取历史记录信息失败Err:" + errInfo.Error()
+		return
+	}
+	if total == 0 {
+		vivoPointsSetDetail, err := models.GetCygxActivityVivoPointsSetByActivityId(activityId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		item := new(models.CygxActivityVivoPointRecord)
+		item.Source = vivoPointsSetDetail.Source
+		item.SourceId = activityId
+		item.UserId = user.UserId
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		item.RealName = user.RealName
+		item.SellerName, _ = services.GetSellerName(user) // 销售姓名
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		item.RegisterPlatform = utils.REGISTER_PLATFORM
+		err = models.AddCygxActivityVivoPointRecord(item)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		go services.YanXuanActivityVivoPointsBillSignupAdd(activityId, user.UserId) // 用户观看音视频研选扣点
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+}

+ 7 - 2
controllers/home.go

@@ -295,6 +295,7 @@ func (this *MobileHomeController) NewList() {
 	var pars []interface{}
 	var yanxuanActivityIds []int
 	var yanxuanArticleIds []int
+	var conditionresp string
 	//var yanxuanspecialIds []int
 
 	if hashtagKeyword != "" {
@@ -307,23 +308,26 @@ func (this *MobileHomeController) NewList() {
 	resp := new(models.HomeResourceDataListNewResp)
 
 	if keyWord == "" {
-		condition += " AND source IN ('article','activity','yanxuanspecial')   " // 只有研选的文章、研选的活动、研选的专栏这三种
+		condition += " AND source IN ('article','activity','yanxuanspecial','activityvoice','activityvideo')  AND IF   ( source IN('activityvoice','activityvideo') , chart_permission_id = 31 ,1=1 ) " // 只有研选的文章、研选的活动、研选的专栏这三种
 		if labelKeyword == "" {
 			//查询近一个月的数据
 			condition += " AND search_order_time  >   '" + time.Now().AddDate(0, 0, -180).Format(utils.FormatDateTime) + "'"
 			yanxuanActivityIds = services.GetYanxuanActivityIds(user, "1,2") // 获取所有的研选活动ID
 			yanxuanArticleIds = services.GetYanxuanArticleIds()              //获取所有研选文章ID
 		} else {
-			yanxuanActivityIds, yanxuanArticleIds, err = services.GetConditionInitByTagIds(user, labelKeyword)
+			yanxuanActivityIds, yanxuanArticleIds, conditionresp, err = services.GetConditionInitByTagIds(user, labelKeyword)
 			if err != nil {
 				br.Msg = "获取失败"
 				br.ErrMsg = "获取活动权限数据失败,GetConditionInitByTagIds Err:" + err.Error()
 				return
 			}
+			condition += conditionresp
 			//如果不是 "全部报告" 、 "专栏" 的关键词查询,就不做研选专栏的查询
 			if labelKeyword != utils.LABEL_L2_1 && labelKeyword != utils.LABEL_L2_2 {
 				condition += `  AND IF ( source = 'yanxuanspecial' , source_id   IN (0) ,1=1 ) `
 			}
+			//任何筛选,都不展示对应的音视频
+			condition += `   AND source  NOT IN ('activityvoice','activityvideo') `
 		}
 
 		yanxuanArticleIds = append(yanxuanArticleIds, 0)
@@ -341,6 +345,7 @@ func (this *MobileHomeController) NewList() {
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
 			return
 		}
+
 		list, err = services.GetResourceDataList(condition, pars, startSize, pageSize, user)
 		if err != nil {
 			br.Msg = "获取失败"

+ 3 - 2
controllers/micro_roadshow.go

@@ -307,16 +307,17 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
 	sourceId := req.SourceId
 	playSeconds := req.PlaySeconds
 	sourceType := req.SourceType
+	inviteShareCode := req.InviteShareCode
 
 	if sourceType == 0 {
 		sourceType = 1
 	}
 	if sourceType == 1 {
 		//添加活动音频的播放记录
-		go services.AddActivityVoiceHistory(user, sourceId, playSeconds)
+		go services.AddActivityVoiceHistory(user, sourceId, playSeconds, inviteShareCode)
 	} else if sourceType == 2 {
 		//添加活动视频的播放记录
-		go services.AddActivityVideoHistory(user, sourceId, playSeconds)
+		go services.AddActivityVideoHistory(user, sourceId, playSeconds, inviteShareCode)
 	} else if sourceType == 3 {
 		//添加产业视频播放记录
 		go services.AddMicroRoadshowVideoRecord(user, sourceId, playSeconds)

+ 63 - 7
controllers/order.go

@@ -143,6 +143,7 @@ func (this *OrderController) AddByActivity() {
 	uid := user.UserId
 	goodsId := req.GoodsId
 	sourceId := req.SourceId
+	source := req.Source
 	if goodsId == 0 {
 		br.Msg = "支付失败"
 		br.ErrMsg = "支付失败,goodsId 信息错误Err:" + err.Error()
@@ -163,14 +164,20 @@ func (this *OrderController) AddByActivity() {
 	}
 	var title string
 	var oldOrderCode string
+	var payTimeCountdown int
 	//var _ int
 	item := new(order.CygxOrder)
-	if (!activityDetail.IsResearchPoints && activityDetail.IsLimitPeople == 0) || activityDetail.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
-		oldOrderCode = services.GetHaverEquallyOrderByUser10Min(uid, goodsId) //获取用户十分钟之内是否有相同的订单信息
-		item.OrderType = 1
+	if source == "ActivityVivo" {
+		oldOrderCode, payTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivtyVivo(uid, sourceId)
+		item.OrderType = 3
 	} else {
-		oldOrderCode, _ = services.GetHaverEquallyOrderByUser10MinByActivty(uid, sourceId)
-		item.OrderType = 2
+		if (!activityDetail.IsResearchPoints && activityDetail.IsLimitPeople == 0) || activityDetail.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
+			oldOrderCode = services.GetHaverEquallyOrderByUser10Min(uid, goodsId) //获取用户十分钟之内是否有相同的订单信息
+			item.OrderType = 1
+		} else {
+			oldOrderCode, payTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivty(uid, sourceId)
+			item.OrderType = 2
+		}
 	}
 
 	title = activityDetail.ActivityName
@@ -190,6 +197,8 @@ func (this *OrderController) AddByActivity() {
 		item.GoodsName = "日卡"
 	case 2:
 		item.GoodsName = "月卡"
+	case 9:
+		item.GoodsName = "活动回放"
 	}
 	//如果活动有自定义的价格就优先按照自定义的价格来
 	if activityDetail.ActivityPrice > 0 {
@@ -215,6 +224,41 @@ func (this *OrderController) AddByActivity() {
 	item.ModifyTime = time.Now()
 	item.RegisterPlatform = utils.REGISTER_PLATFORM
 
+	//如果是音视频的订单,数据做二次处理
+	if source == "ActivityVivo" {
+		vivoPointsSetDetail, err := models.GetCygxActivityVivoPointsSetByActivityId(sourceId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		item.GoodsMoney = vivoPointsSetDetail.GoodsMoney
+		item.OrderMoney = vivoPointsSetDetail.GoodsMoney
+		item.Source = vivoPointsSetDetail.Source
+		if vivoPointsSetDetail.Source == utils.CYGX_OBJ_ACTIVITYVIDEO {
+			activityVideoInfo, err := models.GetCygxActivityVideoByActivityId(sourceId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取信息失败,Err:" + err.Error()
+				return
+			}
+			title = activityVideoInfo.VideoName
+		} else if vivoPointsSetDetail.Source == utils.CYGX_OBJ_ACTIVITYVOICE {
+			activityVoiceInfo, err := models.GetCygxActivityVoiceByActivityId(sourceId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取信息失败,Err:" + err.Error()
+				return
+			}
+			title = activityVoiceInfo.VoiceName
+		} else {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,音视频数据类型错误"
+			return
+		}
+		item.SourceTitle = title
+	}
+
 	//如果十分钟之内有相同的订单就修改,没有就新增
 	if oldOrderCode == "" {
 		err = order.AddCygxOrder(item)
@@ -229,7 +273,7 @@ func (this *OrderController) AddByActivity() {
 		return
 	}
 	resp := new(order.WxNativeApiResp)
-	_, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivty(uid, sourceId) //截止支付时间倒计时
+	resp.PayTimeCountdown = payTimeCountdown //截止支付时间倒计时
 	resp.CodeUrl = codeUrl
 	resp.OrderCode = item.OrderCode
 	br.Data = resp
@@ -398,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(activityVivoIds)
+
 	activityLabelKeyword := services.GetActivityOrderListLabelKeywordByActivityIds(activityIds)
 
 	for _, v := range list {
@@ -443,9 +494,14 @@ func (this *OrderController) UserOrderList() {
 				item.StartDate = v.StartDate.Format(utils.FormatDate)
 				item.EndDate = v.EndDate.Format(utils.FormatDate)
 			}
-		} else {
+		} else if orderType == 2 {
 			item.LabelKeywordImgLink = utils.LABEL_ICO_3
 			item.LabelKeyword = activityLabelKeyword[v.SourceId]
+		} else if orderType == 3 {
+			item.LabelKeyword = "活动回放" //日卡图标
+		}
+		if v.OrderType == 3 {
+			item.PlaySeconds = mapActivityVivo[v.SourceId]
 		}
 		item.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
 		resp.List = append(resp.List, item)

+ 12 - 0
models/activity.go

@@ -291,6 +291,18 @@ type CygxActivityResp struct {
 	PayTimeCountdown   int                    `description:"支付时间倒计时"`
 	OrderCode          string                 `comment:"订单编号"`
 	GoodsList          []*order.CygxGoodsResp `description:"商品信息"`
+	VivoPoints         VivoPointsResp         `description:"音视频设置"`
+}
+
+type VivoPointsResp struct {
+	HavePoint       bool   `description:"是否被扣过点"`
+	PointPermission int    `description:"1:点数充足、2点数不足需付费、3:只能付费"`
+	CompanyPoints   string `description:"公司剩余点数"`
+	ActivityPoints  string `description:"本场活动要扣除的点数"`
+	//Title           string `description:"标题"`
+	//ResourceUrl     string `description:"链接"`
+	//Type            int    `description:"类型: 1-活动音频; 2-活动视频;"`
+	//PlaySeconds     string `description:"音视频时长"`
 }
 
 type CygxYidongActivityUrlResp struct {

+ 8 - 0
models/activity_video.go

@@ -152,6 +152,14 @@ func GetActivityVideoByVideoIdCount(videoId int) (count int, err error) {
 	return
 }
 
+// 获取数量
+func GetCygxActivityVideoCount(activityId int) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity_video   WHERE activity_id = ? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, activityId).QueryRow(&count)
+	return
+}
+
 type ActivityVideoDetailResp struct {
 	VideoDetail *CygxActivityVideoDetailResp
 	AuthInfo    *UserPermissionAuthInfo

+ 39 - 0
models/activity_vivo_point_record.go

@@ -0,0 +1,39 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+//活动音视频,首次播放扣点记录
+
+type CygxActivityVivoPointRecord struct {
+	RecordId         int       `orm:"column(record_id);pk";comment:"主键ID"`
+	SourceId         int       `comment:"来源ID"`
+	Source           string    `comment:"来源 activityvoice:活动音频、activityvideo:活动视频"`
+	UserId           int       `comment:"用户ID"`
+	Mobile           string    `comment:"手机号"`
+	Email            string    `comment:"邮箱"`
+	CompanyId        int       `comment:"公司ID"`
+	CompanyName      string    `comment:"公司名称"`
+	RealName         string    `comment:"用户实际名称"`
+	SellerName       string    `comment:"所属销售"`
+	CreateTime       time.Time `comment:"创建时间"`
+	ModifyTime       time.Time `comment:"修改时间"`
+	RegisterPlatform int       `comment:"来源 1小程序,2:网页"`
+}
+
+// GetCygxActivityVivoPointRecordCount  查询用户是否扣过点
+func GetCygxActivityVivoPointRecordCount(sourceId, userId int) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) count	FROM cygx_activity_vivo_point_record WHERE source_id = ? AND user_id = ?  `
+	err = o.Raw(sql, sourceId, userId).QueryRow(&count)
+	return
+}
+
+// 添加
+func AddCygxActivityVivoPointRecord(item *CygxActivityVivoPointRecord) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}

+ 32 - 0
models/activity_vivo_points_set.go

@@ -0,0 +1,32 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivityVivoPointsSet struct {
+	PointSetId   int       `orm:"column(point_set_id);pk";comment:"主键id"`
+	ActivityId   int       `comment:"活动ID"`
+	PointsObject string    `comment:"扣点设置方式 1:同报名参会时的扣点数、2:输入其余点数"`
+	PointsNum    float64   `comment:"扣点数量"`
+	GoodsMoney   float64   `comment:"商品总价"`
+	Source       string    `comment:"来源 activityvideo 活动视频、activityvoice 活动音频"`
+	CreateTime   time.Time `comment:"创建时间"`
+	ModifyTime   time.Time `comment:"更新时间"`
+}
+
+// 根据活动ID判断音视频是否设置了扣点
+func GetCygxActivityVivoPointsSetCountByActivityId(activityId int) (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity_vivo_points_set  WHERE activity_id =?  `
+	err = o.Raw(sqlCount, activityId).QueryRow(&count)
+	return
+}
+
+func GetCygxActivityVivoPointsSetByActivityId(activityId int) (item *CygxActivityVivoPointsSet, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_vivo_points_set WHERE activity_id = ?  `
+	err = o.Raw(sql, activityId).QueryRow(&item)
+	return
+}

+ 8 - 0
models/activity_voice.go

@@ -113,6 +113,14 @@ func GetCygxActivityVoiceByActivityId(activityId int) (item *CygxActivityVoice,
 	return
 }
 
+// 获取数量
+func GetCygxActivityVoiceCount(activityId int) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity_voice   WHERE activity_id = ? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, activityId).QueryRow(&count)
+	return
+}
+
 // 获取所有活动音频ID
 func GetActivityVoiceActivityIds() (activityIds string, err error) {
 	sql := `SELECT

+ 1 - 0
models/db.go

@@ -108,6 +108,7 @@ func init() {
 		new(CygxUserAdminShareHistory),
 		new(CygxUserAdminShareCode),
 		new(CygxUserPassword),
+		new(CygxActivityVivoPointRecord),
 	)
 
 	initOrder() // 订单模块

+ 61 - 3
models/micro_roadshow.go

@@ -55,6 +55,7 @@ type MicroRoadShowPageList struct {
 	IndustryId             int       `description:"产业ID"`
 	CreateTime             string    `description:"视频创建时间"`
 	CollectTime            time.Time `description:"收藏时间"`
+	LabelKeywordImgLink    string    `description:"标签关键词ico"`
 	AuthInfo               *UserPermissionAuthInfo
 }
 
@@ -66,9 +67,10 @@ func GetMicroRoadshowVideoByVideoId(videoId int) (item *CygxMicroRoadshowVideo,
 }
 
 type AddVideoHistoryReq struct {
-	SourceId    int `description:"资源ID"`
-	PlaySeconds int `description:"播放时长"`
-	SourceType  int `description:"音视频来源: 1-活动音频; 2-活动视频; 3-产业视频; 4-系列问答"`
+	SourceId        int    `description:"资源ID"`
+	PlaySeconds     int    `description:"播放时长"`
+	SourceType      int    `description:"音视频来源: 1-活动音频; 2-活动视频; 3-产业视频; 4-系列问答"`
+	InviteShareCode string `description:"销售账号邀请码"`
 }
 
 type CygxMicroRoadshowVideoHistory struct {
@@ -629,3 +631,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
+}

+ 5 - 2
models/order/order.go

@@ -25,8 +25,8 @@ type PrepayWithRequestPaymentResponse struct {
 }
 
 type CygxOrderAddReq struct {
-	GoodsId int `description:"商品ID"`
-	//Source   string `description:"资源(文章、活动)"`
+	GoodsId         int    `description:"商品ID"`
+	Source          string `description:"资源(文章、活动)"`
 	SourceId        int    `description:"资源ID"`
 	InviteShareCode string `description:"销售账号邀请码"`
 }
@@ -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:"结束日期"`
 }

+ 8 - 0
models/order/order_virtual_asset.go

@@ -96,6 +96,14 @@ func GetCygxOrderVirtualAssetdCount(condition string, pars []interface{}) (count
 	return
 }
 
+// 获取数量
+func GetCygxOrderVirtualAssetdCountByVivo(sourceId, userId int) (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := ` SELECT COUNT(1) AS  count  FROM cygx_order_virtual_asset WHERE source IN ('activityvideo','activityvoice')   AND  source_id = ?  AND  user_id = ?  `
+	err = o.Raw(sqlCount, sourceId, userId).QueryRow(&count)
+	return
+}
+
 // 获取购买的单场活动
 func GetCygxOrderVirtualAssetActivityList(sourceIds []int, mobile string) (items []*CygxOrderVirtualAsset, err error) {
 	lenArr := len(sourceIds)

+ 9 - 0
routers/commentsRouter.go

@@ -124,6 +124,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "VivoPointRecord",
+            Router: `/vivo_point_record`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_web_mfyx/controllers:ActivityController"],
         beego.ControllerComments{
             Method: "ActivityVoiceHistoryAdd",

+ 20 - 0
services/activity_points.go

@@ -91,3 +91,23 @@ func YanXuanActivityPointsBillSignupCancel(activityId, uid int) (err error) {
 	}
 	return
 }
+
+// 用户观看音视频研选扣点
+func YanXuanActivityVivoPointsBillSignupAdd(activityId, uid int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			msg := fmt.Sprint("activityId:", activityId, "userId:", uid)
+			go utils.SendAlarmMsg("用户观看音视频研选扣点,写入Redis队列消息失败:"+err.Error()+msg, 2)
+		}
+	}()
+	//SourceType int       `description:"1:报名、 2:取消报名、3:活动编辑、4:活动发布,取消发布、5:活动到会。 8:用户观看音视频研选扣点"`
+	log := &models.YanXuanActivityPointsRedis{UserId: uid, ActivityId: activityId, SourceType: 8, RegisterPlatform: utils.REGISTER_PLATFORM, Source: 1, CreateTime: time.Now()}
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.CYGX_YANXUAN_POINTS_KEY, log)
+		if err != nil {
+			fmt.Println("YanXuanActivityPointsRedis LPush Err:" + err.Error())
+		}
+	}
+	return
+}

+ 42 - 18
services/cygx_activity_video_history.go

@@ -49,7 +49,7 @@ import (
 //}
 
 // 记录用户活动音频播放记录
-func AddActivityVideoHistory(user *models.WxUserItem, activityId, playSeconds int) {
+func AddActivityVideoHistory(user *models.WxUserItem, activityId, playSeconds int, inviteShareCode string) {
 	// 十分钟之内的合并
 	key := utils.CYGX_VIDEO_HISTORY_KEY + utils.CYGX_OBJ_ACTIVITYVIDEO + strconv.Itoa(activityId) + "_" + strconv.Itoa(user.UserId)
 	if utils.Rc.IsExist(key) {
@@ -59,7 +59,7 @@ func AddActivityVideoHistory(user *models.WxUserItem, activityId, playSeconds in
 	var err error
 	defer func() {
 		if err != nil {
-			go utils.SendAlarmMsg(fmt.Sprint("记录用户活动音频播放记录失败 AddActivityVoiceHistory Err:", err.Error(), "活动ID:", activityId, "UserId:", user.UserId), 2)
+			go utils.SendAlarmMsg(fmt.Sprint("添加活动视频的播放记录失败 AddActivityVideoHistory Err:", err.Error(), "活动ID:", activityId, "UserId:", user.UserId), 2)
 		}
 	}()
 	activityVideoInfo, e := models.GetCygxActivityVideoByActivityId(activityId)
@@ -91,27 +91,30 @@ func AddActivityVideoHistory(user *models.WxUserItem, activityId, playSeconds in
 	//添加记录
 	e = models.AddCygxActivityVideoHistory(item)
 	if e != nil {
-		err = errors.New("AddCygxActivityVoiceHistory, Err: " + e.Error())
+		err = errors.New("AddCygxActivityVideoHistory, Err: " + e.Error())
 		return
 	}
 	//播放记录加1
 	e = models.UpdateActivityVideoCounts(activityId)
 	if e != nil {
-		err = errors.New("UpdateCygxActivityVoiceCounts, Err: " + e.Error())
+		err = errors.New("UpdateActivityVideoCounts, Err: " + e.Error())
 		return
 	}
 	//设置消息提醒
 	go ActivityVideoUserRmind(user, activityId, 1)
+
+	go AddCygxUserAdminShareHistory(user, utils.CYGX_OBJ_ACTIVITYVIDEO, activityVideoInfo.VideoName, inviteShareCode, activityId)
+
 	return
 }
 
 // 记录用户活动音频播放记录
-func AddActivityVoiceHistory(user *models.WxUserItem, activityId, playSeconds int) {
-	key := utils.CYGX_VIDEO_HISTORY_KEY + utils.CYGX_OBJ_ACTIVITYVOICE + strconv.Itoa(activityId) + "_" + strconv.Itoa(user.UserId)
-	if utils.Rc.IsExist(key) {
+func AddActivityVoiceHistory(user *models.WxUserItem, activityId, playSeconds int, inviteShareCode string) {
+	if playSeconds == 0 {
 		return
 	}
-	utils.Rc.Put(key, 1, 10*time.Minute)
+	key := utils.CYGX_VIDEO_HISTORY_KEY + utils.CYGX_OBJ_ACTIVITYVOICE + strconv.Itoa(activityId) + "_" + strconv.Itoa(user.UserId)
+
 	var err error
 	defer func() {
 		if err != nil {
@@ -138,19 +141,40 @@ func AddActivityVoiceHistory(user *models.WxUserItem, activityId, playSeconds in
 	if sellerItem != nil {
 		item.SellerName = sellerItem.RealName
 	}
-	//添加记录
-	e = models.AddCygxActivityVoiceHistory(item)
+	activityVoiceInfo, e := models.GetCygxActivityVoiceByActivityId(activityId)
 	if e != nil {
-		err = errors.New("AddCygxActivityVoiceHistory, Err: " + e.Error())
+		err = errors.New("GetCygxActivityVoiceByActivityId, Err: " + e.Error())
 		return
 	}
-	//播放记录加1
-	e = models.UpdateCygxActivityVoiceCounts(activityId)
-	if e != nil {
-		err = errors.New("UpdateCygxActivityVoiceCounts, Err: " + e.Error())
-		return
+	if !utils.Rc.IsExist(key) {
+		//添加记录
+		e = models.AddCygxActivityVoiceHistory(item)
+		if e != nil {
+			err = errors.New("AddCygxActivityVoiceHistory, Err: " + e.Error())
+			return
+		}
+		//播放记录加1
+		e = models.UpdateCygxActivityVoiceCounts(activityId)
+		if e != nil {
+			err = errors.New("UpdateCygxActivityVoiceCounts, Err: " + e.Error())
+			return
+		}
+		utils.Rc.Put(key, 1, 10*time.Minute)
+		//设置消息提醒
+		go ActivityVideoUserRmind(user, activityId, 2)
+		go AddCygxUserAdminShareHistory(user, utils.CYGX_OBJ_ACTIVITYVOICE, activityVoiceInfo.VoiceName, inviteShareCode, activityId)
+	} else {
+		lastItem, e := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
+		if e != nil {
+			err = errors.New("GetLastCygxActivityVoiceHistory, Err: " + e.Error())
+			return
+		}
+		e = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(playSeconds), lastItem.Id)
+		if e != nil {
+			err = errors.New("UpdateLastCygxActivityVoiceHistory, Err: " + e.Error())
+			return
+		}
 	}
-	//设置消息提醒
-	go ActivityVideoUserRmind(user, activityId, 2)
+
 	return
 }

+ 99 - 8
services/es_comprehensive.go

@@ -298,12 +298,20 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 	var activityIds []int             //活动
 	var yanxuanSpecialIds []int       // 研选专栏
 	var yanxuanspecialauthorIds []int //研选作者ID
+	var activityvideoIds []string     // 活动视频
+	var activityvoiceIds []string     //活动音频
+	var roadshowIds []string          //微路演
+	var askserieVideoIds []string     //问答系列视频
 	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt  、 产品内测:productinterior
 	for _, v := range list {
 		if v.Source == "article" {
 			articleIds = append(articleIds, v.SourceId)
 		} else if v.Source == "activity" {
 			activityIds = append(activityIds, v.SourceId)
+		} else if v.Source == "activityvideo" {
+			activityvideoIds = append(activityvideoIds, strconv.Itoa(v.SourceId))
+		} else if v.Source == "activityvoice" {
+			activityvoiceIds = append(activityvoiceIds, strconv.Itoa(v.SourceId))
 		} else if v.Source == utils.CYGX_OBJ_YANXUANSPECIAL {
 			yanxuanSpecialIds = append(yanxuanSpecialIds, v.SourceId)
 		} else if v.Source == utils.CYGX_OBJ_YANXUANSPECIAL_AUTHOR {
@@ -466,10 +474,99 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 		}
 	}
 
+	if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds) > 0 {
+
+		audioIdstr := strings.Join(activityvoiceIds, ",")
+		activityVideoIdsStr := strings.Join(activityvideoIds, ",")
+		roadshowIdsStr := strings.Join(roadshowIds, ",")
+		askserieVideoIdsStr := strings.Join(askserieVideoIds, ",")
+
+		listv, _, e := GetMicroRoadShowMycollectV12(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds), 0, audioIdstr, activityVideoIdsStr, roadshowIdsStr, askserieVideoIdsStr, user)
+		if e != nil {
+			err = errors.New("GetMicroRoadShowMycollect, Err: " + e.Error())
+			return
+		}
+		// 用户权限
+		authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+		if e != nil {
+			err = errors.New("GetUserRaiPermissionInfo, Err: " + e.Error())
+			return
+		}
+
+		// 获取默认图配置
+		audioMap, videoMap, audioShareMap, videoShareMap, e := GetMicroRoadShowDefaultImgConfig()
+		if e != nil {
+			err = errors.New("GetMicroRoadShowDefaultImgConfig, Err: " + e.Error())
+			return
+		}
+		//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+		for i := range listv {
+			// 权限
+			au := new(models.UserPermissionAuthInfo)
+			au.SellerName = authInfo.SellerName
+			au.SellerMobile = authInfo.SellerMobile
+			au.HasPermission = authInfo.HasPermission
+			au.OperationMode = authInfo.OperationMode
+			if au.HasPermission == 1 {
+				// 非宏观权限进一步判断是否有权限
+				if listv[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, listv[i].ChartPermissionName) {
+					au.HasPermission = 2
+				}
+			}
+			// 无权限的弹框提示
+			if au.HasPermission != 1 {
+				if au.OperationMode == UserPermissionOperationModeCall {
+					if listv[i].Type == 1 {
+						au.PopupMsg = UserPermissionPopupMsgCallActivity
+					} else {
+						au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
+					}
+				} else {
+					if listv[i].Type == 1 {
+						au.PopupMsg = UserPermissionPopupMsgApplyActivity
+					} else {
+						au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
+					}
+				}
+			}
+			listv[i].AuthInfo = au
+			listv[i].PublishTime = utils.StrTimeToTime(listv[i].PublishTime).Format(utils.FormatDate)
+			// 默认图
+			if listv[i].BackgroundImg == "" {
+				if listv[i].Type == 1 {
+					listv[i].BackgroundImg = audioMap[listv[i].ChartPermissionId]
+				} else {
+					listv[i].BackgroundImg = videoMap[listv[i].ChartPermissionId]
+				}
+			}
+			// 分享图
+			if listv[i].ShareImg == "" {
+				if listv[i].Type == 1 {
+					listv[i].ShareImg = audioShareMap[listv[i].ChartPermissionId]
+				} else {
+					listv[i].ShareImg = videoShareMap[listv[i].ChartPermissionId]
+				}
+			}
+			listv[i].LabelKeywordImgLink = utils.LABEL_ICO_10
+		}
+		//Type                int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频"`
+		for _, item := range listv {
+			if item.Type == 1 {
+				mapItems[fmt.Sprint("activityvoice", item.Id)].Activityvoice = item
+			} else if item.Type == 2 {
+				mapItems[fmt.Sprint("activityvideo", item.Id)].Activityvideo = item
+			} else if item.Type == 3 {
+				mapItems[fmt.Sprint("roadshow", item.Id)].Roadshow = item
+			} else if item.Type == 4 {
+				mapItems[fmt.Sprint(utils.CYGX_OBJ_ASKSERIEVIDEO, item.Id)].AskserieVideo = item
+			}
+		}
+	}
+
 	for _, vList := range list {
 		for _, v := range mapItems {
 			//如果这些类型都为空,那么就不合并
-			if v.Article == nil && v.Activity == nil && v.YanxuanSpecial == nil && v.YanxuanSpecialAuthor == nil {
+			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.YanxuanSpecial == nil && v.AskserieVideo == nil {
 				continue
 			}
 			if v.SourceId == vList.SourceId && v.Source == vList.Source {
@@ -499,7 +596,7 @@ func SqlComprehensiveSearch(user *models.WxUserItem, keyWord string, startSize,
 	}
 
 	//yanxuanspecialIds = append(yanxuanspecialIds, 0)
-	condition := " AND source IN ('article','activity','yanxuanspecial')   " // 只有研选的文章、研选的活动、研选的专栏这三种
+	condition := " AND source IN ('article','activity','yanxuanspecial','activityvoice','activityvideo')  AND IF   ( source IN('activityvoice','activityvideo') , chart_permission_id = 31 ,1=1 ) " // 只有研选的文章、研选的活动、研选的专栏这三种
 	condition += `  AND IF ( source = 'article' , source_id   IN (` + strings.Join(yanxuanArticleIdsStr, ",") + `) ,1=1 ) `
 	//pars = append(pars, yanxuanArticleIds)
 
@@ -539,11 +636,7 @@ func SqlComprehensiveSearch(user *models.WxUserItem, keyWord string, startSize,
 	var searchTotal int
 	searchTotal = (startSize/pageSize + 1) * pageSize
 	var list []*models.CygxResourceData
-	fmt.Println("totalTitle", totalTitle)
-	fmt.Println("totalContent", totalContent)
-	fmt.Println(searchTotal)
 	if totalTitle >= searchTotal {
-		fmt.Println("1")
 		//全部都是标题搜索
 		list, e = models.GetResourceDataAndYanxuanSpecialAuthorListCondition(conditionTitle, parsTitle, conditionContentYxAuthor, parsContentYxAuthor, startSize, pageSize)
 		if e != nil && e.Error() != utils.ErrNoRow() {
@@ -551,7 +644,6 @@ func SqlComprehensiveSearch(user *models.WxUserItem, keyWord string, startSize,
 			return
 		}
 	} else if totalTitle <= searchTotal-pageSize {
-		fmt.Println("2")
 		//全部都是内容搜索
 		startSize = startSize - totalTitle
 
@@ -561,7 +653,6 @@ func SqlComprehensiveSearch(user *models.WxUserItem, keyWord string, startSize,
 			return
 		}
 	} else {
-		fmt.Println("3")
 		//一半标题搜索,一半内容搜索
 
 		//list, e = models.GetResourceDataListCondition(conditionTitle, parsTitle, startSize, pageSize)

+ 26 - 0
services/micro_roadshow.go

@@ -857,3 +857,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
+}

+ 168 - 0
services/order.go

@@ -86,6 +86,142 @@ func GetGoodsInfoByActivity(item *models.ActivityDetail) (goodsListResp []*order
 	return
 }
 
+// 获取单场活动音视频关联的商品配置信息
+func GetGoodsInfoByActivityVivo(item *models.ActivityDetail) (goodsListResp []*order.CygxGoodsResp) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("获取单场活动关联的商品配置信息失败 GetGoodsInfoByActivity, err:", err.Error()), 2)
+		}
+	}()
+	activityId := item.ActivityId
+
+	total, e := models.GetCygxActivityVivoPointsSetCountByActivityId(activityId)
+	if e != nil {
+		err = errors.New("GetCygxActivityPointsSetUserNum, Err: " + e.Error())
+		return
+	}
+	if total == 0 {
+		goodsListResp = make([]*order.CygxGoodsResp, 0)
+		return
+	}
+
+	vivoPointsSetDetail, e := models.GetCygxActivityVivoPointsSetByActivityId(activityId)
+	if e != nil {
+		err = errors.New("GetCygxActivityVivoPointsSetCountByActivityId, Err: " + e.Error())
+		return
+	}
+
+	var condition string
+	var pars []interface{}
+	condition = ` AND  goods_id IN  (9) `
+
+	goodsList, e := order.GetCygxGoodsList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxGoodsList, Err: " + e.Error())
+		return
+	}
+
+	for k, _ := range goodsList {
+		goodsList[k].CurrentPrice = fmt.Sprint(vivoPointsSetDetail.GoodsMoney)
+		goodsList[k].Price = fmt.Sprint(vivoPointsSetDetail.GoodsMoney)
+		goodsList[k].PopupPriceMsg = fmt.Sprint("¥", vivoPointsSetDetail.GoodsMoney)
+	}
+
+	goodsListResp = goodsList
+	return
+}
+
+func GetActivityVivoPoints(item *models.ActivityDetail, wxUser *models.WxUserItem, havePower bool) (vivoPointsResp models.VivoPointsResp) {
+	if wxUser.UserId == 0 {
+		return
+	}
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("获取单场活动关联的商品配置信息失败 GetGoodsInfoByActivity, err:", err.Error()), 2)
+		}
+	}()
+	activityId := item.ActivityId
+
+	total, e := models.GetCygxActivityVivoPointsSetCountByActivityId(activityId)
+	if e != nil {
+		err = errors.New("GetCygxActivityPointsSetUserNum, Err: " + e.Error())
+		return
+	}
+
+	if total == 0 {
+		//如果没有设置就直接播放
+		vivoPointsResp.HavePoint = true
+		return
+	}
+
+	totalMySuccess, e := models.GetActivitySignupCount(wxUser.UserId, activityId)
+	if e != nil {
+		err = errors.New("GetActivitySignupCount, Err: " + e.Error())
+		return
+	}
+
+	totalPayVivo, e := order.GetCygxOrderVirtualAssetdCountByVivo(activityId, wxUser.UserId)
+	if e != nil {
+		err = errors.New("GetCygxOrderVirtualAssetdCountByVivo, Err: " + e.Error())
+		return
+	}
+
+	totalPointRecord, e := models.GetCygxActivityVivoPointRecordCount(activityId, wxUser.UserId)
+	if e != nil {
+		err = errors.New("GetCygxActivityVivoPointRecordCount, Err: " + e.Error())
+		return
+	}
+	//如果报了名,或者付费了,或者单独扣点了;就直接观看
+	if totalMySuccess > 0 || totalPayVivo > 0 || totalPointRecord > 0 {
+		vivoPointsResp.HavePoint = true
+	}
+
+	vivoPointsSetDetail, e := models.GetCygxActivityVivoPointsSetByActivityId(activityId)
+	if e != nil {
+		err = errors.New("GetCygxActivityVivoPointsSetCountByActivityId, Err: " + e.Error())
+		return
+	}
+
+	vivoPointsResp.ActivityPoints = fmt.Sprint(vivoPointsSetDetail.PointsNum)
+	// 获取用户所在公司剩余的点
+	companyPointsNum, e := models.GetCompanyPoints(wxUser.CompanyId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCompanyPoints, Err: " + e.Error())
+		return
+	}
+	vivoPointsResp.CompanyPoints = fmt.Sprint(companyPointsNum)
+
+	havePowerYx, e := GetArticleDetailUserPower(wxUser)
+	if e != nil {
+		err = errors.New("GetArticleDetailUserPower, Err: " + e.Error())
+		return
+	}
+	if havePower || havePowerYx {
+		if vivoPointsSetDetail.PointsNum == 0 { //有权限情况下,点数为零的时候直接播放
+			vivoPointsResp.HavePoint = true
+		}
+		if companyPointsNum > 0 {
+			if companyPointsNum >= vivoPointsSetDetail.PointsNum {
+				vivoPointsResp.PointPermission = 1
+			} else {
+				vivoPointsResp.PointPermission = 2
+			}
+		} else {
+			//客户剩余点数为0的情况下,直接支付
+			vivoPointsResp.PointPermission = 3
+		}
+	} else {
+		if vivoPointsSetDetail.GoodsMoney > 0 {
+			vivoPointsResp.PointPermission = 3
+		}
+	}
+	return
+}
+
 // 获取用户十分钟之内是否有相同的订单信息
 func GetHaverEquallyOrderByUser10Min(userId, goodsId int) (orderCode string) {
 	var err error
@@ -147,6 +283,38 @@ func GetHaverEquallyOrderByUser10MinByActivty(userId, sourceId int) (orderCode s
 	return
 }
 
+// 获取用户十分钟之内是否有相同的订单信息
+func GetHaverEquallyOrderByUser10MinByActivtyVivo(userId, sourceId int) (orderCode string, seconds int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("获取用户十分钟之内是否有相同的订单信息失败 GetHaverEquallyOrderByUser10MinByActivty, err:", err.Error()), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	endTime := time.Now().Add(-10 * time.Minute)
+	condition = `  AND order_status = 1  AND source IN ( 'activityvideo', 'activityvoice') AND  user_id = ? AND  source_id = ? AND create_time > ?  AND register_platform = ? ORDER BY order_id DESC  `
+	pars = append(pars, userId, sourceId, endTime, utils.REGISTER_PLATFORM)
+	orderList, e := order.GetCygxOrderList(condition, pars, 0, 1)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCygxOrderList, Err: " + e.Error())
+		return
+	}
+	if len(orderList) == 0 {
+		return
+	} else {
+		for _, v := range orderList {
+			orderCode = v.OrderCode
+			duration := time.Now().Sub(v.CreateTime)
+			// 将时间差转换为秒数
+			seconds = 600 - int(duration.Seconds())
+		}
+	}
+	return
+}
+
 // 获取用户十分钟之内是否有相同的文章订单信息
 func GetHaverEquallyOrderByUser10MinByArticle(userId, sourceId, goodsId int) (orderCode string, seconds int) {
 	var err error

+ 94 - 10
services/resource_data.go

@@ -7,7 +7,6 @@ import (
 	"hongze/hongze_web_mfyx/utils"
 	"strconv"
 	"strings"
-	"time"
 )
 
 func GetResourceDataList(condition string, pars []interface{}, startSize, pageSize int, user *models.WxUserItem) (items []*models.CygxResourceDataNewResp, err error) {
@@ -37,9 +36,9 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 	var activityIds []int         //活动
 	var activityvideoIds []string // 活动视频
 	var activityvoiceIds []string //活动音频
-	var activityspecialIds []int  //专项调研活动
-	var reportselectionIds []int  // 报告精选
 	var yanxuanSpecialIds []int   // 研选专栏
+	var roadshowIds []string      //微路演
+	var askserieVideoIds []string //问答系列视频
 	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt  、 产品内测:productinterior
 	for _, v := range list {
 		if v.Source == "article" {
@@ -50,10 +49,6 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			activityvideoIds = append(activityvideoIds, strconv.Itoa(v.SourceId))
 		} else if v.Source == "activityvoice" {
 			activityvoiceIds = append(activityvoiceIds, strconv.Itoa(v.SourceId))
-		} else if v.Source == "activityspecial" {
-			activityspecialIds = append(activityspecialIds, v.SourceId)
-		} else if v.Source == "reportselection" {
-			reportselectionIds = append(reportselectionIds, v.SourceId)
 		} else if v.Source == utils.CYGX_OBJ_YANXUANSPECIAL {
 			yanxuanSpecialIds = append(yanxuanSpecialIds, v.SourceId)
 		}
@@ -157,7 +152,7 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			mapItems[fmt.Sprint("activity", v.ActivityId)].Activity = v
 		}
 	}
-	fmt.Println(time.Now().UnixMilli())
+
 	//处理研选专栏
 	lenyanxuanSpecialIds := len(yanxuanSpecialIds)
 	if lenyanxuanSpecialIds > 0 {
@@ -179,11 +174,100 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			mapItems[fmt.Sprint(utils.CYGX_OBJ_YANXUANSPECIAL, v.Id)].YanxuanSpecial = v
 		}
 	}
-	fmt.Println(time.Now().UnixMilli())
+
+	if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds) > 0 {
+
+		audioIdstr := strings.Join(activityvoiceIds, ",")
+		activityVideoIdsStr := strings.Join(activityvideoIds, ",")
+		roadshowIdsStr := strings.Join(roadshowIds, ",")
+		askserieVideoIdsStr := strings.Join(askserieVideoIds, ",")
+
+		listv, _, e := GetMicroRoadShowMycollectV12(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds), 0, audioIdstr, activityVideoIdsStr, roadshowIdsStr, askserieVideoIdsStr, user)
+		if e != nil {
+			err = errors.New("GetMicroRoadShowMycollect, Err: " + e.Error())
+			return
+		}
+		// 用户权限
+		authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+		if e != nil {
+			err = errors.New("GetUserRaiPermissionInfo, Err: " + e.Error())
+			return
+		}
+
+		// 获取默认图配置
+		audioMap, videoMap, audioShareMap, videoShareMap, e := GetMicroRoadShowDefaultImgConfig()
+		if e != nil {
+			err = errors.New("GetMicroRoadShowDefaultImgConfig, Err: " + e.Error())
+			return
+		}
+		//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+		for i := range listv {
+			// 权限
+			au := new(models.UserPermissionAuthInfo)
+			au.SellerName = authInfo.SellerName
+			au.SellerMobile = authInfo.SellerMobile
+			au.HasPermission = authInfo.HasPermission
+			au.OperationMode = authInfo.OperationMode
+			if au.HasPermission == 1 {
+				// 非宏观权限进一步判断是否有权限
+				if listv[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, listv[i].ChartPermissionName) {
+					au.HasPermission = 2
+				}
+			}
+			// 无权限的弹框提示
+			if au.HasPermission != 1 {
+				if au.OperationMode == UserPermissionOperationModeCall {
+					if listv[i].Type == 1 {
+						au.PopupMsg = UserPermissionPopupMsgCallActivity
+					} else {
+						au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
+					}
+				} else {
+					if listv[i].Type == 1 {
+						au.PopupMsg = UserPermissionPopupMsgApplyActivity
+					} else {
+						au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
+					}
+				}
+			}
+			listv[i].AuthInfo = au
+			listv[i].PublishTime = utils.StrTimeToTime(listv[i].PublishTime).Format(utils.FormatDate)
+			// 默认图
+			if listv[i].BackgroundImg == "" {
+				if listv[i].Type == 1 {
+					listv[i].BackgroundImg = audioMap[listv[i].ChartPermissionId]
+				} else {
+					listv[i].BackgroundImg = videoMap[listv[i].ChartPermissionId]
+				}
+			}
+			// 分享图
+			if listv[i].ShareImg == "" {
+				if listv[i].Type == 1 {
+					listv[i].ShareImg = audioShareMap[listv[i].ChartPermissionId]
+				} else {
+					listv[i].ShareImg = videoShareMap[listv[i].ChartPermissionId]
+				}
+			}
+			listv[i].LabelKeywordImgLink = utils.LABEL_ICO_10
+		}
+		//Type                int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频"`
+		for _, item := range listv {
+			if item.Type == 1 {
+				mapItems[fmt.Sprint("activityvoice", item.Id)].Activityvoice = item
+			} else if item.Type == 2 {
+				mapItems[fmt.Sprint("activityvideo", item.Id)].Activityvideo = item
+			} else if item.Type == 3 {
+				mapItems[fmt.Sprint("roadshow", item.Id)].Roadshow = item
+			} else if item.Type == 4 {
+				mapItems[fmt.Sprint(utils.CYGX_OBJ_ASKSERIEVIDEO, item.Id)].AskserieVideo = item
+			}
+		}
+	}
+
 	for _, vList := range list {
 		for _, v := range mapItems {
 			//如果这些类型都为空,那么就不合并
-			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.ReportSelection == nil && v.YanxuanSpecial == nil && v.AskserieVideo == nil {
+			if v.Article == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.YanxuanSpecial == nil {
 				continue
 			}
 			if v.SourceId == vList.SourceId && v.Source == vList.Source {

+ 4 - 4
services/tag.go

@@ -45,7 +45,7 @@ func AddCygxTagHistory(user *models.WxUserItem, tagId int) (err error) {
 //	fmt.Println(conditionInit)
 //}
 
-func GetConditionInitByTagIds(user *models.WxUserItem, labelKeyword string) (yanxuanActivityIdsResp, yanxuanArticleIdsResp []int, err error) {
+func GetConditionInitByTagIds(user *models.WxUserItem, labelKeyword string) (yanxuanActivityIdsResp, yanxuanArticleIdsResp []int, conditionresp string, err error) {
 	var yanxuanActivityIds []int
 	var yanxuanArticleIds []int
 	var condition string
@@ -89,11 +89,11 @@ func GetConditionInitByTagIds(user *models.WxUserItem, labelKeyword string) (yan
 		}
 	case "全部报告": // 全部报告
 		yanxuanArticleIds = GetYanxuanArticleIds() //获取所有研选文章ID
-
+		conditionresp = `  AND source IN ('article','yanxuanspecial')  `
 	case "专栏": //专栏
-
+		conditionresp = `  AND source IN ('yanxuanspecial')  `
 	case "纪要": //纪要
-
+		conditionresp = `  AND source IN ('article')  `
 		//condition = ` AND  article_type_id > 0  AND  article_type_id != 12  `
 		condition = ` AND  article_type_id > 0  `
 		list, e := models.GetCygxCygxArticleIdList(condition, pars)

+ 27 - 1
services/user_admin_share.go

@@ -62,13 +62,34 @@ func AddCygxUserAdminShareHistory(user *models.WxUserItem, source, sourceTitle,
 	if user.UserId == 0 {
 		return
 	}
+
+	var err error
+	//如果是已经上传了音视的活动不记录
+	if source == utils.CYGX_OBJ_ACTIVITY {
+		totalvi, e := models.GetCygxActivityVideoCount(sourceId)
+		if e != nil {
+			err = errors.New("GetCygxActivityVideoCount, Err: " + e.Error())
+			return
+		}
+		if totalvi > 0 {
+			return
+		}
+		totalvo, e := models.GetCygxActivityVoiceCount(sourceId)
+		if e != nil {
+			err = errors.New("GetCygxActivityVoiceCount, Err: " + e.Error())
+			return
+		}
+		if totalvo > 0 {
+			return
+		}
+	}
 	//3秒之内多次请求,不重复记录
 	key := "CYGX_" + source + "_" + strconv.Itoa(sourceId) + "_" + strconv.Itoa(user.UserId)
 	if utils.Rc.IsExist(key) {
 		return
 	}
 	utils.Rc.Put(key, 1, 3*time.Second)
-	var err error
+
 	defer func() {
 		if err != nil {
 			fmt.Println(err)
@@ -89,8 +110,13 @@ func AddCygxUserAdminShareHistory(user *models.WxUserItem, source, sourceTitle,
 		item.Action = "查看活动"
 	case utils.CYGX_OBJ_ARTICLE:
 		item.Action = "查看报告"
+	case utils.CYGX_OBJ_ACTIVITYVIDEO:
+		item.Action = "查看活动回放"
+	case utils.CYGX_OBJ_ACTIVITYVOICE:
+		item.Action = "查看活动回放"
 	case utils.CYGX_OBJ_YANXUANSPECIAL:
 		item.Action = "查看专栏"
+
 	case "login":
 		item.Action = "注册"
 	}

+ 1 - 0
services/wx_pay.go

@@ -78,6 +78,7 @@ func ExampleNativeApiServicePrepay(orderDetail *order.CygxOrder) (codeUrl string
 	)
 
 	if err != nil {
+		fmt.Println(err)
 		return
 	}
 	codeUrl = *resp.CodeUrl

+ 10 - 9
utils/constants.go

@@ -299,15 +299,16 @@ const (
 )
 
 const (
-	LABEL_ICO_1 string = "https://hzstatic.hzinsights.com/cygx_web/config/maifangjiaoliu.png"           // 买方交流
-	LABEL_ICO_2 string = "https://hzstatic.hzinsights.com/cygx_web/config/zhuanjiadiaoyan.png"          // 专家访谈
-	LABEL_ICO_3 string = "https://hzstatic.hzinsights.com/cygx_web/config/shangshigongsixiaofanwei.png" // 上市公司小范围
-	LABEL_ICO_4 string = "https://hzstatic.hzinsights.com/cygx_web/config/zhuanlan.png"                 // 专栏
-	LABEL_ICO_5 string = "https://hzstatic.hzinsights.com/cygx_web/config/jiyao.png"                    // 纪要
-	LABEL_ICO_6 string = "https://hzstatic.hzinsights.com/cygx_web/config/maifangshalong.png"           // 买方沙龙
-	LABEL_ICO_7 string = "https://hzstatic.hzinsights.com/mfyx/config/rika.png"                         // 日卡图标
-	LABEL_ICO_8 string = "https://hzstatic.hzinsights.com/mfyx/config/yueka.png"                        // 月卡图标
-	LABEL_ICO_9 string = "https://hzstatic.hzinsights.com/cygx_web/config/zhuanlan_author.png"          // 专栏作者
+	LABEL_ICO_1  string = "https://hzstatic.hzinsights.com/cygx_web/config/maifangjiaoliu.png"           // 买方交流
+	LABEL_ICO_2  string = "https://hzstatic.hzinsights.com/cygx_web/config/zhuanjiadiaoyan.png"          // 专家访谈
+	LABEL_ICO_3  string = "https://hzstatic.hzinsights.com/cygx_web/config/shangshigongsixiaofanwei.png" // 上市公司小范围
+	LABEL_ICO_4  string = "https://hzstatic.hzinsights.com/cygx_web/config/zhuanlan.png"                 // 专栏
+	LABEL_ICO_5  string = "https://hzstatic.hzinsights.com/cygx_web/config/jiyao.png"                    // 纪要
+	LABEL_ICO_6  string = "https://hzstatic.hzinsights.com/cygx_web/config/maifangshalong.png"           // 买方沙龙
+	LABEL_ICO_7  string = "https://hzstatic.hzinsights.com/mfyx/config/rika.png"                         // 日卡图标
+	LABEL_ICO_8  string = "https://hzstatic.hzinsights.com/mfyx/config/yueka.png"                        // 月卡图标
+	LABEL_ICO_9  string = "https://hzstatic.hzinsights.com/cygx_web/config/zhuanlan_author.png"          // 专栏作者
+	LABEL_ICO_10 string = "https://hzstatic.hzinsights.com/cygx_web/config/activity_vivo.png"            // 专栏作者
 )
 
 const (