Browse Source

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into cygx_10.5.2

xingzai 1 year ago
parent
commit
ef575a2e3d
56 changed files with 4057 additions and 638 deletions
  1. 13 27
      controllers/activity.go
  2. 185 34
      controllers/activity_sign.go
  3. 3 83
      controllers/article.go
  4. 33 54
      controllers/report.go
  5. 102 13
      controllers/report_selection.go
  6. 9 98
      controllers/tactics.go
  7. 44 4
      controllers/user.go
  8. 36 1
      models/activity.go
  9. 28 23
      models/activity_attendance_detail.go
  10. 181 1
      models/activity_meet_detail_log.go
  11. 17 0
      models/activity_offline_meeting_detail.go
  12. 13 0
      models/activity_signin.go
  13. 33 1
      models/activity_signup.go
  14. 13 0
      models/activity_signup_break.go
  15. 10 0
      models/activity_special_trip.go
  16. 19 0
      models/admin.go
  17. 29 7
      models/apply_record.go
  18. 23 0
      models/article.go
  19. 0 13
      models/article_category_mapping.go
  20. 1 1
      models/article_history_record_newpv.go
  21. 4 0
      models/db.go
  22. 28 2
      models/industrial_activity_group_management.go
  23. 12 0
      models/industry_fllow.go
  24. 39 0
      models/jmcj_comein_data.go
  25. 32 4
      models/report.go
  26. 21 0
      models/report_mapping.go
  27. 31 0
      models/report_mapping_cygx.go
  28. 24 17
      models/report_selection.go
  29. 34 0
      models/report_selection_log.go
  30. 115 0
      models/user_label.go
  31. 42 0
      models/user_label_activity.go
  32. 43 0
      models/user_label_activity_special.go
  33. 50 0
      models/user_label_article.go
  34. 26 0
      models/wx_user.go
  35. 12 0
      models/xzs_choose_category.go
  36. 27 0
      routers/commentsRouter.go
  37. 42 15
      services/activity.go
  38. 659 0
      services/activity_meeting.go
  39. 27 0
      services/activity_signin.go
  40. 95 2
      services/activity_signup_detail.go
  41. 67 0
      services/activity_wx_template_msg.go
  42. 20 0
      services/admin.go
  43. 47 10
      services/article.go
  44. 85 0
      services/article_history.go
  45. 7 1
      services/company_permission.go
  46. 5 0
      services/industrial_management.go
  47. 1 1
      services/init_10.3.go
  48. 457 0
      services/init_10.5.1.go
  49. 13 4
      services/task.go
  50. 998 0
      services/user_label.go
  51. 14 40
      services/wechat_send_msg.go
  52. 9 8
      services/wx_template_msg.go
  53. 167 168
      services/wx_user.go
  54. 5 6
      services/yidong.go
  55. 3 0
      utils/config.go
  56. 4 0
      utils/constants.go

+ 13 - 27
controllers/activity.go

@@ -345,16 +345,16 @@ func (this *ActivityCoAntroller) Detail() {
 	}
 	activityInfo.SignupNum = signupCount
 
-	havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
+	havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
 		return
 	}
