Ver Fonte

Merge branch 'cygx_12.4' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai há 1 ano atrás
pai
commit
82b4f40acb

+ 1 - 49
controllers/activity.go

@@ -3684,7 +3684,6 @@ func (this *ActivityCoAntroller) ActivityVoiceHistoryAdd() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
 	var req models.ActivityIdRep
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
 	if err != nil {
@@ -3707,55 +3706,8 @@ func (this *ActivityCoAntroller) ActivityVoiceHistoryAdd() {
 		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
 		return
 	}
-	var sellerName string
-	sellerName, err = models.GetCompanySellerName(user.CompanyId)
-	if err != nil {
-		br.Msg = "报名失败!"
-		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
-		return
-	}
-	item := models.CygxActivityVoiceHistory{
-		ActivityId:  activityId,
-		UserId:      uid,
-		CreateTime:  time.Now(),
-		Mobile:      user.Mobile,
-		Email:       user.Email,
-		CompanyId:   user.CompanyId,
-		CompanyName: user.CompanyName,
-		RealName:    user.RealName,
-		SellerName:  sellerName,
-		PlaySeconds: strconv.Itoa(req.PlaySeconds),
-		ModifyTime:  time.Now(),
-	}
 
-	if playSeconds != 0 {
-		lastItem, err := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
-		if err != nil {
-			br.Msg = "操作失败"
-			br.ErrMsg = "操作失败,GetLastCygxActivityVoiceHistory Err:" + err.Error()
-			return
-		}
-		err = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
-		if err != nil {
-			br.Msg = "更新失败"
-			br.ErrMsg = "更新失败,UpdateLastCygxActivityVoiceHistory Err:" + err.Error()
-			return
-		}
-	} else {
-		err = models.AddCygxActivityVoiceHistory(&item)
-		if err != nil {
-			br.Msg = "操作失败"
-			br.ErrMsg = "操作失败,Err:" + err.Error()
-			return
-		}
-		err = models.UpdateCygxActivityVoiceCounts(activityId)
-		if err != nil {
-			br.Msg = "更新失败"
-			br.ErrMsg = "更新失败,Err:" + err.Error()
-			return
-		}
-		go services.ActivityVideoUserRmind(user, activityId, 2)
-	}
+	go services.AddActivityVoiceHistory(user, activityId, playSeconds)
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"

+ 2 - 54
controllers/micro_roadshow.go

@@ -234,7 +234,6 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
 	var req models.AddVideoHistoryReq
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
 	if err != nil {
@@ -248,66 +247,15 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
 	if sourceType == 0 {
 		sourceType = 1
 	}
-	var sellerName string
-	sellerName, err = models.GetCompanySellerName(user.CompanyId)
-	if err != nil {
-		br.Msg = "报名失败!"
-		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
-		return
-	}
 	if sourceType == 1 {
 		//添加活动音频的播放记录
 		go services.AddActivityVoiceHistory(user, sourceId, playSeconds)
 	} else if sourceType == 2 {
 		//添加活动视频的播放记录
 		go services.AddActivityVideoHistory(user, sourceId, playSeconds)
-		//if err != nil {
-		//	br.Msg = "更新失败"
-		//	br.ErrMsg = "更新失败,AddActivityVideoHistory Err:" + err.Error()
-		//	return
-		//}
 	} else if sourceType == 3 {
-		item := models.CygxMicroRoadshowVideoHistory{
-			VideoId:     sourceId,
-			UserId:      uid,
-			Mobile:      user.Mobile,
-			Email:       user.Email,
-			CompanyId:   user.CompanyId,
-			CompanyName: user.CompanyName,
-			RealName:    user.RealName,
-			SellerName:  sellerName,
-			PlaySeconds: strconv.Itoa(playSeconds),
-			CreateTime:  time.Now(),
-			ModifyTime:  time.Now(),
-		}
-		if playSeconds != 0 {
-			lastItem, err := models.GetLastCygxMicroRoadshowVideoHistory(sourceId, user.UserId)
-			if err != nil {
-				br.Msg = "操作失败"
-				br.ErrMsg = "操作失败,GetLastCygxMicroRoadshowVideoHistory Err:" + err.Error()
-				return
-			}
-			err = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
-			if err != nil {
-				br.Msg = "更新失败"
-				br.ErrMsg = "更新失败,UpdateLastCygxActivityVideoHistory Err:" + err.Error()
-				return
-			}
-		} else {
-			err = models.AddCygxMicroRoadshowVideoHistory(&item)
-			if err != nil {
-				br.Msg = "操作失败"
-				br.ErrMsg = "操作失败,Err:" + err.Error()
-				return
-			}
-			err = models.UpdateCygxActivityVideoCounts(sourceId)
-			if err != nil {
-				br.Msg = "更新失败"
-				br.ErrMsg = "更新失败,Err:" + err.Error()
-				return
-			}
-		}
-		go services.MicroRoadshowVideoUserRmind(user, sourceId)
+		// 添加产业视频播放记录
+		go services.AddMicroRoadshowVideoRecord(user, sourceId, playSeconds)
 	} else if sourceType == 4 {
 		go services.AddAskserieVideoHistoryRecord(user, sourceId, playSeconds)
 	}

+ 1 - 3
models/activity.go

@@ -879,11 +879,9 @@ GROUP BY
 func GetActivityMsgExport(activityId int) (item []*ActivityMsgExportRep, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
-			k.*,
-			u.real_name 
+			k.*
 			FROM
 			cygx_activity_help_ask AS k
-			LEFT JOIN wx_user AS u ON u.user_id = k.user_id 
 			WHERE
 			k.activity_id = ? 
 			GROUP BY

+ 2 - 1
models/activity_signup.go

@@ -147,8 +147,9 @@ func AddActivitySignupFromEmail(item *CygxActivitySignup) (lastId int64, err err
 	}()
 	var count int
 	var countMySchedule int
+	ow := orm.NewOrmUsingDB("weekly_report")
 	sql := `UPDATE wx_user SET outbound_mobile=? ,outbound_country_code = ? ,is_msg_outbound_mobile = 1   WHERE user_id=? `
-	_, err = o.Raw(sql, item.OutboundMobile, item.CountryCode, item.UserId).Exec()
+	_, err = ow.Raw(sql, item.OutboundMobile, item.CountryCode, item.UserId).Exec()
 	if err != nil {
 		return
 	}

+ 21 - 0
models/activity_video_history.go

@@ -50,3 +50,24 @@ func UpdateCygxActivityVideoHistory(wxUser *WxUserItem) (err error) {
 	}
 	return
 }
+
+func GetLastCygxActivityVideoHistory(activityId, userId int) (item *CygxActivityVoiceHistory, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM cygx_activity_video_history WHERE activity_id=?  AND user_id=? AND register_platform = 1 ORDER BY create_time DESC limit 1 `
+	err = o.Raw(sql, activityId, userId).QueryRow(&item)
+	return
+}
+
+//func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) {
+//	o := orm.NewOrm()
+//	sql := ` UPDATE cygx_micro_roadshow_video_history SET play_seconds =? WHERE id=? `
+//	_, err = o.Raw(sql, playSeconds, lastId).Exec()
+//	return
+//}
+
+func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` UPDATE cygx_activity_video_history SET play_seconds =? WHERE id=? `
+	_, err = o.Raw(sql, playSeconds, lastId).Exec()
+	return
+}

+ 1 - 1
models/activity_voice_history.go

@@ -30,7 +30,7 @@ func AddCygxActivityVoiceHistory(item *CygxActivityVoiceHistory) (err error) {
 
 func GetLastCygxActivityVoiceHistory(activityId, userId int) (item *CygxActivityVoiceHistory, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT * FROM cygx_activity_voice_history WHERE activity_id=? AND user_id=? ORDER BY create_time DESC limit 1 `
+	sql := ` SELECT * FROM cygx_activity_voice_history WHERE activity_id=?  AND user_id=? AND register_platform = 1 ORDER BY create_time DESC limit 1 `
 	err = o.Raw(sql, activityId, userId).QueryRow(&item)
 	return
 }

+ 0 - 31
models/apply_record.go

@@ -41,37 +41,6 @@ type CygxApplyRecordResp struct {
 	ApplicationSource   string    `description:"申请来源"`
 }
 
-func AddApplyRecordold(item *ApplyTryReq, mobile, companyNamePay string, userId, companyIdPay, CompanyIdType int) (err error) {
-	o, err := orm.NewOrm().Begin()
-	if err != nil {
-		return
-	}
-	defer func() {
-		if err != nil {
-			o.Rollback()
-		} else {
-			o.Commit()
-		}
-	}()
-
-	sql := `INSERT INTO cygx_apply_record (user_id,business_card_url, real_name,company_name, mobile,create_time, apply_method,company_id_pay,company_name_pay,company_id_type)
-          VALUES(?,?,?,?,?,?,?,?,?,?) `
-	_, err = o.Raw(sql, userId, item.BusinessCardUrl, item.RealName, item.CompanyName, mobile, time.Now(), item.ApplyMethod, companyIdPay, companyNamePay, CompanyIdType).Exec()
-	if err != nil {
-		return
-	}
-	msql := `UPDATE  wx_user
-		SET
-		  note = ?,
-		  is_note = 1,
-		  apply_method = ?,
-          real_name=?,
-		  mobile=?
-		WHERE user_id = ? `
-	_, err = o.Raw(msql, item.CompanyName, item.ApplyMethod, item.RealName, mobile, userId).Exec()
-	return
-}
-
 func AddApplyRecord(item *CygxApplyRecord) (err error) {
 	o, err := orm.NewOrm().Begin()
 	if err != nil {

+ 14 - 0
models/askserie_video_history_record.go

@@ -34,3 +34,17 @@ func UpdateAskserieVideoCounts(askserieVideoId int) (err error) {
 	_, err = o.Raw(sql, askserieVideoId).Exec()
 	return
 }
+
+func GetLastCygxAskserieVideoHistoryRecord(activityId, userId int) (item *CygxActivityVoiceHistory, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM cygx_askserie_video_history_record WHERE askserie_video_id=?  AND user_id=? AND register_platform = 1 ORDER BY create_time DESC limit 1 `
+	err = o.Raw(sql, activityId, userId).QueryRow(&item)
+	return
+}
+
+func UpdateLastCygxAskserieVideoHistoryRecord(playSeconds string, lastId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` UPDATE cygx_askserie_video_history_record SET video_duration = ? WHERE id=? `
+	_, err = o.Raw(sql, playSeconds, lastId).Exec()
+	return
+}

+ 0 - 7
models/micro_roadshow.go

@@ -543,13 +543,6 @@ func GetHomeNewestListUnionCount(condition string, pars []interface{}) (count in
 	return
 }
 
-func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) {
-	o := orm.NewOrm()
-	sql := ` UPDATE cygx_micro_roadshow_video_history SET play_seconds =? WHERE id=? `
-	_, err = o.Raw(sql, playSeconds, lastId).Exec()
-	return
-}
-
 // MicroRoadshowVideo 微路演视频
 type MicroRoadshowVideo struct {
 	VideoId             int       `orm:"column(video_id);pk" description:"视频ID"`

+ 15 - 14
models/micro_roadshow_video_history.go

@@ -6,21 +6,22 @@ import (
 )
 
 type CygxMicroRoadshowVideoHistory struct {
-	Id          int       `orm:"column(id);pk"description:"微路演视频浏览记录表id"`
-	VideoId     int       `description:"微路演视频id"`
-	UserId      int       `description:"用户id"`
-	Mobile      string    `description:"手机号"`
-	Email       string    `description:"邮箱"`
-	CompanyId   int       `description:"公司Id"`
-	CompanyName string    `description:"公司名称"`
-	RealName    string    `description:"用户实际名称"`
-	SellerName  string    `description:"所属销售"`
-	PlaySeconds string    `description:"播放时间 单位s"`
-	CreateTime  time.Time `description:"视频创建时间"`
-	ModifyTime  time.Time `description:"视频修改时间"`
+	Id               int       `orm:"column(id);pk"description:"微路演视频浏览记录表id"`
+	VideoId          int       `description:"微路演视频id"`
+	UserId           int       `description:"用户id"`
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司Id"`
+	CompanyName      string    `description:"公司名称"`
+	RealName         string    `description:"用户实际名称"`
+	SellerName       string    `description:"所属销售"`
+	PlaySeconds      string    `description:"播放时间 单位s"`
+	CreateTime       time.Time `description:"视频创建时间"`
+	ModifyTime       time.Time `description:"视频修改时间"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
 }
 
-//获取列表信息根据手机号分组
+// 获取列表信息根据手机号分组
 func GetMicroRoadshowVideoHistoryByMobileList(condition string) (items []*CygxMicroRoadshowVideoHistory, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_micro_roadshow_video_history  WHERE 1 =1  ` + condition + `  GROUP BY user_id  `
@@ -28,7 +29,7 @@ func GetMicroRoadshowVideoHistoryByMobileList(condition string) (items []*CygxMi
 	return
 }
 
-//修改用户浏览产业视频的相关信息
+// 修改用户浏览产业视频的相关信息
 func UpdateCygxMicroRoadshowVideoHistory(wxUser *WxUserItem) (err error) {
 	o := orm.NewOrm()
 	var sql string

+ 0 - 18
models/wx_user.go

@@ -390,24 +390,6 @@ type UserLabel struct {
 	Label string `description:"标签 多个用  , 隔开"`
 }
 
-// 对获取关注的产业
-func GetCygxCompanyUserListSplit(userIds string) (labels string, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT
-			(
-			SELECT
-				GROUP_CONCAT( DISTINCT man.industry_name SEPARATOR ',' ) 
-			FROM
-				cygx_industrial_management AS man 
-			WHERE
-				man.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industry_fllow AS f WHERE f.user_id = u.user_id  AND f.type = 1 ) 
-			) AS labels
-		FROM
-			wx_user AS u WHERE  u.user_id  = ? `
-	err = o.Raw(sql, userIds).QueryRow(&labels)
-	return
-}
-
 // 阅读记录
 type ArticlePvCountResp struct {
 	ArticleId int `description:"文章ID"`

+ 1 - 1
models/wx_user_white.go

@@ -60,6 +60,7 @@ func GetWxUserWhiteMobile() (mobileStr string, err error) {
 
 // 获取用户外呼手机号白名单
 func GetWxUserWhiteOutboundMobile() (mobileStr string, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
 	sql := ` SELECT
 			GROUP_CONCAT( DISTINCT u.outbound_mobile SEPARATOR ',' ) AS outboundmobileStr 
 			FROM
@@ -76,7 +77,6 @@ func GetWxUserWhiteOutboundMobile() (mobileStr string, err error) {
 				AND cp.status IN ( '正式', '试用' )
 				AND u.mobile != ''
 				AND u.mobile !=  u.outbound_mobile `
-	o := orm.NewOrmUsingDB("weekly_report")
 	err = o.Raw(sql).QueryRow(&mobileStr)
 	return
 }

+ 0 - 109
services/activity.go

@@ -1847,115 +1847,6 @@ func ActivityAttendanceDetail(cont context.Context) (err error) {
 	return
 }
 
-// 判断是否加入黑名单
-func AddCygxActivityRestrictSignupByAdmin111(activityId int) (err error) {
-	defer func() {
-		if err != nil {
-			fmt.Println(err)
-			go utils.SendAlarmMsg("判断是否加入黑名单记录失败"+err.Error(), 2)
-		}
-	}()
-	total, err := models.GetActivitySignupNomeetingCount(activityId)
-	if err != nil {
-		err = errors.New("GetActivitySignupNomeetingCount" + err.Error())
-		return err
-	}
-	if total == 0 {
-		return err
-	}
-	mobileList, _ := models.GetUserMeetingMobile(activityId)
-	if len(mobileList) >= 0 {
-		for _, v := range mobileList {
-			totalRestrict, err := models.GetRestrictSignupCountByUid(v.UserId)
-			if err != nil {
-				err = errors.New("GetRestrictSignupCountByUid" + err.Error())
-				return err
-			}
-			totalNomeet, err := models.GetActivitySignupNomeetingCountByUid(v.UserId)
-			if err != nil {
-				err = errors.New("GetActivitySignupNomeetingCountByUid" + err.Error())
-				return err
-			}
-			if totalRestrict > 0 && totalNomeet < 3 {
-				err = models.DeleteCygxActivityRestrictSignup(v.UserId)
-				if err != nil {
-					err = errors.New("DeleteCygxActivityRestrictSignup" + err.Error())
-					return err
-				}
-			}
-		}
-	}
-
-	list, err := models.GetActivitySignupNomeetingCountList(activityId)
-	if err != nil {
-		err = errors.New("GetActivitySignupNomeetingCountList" + err.Error())
-		return err
-	}
-	var items []*models.CygxActivitySignupBreak
-	for _, v := range list {
-		totalRestrict, err := models.GetRestrictSignupCountByUid(v.UserId)
-		if err != nil {
-			err = errors.New("GetRestrictSignupCountByUid" + err.Error())
-			return err
-		}
-		totalNomeet, err := models.GetActivitySignupNomeetingCountByUid(v.UserId)
-		if err != nil {
-			err = errors.New("GetActivitySignupNomeetingCountByUid" + err.Error())
-			return err
-		}
-		if totalNomeet >= 3 {
-			if totalRestrict == 0 {
-				infoUser, err := models.GetUserAndCompanyNameList(v.UserId)
-				//if err != nil && err.Error() != utils.ErrNoRow() {
-				if err != nil {
-					err = errors.New("GetUserAndCompanyNameList" + err.Error())
-					return err
-				}
-				if infoUser != nil {
-					item := new(models.CygxActivityRestrictSignup)
-					item.UserId = infoUser.UserId
-					item.CreateTime = time.Now()
-					item.Mobile = infoUser.Mobile
-					item.Email = infoUser.Email
-					item.CompanyId = infoUser.CompanyId
-					item.CompanyName = infoUser.CompanyName
-					item.IsRestrict = 1
-					err = models.AddCygxActivityRestrictSignup(item)
-					if err != nil {
-						err = errors.New("AddCygxActivityRestrictSignup" + err.Error())
-						return err
-					}
-				}
-			}
-		}
-
-		//处理未到会
-		item := new(models.CygxActivitySignupBreak)
-		item.UserId = v.UserId
-		item.ActivityId = v.ActivityId
-		item.CreateTime = time.Now()
-		item.Mobile = v.Mobile
-		item.Email = v.Email
-		item.CompanyId = v.CompanyId
-		item.CompanyName = v.CompanyName
-		item.RealName = v.RealName
-		item.SellerName = v.SellerName
-		items = append(items, item)
-	}
-
-	err = models.DeleteCygxActivitySignupBreakById(activityId)
-	if err != nil {
-		err = errors.New("DeleteCygxActivitySignupBreakById" + err.Error())
-		return
-	}
-	_, err = models.AddCygxActivitySignupBreakList(items)
-	if err != nil {
-		err = errors.New("AddCygxActivitySignupBreakList, Err: " + err.Error())
-		return
-	}
-	return
-}
-
 // 查研观向处理活动用户限制报名
 func AddCygxActivityRestrictSignupByAdmin(activityId int) (err error) {
 	defer func() {

+ 30 - 11
services/askserie_video.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
+	"strconv"
 	"time"
 )
 
@@ -18,6 +19,7 @@ func AddAskserieVideoHistoryRecord(user *models.WxUserItem, askserieVideoId, pla
 	}()
 	item := new(models.CygxAskserieVideoHistoryRecord)
 	item.UserId = user.UserId
+	item.RealName = user.RealName
 	item.AskserieVideoId = askserieVideoId
 	item.VideoDuration = playSeconds
 	item.Mobile = user.Mobile
@@ -35,18 +37,34 @@ func AddAskserieVideoHistoryRecord(user *models.WxUserItem, askserieVideoId, pla
 	if sellerItem != nil {
 		item.SellerName = sellerItem.RealName
 	}
-	//添加记录
-	e = models.AddCygxAskserieVideoHistoryRecord(item)
-	if e != nil {
-		err = errors.New("AddCygxAskserieVideoHistoryRecord, Err: " + e.Error())
-		return
-	}
-	//播放记录加1
-	e = models.UpdateAskserieVideoCounts(askserieVideoId)
-	if e != nil {
-		err = errors.New("UpdateAskserieVideoCounts, Err: " + e.Error())
-		return
+	if playSeconds != 0 {
+		lastItem, e := models.GetLastCygxAskserieVideoHistoryRecord(askserieVideoId, user.UserId)
+		if e != nil {
+			err = errors.New("GetLastCygxActivityVideoHistory, Err: " + e.Error())
+			return
+		}
+		//更新播放时间
+		e = models.UpdateLastCygxAskserieVideoHistoryRecord(strconv.Itoa(playSeconds), lastItem.Id)
+		if e != nil {
+			err = errors.New("UpdateLastCygxAskserieVideoHistoryRecord, Err: " + e.Error())
+			return
+		}
+
+	} else {
+		//添加记录
+		e = models.AddCygxAskserieVideoHistoryRecord(item)
+		if e != nil {
+			err = errors.New("AddCygxAskserieVideoHistoryRecord, Err: " + e.Error())
+			return
+		}
+		//播放记录加1
+		e = models.UpdateAskserieVideoCounts(askserieVideoId)
+		if e != nil {
+			err = errors.New("UpdateActivityVideoCounts, Err: " + e.Error())
+			return
+		}
 	}
+
 	return
 }
 
@@ -60,6 +78,7 @@ func AddCygxAskserieVideoCollection(user *models.WxUserItem, askserieVideoId int
 	}()
 	item := new(models.CygxAskserieVideoCollection)
 	item.UserId = user.UserId
+	item.RealName = user.RealName
 	item.AskserieVideoId = askserieVideoId
 	item.Content = content
 	item.Mobile = user.Mobile

+ 60 - 28
services/cygx_activity_video_history.go

@@ -48,16 +48,17 @@ import (
 //	return
 //}
 
-// 记录用户活动音频播放记录
+// 添加活动视频的播放记录
 func AddActivityVideoHistory(user *models.WxUserItem, activityId, playSeconds int) {
 	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)
 		}
 	}()
 	item := new(models.CygxActivityVideoHistory)
 	item.UserId = user.UserId
+	item.RealName = user.RealName
 	item.ActivityId = activityId
 	item.PlaySeconds = strconv.Itoa(playSeconds)
 	item.Mobile = user.Mobile
@@ -75,20 +76,36 @@ func AddActivityVideoHistory(user *models.WxUserItem, activityId, playSeconds in
 	if sellerItem != nil {
 		item.SellerName = sellerItem.RealName
 	}
-	//添加记录
-	e = models.AddCygxActivityVideoHistory(item)
-	if e != nil {
-		err = errors.New("AddCygxActivityVoiceHistory, Err: " + e.Error())
-		return
-	}
-	//播放记录加1
-	e = models.UpdateActivityVideoCounts(activityId)
-	if e != nil {
-		err = errors.New("UpdateCygxActivityVoiceCounts, Err: " + e.Error())
-		return
+
+	//小程序端的回传两次,第一次没有播放时长,第二次有播放时长
+	if playSeconds != 0 {
+		lastItem, e := models.GetLastCygxActivityVideoHistory(activityId, user.UserId)
+		if e != nil {
+			err = errors.New("GetLastCygxActivityVideoHistory, Err: " + e.Error())
+			return
+		}
+		//更新播放时长
+		e = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
+		if e != nil {
+			err = errors.New("UpdateLastCygxActivityVideoHistory, Err: " + e.Error())
+			return
+		}
+	} else {
+		//添加记录
+		e = models.AddCygxActivityVideoHistory(item)
+		if e != nil {
+			err = errors.New("AddCygxActivityVideoHistory, Err: " + e.Error())
+			return
+		}
+		//播放记录加1
+		e = models.UpdateActivityVideoCounts(activityId)
+		if e != nil {
+			err = errors.New("UpdateActivityVideoCounts, Err: " + e.Error())
+			return
+		}
+		//设置消息提醒
+		go ActivityVideoUserRmind(user, activityId, 1)
 	}
-	//设置消息提醒
-	go ActivityVideoUserRmind(user, activityId, 1)
 	return
 }
 
@@ -102,6 +119,7 @@ func AddActivityVoiceHistory(user *models.WxUserItem, activityId, playSeconds in
 	}()
 	item := new(models.CygxActivityVoiceHistory)
 	item.UserId = user.UserId
+	item.RealName = user.RealName
 	item.ActivityId = activityId
 	item.PlaySeconds = strconv.Itoa(playSeconds)
 	item.Mobile = user.Mobile
@@ -119,19 +137,33 @@ func AddActivityVoiceHistory(user *models.WxUserItem, activityId, playSeconds in
 	if sellerItem != nil {
 		item.SellerName = sellerItem.RealName
 	}
-	//添加记录
-	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
+	//小程序端的回传两次,第一次没有播放时长,第二次有播放时长
+	if playSeconds != 0 {
+		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
+		}
+	} else {
+		//添加记录
+		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
+		}
+		//设置消息提醒
+		go ActivityVideoUserRmind(user, activityId, 2)
 	}
-	//设置消息提醒
-	go ActivityVideoUserRmind(user, activityId, 2)
 	return
 }

+ 57 - 0
services/micro_roadshow.go

@@ -8,6 +8,7 @@ import (
 	"hongze/hongze_cygx/utils"
 	"strconv"
 	"strings"
+	"time"
 )
 
 // GetMicroRoadShowDefaultImgConfig 获取微路演默认图/分享图配置
@@ -965,3 +966,59 @@ func MicroRoadshowVideoUserRmind(user *models.WxUserItem, videoId int) (err erro
 	}
 	return
 }
+
+// 记录产业视频播放记录
+func AddMicroRoadshowVideoRecord(user *models.WxUserItem, videoId, playSeconds int) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("记录用户活动音频播放记录失败 AddMicroRoadshowVideoRecord Err:", err.Error(), "videoId:", videoId, "UserId:", user.UserId), 2)
+		}
+	}()
+	item := new(models.CygxMicroRoadshowVideoHistory)
+	item.UserId = user.UserId
+	item.RealName = user.RealName
+	item.VideoId = videoId
+	item.PlaySeconds = strconv.Itoa(playSeconds)
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	item.RegisterPlatform = utils.REGISTER_PLATFORM
+	sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
+		return
+	}
+	if sellerItem != nil {
+		item.SellerName = sellerItem.RealName
+	}
+	if playSeconds != 0 {
+		lastItem, e := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
+		if e != nil {
+			err = errors.New("GetLastCygxMicroRoadshowVideoHistory, Err: " + e.Error())
+			return
+		}
+		e = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
+		if e != nil {
+			err = errors.New("UpdateLastCygxActivityVideoHistory, Err: " + e.Error())
+			return
+		}
+	} else {
+		e = models.AddCygxMicroRoadshowVideoHistory(item)
+		if e != nil {
+			err = errors.New("AddCygxMicroRoadshowVideoHistory, Err: " + e.Error())
+			return
+		}
+		e = models.UpdateCygxActivityVideoCounts(videoId)
+		if e != nil {
+			err = errors.New("UpdateCygxActivityVideoCounts, Err: " + e.Error())
+			return
+		}
+		go MicroRoadshowVideoUserRmind(user, videoId)
+	}
+
+	return
+}