Эх сурвалжийг харах

用户移动之后微路演数据修改

xingzai 2 жил өмнө
parent
commit
187225719e

+ 2 - 2
models/activity_signup.go

@@ -561,7 +561,7 @@ func AddCygxActivityRestrictSignup(item *CygxActivityRestrictSignup) (err error)
 //获取列表信息根据手机号分组
 func GetCygxActivitySignupByMobileList(condition string) (items []*CygxActivitySignup, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_activity_signup  WHERE  1= 1 ` + condition + `  GROUP BY mobile  `
+	sql := `SELECT * FROM cygx_activity_signup_detail  WHERE  1= 1 ` + condition + `  GROUP BY mobile  `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
@@ -569,7 +569,7 @@ func GetCygxActivitySignupByMobileList(condition string) (items []*CygxActivityS
 //修改用户报名的相关信息
 func UpdateCygxActivitySignup(wxUser *WxUserItem) (err error) {
 	o := orm.NewOrm()
-	sql := `UPDATE cygx_activity_signup SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE  mobile=? `
+	sql := `UPDATE cygx_activity_signup_detail SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE  mobile=? `
 	_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
 	return
 }

+ 22 - 0
models/activity_video_history.go

@@ -27,3 +27,25 @@ func AddCygxActivityVideoHistory(item *CygxActivityVideoHistory) (err error) {
 	_, err = o.Insert(item)
 	return
 }
+
+//获取列表信息根据手机号分组
+func GetActivityVideoHistoryByMobileList(condition string) (items []*CygxActivityVideoHistory, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_video_history  WHERE 1 =1  ` + condition + `  GROUP BY user_id  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//修改用户浏览活动视频的相关信息
+func UpdateCygxActivityVideoHistory(wxUser *WxUserItem) (err error) {
+	o := orm.NewOrm()
+	var sql string
+	if wxUser.Mobile != "" {
+		sql = `UPDATE cygx_activity_video_history SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
+		_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
+	} else if wxUser.Email != "" {
+		sql = `UPDATE cygx_activity_video_history SET mobile=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE email=? `
+		_, err = o.Raw(sql, wxUser.Mobile, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Email).Exec()
+	}
+	return
+}

+ 26 - 4
models/activity_voice_history.go

@@ -15,9 +15,9 @@ type CygxActivityVoiceHistory struct {
 	CompanyId   int       `description:"公司id"`
 	CompanyName string    `description:"公司名称"`
 	RealName    string    `description:"用户实际名称"`
-	SellerName      string    `description:"所属销售"`
-	PlaySeconds     string    `description:"播放时间 单位s"`
-	ModifyTime      time.Time `description:"视频修改时间"`
+	SellerName  string    `description:"所属销售"`
+	PlaySeconds string    `description:"播放时间 单位s"`
+	ModifyTime  time.Time `description:"视频修改时间"`
 }
 
 //添加