-
+	resp.IsResearchSpecial = isResearchSpecial
 	if havePower {
 		//是否展示限免标签
-		if services.GetShowSustainable() && strings.Contains(activityInfo.ChartPermissionName, "研选") {
+		if services.GetShowSustainable() && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
 			activityInfo.IsShowSustainable = true
 		}
 		resp.HasPermission = 1
@@ -375,23 +375,6 @@ func (this *ActivityCoAntroller) Detail() {
 		if activityInfo.IsHideAppointment == 0 {
 			activityInfo.IsShowAppointment = services.IsShowAppointment(activityInfo.ActivityTypeId, activityInfo.ChartPermissionName)
 		}
-		//if activityInfo.ReportLink != "" {
-		//	artList := strings.Split(activityInfo.ReportLink, "{|}")
-		//	if len(artList) > 0 {
-		//		for _, v := range artList {
-		//			artitem := new(models.ActivityArticleResp)
-		//			artitem.ReportLink = v
-		//			artIdSlice := strings.Split(v, "/")
-		//			if len(artIdSlice) > 0 {
-		//				articleId, _ := strconv.Atoi(artIdSlice[len(artIdSlice)-1])
-		//				artitem.ArticleId = articleId
-		//			}
-		//			activityInfo.ArticleList = append(activityInfo.ArticleList, artitem)
-		//		}
-		//	}
-		//} else {
-		//	activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
-		//}
 		activityInfo.ActivityTypeName = strings.Replace(activityInfo.ActivityTypeName, "(C类)", "", -1)
 
 		//处理活动关联的产业
@@ -542,8 +525,9 @@ func (this *ActivityCoAntroller) Detail() {
 		} else {
 			activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
 		}
-		if (activityInfo.ActivityTypeId == 5 || activityInfo.ActivityTypeId == 6) && services.GetBelongingRai(user.Mobile) {
+		if (activityInfo.ActivityTypeId == 5 || activityInfo.ActivityTypeId == 6) && services.GetBelongingRai(user.Mobile) && activityInfo.SigninImg != "" {
 			activityInfo.IsShowSigninButton = true
+			activityInfo.IsShowSignUpDetail = true
 		}
 		//处理按钮是否展示问题
 		resp.Detail = services.ActivityButtonShow(activityInfo)
@@ -661,12 +645,13 @@ func (this *ActivityCoAntroller) SignupAdd() {
 		resp.IsResearch = true
 	}
 
-	havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
+	havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
 		return
 	}
+	resp.IsResearchSpecial = isResearchSpecial
 	if havePower {
 		hasPermission = 1
 		signupStatus = "Success"
@@ -1184,13 +1169,13 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 		resp.IsResearch = true
 	}
 
-	havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
+	havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
 		return
 	}
-
+	resp.IsResearchSpecial = isResearchSpecial
 	if havePower {
 		hasPermission = 1
 		signupStatus = "Success"
@@ -2084,12 +2069,13 @@ func (this *ActivityCoAntroller) CheckAsk() {
 	}
 	resp := new(models.SignupStatus)
 	hasPermission := 0
-	havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
+	havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
 		return
 	}
+	resp.IsResearchSpecial = isResearchSpecial
 	if havePower {
 		hasPermission = 1
 		signupStatus = "Success"
@@ -3279,13 +3265,13 @@ func (this *ActivityCoAntroller) ActivityAppointmentAdd() {
 	item := new(models.CygxActivityAppointment)
 	resp := new(models.SignupStatus)
 	hasPermission := 0
-	havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
+	havePower, isResearchSpecial, err := services.GetActivityDetailUserPower(user, activityInfo)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
 		return
 	}
-
+	resp.IsResearchSpecial = isResearchSpecial
 	if havePower {
 		hasPermission = 1
 		signupStatus = "Success"

+ 185 - 34
controllers/activity_sign.go

@@ -6,6 +6,7 @@ import (
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -70,6 +71,15 @@ func (this *ActivitySignCoAntroller) Detail() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
+
+	//判断是否已经申请过
+	applyCount, err := models.GetApplyRecordCount(uid)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+		return
+	}
+
 	item := new(models.CygxActivitySignin)
 	item.ActivityId = activityId
 	item.UserId = user.UserId
@@ -82,7 +92,7 @@ func (this *ActivitySignCoAntroller) Detail() {
 	item.CountryCode = user.CountryCode
 	item.OpenId = user.OpenId
 	item.CreateTime = time.Now()
-	if total == 0 && user.Mobile != "" {
+	if total == 0 && (user.Mobile != "" || user.Email != "") && (applyCount > 0 || user.CompanyId > 1) {
 		err = models.AddCygxActivitySignin(item)
 		if err != nil {
 			br.Msg = "签到失败"
@@ -126,17 +136,54 @@ func (this *ActivitySignCoAntroller) Detail() {
 
 		//后期扫码签到,处理是否爽约限制
 		services.CygxActivityRestrictSignupByuid(user.UserId, activityId)
-	}
 
-	if user.Mobile != "" || total > 0 {
+		//线下调研活动扫码签到给对应销售发模版消息
+		services.SendActivitieSignTemplateMsg(user, activityInfo)
+
+		//处理用户标签
+		services.ActivityUserLabelLogAdd(activityId, []string{user.Mobile})
+
+		{
+			//用做后台联系人列表查询
+			itemD := new(models.CygxActivityAttendanceDetail)
+			itemD.ActivityId = activityId
+			itemD.RealName = user.RealName
+			itemD.Mobile = user.Mobile
+			itemD.CompanyName = user.CompanyName
+			itemD.IsMeetingStr = 1
+			itemD.CreateTime = time.Now()
+			var itemDs []*models.CygxActivityAttendanceDetail
+			itemDs = append(itemDs, itemD)
+			services.AddctivitySignupDetailByJmcjNew(itemDs, []int{activityId})
+		}
+
+	}
+	//1,没有签到记录不为潜在客户
+	//2,没有签到记录,手机号不为空,没有申请记录
+	//3,已经有签到记录的
+	if total == 0 && user.CompanyId > 1 || ((user.Mobile != "" || user.Email != "") && applyCount > 0) || total > 0 {
 		resp.IsBindingMobile = true
 	}
 	if user.CompanyId == 1 {
 		detail.IsNewUser = true
 	}
+
+	//潜在客户提交过申请的显示提交时候的公司
+	if applyCount > 0 && (user.Mobile != "" || user.Email != "") && user.CompanyId == 1 {
+		detail, err := models.GetCygxApplyRecordByMobile(user.Mobile)
+		if err != nil {
+			br.Msg = "签到失败"
+			br.ErrMsg = "GetCygxApplyRecordByMobile,Err:" + err.Error()
+			return
+		}
+		user.CompanyName = detail.CompanyName
+	}
 	detail.ActivityId = activityId
 	detail.ActivityName = activityInfo.ActivityName
 	detail.Mobile = user.Mobile
+	if user.Mobile == "" {
+		detail.Mobile = user.Email
+	}
 	detail.RealName = user.RealName
 	detail.CompanyName = user.CompanyName
 
@@ -154,6 +201,9 @@ func (this *ActivitySignCoAntroller) Detail() {
 		if signinDetail != nil {
 			detail.BusinessCard = signinDetail.BusinessCard
 			detail.Mobile = signinDetail.Mobile
+			if signinDetail.Mobile == "" {
+				detail.Mobile = signinDetail.Email
+			}
 			detail.RealName = signinDetail.RealName
 			detail.CompanyName = signinDetail.CompanyName
 			detail.IsNewUser = true
@@ -236,44 +286,61 @@ func (this *ActivitySignCoAntroller) ByHand() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
-	if signinType == 1 {
-		if req.Mobile == "" {
-			br.Msg = "参数错误"
-			br.ErrMsg = "参数错误,手机号为空 为空"
-			return
-		}
-		itemMsgCode, err := models.GetMsgCode(req.Mobile, req.VCode)
-		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
-				br.Msg = "验证码错误,请重新输入"
-				br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+	if user.Mobile == "" && user.Email == "" {
+		if signinType == 1 {
+			if req.Mobile == "" {
+				br.Msg = "参数错误"
+				br.ErrMsg = "参数错误,手机号为空 为空"
 				return
-			} else {
+			}
+			itemMsgCode, err := models.GetMsgCode(req.Mobile, req.VCode)
+			if err != nil {
+				if err.Error() == utils.ErrNoRow() {
+					br.Msg = "验证码错误,请重新输入"
+					br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+					return
+				} else {
+					br.Msg = "验证码错误,请重新输入"
+					br.ErrMsg = "校验验证码失败,Err:" + err.Error()
+					return
+				}
+			}
+			if itemMsgCode == nil {
 				br.Msg = "验证码错误,请重新输入"
-				br.ErrMsg = "校验验证码失败,Err:" + err.Error()
 				return
 			}
-		}
-		if itemMsgCode == nil {
-			br.Msg = "验证码错误,请重新输入"
-			return
-		}
-		userMobile, err := models.GetWxUserItemByMobile(Mobile)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			br.Msg = "签到失败"
-			br.ErrMsg = "获取失败,Err:" + err.Error()
-			return
-		}
-		if userMobile != nil {
-			user = userMobile
+			userMobile, err := models.GetWxUserItemByMobile(Mobile)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "签到失败"
+				br.ErrMsg = "获取失败,Err:" + err.Error()
+				return
+			}
+			if userMobile != nil {
+				user = userMobile
+			}
+		} else {
+			if BusinessCard == "" {
+				br.Msg = "签到失败"
+				br.ErrMsg = "签到失败名片地址为空,Err:"
+				return
+			}
+			item.BusinessCard = BusinessCard
 		}
 	} else {
-		if BusinessCard == "" {
-			br.Msg = "签到失败"
-			br.ErrMsg = "签到失败名片地址为空,Err:"
-			return
+		if signinType == 1 {
+			if CompanyName == "" {
+				br.Msg = "请输入公司名称"
+				return
+			}
+			if RealName == "" {
+				br.Msg = "请输入姓名"
+				return
+			}
 		}
-		item.BusinessCard = BusinessCard
+	}
+	//如果是用邮箱登录的,就把手机号置空
+	if strings.Contains(Mobile, "@") {
+		Mobile = ""
 	}
 	item.ActivityId = activityId
 	item.UserId = user.UserId
@@ -336,3 +403,87 @@ func (this *ActivitySignCoAntroller) ByHand() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title  活动签到到会详情
+// @Description 活动签到到会详情接口
+// @Param   ActivityId   query   int  true       "活动ID"
+// @Success Ret=200 {object} models.CygxActivityResp
+// @router /signup/detail [get]
+func (this *ActivitySignCoAntroller) SignupDetail() {
+	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
+	}
+
+	activityId, _ := this.GetInt("ActivityId")
+	if activityId < 1 {
+		br.Msg = "请输入活动ID"
+		return
+	}
+	resp := new(models.CygxActivityOfflineMeetingDetailResp)
+	activityInfo, err := models.GetAddActivityInfoById(activityId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
+		return
+	}
+	if !services.GetBelongingRai(user.Mobile) {
+		br.Msg = "你暂无查看权限"
+		br.ErrMsg = "你暂无查看权限,UserId:" + strconv.Itoa(user.UserId)
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND do_fail_type = 0 AND activity_id  = ?`
+	pars = append(pars, activityId)
+
+	listSignup, err := models.GetActivitySignupList(condition, pars)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetOfflineMeetingListWithUser,UserId:" + strconv.Itoa(user.UserId)
+		return
+	}
+	//获取对应销售所能查看的用户手机号
+	UserMobileMap, err := services.GetAdminCheckUserMobileMap(user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetAdminCheckUserMobileMap,UserId:" + strconv.Itoa(user.UserId)
+		return
+	}
+	//获取用户的签到时间
+	SigninTimeMap, err := services.GetUserActivitySigninTimeMap(activityId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetUserActivitySigninTimeMap,activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	for _, v := range listSignup {
+		if _, ok := UserMobileMap[v.Mobile]; ok {
+			item := new(models.CygxActivitySignupResp)
+			item.RealName = v.RealName
+			item.CompanyName = v.CompanyName
+			if _, ok := SigninTimeMap[v.UserId]; ok {
+				item.IsMeeting = 1
+				item.SigninTime = SigninTimeMap[v.UserId]
+			}
+			resp.List = append(resp.List, item)
+		}
+	}
+	if len(resp.List) == 0 {
+		resp.List = make([]*models.CygxActivitySignupResp, 0)
+	}
+	resp.ActivityId = activityId
+	resp.ActivityName = activityInfo.ActivityName
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 3 - 83
controllers/article.go

@@ -272,28 +272,7 @@ func (this *ArticleController) Detail() {
 			}
 			if hasPersion {
 				hasPermission = 1
-				historyRecord := new(models.CygxArticleHistoryRecord)
-				historyRecord.UserId = uid
-				historyRecord.ArticleId = articleId
-				historyRecord.CreateTime = time.Now()
-				historyRecord.Mobile = user.Mobile
-				historyRecord.Email = user.Email
-				historyRecord.CompanyId = user.CompanyId
-				historyRecord.CompanyName = user.CompanyName
-				recordCount, _ := models.GetNoAddStoptimeArticleCount(uid, articleId)
-				if recordCount == 0 {
-					go models.AddCygxArticleHistoryRecord(historyRecord)
-				} else {
-					detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
-					if err != nil {
-						br.Msg = "获取信息失败"
-						br.ErrMsg = "获取信息失败,Err:" + err.Error()
-						return
-					}
-					if detailNew.StopTime > 0 {
-						go models.AddCygxArticleHistoryRecord(historyRecord)
-					}
-				}
+				go services.ArticleHistory(articleId, user)
 				//30分钟之内阅读同一篇文章不错二次推送
 				key := "CYGX_ARTICLE_READ" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
 				if !utils.Rc.IsExist(key) {
@@ -308,23 +287,6 @@ func (this *ArticleController) Detail() {
 					hasPermission = 3
 				}
 			}
-			if hasPermission == 1 {
-				key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
-				if !utils.Rc.IsExist(key) {
-					//新增浏览记录
-					record := new(models.CygxArticleViewRecord)
-					record.UserId = uid
-					record.ArticleId = articleId
-					record.CreateTime = time.Now()
-					record.Mobile = user.Mobile
-					record.Email = user.Email
-					record.CompanyId = user.CompanyId
-					record.CompanyName = user.CompanyName
-					go models.AddCygxArticleViewRecord(record)
-					utils.Rc.Put(key, 1, 5*time.Second)
-					models.ModifyReportLastViewTime(uid)
-				}
-			}
 		}
 
 		interviewApplyItem, err := models.GetArticleInterviewApply(uid, articleId)
@@ -533,6 +495,7 @@ func (this *ArticleController) ArticleCollect() {
 		resp.Status = 1
 		// 文章收藏消息发送
 		go services.ArticleUserRemind(user, detail, 2)
+		go services.ArticleHistoryUserLabelLogAdd(articleId, user.UserId)
 	} else {
 		err = models.RemoveArticleCollect(uid, articleId)
 		if err != nil {
@@ -937,50 +900,7 @@ func (this *ArticleController) AddStopTime() {
 				}
 			}
 			if hasPersion {
-				detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
-				if err == nil {
-					hasPermission = 1
-					historyRecord := new(models.AddStopTimeNewRep)
-					historyRecord.StopTime = detailNew.StopTime + stopTime
-					historyRecord.Id = detailNew.Id
-					historyRecord.OutType = outType
-					go models.UpdateArticleStopTime(historyRecord)
-				}
-
-				//不统计本公司的阅读记录、正常退出的不做时间差统计
-				if stopTime > 3 {
-					key := "CYGX_ARTICLE_PV" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid) + "_" + strconv.Itoa(user.CompanyId) + "_" + strconv.Itoa(outType)
-					record := new(models.CygxArticleHistoryRecordNewpv)
-					record.UserId = uid
-					record.ArticleId = articleId
-					record.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
-					record.ModifyTime = time.Now()
-					record.Mobile = user.Mobile
-					record.Email = user.Email
-					record.CompanyId = user.CompanyId
-					record.CompanyName = user.CompanyName
-					record.StopTime = stopTime
-					record.OutType = outType
-					record.Source = source
-					if !utils.Rc.IsExist(key) || outType != 2 {
-						//新增浏览记录
-						go models.AddCygxArticleViewRecordNewpv(record)
-						recordRedis := new(services.ReportViewRecord)
-						recordRedis.UserId = user.UserId
-						recordRedis.ReportId = articleId
-						recordRedis.Mobile = user.Mobile
-						recordRedis.Email = user.Email
-						recordRedis.RealName = user.RealName
-						recordRedis.CompanyName = user.CompanyName
-						recordRedis.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
-						go services.PushViewRecordNewRedisData(recordRedis, user.CompanyId)
-					} else {
-						go models.UpdateCygxArticleViewRecordNewpv(record, stopTime)
-					}
-					utils.Rc.Put(key, 1, 10*time.Minute)
-				}
-
-				models.ModifyReportLastViewTime(uid)
+				go services.ArticleHistoryStopTime(articleId, stopTime, outType, user)
 			} else { //无该行业权限
 				hasPermission = 3
 			}

+ 33 - 54
controllers/report.go

@@ -62,6 +62,11 @@ func (this *ReportController) TradeList() {
 		categoryMap[v.CategoryId] = v.CategoryId
 		list = append(list, v)
 	}
+	//加了一个需求,现有数据结构不支持,手动添加  2023-06-12
+	if ChartPermissionId == utils.KE_JI_ID {
+		list = append(list, &models.TradeReportMapping{MatchTypeName: "AI前沿", CategoryId: utils.ACTEGORY_ID_AI_QY})
+	}
+
 	//var condition string
 	//var pars []interface{}
 	for k, v := range list {
@@ -70,24 +75,34 @@ func (this *ReportController) TradeList() {
 		//} else {
 		//	condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
 		//}
-		listArticle, _, err := models.GetReportAndproductIndustrylList(v.CategoryId, 0, 1)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			br.Msg = "获取信息失败"
-			br.Msg = "GetHomeList,Err:" + err.Error()
-			return
+		pageSize := 1
+		var listArticle []*models.ReportArticle
+		if v.CategoryId == utils.ACTEGORY_ID_AI_QY {
+			//加了一个需求,现有数据结构不支持,手动添加  2023-06-12
+			listArticle, _, err = services.GetAiQianYanArtilceList(0, pageSize)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.Msg = "GetHomeList,Err:" + err.Error()
+				return
+			}
+			//for _, vAi := range listArticleAi {
+			//	listArticle = append(listArticle, &models.ReportArticle{
+			//		CategoryId:  vAi.CategoryId,
+			//		PublishDate: vAi.PublishDate,
+			//	})
+			//}
+		} else {
+			listArticle, _, err = models.GetReportAndproductIndustrylList(v.CategoryId, 0, pageSize)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.Msg = "GetHomeList,Err:" + err.Error()
+				return
+			}
 		}
-		if len(listArticle) > 0 {
-			list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
+		//listArticle, _, err := models.GetReportAndproductIndustrylList(v.CategoryId, 0, 1)
 
-			//count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
-			//if err != nil {
-			//	br.Msg = "获取信息失败"
-			//	br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
-			//	return
-			//}
-			//if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
-			//	list[k].IsRed = true
-			//}
+		if len(listArticle) > 0 {
+			list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式 }
 		}
 	}
 	resp := new(models.TradeReportMappingResp)
@@ -522,37 +537,6 @@ func (this *ReportController) List() {
 	}
 	if categoryId != 99999 {
 		resp := new(models.TacticsListResp)
-		//获取该产业下所对应的行业图片
-		//detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
-		//if errCategory != nil {
-		//	br.Msg = "获取信息失败"
-		//	br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
-		//	return
-		//}
-		////对应行业的图片
-		//detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
-		//if err != nil {
-		//	br.Msg = "获取数据失败"
-		//	br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
-		//	return
-		//}
-		//chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
-		//mapChartPermission := make(map[string]string)
-		//var permissionName string
-		//var imgUrlChartPermission string
-		//for _, v := range chartPermissionUrlList {
-		//	vslice := strings.Split(v, "_")
-		//	permissionName = vslice[0]
-		//	imgUrlChartPermission = vslice[len(vslice)-1]
-		//	mapChartPermission[permissionName] = imgUrlChartPermission
-		//}
-		//total, err := models.GetReportIndustrialCount(categoryId, industrialManagementId)
-		//if err != nil {
-		//	br.Msg = "获取信息失败"
-		//	br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
-		//	return
-		//}
-
 		list, total, err := models.GetReportAndproductInteriorIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
 		if err != nil {
 			br.Msg = "获取信息失败"
@@ -596,11 +580,6 @@ func (this *ReportController) List() {
 			if v.Resource == 2 {
 				v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
 			}
-			//if mapCategoryUrl[v.CategoryId] == "" {
-			//	if detail.ChartPermissionId == utils.YI_YAO_ID {
-			//		list[k].ImgUrlPc = utils.YI_YAO_QI_TA
-			//	}
-			//}
 		}
 
 		//resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
@@ -900,8 +879,8 @@ func (this *ReportController) Fllow() {
 		}
 	}
 
-	//处理是否关注全部赛道字段
-	go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
+	go services.IndustryFllowWithTrack(industrialManagementId, count, uid)       //处理是否关注全部赛道字段
+	go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
 	br.Msg = "操作成功"
 	br.Ret = 200
 	br.Success = true

+ 102 - 13
controllers/report_selection.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
 	"hongze/hongze_cygx/utils"
@@ -35,20 +36,26 @@ func (this *ReportSelectionController) Detail() {
 	}
 	//uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
+	activityId, _ := this.GetInt("ActivityId")
 	isBestNew, _ := this.GetBool("IsBestNew")
-	isBestNew = true
-	if isBestNew {
-		tbdb := "cygx_report_selection"
-		condition := ` AND publish_status = 1  `
-		var pars []interface{}
-		list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
-		if err != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取失败,Err:" + err.Error()
-			return
-		}
-		for _, v := range list {
-			articleId = v.ArticleId
+	if activityId > 0 && articleId == 0 {
+		articleId = activityId
+	}
+	if articleId == 0 || isBestNew {
+		isBestNew = true
+		if isBestNew {
+			tbdb := "cygx_report_selection"
+			condition := ` AND publish_status = 1  `
+			var pars []interface{}
+			list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取失败,Err:" + err.Error()
+				return
+			}
+			for _, v := range list {
+				articleId = v.ArticleId
+			}
 		}
 	}
 	if articleId < 1 {
@@ -307,3 +314,85 @@ func (this *ReportSelectionController) AddStopTime() {
 	br.Success = true
 	br.Msg = "操作成功"
 }
+
+// @Title 获取报告精选列表
+// @Description 获取报告精选列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.ReportSelectionLetailResp
+// @router /list [get]
+func (this *ReportSelectionController) List() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	resp := new(models.CygxReportSelectionListPublicRep)
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+	var condition string
+	var pars []interface{}
+	condition += ` AND art.publish_status = 1 AND article_id >= 16 `
+	total, err := models.GetCygxReportSelectionCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	condition += "	ORDER BY art.publish_date  DESC "
+	list, err := models.GetReportSelectionList(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	var articleIdArr []int
+	for _, v := range list {
+		v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
+		articleIdArr = append(articleIdArr, v.ArticleId)
+	}
+
+	lenarticleIdArr := len(articleIdArr)
+	maplabel := make(map[int]string)
+	if lenarticleIdArr > 0 {
+		condition = ""
+		pars = make([]interface{}, 0)
+		condition = ` AND is_new = 1  AND article_id IN (` + utils.GetOrmInReplace(lenarticleIdArr) + `)`
+		pars = append(pars, articleIdArr)
+		listLog, err := models.GetCygxReportSelectionLog(condition, pars, 0, 9999)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,GetCygxReportSelectionLogErr:" + err.Error()
+			return
+		}
+		for _, v := range listLog {
+			maplabel[v.ArticleId] += v.SubjectName + ","
+		}
+	}
+	for _, v := range list {
+		v.SubjectName = strings.TrimRight(maplabel[v.ArticleId], ",")
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 9 - 98
controllers/tactics.go

@@ -61,82 +61,14 @@ func (this *TacticsController) List() {
 	//var pars []interface{}
 	//var total int
 	resp := new(models.TacticsListResp)
-	//page := paging.GetPaging(currentIndex, pageSize, total)
-
-	//获取该产业下所对应的行业图片
-	//detail, errCategory := models.GetdetailByCategoryIdOneByHangye(categoryId)
-	//if errCategory != nil {
-	//	br.Msg = "获取信息失败"
-	//	br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
-	//	return
-	//}
-	//对应行业的图片
-	//detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
-	//if err != nil {
-	//	br.Msg = "获取数据失败"
-	//	br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
-	//	return
-	//}
-	//chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
-	//mapChartPermission := make(map[string]string)
-	//var permissionName string
-	//var imgUrlChartPermission string
-	//for _, v := range chartPermissionUrlList {
-	//	vslice := strings.Split(v, "_")
-	//	permissionName = vslice[0]
-	//	imgUrlChartPermission = vslice[len(vslice)-1]
-	//	mapChartPermission[permissionName] = imgUrlChartPermission
-	//}
-
-	//对应分类的所图片
-	//detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
-	//if err != nil {
-	//	br.Msg = "获取数据失败"
-	//	br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
-	//	return
-	//}
-	//categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
-	//mapCategoryUrl := make(map[string]string)
-	//var categoryIdStr string
-	//var imgUrlChart string
-	//for _, v := range categoryUrlList {
-	//	vslice := strings.Split(v, "_")
-	//	categoryIdStr = vslice[0]
-	//	imgUrlChart = vslice[len(vslice)-1]
-	//	mapCategoryUrl[categoryIdStr] = imgUrlChart
-	//}
-
-	//if categoryId < 0 {
-	//	listTactics, err := models.GetReportMappingStrategyAll()
-	//	if err != nil && err.Error() != utils.ErrNoRow() {
-	//		br.Msg = "获取信息失败"
-	//		br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
-	//		return
-	//	}
-	//	for _, v := range listTactics {
-	//		listTacticsSrt = listTacticsSrt + strconv.Itoa(v.CategoryId) + `,`
-	//	}
-	//	listTacticsSrt = strings.TrimRight(listTacticsSrt, ",")
-	//	condition = ` AND category_id IN(` + listTacticsSrt + `)`
-	//} else {
-	//	if detail.CeLueFieldId != "" {
-	//		condition = ` AND ce_lue_field_id IN(` + detail.CeLueFieldId + `)`
-	//	} else if detail.PolymerizationId != "" {
-	//		condition = ` AND category_id IN(` + detail.PolymerizationId + `)`
-	//	} else {
-	//		condition = ` AND category_id IN(` + strconv.Itoa(categoryId) + `)`
-	//	}
-	//}
-	//total, err = models.GetHomeCount(condition, pars)
-	//if err != nil {
-	//	br.Msg = "获取信息失败"
-	//	br.Msg = "获取帖子总数失败,Err:" + err.Error()
-	//	return
-	//}
-
-	//list, err := models.GetReportTacticsList(condition, pars, uid, startSize, pageSize)
-
-	list, total, err := models.GetReportAndproductIndustrylList(categoryId, startSize, pageSize)
+	list := make([]*models.ReportArticle, 0)
+	var total int
+	var err error
+	if categoryId == utils.ACTEGORY_ID_AI_QY {
+		list, total, err = services.GetAiQianYanArtilceList(0, pageSize)
+	} else {
+		list, total, err = models.GetReportAndproductIndustrylList(categoryId, startSize, pageSize)
+	}
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.Msg = "获取帖子数据失败,Err:" + err.Error()
@@ -146,15 +78,12 @@ func (this *TacticsController) List() {
 	var productInteriorIs []int
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	for _, v := range list {
-		//if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
-		//	list[k].IsRed = true
-		//}
+
 		if v.Resource == 1 {
 			articleIds = append(articleIds, v.ArticleId)
 		} else {
 			productInteriorIs = append(productInteriorIs, v.ArticleId)
 		}
-		//list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
 	}
 	ArticleHistoryMap := services.GetArticleHistoryByUser(articleIds, user)
 	ProductInteriorHistoryMap := services.GetCygxProductInteriorHistoryListMap(articleIds, user)
@@ -184,24 +113,6 @@ func (this *TacticsController) List() {
 			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
 		}
 	}
-	//lenList := len(list)
-	//for i := 0; i < lenList; i++ {
-	//	item := list[i]
-	//	list[i].Body, _ = services.GetReportContentTextSub(item.Body)
-	//	list[i].Abstract = html.UnescapeString(item.Abstract)
-	//	//list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
-	//	list[i].Annotation = strings.Replace(item.Annotation, "<br>", "", -1)
-	//	//行业比较研究、资金流向,显示报告的摘要
-	//	if resp.MatchTypeName == "行业比较研究" || resp.MatchTypeName == "资金流向" {
-	//		list[i].Annotation = list[i].Abstract
-	//	}
-	//	//if item.ArticleId == 6881 {
-	//	//	fmt.Println(list[i].Annotation)
-	//	//}
-	//	list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
-	//}
-	//
-	//resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
 	resp.List = list
 	resp.Paging = page
 	br.Ret = 200

+ 44 - 4
controllers/user.go

@@ -1093,7 +1093,7 @@ func (this *UserController) ApplyTryOut() {
 					req.RealName = user.RealName
 					req.CompanyName = user.CompanyName
 				}
-				go services.SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, mobile, applyMethod, openIpItem)
+				//go services.SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, mobile, applyMethod, openIpItem)
 			}
 		}
 	} else {
@@ -1132,15 +1132,21 @@ func (this *UserController) ApplyTryOut() {
 	//	go services.SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, mobile, applyMethod, openIpItem)
 	//}
 	//如果对应销售不存在就给王芳,汪洋推模版消息
-	if sellerItem == nil {
-		go services.SendPermissionApplyTemplateMsgAdmin(req, mobile, applyMethod, isResearch)
-	}
+
 	err = models.AddApplyRecord(&req, user.Mobile, user.CompanyName, uid, user.CompanyId, CompanyIdType)
 	if err != nil {
 		br.Msg = "申请失败"
 		br.ErrMsg = "申请失败,Err:" + err.Error()
 		return
 	}
+	if sellerItem == nil {
+		go services.SendPermissionApplyTemplateMsgAdmin(req, mobile, applyMethod, isResearch)
+	} else {
+		openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
+		if openIpItem != nil && openIpItem.OpenId != "" {
+			go services.SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, mobile, applyMethod, openIpItem)
+		}
+	}
 	//添加成功后,设置5分钟缓存,不允许重复添加
 	//utils.Rc.SetNX(cacheKey, user.Mobile, time.Second*60)
 
@@ -1779,3 +1785,37 @@ func (this *UserController) Tracking() {
 	br.Ret = 200
 	br.Success = true
 }
+
+// @Title 未付费申请试用详情
+// @Description 未付费申请试用详情接口
+// @Param   ApplyRecordId    query   int true       "申请ID"
+// @Success 200 {object} models.ArticleCollectListResp
+// @Success 200
+// @router /apply/detail [get]
+func (this *UserController) ApplyDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	resp := new(models.CygxApplyRecordResp)
+	applyRecordId, _ := this.GetInt("ApplyRecordId")
+	detail, err := models.GetCygxApplyRecordById(applyRecordId)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	resp.Detail = detail
+	br.Msg = "申请成功!"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}

+ 36 - 1
models/activity.go

@@ -66,6 +66,8 @@ type CygxActivity struct {
 	YidongSignUpStart       string    `description:"易董活动截止时间"` // 报名开始时间,适应于报名审核后可入会,为空表示不限制报名时间
 	IsExternalLabel         int       `description:"是否为外部资源 1是,0否"`
 	YidongActivityIdByCygx  string    `description:"通过查研观向建会易董返回的活动ID"`
+	JmcjRoadshowTitle       string    `description:"进门财经的活动标题"`
+	JmcjActivityId          string    `description:"进门财经的活动ID"`
 }
 
 type Activity struct {
@@ -206,6 +208,7 @@ type ActivityDetail struct {
 	TencentConferenceNumber string                     `description:"腾讯会议号"`
 	YidongActivityIdByCygx  string                     `description:"通过查研观向建会易董返回的活动ID"`
 	IsShowSigninButton      bool                       `description:"是否展示签到码按钮"`
+	IsShowSignUpDetail      bool                       `description:"是否展示报名详情按钮"`
 	SigninImg               string                     `description:"签到码图片"`
 }
 type ListArticleActivity struct {
@@ -222,6 +225,7 @@ type CygxActivityResp struct {
 	SellerMobile      string `description:"销售电话"`
 	SellerName        string `description:"销售姓名"`
 	IsResearch        bool   `description:"是否属于研选"`
+	IsResearchSpecial bool   `description:"是否属于特殊的研选"`
 	Detail            *ActivityDetail
 }
 
@@ -1009,7 +1013,7 @@ func AddCygxActivity(item *CygxActivity) (lastId int64, err error) {
 func GetActivityListByYidong(condition string) (items []*ActivityDetail, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_activity WHERE 1 = 1 
-	AND ( yidong_activity_id != '' OR yidong_activity_id_by_cygx != '' )  `
+	AND ( yidong_activity_id != '' OR yidong_activity_id_by_cygx != '' )  AND publish_status = 1  `
 	if condition != "" {
 		sql += condition
 	}
@@ -1212,3 +1216,34 @@ func GetActivityLabelListAllNoLimit(condition, sortTime string, pars []interface
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+// 列表
+func GetCygxActivityList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivity, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+// 批量修改弘则活动与进门财经的一个活动关联
+func UpdateJmcjActivityIdGroup(items map[int]string) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw("UPDATE cygx_activity SET jmcj_activity_id = ? WHERE activity_id = ? AND jmcj_activity_id= '' ").Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for k, v := range items {
+		_, err = p.Exec(v, k)
+		if err != nil {
+			return
+		}
+	}
+	return
+}

+ 28 - 23
models/activity_attendance_detail.go

@@ -3,6 +3,7 @@ package models
 import (
 	"fmt"
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_cygx/utils"
 	"time"
 )
 
@@ -83,28 +84,6 @@ func AddCygxActivityAttendanceDetail(item *CygxActivityAttendanceDetail) (lastId
 	return
 }
 
-type RoadshowData struct {
-	Id                    int    `orm:"column(id);pk;"description:"主键ID"`
-	Company               string `description:"公司名称"`
-	UserName              string `description:"用户名"`
-	UserPhone             string `description:"手机号"`
-	UserinfoUource        string `description:"用户来源"`
-	AuthInfo              string `description:"用户参会鉴权"`
-	GuestUsername         string `description:"嘉宾名称, 多个用,隔开"`
-	FirstWatchTime        string `description:"首次观看时间"`
-	LastWatchTime         string `description:"最后观看时间"`
-	RoadshowId            string `description:"路演ID"`
-	RoadshowTitle         string `description:"路演标题"`
-	RoadshowBeginTime     string `description:"路演开始时间"`
-	RoadshowEndTime       string `description:"路演结束时间"`
-	JoinTime              int    `description:"参与时长"`
-	JoinType              int    `description:"参与方式, 1网络, 2电话"`
-	DataType              int    `description:"数据类型: 1直播, 2回放"`
-	Occupation            string `description:"职位"`
-	UseridEntity          int    `description:"参会者身份. 1:主讲人, 2:主持人, 3:嘉宾, 4:普通参会者, 5:联席主讲人, 6:会议助理"`
-	CrmCompanyMapStatusId int    `description:"转换后的对应状态信息:1=正式客户, 2=曾使用客户, 3=其他"`
-}
-
 func AddAttendancDetail(items []*CygxActivityAttendanceDetail, activityId int, mobileStr string) (err error) {
 	if len(items) == 0 {
 		return
@@ -142,7 +121,7 @@ func AddAttendancDetail(items []*CygxActivityAttendanceDetail, activityId int, m
 	//		return
 	//	}
 	//}
-	_, err = o.InsertMulti(1, items)
+	_, err = o.InsertMulti(len(items), items)
 	return
 }
 
@@ -196,3 +175,29 @@ func GetActivityAttendanceDetailListAll() (items []*CygxActivityAttendanceDetail
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+// 列表
+func GetActivityAttendanceDetailListCondition(condition string, pars []interface{}) (items []*CygxActivityAttendanceDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_attendance_detail WHERE   1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+func AddAttendancDetailNew(items []*CygxActivityAttendanceDetail, activityIds []int) (err error) {
+	if len(items) == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	//修改活动是否上传到会信息字段
+	sql := `UPDATE cygx_activity SET  is_submit_meeting=1   WHERE activity_id IN  (` + utils.GetOrmInReplace(len(activityIds)) + `)  `
+	_, err = o.Raw(sql, activityIds).Exec()
+	if err != nil {
+		return
+	}
+	_, err = o.InsertMulti(len(items), items)
+	return
+}

+ 181 - 1
models/activity_meet_detail_log.go

@@ -3,6 +3,7 @@ package models
 import (
 	"fmt"
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_cygx/utils"
 	"strconv"
 	"strings"
 	"time"
@@ -20,6 +21,27 @@ type CygxActivityMeetDetailLog struct {
 	ActivityTime string    `description:"活动时间"`
 }
 
+// 批量添加
+func AddCygxActivityMeetDetailLogMulti(items []*CygxActivityMeetDetailLog) (err error) {
+	o := orm.NewOrm()
+	if len(items) > 0 {
+		//批量添加
+		_, err = o.InsertMulti(len(items), items)
+	}
+	return
+}
+
+// 列表
+func GetCygxActivityMeetDetailLogList(condition string, pars []interface{}) (items []*CygxActivityMeetDetailLog, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_meet_detail_log as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 func GetOfflineMeetingDetailListCompanyIdStr(companyIdStr string) (item []*CygxActivityMeetDetailLog, err error) {
 	if companyIdStr == "" {
 		return
@@ -80,6 +102,37 @@ func GetActivityMeetDetailLogCount(condition string) (count int, err error) {
 	return
 }
 
+// 报名
+type CygxActivityMeetDetailLogCountResp struct {
+	Mobile    string `description:"手机号"`
+	CompanyId int    `description:"公司id 不在数据库的用户为0"`
+	Count     int    `description:"公司id 不在数据库的用户为0"`
+}
+
+// 获取数量
+func GetActivityMeetDetailLogCountCompany(companyIds []int) (item []*CygxActivityMeetDetailLogCountResp, err error) {
+	lenArr := len(companyIds)
+	if lenArr == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	sql := `  SELECT company_id, COUNT(1) AS count  FROM cygx_activity_meet_detail_log WHERE 1=1 AND company_id IN  (` + utils.GetOrmInReplace(lenArr) + `)   GROUP BY company_id`
+	_, err = o.Raw(sql, companyIds).QueryRows(&item)
+	return
+}
+
+// 获取数量
+func GetActivityMeetDetailLogCountMobile(mobiles []string) (item []*CygxActivityMeetDetailLogCountResp, err error) {
+	lenArr := len(mobiles)
+	if lenArr == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	sql := `  SELECT mobile, COUNT(1) AS count  FROM cygx_activity_meet_detail_log WHERE 1=1 AND mobile IN  (` + utils.GetOrmInReplace(lenArr) + `)   GROUP BY company_id`
+	_, err = o.Raw(sql, mobiles).QueryRows(&item)
+	return
+}
+
 // 修改公司参会数量
 func UpdateActivityMeetDetailLog(companyName string, num int) (err error) {
 	sql := ` UPDATE cygx_activity_meet_detail_log SET  company_meet_num= ?  WHERE company_name = ?`
@@ -175,7 +228,7 @@ func AddCygxActivityMeetDetailLogOnline(list []*CygxActivityAttendanceDetail, ac
 }
 
 // 添加线上到会记录
-func AddCygxActivityMeetDetailLogOnlineByList(list []*CygxActivityAttendanceDetail, activityIds string) (err error) {
+func AddCygxActivityMeetDetailLogOnlineByListNew(list []*CygxActivityAttendanceDetail, activityIds string) (err error) {
 	o, err := orm.NewOrm().Begin()
 	if err != nil {
 		return
@@ -369,3 +422,130 @@ func AddCygxActivityMeetDetailLogOffline(activityId int) (err error) {
 	}
 	return
 }
+
+// 添加线上到会记录
+func AddCygxActivityMeetDetailLogOnlineByList(list []*CygxActivityAttendanceDetail, activityIds string) (err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	var CompanyName string
+	var MobileStr string
+	var items []*CygxActivityMeetDetailLog
+	//删除原有数据
+	sql := ` DELETE FROM cygx_activity_meet_detail_log WHERE activity_id IN (` + activityIds + `)`
+	_, err = o.Raw(sql).Exec()
+	if err != nil {
+		return
+	}
+	//插入新的数据
+	for _, v := range list {
+		item := new(CygxActivityMeetDetailLog)
+		item.ActivityId = v.ActivityId
+		item.Mobile = v.Mobile
+		fmt.Println(v.CompanyName)
+		item.CompanyName = v.CompanyName
+		item.CompanyId = v.CompanyId
+		item.ActivityTime = v.ActivityTime
+		item.CreateTime = v.CreateTime
+		if strings.Index(CompanyName, v.CompanyName) == -1 && v.CompanyName != "" {
+			CompanyName += "'" + v.CompanyName + "',"
+		}
+		if strings.Index(MobileStr, v.Mobile) == -1 && v.Mobile != "" {
+			MobileStr += v.Mobile + ","
+		}
+		items = append(items, item)
+	}
+	CompanyName = strings.TrimRight(CompanyName, ",")
+	MobileStr = strings.TrimRight(MobileStr, ",")
+	_, err = o.InsertMulti(1, items)
+	listCompany, err := GetOfflineMeetingDetailListCompanyName(CompanyName)
+	fmt.Println("公司数量", len(listCompany))
+	if err != nil {
+		return
+	}
+	//修改公司对应的数量
+	var condition string
+	for _, v := range listCompany {
+		var total int
+		condition = ` AND company_name = '` + v.CompanyName + `' `
+		total, err = GetActivityMeetDetailLogCount(condition)
+		if err != nil {
+			return
+		}
+		sql := ` UPDATE cygx_activity_meet_detail_log SET  company_meet_num= ?  WHERE company_name = ?`
+		_, err = o.Raw(sql, total, v.CompanyName).Exec()
+		fmt.Println("处理公司", v.CompanyName)
+		if err != nil {
+			return
+		}
+	}
+	listMobile, err := GetActivityMeetDetailLog(MobileStr)
+	fmt.Println("用户数量", len(listMobile))
+	if err != nil {
+		return
+	}
+	//修改个人对应的数量
+	for _, v := range listMobile {
+		var total int
+		condition = ` AND mobile = '` + v.Mobile + `' `
+		total, err = GetActivityMeetDetailLogCount(condition)
+		if err != nil {
+			return
+		}
+		sql := ` UPDATE cygx_activity_meet_detail_log SET  user_meet_num= ?  WHERE mobile = ?`
+		_, err = o.Raw(sql, total, v.Mobile).Exec()
+		fmt.Println("处理用户", v.Mobile)
+		if err != nil {
+			return
+		}
+	}
+	fmt.Println("user_end")
+	return
+}
+
+// UpdateActivitySpecialSignupNumMulti 批量修改个人参会数量
+func UpdateCygxActivityMeetDetailLogMobileNumMulti(items []*CygxActivityMeetDetailLogCountResp) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw("UPDATE cygx_activity_meet_detail_log SET user_meet_num = ? WHERE mobile = ?").Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close()
+	}()
+	for _, v := range items {
+		_, err = p.Exec(v.Count, v.Mobile)
+		if err != nil {
+			return
+		}
+	}
+	return
+}
+
+// UpdateActivitySpecialSignupNumMulti 批量修改机构参会数量
+func UpdateCygxActivityMeetDetailLogCompanyNumMulti(items []*CygxActivityMeetDetailLogCountResp) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw("UPDATE cygx_activity_meet_detail_log SET company_meet_num = ? WHERE company_id = ?").Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close()
+	}()
+	for _, v := range items {
+		_, err = p.Exec(v.Count, v.CompanyId)
+		if err != nil {
+			return
+		}
+	}
+	return
+}

+ 17 - 0
models/activity_offline_meeting_detail.go

@@ -72,3 +72,20 @@ func GetOfflineMeetingListByUser(meetingUids string, activityId int) (items []*C
 	_, err = o.Raw(sql, activityId).QueryRows(&items)
 	return
 }
+
+// 报名
+type CygxActivityOfflineMeetingDetailResp struct {
+	ActivityId   int    `description:"活动ID "`
+	ActivityName string `description:"活动名称"`
+	List         []*CygxActivitySignupResp
+}
+
+// 预约外呼列表
+func GetOfflineMeetingListWithUser(condition string, pars []interface{}) (items []*CygxActivitySignupList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT s.* , u.real_name
+			FROM cygx_activity_offline_meeting_detail  as s 
+			INNER JOIN wx_user as u ON u.user_id = s.user_id  WHERE 1 =1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 13 - 0
models/activity_signin.go

@@ -64,6 +64,19 @@ func GetCygxActivitySigninCount(condition string, pars []interface{}) (count int
 	return
 }
 
+// GetCygxActivitySigninList 获取签到列表信息
+func GetCygxActivitySigninList(condition string, pars []interface{}) (items []*CygxActivitySignin, err error) {
+	sql := `SELECT
+			*
+		FROM
+			cygx_activity_signin AS art
+		WHERE
+			1 = 1 	` + condition
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 func GetCygxActivitySigninDetail(condition string, pars []interface{}) (item *CygxActivitySignin, err error) {
 	sql := `SELECT *  FROM cygx_activity_signin as art WHERE 1= 1 `
 	if condition != "" {

+ 33 - 1
models/activity_signup.go

@@ -41,6 +41,7 @@ type SignupStatus struct {
 	GoOutboundMobile  bool   `description:"是否去绑定手机号"`
 	GoBindEmail       bool   `description:"是否去绑定邮箱"`
 	IsResearch        bool   `description:"是否属于研选"`
+	IsResearchSpecial bool   `description:"是否属于特殊的研选"`
 }
 
 // 我的日程
@@ -520,6 +521,14 @@ type CygxActivitySignupList struct {
 	Mobile      string `description:"手机号"`
 	Email       string `description:"邮箱"`
 	CompanyId   int    `description:"公司id"`
+	SigninTime  string `description:"签到时间"`
+}
+
+type CygxActivitySignupResp struct {
+	CompanyName string `description:"公司名称"`
+	RealName    string `description:"姓名"`
+	IsMeeting   int    `description:"是否到会 ,1是, 0否"`
+	SigninTime  string `description:"签到时间"`
 }
 
 // 获取用户报名列表
@@ -632,10 +641,33 @@ func GetActivitySignupInnerActivityList(condition string, pars []interface{}) (i
 			*
 		FROM
 			cygx_activity_signup AS v
-			INNER JOIN cygx_activity as a 
+			INNER JOIN cygx_activity as a  ON a.activity_id = v.activity_id
 		WHERE
 			1 = 1 	` + condition
 	o := orm.NewOrm()
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+// UpdateCygxActivitySignupIsMeeting 批量标记用户的到会信息
+func UpdateCygxActivitySignupIsMeeting(items []*CygxActivityAttendanceDetail) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw(` UPDATE cygx_activity_signup SET
+							is_meeting = 1
+							WHERE outbound_mobile = ? AND activity_id = ? `).Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for _, v := range items {
+		_, err = p.Exec(
+			v.Mobile,
+			v.ActivityId)
+		if err != nil {
+			return
+		}
+	}
+	return
+}

+ 13 - 0
models/activity_signup_break.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_cygx/utils"
 	"time"
 )
 
@@ -51,3 +52,15 @@ func DeleteCygxActivitySignupBreakById(activityId int) (err error) {
 	_, err = o.Raw(sql, activityId).Exec()
 	return
 }
+
+// 批量删除
+func DeleteCygxActivitySignupBreakByIds(activityIds []int) (err error) {
+	lenactivityIds := len(activityIds)
+	if lenactivityIds == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	sql := ` DELETE FROM cygx_activity_signup_break  WHERE  activity_id IN (` + utils.GetOrmInReplace(lenactivityIds) + `)`
+	_, err = o.Raw(sql, activityIds).Exec()
+	return
+}

+ 10 - 0
models/activity_special_trip.go

@@ -51,6 +51,16 @@ func GetCygxActivitySpecialTripList(condition string, pars []interface{}) (item
 	return
 }
 
+func GetCygxActivitySpecialmeetingDetailList(condition string, pars []interface{}) (item []*CygxActivitySpecialTripResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *
+			FROM
+			cygx_activity_special_meeting_detail  
+			WHERE 1 = 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&item)
+	return
+}
+
 // 获取某一用户的报名的数量
 func GetUserActivitySpecialTripCount(uid, activityId int) (count int, err error) {
 	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_trip  WHERE  user_id=?  AND   activity_id =? `

+ 19 - 0
models/admin.go

@@ -61,6 +61,13 @@ func GetSysAdminById(adminId int) (item *Admin, err error) {
 	return
 }
 
+func GetSysAdminByMobile(mobile string) (item *Admin, err error) {
+	sql := `SELECT * FROM admin WHERE mobile=? LIMIT 1 `
+	o := orm.NewOrm()
+	err = o.Raw(sql, mobile).QueryRow(&item)
+	return
+}
+
 // 获取权益内部人员手机号
 func GetRaiAdmin() (items []*AdminMobileResp, err error) {
 	o := orm.NewOrm()
@@ -78,3 +85,15 @@ WHERE
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+type GetSellerUserMobileResp struct {
+	Mobile string `description:"手机号"`
+}
+
+// 获取销售所能查看到的手机号
+func GetSellerUserMobile(adminId int) (items []*GetSellerUserMobileResp, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT mobile FROM user_seller_relation WHERE seller_id  = ? `
+	_, err = o.Raw(sql, adminId).QueryRows(&items)
+	return
+}

+ 29 - 7
models/apply_record.go

@@ -6,13 +6,15 @@ import (
 )
 
 type CygxApplyRecord struct {
-	ApplyRecordId   int       `orm:"column(apply_record_id);pk" description:"申请试用id"`
-	BusinessCardUrl string    `description:"名片地址"`
-	RealName        string    `description:"姓名"`
-	CompanyName     string    `description:"公司名称"`
-	Mobile          string    `description:"手机号"`
-	CreateTime      time.Time `description:"创建时间"`
-	ApplyMethod     int       `description:"1:已付费客户申请试用,2:非客户申请试用"`
+	ApplyRecordId    int       `orm:"column(apply_record_id);pk" description:"申请试用id"`
+	BusinessCardUrl  string    `description:"名片地址"`
+	RealName         string    `description:"姓名"`
+	CompanyName      string    `description:"公司名称"`
+	CompanyNamePay   string    `description:"公司名称"`
+	Mobile           string    `description:"手机号"`
+	CreateTime       time.Time `description:"创建时间"`
+	ApplyMethod      int       `description:"1:已付费客户申请试用,2:非客户申请试用"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
 }
 
 func AddApplyRecord(item *ApplyTryReq, mobile, companyNamePay string, userId, companyIdPay, CompanyIdType int) (err error) {
@@ -52,3 +54,23 @@ func GetApplyRecordCount(userId int) (count int, err error) {
 	err = o.Raw(sql, userId).QueryRow(&count)
 	return
 }
+
+// 通过手机号获取详情
+func GetCygxApplyRecordByMobile(mobile string) (item *CygxApplyRecord, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_apply_record   WHERE mobile=? AND status=0   ORDER BY apply_record_id DESC   LIMIT 1 `
+	err = o.Raw(sql, mobile).QueryRow(&item)
+	return
+}
+
+// 通过ID获取详情
+func GetCygxApplyRecordById(applyRecordId int) (item *CygxApplyRecord, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_apply_record  WHERE apply_record_id=?  `
+	err = o.Raw(sql, applyRecordId).QueryRow(&item)
+	return
+}
+
+type CygxApplyRecordResp struct {
+	Detail *CygxApplyRecord
+}

+ 23 - 0
models/article.go

@@ -730,3 +730,26 @@ func GetArticleStock() (items []*SummaryArticleStock, err error) {
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+// 列表
+func GetCygxCygxArticleList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxArticle, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+// 获取数量
+func GetCygxArticleCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}

+ 0 - 13
models/article_category_mapping.go

@@ -30,19 +30,6 @@ func AddCygxArticleCategoryMapping(item *CygxArticleCategoryMapping) (lastId int
 	return
 }
 
-type CygxReportMappingCygx struct {
-	Id                  int    `orm:"column(id);pk" description:"id"`
-	ChartPermissionId   int    `description:"行业ID"`
-	ChartPermissionName string `description:"行业名称"`
-	MatchTypeName       string `description:"分类名称"`
-	ReportType          int    `description:"报告类型,2产业报告,1行业报告"`
-	Sort                int    `description:"排序"`
-	IsCustom            int    `description:"是否属于自定义的匹配类型 ,1是,0否"`
-	IsSummary           int    `description:"是否是纪要库,1是,0否"`
-	IsReport            int    `description:"是否是报告,1是,0否"`
-	PermissionType      int    `description:"1主观,2客观"`
-}
-
 type CygxReportMappingGroup struct {
 	Id              int       `orm:"column(id);pk" description:"id"`
 	IdCygx          int       `description:"分类ID"`

+ 1 - 1
models/article_history_record_newpv.go

@@ -295,7 +295,7 @@ func GetCygxArticleHistoryAllTop(pars []interface{}, condition string) (items []
 // 列表
 func GetCygxArticleHistoryRecordNewpvList(condition string, pars []interface{}) (items []*CygxArticleHistoryRecordNewpv, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_article_history_record_newpv as art WHERE 1= 1 `
+	sql := `SELECT * FROM cygx_article_history_record_newpv as art WHERE 1= 1  `
 	if condition != "" {
 		sql += condition
 	}

+ 4 - 0
models/db.go

@@ -147,6 +147,10 @@ func init() {
 		new(CygxActivitySignupBreak),
 		new(CygxBannerHistory),
 		new(CygxReportHistoryRecordLog),
+		new(CygxUserLabel),
+		new(CygxUserLabelActivity),
+		new(CygxUserLabelArticle),
+		new(CygxUserLabelActivitySpecial),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 28 - 2
models/industrial_activity_group_management.go

@@ -29,7 +29,7 @@ type CygxIndustrialSubject struct {
 	Source                 int       `description:"来源,1正常添加,2:通过文章添加,3通过活动添加(默认为1)"`
 }
 
-//获取标的列表
+// 获取标的列表
 func GetCygxIndustrialSubjectList(subjectName string) (items []*CygxIndustrialSubject, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
@@ -82,4 +82,30 @@ func GetActivityIndustryRelationList(condition string, pars []interface{}) (list
 	}
 	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
 	return
-}
+}
+
+// 获取数量
+func GetCygxIndustrialActivityGroupManagementCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_industrial_activity_group_management as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// CygxIndustrialActivityGroupManagement 获取活动与产业关联列表
+func GetCygxIndustrialActivityGroupManagementList(condition string, pars []interface{}) (list []*CygxIndustrialActivityGroupManagement, err error) {
+	sql := `SELECT
+			*
+			FROM
+			cygx_industrial_activity_group_management
+			WHERE
+				1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
+	return
+}

+ 12 - 0
models/industry_fllow.go

@@ -203,3 +203,15 @@ func GetTopIndustryFollowData(startSize, pageSize int, condition string, pars []
 	_, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
 	return
 }
+
+// 列表
+func GetCygxIndustryFllowListByCon(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxIndustryFllow, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_industry_fllow as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	//sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 39 - 0
models/jmcj_comein_data.go

@@ -0,0 +1,39 @@
+package models
+
+import "github.com/beego/beego/v2/client/orm"
+
+type RoadshowData struct {
+	Id                    int    `orm:"column(id);pk;"description:"主键ID"`
+	Company               string `description:"公司名称"`
+	UserName              string `description:"用户名"`
+	UserPhone             string `description:"手机号"`
+	UserinfoUource        string `description:"用户来源"`
+	AuthInfo              string `description:"用户参会鉴权"`
+	GuestUsername         string `description:"嘉宾名称, 多个用,隔开"`
+	FirstWatchTime        string `description:"首次观看时间"`
+	LastWatchTime         string `description:"最后观看时间"`
+	RoadshowId            string `description:"路演ID"`
+	RoadshowTitle         string `description:"路演标题"`
+	RoadshowBeginTime     string `description:"路演开始时间"`
+	RoadshowEndTime       string `description:"路演结束时间"`
+	JoinTime              int    `description:"参与时长"`
+	JoinType              int    `description:"参与方式, 1网络, 2电话"`
+	DataType              int    `description:"数据类型: 1直播, 2回放"`
+	Occupation            string `description:"职位"`
+	UseridEntity          int    `description:"参会者身份. 1:主讲人, 2:主持人, 3:嘉宾, 4:普通参会者, 5:联席主讲人, 6:会议助理"`
+	CrmCompanyMapStatusId int    `description:"转换后的对应状态信息:1=正式客户, 2=曾使用客户, 3=其他"`
+}
+
+// 获取列表
+func GetJmcjRoadshowDataList(condition string, pars []interface{}) (list []*RoadshowData, err error) {
+	if condition == "" {
+		return
+	}
+	o := orm.NewOrmUsingDB("comein_data")
+	sql := `SELECT * FROM roadshow_data WHERE  1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&list)
+	return
+}

+ 32 - 4
models/report.go

@@ -1110,8 +1110,17 @@ WHERE
 	WHERE
 	mm.id = mmc.meeting_id
 	AND mm.status = 1
-	AND mmc.industry_id = ? ) AS t `
-	err = o.Raw(sql, industrialManagementId, industrialManagementId).QueryRow(&count)
+	AND mmc.industry_id = ? UNION ALL
+	SELECT
+		COUNT( 1 ) count 
+	FROM
+		cygx_product_interior AS p
+		INNER JOIN cygx_product_interior_industrial_group_management AS pm 
+	WHERE
+		p.product_interior_id = pm.product_interior_id 
+		AND p.visible_range = 1 
+	AND pm.industrial_management_id = ?  ) AS t `
+	err = o.Raw(sql, industrialManagementId, industrialManagementId, industrialManagementId).QueryRow(&count)
 	return
 }
 
@@ -1126,6 +1135,7 @@ type TimeLineReportItem struct {
 	SubCategoryName string `description:"二级分类"`
 	IsRed           bool   `description:"是否标红"`
 	Readnum         int    `description:"阅读数量"`
+	Resource        int    `description:"来源类型,1:文章、2:产品内测、3:晨报点评"`
 }
 
 // 获取产业报告+晨会点评列表
@@ -1142,6 +1152,7 @@ FROM
 		a.video_url,
 		a.sub_category_name,
 		'' AS content,
+		1 AS resource,
 		( SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.article_id = a.article_id ) AS readnum 
 	FROM
 		cygx_article AS a
@@ -1157,6 +1168,7 @@ FROM
 		'' AS video_url,
 		'时间线' AS sub_category_name,
 		mmc.content,
+		3 AS resource,
 		0  AS readnum 
 	FROM
 		cygx_morning_meeting_review_chapter AS mmc
@@ -1164,12 +1176,28 @@ FROM
 	WHERE
 		mm.id = mmc.meeting_id 
 		AND mm.STATUS = 1 
-		AND mmc.industry_id = ? 
+		AND mmc.industry_id = ? UNION ALL
+	SELECT
+		p.product_interior_id AS id,
+		p.title,
+		p.publish_time,
+		'' AS video_url,
+		'' AS sub_category_name,
+		'' AS content,
+		2 AS resource,
+		0 AS readnum 
+	FROM
+		cygx_product_interior AS p
+		INNER JOIN cygx_product_interior_industrial_group_management AS pm 
+	WHERE
+		p.product_interior_id = pm.product_interior_id 
+		AND p.visible_range = 1 
+	AND pm.industrial_management_id = ? 
 	) AS t 
 `
 	sql += ` ORDER BY 
 	t.publish_time DESC LIMIT ?,? `
-	_, err = o.Raw(sql, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
+	_, err = o.Raw(sql, industrialManagementId, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
 	return
 }
 

+ 21 - 0
models/report_mapping.go

@@ -374,3 +374,24 @@ func GetReportMapping() (items []*CygxReportMapping, err error) {
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+// 通过分类ID对应的系列名称
+func GetdetailByCategoryIdLabel(categoryId int) (item *CygxReportMapping, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			c.id,c.match_type_name
+			FROM
+			cygx_report_mapping_group as g
+			INNER JOIN cygx_report_mapping_cygx as c ON c.id = g.id_cygx
+			WHERE
+			category_id_celue = ? LIMIT 1`
+	err = o.Raw(sql, categoryId).QueryRow(&item)
+	return
+}
+
+func GetCygxReportMappingById(id int) (items *CygxReportMapping, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_mapping_cygx WHERE id = ?`
+	err = o.Raw(sql, id).QueryRow(&items)
+	return
+}

+ 31 - 0
models/report_mapping_cygx.go

@@ -0,0 +1,31 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	//"time"
+)
+
+type CygxReportMappingCygx struct {
+	Id                  int    `orm:"column(id);pk" description:"id"`
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业名称"`
+	MatchTypeName       string `description:"分类名称"`
+	ReportType          int    `description:"报告类型,2产业报告,1行业报告"`
+	Sort                int    `description:"排序"`
+	IsCustom            int    `description:"是否属于自定义的匹配类型 ,1是,0否"`
+	IsSummary           int    `description:"是否是纪要库,1是,0否"`
+	IsReport            int    `description:"是否是报告,1是,0否"`
+	PermissionType      int    `description:"1主观,2客观"`
+}
+
+// 列表
+func GetCygxReportMappingCygxByCon(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxReportMappingCygx, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_mapping_cygx as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	//sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 24 - 17
models/report_selection.go

@@ -3,7 +3,6 @@ package models
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
-	"time"
 )
 
 type CygxReportSelectionRep struct {
@@ -16,6 +15,7 @@ type CygxReportSelectionRep struct {
 	UpdateDescription string `description:"更新说明"`
 	IsRed             bool   `description:"是否标记红点"`
 	ReadNum           int    `description:"阅读次数"`
+	SubjectName       string `description:"标的名称"`
 }
 
 type CygxReportSelectionListPublicRep struct {
@@ -100,6 +100,29 @@ func GetCygxReportSelectionPublic(condition, tbdb string, pars []interface{}) (c
 	return
 }
 
+// 获取数量
+func GetCygxReportSelectionCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_report_selection as art WHERE 1= 1 AND art.publish_status = 1   `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 列表
+func GetReportSelectionList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_selection  as art WHERE 1= 1 AND art.publish_status = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `   LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
 // 通过ID获取详情
 func GetCygxReportSelectionInfoById(articleId int) (item *DetailCygxReportSelectionRep, err error) {
 	o := orm.NewOrm()
@@ -140,22 +163,6 @@ func GetReportSelectionListHome(condition, tbdb string, pars []interface{}, star
 	return
 }
 
-type CygxReportSelectionLog struct {
-	ArticleSunId           int       `description:"子级报告id"`
-	ArticleId              int       `description:"父级报告Id"`
-	ChartPermissionId      int       `description:"行业ID"`
-	PermissionName         string    `description:"行业ID"`
-	CreateTime             time.Time `description:"创建时间"`
-	Body                   string    `description:"内容"`
-	IndustrialSubjectId    int       `description:"标的ID"`
-	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
-	SubjectName            string    `description:"标的名称"`
-	IcoLink                string    `orm:"column(image_url)"description:"图标链接"`
-	CompanyLabel           []string  `description:"公司标签"`
-	Label                  string    `description:"公司标签"`
-	OverviewArticleId      int       `description:"综述报告Id"`
-}
-
 // 列表
 func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLog, err error) {
 	o := orm.NewOrm()

+ 34 - 0
models/report_selection_log.go

@@ -0,0 +1,34 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxReportSelectionLog struct {
+	ArticleSunId           int       `description:"子级报告id"`
+	ArticleId              int       `description:"父级报告Id"`
+	ChartPermissionId      int       `description:"行业ID"`
+	PermissionName         string    `description:"行业ID"`
+	CreateTime             time.Time `description:"创建时间"`
+	Body                   string    `description:"内容"`
+	IndustrialSubjectId    int       `description:"标的ID"`
+	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
+	SubjectName            string    `description:"标的名称"`
+	IcoLink                string    `orm:"column(image_url)"description:"图标链接"`
+	CompanyLabel           []string  `description:"公司标签"`
+	Label                  string    `description:"公司标签"`
+	OverviewArticleId      int       `description:"综述报告Id"`
+}
+
+// 列表
+func GetCygxReportSelectionLog(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionLog, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_selection_log as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 115 - 0
models/user_label.go

@@ -0,0 +1,115 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxUserLabelLogRedis struct {
+	UserId     int       `description:"用户ID"`
+	SourceId   int       `description:"资源ID"`
+	SourceType int       `description:"1:文章阅读、 2产业关注、3:活动到会、4系列关注、5专项调研活动到会。"`
+	IsFllow    int       `description:"1关注、0取消关注"`
+	CreateTime time.Time `description:"创建时间"`
+}
+
+type CygxUserLabel struct {
+	Id         int       `orm:"column(id);pk"`
+	UserId     int       `description:"用户ID"`
+	CompanyId  int       `description:"公司id"`
+	RealName   string    `description:"用户实际名称"`
+	Mobile     string    `description:"手机号"`
+	Email      string    `description:"邮箱"`
+	Label      string    `description:"标签内容"`
+	Weight     int       `description:"权重"`
+	SourceId   int       `description:"来源ID(产业ID,系列ID)"`
+	Source     int       `description:"来源1:产业、2:系列"`
+	IsFollow   int       `description:"是否关注,1是,0否"`
+	CreateTime time.Time `description:"创建时间"`
+	ModifyTime time.Time `description:"更新时间"`
+}
+
+// 获取数量
+func GetCygxUserLabelCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_user_label as art WHERE 1= 1   AND modify_time > DATE_SUB(CURDATE(), INTERVAL 3 MONTH)  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 添加
+func AddCygxUserLabel(item *CygxUserLabel) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+// 批量添加
+func CygxUserLabelMulti(items []*CygxUserLabel) (err error) {
+	o := orm.NewOrm()
+	if len(items) > 0 {
+		//批量添加新的记录
+		_, err = o.InsertMulti(len(items), items)
+	}
+	return
+}
+
+// 修改是否关注
+func UpdateCygxUserLabelIsFollow(isFollow, sourceId, source, userId int, label string) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_user_label SET is_follow=?,label = ? , modify_time=NOW()  WHERE source_id=? AND source = ? AND user_id = ? `
+	_, err = o.Raw(sql, isFollow, label, sourceId, source, userId).Exec()
+	return
+}
+
+// 修改对应标签权重+1
+func UpdateCygxUserLabelWeight(sourceId, source, userId int, label string) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_user_label SET weight = weight +1 ,label = ? , modify_time=NOW()  WHERE source_id=? AND source = ? AND  user_id = ? `
+	_, err = o.Raw(sql, label, sourceId, source, userId).Exec()
+	return
+}
+
+// 把所有用户标签权重设置为0
+func UpdateCygxUserLabelWeightAll() (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_user_label SET weight = 0 `
+	_, err = o.Raw(sql).Exec()
+	return
+}
+
+// 列表
+func GetCygxUserLabelList(condition string, pars []interface{}) (items []*CygxUserLabel, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_user_label as art WHERE 1= 1   	`
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+// UpdateCygxUserLabelMulti 批量修改用户标签权重
+func UpdateCygxUserLabelMulti(items []*CygxUserLabel) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw(` UPDATE cygx_user_label SET weight = ? WHERE user_id = ? AND label = ? `).Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for _, v := range items {
+		_, err = p.Exec(
+			v.Weight,
+			v.UserId,
+			v.Label)
+		if err != nil {
+			return
+		}
+	}
+	return
+}

+ 42 - 0
models/user_label_activity.go

@@ -0,0 +1,42 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxUserLabelActivity struct {
+	Id                     int       `orm:"column(id);pk"`
+	UserId                 int       `description:"用户ID"`
+	CompanyId              int       `description:"公司id"`
+	RealName               string    `description:"用户实际名称"`
+	Mobile                 string    `description:"手机号"`
+	Email                  string    `description:"邮箱"`
+	Label                  string    `description:"标签内容"`
+	ActivityId             int       `description:"活动ID"`
+	IndustrialManagementId int       `description:"cygx_industrial_management表的主键ID"`
+	CreateTime             time.Time `description:"创建时间"`
+	ModifyTime             time.Time `description:"更新时间"`
+}
+
+// 列表
+func GetCygxUserLabelActivity(condition string, pars []interface{}) (items []*CygxUserLabelActivity, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_user_label_activity as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+// 批量添加
+func AddCygxUserLabelActivityList(items []*CygxUserLabelActivity) (lastId int64, err error) {
+	lenitems := len(items)
+	if lenitems == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	_, err = o.InsertMulti(1, items)
+	return
+}

+ 43 - 0
models/user_label_activity_special.go

@@ -0,0 +1,43 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxUserLabelActivitySpecial struct {
+	Id                     int       `orm:"column(id);pk"`
+	UserId                 int       `description:"用户ID"`
+	CompanyId              int       `description:"公司id"`
+	RealName               string    `description:"用户实际名称"`
+	Mobile                 string    `description:"手机号"`
+	Email                  string    `description:"邮箱"`
+	Label                  string    `description:"标签内容"`
+	ActivityId             int       `description:"活动ID"`
+	IndustrialManagementId int       `description:"cygx_industrial_management表的主键ID"`
+	CreateTime             time.Time `description:"创建时间"`
+	ModifyTime             time.Time `description:"更新时间"`
+}
+
+// 列表
+func GetCygxUserLabelActivitySpecial(condition string, pars []interface{}) (items []*CygxUserLabelActivitySpecial, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_user_label_activity_special as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+// 批量添加
+func AddCygxUserLabelActivitySpecialList(items []*CygxUserLabelActivitySpecial) (lastId int64, err error) {
+	lenitems := len(items)
+	if lenitems == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	_, err = o.InsertMulti(1, items)
+	return
+}

+ 50 - 0
models/user_label_article.go

@@ -0,0 +1,50 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxUserLabelArticle struct {
+	Id         int       `orm:"column(id);pk"`
+	UserId     int       `description:"用户ID"`
+	CompanyId  int       `description:"公司id"`
+	RealName   string    `description:"用户实际名称"`
+	Mobile     string    `description:"手机号"`
+	Email      string    `description:"邮箱"`
+	Label      string    `description:"标签内容"`
+	ArticleId  int       `description:"文章ID"`
+	SourceId   int       `description:"来源ID(产业ID,系列ID)"`
+	Source     int       `description:"来源1:产业、2:系列"`
+	CreateTime time.Time `description:"创建时间"`
+	ModifyTime time.Time `description:"更新时间"`
+}
+
+// 添加
+func AddCygxUserLabelArticle(item *CygxUserLabelArticle) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+// 批量添加
+func AddCygxUserLabelArticleList(items []*CygxUserLabelArticle) (lastId int64, err error) {
+	lenitems := len(items)
+	if lenitems == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	_, err = o.InsertMulti(1, items)
+	return
+}
+
+// 列表
+func GetCygxUserLabelArticleList(condition string, pars []interface{}) (items []*CygxUserLabelArticle, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_user_label_article as art WHERE 1= 1   	`
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 26 - 0
models/wx_user.go

@@ -584,9 +584,35 @@ func GetWxUserByMobiles(mobiles []string) (items []*WxUser, err error) {
 	return
 }
 
+// GetWxUserByMobiles 根据用户手机号获取用户详情
+func GetWxUserByOutboundMobiles(mobiles []string) (items []*WxUser, err error) {
+	lenmobiles := len(mobiles)
+	if lenmobiles == 0 {
+		return
+	}
+	sql := `SELECT* FROM wx_user  WHERE outbound_mobile in (` + utils.GetOrmInReplace(lenmobiles) + `)  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, mobiles).QueryRows(&items)
+	return
+}
+
 func UserSubscribe(subscribeTime string, userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE wx_user SET cygx_subscribe=1,cygx_subscribe_time=? WHERE user_id = ? `
 	_, err = o.Raw(sql, subscribeTime, userId).Exec()
 	return
 }
+
+func GetWxUserOutboundMobiles(mobiles []string) (item []*WxUserOutboundMobile, err error) {
+	lenmobiles := len(mobiles)
+	if lenmobiles == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	sql := `SELECT u.real_name,u.mobile,u.outbound_mobile,u.company_id,p.company_name ,GROUP_CONCAT( DISTINCT p.seller_name SEPARATOR '/' ) AS seller_name
+			FROM wx_user as u 
+			INNER JOIN company_product AS p ON p.company_id = u.company_id 
+			WHERE outbound_mobile IN(` + utils.GetOrmInReplace(lenmobiles) + `)   OR mobile IN (` + utils.GetOrmInReplace(lenmobiles) + `)   GROUP BY u.user_id`
+	_, err = o.Raw(sql, mobiles, mobiles).QueryRows(&item)
+	return
+}

+ 12 - 0
models/xzs_choose_category.go

@@ -27,6 +27,18 @@ func GetCygxXzsChooseCategoryList(mobile string) (items []*CygxXzsChooseCategory
 	return
 }
 
+// 列表
+func GetCygxXzsChooseCategoryListByCon(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxXzsChooseCategory, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_xzs_choose_category as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	//sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 // 添加
 func AddCygxCategoryFllow(item *CygxXzsChooseCategory) (lastId int64, err error) {
 	o := orm.NewOrm()

+ 27 - 0
routers/commentsRouter.go

@@ -250,6 +250,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySignCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySignCoAntroller"],
+        beego.ControllerComments{
+            Method: "SignupDetail",
+            Router: `/signup/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"],
         beego.ControllerComments{
             Method: "SpecialTripAdd",
@@ -1105,6 +1114,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"],
         beego.ControllerComments{
             Method: "ArticleHotList",
@@ -1285,6 +1303,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
+        beego.ControllerComments{
+            Method: "ApplyDetail",
+            Router: `/apply/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
         beego.ControllerComments{
             Method: "ApplyTryOut",

+ 42 - 15
services/activity.go

@@ -426,6 +426,13 @@ func GetUserTypeZhengShi(companyId int) (userType int, permissionStrnew, permiss
 				return
 			}
 			permissionStrnew = permissionStr
+
+			permissionZhengShiStr, errs = models.GetCompanyPermissionByUserZhengShi(companyId)
+			if errs != nil {
+				err = errs
+				return
+			}
+			permissionStrZhengShinew = permissionZhengShiStr
 			//大套餐客户,数据库添加标识,
 			companyUserTypeDetail, errs := models.GetCygxCompanyUserType(companyId)
 			if errs != nil && errs.Error() != utils.ErrNoRow() {
@@ -438,11 +445,6 @@ func GetUserTypeZhengShi(companyId int) (userType int, permissionStrnew, permiss
 					return
 				}
 			}
-			permissionZhengShiStr, errs = models.GetCompanyPermissionByUserZhengShi(companyId)
-			if errs != nil {
-				err = errs
-				return
-			}
 			//1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户、 10: 30W套餐客户
 			//大套餐客户定义:医药、消费、科技、智造、策略。5个行业中任意4个及以上是正式权限的,属于大套餐客户(医药、消费、科技、智造需要主客观都开)
 			if companyDetail.Status == "永续" {
@@ -493,14 +495,35 @@ func GetUserTypeZhengShi(companyId int) (userType int, permissionStrnew, permiss
 }
 
 // GetSpecialDetailUserPower 处理用户查看详情的权限
-func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.ActivityDetail) (havePower bool, err error) {
+func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.ActivityDetail) (havePower, isResearchSpecial bool, err error) {
 	var companyDetailStatus string
 	var userTypeStr string
+
 	//如果是弘则的用户或者宏观的权限不做校验
 	if GetBelongingRai(user.Mobile) || activityInfo.ChartPermissionName == utils.HONG_GUAN_NAME {
 		havePower = true
 		return
 	}
+	userType, permissionStr, permissionStrZhengShi, e := GetUserTypeZhengShi(user.CompanyId)
+	if e != nil {
+		err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
+		return
+	}
+	//如果是 公司调研电话会:3,或 专家线下沙龙:5  而且  除易董同步过来的以外的研选类型活动,必须要有研选的正式权限
+	if (activityInfo.ActivityTypeId == 3 || activityInfo.ActivityTypeId == 5) && activityInfo.YidongActivityId == "" && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
+		isResearchSpecial = true
+	}
+	//如果是 公司调研电话会:3,或 专家线下沙龙:5  而且  除易董同步过来的以外的研选类型活动,必须要有研选的正式权限
+	if isResearchSpecial {
+		if !strings.Contains(permissionStr, utils.CHART_PERMISSION_NAME_YANXUAN) {
+			//如果连试用权限都没有,那么久按照普通的研选样式展示
+			isResearchSpecial = false
+		}
+		if !strings.Contains(permissionStrZhengShi, activityInfo.ChartPermissionName) {
+			havePower = false
+			return
+		}
+	}
 	//处理决策人可见权限
 	if user.IsMaker == 0 && activityInfo.IsMakerShow == 1 {
 		havePower = false
@@ -526,12 +549,6 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
 			return
 		}
 	}
-
-	userType, permissionStr, permissionStrZhengShi, e := GetUserTypeZhengShi(user.CompanyId)
-	if e != nil {
-		err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
-		return
-	}
 	if permissionStr == "" {
 		return
 	}
@@ -1312,7 +1329,7 @@ func ActivityAttendanceDetail(cont context.Context) (err error) {
 	var activityIds string
 	var activityIdsLongTime string //可回放的会议,到会详情持续更新加入到不做14天限制的活动中
 	fmt.Println("开始同步")
-	dateTime := time.Now().AddDate(0, 0, -14).Format(utils.FormatDate)
+	dateTime := time.Now().AddDate(0, 0, -7).Format(utils.FormatDate)
 	dateNow := time.Now().AddDate(0, 0, 0).Format(utils.FormatDate)
 	startDate := dateTime + " 00:00:00"
 	endDate := dateNow + " 23:59:59"
@@ -1360,6 +1377,7 @@ func ActivityAttendanceDetail(cont context.Context) (err error) {
 				var isPlayback bool // 是否包含回放
 				needAddAttendanc := make([]*models.CygxActivityAttendanceDetail, 0)
 				var mobileStr string
+				var mobileArr []string
 				if len(list) > 0 {
 					fmt.Println("原来的", vAct.RoadshowTitle)
 					fmt.Println("处理的", activityName)
@@ -1392,6 +1410,7 @@ func ActivityAttendanceDetail(cont context.Context) (err error) {
 							item.CrmCompanyMapStatusId = v.CrmCompanyMapStatusId
 							item.CreateTime = time.Now()
 							mobileStr += "'" + v.UserPhone + "'" + ","
+							mobileArr = append(mobileArr, v.UserPhone)
 							needAddAttendanc = append(needAddAttendanc, item)
 						}
 					}
@@ -1433,7 +1452,10 @@ func ActivityAttendanceDetail(cont context.Context) (err error) {
 						return err
 					}
 
-					go AddctivitySignupDetailByJmcj(needAddAttendanc, activityDetail.ActivityId)
+					go ActivityUserLabelLogAdd(activityDetail.ActivityId, mobileArr)
+
+					AddctivitySignupDetailByJmcj(needAddAttendanc, activityDetail.ActivityId)
+
 				}
 			}
 		}
@@ -1469,6 +1491,7 @@ func ActivityAttendanceDetail(cont context.Context) (err error) {
 				var isPlayback bool // 是否包含回放
 				needAddAttendanc := make([]*models.CygxActivityAttendanceDetail, 0)
 				var mobileStr string
+				var mobileArr []string
 				if len(list) > 0 {
 					fmt.Println("原来的1", vAct.ActivityName)
 					fmt.Println("处理的2", activityName)
@@ -1501,6 +1524,7 @@ func ActivityAttendanceDetail(cont context.Context) (err error) {
 							item.CrmCompanyMapStatusId = v.CrmCompanyMapStatusId
 							item.CreateTime = time.Now()
 							mobileStr += "'" + v.UserPhone + "'" + ","
+							mobileArr = append(mobileArr, v.UserPhone)
 							needAddAttendanc = append(needAddAttendanc, item)
 						}
 					}
@@ -1541,7 +1565,10 @@ func ActivityAttendanceDetail(cont context.Context) (err error) {
 						return err
 					}
 					activityIds += strconv.Itoa(vAct.ActivityId) + ","
-					go AddctivitySignupDetailByJmcj(needAddAttendanc, vAct.ActivityId)
+
+					go ActivityUserLabelLogAdd(vAct.ActivityId, mobileArr)
+					AddctivitySignupDetailByJmcj(needAddAttendanc, vAct.ActivityId)
+
 				}
 			}
 		}

+ 659 - 0
services/activity_meeting.go

@@ -0,0 +1,659 @@
+package services
+
+import (
+	"context"
+	"errors"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+//func init() {
+//	fmt.Println(strings.Contains("渠道新声第583期运动服饰渠道调研更新反馈", "运动服饰渠道调研更新反馈"))
+//	fmt.Println(len("反馈"))
+//	GroupingActivityToJmcj()
+//	GetActivityMeetingByJmcj()
+//}
+
+// GroupingActivityToJmcj 建立与进门财经的活动关联
+func GroupingActivityToJmcj(cont context.Context) (err error) {
+	//func GroupingActivityToJmcj() (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("建立与进门财经的活动关联失败"+err.Error(), 2)
+		}
+	}()
+	dateTime := time.Now().AddDate(0, 0, -7).Format(utils.FormatDate)
+	dateNow := time.Now().AddDate(0, 0, 0).Format(utils.FormatDate)
+	startDate := dateTime + " 00:00:00"
+	endDate := dateNow + " 23:59:59"
+	var condition string
+	var pars []interface{}
+	condition = " AND roadshow_begin_time BETWEEN ? AND ? "
+	//condition += " AND roadshow_id = 95871  "
+	pars = append(pars, startDate, endDate)
+	condition += ` GROUP BY roadshow_id `
+	listJmcj, e := models.GetJmcjRoadshowDataList(condition, pars)
+	if e != nil {
+		err = errors.New("GetJmcjRoadshowDataList, Err: " + e.Error())
+		return
+	}
+	textLen := 15
+	pars = make([]interface{}, 0)
+	condition = " AND activity_time BETWEEN ? AND ? AND publish_status = 1  AND jmcj_activity_id = '' "
+	//condition += " AND activity_id = 1339   "
+	pars = append(pars, startDate, endDate)
+	listHz, e := models.GetActivityListByCondition(condition, pars)
+	if e != nil {
+		err = errors.New("GetActivityListByCondition, Err: " + e.Error())
+		return
+	}
+
+	mapGroupActivityid := make(map[int]string)
+	//通过进门财经匹配弘则
+	for _, vJmcj := range listJmcj {
+		var roadshowTitle, roadshowTitle1, roadshowTitle2, roadshowTitle3, roadshowTitle4 string
+		roadshowTitle = vJmcj.RoadshowTitle
+		roadshowTitle = strings.Replace(roadshowTitle, " ", "", -1)
+		roadshowBeginTime := utils.TimeRemoveHms2(vJmcj.RoadshowBeginTime)
+		nameSlice1 := strings.Split(roadshowTitle, "|")
+		nameSlice2 := strings.Split(roadshowTitle, ":")
+		nameSlice3 := strings.Split(roadshowTitle, "】")
+		nameSlice4 := strings.Split(roadshowTitle, "-")
+		if len(nameSlice1) >= 1 {
+			roadshowTitle1 = nameSlice1[len(nameSlice1)-1]
+		}
+		if len(nameSlice2) >= 1 {
+			roadshowTitle2 = nameSlice2[len(nameSlice2)-1]
+		}
+		if len(nameSlice3) >= 1 {
+			roadshowTitle3 = nameSlice3[len(nameSlice3)-1]
+		}
+		if len(nameSlice4) >= 1 {
+			roadshowTitle4 = nameSlice4[len(nameSlice4)-1]
+		}
+
+		if roadshowTitle == "" {
+			continue
+		}
+		//fmt.Println(roadshowTitle1)
+		//fmt.Println(roadshowTitle2)
+		//fmt.Println(roadshowTitle3)
+		//fmt.Println(roadshowTitle4)
+
+		for _, vHz := range listHz {
+			//如果同一时间标题匹配就建立匹配关系
+			if roadshowBeginTime == utils.TimeRemoveHms2(vHz.ActivityTime) {
+				if strings.Contains(vHz.ActivityNameTask, roadshowTitle) || strings.Contains(vHz.JmcjRoadshowTitle, roadshowTitle) {
+					mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
+					break
+				}
+
+				//去掉空格标识,完全等于时候的匹配
+				if strings.Replace(vHz.ActivityName, " ", "", -1) == strings.Replace(vJmcj.RoadshowTitle, " ", "", -1) {
+					mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
+					break
+				}
+
+				if len(roadshowTitle1) > textLen {
+					if strings.Contains(vHz.ActivityNameTask, roadshowTitle1) || strings.Contains(vHz.JmcjRoadshowTitle, roadshowTitle1) {
+						mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
+						break
+					}
+				}
+				if len(roadshowTitle2) > textLen {
+					if strings.Contains(vHz.ActivityNameTask, roadshowTitle2) || strings.Contains(vHz.JmcjRoadshowTitle, roadshowTitle2) {
+						mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
+						break
+					}
+				}
+				if len(roadshowTitle3) > textLen {
+					if strings.Contains(vHz.ActivityNameTask, roadshowTitle3) || strings.Contains(vHz.JmcjRoadshowTitle, roadshowTitle3) {
+						mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
+						break
+					}
+				}
+				if len(roadshowTitle4) > textLen {
+					if strings.Contains(vHz.ActivityNameTask, roadshowTitle4) || strings.Contains(vHz.JmcjRoadshowTitle, roadshowTitle4) {
+						mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
+						break
+					}
+				}
+			}
+		}
+	}
+
+	//通过弘则匹配进门财经
+	for _, vHz := range listHz {
+		if mapGroupActivityid[vHz.ActivityId] != "" {
+			continue
+		}
+		var roadshowTitle string
+		roadshowTitle = vHz.ActivityName
+		nameSlice := strings.Split(roadshowTitle, "】")
+		if len(nameSlice) >= 1 {
+			roadshowTitle = nameSlice[len(nameSlice)-1]
+			if len(roadshowTitle) > textLen {
+				vHz.ActivityTime = utils.TimeRemoveHms2(vHz.ActivityTime)
+				for _, vJmcj := range listJmcj {
+					//如果同一时间标题匹配就建立匹配关系
+					if vHz.ActivityTime == utils.TimeRemoveHms2(vJmcj.RoadshowBeginTime) {
+						if strings.Contains(vJmcj.RoadshowTitle, roadshowTitle) {
+							mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
+							break
+						}
+						if strings.Contains(vJmcj.RoadshowTitle, vHz.JmcjRoadshowTitle) && vHz.JmcjRoadshowTitle != "" {
+							mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
+							break
+						}
+					}
+				}
+			}
+		}
+	}
+
+	if len(mapGroupActivityid) > 0 {
+		e = models.UpdateJmcjActivityIdGroup(mapGroupActivityid)
+		if e != nil {
+			err = errors.New("UpdateJmcjActivityIdGroup, Err: " + e.Error())
+		}
+	}
+
+	return
+
+}
+
+// GetActivityMeetingByJmcj 同步进门财经到会信息,并处理爽约记录
+func GetActivityMeetingByJmcj(cont context.Context) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("获取进门财经的到会信息失败,Err"+err.Error(), 2)
+		}
+	}()
+
+	//获取需要一直同步的活动信息
+	configCode := "jin_meng_activity_id"
+	detail, e := models.GetConfigByCode(configCode)
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error())
+		return
+	}
+	mapActivityIdlLongTime := make(map[string]string)
+	sliceValue := strings.Split(detail.ConfigValue, ",")
+	for _, v := range sliceValue {
+		mapActivityIdlLongTime[v] = v
+	}
+	dateTime := time.Now().AddDate(0, 0, 14).Format(utils.FormatDate)
+	dateNow := time.Now().AddDate(0, 0, 0).Format(utils.FormatDate)
+	startDate := dateTime + " 00:00:00"
+	endDate := dateNow + " 23:59:59"
+	var condition string
+	var pars []interface{}
+	//获取弘则要同步到会信息的活动
+	condition = ` AND activity_time BETWEEN ? AND ? AND publish_status = 1  AND  jmcj_activity_id != '' OR (  activity_id IN (` + detail.ConfigValue + `) AND publish_status = 1 AND  jmcj_activity_id != '' ) `
+	pars = append(pars, startDate, endDate)
+	listHz, e := models.GetActivityListByCondition(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetActivityListByCondition, Err: " + e.Error())
+		return
+	}
+
+	var jmcjActivityIds []string
+	var activityIds []int
+	mapGroupActivityid := make(map[string]int)
+	mapGroupActivityTime := make(map[string]string)
+	for _, v := range listHz {
+		jmcjActivityIds = append(jmcjActivityIds, v.JmcjActivityId)
+		activityIds = append(activityIds, v.ActivityId)
+		mapGroupActivityid[v.JmcjActivityId] = v.ActivityId
+		mapGroupActivityTime[v.JmcjActivityId] = v.ActivityTime
+	}
+
+	//return
+	lenjmcjActivityIds := len(jmcjActivityIds)
+	if lenjmcjActivityIds == 0 {
+		return
+	}
+	//获取进门财经对应的路演ID的到会列表
+	pars = make([]interface{}, 0)
+	condition = ` AND roadshow_id IN (` + utils.GetOrmInReplace(lenjmcjActivityIds) + `)`
+	pars = append(pars, jmcjActivityIds)
+	listJmcj, e := models.GetJmcjRoadshowDataList(condition, pars)
+	if e != nil {
+		err = errors.New("GetJmcjRoadshowDataList, Err: " + e.Error())
+		return
+	}
+
+	//获取已经写入到会信息的参会人员
+	lenactivityIds := len(activityIds)
+	pars = make([]interface{}, 0)
+	condition = ` AND activity_id IN (` + utils.GetOrmInReplace(lenactivityIds) + `)`
+	pars = append(pars, activityIds)
+	attendanceDetailList, e := models.GetActivityAttendanceDetailListCondition(condition, pars)
+	if e != nil {
+		err = errors.New("GetActivityAttendanceDetailListCondition, Err: " + e.Error())
+		return
+	}
+	mapAttendanceDetail := make(map[string]int)
+	for _, v := range attendanceDetailList {
+		mapAttendanceDetail[fmt.Sprint("ActivityId:", v.ActivityId, "Mobile:", v.Mobile)] = v.ActivityId
+	}
+
+	var mobiles []string
+	var mobileMap = make(map[string]string)
+	//var isPlayback bool                    // 是否包含回放
+	var isPlaybackMap = make(map[int]bool) // 是否包含回放map
+	var activityIdsLongTime string         //包含回放的活动ID
+	needAddAttendanc := make([]*models.CygxActivityAttendanceDetail, 0)
+	for _, v := range listJmcj {
+		if v.UserPhone == "" {
+			continue
+		}
+		if mapGroupActivityid[v.RoadshowId] == 0 {
+			continue
+		}
+		//如果数据已经存在了那么就不做数据更新
+		if mapAttendanceDetail[fmt.Sprint("ActivityId:", mapGroupActivityid[v.RoadshowId], "Mobile:", v.UserPhone)] > 0 {
+			continue
+		}
+		item := new(models.CygxActivityAttendanceDetail)
+		item.ActivityId = mapGroupActivityid[v.RoadshowId]
+		item.RealName = v.UserName
+		item.Mobile = v.UserPhone
+		item.CompanyName = v.Company
+		item.FirstMeetingTime = v.FirstWatchTime
+		item.LastMeetingTime = v.LastWatchTime
+		item.IsMeetingStr = 1
+		item.Duration = utils.GetAttendanceDetailSeconds(v.JoinTime)
+		if v.JoinType == 1 {
+			item.MeetingTypeStr = "网络"
+		} else {
+			item.MeetingTypeStr = "电话"
+		}
+		item.MeetingAuthentication = v.AuthInfo
+		if v.DataType == 1 {
+			item.MeetingStatusStr = "直播"
+		} else {
+			item.MeetingStatusStr = "回放"
+			if !isPlaybackMap[item.ActivityId] && mapActivityIdlLongTime[strconv.Itoa(item.ActivityId)] == "" {
+				activityIdsLongTime += strconv.Itoa(item.ActivityId) + ","
+			}
+			isPlaybackMap[item.ActivityId] = true
+		}
+		item.Position = v.Occupation
+		item.UseridEntity = v.UseridEntity
+		item.ActivityTime = mapGroupActivityTime[v.RoadshowId]
+		item.CrmCompanyMapStatusId = v.CrmCompanyMapStatusId
+		item.CreateTime = time.Now()
+		needAddAttendanc = append(needAddAttendanc, item)
+		if mobileMap[v.UserPhone] == "" {
+			mobiles = append(mobiles, v.UserPhone)
+			mobileMap[v.UserPhone] = v.UserPhone
+		}
+	}
+
+	if len(needAddAttendanc) == 0 {
+		return
+	}
+
+	//根据手机号获取这些用户的信息
+	listUser, e := models.GetWxUserOutboundMobiles(mobiles)
+	if e != nil {
+		err = errors.New("GetWxUserOutboundMobiles, Err: " + e.Error())
+		return
+	}
+
+	mapUser := make(map[string]*models.WxUserOutboundMobile)
+	for _, v := range listUser {
+		mapUser[v.Mobile] = v
+		mapUser[v.OutboundMobile] = v
+	}
+
+	var updateActivityIds []int                   // 需要更新的活动ID
+	var updateActivityIdsMap = make(map[int]bool) // 需要更新的活动ID
+	for k, v := range needAddAttendanc {
+		if needAddAttendanc[k].CompanyId == 0 && mapUser[v.Mobile] != nil {
+			needAddAttendanc[k].CompanyId = mapUser[v.Mobile].CompanyId
+			needAddAttendanc[k].SellerName = mapUser[v.Mobile].SellerName
+			needAddAttendanc[k].CompanyName = mapUser[v.Mobile].CompanyName
+			needAddAttendanc[k].IsMeetingStr = 1
+		}
+		if !updateActivityIdsMap[v.ActivityId] {
+			updateActivityIds = append(updateActivityIds, v.ActivityId)
+			updateActivityIdsMap[v.ActivityId] = true
+		}
+		attendanceDetailList = append(attendanceDetailList, v)
+	}
+	if len(updateActivityIds) == 0 {
+		return
+	}
+
+	// 更新需要长时间同步到会信息的活动
+	if activityIdsLongTime != "" {
+		activityIdsLongTime = strings.TrimRight(activityIdsLongTime, ",")
+		activityIdsLongTime = detail.ConfigValue + "," + activityIdsLongTime
+		e = models.UpdateConfigByCode(activityIdsLongTime, configCode)
+		if e != nil {
+			err = errors.New("UpdateConfigByCode, Err: " + e.Error())
+			return
+		}
+	}
+
+	//return
+	{
+		//参会记录
+		e = models.AddAttendancDetailNew(needAddAttendanc, updateActivityIds)
+		if e != nil {
+			err = errors.New("AddAttendancDetailNew, Err: " + e.Error())
+			return err
+		}
+	}
+
+	{
+		//标记到会信息
+		e = models.UpdateCygxActivitySignupIsMeeting(needAddAttendanc)
+		if e != nil {
+			err = errors.New("UpdateCygxActivitySignupIsMeeting, Err: " + e.Error())
+			return err
+		}
+	}
+
+	{
+		//处理是否限制报名
+		AddCygxActivityRestrictSignupByAdminNew(updateActivityIds)
+	}
+
+	{
+		//通过进门财经添加用户参数信息
+		AddctivitySignupDetailByJmcjNew(needAddAttendanc, updateActivityIds)
+	}
+
+	{
+		//添加报名日志 (对个人以及机构互动数量进行排序下载使用)
+		CygxActivityMeetSort(needAddAttendanc, updateActivityIds)
+	}
+	return
+}
+
+// 查研观向处理活动用户限制报名
+func AddCygxActivityRestrictSignupByAdminNew(activityIds []int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go utils.SendAlarmMsg("查研观向处理活动用户限制报名失败,AddCygxActivityRestrictSignupByAdminNew,Err:"+err.Error()+"activityIds"+fmt.Sprint(activityIds), 3)
+		}
+	}()
+
+	var condition string
+	var pars []interface{}
+	lenactivityIds := len(activityIds)
+	if lenactivityIds == 0 {
+		return
+	}
+	condition = ` AND	is_meeting = 1  AND activity_id IN (` + utils.GetOrmInReplace(lenactivityIds) + `)`
+	pars = append(pars, activityIds)
+	//获取到会了的人员
+	meetingList, e := models.GetActivitySignupList(condition, pars)
+	if e != nil {
+		err = errors.New("GetActivitySignupList" + e.Error())
+		return
+	}
+	var userIdArr []int
+	if len(meetingList) > 0 {
+		for _, v := range meetingList {
+			userIdArr = append(userIdArr, v.UserId)
+		}
+		lenuserIdArr := len(userIdArr)
+		var condition string
+		var pars []interface{}
+		condition = ` AND user_id IN (` + utils.GetOrmInReplace(lenuserIdArr) + `)`
+		pars = append(pars, userIdArr)
+		restrictSignupList, e := models.GetCygxActivityRestrictSignupList(condition, pars, 0, 9999)
+		if e != nil {
+			err = errors.New("GetCygxActivityRestrictSignupList" + e.Error())
+			return
+		}
+
+		//获取这些用户是否被加入到限制报名了
+		maptotalRestrict := make(map[int]bool)
+		for _, v := range restrictSignupList {
+			maptotalRestrict[v.UserId] = true
+		}
+
+		pars = make([]interface{}, 0)
+		condition = `   AND a.is_limit_people  = 1  AND  v.is_meeting = 0 	AND  v.do_fail_type = 0   AND  v.user_id IN (` + utils.GetOrmInReplace(lenuserIdArr) + `) AND a.activity_id IN (` + utils.GetOrmInReplace(lenactivityIds) + `)`
+		pars = append(pars, userIdArr, activityIds)
+		listSignup, e := models.GetActivitySignupInnerActivityList(condition, pars)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetActivitySignupInnerActivityList" + e.Error())
+			return
+		}
+
+		mapNomeet := make(map[int]int)
+		if len(listSignup) > 0 {
+			for _, v := range listSignup {
+				mapNomeet[v.UserId]++
+			}
+		}
+		var userIdDelArr []int
+		for _, v := range meetingList {
+			//如果加入了爽约限制但是爽约次数少于3条就删除爽约记录
+			if maptotalRestrict[v.UserId] && mapNomeet[v.UserId] < 3 {
+				userIdDelArr = append(userIdDelArr, v.UserId)
+			}
+		}
+		//if len(userIdDelArr) > 0 {
+		//	e = models.DeleteCygxActivityRestrictSignupByUserIds(userIdDelArr)
+		//	if e != nil {
+		//		err = errors.New("DeleteCygxActivityRestrictSignupByUserIds" + e.Error())
+		//		return
+		//	}
+		//}
+	}
+
+	//获取未到会的人员
+	pars = make([]interface{}, 0)
+	condition = `   AND  v.is_meeting = 0 	AND  v.do_fail_type = 0  AND v.activity_id IN (` + utils.GetOrmInReplace(lenactivityIds) + `)`
+	pars = append(pars, activityIds)
+	nomeetingListlist, e := models.GetActivitySignupInnerActivityList(condition, pars)
+	if e != nil {
+		err = errors.New("GetActivitySignupNomeetingCountList" + e.Error())
+		return
+	}
+	var userIdSiginArr []int
+	var items []*models.CygxActivitySignupBreak
+	for _, v := range nomeetingListlist {
+		userIdSiginArr = append(userIdSiginArr, v.UserId)
+		//添加爽约记录
+		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)
+	}
+	lenuserIdSiginArr := len(userIdSiginArr)
+	if lenuserIdSiginArr == 0 {
+		return
+	}
+
+	var itemsRestrict []*models.CygxActivityRestrictSignup
+	maptotalRestrict := make(map[int]bool)
+
+	//var condition string
+	pars = make([]interface{}, 0)
+	condition = ""
+	restrictSignupList, e := models.GetCygxActivityRestrictSignupList(condition, pars, 0, 9999)
+	if e != nil {
+		err = errors.New("GetCygxActivityRestrictSignupList" + e.Error())
+		return
+	}
+
+	//获取这些用户是否被加入到限制报名了
+	for _, v := range restrictSignupList {
+		maptotalRestrict[v.UserId] = true
+	}
+
+	pars = make([]interface{}, 0)
+	condition = `    AND a.is_limit_people  = 1  AND  v.is_meeting = 0 	AND  v.do_fail_type = 0  AND user_id IN (` + utils.GetOrmInReplace(lenuserIdSiginArr) + `)`
+	pars = append(pars, userIdSiginArr)
+	listSignup, e := models.GetActivitySignupInnerActivityList(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetActivitySignupInnerActivityList" + e.Error())
+		return
+	}
+	mapNomeet := make(map[int]int)
+	if len(listSignup) > 0 {
+		for _, v := range listSignup {
+			mapNomeet[v.UserId]++
+		}
+	}
+
+	for _, v := range meetingList {
+		//如果加入了爽约限制但是爽约次数少于3条就删除爽约记录
+		if !maptotalRestrict[v.UserId] && mapNomeet[v.UserId] >= 3 {
+			itemRestrict := new(models.CygxActivityRestrictSignup)
+			itemRestrict.UserId = v.UserId
+			itemRestrict.CreateTime = time.Now()
+			itemRestrict.Mobile = v.Mobile
+			itemRestrict.Email = v.Email
+			itemRestrict.CompanyId = v.CompanyId
+			itemRestrict.CompanyName = v.CompanyName
+			itemRestrict.IsRestrict = 1
+			itemsRestrict = append(itemsRestrict, itemRestrict)
+			maptotalRestrict[v.UserId] = true
+		}
+	}
+
+	e = models.DeleteCygxActivitySignupBreakByIds(activityIds)
+	if e != nil {
+		err = errors.New("DeleteCygxActivitySignupBreakById" + e.Error())
+		return
+	}
+
+	//添加爽约记录
+	if len(items) > 0 {
+		_, e = models.AddCygxActivitySignupBreakList(items)
+		if e != nil {
+			err = errors.New("AddCygxActivitySignupBreakList, Err: " + e.Error())
+			return
+		}
+	}
+
+	//添加报名限制
+	if len(itemsRestrict) > 0 {
+		_, e = models.AddCygxActivityRestrictSignupList(itemsRestrict)
+		if e != nil {
+			err = errors.New("AddCygxActivityRestrictSignupList, Err: " + e.Error())
+			return
+		}
+	}
+
+	return
+}
+
+// 对个人以及机构互动数量进行排序下载使用
+func CygxActivityMeetSort(list []*models.CygxActivityAttendanceDetail, activityIds []int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go utils.SendAlarmMsg("查研观向处理活动用户限制报名失败,AddCygxActivityRestrictSignupByAdminNew,Err:"+err.Error()+"activityIds"+fmt.Sprint(activityIds), 3)
+		}
+	}()
+	var items []*models.CygxActivityMeetDetailLog
+	var condition string
+	var pars []interface{}
+	lenactivityIds := len(activityIds)
+	if lenactivityIds == 0 {
+		return
+	}
+	//获取已经写入到会信息的参会人员
+	pars = make([]interface{}, 0)
+	condition = ` AND activity_id IN (` + utils.GetOrmInReplace(lenactivityIds) + `)`
+	pars = append(pars, activityIds)
+	activityMeetDetailLogList, e := models.GetCygxActivityMeetDetailLogList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxActivityMeetDetailLogList, Err: " + e.Error())
+		return
+	}
+	mapActivityMeetDetailL := make(map[string]int)
+	for _, v := range activityMeetDetailLogList {
+		mapActivityMeetDetailL[fmt.Sprint("ActivityId:", v.ActivityId, "Mobile:", v.Mobile)] = v.ActivityId
+	}
+
+	var companyIds []int
+	var companyIdsMap = make(map[int]bool)
+	var mobiles []string
+	var mobilesMap = make(map[string]bool)
+	for _, v := range list {
+		if mapActivityMeetDetailL[fmt.Sprint("ActivityId:", v.ActivityId, "Mobile:", v.Mobile)] > 0 {
+			continue
+		}
+		item := new(models.CygxActivityMeetDetailLog)
+		item.ActivityId = v.ActivityId
+		item.Mobile = v.Mobile
+		item.CompanyName = v.CompanyName
+		item.CompanyId = v.CompanyId
+		item.ActivityTime = v.ActivityTime
+		item.CreateTime = v.CreateTime
+		if !companyIdsMap[v.CompanyId] {
+			companyIds = append(companyIds, v.CompanyId)
+		}
+		if !mobilesMap[v.Mobile] {
+			mobiles = append(mobiles, v.Mobile)
+		}
+		items = append(items, item)
+	}
+	//插入
+	e = models.AddCygxActivityMeetDetailLogMulti(items)
+	if e != nil {
+		err = errors.New("AddCygxActivityMeetDetailLogMulti, Err: " + e.Error())
+		return
+	}
+
+	{
+		//批量修改个人参会数量
+		listMobileCount, e := models.GetActivityMeetDetailLogCountMobile(mobiles)
+		if e != nil {
+			err = errors.New("GetActivityMeetDetailLogCountCompany, Err: " + e.Error())
+			return
+		}
+
+		if len(listMobileCount) > 0 {
+			e = models.UpdateCygxActivityMeetDetailLogMobileNumMulti(listMobileCount)
+			if e != nil {
+				err = errors.New("UpdateCygxActivityMeetDetailLogMobileNumMulti, Err: " + e.Error())
+				return
+			}
+		}
+	}
+
+	{
+		//批量修改机构参会数量
+		listCompanyCount, e := models.GetActivityMeetDetailLogCountCompany(companyIds)
+		if e != nil {
+			err = errors.New("GetActivityMeetDetailLogCountCompany, Err: " + e.Error())
+			return
+		}
+
+		if len(listCompanyCount) > 0 {
+			e = models.UpdateCygxActivityMeetDetailLogCompanyNumMulti(listCompanyCount)
+			if e != nil {
+				err = errors.New("UpdateCygxActivityMeetDetailLogCompanyNumMulti, Err: " + e.Error())
+				return
+			}
+		}
+	}
+	return
+
+}

+ 27 - 0
services/activity_signin.go

@@ -179,3 +179,30 @@ func CygxActivityRestrictSignupByuid(uid, activityId int) (err error) {
 	}
 	return
 }
+
+// GetUserActivitySigninTimeMap  获取用户的签到时间
+func GetUserActivitySigninTimeMap(activityId int) (mapItem map[int]string, err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("扫码签到日志记录,失败,活动ID:"+strconv.Itoa(activityId)+err.Error(), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition = "  AND activity_id = ?  "
+	pars = append(pars, activityId)
+	userList, e := models.GetCygxActivitySigninList(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCygxActivitySigninList" + e.Error())
+		return
+	}
+	mapItem = make(map[int]string, 0)
+	for _, v := range userList {
+		if v.UserId == 0 {
+			continue
+		}
+		mapItem[v.UserId] = v.CreateTime.Format(utils.FormatDateTime)
+	}
+	return
+}

+ 95 - 2
services/activity_signup_detail.go

@@ -7,7 +7,7 @@ import (
 	"hongze/hongze_cygx/utils"
 )
 
-//AddctivitySignupDetail  获取当天已结束的活动的报名信息。添加到到会详情
+// AddctivitySignupDetail  获取当天已结束的活动的报名信息。添加到到会详情
 func AddctivitySignupDetail(cont context.Context) (err error) {
 	defer func() {
 		if err != nil {
@@ -93,7 +93,7 @@ func AddctivitySignupDetail(cont context.Context) (err error) {
 	return err
 }
 
-//AddctivitySignupDetailByJmcj 通过进门财经添加用户参数信息
+// AddctivitySignupDetailByJmcj 通过进门财经添加用户参数信息
 func AddctivitySignupDetailByJmcj(itemsDetail []*models.CygxActivityAttendanceDetail, activityId int) (err error) {
 	defer func() {
 		if err != nil {
@@ -207,3 +207,96 @@ func GetCygxActivityAttendanceDetail() {
 	}
 	//fmt.Println(mapDetal)
 }
+
+// AddctivitySignupDetailByJmcj 通过进门财经添加用户参数信息
+func AddctivitySignupDetailByJmcjNew(itemsDetail []*models.CygxActivityAttendanceDetail, activityIds []int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("通过进门财经添加用户参数信息失败 ErrMsg:"+err.Error(), 2)
+		}
+	}()
+	actLen := len(activityIds)
+	var condition string
+	var pars []interface{}
+	if actLen > 0 {
+		condition += ` AND activity_id IN (` + utils.GetOrmInReplace(actLen) + `)`
+		pars = append(pars, activityIds)
+	}
+
+	signUpDetailList, err := models.GetSignupDetailList(condition, pars)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+
+	mapsignUpDetai := make(map[string]string)
+	if len(signUpDetailList) > 0 {
+		for _, v := range signUpDetailList {
+			mapsignUpDetai[fmt.Sprint("ActivityId", v.ActivityId, "Mobile", v.Mobile)] = v.Mobile
+		}
+	}
+
+	//获取当天已经结束了 活动的报名人数
+	signUpList, err := models.GetSignupDetailBySignup(condition, pars)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+	//建立外呼号与手机号的绑定
+	mapsignUp := make(map[string]string)
+	if len(signUpList) > 0 {
+		for _, v := range signUpList {
+			mapsignUp[fmt.Sprint(v.OutboundMobile)] = v.Mobile
+		}
+	}
+
+	var itemsAdd []*models.CygxActivitySignupDetail
+	var itemsUpdate []*models.CygxActivitySignupDetail
+
+	for _, v := range itemsDetail {
+		var item = new(models.CygxActivitySignupDetail)
+		item.ActivityId = v.ActivityId
+		item.RealName = v.RealName
+		//如果手机号存在那么就是报名的,不存在就是直接参与的
+		if _, ok := mapsignUp[v.Mobile]; ok {
+			item.Mobile = mapsignUp[v.Mobile]
+		} else {
+			item.Mobile = v.Mobile
+		}
+		item.OutboundMobile = v.Mobile
+		item.CompanyName = v.CompanyName
+		item.CompanyId = v.CompanyId
+		item.SellerName = v.SellerName
+		item.FirstMeetingTime = v.FirstMeetingTime
+		item.LastMeetingTime = v.LastMeetingTime
+		item.Duration = v.Duration
+		item.MeetingTypeStr = v.MeetingTypeStr
+		item.MeetingAuthentication = v.MeetingAuthentication
+		item.MeetingStatusStr = v.MeetingStatusStr
+		item.CreateTime = v.CreateTime
+		item.Position = v.Position
+		item.IsMeeting = 1
+		item.UseridEntity = v.UseridEntity
+		item.ActivityTime = v.ActivityTime
+		item.CrmCompanyMapStatusId = v.CrmCompanyMapStatusId
+
+		if _, ok := mapsignUpDetai[fmt.Sprint("ActivityId", v.ActivityId, "Mobile", item.Mobile)]; !ok {
+			itemsAdd = append(itemsAdd, item)
+		} else {
+			itemsUpdate = append(itemsUpdate, item)
+		}
+	}
+	if len(itemsAdd) > 0 {
+		err = models.AddCygxActivitySignupDetail(itemsAdd)
+		if err != nil {
+			return
+		}
+	}
+	if len(itemsUpdate) > 0 {
+		err = models.UpdateActivitySignupDetailMulti(itemsUpdate)
+		if err != nil {
+			return
+		}
+	}
+
+	return err
+}

+ 67 - 0
services/activity_wx_template_msg.go

@@ -83,3 +83,70 @@ func SendResearchActivitiesTemplateMsg(user *models.WxUserItem, activityDetail *
 	}
 	return
 }
+
+// SendActivitieSignTemplateMsg 线下调研活动扫码签到给对应销售发模班消息
+func SendActivitieSignTemplateMsg(user *models.WxUserItem, activityDetail *models.ActivityDetail) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("线下调研活动扫码签到给对应销售发模班消息推送失败Err:", err.Error(), "活动ID:", activityDetail.ActivityId, "手机号:", user.Mobile), 2)
+		}
+	}()
+	var mobiles []string
+	//获取销售信息
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	if sellerItem != nil {
+		mobiles = append(mobiles, sellerItem.Mobile)
+	}
+
+	var first string
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+	var redirectUrl string
+
+	first = ""
+	keyword1 = activityDetail.ActivityName
+	keyword2 = user.RealName + "——" + user.CompanyName
+	keyword3 = time.Now().Format(utils.FormatDateTime)
+	keyword4 = ""
+	remark = ""
+
+	openIdList, e := models.GetWxOpenIdByMobileSliceList(mobiles)
+	if e != nil {
+		err = errors.New("GetWxOpenIdByMobileList, Err: " + e.Error())
+		return
+	}
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	if utils.RunMode != "release" {
+		redirectUrl = utils.WX_MSG_PATH_ACTIVITY_DETAIL + strconv.Itoa(activityDetail.ActivityId)
+	} else {
+		redirectUrl = utils.WX_MSG_PATH_ACTIVITY_SIGN + strconv.Itoa(activityDetail.ActivityId)
+	}
+
+	sendInfo := new(SendWxTemplate)
+	sendInfo.First = first
+	sendInfo.Keyword1 = keyword1
+	sendInfo.Keyword2 = keyword2
+	sendInfo.Keyword3 = keyword3
+	sendInfo.Keyword4 = keyword4
+	sendInfo.Remark = remark
+	sendInfo.TemplateId = utils.WxMsgTemplateIdActivitySign
+	sendInfo.RedirectUrl = redirectUrl
+	sendInfo.RedirectTarget = 3
+	sendInfo.Resource = strconv.Itoa(activityDetail.ActivityId)
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_COMMENT
+	sendInfo.OpenIdArr = openIdArr
+	err = PublicSendTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}

+ 20 - 0
services/admin.go

@@ -64,3 +64,23 @@ func GetBelongingRai(mobile string) (isBelong bool) {
 	}
 	return
 }
+
+// GetAdminCheckUserMobileMap  获取对应销售所能查看的用户手机号
+func GetAdminCheckUserMobileMap(user *models.WxUserItem) (mapItem map[string]string, err error) {
+	admin, e := models.GetSysAdminByMobile(user.Mobile)
+	if e != nil {
+		err = e
+		return
+	}
+	userList, e := models.GetSellerUserMobile(admin.AdminId)
+	if e != nil {
+		err = e
+		return
+	}
+	mapMobile := make(map[string]string)
+	for _, v := range userList {
+		mapMobile[v.Mobile] = v.Mobile
+	}
+	mapItem = mapMobile
+	return
+}

+ 47 - 10
services/article.go

@@ -675,15 +675,15 @@ func GetArticleListByApi(cont context.Context) (err error) {
 }
 
 //func init() {
-//allList, err := models.GetArticleAll()
+//	// allList, err := models.GetArticleAll()
+//	//
+//	// fmt.Println(err)
+//	//
+//	//	for _, v := range allList {
+//	//		HandleArticleListByApi(v.ArticleId)
+//	//	}
+//	HandleArticleListByApi(8785)
 //
-//fmt.Println(err)
-//
-//for _, v := range allList {
-//	HandleArticleListByApi(v.ArticleId)
-//}
-//HandleArticleListByApi(8220)
-
 //}
 
 // 处理同步过来的文章
@@ -758,8 +758,11 @@ func HandleArticleListByApi(artcleId int) (err error) {
 	var cover string
 	if articleResult.Series.Name == "图解市场" {
 		cover = GetArticleCoverByChartFirst(articleResult.Content.Body)
+	} else if articleResult.Series.Name == "行业深度" {
+		cover = articleResult.Cover
 	}
 	fmt.Println(cover)
+	//return
 	//状态等于 2 跟 4 的进行同步 IsActive 为false 软删除的也不同步
 	if exitMap[articleResult.SeriesId] > 0 && (articleResult.PublishStatus == 2 || articleResult.PublishStatus == 4) && articleResult.IsActive {
 		articleResult.PublishDate = time.Date(articleResult.PublishDate.Year(), articleResult.PublishDate.Month(), articleResult.PublishDate.Day(), articleResult.PublishDate.Hour(), articleResult.PublishDate.Minute(), articleResult.PublishDate.Second(), articleResult.PublishDate.Nanosecond(), time.Local)
@@ -2052,6 +2055,42 @@ func GetArticleStockMap() (mapResp map[string]int, err error) {
 	return
 }
 
+// GetAiQianYanArtilceList 获取AI前沿几篇文章
+func GetAiQianYanArtilceList(startSize, pageSize int) (items []*models.ReportArticle, total int, err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("获取AI前沿几篇文章失败"+err.Error(), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition += ` AND title LIKE '%AI前沿%' AND publish_status = 1  ORDER BY publish_date DESC   `
+	articleList, e := models.GetCygxCygxArticleList(condition, pars, startSize, pageSize)
+	if e != nil {
+		err = errors.New("GetCygxCygxArticleList, Err: " + e.Error())
+		return
+	}
+	total, e = models.GetCygxArticleCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxArticleCount, Err: " + e.Error())
+		return
+	}
+
+	for _, v := range articleList {
+		item := new(models.ReportArticle)
+		item.ArticleId = v.ArticleId
+		item.Title = v.Title
+		item.Abstract = v.Abstract
+		item.Annotation = v.Annotation
+		item.PublishDate = v.PublishDate
+		item.Resource = 1
+		item.CategoryId = strconv.Itoa(v.CategoryId)
+		item.Body = v.Body
+		items = append(items, item)
+	}
+	return
+}
+
 // 获取文章内部图表的第一张封面图
 func GetArticleCoverByChartFirst(body string) (cover string) {
 	var err error
@@ -2070,7 +2109,6 @@ func GetArticleCoverByChartFirst(body string) (cover string) {
 				chartUrl = v
 				break
 			}
-
 		}
 	}
 	if chartUrl != "" {
@@ -2098,6 +2136,5 @@ func GetArticleCoverByChartFirst(body string) (cover string) {
 		}
 		cover = resultDate.Data.Cover
 	}
-	fmt.Println(chartUrl)
 	return
 }

+ 85 - 0
services/article_history.go

@@ -1,9 +1,12 @@
 package services
 
 import (
+	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
+	"strconv"
+	"time"
 )
 
 func GetArticleHistoryByUser(articleIds []int, user *models.WxUserItem) (mapResp map[int]int) {
@@ -32,3 +35,85 @@ func GetArticleHistoryByUser(articleIds []int, user *models.WxUserItem) (mapResp
 	}
 	return
 }
+
+// 记录用户文章浏览记录
+func ArticleHistory(articleId int, user *models.WxUserItem) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("记录用户文章浏览记录,失败"+err.Error(), 2)
+		}
+	}()
+	recordRedis := new(ReportViewRecord)
+	recordRedis.UserId = user.UserId
+	recordRedis.ReportId = articleId
+	recordRedis.Mobile = user.Mobile
+	recordRedis.Email = user.Email
+	recordRedis.RealName = user.RealName
+	recordRedis.CompanyName = user.CompanyName
+	recordRedis.CreateTime = time.Now()
+	go PushViewRecordNewRedisData(recordRedis, user.CompanyId)
+	uid := user.UserId
+	key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
+	if !utils.Rc.IsExist(key) {
+		//新增浏览记录
+		//这个表貌似没怎么用了,暂时保留记录
+		record := new(models.CygxArticleViewRecord)
+		record.UserId = uid
+		record.ArticleId = articleId
+		record.CreateTime = time.Now()
+		record.Mobile = user.Mobile
+		record.Email = user.Email
+		record.CompanyId = user.CompanyId
+		record.CompanyName = user.CompanyName
+		_, e := models.AddCygxArticleViewRecord(record)
+		if e != nil {
+			err = errors.New("AddCygxArticleViewRecord, Err: " + e.Error())
+			return
+		}
+
+		e = models.ModifyReportLastViewTime(uid)
+		if e != nil {
+			err = errors.New("ModifyReportLastViewTime, Err: " + e.Error())
+			return
+		}
+		utils.Rc.Put(key, 1, 2*time.Second)
+	}
+	return
+}
+
+// 记录用户文章浏览记录带时长
+func ArticleHistoryStopTime(articleId, stopTime, outType int, user *models.WxUserItem) (err error) {
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("记录用户文章浏览记录带时长,失败"+err.Error(), 2)
+		}
+	}()
+	if stopTime < 3 {
+		return
+	}
+	uid := user.UserId
+
+	key := "CYGX_ARTICLE_PV" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid) + "_" + strconv.Itoa(user.CompanyId) + "_" + strconv.Itoa(outType)
+	if !utils.Rc.IsExist(key) {
+		record := new(models.CygxArticleHistoryRecordNewpv)
+		record.UserId = uid
+		record.ArticleId = articleId
+		record.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
+		record.ModifyTime = time.Now()
+		record.Mobile = user.Mobile
+		record.Email = user.Email
+		record.CompanyId = user.CompanyId
+		record.CompanyName = user.CompanyName
+		record.StopTime = stopTime
+		record.OutType = outType
+		record.Source = "WEB"
+		_, e := models.AddCygxArticleViewRecordNewpv(record)
+		if e != nil {
+			err = errors.New("AddCygxArticleViewRecordNewpv, Err: " + e.Error())
+			return
+		}
+		utils.Rc.Put(key, 1, 2*time.Second)
+	}
+	go ArticleHistoryUserLabelLogAdd(articleId, uid)
+	return
+}

+ 7 - 1
services/company_permission.go

@@ -149,6 +149,7 @@ func GetUserHasPermissionActivity(user *models.WxUserItem, activityInfo *models.
 		err = errors.New("GetApplyRecordCount, Err: " + e.Error())
 		return
 	}
+
 	if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
 		popupMsg = "暂无<b>买方研选</b>权限<br/>您可申请开通试用"
 	} else {
@@ -202,7 +203,12 @@ func GetUserHasPermissionActivity(user *models.WxUserItem, activityInfo *models.
 			return
 		}
 		if strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
-			popupMsg = "暂无<b>买方研选</b>权限<br/>点击提交申请,提醒对口销售为你开通试用"
+			//popupMsg = "暂无<b>买方研选</b>权限<br/>点击提交申请,提醒对口销售为你开通试用"
+			if !strings.Contains(companyPermission, utils.CHART_PERMISSION_NAME_YANXUAN) && (activityInfo.ActivityTypeId == 3 || activityInfo.ActivityTypeId == 5) {
+				popupMsg = "暂无<b>买方研选</b>权限<br/>点击提交申请,提醒对口销售为你开通试用"
+			} else {
+				popupMsg = "签约买方研选套餐才可参与此活动,请联系对口销售"
+			}
 		} else {
 			if companyPermission == "专家" {
 				popupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile

+ 5 - 0
services/industrial_management.go

@@ -299,6 +299,11 @@ func IndustryFllowWithTrack(industrialManagementId, count, uid int) (err error)
 	return err
 }
 
+func init() {
+	//IndustryFllowUserLabel(136, 16, 5660)
+	//UserLabelLogReduce()
+}
+
 // GetIndustryNewLabelMap 获取产业【新】标签Map
 func GetIndustryNewLabelMap(industryIds []int) (labelMap map[int]bool, err error) {
 	labelMap = make(map[int]bool, 0)

+ 1 - 1
services/init_10.3.go

@@ -7,7 +7,7 @@ import (
 
 //10.3版本上线需要更新的数据
 
-func init1111() {
+func init51111() {
 	var condition string
 	var pars []interface{}
 	var err error

+ 457 - 0
services/init_10.5.1.go

@@ -0,0 +1,457 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"time"
+)
+
+//10.5.1版本上线需要更新的数据
+
+func init1111() {
+	var condition string
+	var pars []interface{}
+	var err error
+	fmt.Print()
+
+	var topCond string
+	var topPars []interface{}
+	toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+	if err != nil {
+		return
+	}
+
+	mapIndustryName := make(map[int]string)
+	for _, v := range toplist {
+		mapIndustryName[v.IndustrialManagementId] = v.IndustryName
+	}
+	fmt.Println(mapIndustryName)
+	//处理上周纪要汇总
+	condition = ` AND  type = 1  `
+	list, err := models.GetCygxIndustryFllowListByCon(condition, pars, 0, 100000)
+	if err != nil {
+		fmt.Println(err)
+	}
+	var items []*models.CygxUserLabel
+	for _, user := range list {
+		item := new(models.CygxUserLabel)
+		item.UserId = user.UserId
+		item.CompanyId = user.CompanyId
+		item.RealName = user.RealName
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.Label = mapIndustryName[user.IndustrialManagementId]
+		item.SourceId = user.IndustrialManagementId
+		item.Source = 1
+		item.IsFollow = 1
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		items = append(items, item)
+		if len(items)%5000 == 0 {
+			err = models.CygxUserLabelMulti(items)
+			fmt.Println(err)
+			items = make([]*models.CygxUserLabel, 0)
+		}
+	}
+	if len(items) > 0 {
+		err = models.CygxUserLabelMulti(items)
+		fmt.Println(err, "555")
+	}
+}
+
+func init123() {
+	var condition string
+	var pars []interface{}
+	var err error
+	fmt.Print()
+
+	var topCond string
+	var topPars []interface{}
+	toplist, err := models.GetCygxReportMappingCygxByCon(topCond, topPars, 0, 0)
+	if err != nil {
+		return
+	}
+
+	mapIndustryName := make(map[int]string)
+	for _, v := range toplist {
+		mapIndustryName[v.Id] = v.MatchTypeName
+	}
+	fmt.Println(mapIndustryName)
+
+	condition = ` `
+	list, err := models.GetCygxXzsChooseCategoryListByCon(condition, pars, 0, 100000)
+	if err != nil {
+		fmt.Println(err)
+	}
+	var items []*models.CygxUserLabel
+	for _, user := range list {
+		if user.IdCygx == 0 {
+			continue
+		}
+		item := new(models.CygxUserLabel)
+		item.UserId = user.UserId
+		item.CompanyId = user.CompanyId
+		item.RealName = user.RealName
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.Label = mapIndustryName[user.IdCygx]
+		item.SourceId = user.IdCygx
+		item.Source = 2
+		item.IsFollow = 1
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		fmt.Println(item.SourceId)
+		items = append(items, item)
+		if len(items)%5000 == 0 {
+			err = models.CygxUserLabelMulti(items)
+			fmt.Println(err)
+			items = make([]*models.CygxUserLabel, 0)
+		}
+	}
+	if len(items) > 0 {
+		err = models.CygxUserLabelMulti(items)
+		fmt.Println(err, "555")
+	}
+}
+
+func init5333() {
+	var condition string
+	var pars []interface{}
+	var err error
+	fmt.Print()
+
+	var topCond string
+	var topPars []interface{}
+	toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+	if err != nil {
+		return
+	}
+
+	mapIndustryName := make(map[int]string)
+	for _, v := range toplist {
+		mapIndustryName[v.IndustrialManagementId] = v.IndustryName
+	}
+	fmt.Println(mapIndustryName)
+	condition = ` AND activity_time > '2022-11-25 00:00:00' AND publish_status = 1    `
+	listAct, err := models.GetCygxActivityList(condition, pars, 0, 100000)
+	if err != nil {
+		fmt.Println(err)
+	}
+	var items []*models.CygxUserLabelActivity
+	for _, v := range listAct {
+		fmt.Println(v.ActivityTime)
+		var condition1 string
+		var pars1 []interface{}
+		condition1 = ` AND activity_id = ?  `
+		pars1 = append(pars1, v.ActivityId)
+		total, e := models.GetCygxIndustrialActivityGroupManagementCount(condition1+"  AND  source = 1 ", pars1)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+		if total == 0 {
+			continue
+		}
+		industrialList, e := models.GetCygxIndustrialActivityGroupManagementList(condition1+"  AND  source = 1 ", pars1)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+
+		pars = make([]interface{}, 0)
+		condition = ` AND activity_id  = ? AND is_meeting = 1  `
+		pars = append(pars, v.ActivityId)
+		signUpList, err := models.GetSignupDetailBySignup(condition, pars)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			return
+		}
+		for _, vi := range industrialList {
+			for _, user := range signUpList {
+				item := new(models.CygxUserLabelActivity)
+				item.UserId = user.UserId
+				item.CompanyId = user.CompanyId
+				item.RealName = user.RealName
+				item.Mobile = user.Mobile
+				item.Email = user.Email
+				item.ActivityId = v.ActivityId
+				item.IndustrialManagementId = vi.IndustrialManagementId
+				item.Label = mapIndustryName[vi.IndustrialManagementId]
+				item.CreateTime = utils.StrTimeToTime(v.ActivityTime)
+				item.ModifyTime = time.Now()
+				items = append(items, item)
+				if len(items)%5000 == 0 {
+					_, err = models.AddCygxUserLabelActivityList(items)
+					fmt.Println(err)
+					items = make([]*models.CygxUserLabelActivity, 0)
+				}
+			}
+		}
+	}
+	fmt.Println(len(items))
+	if len(items) > 0 {
+		_, err = models.AddCygxUserLabelActivityList(items)
+		fmt.Println(err, "555")
+	}
+}
+
+func init5444() {
+	var condition string
+	var pars []interface{}
+	var err error
+	fmt.Print()
+
+	var topCond string
+	var topPars []interface{}
+	toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+	if err != nil {
+		return
+	}
+
+	mapIndustryName := make(map[int]string)
+	for _, v := range toplist {
+		mapIndustryName[v.IndustrialManagementId] = v.IndustryName
+	}
+	fmt.Println(mapIndustryName)
+	condition = ` AND is_meeting = 1  `
+	listAct, err := models.GetCygxActivitySpecialmeetingDetailList(condition, pars)
+	if err != nil {
+		fmt.Println(err)
+	}
+	var items []*models.CygxUserLabelActivitySpecial
+	for _, user := range listAct {
+		var condition1 string
+		var pars1 []interface{}
+		condition1 = ` AND activity_id = ?  `
+		pars1 = append(pars1, user.ActivityId)
+		total, e := models.GetCygxIndustrialActivityGroupManagementCount(condition1+"  AND  source = 2 ", pars1)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+		if total == 0 {
+			continue
+		}
+		industrialList, e := models.GetCygxIndustrialActivityGroupManagementList(condition1+"  AND  source = 2 ", pars1)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+		for _, vi := range industrialList {
+			item := new(models.CygxUserLabelActivitySpecial)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.ActivityId = user.ActivityId
+			item.IndustrialManagementId = vi.IndustrialManagementId
+			item.Label = mapIndustryName[vi.IndustrialManagementId]
+			item.CreateTime = utils.StrTimeToTime(user.CreateTime)
+			item.ModifyTime = time.Now()
+			items = append(items, item)
+			if len(items)%5000 == 0 {
+				_, err = models.AddCygxUserLabelActivitySpecialList(items)
+				fmt.Println(err)
+				items = make([]*models.CygxUserLabelActivitySpecial, 0)
+			}
+		}
+	}
+	fmt.Println(len(items))
+	if len(items) > 0 {
+		_, err = models.AddCygxUserLabelActivitySpecialList(items)
+		fmt.Println(err, "555")
+	}
+}
+
+func init5555() {
+	var condition string
+	var pars []interface{}
+	var err error
+	fmt.Print()
+
+	var topCond string
+	var topPars []interface{}
+	toplist, err := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+	if err != nil {
+		return
+	}
+
+	mapIndustryName := make(map[int]string)
+	for _, v := range toplist {
+		mapIndustryName[v.IndustrialManagementId] = v.IndustryName
+	}
+	//fmt.Println(mapIndustryName)
+	condition = ` AND   stop_time > 3  AND create_time > '2022-11-25 00:00:00' GROUP BY article_id  `
+	//condition = `   AND   stop_time > 4   AND create_time > '2023-04-25 00:00:00' GROUP BY article_id  `
+	listArtGroup, err := models.GetCygxArticleHistoryRecordNewpvList(condition, pars)
+	if err != nil {
+		fmt.Println(err)
+	}
+	fmt.Println(len(listArtGroup))
+	var source int
+
+	itemsMap := make(map[int][]*models.CygxUserLabel)
+	for _, v := range listArtGroup {
+
+		fmt.Println(v.ArticleId)
+		var items []*models.CygxUserLabel
+		articleId := v.ArticleId
+		var condition string
+		var pars []interface{}
+		condition = ` AND article_id = ? `
+		pars = append(pars, v.ArticleId)
+		industrialList, e := models.GetIndustrialArticleGroupManagementList(condition, pars)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			fmt.Println(e)
+			continue
+			//return
+		}
+		if len(industrialList) == 0 {
+			//如果没有行产业归类就按照行业报告处理
+			source = 2
+			detailArticle, e := models.GetArticleDetailById(articleId)
+			if e != nil {
+				fmt.Println(e)
+				continue
+				//return
+			}
+
+			labelDetail, e := models.GetdetailByCategoryIdLabel(detailArticle.CategoryId)
+			if e != nil {
+				fmt.Println(e)
+				continue
+				//return
+			}
+			label := labelDetail.MatchTypeName
+			industrialManagementId := labelDetail.Id
+			item := new(models.CygxUserLabel)
+
+			item.Label = label
+			item.SourceId = industrialManagementId
+			item.Source = source
+			item.Weight = 1
+			item.CreateTime = time.Now()
+			item.ModifyTime = time.Now()
+			items = append(items, item)
+		} else {
+			//如果有行产业归类就按照产业报告处理
+			var topCond string
+			var topPars []interface{}
+			var industrialManagementIds []int
+
+			for _, v := range industrialList {
+				industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
+			}
+			idsLen := len(industrialManagementIds)
+			if idsLen > 0 {
+				topCond = ` AND industrial_management_id IN (` + utils.GetOrmInReplace(idsLen) + `)`
+				topPars = append(topPars, industrialManagementIds)
+			} else {
+				continue
+			}
+			industrNamelist, e := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+			if e != nil {
+				fmt.Println(e)
+				continue
+			}
+			source = 1
+			for _, v := range industrNamelist {
+				label := v.IndustryName
+				industrialManagementId := v.IndustrialManagementId
+
+				item := new(models.CygxUserLabel)
+				item.Label = label
+				item.SourceId = industrialManagementId
+				item.Source = source
+				item.Weight = 1
+				item.CreateTime = time.Now()
+				item.ModifyTime = time.Now()
+				items = append(items, item)
+
+			}
+
+			//for _, vi := range industrialList {
+			//	for _, user := range signUpList {
+			//		item := new(models.CygxUserLabelActivity)
+			//		item.UserId = user.UserId
+			//		item.CompanyId = user.CompanyId
+			//		item.RealName = user.RealName
+			//		item.Mobile = user.Mobile
+			//		item.Email = user.Email
+			//		item.ActivityId = v.ActivityId
+			//		item.IndustrialManagementId = vi.IndustrialManagementId
+			//		item.Label = mapIndustryName[vi.IndustrialManagementId]
+			//		item.CreateTime = utils.StrTimeToTime(v.ActivityTime)
+			//		item.ModifyTime = time.Now()
+			//		items = append(items, item)
+			//		if len(items)%50 == 0 {
+			//			_, err = models.AddCygxUserLabelActivityList(items)
+			//			fmt.Println(err)
+			//			items = make([]*models.CygxUserLabelActivity, 0)
+			//		}
+			//	}
+			//}
+			itemsMap[articleId] = items
+		}
+	}
+	condition = `   AND   stop_time > 3   AND create_time > '2022-11-25 00:00:00'   `
+	//condition = `  AND   stop_time > 4    AND create_time > '2023-4-25 00:00:00'   `
+	listArt, err := models.GetCygxArticleHistoryRecordNewpvList(condition, pars)
+	if err != nil {
+		fmt.Println(err)
+	}
+	var items []*models.CygxUserLabelArticle
+
+	fmt.Println(len(listArt))
+
+	for _, user := range listArt {
+		if len(itemsMap[user.ArticleId]) > 0 {
+			for k2, vlsit := range itemsMap {
+				if k2 != user.ArticleId {
+					continue
+				}
+				for _, vm := range vlsit {
+
+					//if user.ArticleId == 8365 {
+					//	fmt.Println("k", k, "_k2:", k2, "_k3:", k3)
+					//	fmt.Println(vm.Label)
+					//}
+					item := new(models.CygxUserLabelArticle)
+					item.UserId = user.UserId
+					item.ArticleId = user.ArticleId
+					item.CompanyId = user.CompanyId
+					//item.RealName = user.R
+					item.Mobile = user.Mobile
+					item.Email = user.Email
+					item.Label = vm.Label
+					item.SourceId = vm.SourceId
+					item.Source = vm.Source
+					item.CreateTime = user.CreateTime
+					item.ModifyTime = time.Now()
+					items = append(items, item)
+					if len(items)%5000 == 0 {
+						_, err = models.AddCygxUserLabelArticleList(items)
+						fmt.Println(err)
+						items = make([]*models.CygxUserLabelArticle, 0)
+					}
+				}
+			}
+		}
+	}
+	//for k, vlsit := range itemsMap[8365] {
+	//	fmt.Println(k)
+	//	fmt.Println(vlsit)
+	//	//for _, vm := range vlsit {
+	//	//	fmt.Println(vm)
+	//	//}
+	//}
+	fmt.Println(len(items))
+	fmt.Println(len(itemsMap))
+	fmt.Println((itemsMap))
+	fmt.Println(len(items))
+	if len(items) > 0 {
+		_, err = models.AddCygxUserLabelArticleList(items)
+		fmt.Println(err, "555")
+	}
+}

+ 13 - 4
services/task.go

@@ -29,8 +29,8 @@ func Task() {
 		sendEmailUserWhiteListChange := task.NewTask("sendEmailUserWhiteListChange", "0 00 17 * * *", SendEmailUserWhiteListChange) //新增 和冻结的客户白名单
 		task.AddTask("白名单发送", sendEmailUserWhiteListChange)
 
-		dotongbuShangHaiSendEmail := task.NewTask("dotongbuShangHaiSendEmail", "0 00 4 * * *", DotongbuShangHaiSendEmail) //发送上海策略品台同步结果名单的邮件附件
-		task.AddTask("发送上海策略品台同步结果名单的邮件附件", dotongbuShangHaiSendEmail)
+		//dotongbuShangHaiSendEmail := task.NewTask("dotongbuShangHaiSendEmail", "0 00 4 * * *", DotongbuShangHaiSendEmail) //发送上海策略品台同步结果名单的邮件附件
+		//task.AddTask("发送上海策略品台同步结果名单的邮件附件", dotongbuShangHaiSendEmail)
 
 		getChartListByApi := task.NewTask("getChartListByApi", "0 */10 * * * *", GetChartDetailByChartId) //同步图表
 		task.AddTask("getChartListByApi", getChartListByApi)
@@ -65,8 +65,15 @@ func Task() {
 		//更改对应产业的文章阅读数量
 		chageIndustrialArticleNum := task.NewTask("chageIndustrialArticleNum", "0 01 00 * * *", ChageIndustrialArticleNum) //更改对应产业的文章阅读数量
 		task.AddTask("chageIndustrialArticleNum", chageIndustrialArticleNum)
-		activityAttendanceDetail := task.NewTask("activityAttendanceDetail", "0 00 3 * * *", ActivityAttendanceDetail) //同步进门财经的路演信息
-		task.AddTask("sendEmailUserWhiteListChange", activityAttendanceDetail)
+
+		//activityAttendanceDetail := task.NewTask("activityAttendanceDetail", "0 00 3 * * *", ActivityAttendanceDetail) //同步进门财经的路演信息
+		//task.AddTask("activityAttendanceDetail", activityAttendanceDetail)
+
+		groupingActivityToJmcj := task.NewTask("groupingActivityToJmcj", "0 00 1 * * *", GroupingActivityToJmcj) //建立进门财经与弘则活动的匹配关系
+		task.AddTask("groupingActivityToJmcj", groupingActivityToJmcj)
+
+		getActivityMeetingByJmcj := task.NewTask("getActivityMeetingByJmcj", "0 00 3 * * *", GetActivityMeetingByJmcj) //同步进门财经的路演信息
+		task.AddTask("getActivityMeetingByJmcj", getActivityMeetingByJmcj)
 
 		sendEmailFileForAskMsgResearch := task.NewTask("sendEmailFileForAskMsgResearch", "0 */5 6-23 * * *", SendEmailFileForAskMsgResearch) //研选系列专家电话会,会前1小时将问题列表发送给邮箱
 		task.AddTask("sendEmailFileForAskMsgResearch", sendEmailFileForAskMsgResearch)
@@ -118,6 +125,8 @@ func Task() {
 		getArticleListByApi := task.NewTask("getArticleListByApi", "0 */60 * * * *", GetArticleListByApi) //通过三方接口获取策略平台上的文章
 		task.AddTask("getArticleListByApi", getArticleListByApi)
 	}
+
+	go UserLabelLogReduce() // 处理用户标签的队列消息
 	//GetCygxActivityAttendanceDetail()
 	//CreateIndexNameArticleHistory()
 	//AddAllArticleHistory()

+ 998 - 0
services/user_label.go

@@ -0,0 +1,998 @@
+package services
+
+import (
+	"encoding/json"
+	"errors"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+func init() {
+
+	//ArticleHistoryUserLabelLogAdd(8350, 53095)
+	//UserLabelLogReduce()
+	//var mobileArr []string
+	//mobileArr = append(mobileArr, "15557270714")
+	//ActivityUserLabelLogAdd(2239, mobileArr)
+
+	//UserLabelLogReduce()
+}
+
+// 添加用户阅读标签到Redis
+func ArticleHistoryUserLabelLogAdd(articleId, uid int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			msg := fmt.Sprint("articleId:", articleId, "userId:", uid)
+			go utils.SendAlarmMsg("用户关注产业更新相关标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
+		}
+	}()
+	// SourceType 1:文章阅读、 2产业关注、3:活动到会、4系列关注、5专项调研活动到会。
+	log := &models.CygxUserLabelLogRedis{UserId: uid, SourceId: articleId, SourceType: 1, CreateTime: time.Now()}
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.CYGX_USER_KEY_LABEL, log)
+		if err != nil {
+			fmt.Println("CygxUserLabelLogRedis LPush Err:" + err.Error())
+		}
+	}
+	return
+}
+
+// 添加用户2产业关注标签到Redis
+func IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid int) (err error) {
+	var isFllow int
+	if count == 0 {
+		isFllow = 1
+	} else {
+		isFllow = 0
+	}
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			msg := fmt.Sprint("industrialManagementId:", industrialManagementId, "isFllow:", isFllow, "userId:", uid)
+			go utils.SendAlarmMsg("用户关注产业更新相关标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
+		}
+	}()
+	log := &models.CygxUserLabelLogRedis{UserId: uid, SourceId: industrialManagementId, SourceType: 2, IsFllow: isFllow, CreateTime: time.Now()}
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.CYGX_USER_KEY_LABEL, log)
+		if err != nil {
+			fmt.Println("RecordNewLogs LPush Err:" + err.Error())
+		}
+	}
+	return
+}
+
+// 添加用户活动到会标签到Redis
+func ActivityUserLabelLogAdd(activityId int, mobileArr []string) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			msg := fmt.Sprint("activityId:", activityId, "mobile:", mobileArr)
+			go utils.SendAlarmMsg("添加用户活动到会标签到Redis,写入Redis队列消息失败:"+err.Error()+msg, 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition = ` AND activity_id = ?  `
+	pars = append(pars, activityId)
+	total, e := models.GetCygxIndustrialActivityGroupManagementCount(condition+"  AND  source = 1 ", pars)
+	if e != nil {
+		err = errors.New("GetCygxIndustrialActivityGroupManagementCount" + e.Error())
+		return
+	}
+	if total == 0 {
+		//没有关联产业的活动不做标签处理
+		return
+	}
+
+	industrialList, e := models.GetCygxIndustrialActivityGroupManagementList(condition+"  AND  source = 1 ", pars)
+	if e != nil {
+		err = errors.New("GetCygxIndustrialActivityGroupManagementList, Err: " + e.Error())
+		return
+	}
+
+	//如果有行产业归类就按照产业报告处理
+	var topCond string
+	var topPars []interface{}
+	var industrialManagementIds []int
+
+	for _, v := range industrialList {
+		industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
+	}
+	idsLen := len(industrialManagementIds)
+	if idsLen > 0 {
+		topCond = ` AND industrial_management_id IN (` + utils.GetOrmInReplace(idsLen) + `)`
+		topPars = append(topPars, industrialManagementIds)
+	} else {
+		return
+	}
+	industrNamelist, e := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+	if e != nil {
+		err = errors.New("GetTopOneMonthArtReadNumIndustryAll, Err: " + e.Error())
+		return
+	}
+
+	userList, e := models.GetWxUserByOutboundMobiles(mobileArr)
+	if e != nil {
+		err = errors.New("GetWxUserByOutboundMobiles" + e.Error())
+		return
+	}
+	listActivityHistory, e := models.GetCygxUserLabelActivity(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxUserLabelActivity" + e.Error())
+		return
+	}
+	activityHistoryMap := make(map[int]bool)
+	for _, v := range listActivityHistory {
+		activityHistoryMap[v.UserId] = true
+	}
+	var items []*models.CygxUserLabelActivity
+	for _, user := range userList {
+		//已经提交到会的活动写入标签的不做二次添加处理
+		if activityHistoryMap[user.UserId] {
+			continue
+		}
+		// SourceType 1:文章阅读、 2产业关注、3:活动到会、4系列关注、5专项调研活动到会。
+		log := &models.CygxUserLabelLogRedis{UserId: user.UserId, SourceId: activityId, SourceType: 3, CreateTime: time.Now()}
+		if utils.Re == nil {
+			err := utils.Rc.LPush(utils.CYGX_USER_KEY_LABEL, log)
+			if err != nil {
+				fmt.Println("CygxUserLabelLogRedis LPush Err:" + err.Error())
+			}
+		}
+		for _, industr := range industrNamelist {
+			item := new(models.CygxUserLabelActivity)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.ActivityId = activityId
+			item.IndustrialManagementId = industr.IndustrialManagementId
+			item.Label = industr.IndustryName
+			item.CreateTime = time.Now()
+			item.ModifyTime = time.Now()
+			items = append(items, item)
+		}
+	}
+	if len(items) > 0 {
+		_, err = models.AddCygxUserLabelActivityList(items)
+	}
+	return
+}
+
+func UserLabelLogReduce() (err error) {
+	for {
+		//SourceType int       `description:"1:文章阅读、 2产业关注、3:活动到会、4系列关注、5专项调研活动到会。"`
+		utils.Rc.Brpop(utils.CYGX_USER_KEY_LABEL, func(b []byte) {
+			var log models.CygxUserLabelLogRedis
+			if err := json.Unmarshal(b, &log); err != nil {
+				fmt.Println("json unmarshal wrong!")
+				go utils.SendAlarmMsg("用户更新相关标签处理Redis队列消息失败:"+err.Error()+string(b), 2)
+			}
+			switch log.SourceType {
+			case 1:
+				go ArticleHistoryUserLabelLogReduce(log)
+				fmt.Println("文章阅读")
+				break
+			case 2:
+				go IndustryFllowUserLabelLogReduce(log)
+				fmt.Println("2产业关注")
+				break
+			case 3:
+				go ActivityUserLabelLogReduce(log)
+				fmt.Println("活动到会")
+				break
+			case 4:
+				go CategoryFllowUserLabelLogReduce(log)
+				fmt.Println("4系列关注")
+				break
+			case 5:
+				go ActivitySpecialUserLabelLogReduce(log)
+				fmt.Println("5专项调研活动到会")
+				break
+			default:
+				fmt.Println(string(b))
+				go utils.SendAlarmMsg("用户更新相关标签处理Redis队列消息失败:"+string(b), 2)
+			}
+		})
+	}
+}
+
+// 1:文章阅读
+func ArticleHistoryUserLabelLogReduce(log models.CygxUserLabelLogRedis) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("用户文章阅读更新相关标签,处理Redis队列消息失败:"+err.Error(), 2)
+		}
+	}()
+
+	articleId := log.SourceId
+	userId := log.UserId
+	var source int
+	user, e := models.GetWxUserItemByUserId(userId)
+	if e != nil {
+		err = errors.New("GetWxUserItemByUserId" + e.Error())
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND article_id = ? `
+	pars = append(pars, articleId)
+	industrialList, e := models.GetIndustrialArticleGroupManagementList(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error())
+		return
+	}
+	var items []*models.CygxUserLabel
+	if len(industrialList) == 0 {
+		//如果没有行产业归类就按照行业报告处理
+		source = 2
+		detailArticle, e := models.GetArticleDetailById(articleId)
+		if e != nil {
+			err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error())
+			return
+		}
+
+		labelDetail, e := models.GetdetailByCategoryIdLabel(detailArticle.CategoryId)
+		if e != nil {
+			err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error())
+			return
+		}
+		label := labelDetail.MatchTypeName
+		industrialManagementId := labelDetail.Id
+		var condition string
+		var pars []interface{}
+		condition += ` AND source_id=? AND source = ?  AND  user_id = ?  `
+		pars = append(pars, industrialManagementId, source, userId)
+		total, e := models.GetCygxUserLabelCount(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxProductInteriorCount" + e.Error())
+			return
+		}
+		item := new(models.CygxUserLabel)
+		item.UserId = user.UserId
+		item.CompanyId = user.CompanyId
+		item.RealName = user.RealName
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.Label = label
+		item.SourceId = industrialManagementId
+		item.Source = source
+		item.Weight = 1
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		items = append(items, item)
+		if total == 0 {
+			_, e = models.AddCygxUserLabel(item)
+			if e != nil {
+				err = errors.New("AddCygxUserLabel" + e.Error())
+				return
+			}
+		} else {
+			//source 来源1:产业、2:系列
+			e = models.UpdateCygxUserLabelWeight(industrialManagementId, source, userId, label)
+			if e != nil {
+				err = errors.New("UpdateCygxUserLabelWeight" + e.Error())
+				return
+			}
+		}
+	} else {
+		//如果有行产业归类就按照产业报告处理
+		var topCond string
+		var topPars []interface{}
+		var industrialManagementIds []int
+
+		for _, v := range industrialList {
+			industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
+		}
+		idsLen := len(industrialManagementIds)
+		if idsLen > 0 {
+			topCond = ` AND industrial_management_id IN (` + utils.GetOrmInReplace(idsLen) + `)`
+			topPars = append(topPars, industrialManagementIds)
+		} else {
+			return
+		}
+		industrNamelist, e := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+		if e != nil {
+			err = errors.New("GetTopOneMonthArtReadNumIndustryAll, Err: " + e.Error())
+			return
+		}
+		source = 1
+		for _, v := range industrNamelist {
+			label := v.IndustryName
+			industrialManagementId := v.IndustrialManagementId
+			var condition string
+			var pars []interface{}
+			condition += ` AND source_id=? AND source = ?  AND  user_id = ?  `
+			pars = append(pars, v.IndustrialManagementId, source, userId)
+			total, e := models.GetCygxUserLabelCount(condition, pars)
+			if e != nil {
+				err = errors.New("GetCygxProductInteriorCount" + e.Error())
+				return
+			}
+			item := new(models.CygxUserLabel)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.Label = label
+			item.SourceId = industrialManagementId
+			item.Source = source
+			item.Weight = 1
+			item.CreateTime = time.Now()
+			item.ModifyTime = time.Now()
+			items = append(items, item)
+			if total == 0 {
+				_, e = models.AddCygxUserLabel(item)
+				if e != nil {
+					err = errors.New("AddCygxUserLabel" + e.Error())
+					return
+				}
+			} else {
+				//source 来源1:产业、2:系列
+				e = models.UpdateCygxUserLabelWeight(industrialManagementId, source, userId, label)
+				if e != nil {
+					err = errors.New("UpdateCygxUserLabelWeight" + e.Error())
+					return
+				}
+			}
+		}
+	}
+	if len(items) > 0 {
+		go AddArticleHistoryUserLabelLog(items, articleId)
+	}
+	updateUserLabelByUserId(userId)
+	return
+}
+
+// 添加文章阅读记录日志,处理文章阅读三个月之内标签权重有效逻辑
+func AddArticleHistoryUserLabelLog(items []*models.CygxUserLabel, articleId int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("添加文章阅读记录日志,处理文章阅读三个月之内标签权重有效逻辑失败:"+err.Error(), 2)
+		}
+	}()
+	if len(items) == 0 {
+		return
+	}
+	for _, v := range items {
+		item := new(models.CygxUserLabelArticle)
+		item.UserId = v.UserId
+		item.CompanyId = v.CompanyId
+		item.RealName = v.RealName
+		item.Mobile = v.Mobile
+		item.Email = v.Email
+		item.Label = v.Label
+		item.SourceId = v.SourceId
+		item.Source = v.Source
+		item.ArticleId = articleId
+		item.CreateTime = time.Now()
+		item.ModifyTime = time.Now()
+		_, e := models.AddCygxUserLabelArticle(item)
+		if e != nil {
+			err = errors.New("AddCygxUserLabelArticle" + e.Error())
+			return
+		}
+	}
+	return
+}
+
+// 2:产业关注
+func IndustryFllowUserLabelLogReduce(log models.CygxUserLabelLogRedis) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("用户关注产业更新相关标签,处理Redis队列消息失败:"+err.Error(), 2)
+		}
+	}()
+	isFllow := log.IsFllow
+	industrialManagementId := log.SourceId
+	userId := log.UserId
+	source := 1
+	detailIndustrial, e := models.GetIndustrialManagementDetail(industrialManagementId)
+	if e != nil {
+		err = errors.New("GetIndustrialManagementDetail" + e.Error())
+		return
+	}
+	label := detailIndustrial.IndustryName
+	if isFllow == 0 {
+		e = models.UpdateCygxUserLabelIsFollow(isFllow, industrialManagementId, source, userId, label)
+		if e != nil {
+			err = errors.New("UpdateCygxUserLabelIsFollow" + e.Error())
+			return
+		}
+	} else {
+		var condition string
+		var pars []interface{}
+		condition += ` AND source_id=? AND source = ?   AND user_id = ?`
+		pars = append(pars, industrialManagementId, source, userId)
+		total, e := models.GetCygxUserLabelCount(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxProductInteriorCount" + e.Error())
+			return
+		}
+		if total == 0 {
+			user, e := models.GetWxUserItemByUserId(userId)
+			if e != nil {
+				err = errors.New("GetWxUserItemByUserId" + e.Error())
+				return
+			}
+			item := new(models.CygxUserLabel)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.Label = label
+			item.SourceId = industrialManagementId
+			item.Source = source
+			item.IsFollow = isFllow
+			item.CreateTime = time.Now()
+			item.ModifyTime = time.Now()
+			_, e = models.AddCygxUserLabel(item)
+			if e != nil {
+				err = errors.New("AddCygxUserLabel" + e.Error())
+				return
+			}
+		} else {
+			//source 来源1:产业、2:系列
+			e = models.UpdateCygxUserLabelIsFollow(isFllow, industrialManagementId, source, userId, label)
+			if e != nil {
+				err = errors.New("UpdateCygxUserLabelIsFollow" + e.Error())
+				return
+			}
+		}
+	}
+	updateUserLabelByUserId(userId)
+	return
+}
+
+// 3:活动到会
+func ActivityUserLabelLogReduce(log models.CygxUserLabelLogRedis) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("用户活动到会更新相关标签,处理Redis队列消息失败:"+err.Error(), 2)
+		}
+	}()
+
+	activityId := log.SourceId
+	userId := log.UserId
+	var source int
+	user, e := models.GetWxUserItemByUserId(userId)
+	if e != nil {
+		err = errors.New("GetWxUserItemByUserId" + e.Error())
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND activity_id = ?  `
+	pars = append(pars, activityId)
+	industrialList, e := models.GetCygxIndustrialActivityGroupManagementList(condition+"  AND  source = 1 ", pars)
+	if e != nil {
+		err = errors.New("GetCygxIndustrialActivityGroupManagementList, Err: " + e.Error())
+		return
+	}
+
+	//如果有行产业归类就按照产业报告处理
+	var topCond string
+	var topPars []interface{}
+	var industrialManagementIds []int
+
+	for _, v := range industrialList {
+		industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
+	}
+	idsLen := len(industrialManagementIds)
+	if idsLen > 0 {
+		topCond = ` AND industrial_management_id IN (` + utils.GetOrmInReplace(idsLen) + `)`
+		topPars = append(topPars, industrialManagementIds)
+	} else {
+		return
+	}
+	industrNamelist, e := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+	if e != nil {
+		err = errors.New("GetTopOneMonthArtReadNumIndustryAll, Err: " + e.Error())
+		return
+	}
+
+	source = 1
+	for _, v := range industrNamelist {
+		label := v.IndustryName
+		industrialManagementId := v.IndustrialManagementId
+		var condition string
+		var pars []interface{}
+		condition += ` AND source_id=? AND source = ?  AND  user_id = ?  `
+		pars = append(pars, v.IndustrialManagementId, source, userId)
+		total, e := models.GetCygxUserLabelCount(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxProductInteriorCount" + e.Error())
+			return
+		}
+		if total == 0 {
+			item := new(models.CygxUserLabel)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.Label = label
+			item.SourceId = industrialManagementId
+			item.Source = source
+			item.Weight = 1
+			item.CreateTime = time.Now()
+			item.ModifyTime = time.Now()
+			_, e = models.AddCygxUserLabel(item)
+			if e != nil {
+				err = errors.New("AddCygxUserLabel" + e.Error())
+				return
+			}
+		} else {
+			//source 来源1:产业、2:系列
+			e = models.UpdateCygxUserLabelWeight(industrialManagementId, source, userId, label)
+			if e != nil {
+				err = errors.New("UpdateCygxUserLabelWeight" + e.Error())
+				return
+			}
+		}
+	}
+	updateUserLabelByUserId(userId)
+	return
+}
+
+// 4:系列关注
+func CategoryFllowUserLabelLogReduce(log models.CygxUserLabelLogRedis) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("用户关注系列更新相关标签,处理Redis队列消息失败:"+err.Error(), 2)
+		}
+	}()
+	isFllow := log.IsFllow
+	industrialManagementId := log.SourceId
+	userId := log.UserId
+	source := 2
+	detailIndustrial, e := models.GetCygxReportMappingById(industrialManagementId)
+	if e != nil {
+		err = errors.New("GetCygxReportMappingById" + e.Error())
+		return
+	}
+	label := detailIndustrial.MatchTypeName
+	if isFllow == 0 {
+		e = models.UpdateCygxUserLabelIsFollow(isFllow, industrialManagementId, source, userId, label)
+		if e != nil {
+			err = errors.New("UpdateCygxUserLabelIsFollow" + e.Error())
+			return
+		}
+	} else {
+		var condition string
+		var pars []interface{}
+		condition += ` AND source_id=? AND source = ?   AND user_id = ?`
+		pars = append(pars, industrialManagementId, source, userId)
+		total, e := models.GetCygxUserLabelCount(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxProductInteriorCount" + e.Error())
+			return
+		}
+		if total == 0 {
+			user, e := models.GetWxUserItemByUserId(userId)
+			if e != nil {
+				err = errors.New("GetWxUserItemByUserId" + e.Error())
+				return
+			}
+			item := new(models.CygxUserLabel)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.Label = label
+			item.SourceId = industrialManagementId
+			item.Source = source
+			item.IsFollow = isFllow
+			item.CreateTime = time.Now()
+			item.ModifyTime = time.Now()
+			_, e = models.AddCygxUserLabel(item)
+			if e != nil {
+				err = errors.New("AddCygxUserLabel" + e.Error())
+				return
+			}
+		} else {
+			//source 来源1:产业、2:系列
+			e = models.UpdateCygxUserLabelIsFollow(isFllow, industrialManagementId, source, userId, label)
+			if e != nil {
+				err = errors.New("UpdateCygxUserLabelIsFollow" + e.Error())
+				return
+			}
+		}
+	}
+	updateUserLabelByUserId(userId)
+	return
+}
+
+// 5:专项调研活动到会
+func ActivitySpecialUserLabelLogReduce(log models.CygxUserLabelLogRedis) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("用户活动到会更新相关标签,处理Redis队列消息失败:"+err.Error(), 2)
+		}
+	}()
+
+	activityId := log.SourceId
+	userId := log.UserId
+	var source int
+	user, e := models.GetWxUserItemByUserId(userId)
+	if e != nil {
+		err = errors.New("GetWxUserItemByUserId" + e.Error())
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND activity_id = ?  `
+	pars = append(pars, activityId)
+	industrialList, e := models.GetCygxIndustrialActivityGroupManagementList(condition+"  AND  source = 2 ", pars)
+	if e != nil {
+		err = errors.New("GetCygxIndustrialActivityGroupManagementList, Err: " + e.Error())
+		return
+	}
+
+	//如果有行产业归类就按照产业报告处理
+	var topCond string
+	var topPars []interface{}
+	var industrialManagementIds []int
+
+	for _, v := range industrialList {
+		industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
+	}
+	idsLen := len(industrialManagementIds)
+	if idsLen > 0 {
+		topCond = ` AND industrial_management_id IN (` + utils.GetOrmInReplace(idsLen) + `)`
+		topPars = append(topPars, industrialManagementIds)
+	} else {
+		return
+	}
+	industrNamelist, e := models.GetTopOneMonthArtReadNumIndustryAll(topCond, topPars)
+	if e != nil {
+		err = errors.New("GetTopOneMonthArtReadNumIndustryAll, Err: " + e.Error())
+		return
+	}
+
+	source = 1
+	for _, v := range industrNamelist {
+		label := v.IndustryName
+		industrialManagementId := v.IndustrialManagementId
+		var condition string
+		var pars []interface{}
+		condition += ` AND source_id=? AND source = ?  AND  user_id = ?  `
+		pars = append(pars, v.IndustrialManagementId, source, userId)
+		total, e := models.GetCygxUserLabelCount(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxProductInteriorCount" + e.Error())
+			return
+		}
+		if total == 0 {
+			item := new(models.CygxUserLabel)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.Label = label
+			item.SourceId = industrialManagementId
+			item.Source = source
+			item.Weight = 1
+			item.CreateTime = time.Now()
+			item.ModifyTime = time.Now()
+			_, e = models.AddCygxUserLabel(item)
+			if e != nil {
+				err = errors.New("AddCygxUserLabel" + e.Error())
+				return
+			}
+		} else {
+			//source 来源1:产业、2:系列
+			e = models.UpdateCygxUserLabelWeight(industrialManagementId, source, userId, label)
+			if e != nil {
+				err = errors.New("UpdateCygxUserLabelWeight" + e.Error())
+				return
+			}
+		}
+	}
+	updateUserLabelByUserId(userId)
+	return
+}
+
+//func init() {
+//	var condition string
+//	var pars []interface{}
+//	pars = make([]interface{}, 0)
+//	condition = ` GROUP BY user_id`
+//	listUser, _ := models.GetCygxUserLabelList(condition, pars)
+//	for k, v := range listUser {
+//		fmt.Println(k)
+//		updateUserLabelByUserId(v.UserId)
+//	}
+//	//updateUserLabelByUserId(13269)
+//}
+
+// 更新用户标签
+func updateUserLabelByUserId(userId int) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			utils.FileLog.Info("更新用户标签,Err:%s", err.Error(), userId)
+			go utils.SendAlarmMsg("更新用户标签失败:"+err.Error()+"userId:"+strconv.Itoa(userId), 2)
+		}
+	}()
+	time.Sleep(1 * time.Second)
+	var condition string
+	var pars []interface{}
+	condition = ` AND is_follow=1  AND  user_id = ?  `
+	pars = append(pars, userId)
+	totalSource1, e := models.GetCygxUserLabelCount(condition+" AND source = 1 ", pars)
+	if e != nil {
+		err = errors.New("GetCygxProductInteriorCount" + e.Error())
+		return
+	}
+
+	totalSource2, e := models.GetCygxUserLabelCount(condition+" AND source = 2 ", pars)
+	if e != nil {
+		err = errors.New("GetCygxProductInteriorCount" + e.Error())
+		return
+	}
+	condition = `   AND  user_id = ?  `
+	var list []*models.CygxUserLabel
+	//当产业关注数量不超过10 ,系列关注数量不超过5
+	if totalSource1 <= 10 && totalSource2 <= 5 {
+		condition += `  	AND ( is_follow > 0 OR weight > 0 )  ORDER BY is_follow DESC, weight DESC  `
+		list, e = models.GetCygxUserLabelList(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxUserLabelList当产业关注数量不超过10 ,系列关注数量不超过5" + e.Error())
+			return
+		}
+	}
+
+	//当产业关注数量超过10 ,系列关注数量超过5
+	if totalSource1 > 10 && totalSource2 > 5 {
+		condition += `  AND  weight > 0 ORDER BY  weight DESC  `
+		list, e = models.GetCygxUserLabelList(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxUserLabelList 当产业关注数量超过10 ,系列关注数量超过5" + e.Error())
+			return
+		}
+	}
+	//当产业关注数量不超过10 ,系列关注数量超过5
+	if totalSource1 <= 10 && totalSource2 > 5 {
+		condition += `  AND  source = 1  AND is_follow = 1 ORDER BY  weight DESC  `
+		listfollow, e := models.GetCygxUserLabelList(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxUserLabelList" + e.Error())
+			return
+		}
+		idMap := make(map[int]bool)
+		for _, v := range listfollow {
+			idMap[v.Id] = true
+			list = append(list, v)
+		}
+		pars = make([]interface{}, 0)
+		condition = `  AND  user_id = ?  `
+		pars = append(pars, userId)
+		condition += ` 	AND  weight > 0   ORDER BY  weight DESC  `
+		listother, e := models.GetCygxUserLabelList(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxUserLabelList 当产业关注数量不超过10 ,系列关注数量超过5" + e.Error())
+			return
+		}
+		for _, v := range listother {
+			if idMap[v.Id] {
+				continue
+			}
+			list = append(list, v)
+		}
+	}
+
+	//当产业关注数量超过10 ,系列关注数量不超过5
+	if totalSource1 > 10 && totalSource2 <= 5 {
+		condition += `  AND  source = 2  AND is_follow = 1 ORDER BY  weight DESC  `
+		listfollow, e := models.GetCygxUserLabelList(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxUserLabelList 当产业关注数量超过10 ,系列关注数量不超过5" + e.Error())
+			return
+		}
+		idMap := make(map[int]bool)
+		for _, v := range listfollow {
+			idMap[v.Id] = true
+			list = append(list, v)
+		}
+		pars = make([]interface{}, 0)
+		condition = `  AND  user_id = ?  `
+		pars = append(pars, userId)
+		condition += ` 	AND  weight > 0   ORDER BY  weight DESC  `
+		listother, e := models.GetCygxUserLabelList(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxUserLabelList 当产业关注数量超过10 ,系列关注数量不超过5" + e.Error())
+			return
+		}
+		for _, v := range listother {
+			if idMap[v.Id] {
+				continue
+			}
+			list = append(list, v)
+		}
+	}
+
+	var labelUser string
+	for _, v := range list {
+		labelUser += v.Label + ","
+	}
+	labelUser = strings.TrimRight(labelUser, ",")
+	e = models.UpdateUserLabel(labelUser, userId)
+	if e != nil {
+		err = errors.New("UpdateUserLabel" + e.Error())
+		return err
+	}
+	return
+}
+
+//func init() {
+//	UpdateUserLabelWeight()
+//}
+
+// 更新用户标签权重
+func UpdateUserLabelWeight() (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("更新用户标签权重失败:"+err.Error(), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	list, e := models.GetCygxUserLabelList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxUserLabelList" + e.Error())
+		return
+	}
+	updateTime := time.Now().AddDate(0, -3, 0)
+	condition = ` AND create_time > ?`
+	pars = append(pars, updateTime)
+
+	listArticle, e := models.GetCygxUserLabelArticleList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxUserLabelArticleList" + e.Error())
+		return
+	}
+
+	listActivity, e := models.GetCygxUserLabelActivity(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxUserLabelActivity" + e.Error())
+		return
+	}
+
+	listActivitySpecial, e := models.GetCygxUserLabelActivitySpecial(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxUserLabelActivitySpecial" + e.Error())
+		return
+	}
+	userLabel := make(map[string]bool)
+	userLabelWeight := make(map[string]int)
+	for _, v := range list {
+		userLabel[fmt.Sprint("user_id{|}", v.UserId, "{|}source_id{|}", v.SourceId, "{|}source{|}", v.Source)] = true
+	}
+	fmt.Println(userLabel)
+	//处理文章标签
+	var items []*models.CygxUserLabel
+	for _, user := range listArticle {
+		if !userLabel[fmt.Sprint("user_id{|}", user.UserId, "{|}source_id{|}", user.SourceId, "{|}source{|}", user.Source)] {
+			item := new(models.CygxUserLabel)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.Label = user.Label
+			item.SourceId = user.SourceId
+			item.Source = user.Source
+			item.CreateTime = user.CreateTime
+			item.ModifyTime = time.Now()
+			items = append(items, item)
+			userLabel[fmt.Sprint("user_id{|}", user.UserId, "{|}source_id{|}", user.SourceId, "{|}source{|}", user.Source)] = true
+		}
+		userLabelWeight[fmt.Sprint("user_id{|}", user.UserId, "{|}label{|}", user.Label)]++
+	}
+
+	//处理活动标签
+	for _, user := range listActivity {
+		if !userLabel[fmt.Sprint("user_id{|}", user.UserId, "{|}source_id{|}", user.IndustrialManagementId, "{|}source{|}", 1)] {
+			item := new(models.CygxUserLabel)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.Label = user.Label
+			item.SourceId = user.IndustrialManagementId
+			item.Source = 1
+			item.CreateTime = user.CreateTime
+			item.ModifyTime = time.Now()
+			items = append(items, item)
+			userLabel[fmt.Sprint("user_id{|}", user.UserId, "{|}source_id{|}", user.IndustrialManagementId, "{|}source{|}", 1)] = true
+		}
+		userLabelWeight[fmt.Sprint("user_id{|}", user.UserId, "{|}label{|}", user.Label)]++
+	}
+
+	//处理专项调研活动标签
+	for _, user := range listActivitySpecial {
+		if !userLabel[fmt.Sprint("user_id{|}", user.UserId, "{|}source_id{|}", user.IndustrialManagementId, "{|}source{|}", 1)] {
+			item := new(models.CygxUserLabel)
+			item.UserId = user.UserId
+			item.CompanyId = user.CompanyId
+			item.RealName = user.RealName
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.Label = user.Label
+			item.SourceId = user.IndustrialManagementId
+			item.Source = 1
+			item.CreateTime = user.CreateTime
+			item.ModifyTime = time.Now()
+			items = append(items, item)
+			userLabel[fmt.Sprint("user_id{|}", user.UserId, "{|}source_id{|}", user.IndustrialManagementId, "{|}source{|}", 1)] = true
+		}
+		userLabelWeight[fmt.Sprint("user_id{|}", user.UserId, "{|}label{|}", user.Label)]++
+	}
+	var itemLimt []*models.CygxUserLabel
+	fmt.Println(len(items))
+	if len(items) > 0 {
+		for _, v := range items {
+			itemLimt = append(itemLimt, v)
+			if len(itemLimt)%5000 == 0 {
+				err = models.CygxUserLabelMulti(itemLimt)
+				fmt.Println(err)
+				itemLimt = make([]*models.CygxUserLabel, 0)
+			}
+		}
+	}
+	if len(itemLimt) > 0 {
+		err = models.CygxUserLabelMulti(itemLimt)
+		fmt.Println(err)
+	}
+	var itemsUpdate []*models.CygxUserLabel
+	for k, v := range userLabelWeight {
+		sliceUser := strings.Split(k, "{|}")
+		userid, _ := strconv.Atoi(sliceUser[1])
+		label := sliceUser[len(sliceUser)-1]
+		item := new(models.CygxUserLabel)
+		item.UserId = userid
+		item.Label = label
+		item.Weight = v
+		itemsUpdate = append(itemsUpdate, item)
+	}
+
+	e = models.UpdateCygxUserLabelWeightAll()
+	if e != nil {
+		err = errors.New("UpdateCygxUserLabelWeightAll" + e.Error())
+		return
+	}
+	fmt.Println(len(itemsUpdate))
+	e = models.UpdateCygxUserLabelMulti(itemsUpdate)
+	if e != nil {
+		err = errors.New("UpdateCygxUserLabelMulti" + e.Error())
+		return
+	}
+
+	pars = make([]interface{}, 0)
+	condition = ` GROUP BY user_id`
+	listUser, e := models.GetCygxUserLabelList(condition, pars)
+	for _, v := range listUser {
+		go updateUserLabelByUserId(v.UserId)
+	}
+	return
+}

+ 14 - 40
services/wechat_send_msg.go

@@ -9,6 +9,7 @@ import (
 	"hongze/hongze_cygx/utils"
 	"io/ioutil"
 	"net/http"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -104,50 +105,13 @@ func SendInterviewApplyCancelTemplateMsg(realName, companyName, mobile, articleT
 
 // 权限申请
 func SendPermissionApplyTemplateMsg(realName, companyName, mobile, applyMethod string, itemOpenid *models.OpenIdList) (err error) {
-	var msg string
+
 	defer func() {
 		if err != nil {
-			go utils.SendEmail("发送模版消息失败"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
-			go utils.SendAlarmMsg(fmt.Sprint("权限申请模板消息推送消息失败,手机号", mobile, "公司:", companyName, "手机号:", mobile), 2)
-		}
-		if msg != "" {
-			utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
+			go utils.SendAlarmMsg(fmt.Sprint("权限申请模板消息推送消息失败,手机号", mobile, "公司:", companyName, "手机号:", mobile, ";Err:"+err.Error()), 2)
 		}
-	}()
 
-	//var accessToken string
-	//accessToken, err = models.GetWxAccessTokenByXzs()
-	//if err != nil {
-	//	msg = "GetWxAccessToken Err:" + err.Error()
-	//	return
-	//}
-	//if accessToken == "" {
-	//	msg = "accessToken is empty"
-	//	return
-	//}
-	//sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
-	//
-	//sendMap := make(map[string]interface{})
-	//sendData := make(map[string]interface{})
-	//
-	//keyword1 := "权限申请:" + realName + "【" + companyName + "】"
-	//first := "查研观向有一条新的权限申请,请及时处理。"
-	//keyword2 := mobile
-	//keyword3 := time.Now().Format(utils.FormatDateTime)
-	//keyword4 := applyMethod
-	//fontColor := "#D9001B"
-	//sendData["first"] = map[string]interface{}{"value": first, "color": fontColor}
-	//sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": fontColor}
-	//sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": fontColor}
-	//sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": fontColor}
-	//sendData["keyword4"] = map[string]interface{}{"value": keyword4, "color": fontColor}
-	//if utils.RunMode == "release" {
-	//	sendMap["template_id"] = utils.WxMsgTemplateIdApplyXzs
-	//} else {
-	//	sendMap["template_id"] = utils.WxMsgTemplateIdApply
-	//}
-	//sendMap["data"] = sendData
-	//sendTemplateMsg(sendUrl, sendMap, itemOpenid, mobile, utils.TEMPLATE_MSG_CYGX_APPLY)
+	}()
 
 	var first string
 	var keyword1 string
@@ -156,6 +120,16 @@ func SendPermissionApplyTemplateMsg(realName, companyName, mobile, applyMethod s
 	var keyword4 string
 	var remark string
 	var redirectUrl string
+
+	detail, e := models.GetCygxApplyRecordByMobile(mobile)
+	if e != nil {
+		err = errors.New("GetActivitySignupNomeetingCountList" + e.Error())
+		return
+	}
+	//如果是潜在客户就推送可查看详情的模版消息
+	if detail.ApplyMethod == 2 {
+		redirectUrl = utils.WX_MSG_PATH_APPLY_DETAIL + strconv.Itoa(detail.ApplyRecordId)
+	}
 	keyword1 = "权限申请:" + realName + "【" + companyName + "】"
 	keyword2 = mobile
 	keyword3 = time.Now().Format(utils.FormatDateTime)

+ 9 - 8
services/wx_template_msg.go

@@ -425,7 +425,14 @@ func SendActivityAskApplyTemplateMsgV2(keyword1, keyword2, keyword3, keyword4, r
 
 	activityId := itemAct.ActivityId
 	var redirectUrl string
-	redirectUrl = utils.WX_MSG_PATH_ACTIVITY_DETAIL + strconv.Itoa(activityId)
+	//redirectUrl = utils.WX_MSG_PATH_ACTIVITY_DETAIL + strconv.Itoa(activityId)
+	//mapSource留言跳转类型,1:文章、2:活动、3:微路演视频、4:活动视频、5:活动音频
+	//if utils.RunMode != "release" {
+	//
+	//} else {
+	//
+	//}
+	redirectUrl = utils.WX_MSG_PATH_TEMPLATE_MSG + "SourceId=" + strconv.Itoa(msgId) + "&SourceType=2"
 	openIdArr := make([]string, 0)
 	openIdArr = append(openIdArr, itemOpenid.OpenId)
 	sendInfo := new(SendWxTemplate)
@@ -433,19 +440,13 @@ func SendActivityAskApplyTemplateMsgV2(keyword1, keyword2, keyword3, keyword4, r
 	sendInfo.Keyword2 = keyword2
 	sendInfo.Keyword3 = keyword3
 	sendInfo.Keyword4 = keyword4
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ACTIVITY_ADD
 	sendInfo.Remark = remark
 	sendInfo.TemplateId = utils.WxMsgTemplateIdApplyXzs
 	sendInfo.RedirectUrl = redirectUrl
 	sendInfo.RedirectTarget = 3
 	sendInfo.Resource = strconv.Itoa(activityId)
 
-	//mapSource留言跳转类型,1:文章、2:活动、3:微路演视频、4:活动视频、5:活动音频
-	if utils.RunMode != "release" {
-		sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ACTIVITY_ADD
-	} else {
-		redirectUrl = utils.WX_MSG_PATH_TEMPLATE_MSG + "SourceId=" + strconv.Itoa(msgId) + "&SourceType=2"
-	}
-
 	sendInfo.OpenIdArr = openIdArr
 	err = PublicSendTemplateMsg(sendInfo)
 	return

+ 167 - 168
services/wx_user.go

@@ -5,7 +5,6 @@ import (
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
-	"sort"
 	"strconv"
 	"strings"
 	"time"
@@ -15,8 +14,6 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 	defer func() {
 		if err != nil {
 			go utils.SendAlarmMsg("更新用户标签失败;Err:"+err.Error(), 2)
-			go utils.SendEmail("更新用户标签失败"+"【"+utils.APPNAME+"】"+time.Now().Format(utils.FormatDateTime), ";Err:"+err.Error(), utils.EmailSendToUsers)
-			utils.FileLog.Info("更新用户标签失败,Err:%s", err.Error())
 		}
 	}()
 	//获取需要处理的权益客户
@@ -25,7 +22,6 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 		fmt.Println("GetUserRegisterList Err", err)
 		return err
 	}
-
 	mapChartCollect := make(map[string]int)
 	//获取已经处理记录的用户并记录切片
 	listChartCollectL, err := models.GetCygxChartCollectList()
@@ -336,170 +332,170 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 	}
 
 	//处理用户标签
-	for _, vUser := range listUser {
-		labels, err := models.GetCygxCompanyUserListSplit(strconv.Itoa(vUser.UserId))
-		if err != nil {
-			fmt.Println("GetCygxCompanyUserListSplit Err", err)
-			return err
-		}
-		mapLabels := make(map[string]string)
-		var labelsListStr []*models.UserLabel
-		mapActivityLabels := make(map[string]string)
-		labelsList := strings.Split(labels, ",")
-		for _, vL := range labelsList {
-			if mapLabels[vL] == "" && vL != "" {
-				mapLabels[vL] = vL
-				item := new(models.UserLabel)
-				item.Label = vL
-				labelsListStr = append(labelsListStr, item)
-			}
-		}
-		dateTime := time.Now().AddDate(0, -3, 0).Format(utils.FormatDate)
-		listArticlePv, err := models.GetArticlePvCount(vUser.Mobile, vUser.Email, dateTime)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			fmt.Println("GetArticlePvCount Err", err)
-			return err
-		}
-		var articleIds string
-		mapArticleIdLabelTotal := make(map[string]int)
-		mapArticleIdPv := make(map[int]int)
-		if len(listArticlePv) > 0 {
-			for _, v := range listArticlePv {
-				articleIds += strconv.Itoa(v.ArticleId) + ","
-				mapArticleIdPv[v.ArticleId] = v.Pv
-			}
-			articleIds = strings.TrimRight(articleIds, ",")
-			//产业、标的标签
-			listLabelName, err := models.GetArticleGroupyIndustryName(articleIds)
-			if err != nil && err.Error() != utils.ErrNoRow() {
-				fmt.Println("GetArticleGroupyIndustryName Err", err)
-				return err
-			}
-			if len(listLabelName) > 0 {
-				for _, v := range listLabelName {
-					labelsIndustryList := strings.Split(v.IndustryName, "/")
-					labelsSubjectList := strings.Split(v.SubjectName, "/")
-					//添加产业统计
-					if len(labelsIndustryList) > 0 {
-						for _, vIn := range labelsIndustryList {
-							if mapActivityLabels[vIn] != "" {
-								mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
-							} else {
-								mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
-								mapActivityLabels[vIn] = vIn
-							}
-						}
-					}
-					if len(labelsSubjectList) > 0 {
-						//添加标的统计
-						for _, vIn := range labelsSubjectList {
-							if mapActivityLabels[vIn] != "" {
-								mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
-							} else {
-								mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
-								mapActivityLabels[vIn] = vIn
-							}
-						}
-					}
-				}
-			}
-		}
-		articleIds, err = models.GetCygxArticleCollectId(vUser.UserId, dateTime)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			fmt.Println("GetCygxArticleCollectId Err", err)
-			return err
-		}
-		if articleIds != "" {
-			//产业、标的标签
-			listLabelName, err := models.GetArticleGroupyIndustryName(articleIds)
-			if err != nil && err.Error() != utils.ErrNoRow() {
-				fmt.Println("GetArticleGroupyIndustryName Err", err)
-				return err
-			}
-			if len(listLabelName) > 0 {
-				for _, v := range listLabelName {
-					labelsIndustryList := strings.Split(v.IndustryName, "/")
-					labelsSubjectList := strings.Split(v.SubjectName, "/")
-					//添加产业统计
-					if len(labelsIndustryList) > 0 {
-						for _, vIn := range labelsIndustryList {
-							if mapActivityLabels[vIn] != "" {
-								mapArticleIdLabelTotal[vIn] += 1
-							} else {
-								mapArticleIdLabelTotal[vIn] = 1
-								mapActivityLabels[vIn] = vIn
-							}
-						}
-					}
-					if len(labelsSubjectList) > 0 {
-						//添加标的统计
-						for _, vIn := range labelsSubjectList {
-							if mapActivityLabels[vIn] != "" {
-								mapArticleIdLabelTotal[vIn] += 1
-							} else {
-								mapArticleIdLabelTotal[vIn] = 1
-								mapActivityLabels[vIn] = vIn
-							}
-						}
-					}
-				}
-			}
-		}
-		//活动标签计算
-		listActivityPv, err := models.GetActivitySignCount(vUser.Mobile, dateTime)
-		if err != nil && err.Error() != utils.ErrNoRow() {
-			fmt.Println("GetActivitySignCount Err", err)
-			return err
-		}
-		if len(listActivityPv) > 0 {
-			for _, v := range listActivityPv {
-				labelsList := strings.Split(v.Label, "-")
-				for _, v2 := range labelsList {
-					labelsListSon := strings.Split(v2, "/")
-					for _, v3 := range labelsListSon {
-						if mapActivityLabels[v3] != "" {
-							mapArticleIdLabelTotal[v3] += 1
-						} else {
-							mapArticleIdLabelTotal[v3] = 1
-							mapActivityLabels[v3] = v3
-						}
-					}
-				}
-			}
-		}
-		//对标签数量进行排序
-		type KvPair struct {
-			Key string
-			Val int
-		}
-		tmpList := make([]KvPair, 0)
-		for k, v := range mapArticleIdLabelTotal {
-			tmpList = append(tmpList, KvPair{Key: k, Val: v})
-		}
-		sort.Slice(tmpList, func(i, j int) bool {
-			return tmpList[i].Val > tmpList[j].Val // 降序
-		})
-		for _, v := range tmpList {
-			if v.Key != "" {
-				mapLabels[v.Key] = v.Key
-				item := new(models.UserLabel)
-				item.Label = v.Key
-				labelsListStr = append(labelsListStr, item)
-			}
-		}
-		var labelNew string
-		for _, v := range labelsListStr {
-			labelNew += v.Label + ","
-		}
-		labelNew = strings.TrimRight(labelNew, ",")
-		if labelNew != "" {
-			err = models.UpdateUserLabel(labelNew, vUser.UserId)
-			if err != nil {
-				fmt.Println("UpdateUserLabel Err", err)
-				return err
-			}
-		}
-	}
+	//for _, vUser := range listUser {
+	//	labels, err := models.GetCygxCompanyUserListSplit(strconv.Itoa(vUser.UserId))
+	//	if err != nil {
+	//		fmt.Println("GetCygxCompanyUserListSplit Err", err)
+	//		return err
+	//	}
+	//	mapLabels := make(map[string]string)
+	//	var labelsListStr []*models.UserLabel
+	//	mapActivityLabels := make(map[string]string)
+	//	labelsList := strings.Split(labels, ",")
+	//	for _, vL := range labelsList {
+	//		if mapLabels[vL] == "" && vL != "" {
+	//			mapLabels[vL] = vL
+	//			item := new(models.UserLabel)
+	//			item.Label = vL
+	//			labelsListStr = append(labelsListStr, item)
+	//		}
+	//	}
+	//	dateTime := time.Now().AddDate(0, -3, 0).Format(utils.FormatDate)
+	//	listArticlePv, err := models.GetArticlePvCount(vUser.Mobile, vUser.Email, dateTime)
+	//	if err != nil && err.Error() != utils.ErrNoRow() {
+	//		fmt.Println("GetArticlePvCount Err", err)
+	//		return err
+	//	}
+	//	var articleIds string
+	//	mapArticleIdLabelTotal := make(map[string]int)
+	//	mapArticleIdPv := make(map[int]int)
+	//	if len(listArticlePv) > 0 {
+	//		for _, v := range listArticlePv {
+	//			articleIds += strconv.Itoa(v.ArticleId) + ","
+	//			mapArticleIdPv[v.ArticleId] = v.Pv
+	//		}
+	//		articleIds = strings.TrimRight(articleIds, ",")
+	//		//产业、标的标签
+	//		listLabelName, err := models.GetArticleGroupyIndustryName(articleIds)
+	//		if err != nil && err.Error() != utils.ErrNoRow() {
+	//			fmt.Println("GetArticleGroupyIndustryName Err", err)
+	//			return err
+	//		}
+	//		if len(listLabelName) > 0 {
+	//			for _, v := range listLabelName {
+	//				labelsIndustryList := strings.Split(v.IndustryName, "/")
+	//				labelsSubjectList := strings.Split(v.SubjectName, "/")
+	//				//添加产业统计
+	//				if len(labelsIndustryList) > 0 {
+	//					for _, vIn := range labelsIndustryList {
+	//						if mapActivityLabels[vIn] != "" {
+	//							mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
+	//						} else {
+	//							mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
+	//							mapActivityLabels[vIn] = vIn
+	//						}
+	//					}
+	//				}
+	//				if len(labelsSubjectList) > 0 {
+	//					//添加标的统计
+	//					for _, vIn := range labelsSubjectList {
+	//						if mapActivityLabels[vIn] != "" {
+	//							mapArticleIdLabelTotal[vIn] += mapArticleIdPv[v.ArticleId]
+	//						} else {
+	//							mapArticleIdLabelTotal[vIn] = mapArticleIdPv[v.ArticleId]
+	//							mapActivityLabels[vIn] = vIn
+	//						}
+	//					}
+	//				}
+	//			}
+	//		}
+	//	}
+	//	articleIds, err = models.GetCygxArticleCollectId(vUser.UserId, dateTime)
+	//	if err != nil && err.Error() != utils.ErrNoRow() {
+	//		fmt.Println("GetCygxArticleCollectId Err", err)
+	//		return err
+	//	}
+	//	if articleIds != "" {
+	//		//产业、标的标签
+	//		listLabelName, err := models.GetArticleGroupyIndustryName(articleIds)
+	//		if err != nil && err.Error() != utils.ErrNoRow() {
+	//			fmt.Println("GetArticleGroupyIndustryName Err", err)
+	//			return err
+	//		}
+	//		if len(listLabelName) > 0 {
+	//			for _, v := range listLabelName {
+	//				labelsIndustryList := strings.Split(v.IndustryName, "/")
+	//				labelsSubjectList := strings.Split(v.SubjectName, "/")
+	//				//添加产业统计
+	//				if len(labelsIndustryList) > 0 {
+	//					for _, vIn := range labelsIndustryList {
+	//						if mapActivityLabels[vIn] != "" {
+	//							mapArticleIdLabelTotal[vIn] += 1
+	//						} else {
+	//							mapArticleIdLabelTotal[vIn] = 1
+	//							mapActivityLabels[vIn] = vIn
+	//						}
+	//					}
+	//				}
+	//				if len(labelsSubjectList) > 0 {
+	//					//添加标的统计
+	//					for _, vIn := range labelsSubjectList {
+	//						if mapActivityLabels[vIn] != "" {
+	//							mapArticleIdLabelTotal[vIn] += 1
+	//						} else {
+	//							mapArticleIdLabelTotal[vIn] = 1
+	//							mapActivityLabels[vIn] = vIn
+	//						}
+	//					}
+	//				}
+	//			}
+	//		}
+	//	}
+	//	//活动标签计算
+	//	listActivityPv, err := models.GetActivitySignCount(vUser.Mobile, dateTime)
+	//	if err != nil && err.Error() != utils.ErrNoRow() {
+	//		fmt.Println("GetActivitySignCount Err", err)
+	//		return err
+	//	}
+	//	if len(listActivityPv) > 0 {
+	//		for _, v := range listActivityPv {
+	//			labelsList := strings.Split(v.Label, "-")
+	//			for _, v2 := range labelsList {
+	//				labelsListSon := strings.Split(v2, "/")
+	//				for _, v3 := range labelsListSon {
+	//					if mapActivityLabels[v3] != "" {
+	//						mapArticleIdLabelTotal[v3] += 1
+	//					} else {
+	//						mapArticleIdLabelTotal[v3] = 1
+	//						mapActivityLabels[v3] = v3
+	//					}
+	//				}
+	//			}
+	//		}
+	//	}
+	//	//对标签数量进行排序
+	//	type KvPair struct {
+	//		Key string
+	//		Val int
+	//	}
+	//	tmpList := make([]KvPair, 0)
+	//	for k, v := range mapArticleIdLabelTotal {
+	//		tmpList = append(tmpList, KvPair{Key: k, Val: v})
+	//	}
+	//	sort.Slice(tmpList, func(i, j int) bool {
+	//		return tmpList[i].Val > tmpList[j].Val // 降序
+	//	})
+	//	for _, v := range tmpList {
+	//		if v.Key != "" {
+	//			mapLabels[v.Key] = v.Key
+	//			item := new(models.UserLabel)
+	//			item.Label = v.Key
+	//			labelsListStr = append(labelsListStr, item)
+	//		}
+	//	}
+	//	var labelNew string
+	//	for _, v := range labelsListStr {
+	//		labelNew += v.Label + ","
+	//	}
+	//	labelNew = strings.TrimRight(labelNew, ",")
+	//	if labelNew != "" {
+	//		err = models.UpdateUserLabel(labelNew, vUser.UserId)
+	//		if err != nil {
+	//			fmt.Println("UpdateUserLabel Err", err)
+	//			return err
+	//		}
+	//	}
+	//}
 
 	//处理用户、机构互动量数据
 	{
@@ -754,5 +750,8 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 			}
 		}
 	}
+
+	//更新用户标签以及权重
+	go UpdateUserLabelWeight()
 	return
 }