@@ -39,4 +39,26 @@ func UpdateLastCygxActivityVoiceHistory(playSeconds string, lastId int) (err err
 	sql := ` UPDATE cygx_activity_voice_history SET play_seconds =? WHERE id=? `
 	_, err = o.Raw(sql, playSeconds, lastId).Exec()
 	return
-}
+}
+
+//获取列表信息根据手机号分组
+func GetActivityVoiceHistoryByMobileList(condition string) (items []*CygxActivityVoiceHistory, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_voice_history  WHERE 1 =1  ` + condition + `  GROUP BY user_id  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//修改用户浏览活动音频的相关信息
+func UpdateCygxActivityVoiceHistory(wxUser *WxUserItem) (err error) {
+	o := orm.NewOrm()
+	var sql string
+	if wxUser.Mobile != "" {
+		sql = `UPDATE cygx_activity_voice_history SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
+		_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
+	} else if wxUser.Email != "" {
+		sql = `UPDATE cygx_activity_voice_history SET mobile=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE email=? `
+		_, err = o.Raw(sql, wxUser.Mobile, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Email).Exec()
+	}
+	return
+}

+ 0 - 15
models/micro_roadshow.go

@@ -154,21 +154,6 @@ type AddVideoHistoryReq struct {
 	SourceType  int `description:"视频来源: 1-微路演; 2-活动 (不传默认为1)"`
 }
 
-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:"视频修改时间"`
-}
-
 func GetLastCygxMicroRoadshowVideoHistory(videoId, userId int) (item *CygxMicroRoadshowVideoHistory, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT * FROM cygx_micro_roadshow_video_history WHERE video_id=? AND user_id=? ORDER BY create_time DESC limit 1 `

+ 43 - 0
models/micro_roadshow_video_history.go

@@ -0,0 +1,43 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+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:"视频修改时间"`
+}
+
+//获取列表信息根据手机号分组
+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  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//修改用户浏览产业视频的相关信息
+func UpdateCygxMicroRoadshowVideoHistory(wxUser *WxUserItem) (err error) {
+	o := orm.NewOrm()
+	var sql string
+	if wxUser.Mobile != "" {
+		sql = `UPDATE cygx_micro_roadshow_video_history SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
+		_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
+	} else if wxUser.Email != "" {
+		sql = `UPDATE cygx_micro_roadshow_video_history SET mobile=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE email=? `
+		_, err = o.Raw(sql, wxUser.Mobile, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Email).Exec()
+	}
+	return
+}

+ 3 - 3
models/search_key_word.go

@@ -42,7 +42,7 @@ func GetSearchKeyWordTop() (items []*CygxSearchKeyWord, err error) {
 
 func GetCygxSearchKeyWordList(condition string) (items []*CygxSearchKeyWord, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_search_key_word   WHERE 1 = 1 ` + condition + `  GROUP BY user_id  `
+	sql := `SELECT * FROM cygx_search_key_word_log   WHERE 1 = 1 ` + condition + `  GROUP BY user_id  `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
@@ -52,10 +52,10 @@ func UpdateCygxSearchKeyWord(wxUser *WxUserItem) (err error) {
 	o := orm.NewOrm()
 	var sql string
 	if wxUser.Mobile != "" {
-		sql = `UPDATE cygx_search_key_word SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
+		sql = `UPDATE cygx_search_key_word_log SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
 		_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
 	} else if wxUser.Email != "" {
-		sql = `UPDATE cygx_search_key_word SET mobile=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE email=? `
+		sql = `UPDATE cygx_search_key_word_log SET mobile=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE email=? `
 		_, err = o.Raw(sql, wxUser.Mobile, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Email).Exec()
 	}
 	return

+ 1 - 1
models/send_company_user.go

@@ -338,7 +338,7 @@ func GetCompanyFreezeAndLoss(createTime string) (items []*WxUserOpLogResp, err e
 //获取指定时间内被移动的用户
 func GetWxUserOpLogList(startDate, endDate string) (items []*WxUserOpLogResp, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT company_id,user_id,mobile FROM wx_user_op_log WHERE  log_type IN ('move','add') AND create_time >=  '` + startDate + `' AND create_time <=  '` + endDate + `'   GROUP BY user_id `
+	sql := ` SELECT company_id,user_id,mobile FROM wx_user_op_log WHERE  log_type IN ('move','add') AND create_time >=  '` + startDate + `' AND create_time <=  '` + endDate + `'    GROUP BY user_id `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }

+ 69 - 0
services/wx_user.go

@@ -238,6 +238,75 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 			}
 			// 处理用户的作者关注end
 
+			// 处理用户的活动视频播放
+			listActivityVideo, err := models.GetActivityVideoHistoryByMobileList(condition)
+			if err != nil {
+				fmt.Println("GetArticleDepartmentFollowByMobileList ,Err" + err.Error())
+				return err
+			}
+			for k, v := range listActivityVideo {
+				if v.Mobile != "" {
+					user, err := models.GetWxUserItemByUserId(v.UserId)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+					}
+					if user != nil {
+						fmt.Println(user.RealName, k)
+						err = models.UpdateCygxActivityVideoHistory(user)
+						if err != nil {
+							fmt.Println("UpdateCygxActivityVideoHistory ,Err" + err.Error())
+						}
+					}
+				}
+			}
+			// 处理用户的活动视频播放end
+
+			// 处理用户的活动音频播放
+			listActivityVoice, err := models.GetActivityVoiceHistoryByMobileList(condition)
+			if err != nil {
+				fmt.Println("GetActivityVoiceHistoryByMobileList ,Err" + err.Error())
+				return err
+			}
+			for k, v := range listActivityVoice {
+				if v.Mobile != "" {
+					user, err := models.GetWxUserItemByUserId(v.UserId)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+					}
+					if user != nil {
+						fmt.Println(user.RealName, k)
+						err = models.UpdateCygxActivityVoiceHistory(user)
+						if err != nil {
+							fmt.Println("UpdateCygxActivityVoiceHistory ,Err" + err.Error())
+						}
+					}
+				}
+			}
+			// 处理用户的活动音频播放end
+
+			// 处理用户产业视频的播放记录
+			listMicroRoadshow, err := models.GetMicroRoadshowVideoHistoryByMobileList(condition)
+			if err != nil {
+				fmt.Println("GetMicroRoadshowVideoHistoryByMobileList ,Err" + err.Error())
+				return err
+			}
+			for k, v := range listMicroRoadshow {
+				if v.Mobile != "" {
+					user, err := models.GetWxUserItemByUserId(v.UserId)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+					}
+					if user != nil {
+						fmt.Println(user.RealName, k)
+						err = models.UpdateCygxMicroRoadshowVideoHistory(user)
+						if err != nil {
+							fmt.Println("UpdateCygxMicroRoadshowVideoHistory ,Err" + err.Error())
+						}
+					}
+				}
+			}
+			// 处理用户产业视频的播放记录 end
+
 			//如果手机号不为空,则更新用户的报名信息
 			if mobiles != "" {
 				condition = ` AND mobile IN (` + mobiles + `)`