+ 5 - 6
services/yidong.go

@@ -554,6 +554,7 @@ func GetYiDongActivityMeeting(cont context.Context) (err error) {
 	endDate := time.Now().Add(-time.Minute * 120).Format(utils.FormatDateTime)
 	condition += ` AND   activity_time > ` + "'" + startDate + "'"
 	condition += ` AND  activity_time < ` + "'" + endDate + "'"
+
 	//fmt.Println(startDate)
 	artivityListYidong, err := models.GetActivityListByYidong(condition)
 	if err != nil {
@@ -701,11 +702,10 @@ func GetYiDongActivityMeeting(cont context.Context) (err error) {
 					item.Duration = vresult.Duration
 					item.IsMeetingStr = 1
 					mobileStrMeet += "'" + vresult.PersonTelephone + "'" + ","
-
+					item.CreateTime = time.Now()
+					needAddAttendanc = append(needAddAttendanc, item)
 				}
 				mobileStr += "'" + vresult.PersonTelephone + "'" + ","
-				item.CreateTime = time.Now()
-				needAddAttendanc = append(needAddAttendanc, item)
 
 			}
 			lenmobiles := len(mobiles)
@@ -753,7 +753,7 @@ func GetYiDongActivityMeeting(cont context.Context) (err error) {
 					}
 				}
 			}
-			//fmt.Println(mobileStr)
+
 			//参会记录
 			err = models.AddAttendancDetail(needAddAttendanc, v.ActivityId, mobileStrMeet)
 			if err != nil {
@@ -766,8 +766,7 @@ func GetYiDongActivityMeeting(cont context.Context) (err error) {
 				fmt.Println("AddCygxActivityRestrictSignupByAdmin Err:", err.Error())
 				return err
 			}
-			fmt.Println(len(needAddAttendanc))
-			go AddctivitySignupDetailByJmcj(needAddAttendanc, v.ActivityId)
+			AddctivitySignupDetailByJmcj(needAddAttendanc, v.ActivityId)
 		}
 	}
 

+ 3 - 0
utils/config.go

@@ -44,6 +44,7 @@ var (
 	WxMsgTemplateIdArticleUserRemind      string //用户阅读报告通知-模板ID
 	WxMsgTemplateIdArticleUserRemindXzs   string //用户阅读报告通知-模板ID(小助手)
 	WxMsgTemplateIdActivityChangeApplyXzs string //查研观向活动变更通知-模板ID(小助手)
+	WxMsgTemplateIdActivitySign           string //查研观向活动签到通知-模板ID(小助手)
 )
 
 // 微信公众号配置信息
@@ -227,6 +228,7 @@ func init() {
 		WxMsgTemplateIdApplyCancelXzs = "UU_d7ks0XZBnWg2xFzxL9Heilm4kisX39K7dr4SDdO8"         ////预约取消提醒(小助手)
 		TemplateIdByProductXzs = "-YjuPOB7Fqd-S3ilabYa6wvjDY9aXmeEfPN6DCiy-EY"                //产品运行报告通知-模板ID(小助手)
 		WxMsgTemplateIdActivityChangeApplyXzs = "CB7bOl7f3viMG4s1uhRo7WM0Jbx3WvodKuIZ8A_z8fM" //查研观向活动变更通知-模板ID(小助手)
+		WxMsgTemplateIdActivitySign = "3l5cxpqH6c9kkLe9ow7qzqd0uYEOdY3A_PB8wRWkiHk"           //查研观向活动签到通知-模板ID(小助手)
 	} else {
 		//新的模板ID
 		WxPublicIdXzs = "wxb7cb8a15abad5b8e"                                                  //查研观向小助手
@@ -237,6 +239,7 @@ func init() {
 		WxMsgTemplateIdApplyCancelXzs = "gCSCAWNNhjkzE2V1cjbIV_Ex68R_8LM_u25qDlSKWyM"         ////预约取消提醒(小助手)
 		TemplateIdByProductXzs = "tNcCUiK_uUkuxaFF7M9NP2RwLkw8uHFjG-TDIxGUKxo"                //产品运行报告通知-模板ID(小助手)
 		WxMsgTemplateIdActivityChangeApplyXzs = "7qe3i4MrGxAIPhJeMgoqqw6j0A_foUB65DLSmxKe05s" //查研观向活动变更通知-模板ID(小助手)
+		WxMsgTemplateIdActivitySign = "7qe3i4MrGxAIPhJeMgoqqw6j0A_foUB65DLSmxKe05s"           //查研观向活动签到通知-模板ID(小助手)
 	}
 
 	//易董开放api配置

+ 4 - 0
utils/constants.go

@@ -108,6 +108,7 @@ const (
 	CYGX_TACTICS_TIME_LINE_STATUS    string = "cygx_tactics_time_line_status" // 策略时间线是否对外开放
 	TIME_LINE_ID                     int    = 99999                           // 策略时间线的值
 	TIME_LINE_NAME                   string = "时间线"                           // 策略时间线的名称
+	ACTEGORY_ID_AI_QY                int    = 61                              // AI前沿自定义ID
 )
 
 const (
@@ -121,6 +122,7 @@ const (
 
 const (
 	YI_DONG_ZHENG_TONG_YUN_TOKEN_KEY = "YI_DONG_ZHENG_TONG_YUN_TOKEN_KEY" //易董证通云的token,存Redis使用
+	CYGX_USER_KEY_LABEL              = "CYGX_USER_KEY_LABEL"              //查研观向用户标签
 )
 
 const (
@@ -169,6 +171,8 @@ const (
 	WX_MSG_PATH_LAST_WEEK_DETAIL       = "reportPages/reportSecretDetail/reportSecretDetail?type=3&id=" //上周纪要汇总详情模板消息地址
 	WX_MSG_PATH_KEY_COMPANY_DETAIL     = "reportPages/keyCompany/keyCompany"                            //重点公司详情模板消息地址
 	WX_MSG_PATH_RESEARCHTHEME_DETAIL   = "reportPages/researchTheme/researchTheme?id="                  //主题详情模板消息地址
+	WX_MSG_PATH_ACTIVITY_SIGN          = "pages-message/activityTemplate/activityTemplate?id="          //活动模板消息地址
+	WX_MSG_PATH_APPLY_DETAIL           = "pages-message/applyFor/applyFor?id="                          //潜在用户试用权限申请
 )
 
 //2:文章详情  https://web.hzinsights.com/material/info/8436  小程序路径:/pageMy/reportDetail/reportDetail?id=