Просмотр исходного кода

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into cygx_8.2.1

xingzai 2 лет назад
Родитель
Сommit
20a2ba1fbb
42 измененных файлов с 3608 добавлено и 519 удалено
  1. 153 185
      controllers/activity.go
  2. 348 0
      controllers/activity_special.go
  3. 6 4
      controllers/micro_roadshow.go
  4. 452 81
      controllers/report.go
  5. 14 0
      controllers/user.go
  6. 171 45
      models/activity.go
  7. 13 2
      models/activity_appointment.go
  8. 11 0
      models/activity_meeting_reminder.go
  9. 10 0
      models/activity_signup.go
  10. 73 0
      models/activity_special.go
  11. 10 0
      models/activity_special_signup.go
  12. 116 0
      models/activity_special_trip.go
  13. 30 0
      models/article.go
  14. 32 0
      models/article_comment.go
  15. 28 0
      models/article_data.go
  16. 127 0
      models/company_activity_trip.go
  17. 3 0
      models/db.go
  18. 55 0
      models/industrial_management.go
  19. 10 10
      models/micro_roadshow.go
  20. 90 8
      models/report.go
  21. 7 0
      models/seller.go
  22. 14 0
      models/send_company_user.go
  23. 8 0
      models/tactics.go
  24. 24 0
      models/wx_template_msg.go
  25. 63 0
      routers/commentsRouter.go
  26. 5 0
      routers/router.go
  27. 277 0
      services/activity_button.go
  28. 113 0
      services/activity_my_schedule.go
  29. 881 9
      services/activity_special.go
  30. 127 0
      services/activity_special_trip.go
  31. 42 139
      services/article.go
  32. 77 0
      services/company_permission.go
  33. 12 0
      services/config.go
  34. 9 5
      services/micro_roadshow.go
  35. 2 2
      services/report_billboard.go
  36. 11 0
      services/send_company_user.go
  37. 6 0
      services/task.go
  38. 57 0
      services/wechat_send_msg.go
  39. 93 27
      services/wx_template_msg.go
  40. 1 1
      utils/common.go
  41. 7 1
      utils/config.go
  42. 20 0
      utils/constants.go

+ 153 - 185
controllers/activity.go

@@ -492,7 +492,8 @@ func (this *ActivityCoAntroller) ScheduleList() {
 		if source == 1 {
 			condition += ` AND art.yidong_activity_id = '' `
 		}
-		listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
+		//listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
+		listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
 		if errList != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取失败,Err:" + errList.Error()
@@ -505,7 +506,8 @@ func (this *ActivityCoAntroller) ScheduleList() {
 		}
 	} else {
 		condition += ` AND art.active_state IN(1,3)` //全部都不是进行中的活动
-		listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
+		//listOther, errList := models.GetScheduleList(condition, pars, uid, startSize, pageSize)
+		listOther, errList := services.GetScheduleAndSpecilList(user, condition, startSize, pageSize)
 		list = listOther
 		if errList != nil {
 			br.Msg = "获取失败"
@@ -1042,6 +1044,16 @@ func (this *ActivityCoAntroller) Detail() {
 			activityInfo.AudioLink = true
 			activityInfo.VideoDetail = mapActivityVideo[activityId]
 		}
+		//8.5 小程序活动详情页 除专家电话外 其余属于新产业的活动 ,不显示 new 标签
+		if activityInfo.ActivityTypeName != "专家电话会" {
+			for _, rep := range activityInfo.Listndustrial {
+				rep.IndustryNewLabel = false
+			}
+		}
+		//8.5 买方研选的活动去掉限免标签
+		if strings.Contains(activityInfo.ChartPermissionName, "研选") {
+			activityInfo.IsShowSustainable = false
+		}
 		//处理按钮是否展示问题
 		resp.Detail = services.ActivityButtonShow(activityInfo)
 	}
@@ -1252,6 +1264,7 @@ func (this *ActivityCoAntroller) SignupAdd() {
 				resp.SignupType = signupType
 				resp.SignupStatus = signupStatus
 				resp.HasPermission = hasPermission
+				resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
 				br.Ret = 200
 				br.Success = true
 				br.Msg = ""
@@ -1278,6 +1291,7 @@ func (this *ActivityCoAntroller) SignupAdd() {
 				}
 				if totalRestrict >= 1 {
 					signupStatus = "BreakPromise"
+					resp.PopupMsg = "由于爽约次数过多,您暂时被限制报名资格"
 					item.FailType = 3
 				}
 				totalSignupCompany, err := models.GetActivitySignupCompanyCount(activityId, user.CompanyId)
@@ -1288,6 +1302,7 @@ func (this *ActivityCoAntroller) SignupAdd() {
 				}
 				if totalSignupCompany >= 2 {
 					signupStatus = "TwoPeople"
+					resp.PopupMsg = "单机构最多2人报名同一活动,您所在机构报名人数已满"
 					item.FailType = 2
 				}
 				totaSignupPeopleNum, err := models.GetActivitySignupSuccessCount(activityId)
@@ -1298,6 +1313,7 @@ func (this *ActivityCoAntroller) SignupAdd() {
 				}
 				if totaSignupPeopleNum >= activityInfo.LimitPeopleNum {
 					signupStatus = "FullStarffed"
+					resp.PopupMsg = "此活动报名人数已满,请留意下期活动"
 					item.FailType = 1
 				}
 				totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
@@ -1438,10 +1454,11 @@ func (this *ActivityCoAntroller) SignupAdd() {
 				//1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
 				if signupType == 1 {
 					go services.ActivityUserRemind(user, activityInfo, 1)
+					resp.PopupMsg = item.CountryCode + "-" + item.Mobile + "<br/>预约成功,已加入您的活动日程<br/><br/>想要及时获取活动时间变更通知,请关注【查研观向小助手】公众号"
 				} else {
 					go services.ActivityUserRemind(user, activityInfo, 4)
+					resp.PopupMsg = "报名成功,已加入您的活动日程<br/><br/>想要及时获取活动时间变更通知,请关注【查研观向小助手】公众号"
 				}
-
 			}
 		} else {
 			if companyItem.ProductId == 2 {
@@ -1997,6 +2014,7 @@ func (this *ActivityCoAntroller) MeetingReminderAdd() {
 	br.Success = true
 	if hasPermission == 1 {
 		br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
+		resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
 	}
 	br.Data = resp
 }
@@ -2425,6 +2443,7 @@ func (this *ActivityCoAntroller) LabelMoreList() {
 // @Param   PlayBack   query   int  false       "是否仅展示回放 1:是、0:否 默认0"
 // @Param   KeyWord   query   string  false       "搜索关键词 多个用 , 隔开"
 // @Param   ActivityId   query   int  false       "活动列表传过来的活动ID"
+// @Param   Filter			query	int		false	"筛选条件 0:全部 1:视频 2:音频"
 // @Success 200 {object} models.GetCygxActivityListRep
 // @router /listNew [get]
 func (this *ActivityCoAntroller) ActivityListNew() {
@@ -2450,6 +2469,7 @@ func (this *ActivityCoAntroller) ActivityListNew() {
 	activityTypeId := this.GetString("ActivityTypeId")
 	keyWord := this.GetString("KeyWord")
 	playBack, _ := this.GetInt("PlayBack")
+	filter, _ := this.GetInt("Filter")
 	activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签
 
 	if label == "undefined" {
@@ -2558,7 +2578,7 @@ func (this *ActivityCoAntroller) ActivityListNew() {
 	}
 
 	condition += conditionOrder
-	list, errList := models.GetActivityListAll(condition, pars, uid, startSize, pageSize, playBack)
+	list, errList := models.GetActivityListNew(condition, pars, uid, startSize, pageSize, playBack, filter)
 	if errList != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + errList.Error()
@@ -2965,6 +2985,9 @@ func (this *ActivityCoAntroller) CheckAsk() {
 // @Param   ActivityTypeIds   query   string  false     "活动类型id 多个用 , 隔开"
 // @Param   ActiveState   query   string  false       "活动进行状态 未开始:1、进行中2、已结束3"
 // @Param   WhichDay   query   string  false       "哪一天 今天:1、明天:2,多个用 , 隔开"
+// @Param   WhichWeek   query   string  false       "哪一周 本周:1 上周:2"
+// @Param   WhichMonth   query   string  false       "哪一月 本月:1 上月:2"
+// @Param   WhichMonth   query   string  false       "哪一月 本月:1 上月:2"
 // @Param   IsPower   query   int  false       "是否选择有权限行业 ,1是 0 否 默认0"
 // @Success 200 {object} models.ActivityTypeListHomeResp
 // @router /labelTypeListV5 [get]
@@ -3042,12 +3065,12 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 		return
 	}
 	//判断客户规模是否属于可见范围的活动
-	companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
-		return
-	}
+	//companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
+	//if err != nil && err.Error() != utils.ErrNoRow() {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+	//	return
+	//}
 	//isMaker := user.IsMaker
 
 	//var sqlExport string
@@ -3074,6 +3097,9 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 		}
 		//标签字段关联的产业与标签处理
 		for k2, v2 := range labelList {
+			if v2.YidongActivityId != 0 {
+				v2.IsExternalLabel = true
+			}
 			labelList[k2].KeyWord = services.LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
 			labelList[k2].ImgUrlBg = v.ImgUrlBgs
 		}
@@ -3083,11 +3109,7 @@ func (this *ActivityCoAntroller) LabelTypeListV5() {
 
 	//查询专项产业调研展示权限 仅对大套餐客户跟永续客户展示
 	if whichDay == "" {
-		var scale string
-		if companyProduct != nil {
-			scale = companyProduct.Scale
-		}
-		speciaItem, err := services.GetActivityLabelSpecialList(userType, isPower, chartPermissionIds, scale, permissionNameStr)
+		speciaItem, err := services.GetActivityLabelSpecialList(user, isPower, chartPermissionIds, permissionNameStr)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取失败,Err:" + err.Error()
@@ -3633,22 +3655,6 @@ func (this *ActivityCoAntroller) SpecialSignupAdd() {
 		return
 	}
 	activityId := req.ActivityId
-	hasPermission := 0
-	//判断是否已经申请过
-	applyCount, err := models.GetApplyRecordCount(uid)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
-		return
-	}
-	//获取FICC销售信息
-	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "申请失败"
-		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
-		return
-	}
-
 	activityInfo, errInfo := models.GetCygxActivitySpecialDetail(activityId)
 	if activityInfo == nil {
 		br.Msg = "操作失败"
@@ -3660,143 +3666,22 @@ func (this *ActivityCoAntroller) SpecialSignupAdd() {
 		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
 		return
 	}
-	//HasPermission "1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
-	//var companyDetailStatus string
-	if user.CompanyId > 1 {
-		companyPermission, err := models.GetCompanyPermission(user.CompanyId)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
-			return
-		}
-		if companyPermission == "" {
-			if applyCount > 0 {
-				hasPermission = 4
-			} else {
-				if sellerItem != nil {
-					hasPermission = 5
-				} else {
-					//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
-					sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
-					if err != nil && err.Error() != utils.ErrNoRow() {
-						br.Msg = "获取信息失败"
-						br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
-						return
-					}
-					if sellerItemQy != nil {
-						hasPermission = 2
-						resp.SellerMobile = sellerItemQy.Mobile
-						resp.SellerName = sellerItemQy.RealName
-					} else {
-						hasPermission = 3
-					}
-				}
-			}
-			resp.HasPermission = hasPermission
-			resp.ActivityId = activityId
-			resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
-			br.Ret = 200
-			br.Success = true
-			br.Msg = "获取成功"
-			br.Data = resp
-			return
-		}
-		companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
-		if err != nil {
-			br.Msg = "获取信息失败!"
-			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
-			return
-		}
-		if companyDetail == nil {
-			br.Msg = "获取信息失败!"
-			br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
-			return
-		}
-	}
-	var userType int
-	var permissionStr string
-	userType, permissionStr, err = services.GetUserType(user.CompanyId)
+	havePower, err := services.GetSpecialDetailUserPower(user, activityInfo)
 	if err != nil {
-		br.Msg = "获取信息失败!"
-		br.ErrMsg = "获取失败,Err:" + err.Error()
-		return
-	}
-	if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
-		br.Msg = "您暂无查看该活动权限"
-		br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		return
 	}
-
-	if user.CompanyId > 1 {
-		companyItem, err := models.GetCompanyDetailById(user.CompanyId)
-		//冻结客户
-		if err != nil {
-			if err.Error() == utils.ErrNoRow() {
-				if applyCount > 0 {
-					hasPermission = 4
-				} else {
-					if sellerItem != nil {
-						hasPermission = 5
-					} else {
-						hasPermission = 3
-					}
-				}
-				resp.ActivityId = activityId
-				resp.HasPermission = hasPermission
-				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
-				br.Ret = 200
-				br.Success = true
-				br.Msg = "获取成功"
-				br.Data = resp
-				return
-			} else {
-				br.Msg = "获取信息失败"
-				br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
-				return
-			}
-		}
-		//判断是否有权限
-		var havePower bool
-		if strings.Contains(permissionStr, activityInfo.ActivityTypeName) {
-			havePower = true
-		}
-		if havePower {
-			hasPermission = 1
-		} else {
-			if companyItem.ProductId == 2 {
-				hasPermission = 2
-				resp.SellerMobile = companyItem.Mobile
-				resp.SellerName = companyItem.SellerName
-				if permissionStr == "专家" {
-					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ActivityTypeName + "】类型活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
-				} else {
-					resp.PopupMsg = "您暂无权限参加【" + activityInfo.ChartPermissionName + "】行业活动,若想参加请联系对口销售--" + companyItem.SellerName + ":" + companyItem.Mobile
-				}
-			} else {
-				hasPermission = 5
-			}
-		}
-	} else { //潜在客户
-		if applyCount > 0 {
-			hasPermission = 4
-		} else {
-			if sellerItem != nil {
-				hasPermission = 5
-			} else {
-				hasPermission = 3
-			}
-		}
-		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
-	}
-	resp.HasPermission = hasPermission
-	resp.ActivityId = activityId
-	if hasPermission == 1 {
+	//判断有没有对应的权限,如果没有则给出对应的状态码
+	if havePower {
+		resp.HasPermission = 1
 		total, err := models.GetUserCygxActivitySpecialSignup(user.UserId, activityId)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
 			return
 		}
+		resp.SignupStatus = 1
 		//判断是删除还是添加
 		if total == 0 {
 			//获取销售信息
@@ -3825,8 +3710,9 @@ func (this *ActivityCoAntroller) SpecialSignupAdd() {
 				return
 			}
 			resp.Status = 1
-
-			////给所属销售发送消息
+			resp.PopupMsg = "感谢反馈"
+			resp.PopupMsg2 = "此调研具体行程尚未确认,待预报名人数满10人后弘则会确定行程并推送给您活动日期,只有在确认行程中再次报名才完成占位。"
+			//给所属销售发送消息
 			if sellerItem.Mobile != "" {
 				openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
 				if openIpItem != nil && openIpItem.OpenId != "" {
@@ -3836,20 +3722,25 @@ func (this *ActivityCoAntroller) SpecialSignupAdd() {
 				}
 			}
 			// 给芳姐发消息
-			cnf, _ := models.GetConfigByCode("tpl_msg")
-			if cnf != nil {
-				openIpItem, _ := models.GetUserRecordByMobile(4, cnf.ConfigValue)
-				if openIpItem != nil && openIpItem.OpenId != "" {
-					actList, _ := models.GetActivityListSpecialAll(activityId)
-					if len(actList) == 5 {
-						var companyName string
-						for _, v := range actList {
-							companyName += "【" + v.CompanyName + "】"
-						}
-						go services.SendSpecialTemplateMsg(companyName, "", "", activityInfo.ResearchTheme, "", openIpItem)
-					}
-				}
+			//cnf, _ := models.GetConfigByCode("tpl_msg")
+			actList, _ := models.GetActivityListSpecialByActivityId(activityId)
+			//if cnf != nil {
+			//	openIpItem, _ := models.GetUserRecordByMobile(4, cnf.ConfigValue)
+			//	if openIpItem != nil && openIpItem.OpenId != "" {
+			//		if len(actList) == 5 {
+			//			var companyName string
+			//			for _, v := range actList {
+			//				companyName += "【" + v.CompanyName + "】"
+			//			}
+			//			go services.SendSpecialTemplateMsg(companyName, "", "", activityInfo.ResearchTheme, "", openIpItem)
+			//		}
+			//	}
+			//}
+			//感兴趣人数到达10人时,模板消息发送给活动负责人
+			if len(actList) == 10 {
+				go services.SendWxMsgActivitySpecial10(activityInfo)
 			}
+
 			//用户专项调研操作行为,模板消息推送
 			go services.SpecialActivityUserRemind(user, activityInfo, 1)
 		} else {
@@ -3861,7 +3752,19 @@ func (this *ActivityCoAntroller) SpecialSignupAdd() {
 			}
 			resp.Status = 2
 		}
+	} else {
+		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		resp.PopupMsg = popupMsg
+		resp.HasPermission = hasPermission
+		resp.SellerName = sellerName
+		resp.SellerMobile = sellerMobile
 	}
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"
@@ -4017,12 +3920,12 @@ func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
 		return
 	}
 	//判断客户规模是否属于可见范围的活动
-	companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
-		return
-	}
+	//companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
+	//if err != nil && err.Error() != utils.ErrNoRow() {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+	//	return
+	//}
 	var sqlExport string
 	//处理专家权限的查询
 	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
@@ -4067,11 +3970,11 @@ func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
 
 	if whichDay == "" {
 		//查询专项产业调研展示权限
-		var scale string
-		if companyProduct != nil {
-			scale = companyProduct.Scale
-		}
-		speciaItem, err := services.GetActivityLabelSpecialList(userType, isPower, chartPermissionIds, scale, permissionNameStr)
+		//var scale string
+		//if companyProduct != nil {
+		//	scale = companyProduct.Scale
+		//}
+		speciaItem, err := services.GetActivityLabelSpecialList(user, isPower, chartPermissionIds, permissionNameStr)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取失败,Err:" + err.Error()
@@ -4413,6 +4316,7 @@ func (this *ActivityCoAntroller) ActivityAppointmentAdd() {
 	br.Success = true
 	if hasPermission == 1 {
 		br.Msg = "请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
+		resp.PopupMsg = "会议纪要预约成功<br/><br/>请关注【查研观向小助手】公众号,若有调研纪要发布/更新,将及时为您推送微信消息"
 	}
 	br.Data = resp
 }
@@ -4662,3 +4566,67 @@ func (this *ActivityCoAntroller) ActivityVideoHistoryAdd() {
 	br.Msg = "操作成功"
 	return
 }
+
+// @Title 活动、专项调研搜索
+// @Description 活动、专项调研搜索接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  false       "搜索关键词 多个用 , 隔开"
+// @Success 200 {object} models.GetCygxActivityListRep
+// @router /listSearch [get]
+func (this *ActivityCoAntroller) ActivityListSearch() {
+	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"
+		return
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	source, _ := this.GetInt("Source")
+	keyWord := this.GetString("KeyWord")
+	playBack, _ := this.GetInt("PlayBack")
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+	var condition string
+	//活动可见限制
+	conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "", "", 0, 1, keyWord, playBack)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
+		return
+	}
+	if source == 1 {
+		condition += ` AND art.yidong_activity_id = '' `
+	}
+	condition += ` AND art.is_limit_people = 1 AND art.publish_status = 1 ` + conditionActivity
+	list, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, keyWord)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(models.GetCygxActivityListRep)
+	//添加活动搜索记录
+	if keyWord != "" {
+		go services.AddActivitykeyWordSearch(keyWord, user)
+	}
+	resp.Paging = page
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 348 - 0
controllers/activity_special.go

@@ -0,0 +1,348 @@
+package controllers
+
+import (
+	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"time"
+)
+
+//专项调研活动
+type ActivitySpecialCoAntroller struct {
+	BaseAuthController
+}
+
+// @Title 专项产业调研列表
+// @Description 获取专项产业调研列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.GetCygxActivitySpecialDetailListResp
+// @router /list [get]
+func (this *ActivitySpecialCoAntroller) SpecialList() {
+	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"
+		return
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	list, total, errList := services.GetActivitySpecialList(user, currentIndex, pageSize, "")
+	if errList != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + errList.Error()
+		return
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(models.GetCygxActivitySpecialDetailListResp)
+	count, err := models.GetCygxUserFollowSpecial(user.UserId)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+		return
+	}
+	if count == 1 && user.UserId > 0 {
+		resp.IsFollow = true
+	}
+	if user.Mobile != "" {
+		resp.IsBindingMobile = true
+	}
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title  专项产业调研详情
+// @Description 获取专项产业调研详情接口
+// @Param   ActivityId   query   int  true       "活动ID"
+// @Success Ret=200 {object} models.CygxActivitySpecialResp
+// @router /detail [get]
+func (this *ActivitySpecialCoAntroller) SpecialDetail() {
+	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
+	}
+	uid := user.UserId
+	activityId, _ := this.GetInt("ActivityId")
+	if activityId < 1 {
+		br.Msg = "请输入活动ID"
+		return
+	}
+	resp := new(models.CygxActivitySpecialResp)
+	activityInfo, err := models.GetCygxActivitySpecialDetailById(uid, activityId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if activityInfo == nil {
+		br.Msg = "活动不存在"
+		br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	havePower, err := services.GetSpecialDetailUserPower(user, activityInfo)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+		return
+	}
+	//判断有没有对应的权限,如果没有则给出对应的状态码
+	if havePower {
+		resp.HasPermission = 1
+		count, err := models.GetCygxUserFollowSpecial(user.UserId)
+		if err != nil {
+			br.Msg = "获取数据失败!"
+			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+			return
+		}
+		if count == 1 {
+			resp.IsFollow = true
+		}
+		activityInfo, err := services.HandleActivitySpecialShow(activityInfo, user)
+		if err != nil {
+			br.Msg = "获取数据失败!"
+			br.ErrMsg = "HandleActivitySpecialShow,Err:" + err.Error()
+			return
+		}
+		var condition string
+		var pars []interface{}
+
+		condition += ` AND t.activity_id =  ? AND t.is_cancel = 0 `
+		pars = append(pars, activityInfo.ActivityId)
+
+		tripTota, err := models.GetActivitySpecialTripCountByActivityId(condition, pars)
+		if err != nil {
+			br.Msg = "获取数据失败!"
+			br.ErrMsg = "GetActivitySpecialTripCountByActivityId,Err:" + err.Error()
+			return
+		}
+		activityInfo.TripNum = tripTota
+		activityInfo.ActivityTypeName = "专项调研"
+		resp.Detail = activityInfo
+		resp.Detail = activityInfo
+	} else {
+		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		resp.PopupMsg = popupMsg
+		resp.HasPermission = hasPermission
+		resp.SellerName = sellerName
+		resp.SellerMobile = sellerMobile
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title报名
+// @Description 报名
+// @Param	request	body models.ActivityIdRep true "type json string"
+// @Success Ret=200 {object} models.SignupSpecialStatus
+// @router /add [post]
+func (this *ActivitySpecialCoAntroller) SpecialTripAdd() {
+	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
+	}
+	uid := user.UserId
+	var req models.ActivityIdRep
+	resp := new(models.SignupSpecialStatus)
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	activityInfo, errInfo := models.GetCygxActivitySpecialDetail(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+
+	havePower, err := services.GetSpecialDetailUserPower(user, activityInfo)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+		return
+	}
+
+	//判断有没有对应的权限,如果没有则给出对应的状态码
+	if havePower {
+		resp.HasPermission = 1
+		signupStatus, popupMsg, popupMsg2, err := services.SpecialTripPopupMsg(activityInfo, user)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "SpecialTripPopupMsg,Err:" + err.Error()
+			return
+		}
+		resp.PopupMsg = popupMsg
+		resp.PopupMsg2 = popupMsg2
+		resp.SignupStatus = signupStatus
+
+		if signupStatus == 1 {
+			total, err := models.GetUserActivitySpecialTripCount(user.UserId, activityId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
+				return
+			}
+			//判断是删除还是添加
+			if total == 0 {
+				//获取销售信息
+				sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+				if err != nil {
+					br.Msg = "操作失败"
+					br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+					return
+				}
+				item := new(models.CygxActivitySpecialTrip)
+				item.UserId = uid
+				item.RealName = user.RealName
+				item.ActivityId = activityId
+				item.CreateTime = time.Now()
+				item.Mobile = user.Mobile
+				item.Email = user.Email
+				item.CompanyId = user.CompanyId
+				item.CompanyName = user.CompanyName
+				item.IsValid = 1
+				if sellerItem != nil {
+					item.SellerName = sellerItem.RealName
+				}
+				err = models.AddCygxActivitySpecialTrip(item)
+				if err != nil {
+					br.Msg = "操作失败"
+					br.ErrMsg = "操作失败,Err:" + err.Error()
+					return
+				}
+				//SignupStatus  int    `description:"返回状态:1:成功 、2 :人数已满 、3:调研次数已用完、 4:超时"`
+			} else {
+				updateParams := make(map[string]interface{})
+				updateParams["IsValid"] = 1
+				updateParams["CreateTime"] = time.Now()
+				updateParams["IsCancel"] = 0
+				whereParam := map[string]interface{}{"user_id": user.UserId, "activity_id": activityId}
+				err = models.UpdateByExpr(models.CygxActivitySpecialTrip{}, whereParam, updateParams)
+				if err != nil {
+					br.Msg = "报名失败,"
+					br.ErrMsg = "二次报名,更改报名是否有效状态失败,Err:" + err.Error()
+					return
+				}
+			}
+		}
+	} else {
+		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		resp.PopupMsg = popupMsg
+		resp.HasPermission = hasPermission
+		resp.SellerName = sellerName
+		resp.SellerMobile = sellerMobile
+	}
+	resp.ActivityId = activityId
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+	br.Data = resp
+}
+
+// @Title 取消报名
+// @Description 取消报名
+// @Param	request	body models.ActivityIdRep true "type json string"
+// @Success Ret=200 {object} models.SignupStatus
+// @router /trip/cancel [post]
+func (this *ActivitySpecialCoAntroller) Tripcancel() {
+	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
+	}
+	uid := user.UserId
+	var req models.ActivityIdRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	activityInfo, errInfo := models.GetCygxActivitySpecialDetailById(uid, activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+	resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
+	//48小时之内的取消也扣除一次参会记录
+	var isValid int
+	if time.Now().Add(+time.Hour * 48).After(resultTime) {
+		isValid = 1
+	}
+	err = models.CancelActivitySpecialTripIsValid(isValid, activityInfo.ActivityId, uid)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "CancelActivitySpecialTrip,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "已取消"
+}

+ 6 - 4
controllers/micro_roadshow.go

@@ -23,6 +23,7 @@ type MicroRoadShowController struct {
 // @Param   AudioId			query	int		false	"音频ID"
 // @Param   VideoId			query	int		false	"视频ID"
 // @Param   ActivityVideoId			query	int		false	"活动视频ID"
+// @Param   Filter			query	int		false	"筛选条件 0:全部 1:视频 2:音频"
 // @Success 200 {object} models.HomeListResp
 // @router /list [get]
 func (this *MicroRoadShowController) List() {
@@ -44,6 +45,7 @@ func (this *MicroRoadShowController) List() {
 	audioId, _ := this.GetInt("AudioId")
 	videoId, _ := this.GetInt("VideoId")
 	activityVideoId, _ := this.GetInt("ActivityVideoId")
+	filter, _ := this.GetInt("Filter", 0)
 
 	if pageSize <= 0 {
 		pageSize = utils.PageSize20
@@ -53,7 +55,7 @@ func (this *MicroRoadShowController) List() {
 	}
 
 	// 微路演列表
-	list, total, e := services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, keywords)
+	list, total, e := services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter, keywords)
 	if e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
@@ -125,9 +127,9 @@ func (this *MicroRoadShowController) List() {
 		}
 
 		//修改产业视频的标题
-		if list[i].Type == 3 && list[i].IndustryName != ""{
-			list[i].Title = "5min"+"【"+ list[i].IndustryName +"】"+"逻辑解析"
-		}
+		//if list[i].Type == 3 && list[i].IndustryName != "" {
+		//	list[i].Title = "5min" + "【" + list[i].IndustryName + "】" + "逻辑解析"
+		//}
 	}
 
 	resp := new(models.MicroRoadShowListResp)

+ 452 - 81
controllers/report.go

@@ -3,6 +3,7 @@ package controllers
 import (
 	"encoding/json"
 	"fmt"
+	"github.com/medivhzhan/weapp/v2"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
@@ -267,6 +268,7 @@ func (this *ReportController) IndustryList() {
 		br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
 		return
 	}
+	mapUPdateTime := make(map[int]string)
 
 	if len(industrialManagementIds) > 0 {
 		// 获取默认图配置
@@ -298,6 +300,28 @@ func (this *ReportController) IndustryList() {
 			}
 			industrialVideoMap[v.IndustryId] = tmp
 		}
+		//获取这些产业下最新更新的文章
+		listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialManagementIds)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			return
+		}
+		for _, v := range listUpdateTime {
+			mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
+		}
+
+		//时间线的更新时间
+		//	maptimelineUPdateTime := make(map[int]string)
+		listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialManagementIds)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			return
+		}
+		for _, v := range listtimelinePublishdate {
+			if mapUPdateTime[v.IndustrialManagementId] != "" {
+				if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
+					mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
+				}
+			}
+		}
 	}
 
 	nowTime := time.Now().Local()
@@ -317,7 +341,7 @@ func (this *ReportController) IndustryList() {
 			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 			return
 		}
-		list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
+		list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
 		recordCount, err := models.GetUserToArticleCount(uid, newArtinfo.ArticleId)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
@@ -408,6 +432,7 @@ func (this *ReportController) IndustryList() {
 // @Title 产业下所关联的文章分类列表
 // @Description 产业下所关联的文章分类列表接口
 // @Param   IndustrialManagementId   query   int  true       "产业ID"
+// @Param   ShowTimeLine   query   int  true       "是否展示时间线 0不展示,1展示"
 // @Success 200 {object} models.IndustrialToArticleCategoryListRep
 // @router /toArticleCategoryList [get]
 func (this *ReportController) ArticleCategoryList() {
@@ -428,6 +453,7 @@ func (this *ReportController) ArticleCategoryList() {
 		br.Msg = "请输入分类ID"
 		return
 	}
+	showTimeLine, _ := this.GetInt("ShowTimeLine", 0)
 
 	detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
 	if err != nil {
@@ -516,6 +542,24 @@ func (this *ReportController) ArticleCategoryList() {
 			videoSimple.ResourceUrl = ""
 		}
 	}
+
+	//detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
+	//if err != nil {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取信息失败,Err:" + err.Error()
+	//	return
+	//}
+
+	//时间线
+	if showTimeLine == 1 {
+		timeLineItem := models.IndustrialToArticleCategoryRep{
+			CategoryId:    99999,
+			MatchTypeName: "时间线",
+		}
+
+		list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
+	}
+
 	resp := new(models.IndustrialToArticleCategoryListRep)
 	resp.List = list
 	resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
@@ -568,7 +612,7 @@ func (this *ReportController) List() {
 	startSize = paging.StartIndex(currentIndex, pageSize)
 	var pars []interface{}
 	var total int
-	resp := new(models.TacticsListResp)
+
 	page := paging.GetPaging(currentIndex, pageSize, total)
 
 	if categoryId < 1 {
@@ -579,93 +623,205 @@ func (this *ReportController) List() {
 		br.Msg = "请输入产业ID"
 		return
 	}
-	//获取该产业下所对应的行业图片
-	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
-	}
+	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
-	}
-	page = paging.GetPaging(currentIndex, pageSize, total)
-	list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
-	if err != nil {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
-		return
-	}
-	//对应分类的所图片
-	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
-	}
-	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)
-	}
+		total, err = models.GetReportIndustrialCount(categoryId, industrialManagementId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
+			return
+		}
+		page = paging.GetPaging(currentIndex, pageSize, total)
+		list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
+			return
+		}
+		//对应分类的所图片
+		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
+		}
+		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)
+		}
+
+		for k, 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.VideoUrl != "" {
+				list[k].IsHaveVideo = true
+			}
+			list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
 
-	for k, 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 mapCategoryUrl[v.CategoryId] == "" {
+				if detail.ChartPermissionId == utils.YI_YAO_ID {
+					list[k].ImgUrlPc = utils.YI_YAO_QI_TA
+				}
+			}
 		}
-		if v.VideoUrl != "" {
-			list[k].IsHaveVideo = true
+
+		resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
+		resp.ChartPermissionId = detail.ChartPermissionId
+		resp.List = list
+		resp.Paging = page
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+	} else {
+		//获取该产业下所对应的行业图片
+		//因为时间线不属于数据表里的二级分类,所以图片Id用产业id查到的list中的任意一个categoryId取到的图片替代
+		categoryList, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+			return
 		}
-		list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
+		var timeLineCategoryId int
+		if len(categoryList) > 0 {
+			timeLineCategoryId = categoryList[0].CategoryId
+		}
+
+		var detail *models.ReportMapping
+		var errCategory error
 
-		if mapCategoryUrl[v.CategoryId] == "" {
-			if detail.ChartPermissionId == utils.YI_YAO_ID {
-				list[k].ImgUrlPc = utils.YI_YAO_QI_TA
+		if timeLineCategoryId > 0 {
+			detail, errCategory = models.GetdetailByCategoryIdOne(timeLineCategoryId)
+			if errCategory != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
+				return
 			}
 		}
-	}
 
-	resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
-	resp.ChartPermissionId = detail.ChartPermissionId
-	resp.List = list
-	resp.Paging = page
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "获取成功"
-	br.Data = resp
+		//对应行业的图片
+		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.GetTimeLineReportIndustrialCount(industrialManagementId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
+			return
+		}
+		page = paging.GetPaging(currentIndex, pageSize, total)
+		list, err := models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
+			return
+		}
+		//对应分类的所图片
+		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
+		}
+
+		//lenList := len(list)
+		//for i := 0; i < lenList; i++ {
+		//	item := list[i]
+		//	list[i].Content, _ = services.GetReportContentTextSub(item.Content)
+		//	//list[i].Abstract = html.UnescapeString(item.Abstract)
+		//	//list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
+		//}
+
+		for k, 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.VideoUrl != "" {
+				list[k].IsHaveVideo = true
+			}
+			id := strconv.Itoa(timeLineCategoryId)
+			list[k].ImgUrlPc = mapCategoryUrl[id]
+
+			if mapCategoryUrl[id] == "" {
+				if detail.ChartPermissionId == utils.YI_YAO_ID {
+					list[k].ImgUrlPc = utils.YI_YAO_QI_TA
+				}
+			}
+		}
+
+		resp := new(models.TimeLineReportListResp)
+		resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
+
+		resp.List = list
+		resp.Paging = page
+		br.Ret = 200
+		br.Success = true
+		br.Msg = "获取成功"
+		br.Data = resp
+	}
 }
 
 // @Title 置顶/取消置顶
@@ -1354,6 +1510,7 @@ func (this *ReportController) IsShow() {
 	resp.IsShowChart = true
 	//resp.IsShowResearch = true
 	resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
+	resp.ActivitySpecialExplain = utils.ACTIVITY_SPECIAL_EXPLAIN
 	//resp.YanXuan_Explain = true
 	resp.IsShowFreeButton = IsShowFreeButton
 	//mobile := user.Mobile
@@ -2690,6 +2847,8 @@ func (this *ReportController) SearchReportAndResource() {
 	sqlGroup = ` GROUP BY  a.article_id  ORDER BY a.publish_date DESC  `
 	if pageSize > 0 {
 		sqlGroup += ` LIMIT 5 `
+	} else {
+		sqlGroup += ` LIMIT 100 `
 	}
 	ListYxReport, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
 	if err != nil {
@@ -2903,3 +3062,215 @@ func (this *ReportController) SearchReportAndResource() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 产业报告公司列表
+// @Description 获取产业报告公司列表接口
+// @Param   ChartPermissionId   query   int  true       "行业id"
+// @Success 200 {object} models.IndustrialManagementList
+// @router /home/stockName [get]
+func (this *ReportController) StockNameList() {
+	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
+	}
+	//uid := user.UserId
+	chartPermissionId, _ := this.GetInt("ChartPermissionId")
+
+	list, err := models.GetSummaryArticle(chartPermissionId)
+	if err != nil {
+		br.Msg = "获取综述报告公司名称失败"
+		br.ErrMsg = "获取综述报告公司名称失败,Err:" + err.Error()
+		return
+	}
+	var respList []*models.SummaryArticleStock
+	for _, item := range list {
+		sliceSubjects := strings.Split(item.Stock, "/")
+		if len(sliceSubjects) > 0 {
+			for i, vSubject := range sliceSubjects {
+				sliceKuohao := strings.Split(vSubject, "(")           //过滤括号
+				sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
+				subject := sliceXiahuaxian[0]
+				if i > 0 {
+					newItem := models.SummaryArticleStock{
+						Id:        item.Id,
+						ArticleId: item.ArticleId,
+						Stock:     subject,
+					}
+
+					respList = append(respList, &newItem)
+				} else {
+					item.Stock = subject
+					respList = append(respList, item)
+				}
+			}
+		}
+
+		//index := strings.Index(item.Stock, "(")
+		//item.Stock = item.Stock[:index]
+		//if strings.Contains(item.Stock, "-B"){
+		//	item.Stock = strings.Replace(item.Stock, "-B", "", -1)
+		//}
+		//if strings.Contains(item.Stock, "-W"){
+		//	item.Stock = strings.Replace(item.Stock, "-W", "", -1)
+		//}
+	}
+	resp := new(models.SummaryArticleStockResp)
+	resp.List = respList
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 文章留言接口
+// @Description 文章留言接口
+// @Param	request	body models.AddCygxActivityHelpAsk true "type json string"
+// @Success 200 {object} models.TacticsListResp
+// @router /commentAdd [post]
+func (this *ReportController) CommentAdd() {
+	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
+	}
+	var req models.AddCygxArticleCommentReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.ArticleId <= 0 {
+		br.Msg = "文章不存在"
+		br.ErrMsg = "文章不存在,文章ID错误"
+		return
+	}
+	if req.Content == "" {
+		br.Msg = "建议内容不可为空"
+		return
+	}
+	content := req.Content
+	itemToken, err := services.WxGetToken()
+	if err != nil {
+		br.Msg = "GetWxAccessToken Err:" + err.Error()
+		return
+	}
+	if itemToken.AccessToken == "" {
+		br.Msg = "accessToken is empty"
+		return
+	}
+	commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
+	if err != nil {
+		br.Msg = "内容校验失败!"
+		br.ErrMsg = "内容校验失败,Err:" + err.Error()
+		return
+	}
+	if commerr.ErrCode != 0 {
+		br.Msg = "内容违规,请重新提交!"
+		br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
+		return
+	}
+
+	articleId := req.ArticleId
+	articleInfo, errInfo := models.GetArticleDetailById(articleId)
+	if articleInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+
+	companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
+	if err != nil {
+		br.Msg = "提交失败!"
+		br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+		return
+	}
+	if companyDetail == nil {
+		br.Msg = "提交失败!"
+		br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
+		return
+	}
+	item := models.CygxArticleComment{
+		UserId:      user.UserId,
+		ArticleId:   req.ArticleId,
+		CreateTime:  time.Now(),
+		Mobile:      user.Mobile,
+		Email:       user.Email,
+		CompanyId:   user.CompanyId,
+		CompanyName: companyDetail.CompanyName,
+		Content:     content,
+	}
+	_, err = models.AddArticleComment(&item)
+	if err != nil {
+		br.Msg = "提交失败"
+		br.ErrMsg = "提交留言失败,Err:" + err.Error()
+		return
+	}
+
+
+	//var sendMobile string
+	//for _, v := range listEmail {
+	//	if strings.Index(activityInfo.Host, v.Name) > 0 {
+	//		sendMobile = v.Mobile
+	//	}
+	//}
+	//if activityInfo.ChartPermissionId == 31 {
+	//	sendMobile = utils.ActSendMsgMobile
+	//}
+
+	//获取销售信息
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "提交失败"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+		return
+	}
+	// 给所属销售发送消息
+	var openIdList []*models.OpenIdList
+	if sellerItem != nil {
+		list, _ := models.GetWxOpenIdByMobileList(sellerItem.Mobile)
+		for _, idList := range list {
+			openIdList = append(openIdList, idList)
+		}
+		if openIdList != nil {
+			// 给芳姐发消息
+			cnf, _ := models.GetConfigByCode("tpl_msg")
+			if cnf != nil {
+				list, _ := models.GetWxOpenIdByMobileList(cnf.ConfigValue)
+				for _, idList := range list {
+					openIdList = append(openIdList, idList)
+				}
+			}
+			if articleId > 1000000{
+				//发给汪洋
+				list, _ := models.GetWxOpenIdByMobileList( utils.ActSendMsgMobile)
+				for _, idList := range list {
+					openIdList = append(openIdList, idList)
+				}
+			}
+			services.SendCommentWxTemplateMsg(articleInfo.Title, user.CompanyName, user.RealName, sellerItem.RealName, item.CreateTime.Format(utils.FormatDateTime), req.Content, openIdList, req.ArticleId)
+		}
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "提交成功"
+}

+ 14 - 0
controllers/user.go

@@ -227,6 +227,11 @@ func (this *UserController) Detail() {
 			br.ErrMsg = "获取信息失败,Err:" + err.Error()
 			return
 		}
+		if detail == nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:用户不存在"
+			return
+		}
 
 		userRecord, _ := models.GetUserRecordByUserId(uid, utils.WxPlatform)
 		if userRecord != nil {
@@ -280,6 +285,15 @@ func (this *UserController) Detail() {
 				//}
 				detail.SellerName = companyItem.SellerName
 				detail.SellerMobile = companyItem.Mobile
+
+				tatolSpecil, err := services.GetSpecialTripUserSchedule(user.UserId)
+				if err != nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+					return
+				}
+				detail.ScheduleNum += tatolSpecil
+
 			} else {
 				hasPermission = 1
 			}

+ 171 - 45
models/activity.go

@@ -191,6 +191,9 @@ type ActivityDetail struct {
 	VisibleRange            int                        `description:"可见范围 1,仅本组可见 、2,全部客户可见"`
 	VideoDetail             *CygxActivityVideoListResp `description:"视频数据"`
 	FileType                int                        `description:"类型: 1-音频; 2-视频"`
+	SourceType              int                        `description:"活动来源。 1:活动 、2:专项产业调研"`
+	TripImgLink             string                     `description:"专项产业调研行程链接"`
+	ActivityTimeEnd         string                     `description:"专项产业调研活动预期结束时间"`
 }
 
 type CygxActivityResp struct {
@@ -365,6 +368,71 @@ func GetScheduleList(condition string, pars []interface{}, uid, startSize, pageS
 	return
 }
 
+//我的日程列表 活动以及专项调研一起
+func GetScheduleAndSpecilList(condition string, pars []interface{}, conditionSpecil string, parsSpecil []interface{}, startSize, pageSize int) (items []*ActivityDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			art.activity_id,
+			art.activity_time_text,
+			art.activity_name,
+			art.chart_permission_id,
+			art.active_state,
+			t.activity_type,
+			art.chart_permission_name,
+			art.distinguished_guest,
+			art.expert,
+			art.speaker,
+			"" AS trip_img_link,
+			"" AS activity_time_end,
+			art.yidong_activity_id,
+			art.is_can_appointment_minutes,
+			art.activity_type_id,
+			art.limit_people_num,
+			1 AS source_type,
+			art.activity_time 
+		FROM
+			cygx_activity AS art
+			INNER JOIN cygx_my_schedule AS my ON my.activity_id = art.activity_id
+			INNER JOIN cygx_activity_type AS t ON t.activity_type_id = art.activity_type_id
+			INNER JOIN chart_permission AS c ON c.chart_permission_id = art.chart_permission_id 
+		WHERE
+			1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` UNION ALL
+		SELECT
+			art.activity_id,
+			art.activity_time_text_by_day AS activity_time_text,
+			art.research_theme AS activity_name,
+			art.chart_permission_id,
+			"",
+			art.special_type AS activity_type,
+			art.chart_permission_name,
+			"",
+			"",
+			"",
+			art.trip_img_link_fix AS trip_img_link,
+			art.activity_time_end,
+			"",
+			"",
+			"",
+			"",
+			2 AS source_type,
+			art.activity_time 
+		FROM
+			cygx_activity_special AS art
+			INNER JOIN cygx_activity_special_trip AS my ON my.activity_id = art.activity_id 
+		WHERE
+			1 = 1`
+	if conditionSpecil != "" {
+		sql += conditionSpecil
+	}
+	sql += ` ORDER BY activity_time DESC   LIMIT ?,?`
+	_, err = o.Raw(sql, pars, parsSpecil, startSize, pageSize).QueryRows(&items)
+	return
+}
+
 //获取数量
 func GetActivityCountById(activityId int) (count int, err error) {
 	o := orm.NewOrm()
@@ -401,7 +469,6 @@ func UpdateActivitySattusToHaveInHand() (err error) {
 	condition += ` OR(activity_type_id IN ( 4, 5, 6 ) AND  activity_time > ` + "'" + resultTime_60 + "'" + sqlOr + ")"
 	msql := " UPDATE cygx_activity SET active_state = 2 WHERE 1 = 1 " + condition
 	_, err = o.Raw(msql).Exec()
-
 	return
 }
 
@@ -621,12 +688,14 @@ type CygxActivityLabelList struct {
 	Resource          int    `description:"位置 ,1:活动 ,2:专项产业调研"`
 	TemporaryLabel    string `description:"临时标签"`
 	IsNew             bool   `description:"是否为新:活动存在关联的的产业所关联的报告均在3个月内/无报告则标记新"`
+	YidongActivityId   int   `description:"易董活动ID"`
+	IsExternalLabel   bool   `description:"是否为外部资源"`
 }
 
 //主题列表
 func GetActivityLabelListAll(condition, sortTime string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityLabelList, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT	activity_id, label,temporary_label,is_show_subject_name, MAX( art.activity_time ) AS timesort, MIn( art.activity_time ) AS mintimesort 
+	sql := `SELECT	activity_id, label,temporary_label,is_show_subject_name, MAX( art.activity_time ) AS timesort, MIn( art.activity_time ) AS mintimesort , yidong_activity_id 
 		FROM cygx_activity as art WHERE 1= 1 `
 	if condition != "" {
 		sql += condition
@@ -724,31 +793,11 @@ func GetActivityLabelSpecialListAll(condition string, pars []interface{}, startS
 	if condition != "" {
 		sql += condition
 	}
-	sql += ` ORDER BY art.last_updated_time DESC  LIMIT ?,? `
+	sql += `  LIMIT ?,? `
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
 
-//专项调研活动列表
-type CygxActivitySpecialDetail struct {
-	ActivityId            int    `description:"活动ID "`
-	ActivityTypeName      string `description:"活动名称"`
-	SpecialType           int    `description:"调研形式、 1 线上 , 2 线下"`
-	City                  string `description:"调研城市"`
-	ChartPermissionName   string `description:"行业名称"`
-	ResearchTheme         string `description:"调研主题"`
-	ActivityTimeText      string `description:"活动预期时间带文字"`
-	TripImgLink           string `description:"行程图片链接"`
-	IsSignup              int    `description:"是否感兴趣 1是 ,0 否"`
-	Label                 string `description:"主题标签"`
-	ImgUrl                string `description:"图片链接"`
-	ImgUrlText            string `description:"图片链接文字"`
-	IndustrialName        string `description:"产业名称"`
-	IndustrialSubjectName string `description:"标的名称(相关公司)"`
-	Scale                 string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
-	CustomerTypeIds       string `description:"活动可见的客户类型,多个ID用 , 隔开"`
-}
-
 type GetCygxActivitySpecialDetailListResp struct {
 	IsFollow        bool               `description:"是否关注新调研通知"`
 	IsBindingMobile bool               `description:"是否绑定了手机号"`
@@ -768,17 +817,6 @@ type CygxActivitySpecialResp struct {
 	Detail            *CygxActivitySpecialDetail
 }
 
-//获取数量
-func GetActivitySpecialCount(condition string, pars []interface{}) (count int, err error) {
-	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity_special as art WHERE 1= 1  `
-	if condition != "" {
-		sqlCount += condition
-	}
-	o := orm.NewOrm()
-	err = o.Raw(sqlCount, pars).QueryRow(&count)
-	return
-}
-
 //获取专项调研活动列表
 func GetCygxActivitySpecialDetailList(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*CygxActivitySpecialDetail, err error) {
 	o := orm.NewOrm()
@@ -802,8 +840,8 @@ WHERE
 	if condition != "" {
 		sql += condition
 	}
-	sql += ` ORDER BY art.last_updated_time DESC  LIMIT ?,? `
-	_, err = o.Raw(sql, pars, uid, startSize, pageSize).QueryRows(&items)
+	sql += `  LIMIT ?,? `
+	_, err = o.Raw(sql, uid, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
 
@@ -815,7 +853,7 @@ FROM
 	cygx_activity_special AS a 
 WHERE
 	activity_id = ?
-	AND publish_status = 1`
+	AND publish_status = 1 	AND is_offline = 0  `
 	err = o.Raw(sql, uid, ActivityId).QueryRow(&item)
 	return
 }
@@ -828,14 +866,6 @@ func GetCygxActivitySpecialDetail(ActivityId int) (item *CygxActivitySpecialDeta
 	return
 }
 
-//列表
-func GetActivityList() (items []*CygxActivityList, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT  *  FROM cygx_activity`
-	_, err = o.Raw(sql).QueryRows(&items)
-	return
-}
-
 func UpdateCygxActivityName(activityId int, Name string) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE cygx_activity SET activity_name_task = ? WHERE activity_id=?  `
@@ -915,3 +945,99 @@ func UpdateActivityshowSubject(activityId int) (err error) {
 	_, err = o.Raw(sql, activityId).Exec()
 	return
 }
+
+//GetActivitySpecialSearcheList 活动与专项调研的搜索
+func GetActivitySpecialSearcheList(condition string, pars []interface{}, conditionSpecil string, parsSpecil []interface{}, startSize, pageSize int) (items []*ActivityDetail, total int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			art.activity_id,
+			art.activity_time_text,
+			art.activity_name,
+			art.chart_permission_id,
+			art.active_state,
+			t.activity_type,
+			art.chart_permission_name,
+			art.distinguished_guest,
+			art.expert,
+			art.speaker,
+			"" AS trip_img_link,
+			"" AS activity_time_end,
+			art.yidong_activity_id,
+			art.is_can_appointment_minutes,
+			art.activity_type_id,
+			art.limit_people_num,
+			1 AS source_type,
+			art.activity_time 
+		FROM
+			cygx_activity AS art
+			INNER JOIN cygx_activity_type AS t ON t.activity_type_id = art.activity_type_id
+		WHERE
+			1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` UNION ALL
+		SELECT
+			art.activity_id,
+			art.activity_time_text_by_day AS activity_time_text,
+			art.research_theme AS activity_name,
+			art.chart_permission_id,
+			"",
+			art.special_type AS activity_type,
+			art.chart_permission_name,
+			"",
+			"",
+			"",
+			art.trip_img_link_fix AS trip_img_link,
+			art.activity_time_end,
+			"",
+			"",
+			"",
+			"",
+			2 AS source_type,
+			art.activity_time 
+		FROM
+			cygx_activity_special AS art
+		WHERE
+			1 = 1 `
+	if conditionSpecil != "" {
+		sql += conditionSpecil
+	}
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql, pars, parsSpecil).QueryRow(&total)
+	if err != nil {
+		return
+	}
+	sql += ` ORDER BY activity_time DESC   LIMIT ?,?`
+	_, err = o.Raw(sql, pars, parsSpecil, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+//列表
+func GetActivityListNew(condition string, pars []interface{}, uid, startSize, pageSize, playBack, filter int) (items []*ActivityDetail, err error) {
+	var sqlJiontable string
+	if playBack == 1 {
+		//sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
+	}
+	if filter == 1 {
+		sqlJiontable = ` INNER JOIN cygx_activity_video AS av ON av.activity_id = art.activity_id `
+	} else if filter == 2 {
+		sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
+	}
+
+	o := orm.NewOrm()
+	sql := `SELECT art.* ,t.activity_type,t.img_url_text,c.image_url as  img_url,
+		( SELECT COUNT( 1 ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id AND s.user_id = ?   AND s.is_cancel = 0  AND s.do_fail_type = 0) AS is_signup,
+		( SELECT COUNT( DISTINCT user_id ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id   AND s.is_cancel = 0  AND s.do_fail_type = 0) AS signup_num,
+		( SELECT COUNT( 1 ) FROM cygx_activity_meeting_reminder AS m WHERE m.activity_id = art.activity_id AND m.user_id = ?  AND m.is_cancel = 0  ) AS is_cancel_meeting_reminder,
+		( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment
+		FROM cygx_activity as art
+		INNER JOIN cygx_activity_type  as t ON t.activity_type_id = art.activity_type_id
+		INNER JOIN  chart_permission  AS c ON c.chart_permission_id = art.chart_permission_id ` + sqlJiontable + ` WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, uid, uid, uid, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 13 - 2
models/activity_appointment.go

@@ -198,7 +198,7 @@ func GetCygxAppointmentSummaryListBySubjectId(subjectIds string) (item []*CygxAp
 
 type CygxAppointment struct {
 	Mobile         string `description:"手机号"`
-	UserId         int `description:"userId"`
+	UserId         int    `description:"userId"`
 	ActivityName   string `description:"所属销售"`
 	ActivityTypeId int    `description:"活动类型"`
 }
@@ -223,4 +223,15 @@ func GetCygxAppointmentSummaryBySubjectId(subjectIds string) (item []*CygxAppoin
 			ap.activity_id `
 	_, err = o.Raw(sql).QueryRows(&item)
 	return
-}
+}
+
+//GetCygxAppointmentListByUser 获取预约纪要的人
+func GetCygxAppointmentListByUser(condition string, pars []interface{}) (item []*CygxActivityAppointment, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *
+			FROM
+			cygx_activity_appointment  
+			WHERE 1 = 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&item)
+	return
+}

+ 11 - 0
models/activity_meeting_reminder.go

@@ -154,3 +154,14 @@ func GetUserActivityMeetingReminderCount(uid int) (count int, err error) {
 	err = o.Raw(sqlCount, uid).QueryRow(&count)
 	return
 }
+
+//GetCygxReminderListByUser 获取设置会议提醒的人
+func GetCygxReminderListByUser(condition string, pars []interface{}) (item []*CygxActivityMeetingReminder, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *
+			FROM
+			cygx_activity_meeting_reminder  
+			WHERE 1 = 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&item)
+	return
+}

+ 10 - 0
models/activity_signup.go

@@ -349,6 +349,16 @@ func GetActivitySignupDetail(activityId, uid int) (item *CygxActivitySignup, err
 	return
 }
 
+func GetActivitySignuListByUser(condition string, pars []interface{}) (item []*CygxActivitySignup, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *
+			FROM
+			cygx_activity_signup  
+			WHERE 1 = 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&item)
+	return
+}
+
 //解除报名限制之后二次报名
 func AddActivitySignupByRestrict(item *CygxActivitySignup) (lastId int64, err error) {
 	o, err := orm.NewOrm().Begin()

+ 73 - 0
models/activity_special.go

@@ -0,0 +1,73 @@
+package models
+
+import (
+	//"fmt"
+	"github.com/beego/beego/v2/client/orm"
+)
+
+//专项调研活动列表
+type CygxActivitySpecialDetail struct {
+	ActivityId            int    `description:"活动ID "`
+	ActivityTypeName      string `description:"活动名称"`
+	SpecialType           int    `description:"调研形式、 1 线上 , 2 线下"`
+	City                  string `description:"调研城市"`
+	ChartPermissionName   string `description:"行业名称"`
+	ChartPermissionId     string `description:"行业Id"`
+	ResearchTheme         string `description:"调研主题"`
+	ActivityTimeText      string `description:"活动预期时间带文字"`
+	TripImgLink           string `description:"行程图片链接"`
+	IsSignup              int    `description:"是否感兴趣 1是 ,0 否"`
+	Label                 string `description:"主题标签"`
+	ImgUrl                string `description:"图片链接"`
+	ImgUrlText            string `description:"图片链接文字"`
+	IndustrialName        string `description:"产业名称"`
+	IndustrialSubjectName string `description:"标的名称(相关公司)"`
+	Scale                 string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
+	CustomerTypeIds       string `description:"活动可见的客户类型,多个ID用 , 隔开"`
+	IsTrip                int    `description:"是否报名 1是 ,0 否"`
+	TripNum               int    `description:"已报名人数"`
+	Days                  int    `description:"调研天数"`
+	Host                  string `description:"主持人"`
+	PersonInCharge        string `description:"纪要负责人"`
+	LimitPeopleNum        int    `description:"限制人数数量"`
+	TripImgLinkFix        string `description:"确定行程之后的图片链接"`
+	ActivityTimeTextByDay string `description:"活动预期时间带周日"`
+	ActivityTime          string `description:"活动预期时间"`
+	ActivityTimeEnd       string `description:"活动预期结束时间"`
+	ActiveState           int    `description:"活动进行状态 未开始:1、进行中2、已结束3"`
+	TripStatus            int    `description:"行程进行状态 1:预报名,2:确定行程"`
+	Explain               string `description:"说明"`
+	AdminId               int    `description:"管理员ID"`
+}
+
+//获取数量
+func GetActivitySpecialCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity_special as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+//主题列表
+func GetActivitySpecialListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivitySpecialDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT	*
+		FROM cygx_activity_special as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY art.last_updated_time DESC  LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+//修改发布状态
+func UpdateActivitySpecialPublishStatus(publishStatus, activityId int) (err error) {
+	sql := ` UPDATE cygx_activity_special SET  publish_status= ?  WHERE activity_id = ?`
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, publishStatus, activityId).Exec()
+	return
+}

+ 10 - 0
models/activity_special_signup.go

@@ -22,9 +22,11 @@ type SignupSpecialStatus struct {
 	ActivityId    int    `description:"活动ID"`
 	HasPermission int    `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
 	PopupMsg      string `description:"权限弹窗信息"`
+	PopupMsg2     string `description:"权限弹窗信息"`
 	Status        int    `description:"返回类型,1:添加,2:取消"`
 	SellerMobile  string `description:"销售电话"`
 	SellerName    string `description:"销售姓名"`
+	SignupStatus  int    `description:"返回状态:1:成功 、2 :人数已满 、3:调研次数已用完、 4:超时"`
 }
 
 //添加
@@ -58,6 +60,14 @@ func GetActivityListSpecialAll(activityId int) (items []*CygxActivitySpecialSign
 	return
 }
 
+//列表
+func GetActivityListSpecialByActivityId(activityId int) (items []*CygxActivitySpecialSignup, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT art.*  FROM cygx_activity_special_signup as art WHERE 1= 1 AND  activity_id = ? `
+	_, err = o.Raw(sql, activityId).QueryRows(&items)
+	return
+}
+
 type CygxActivitySpecialSignupResp struct {
 	Id          int       `orm:"column(id);pk"`
 	ActivityId  int       `description:"活动ID"`

+ 116 - 0
models/activity_special_trip.go

@@ -0,0 +1,116 @@
+package models
+
+import (
+	//"hongze/hongze_admin/models"
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivitySpecialTrip struct {
+	Id             int       `orm:"column(id);pk"`
+	UserId         int       `description:"用户id,多个用,隔开"`
+	ActivityId     int       `description:"活动ID"`
+	CreateTime     time.Time `description:"创建时间"`
+	Mobile         string    `description:"手机号"`
+	Email          string    `description:"邮箱号"`
+	CompanyId      int       `description:"公司ID"`
+	CompanyName    string    `description:"公司名称"`
+	RealName       string    `description:"用户实际名称"`
+	SellerName     string    `description:"所属销售"`
+	AdminId        int       `description:"销售/管理员ID"`
+	Source         int       `description:"来源,1小程序,2后台添加"`
+	OutboundMobile string    `description:"外呼手机号"`
+	CountryCode    string    `description:"手机国家区号"`
+	IsCancel       string    `description:"是否取消,1是,0否"`
+	IsValid        int       `description:"参会报名是否有效 1:是,0"`
+}
+
+type CygxActivitySpecialTripResp struct {
+	Id             int    `description:"ID"`
+	UserId         int    `description:"用户id"`
+	ActivityId     int    `description:"活动ID"`
+	CreateTime     string `description:"创建时间"`
+	Mobile         string `description:"手机号"`
+	Email          string `description:"邮箱号"`
+	CompanyId      int    `description:"公司ID"`
+	CompanyName    string `description:"公司名称"`
+	RealName       string `description:"用户实际名称"`
+	SellerName     string `description:"所属销售"`
+	OutboundMobile string `description:"外呼手机号"`
+	CountryCode    string `description:"手机国家区号"`
+}
+
+func GetCygxActivitySpecialTripList(condition string, pars []interface{}) (item []*CygxActivitySpecialTripResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *
+			FROM
+			cygx_activity_special_trip  
+			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 =? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
+	return
+}
+
+//获取某一活动的报名的数量
+func GetActivitySpecialTripCountByActivityId(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_trip as t   INNER JOIN wx_user as  u on u.user_id = t.user_id WHERE    1 = 1 ` + condition
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+//获取某一活动的报名的数量 (同时关联活动类型进行获取)
+func GetActivitySpecialTripCountByActivitySpecial(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count
+		FROM
+			cygx_activity_special_trip AS t
+			INNER JOIN cygx_activity_special AS a ON a.activity_id = t.activity_id 
+		WHERE
+			 1= 1 ` + condition
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+//获取空降的公司报名的记录
+func GetActivitySpecialTripAirborneCountByActivitySpecial(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count
+		FROM
+			cygx_activity_special_meeting_detail AS t
+			INNER JOIN cygx_activity_special AS a ON a.activity_id = t.activity_id 
+		WHERE
+			 1= 1 ` + condition
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+//添加
+func AddCygxActivitySpecialTrip(item *CygxActivitySpecialTrip) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+//取消
+func CancelActivitySpecialTrip(uid int, item *CygxActivitySpecialDetail) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE  FROM cygx_activity_special_trip   WHERE user_id=?  AND activity_id=? `
+	_, err = o.Raw(sql, uid, item.ActivityId).Exec()
+	return
+}
+
+//CancelActivitySpecialTripIsValid  处理活动报名是否有效
+func CancelActivitySpecialTripIsValid(isValid, activityId, userId int) (err error) {
+	sql := ` UPDATE cygx_activity_special_trip SET  is_valid= ?,is_cancel = 1  WHERE activity_id = ? AND  user_id = ? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, isValid, activityId, userId).Exec()
+	return
+}

+ 30 - 0
models/article.go

@@ -45,6 +45,7 @@ type CygxArticle struct {
 	FieldName        string `description:"产业标签"`
 	Annotation       string `description:"核心观点"`
 	TypeName         string `description:"策略平台报告类型"`
+	ModifyTimeByCl   string `description:"策略平台报告更新时间"`
 }
 
 type CygxArticleEs struct {
@@ -535,6 +536,8 @@ type ArticleResultApidate struct {
 	Stock         []string                 `json:"stock"`
 	Field         ArticleField             `json:"field"`
 	Corpus        Corpus                   `json:"corpus"`
+	Cover         string                   `json:"cover"`
+	TypeId        int                      `json:"type_id"`
 }
 
 type ArticleField struct {
@@ -651,3 +654,30 @@ func UpdateIsClassFail(articleId int) (err error) {
 	_, err = o.Raw(sql, articleId).Exec()
 	return
 }
+
+type SummaryArticleStock struct {
+	Id        int    `description:"新ID"`
+	ArticleId int    `description:"文章id"`
+	Stock     string `description:"个股标签"`
+}
+
+//综述报告
+func GetSummaryArticle(chartPermissionId int) (items []*SummaryArticleStock, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	* 
+FROM
+	cygx_article AS c
+	INNER JOIN cygx_report_mapping AS m 
+WHERE
+	c.type_name = '综述报告' 
+	AND m.category_id = c.category_id_two 
+	AND m.chart_permission_id = ? ORDER BY modify_time_by_cl DESC `
+
+	_, err = o.Raw(sql, chartPermissionId).QueryRows(&items)
+	return
+}
+
+type SummaryArticleStockResp struct {
+	List []*SummaryArticleStock
+}

+ 32 - 0
models/article_comment.go

@@ -0,0 +1,32 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxArticleComment struct {
+	Id       int       `orm:"column(id);pk" description:"留言id"`
+	UserId      int       `description:"用户id"`
+	ArticleId  int       `description:"活动id"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	Content     string    `description:"内容"`
+}
+
+
+//添加留言
+func AddArticleComment(item *CygxArticleComment) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+
+type AddCygxArticleCommentReq struct {
+	ArticleId int    `description:"文章id"`
+	Content    string `description:"内容"`
+}

+ 28 - 0
models/article_data.go

@@ -0,0 +1,28 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxArticleData struct {
+	Id         int       `orm:"column(id);pk"`
+	ArticleId  int       `description:"文章id"`
+	CreateTime time.Time `description:"创建时间"`
+	Cover      string    `description:"封面图片,公司logo"`
+}
+
+//新增文章
+func AddCygxArticleData(item *CygxArticleData) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+//获取数量
+func GetCygxArticleDataCount(articcleId int) (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_data WHERE article_id=? `
+	err = o.Raw(sqlCount, articcleId).QueryRow(&count)
+	return
+}

+ 127 - 0
models/company_activity_trip.go

@@ -0,0 +1,127 @@
+package models
+
+import "github.com/beego/beego/v2/client/orm"
+
+func GetCountCompanyDetailByIdGroupTrip(companyId int) (count int, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT
+	COUNT( 1 ) AS count 
+FROM
+	company AS a
+	INNER JOIN company_product AS b ON a.company_id = b.company_id
+	INNER JOIN company_report_permission AS p ON p.company_id = a.company_id
+	INNER JOIN chart_permission AS cp ON cp.chart_permission_id = p.chart_permission_id
+	LEFT JOIN admin AS c ON b.seller_id = c.admin_id 
+WHERE
+	a.company_id = ? 
+	AND b.product_id = 2 
+	AND b.status = '正式' 
+	AND p.is_upgrade =  1
+	OR (
+		a.company_id = ? 
+	AND b.product_id = 2 
+	AND b.status = '永续') `
+	err = o.Raw(sql, companyId, companyId).QueryRow(&count)
+	return
+}
+
+func GetCompanyDetailByIdGroupTrip(companyId int) (item *CompanyDetail, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT a.company_id,a.company_name,b.status,b.seller_id,b.seller_name,c.mobile ,b.is_suspend
+            FROM company AS a
+			INNER JOIN company_product AS b ON a.company_id=b.company_id
+			INNER JOIN company_report_permission AS p ON p.company_id = a.company_id
+			INNER JOIN chart_permission AS cp ON cp.chart_permission_id = p.chart_permission_id
+			LEFT JOIN admin AS c ON b.seller_id=c.admin_id
+			WHERE a.company_id=? AND b.product_id = 2  
+			ORDER BY b.product_id DESC  LIMIT 0,1  `
+	err = o.Raw(sql, companyId).QueryRow(&item)
+	return
+}
+
+func GetCompanyPermissionByUserTrip(companyId int) (permission string, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT
+			GROUP_CONCAT( DISTINCT b.remark ORDER BY b.sort ASC SEPARATOR ',' ) AS permission 
+		FROM
+			company_report_permission AS a
+			INNER JOIN chart_permission AS b ON a.chart_permission_id = b.chart_permission_id
+			INNER JOIN company_product AS c ON a.company_id = c.company_id 
+			AND a.product_id = c.product_id 
+		WHERE
+			a.company_id = ? 
+			AND c.is_suspend = 0 
+			AND b.cygx_auth = 1 
+			AND a.is_upgrade = 1 
+			AND c.STATUS IN ( '正式' ) 
+			OR ( a.company_id = ? AND c.is_suspend = 0 AND b.cygx_auth = 1 AND c.STATUS IN ( '永续' ) ) 
+			OR ( a.company_id = ? AND c.is_suspend = 0 AND b.cygx_auth = 1 AND b.chart_permission_name = '策略' AND c.STATUS IN ( '正式' ) )`
+	err = o.Raw(sql, companyId, companyId, companyId).QueryRow(&permission)
+	return
+}
+
+//获取正式权限
+func GetCompanyPermissionByUserZhengShiTrip(companyId int) (permission string, err error) {
+	sql := ` SELECT GROUP_CONCAT(DISTINCT b.remark  ORDER BY b.sort ASC  SEPARATOR ',') AS permission
+			FROM company_report_permission AS a
+			INNER JOIN chart_permission AS b ON a.chart_permission_id=b.chart_permission_id
+			INNER JOIN company_product AS c ON a.company_id=c.company_id AND a.product_id=c.product_id
+			WHERE  a.company_id=?
+			AND c.is_suspend=0
+            AND b.cygx_auth=1
+			AND a.is_upgrade = 1 
+			AND c.status IN('正式')  `
+	o := orm.NewOrm()
+	err = o.Raw(sql, companyId).QueryRow(&permission)
+	return
+}
+
+//GetCompanyReportPermissionUpgrade 获取升级的权限类型
+func GetCompanyReportPermissionUpgrade(companyId, productId int) (items []*CompanyReportPermission, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	re.*
+FROM
+	company_report_permission  as re 
+	INNER JOIN chart_permission as  c ON c.chart_permission_id = re.chart_permission_id
+WHERE
+	re.company_id = ? 
+	AND re.product_id = ? 
+	AND re.is_upgrade = 1 
+	AND c.permission_type = 1
+	AND STATUS = '正式' `
+	_, err = o.Raw(sql, companyId, productId).QueryRows(&items)
+	return
+}
+
+// GetChartPermissionByIds 主键获取权限
+func GetChartPermissionByIds(permissionIds []string) (list []*ChartPermission, err error) {
+	qb, _ := orm.NewQueryBuilder("mysql")
+	// 构建查询对象
+	qb.Select("*").From("chart_permission").
+		Where("chart_permission_id").In(permissionIds...)
+	// 导出 SQL 语句
+	sql := qb.String()
+
+	// 执行 SQL 语句
+	o := orm.NewOrm()
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}
+
+//GetCompanyPermissionNameCheck 通过名称判断客户是否开了某一类型的权限
+func GetCompanyPermissionNameCheck(companyId, productId int, permissionName string) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS count 
+		FROM
+			company_report_permission AS a 
+			INNER JOIN chart_permission as  c  ON c.chart_permission_id = a.chart_permission_id
+		WHERE
+			a.company_id = ?
+			AND a.STATUS = '正式'
+			AND a.product_id = ? 
+			AND c.chart_permission_name = ? `
+	err = o.Raw(sql, companyId, productId, permissionName).QueryRow(&count)
+	return
+}

+ 3 - 0
models/db.go

@@ -125,6 +125,9 @@ func init() {
 		new(CygxMicroRoadshowVideoHistory),
 		new(MicroRoadshowVideo),
 		new(CygxActivityVideoHistory),
+		new(CygxActivitySpecialTrip),
+		new(CygxArticleData),
+		new(CygxArticleComment),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 55 - 0
models/industrial_management.go

@@ -628,3 +628,58 @@ func GetIndustryByName(industryName string) (item *IndustrialManagement, err err
 	err = orm.NewOrm().Raw(sql, industryName).QueryRow(&item)
 	return
 }
+
+type IndustrialManagementArticle struct {
+	IndustrialManagementId int    `description:"产业Id"`
+	IndustryName           string `description:"产业名称"`
+	ArticleId              int    `description:"文章ID"`
+	PublishDate            string `description:"发布时间"`
+}
+
+//时间线的更新时间
+func GetTimeLineReportIndustrialPublishdateList(industrialIdArr []int) (items []*IndustrialManagementArticle, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT	
+			mmc.id,
+			0,
+			mmc.industry_id AS industrial_management_id,			
+			mmc.content AS title,
+			MAX( mm.meeting_time ) AS publish_date 
+		FROM
+			cygx_morning_meeting_review_chapter AS mmc
+			INNER JOIN cygx_morning_meeting_reviews AS mm 
+		WHERE
+			mm.id = mmc.meeting_id 
+			AND mm.STATUS = 1 
+			AND mmc.industry_id IN (` + utils.GetOrmInReplace(len(industrialIdArr)) + `)
+		GROUP BY industrial_management_id ORDER BY publish_date DESC  `
+	_, err = o.Raw(sql, industrialIdArr).QueryRows(&items)
+	return
+}
+
+//获取该产业下最新的文章详情
+func GetNewArticleDetailByIndustrialIds(industrialIdArr []int) (items []*IndustrialManagementArticle, err error) {
+	arrLen := len(industrialIdArr)
+	if arrLen == 0 {
+		return
+	}
+	o := orm.NewOrm()
+	sql := `SELECT
+			mg.industrial_management_id,
+			MAX( a.article_id ) AS article_id,
+			a.title,
+			MAX( a.publish_date ) AS publish_date 
+		FROM
+			cygx_industrial_article_group_management AS mg
+			INNER JOIN cygx_article AS a ON mg.article_id = a.article_id 
+		WHERE
+			1 = 1 
+			AND a.article_id < ?
+			AND a.is_report = 1
+			AND a.is_class = 1
+			AND mg.industrial_management_id IN(` + utils.GetOrmInReplace(len(industrialIdArr)) + `)   
+		GROUP BY
+			mg.industrial_management_id `
+	_, err = o.Raw(sql, utils.SummaryArticleId, industrialIdArr).QueryRows(&items)
+	return
+}

+ 10 - 10
models/micro_roadshow.go

@@ -31,10 +31,10 @@ type MicroRoadShowPageList struct {
 }
 
 // GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
-func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}, audioId, videoId, activityVideoId int) (total int, list []*MicroRoadShowPageList, err error) {
+func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}, audioId, videoId, activityVideoId, filter int) (total int, list []*MicroRoadShowPageList, err error) {
 	o := orm.NewOrm()
 	var sql string
-	if audioId+activityVideoId == 0 {
+	if audioId+activityVideoId == 0 && filter != 2{
 		sql += `SELECT
 			video_id AS id,
 			video_name AS title,
@@ -43,9 +43,9 @@ func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string,
 			publish_date AS publish_time,
 			chart_permission_id,
 			chart_permission_name,
-            industry_name,
 			video_duration AS play_seconds,
-			img_url AS background_img,
+			img_url AS background_img,            
+			industry_name,
 			share_img_url AS share_img,
 			"" as  activity_id
 		FROM
@@ -56,11 +56,11 @@ func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string,
 			sql += condition
 		}
 	}
-	if audioId+videoId+activityVideoId == 0 {
+	if audioId+videoId+activityVideoId == 0 && filter != 2 {
 		sql += `  UNION ALL `
 	}
 
-	if audioId+videoId == 0 {
+	if audioId+videoId == 0 && filter != 2{
 		sql += `
 		SELECT
 			video_id AS id,
@@ -72,8 +72,8 @@ func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string,
 			art.chart_permission_name,
 			"" AS play_seconds,
 			"" AS background_img,
-			"" AS share_img,
 			"" AS industry_name,
+			"" AS share_img,
 			v.activity_id
 		FROM
 			cygx_activity_video as v
@@ -82,11 +82,11 @@ func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string,
 			sql += conditionAct
 		}
 	}
-	if audioId+videoId+activityVideoId == 0 {
+	if audioId+videoId+activityVideoId == 0 && filter == 0 {
 		sql += `  UNION ALL `
 	}
 
-	if videoId+activityVideoId == 0 {
+	if videoId+activityVideoId == 0 && filter != 1 {
 		sql += `
 			SELECT
 			a.activity_voice_id AS id,
@@ -98,8 +98,8 @@ func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string,
 			b.chart_permission_name,
 			a.voice_play_seconds AS play_seconds,
 			a.img_url AS background_img,
+			"" AS industry_name,
 			"" AS share_img,
-            "" AS industry_name,
 			a.activity_id 
 		FROM
 			cygx_activity_voice AS a

+ 90 - 8
models/report.go

@@ -240,14 +240,15 @@ func GetWhichDepartmentCount(condition string) (count int, err error) {
 }
 
 type IsShow struct {
-	IsShow           bool      `description:"绝密内参按钮是否展示"`
-	IsShowFreeButton bool      `description:"免费送月卡按钮是否展示"`
-	IsShowResearch   bool      `description:"研选是否展示限免"`
-	IsShowChart      bool      `description:"图表是否展示限免"`
-	IsShowList       bool      `description:"榜单是否展示"`
-	LinkWxExplain    string    `description:"关注微信公众号链接说明地址"`
-	YanXuan_Explain  bool      `description:"研选说明"`
-	SearchTxtList    SearchTxt `description:"搜索栏回显内容说明"`
+	IsShow                 bool      `description:"绝密内参按钮是否展示"`
+	IsShowFreeButton       bool      `description:"免费送月卡按钮是否展示"`
+	IsShowResearch         bool      `description:"研选是否展示限免"`
+	IsShowChart            bool      `description:"图表是否展示限免"`
+	IsShowList             bool      `description:"榜单是否展示"`
+	LinkWxExplain          string    `description:"关注微信公众号链接说明地址"`
+	YanXuan_Explain        bool      `description:"研选说明"`
+	ActivitySpecialExplain string    `description:"专项调研活动"`
+	SearchTxtList          SearchTxt `description:"搜索栏回显内容说明"`
 }
 
 type SearchTxt struct {
@@ -820,3 +821,84 @@ func GetReportPvBillboardList(pars []interface{}, condition string) (items []*Ar
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+//获取产业报告+晨会点评数量
+func GetTimeLineReportIndustrialCount(industrialManagementId int) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT SUM(count) AS count FROM (
+SELECT
+	COUNT( 1 ) count 
+FROM
+	cygx_article AS a
+	INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id 
+WHERE
+	a.publish_status = 1 
+	AND a.is_class = 1 
+	AND man_g.industrial_management_id = ?
+	UNION ALL
+	SELECT
+	COUNT( 1 ) count 
+	FROM
+	cygx_morning_meeting_review_chapter AS mmc
+	INNER JOIN cygx_morning_meeting_reviews AS mm
+	WHERE
+	mm.id = mmc.meeting_id
+	AND mm.status = 1
+	AND mmc.industry_id = ? ) AS t `
+	err = o.Raw(sql, industrialManagementId, industrialManagementId).QueryRow(&count)
+	return
+}
+
+type TimeLineReportItem struct {
+	Id              int    `description:"文章或晨报点评id"`
+	Title           string `description:"标题"`
+	PublishTime     string `description:"发布时间"`
+	Content         string `description:"内容"`
+	VideoUrl        string `description:"视频链接"`
+	IsHaveVideo     bool   `description:"是否包含视频"`
+	ImgUrlPc        string `description:"pc图片"`
+	SubCategoryName string `description:"二级分类"`
+}
+
+//获取产业报告+晨会点评列表
+func GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize int) (items []*TimeLineReportItem, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	* 
+FROM
+	(
+		SELECT
+		a.article_id AS id,
+		a.title,
+		a.publish_date AS publish_time,
+		a.video_url,
+		a.sub_category_name,
+		'' AS content 
+	FROM
+		cygx_article AS a
+		INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id 
+	WHERE
+		a.publish_status = 1 
+		AND a.is_class = 1 
+		AND man_g.industrial_management_id = ? GROUP BY id UNION ALL
+	SELECT
+		mmc.id,
+		'' AS title,
+		mm.meeting_time AS publish_time,
+		'' AS video_url,
+		'时间线' AS sub_category_name,
+		mmc.content 
+	FROM
+		cygx_morning_meeting_review_chapter AS mmc
+		INNER JOIN cygx_morning_meeting_reviews AS mm 
+	WHERE
+		mm.id = mmc.meeting_id 
+		AND mm.STATUS = 1 
+		AND mmc.industry_id = ? 
+	) AS t 
+`
+	sql += ` ORDER BY 
+	t.publish_time DESC LIMIT ?,? `
+	_, err = o.Raw(sql, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 7 - 0
models/seller.go

@@ -47,6 +47,13 @@ func GetSellerByName(userName string) (item *AdminItem, err error) {
 	return
 }
 
+func GetSellerByAdminId(adminId int) (item *AdminItem, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM admin WHERE admin_id=?  `
+	err = o.Raw(sql, adminId).QueryRow(&item)
+	return
+}
+
 //获取本组的销售ID
 func GetSelleridWhichGroup(companyId, productId int) (adminId string, err error) {
 	o := orm.NewOrm()

+ 14 - 0
models/send_company_user.go

@@ -273,6 +273,20 @@ func GetWxUserOpLogSuspend(createTime string) (items []*WxUserOpLogDeleteResp, e
 	return
 }
 
+//获取指定时间内被移动的客户
+func GetCompanyOperationRecord(createTime string) (items []*WxUserOpLogDeleteResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+				* 
+			FROM
+				company_operation_record AS p 
+			WHERE
+				 operation IN ('move_seller')
+				 AND p.create_time > '` + createTime + `'  GROUP BY company_id  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 //获取指定时间内试用转冻结,冻结转流失的客户
 func GetCompanyFreezeAndLoss(createTime string) (items []*WxUserOpLogResp, err error) {
 	o := orm.NewOrm()

+ 8 - 0
models/tactics.go

@@ -82,6 +82,7 @@ type Tactics2 struct {
 	FieldName       string    `description:"产业标签"`
 	File            string    `description:"Pdf下载链接"`
 	TypeName        string    `description:"策略平台报告类型"`
+	UpdateDate      string    `description:"策略平台报告更新时间"`
 }
 
 func GetTacticsList2(endDate string) (list []*Tactics2, err error) {
@@ -132,3 +133,10 @@ func GetReportTacticsList(condition string, pars []interface{}, userId, startSiz
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
+
+type TimeLineReportListResp struct {
+	Paging           *paging.PagingItem
+	MatchTypeName    string `description:"匹配类型"`
+	CategoryImgUrlPc string `description:"图片"`
+	List             []*TimeLineReportItem
+}

+ 24 - 0
models/wx_template_msg.go

@@ -44,3 +44,27 @@ func GetWxOpenIdByMobileList(mobile string) (items []*OpenIdList, err error) {
 	_, err = orm.NewOrm().Raw(sql).QueryRows(&items)
 	return
 }
+
+type AdminOpenIdList struct {
+	OpenId    string `description:"OpenId"`
+	UserId    int    `description:"UserId"`
+	Mobile    string `description:"手机号"`
+	CompanyId int    `description:"手机号"`
+}
+
+// GetAdminOpendidByCompany 通过用户公司ID获取对应销售的openid
+func GetAdminOpendidByCompany(condition string, pars []interface{}) (list []*AdminOpenIdList, err error) {
+	sql := `SELECT
+			cr.open_id,a.mobile,p.company_id,cr.union_id
+		FROM
+			company_product AS p
+			INNER JOIN admin AS a ON a.admin_id = p.seller_id 
+			INNER JOIN user_record  as c ON c.bind_account = a.mobile
+			INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
+		WHERE
+			1 = 1 
+			AND p.product_id = 2
+			AND create_platform = 4 ` + condition
+	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
+	return
+}

+ 63 - 0
routers/commentsRouter.go

@@ -124,6 +124,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
+        beego.ControllerComments{
+            Method: "ActivityListSearch",
+            Router: `/listSearch`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
         beego.ControllerComments{
             Method: "MeetingReminderAdd",
@@ -223,6 +232,42 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"],
+        beego.ControllerComments{
+            Method: "SpecialTripAdd",
+            Router: `/add`,
+            AllowHTTPMethods: []string{"post"},
+            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: "SpecialDetail",
+            Router: `/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: "SpecialList",
+            Router: `/list`,
+            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: "Tripcancel",
+            Router: `/trip/cancel`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:AdviceController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:AdviceController"],
         beego.ControllerComments{
             Method: "ApplyApprove",
@@ -673,6 +718,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "CommentAdd",
+            Router: `/commentAdd`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
         beego.ControllerComments{
             Method: "Fllow",
@@ -700,6 +754,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "StockNameList",
+            Router: `/home/stockName`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
         beego.ControllerComments{
             Method: "TradeList",

+ 5 - 0
routers/router.go

@@ -129,6 +129,11 @@ func init() {
 				&controllers.MicroRoadShowController{},
 			),
 		),
+		web.NSNamespace("/activity_special",
+			web.NSInclude(
+				&controllers.ActivitySpecialCoAntroller{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 277 - 0
services/activity_button.go

@@ -0,0 +1,277 @@
+package services
+
+import (
+	"errors"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+//获取用户已经报名的活动
+func GetActivitySignUpUserMap(activityIds []int, user *models.WxUserItem) (mapUserId map[int]int, err error) {
+	userId := user.UserId
+	var condition string
+	var pars []interface{}
+	activityIdsLen := len(activityIds)
+	if activityIdsLen > 0 {
+		condition += ` AND activity_id IN (` + utils.GetOrmInReplace(activityIdsLen) + `)`
+		pars = append(pars, activityIds)
+	}
+	condition += ` AND user_id = ?  AND do_fail_type = 0 `
+	pars = append(pars, userId)
+	list, e := models.GetActivitySignuListByUser(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxActivitySpecialTripList, Err: " + e.Error())
+		return
+	}
+	mapUid := make(map[int]int)
+	for _, v := range list {
+		mapUid[v.ActivityId] = v.UserId
+	}
+	mapUserId = mapUid
+	return
+}
+
+//获取用户已经设置会议提醒的活动  cygx_activity_meeting_reminder
+func GetActivityReminderUserMasp(activityIds []int, user *models.WxUserItem) (mapUserId map[int]int, err error) {
+	userId := user.UserId
+	var condition string
+	var pars []interface{}
+	activityIdsLen := len(activityIds)
+	if activityIdsLen > 0 {
+		condition += ` AND activity_id IN (` + utils.GetOrmInReplace(activityIdsLen) + `)`
+		pars = append(pars, activityIds)
+	}
+	condition += ` AND user_id = ?  `
+	pars = append(pars, userId)
+	list, e := models.GetCygxReminderListByUser(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxReminderListByUser, Err: " + e.Error())
+		return
+	}
+	mapUid := make(map[int]int)
+	for _, v := range list {
+		mapUid[v.ActivityId] = v.UserId
+	}
+	mapUserId = mapUid
+	return
+}
+
+//获取用户已经预约纪要的活动
+func GetActivityAppointmentUserMap(activityIds []int, user *models.WxUserItem) (mapUserId map[int]int, err error) {
+	userId := user.UserId
+	var condition string
+	var pars []interface{}
+	activityIdsLen := len(activityIds)
+	if activityIdsLen > 0 {
+		condition += ` AND activity_id IN (` + utils.GetOrmInReplace(activityIdsLen) + `)`
+		pars = append(pars, activityIds)
+	}
+	condition += ` AND user_id = ?  `
+	pars = append(pars, userId)
+	list, e := models.GetCygxAppointmentListByUser(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxActivitySpecialTripList, Err: " + e.Error())
+		return
+	}
+	mapUid := make(map[int]int)
+	for _, v := range list {
+		mapUid[v.ActivityId] = v.UserId
+	}
+	mapUserId = mapUid
+	return
+}
+
+//活动列表的展示  HandleActivityListButton
+func HandleActivityListButton(list []*models.ActivityDetail, user *models.WxUserItem) (items []*models.ActivityDetail, err error) {
+	var activityIds []int
+	var activitySpecilalIds []int
+	for k, v := range list {
+		if v.SourceType == 2 {
+			activitySpecilalIds = append(activitySpecilalIds, v.ActivityId)
+			//把专项调研的线下改为活动的线下类型
+			if v.ActivityType == 2 {
+				list[k].ActivityType = 0
+			}
+			list[k].IsShowSignup = true
+		} else {
+			activityIds = append(activityIds, v.ActivityId)
+		}
+	}
+	//处理活动
+	if len(activityIds) > 0 {
+		//处理用户是否报名
+		mapSignUp, e := GetActivitySignUpUserMap(activityIds, user)
+		if e != nil {
+			err = errors.New("GetActivitySignUpUserMap, Err: " + e.Error())
+			return
+		}
+		for k, v := range list {
+			if v.SourceType != 2 {
+				if _, ok := mapSignUp[v.ActivityId]; ok {
+					list[k].IsSignup = 1
+				}
+			}
+		}
+		//处理用户是否预约纪要
+		mapAppointment, e := GetActivityAppointmentUserMap(activityIds, user)
+		if e != nil {
+			err = errors.New("GetActivityAppointmentUserMap, Err: " + e.Error())
+			return
+		}
+		for k, v := range list {
+			if v.SourceType != 2 {
+				if _, ok := mapAppointment[v.ActivityId]; ok {
+					list[k].IsAppointment = 1
+				}
+			}
+		}
+		//处理用户是否预约会议提醒
+		mapReminder, e := GetActivityReminderUserMasp(activityIds, user)
+		if e != nil {
+			err = errors.New("GetActivityReminderUserMasp, Err: " + e.Error())
+			return
+		}
+		for k, v := range list {
+			if v.SourceType != 2 {
+				if _, ok := mapReminder[v.ActivityId]; ok {
+					list[k].IsCancelMeetingReminder = 1
+				}
+			}
+		}
+	}
+
+	//处理专项产业调研
+	if len(activitySpecilalIds) > 0 {
+		//处理用户是否报名
+		UserMap, e := GetSpecialTripUserMap(activitySpecilalIds, user.UserId)
+		if e != nil {
+			err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
+			return
+		}
+		for k, v := range list {
+			if v.SourceType == 2 {
+				if _, ok := UserMap[v.ActivityId]; ok {
+					list[k].IsSignup = 1
+				}
+			}
+		}
+
+		for k, v := range list {
+			if v.SourceType == 2 {
+				resultTimeStart := utils.StrTimeToTime(v.ActivityTime)  //时间字符串格式转时间格式
+				resultTimeEnd := utils.StrTimeToTime(v.ActivityTimeEnd) //时间字符串格式转时间格式
+				if resultTimeStart.After(time.Now()) {
+					list[k].ActiveState = strconv.Itoa(1)
+				} else if time.Now().After(resultTimeEnd) {
+					list[k].ActiveState = strconv.Itoa(3)
+				} else {
+					list[k].ActiveState = strconv.Itoa(2)
+				}
+			}
+		}
+	}
+
+	//var isShow bool
+	isShow, e := GetShowSustainableNew()
+	if e != nil {
+		err = errors.New("GetShowSustainableNew, Err: " + e.Error())
+		return
+	}
+	detail, e := models.GetConfigByCode("city_img_url")
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error())
+		return
+	}
+	detailChart, e := models.GetConfigByCode("chart_img_url")
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error())
+		return
+	}
+	addressList := strings.Split(detail.ConfigValue, "{|}")
+	mapAddress := make(map[string]string)
+	chartList := strings.Split(detailChart.ConfigValue, "{|}")
+	mapChart := make(map[string]string)
+	var cityName string
+	var chartName string
+	var imgUrl string
+	var imgUrlChart string
+	var mapActivityId []int
+	for _, v := range addressList {
+		vslice := strings.Split(v, "_")
+		cityName = vslice[0]
+		imgUrl = vslice[len(vslice)-1]
+		mapAddress[cityName] = imgUrl
+	}
+	for _, v := range chartList {
+		vslice := strings.Split(v, "_")
+		chartName = vslice[0]
+		imgUrlChart = vslice[len(vslice)-1]
+		mapChart[chartName] = imgUrlChart
+	}
+	for k, v := range list {
+		if strings.Contains(v.ActivityName, "【") {
+			list[k].IsBrackets = 1
+		}
+		if v.SignupNum > v.LimitPeopleNum {
+			list[k].SignupNum = v.LimitPeopleNum
+		}
+		if isShow && strings.Contains(v.ChartPermissionName, "研选") {
+			list[k].IsShowSustainable = true
+		}
+		if strings.Contains(v.ChartPermissionName, "研选") && v.ActivityTypeId == 1 {
+			list[k].ActivityTypeName = "买方研选电话会"
+			list[k].ImgUrlText = utils.YAN_XUAN_IMG
+		}
+		if v.ActivityType == 0 {
+			if mapAddress[v.City] != "" {
+				list[k].ImgUrl = mapAddress[v.City]
+			} else {
+				list[k].ImgUrl = mapAddress["其它"]
+			}
+		} else {
+			if mapChart[v.ChartPermissionName] != "" {
+				list[k].ImgUrl = mapChart[v.ChartPermissionName]
+			}
+		}
+		expertTxt, _ := GetReportContentTextSub(v.Expert)
+		list[k].Expert = expertTxt
+		if v.IsHideAppointment == 0 {
+			list[k].IsShowAppointment = IsShowAppointment(v.ActivityTypeId, v.ChartPermissionName)
+		}
+		if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
+			list[k].IsCClassMeeting = true
+		}
+		mapActivityId = append(mapActivityId, v.ActivityId)
+	}
+
+	//处理音频回放
+	mapActivityVoice, e := GetActivityVoiceResp(mapActivityId)
+	if e != nil {
+		err = errors.New("GetActivityVoiceResp, Err: " + e.Error())
+		return
+	}
+
+	//处理视频回放
+	mapActivityVideo, e := GetActivityVideoResp(mapActivityId)
+	if e != nil {
+		err = errors.New("GetActivityVoiceResp, Err: " + e.Error())
+		return
+	}
+	for k, v := range list {
+		if mapActivityVoice[v.ActivityId] != nil {
+			list[k].FileType = 1
+			list[k].AudioLink = true
+			list[k].VoiceList = mapActivityVoice[v.ActivityId]
+		}
+		if mapActivityVideo[v.ActivityId] != nil {
+			list[k].FileType = 2
+			list[k].AudioLink = true
+			list[k].VideoDetail = mapActivityVideo[v.ActivityId]
+		}
+		items = append(items, ActivityButtonShow(v))
+	}
+	return
+}

+ 113 - 0
services/activity_my_schedule.go

@@ -0,0 +1,113 @@
+package services
+
+import (
+	"errors"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"time"
+)
+
+//我的日程 GetScheduleAndSpecilList
+func GetScheduleAndSpecilList(user *models.WxUserItem, condition string, startSize, pageSize int) (items []*models.ActivityDetail, err error) {
+	var conditionSpecil string
+	var pars, parsSpecil []interface{}
+	condition += ` AND my.user_id = ?`
+	pars = append(pars, user.UserId)
+	conditionSpecil += ` AND my.user_id = ? AND my.is_cancel = 0 `
+	parsSpecil = append(parsSpecil, user.UserId)
+	list, e := models.GetScheduleAndSpecilList(condition, pars, conditionSpecil, parsSpecil, startSize, pageSize)
+	if e != nil {
+		err = errors.New("GetScheduleAndSpecilList, Err: " + e.Error())
+		return
+	}
+	var activityIds []int
+	var activitySpecilalIds []int
+	for k, v := range list {
+		if v.SourceType == 2 {
+			activitySpecilalIds = append(activitySpecilalIds, v.ActivityId)
+			//把专项调研的线下改为活动的线下类型
+			if v.ActivityType == 2 {
+				list[k].ActivityType = 0
+			}
+			list[k].IsShowSignup = true
+		} else {
+			activityIds = append(activityIds, v.ActivityId)
+		}
+	}
+	//处理活动
+	if len(activityIds) > 0 {
+		//处理用户是否报名
+		mapSignUp, e := GetActivitySignUpUserMap(activityIds, user)
+		if e != nil {
+			err = errors.New("GetActivitySignUpUserMap, Err: " + e.Error())
+			return
+		}
+		for k, v := range list {
+			if v.SourceType != 2 {
+				if _, ok := mapSignUp[v.ActivityId]; ok {
+					list[k].IsSignup = 1
+				}
+			}
+		}
+		//处理用户是否预约纪要
+		mapAppointment, e := GetActivityAppointmentUserMap(activityIds, user)
+		if e != nil {
+			err = errors.New("GetActivityAppointmentUserMap, Err: " + e.Error())
+			return
+		}
+		for k, v := range list {
+			if v.SourceType != 2 {
+				if _, ok := mapAppointment[v.ActivityId]; ok {
+					list[k].IsAppointment = 1
+				}
+			}
+		}
+		//处理用户是否预约会议提醒
+		mapReminder, e := GetActivityReminderUserMasp(activityIds, user)
+		if e != nil {
+			err = errors.New("GetActivityReminderUserMasp, Err: " + e.Error())
+			return
+		}
+		for k, v := range list {
+			if v.SourceType != 2 {
+				if _, ok := mapReminder[v.ActivityId]; ok {
+					list[k].IsCancelMeetingReminder = 1
+				}
+			}
+		}
+	}
+
+	//处理专项产业调研
+	if len(activitySpecilalIds) > 0 {
+		//处理用户是否报名
+		UserMap, e := GetSpecialTripUserMap(activitySpecilalIds, user.UserId)
+		if e != nil {
+			err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
+			return
+		}
+		for k, v := range list {
+			if v.SourceType == 2 {
+				if _, ok := UserMap[v.ActivityId]; ok {
+					list[k].IsSignup = 1
+				}
+			}
+		}
+
+		for k, v := range list {
+			if v.SourceType == 2 {
+				resultTimeStart := utils.StrTimeToTime(v.ActivityTime)  //时间字符串格式转时间格式
+				resultTimeEnd := utils.StrTimeToTime(v.ActivityTimeEnd) //时间字符串格式转时间格式
+				if resultTimeStart.After(time.Now()) {
+					list[k].ActiveState = strconv.Itoa(1)
+				} else if time.Now().After(resultTimeEnd) {
+					list[k].ActiveState = strconv.Itoa(3)
+				} else {
+					list[k].ActiveState = strconv.Itoa(2)
+				}
+			}
+		}
+	}
+	items = list
+	return
+}

+ 881 - 9
services/activity_special.go

@@ -2,10 +2,12 @@ package services
 
 import (
 	"context"
+	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -70,10 +72,45 @@ func UpdateCygxActivitySpecialSignupNum(cont context.Context) (err error) {
 }
 
 //处理专项调研的展示
-func GetActivityLabelSpecialList(userType, isPower int, chartPermissionIds, scale, permissionNameStr string) (item *models.ActivityTypeHome, err error) {
+func GetActivityLabelSpecialList(user *models.WxUserItem, isPower int, chartPermissionIds, permissionNameStr string) (item *models.ActivityTypeHome, err error) {
+	itemList := new(models.ActivityTypeHome)
+	if user.CompanyId <= 1 {
+		itemList.List = make([]*models.CygxActivityLabelList, 0)
+		item = itemList
+		return
+	}
+	userType, e := GetSpecialUserType(user)
+	if e != nil {
+		err = errors.New("GetSpecialUserType, Err: " + e.Error())
+		return
+	}
+	if userType == 0 {
+		itemList.List = make([]*models.CygxActivityLabelList, 0)
+		item = itemList
+		return
+	}
+	companyDetail, e := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
+	if e != nil {
+		err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
+		return
+	}
+	//如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
 	var condition string
+	if companyDetail.Status == "永续" {
+		condition, e = HandleActivityLabelSpecialPermission(user)
+		if e != nil {
+			err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
+			return
+		}
+	} else {
+		condition, e = HandleActivityLabelSpecialTripPermission(user)
+		if e != nil {
+			err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
+			return
+		}
+	}
 	var pars []interface{}
-	condition = ` AND art.publish_status = 1  AND art.label != '' `
+	condition += ` AND art.publish_status = 1  AND art.label != ''  AND art.is_offline = 0 `
 
 	//行业名称
 	if isPower == 1 {
@@ -82,21 +119,28 @@ func GetActivityLabelSpecialList(userType, isPower int, chartPermissionIds, scal
 	if chartPermissionIds != "" {
 		condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `) `
 	}
-	var conditionOr string
-	if scale != "" {
-		conditionOr += ` OR (  art.scale LIKE '%` + scale + `%'	 ` + condition + `) `
-	}
-	condition += ` AND  art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%'` + conditionOr
-	specialList, err := models.GetActivityLabelSpecialListAll(condition, pars, 0, 8)
+	conditionTrip := condition
+	conditionTrip += ` AND art.days > 0  ORDER BY art.activity_time ASC `
+	specialList, err := models.GetActivityLabelSpecialListAll(conditionTrip, pars, 0, 8)
 	if err != nil {
 		return
 	}
+	if len(specialList) < 8 {
+		conditionTrip += ` AND art.days = 0  ORDER BY art.last_updated_time DESC`
+		specialListNotrip, e := models.GetActivityLabelSpecialListAll(condition, pars, 0, 8-len(specialList))
+		if e != nil {
+			err = e
+			return
+		}
+		for _, v := range specialListNotrip {
+			specialList = append(specialList, v)
+		}
+	}
 	for k2, v2 := range specialList {
 		specialList[k2].KeyWord = LabelStrV5(v2.KeyWord, v2.IsShowSubjectName, v2.TemporaryLabel)
 		specialList[k2].ImgUrlBg = "https://hzstatic.hzinsights.com/static/temp/20220426202204/20220426/XDLLsjC9XAAy8LIzQr7GsjrBbtX6.png"
 		specialList[k2].ImgUrlBg = utils.ACTIVITY_ZXDY_ImgUrl3
 	}
-	itemList := new(models.ActivityTypeHome)
 	itemList.ActivityTypeName = "专项产业调研"
 	itemList.Resource = 2
 	itemList.List = specialList
@@ -106,3 +150,831 @@ func GetActivityLabelSpecialList(userType, isPower int, chartPermissionIds, scal
 	item = itemList
 	return
 }
+
+//HandleActivityLabelSpecialPermission 处理专项产业调研的查询权限sql 永续
+func HandleActivityLabelSpecialPermission(user *models.WxUserItem) (condition string, err error) {
+	permissionStr, e := GetCompanyPermission(user.CompanyId)
+	if e != nil {
+		err = errors.New("GetCompanyPermission, Err: " + e.Error())
+		return
+	}
+	userType, e := GetSpecialUserType(user)
+	if e != nil {
+		err = errors.New("GetSpecialUserType, Err: " + e.Error())
+		return
+	}
+	slicePer := strings.Split(permissionStr, ",")
+	var permissionSqlStr string
+	for _, v := range slicePer {
+		if userType == 1 {
+			if !strings.Contains(v, "研选") {
+				permissionSqlStr += "'" + v + "',"
+			}
+		} else {
+			permissionSqlStr += "'" + v + "',"
+		}
+	}
+	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
+	condition = ` AND art.publish_status = 1  AND art.label != ''  AND art.is_offline = 0  `
+	if permissionSqlStr != "" {
+		condition += ` AND art.chart_permission_name  IN (` + permissionSqlStr + `) `
+	}
+	condition += ` AND  art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
+	return
+}
+
+//HandleActivityLabelSpecialPermisseion 处理专项产业调研的查询权限sql
+func HandleActivityLabelSpecialTripPermission(user *models.WxUserItem) (condition string, err error) {
+	permissionStr, e := GetCompanyPermission(user.CompanyId)
+	if e != nil {
+		err = errors.New("GetCompanyPermission, Err: " + e.Error())
+		return
+	}
+	userType, e := GetSpecialUserType(user)
+	if e != nil {
+		err = errors.New("GetSpecialUserType, Err: " + e.Error())
+		return
+	}
+	slicePer := strings.Split(permissionStr, ",")
+	var permissionSqlStr string
+	for _, v := range slicePer {
+		if userType == 1 {
+			if !strings.Contains(v, "研选") {
+				permissionSqlStr += "'" + v + "',"
+			}
+		} else {
+			permissionSqlStr += "'" + v + "',"
+		}
+	}
+	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
+	condition = ` AND art.publish_status = 1  AND art.label != ''  AND art.is_offline = 0  `
+	if permissionSqlStr != "" {
+		condition += ` AND art.chart_permission_name  IN (` + permissionSqlStr + `) `
+	}
+	condition += ` AND  art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
+	return
+}
+
+//获取预报名列表
+func GetActivitySpecialPrepareList(user *models.WxUserItem, startSize, pageSize int, keywords string) (list []*models.CygxActivitySpecialDetail, totalPrepare int, err error) {
+	companyDetail, e := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
+	if e != nil {
+		err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
+		return
+	}
+	//如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
+	var condition string
+	if companyDetail.Status == "永续" {
+		condition, e = HandleActivityLabelSpecialPermission(user)
+		if e != nil {
+			err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
+			return
+		}
+	} else {
+		condition, e = HandleActivityLabelSpecialTripPermission(user)
+		if e != nil {
+			err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
+			return
+		}
+	}
+	var pars []interface{}
+	condition += ` AND art.days = 0  AND art.publish_status = 1 AND art.is_offline = 0   `
+	if keywords != "" {
+		keywords = "%" + keywords + "%"
+		condition += ` AND art.research_theme LIKE ? `
+		pars = append(pars, keywords)
+	}
+	totalPrepare, e = models.GetActivitySpecialCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetActivitySpecialCount, Err: " + e.Error())
+		return
+	}
+	condition += `  ORDER BY art.last_updated_time DESC `
+	list, e = models.GetCygxActivitySpecialDetailList(condition, pars, user.UserId, startSize, pageSize)
+	if e != nil {
+		err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
+		return
+	}
+	return
+}
+
+/*
+确定行程的查询  GetActivityLabelSpecialConfirmList
+state 进行状态 1:未开始,2:进行中,3:已结束,4:未开始、进行中 不传默认查询全部items []*CygxActivitySpecialDetail
+*/
+func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, pageSize, state int, keywords string) (list []*models.CygxActivitySpecialDetail, totalConfirm int, err error) {
+	//var condition string
+	companyDetail, e := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
+	if e != nil {
+		err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
+		return
+	}
+	//如果是永续的就按照普通的权限逻辑来查,如果不是就按照升级的逻辑来查
+	var condition string
+	if companyDetail.Status == "永续" {
+		condition, e = HandleActivityLabelSpecialPermission(user)
+		if e != nil {
+			err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
+			return
+		}
+	} else {
+		condition, e = HandleActivityLabelSpecialTripPermission(user)
+		if e != nil {
+			err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
+			return
+		}
+	}
+	var pars []interface{}
+	condition += ` AND art.days >0  AND art.publish_status =1   AND art.is_offline = 0  `
+	if state == 1 {
+		condition += ` AND art.activity_time > ? `
+		pars = append(pars, time.Now())
+	}
+	if state == 2 {
+		condition += ` AND art.activity_time < ? `
+		pars = append(pars, time.Now())
+		condition += ` AND art.activity_time_end > ? `
+		pars = append(pars, time.Now())
+	}
+	if state == 3 {
+		condition += ` AND art.activity_time_end < ? `
+		pars = append(pars, time.Now())
+	}
+	if state == 4 {
+		condition += ` AND art.activity_time_end > ? `
+		pars = append(pars, time.Now())
+	}
+	if keywords != "" {
+		keywords = "%" + keywords + "%"
+		condition += ` AND art.research_theme LIKE ? `
+		pars = append(pars, keywords)
+	}
+	totalConfirm, e = models.GetActivitySpecialCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetActivitySpecialCount, Err: " + e.Error())
+		return
+	}
+	condition += `  ORDER BY art.activity_time ASC `
+	list, e = models.GetCygxActivitySpecialDetailList(condition, pars, user.UserId, startSize, pageSize)
+	if e != nil {
+		err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
+		return
+	}
+	var activityIds []int
+	for k, v := range list {
+		resultTimeStart := utils.StrTimeToTime(v.ActivityTime)  //时间字符串格式转时间格式
+		resultTimeEnd := utils.StrTimeToTime(v.ActivityTimeEnd) //时间字符串格式转时间格式
+		if resultTimeStart.After(time.Now()) {
+			list[k].ActiveState = 1
+		} else if time.Now().After(resultTimeEnd) {
+			list[k].ActiveState = 3
+		} else {
+			list[k].ActiveState = 2
+		}
+		if list[k].Days == 0 {
+			list[k].TripStatus = 1
+		} else {
+			list[k].TripStatus = 2
+		}
+		activityIds = append(activityIds, v.ActivityId)
+	}
+
+	//处理用户已经报名了的行程
+	UserMap, e := GetSpecialTripUserMap(activityIds, user.UserId)
+	if e != nil {
+		err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
+		return
+	}
+	for k, v := range list {
+		if _, ok := UserMap[v.ActivityId]; ok {
+			list[k].IsTrip = 1
+		}
+	}
+	return
+}
+
+//获取用户已经报名的活动
+func GetSpecialTripUserMap(activityIds []int, userId int) (mapUserId map[int]int, err error) {
+	var condition string
+	var pars []interface{}
+	activityIdsLen := len(activityIds)
+	if activityIdsLen > 0 {
+		condition += ` AND activity_id IN (` + utils.GetOrmInReplace(activityIdsLen) + `)`
+		pars = append(pars, activityIds)
+	}
+	condition += ` AND user_id = ?  AND is_cancel = 0 `
+	pars = append(pars, userId)
+	list, e := models.GetCygxActivitySpecialTripList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxActivitySpecialTripList, Err: " + e.Error())
+		return
+	}
+	mapUid := make(map[int]int)
+	for _, v := range list {
+		mapUid[v.ActivityId] = v.UserId
+	}
+	mapUserId = mapUid
+	return
+}
+
+//获取用户已经报名的活动数量
+func GetSpecialTripUserSchedule(userId int) (total int, err error) {
+	var condition string
+	var pars []interface{}
+
+	condition += ` AND t.user_id = ? AND t.is_cancel = 0 `
+	pars = append(pars, userId)
+	condition += ` AND a.activity_time_end >= ? `
+	pars = append(pars, time.Now())
+	condition += ` AND is_valid = 1 `
+	total, err = models.GetActivitySpecialTripCountByActivitySpecial(condition, pars)
+	return
+}
+
+//GetActivitySpecialList 获取专项调研列表
+func GetActivitySpecialList(user *models.WxUserItem, currentIndex, pageSize int, keywords string) (list []*models.CygxActivitySpecialDetail, total int, err error) {
+	listConfirm, totalConfirm, e := GetActivityLabelSpecialConfirmList(user, (currentIndex-1)*pageSize, pageSize, 4, keywords)
+	if e != nil {
+		err = errors.New("GetActivityLabelSpecialConfirmList, Err: " + e.Error())
+		return
+	}
+	if currentIndex == 1 && len(listConfirm) > 0 {
+		listConfirm[0].Explain = utils.ACtIVITY_SPECIAL_TRIP_EXPLAIN
+	}
+	list = listConfirm
+	total = totalConfirm
+	var startSizePrepare, pageSizePrepare int
+	//全是确定行程的查询数据
+	if totalConfirm >= currentIndex*pageSize {
+		startSizePrepare = 0
+		pageSizePrepare = 0
+	} else if totalConfirm > (currentIndex-1)*pageSize && totalConfirm < currentIndex*pageSize {
+		//一半确认行程一半预报名
+		startSizePrepare = 0
+		pageSizePrepare = pageSize - len(listConfirm)
+	} else {
+		//全是预报名
+		startSizePrepare = (currentIndex-1)*pageSize - totalConfirm
+		pageSizePrepare = pageSize - len(listConfirm)
+	}
+	listPrepare, totalPrepare, e := GetActivitySpecialPrepareList(user, startSizePrepare, pageSizePrepare, keywords)
+	if e != nil {
+		err = errors.New("GetActivityLabelSpecialConfirmList, Err: " + e.Error())
+		return
+	}
+	if len(listPrepare) > 0 {
+		for _, v := range listPrepare {
+			list = append(list, v)
+		}
+		if startSizePrepare == 0 {
+			listPrepare[0].Explain = utils.ACtIVITY_SPECIAL_EXPLAIN
+		}
+	}
+	total = totalConfirm + totalPrepare
+
+	//处理封面图片
+	detail, e := models.GetConfigByCode("city_img_url")
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error())
+		return
+	}
+	detailChart, e := models.GetConfigByCode("chart_img_url")
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error())
+		return
+	}
+	addressList := strings.Split(detail.ConfigValue, "{|}")
+	mapAddress := make(map[string]string)
+	chartList := strings.Split(detailChart.ConfigValue, "{|}")
+	mapChart := make(map[string]string)
+	var cityName string
+	var chartName string
+	var imgUrl string
+	var imgUrlChart string
+	for _, v := range addressList {
+		vslice := strings.Split(v, "_")
+		cityName = vslice[0]
+		imgUrl = vslice[len(vslice)-1]
+		mapAddress[cityName] = imgUrl
+	}
+	for _, v := range chartList {
+		vslice := strings.Split(v, "_")
+		chartName = vslice[0]
+		imgUrlChart = vslice[len(vslice)-1]
+		mapChart[chartName] = imgUrlChart
+	}
+	for k, v := range list {
+		//list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
+		if mapChart[v.ChartPermissionName] != "" {
+			list[k].ImgUrl = mapChart[v.ChartPermissionName]
+		}
+		list[k].ActivityTypeName = "专项调研"
+		if list[k].Days == 0 {
+			list[k].TripStatus = 1
+		} else {
+			list[k].TripStatus = 2
+			list[k].TripImgLink = list[k].TripImgLinkFix
+		}
+	}
+	return
+}
+
+//HandleActivitySpecialShow 处理活动的状态
+func HandleActivitySpecialShow(activityDetail *models.CygxActivitySpecialDetail, user *models.WxUserItem) (item *models.CygxActivitySpecialDetail, err error) {
+	var activityIds []int
+	resultTimeStart := utils.StrTimeToTime(activityDetail.ActivityTime)  //时间字符串格式转时间格式
+	resultTimeEnd := utils.StrTimeToTime(activityDetail.ActivityTimeEnd) //时间字符串格式转时间格式
+	if resultTimeStart.After(time.Now()) {
+		activityDetail.ActiveState = 1
+	} else if time.Now().After(resultTimeEnd) {
+		activityDetail.ActiveState = 3
+	} else {
+		activityDetail.ActiveState = 2
+	}
+	activityIds = append(activityIds, activityDetail.ActivityId)
+	//处理用户已经报名了的行程
+	UserMap, e := GetSpecialTripUserMap(activityIds, user.UserId)
+	if e != nil {
+		err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
+		return
+	}
+	if activityDetail.Days == 0 {
+		activityDetail.TripStatus = 1
+		activityDetail.Explain = utils.ACtIVITY_SPECIAL_EXPLAIN
+	} else {
+		activityDetail.TripStatus = 2
+		activityDetail.TripImgLink = activityDetail.TripImgLinkFix
+		activityDetail.Explain = utils.ACtIVITY_SPECIAL_TRIP_EXPLAIN
+	}
+	if _, ok := UserMap[activityDetail.ActivityId]; ok {
+		activityDetail.IsTrip = 1
+	}
+	item = activityDetail
+	return
+}
+
+//活动与专项调研搜索 GetActivitySpecialSearcheList
+func GetActivitySpecialSearcheList(user *models.WxUserItem, condition string, startSize, pageSize int, keywords string) (items []*models.ActivityDetail, total int, err error) {
+	var conditionSpecil string
+	var pars, parsSpecil []interface{}
+	if keywords != "" {
+		keywords = "%" + keywords + "%"
+		conditionSpecil += ` AND art.days > 0 AND (art.research_theme LIKE ? OR art.label LIKE ? OR art.industrial_name LIKE ? OR art.industrial_subject_name LIKE ? ) `
+		parsSpecil = append(parsSpecil, keywords, keywords, keywords, keywords)
+	}
+	list, totalSearche, e := models.GetActivitySpecialSearcheList(condition, pars, conditionSpecil, parsSpecil, startSize, pageSize)
+	if e != nil {
+		err = errors.New("GetActivitySpecialSearcheList, Err: " + e.Error())
+		return
+	}
+	items, e = HandleActivityListButton(list, user)
+	if e != nil {
+		err = errors.New("HandleActivityListButton, Err: " + e.Error())
+		return
+	}
+	total = totalSearche
+	return
+}
+
+//获取 专项调研客户类型   //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //8、行业升级套餐客户 //9、其余正式客户;5、试用客户
+func GetActivitySpecialUserType(companyId int) (userType int, permissionStrnew string, err error) {
+	var permissionStr string
+	if companyId <= 1 {
+		userType = 0
+	} else {
+		total, e := models.GetCountCompanyDetailByIdGroupTrip(companyId)
+		if e != nil {
+			err = errors.New("GetCountCompanyDetailByIdGroupTrip, Err: " + e.Error())
+			return
+		}
+		if total == 0 {
+			userType = 0
+		} else {
+			companyDetail, e := models.GetCompanyDetailByIdGroupTrip(companyId)
+			if e != nil {
+				err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
+				return
+			}
+			permissionStr, e = models.GetCompanyPermissionByUserTrip(companyId)
+			if e != nil {
+				err = errors.New("GetCompanyPermissionByUserTrip, Err: " + e.Error())
+				return
+			}
+			//permissionZhengShiStr, e = models.GetCompanyPermissionByUserZhengShiTrip(companyId)
+			//if e != nil {
+			//	err = errors.New("GetCompanyPermissionByUserZhengShiTrip, Err: " + e.Error())
+			//	return
+			//}
+			//大套餐客户定义:医药、消费、科技、智造。4个行业中为升级,策略是正式,属于大套餐客户
+			if companyDetail.Status == "永续" {
+				userType = 1
+			} else if companyDetail.Status == "试用" {
+				userType = 5
+			} else if companyDetail.Status == "正式" {
+				if permissionStr == "专家" {
+					userType = 4
+				} else if strings.Count(permissionStr, "医药") == 2 && strings.Count(permissionStr, "消费") == 2 && strings.Count(permissionStr, "科技") == 2 && strings.Count(permissionStr, "智造") == 2 && strings.Count(permissionStr, "策略") == 1 {
+					userType = 2
+				} else {
+					userType = 3
+				}
+				if userType == 3 {
+					if !strings.Contains(permissionStr, "医药") && !strings.Contains(permissionStr, "消费") && !strings.Contains(permissionStr, "科技") && !strings.Contains(permissionStr, "智造") {
+						userType = 4
+					}
+				}
+			} else if companyDetail.Status == "冻结" {
+				userType = 6
+			} else if companyDetail.Status == "流失" {
+				userType = 7
+			}
+		}
+	}
+	permissionStrnew = permissionStr
+	return
+}
+
+//GetSpecialUserType 获取专项产业调研的用户身份类型
+//获取 专项调研客户类型   //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //8、行业升级套餐客户 //9、其余正式客户;5、试用客户
+func GetSpecialUserType(user *models.WxUserItem) (userType int, err error) {
+	companyId := user.CompanyId
+	companyDetail, e := models.GetCompanyDetailByIdGroupTrip(companyId)
+	if e != nil {
+		err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
+		return
+	}
+	if companyId <= 1 {
+		userType = 0
+	} else {
+		if companyDetail.Status == "永续" {
+			userType = 1
+		} else {
+			if companyDetail.Status == "正式" {
+				list, e := models.GetCompanyReportPermissionUpgrade(companyId, 2)
+				if e != nil && e.Error() != utils.ErrNoRow() {
+					err = errors.New("GetCompanyReportPermissionUpgrade, Err: " + e.Error())
+				}
+				if len(list) == 0 {
+					userType = 9
+				}
+				if len(list) == 4 {
+					totalName, e := models.GetCompanyPermissionNameCheck(companyId, 2, "策略")
+					if e != nil {
+						err = errors.New("获取品种信息失败, Err:" + e.Error())
+						return
+					}
+					if totalName > 0 {
+						userType = 2
+					} else {
+						userType = 8
+					}
+				} else {
+					userType = 8
+				}
+			} else if companyDetail.Status == "试用" {
+				userType = 5
+			}
+		}
+	}
+	return
+}
+
+//GetSpecialDetailUserPower 处理用户查看专项调研详情的权限
+func GetSpecialDetailUserPower(user *models.WxUserItem, activityInfo *models.CygxActivitySpecialDetail) (havePower bool, err error) {
+	permissionStr, e := GetCompanyPermissionUpgrade(user.CompanyId)
+	if e != nil {
+		err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
+		return
+	}
+	fmt.Println(permissionStr)
+	//如果没有对应的升级权限,则返回
+	if !strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
+		return
+	}
+	userType, e := GetSpecialUserType(user)
+	if e != nil {
+		err = errors.New("GetSpecialUserType, Err: " + e.Error())
+		return
+	}
+	if userType == 0 {
+		return
+	}
+	var pars []interface{}
+	var condition string
+	var userTypes string
+	condition += `  AND art.publish_status = 1 AND art.is_offline = 0   `
+	userTypes = "%" + strconv.Itoa(userType) + "%"
+	condition += ` AND art.customer_type_ids LIKE ? `
+	pars = append(pars, userTypes)
+
+	condition += ` AND art.activity_id = ? `
+	pars = append(pars, activityInfo.ActivityId)
+
+	total, e := models.GetActivitySpecialCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetSpecialUserType, Err: " + e.Error())
+		return
+	}
+	if total == 1 {
+		havePower = true
+	}
+	return
+}
+
+//预报名活动,感兴趣人数满10人时,推送给活动负责人和王芳
+func SendWxMsgActivitySpecial10(activityInfo *models.CygxActivitySpecialDetail) (err error) {
+	activityId := activityInfo.ActivityId
+	var msg string
+	defer func() {
+		if err != nil {
+			go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
+			go utils.SendAlarmMsg(fmt.Sprint("预报名活动,感兴趣人数满10人时,推送给活动负责人和王芳消息发送失败", activityInfo.ResearchTheme, ", activityId"), 2)
+			utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
+		}
+	}()
+	var first string
+	var keyword1 string
+	var keyword2 string
+	var keyword3 string
+	var keyword4 string
+	var remark string
+
+	adminUser, e := models.GetSellerByAdminId(activityInfo.AdminId)
+	if e != nil {
+		err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+		return
+	}
+	cnf, _ := models.GetConfigByCode("tpl_msg")
+	mobile := adminUser.Mobile + "," + cnf.ConfigValue
+
+	specialSignupList, e := models.GetActivityListSpecialByActivityId(activityId)
+	if e != nil {
+		err = errors.New("GetActivityListSpecialAll, Err: " + e.Error())
+		return
+	}
+	for _, v := range specialSignupList {
+		keyword1 += "【" + v.RealName + "--" + v.CompanyName + "】"
+	}
+	openIdList, e := models.GetWxOpenIdByMobileList(mobile)
+	if e != nil {
+		err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+		return
+	}
+	first = "【" + activityInfo.ResearchTheme + "】已有10人预报名"
+	keyword3 = "-"
+	keyword2 = "-"
+	keyword4 = activityInfo.ResearchTheme
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	redirectUrl := utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(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.WxMsgTemplateIdAskMsgXzs
+	sendInfo.RedirectUrl = redirectUrl
+	sendInfo.RedirectTarget = 3
+	sendInfo.Resource = strconv.Itoa(activityId)
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	err = PublicSendTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
+	return
+}
+
+//SendWxMsgActivitySpecialTwoDays  活动开始前两天08:00,提醒报名客户 \提醒报名客户的对口销售
+func SendWxMsgActivitySpecialTwoDays(cont context.Context) (err error) {
+	var msg string
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
+			go utils.SendAlarmMsg(fmt.Sprint(" 活动开始前两天08:00,提醒报名客户、提醒报名客户的对口销售消息发送失败"), 2)
+			utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
+		}
+	}()
+	twoDayTime := time.Now().AddDate(0, 0, 2)
+	startTime := twoDayTime.Format(utils.FormatDate) + " 00:00:00"
+	endTime := twoDayTime.Format(utils.FormatDate) + " 23:59:59"
+	var condition string
+	var pars []interface{}
+	condition = ` AND  days >0  AND activity_time BETWEEN ? AND  ? `
+	pars = append(pars, startTime, endTime)
+	listActivitySpecial, e := models.GetActivitySpecialListAll(condition, pars, 0, 1000)
+	if e != nil {
+		err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+		return
+	}
+	if len(listActivitySpecial) == 0 {
+		return
+	}
+
+	var activityIds []int
+
+	for _, v := range listActivitySpecial {
+		activityIds = append(activityIds, v.ActivityId)
+		condition = `  AND is_cancel = 0 AND activity_id = ` + strconv.Itoa(v.ActivityId)
+		pars = make([]interface{}, 0)
+		listSpecialTrip, e := models.GetCygxActivitySpecialTripList(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxActivitySpecialTripList, Err: " + e.Error())
+			return
+		}
+		if len(listSpecialTrip) == 0 {
+			return
+		}
+		var mobile string
+		var companyIds []int
+		for _, vT := range listSpecialTrip {
+			mobile += "'" + vT.Mobile + "',"
+			companyIds = append(companyIds, vT.CompanyId)
+		}
+		mobile = strings.TrimRight(mobile, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(mobile)
+		if e != nil {
+			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+			return
+		}
+		first := "【" + v.ResearchTheme + "】专项调研将在两天后进行,如不能参加,请及时取消报名"
+		keyword1 := v.ResearchTheme
+		keyword2 := "已报名"
+		keyword3 := v.ActivityTimeTextByDay
+		keyword4 := "线上"
+		if v.SpecialType == 2 {
+			keyword4 = v.City
+		}
+		remark := "点击查看活动详情"
+		SendWxMsgWithFrequency(first, keyword1, keyword2, keyword3, keyword4, remark, openIdList, v.ActivityId)
+
+		//活动开始前两天08:00,提醒报名客户的对口销售
+		companyIdsLen := len(companyIds)
+		if companyIdsLen == 0 {
+			continue
+		} else {
+			pars = make([]interface{}, 0)
+			condition = ` AND p.company_id IN (` + utils.GetOrmInReplace(companyIdsLen) + `)  GROUP BY  p.company_id  `
+			pars = append(pars, companyIds)
+
+			listSeller, e := models.GetAdminOpendidByCompany(condition, pars)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = errors.New("GetAdminOpendidByCompany, Err: " + e.Error())
+				return
+			}
+			if len(listSeller) == 0 {
+				continue
+			}
+			type SllerData struct {
+				Openid  string `description:"Openid"`
+				Keyword string `description:"Keyword "`
+			}
+			mapSller := make(map[string]string)
+			mapSllerOpenid := make(map[string]string)
+			for _, vS := range listSeller {
+				for _, vT := range listSpecialTrip {
+					if vT.CompanyId == vS.CompanyId {
+						mapSller[vS.Mobile] += "【" + vT.RealName + "--" + vT.CompanyName + "】"
+						mapSllerOpenid[vS.Mobile] = vS.OpenId
+					}
+				}
+			}
+			for k, vM := range mapSller {
+				first = "【" + v.ResearchTheme + "】专项调研将在两天后进行,请及时提醒您的报名客户"
+				keyword2 = vM
+				openIdList = make([]*models.OpenIdList, 0)
+				openIdList = append(openIdList, &models.OpenIdList{OpenId: mapSllerOpenid[k]})
+				SendWxMsgWithFrequency(first, keyword1, keyword2, keyword3, keyword4, remark, openIdList, v.ActivityId)
+			}
+		}
+	}
+	return
+}
+
+//SendWxMsgActivitySpecialCancel  线下活动前4天08:00报名人数不足7人,线上活动前3天08:00报名人数不足10人,活动自动取消发布,并推送模板消息至报名客户及对口销售
+func SendWxMsgActivitySpecialCancel(cont context.Context) (err error) {
+	var msg string
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
+			go utils.SendAlarmMsg(fmt.Sprint(" 活动开始前两天08:00,提醒报名客户、提醒报名客户的对口销售消息发送失败"), 2)
+			utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
+		}
+	}()
+	dayTime3 := time.Now().AddDate(0, 0, 3)
+	startTime := dayTime3.Format(utils.FormatDate) + " 00:00:00"
+	endTime := dayTime3.Format(utils.FormatDate) + " 23:59:59"
+
+	dayTime4 := time.Now().AddDate(0, 0, 4)
+	startTime4 := dayTime4.Format(utils.FormatDate) + " 00:00:00"
+	endTime4 := dayTime4.Format(utils.FormatDate) + " 23:59:59"
+	var condition string
+	var pars []interface{}
+	condition = ` AND days >0  AND activity_time BETWEEN ? AND  ? AND special_type= 1 `
+	pars = append(pars, startTime, endTime)
+
+	condition += ` OR ( days >0  AND activity_time BETWEEN ? AND  ? AND special_type= 2 ) `
+	pars = append(pars, startTime4, endTime4)
+
+	listActivitySpecial, e := models.GetActivitySpecialListAll(condition, pars, 0, 1000)
+	if e != nil {
+		err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+		return
+	}
+	if len(listActivitySpecial) == 0 {
+		return
+	}
+
+	var activityIds []int
+
+	for _, v := range listActivitySpecial {
+		activityIds = append(activityIds, v.ActivityId)
+		condition = ` AND is_cancel = 0  AND activity_id = ` + strconv.Itoa(v.ActivityId)
+		pars = make([]interface{}, 0)
+		listSpecialTrip, e := models.GetCygxActivitySpecialTripList(condition, pars)
+		if e != nil {
+			err = errors.New("GetCygxActivitySpecialTripList, Err: " + e.Error())
+			return
+		}
+		if v.SpecialType == 1 {
+			if len(listSpecialTrip) >= 10 {
+				continue
+			}
+		}
+		if v.SpecialType == 2 {
+			if len(listSpecialTrip) >= 7 {
+				continue
+			}
+		}
+		e = models.UpdateActivitySpecialPublishStatus(0, v.ActivityId)
+		if e != nil {
+			err = errors.New("UpdateActivitySpecialPublishStatus,自动取消专项调研日程失败 Err: " + e.Error() + strconv.Itoa(v.ActivityId))
+			return
+		}
+		if len(listSpecialTrip) < 0 {
+			return
+		}
+		var mobile string
+		var companyIds []int
+		for _, vT := range listSpecialTrip {
+			mobile += "'" + vT.Mobile + "',"
+			companyIds = append(companyIds, vT.CompanyId)
+		}
+		mobile = strings.TrimRight(mobile, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(mobile)
+		if e != nil {
+			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
+			return
+		}
+		first := "【" + v.ResearchTheme + "】专项调研因专家安排变动,本次调研活动延期举办,具体时间另行通知"
+		keyword1 := v.ResearchTheme
+		keyword2 := "已取消"
+		keyword3 := ""
+		keyword4 := ""
+		remark := ""
+
+		openIdArr := make([]string, 0)
+		for _, vOpenid := range openIdList {
+			openIdArr = append(openIdArr, vOpenid.OpenId)
+		}
+		companyIdsLen := len(companyIds)
+		if len(companyIds) > 0 {
+			pars = make([]interface{}, 0)
+			condition = ` AND p.company_id IN (` + utils.GetOrmInReplace(companyIdsLen) + `)  GROUP BY  p.company_id  `
+			pars = append(pars, companyIds)
+			listSeller, e := models.GetAdminOpendidByCompany(condition, pars)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = errors.New("GetAdminOpendidByCompany, Err: " + e.Error())
+				return
+			}
+			if len(listSeller) > 0 {
+				for _, vOpenid := range listSeller {
+					openIdArr = append(openIdArr, vOpenid.OpenId)
+				}
+			}
+		}
+		redirectUrl := ""
+		sendInfo := new(SendWxTemplate)
+		sendInfo.First = first
+		sendInfo.Keyword1 = keyword1
+		sendInfo.Keyword2 = keyword2
+		sendInfo.Keyword3 = keyword3
+		sendInfo.Keyword4 = keyword4
+		sendInfo.Remark = remark
+		sendInfo.TemplateId = utils.WxMsgTemplateIdArticleUserRemind
+		sendInfo.RedirectUrl = redirectUrl
+		sendInfo.RedirectTarget = 3
+		sendInfo.Resource = strconv.Itoa(v.ActivityId)
+		sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+		sendInfo.OpenIdArr = openIdArr
+		fmt.Println(sendInfo)
+		err = PublicSendTemplateMsg(sendInfo)
+	}
+	return
+}

+ 127 - 0
services/activity_special_trip.go

@@ -0,0 +1,127 @@
+package services
+
+import (
+	"errors"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"time"
+)
+
+func SpecialTripPopupMsg(activityInfo *models.CygxActivitySpecialDetail, user *models.WxUserItem) (signupStatus int, popupMsg, popupMsg2 string, err error) {
+	//SignupStatus  int    `description:"返回状态:1:成功 、2 :人数已满 、3:调研次数已用完、 4:超时"`
+	signupStatus = 1
+	resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
+	if time.Now().After(resultTime.Add(-time.Minute * 60)) {
+		signupStatus = 4
+		popupMsg = "活动开始前1小时内无法报名,请联系对口销售处理"
+		return
+	}
+
+	errMsg, _, e := GetTripRemainingtimesBycompany(user, activityInfo)
+	if e != nil {
+		err = errors.New("获取客户剩余报名次数失败 GetActivitySpecialUserType, Err: " + e.Error())
+		return
+	}
+	if errMsg != "" {
+		popupMsg = errMsg
+		signupStatus = 3
+		return
+	}
+	var condition string
+	var pars []interface{}
+
+	condition += ` AND activity_id =  ? AND  is_cancel = 0 `
+	pars = append(pars, activityInfo.ActivityId)
+
+	tripTota, e := models.GetActivitySpecialTripCountByActivityId(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
+		return
+	}
+	if activityInfo.LimitPeopleNum-tripTota < 1 {
+		signupStatus = 2
+		popupMsg = "此活动报名人数已满,请留意下期活动"
+		return
+	}
+	//signupStatus = 4
+	popupMsg = "感谢参与,本次报名会扣除一次贵司在弘则的调研点数。"
+	popupMsg2 = "由于每场活动人数有限,如果不能参加请提前48小时取消,未及时取消导致影响其他客户报名将会维持扣点。"
+	return
+}
+
+//获取用户剩余报名次数
+func GetTripRemainingtimesBycompany(user *models.WxUserItem, activityInfo *models.CygxActivitySpecialDetail) (errMsg string, tripRemaining int, err error) {
+
+	//获取 专项调研客户类型   //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户;6、冻结客户;7、流失客户 8:行业升级套餐客户
+	msgTemplate := "您的专项调研次数已用完,如仍想参加,请与您的对口销售商议"
+	var tripTota int
+	var airborneTota int
+	userType, _, e := GetActivitySpecialUserType(user.CompanyId)
+	if e != nil {
+		err = errors.New("获取客户身份信息失败 GetActivitySpecialUserType, Err: " + e.Error())
+		return
+	}
+	if userType == 0 {
+		errMsg = msgTemplate
+		return
+	} else if userType == 1 {
+		tripRemaining = 999
+		return
+	} else if userType == 2 {
+		var condition string
+		var pars []interface{}
+
+		condition += ` AND company_id = ? `
+		pars = append(pars, user.CompanyId)
+
+		airborneTota, e = models.GetActivitySpecialTripAirborneCountByActivitySpecial(condition, pars)
+		if e != nil {
+			err = errors.New("GetActivitySpecialTripAirborneCountByActivitySpecial, Err: " + e.Error())
+			return
+		}
+
+		condition += ` AND is_valid = 1 `
+
+		tripTota, e = models.GetActivitySpecialTripCountByActivitySpecial(condition, pars)
+		if e != nil {
+			err = errors.New("GetActivitySpecialTripCountByActivitySpecial, Err: " + e.Error())
+			return
+		}
+		tripTota += airborneTota
+		if tripTota >= 12 {
+			errMsg = msgTemplate
+			return
+		}
+		tripRemaining = 12 - tripTota
+	} else {
+		var condition string
+		var pars []interface{}
+
+		condition += ` AND company_id = ? `
+		pars = append(pars, user.CompanyId)
+
+		condition += ` AND chart_permission_id = ? `
+		pars = append(pars, activityInfo.ChartPermissionId)
+
+		airborneTota, e = models.GetActivitySpecialTripAirborneCountByActivitySpecial(condition, pars)
+		if e != nil {
+			err = errors.New("GetActivitySpecialTripAirborneCountByActivitySpecial, Err: " + e.Error())
+			return
+		}
+
+		condition += ` AND is_valid = 1 `
+
+		tripTota, e = models.GetActivitySpecialTripCountByActivitySpecial(condition, pars)
+		if e != nil {
+			err = errors.New("GetActivitySpecialTripCountByActivitySpecial, Err: " + e.Error())
+			return
+		}
+		tripTota += airborneTota
+		if tripTota >= 6 {
+			errMsg = msgTemplate
+			return
+		}
+		tripRemaining = 6 - tripTota
+	}
+	return
+}

+ 42 - 139
services/article.go

@@ -672,7 +672,7 @@ func GetArticleListByApi(cont context.Context) (err error) {
 }
 
 //func init() {
-//	HandleArticleListByApi(5978)
+//	HandleArticleListByApi(6005)
 //}
 
 //处理同步过来的文章
@@ -736,12 +736,22 @@ func HandleArticleListByApi(artcleId int) (err error) {
 		}
 	}
 	var list []*models.Tactics2
+	var listArticleData []*models.CygxArticleData
 	var listAuthor []*models.CygxArticleAuthor
+	//如果是英文报告那么则不同步
+	if articleResult.TypeId == 9 {
+		return
+	}
 
 	//状态等于 2 跟 4 的进行同步
 	if exitMap[articleResult.SeriesId] > 0 && (articleResult.PublishStatus == 2 || articleResult.PublishStatus == 4) {
 		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)
 		item := new(models.Tactics2)
+		itemArticleData := new(models.CygxArticleData)
+		itemArticleData.ArticleId = articleResult.ArticleId
+		itemArticleData.Cover = articleResult.Cover
+		itemArticleData.CreateTime = time.Now()
+		listArticleData = append(listArticleData, itemArticleData)
 		itemAuthor := new(models.CygxArticleAuthor)
 		item.ArticleId = articleResult.ArticleId
 		item.Title = articleResult.Title
@@ -780,10 +790,12 @@ func HandleArticleListByApi(artcleId int) (err error) {
 		}
 		item.FieldName = articleResult.Field.Name
 		item.TypeName = articleResult.Type.Name
+		item.UpdateDate = articleResult.UpdateDate
 		list = append(list, item)
 		itemAuthor.ArticleId = articleResult.ArticleId
 		itemAuthor.Name = articleResult.Author.Name
 		itemAuthor.Mobile = articleResult.Author.PhoneNumber
+		fmt.Println(articleResult.Cover)
 		listAuthor = append(listAuthor, itemAuthor)
 	} else {
 		// 如果这篇文章没有发布,那么就不作处理。
@@ -794,7 +806,6 @@ func HandleArticleListByApi(artcleId int) (err error) {
 		}
 		go models.UpdateCygxArticleCeluePush(artcleId)
 		return err
-
 	}
 
 	//同步作者
@@ -904,6 +915,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 				return err
 			}
 			v.CategoryId = detailCategory.CategoryId
+			v.IsSummary = 0
 		}
 
 		if count > 0 {
@@ -949,6 +961,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			updateParams["FieldName"] = v.FieldName
 			updateParams["Annotation"] = v.Annotation
 			updateParams["TypeName"] = v.TypeName
+			updateParams["ModifyTimeByCl"] = v.UpdateDate
 			whereParam := map[string]interface{}{"article_id": v.ArticleId}
 			err = models.UpdateByExpr(models.CygxArticle{}, whereParam, updateParams)
 			if err != nil {
@@ -989,6 +1002,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			item.FieldName = v.FieldName
 			item.Annotation = v.Annotation
 			item.TypeName = v.TypeName
+			item.ModifyTimeByCl = v.UpdateDate
 			newId, err := models.AddCygxArticles(item)
 			if err != nil {
 				fmt.Println("AddCygxArticle Err:", err.Error())
@@ -1075,143 +1089,6 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			}
 		}
 
-		//类型ID 医药(医享会:28 、药调研:301)、消费【渠道新声:32】、科技【科技前言:79】、智造【匠心智造:84】或者是纪要做消息模板推送
-		fmt.Println(v.CategoryId)
-		//if v.IsSummary == 1 || (v.CategoryId == 28 || v.CategoryId == 301 || v.CategoryId == 32 || v.CategoryId == 79 || v.CategoryId == 84) {
-		//	sliceSubjects := strings.Split(v.Stock, "/")
-		//	fmt.Println(sliceSubjects)
-		//	if len(sliceSubjects) > 0 {
-		//		var subjectStr string
-		//		for _, vSubject := range sliceSubjects {
-		//			sliceKuohao := strings.Split(vSubject, "(")           //过滤括号
-		//			sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
-		//			subject := sliceXiahuaxian[0]
-		//			subjectStr += "'" + subject + "',"
-		//		}
-		//		if subjectStr != "" {
-		//			subjectStr = strings.TrimRight(subjectStr, ",")
-		//			activityIdList, err := models.GetActivityIdListBySubjecName(subjectStr)
-		//			if err != nil {
-		//				fmt.Println("GetActivityIdListBySubjecName Err:", err.Error())
-		//				return err
-		//			}
-		//			if len(activityIdList) > 0 {
-		//				var activityIdStr string
-		//				for _, vAct := range activityIdList {
-		//					activityIdStr += strconv.Itoa(vAct.ActivityId) + ","
-		//				}
-		//				activityIdStr = strings.TrimRight(activityIdStr, ",")
-		//				if activityIdStr != "" {
-		//					appointmentList, err := models.GetAppointmentListByActivityId(activityIdStr, "1,2,5")
-		//					if err != nil {
-		//						fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
-		//						return err
-		//					}
-		//					if len(appointmentList) > 0 {
-		//						for _, vApp := range appointmentList {
-		//
-		//							appointmentByMobileList, err := models.GetAppointmentListByActivityIdAndMobile(activityIdStr, vApp.Mobile)
-		//							if err != nil {
-		//								fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
-		//								return err
-		//							}
-		//							var appointmentActivityName string
-		//							if len(appointmentByMobileList) > 0 {
-		//								for _, vAppM := range appointmentByMobileList {
-		//									appointmentActivityName += vAppM.ActivityName + ","
-		//								}
-		//							}
-		//							appointmentActivityName = strings.TrimRight(appointmentActivityName, ",")
-		//							if vApp.ActivityTypeId == 5 && v.CategoryId != 301 {
-		//								continue
-		//							}
-		//
-		//							if vApp.Mobile != "" {
-		//								openIdListByAppointment, err := models.GetUserRecordListByMobile(4, vApp.Mobile)
-		//								if err != nil {
-		//									fmt.Println(err)
-		//									return err
-		//								}
-		//								keyword1 := "您预约的调研,有关联的纪要发布/更新了"
-		//								keyword2 := appointmentActivityName
-		//								keyword3 := v.Title
-		//								keyword4 := v.PublishDate.Format(utils.FormatDateTime)
-		//								SendWxMsgWithArticleClassToAdmin(keyword1, keyword2, keyword3, keyword4, openIdListByAppointment, artcleId)
-		//							}
-		//						}
-		//					}
-		//				}
-		//			}
-		//		}
-		//	}
-		//}
-		//
-		////【公司调研】系列纪要发布/更新后
-		//if v.CategoryId == 45 || v.CategoryId == 74 || v.CategoryId == 86 || v.CategoryId == 88 {
-		//	fmt.Println("处理预约纪要")
-		//	sliceSubjects := strings.Split(v.Stock, "/")
-		//	if len(sliceSubjects) > 0 {
-		//		var subjectStr string
-		//		for _, vSubject := range sliceSubjects {
-		//			sliceKuohao := strings.Split(vSubject, "(")           //过滤括号
-		//			sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
-		//			subject := sliceXiahuaxian[0]
-		//			subjectStr += "'" + subject + "',"
-		//		}
-		//		if subjectStr != "" {
-		//			subjectStr = strings.TrimRight(subjectStr, ",")
-		//			activityIdList, err := models.GetActivityIdListBySubjecName(subjectStr)
-		//			if err != nil {
-		//				fmt.Println("GetActivityIdListBySubjecName Err:", err.Error())
-		//				return err
-		//			}
-		//			if len(activityIdList) > 0 {
-		//				var activityIdStr string
-		//				for _, vAct := range activityIdList {
-		//					activityIdStr += strconv.Itoa(vAct.ActivityId) + ","
-		//				}
-		//				activityIdStr = strings.TrimRight(activityIdStr, ",")
-		//				if activityIdStr != "" {
-		//					appointmentList, err := models.GetAppointmentListByActivityId(activityIdStr, "3,4")
-		//					if err != nil {
-		//						fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
-		//						return err
-		//					}
-		//					if len(appointmentList) > 0 {
-		//						for _, vApp := range appointmentList {
-		//							appointmentByMobileList, err := models.GetAppointmentListByActivityIdAndMobile(activityIdStr, vApp.Mobile)
-		//							if err != nil {
-		//								fmt.Println("GetAppointmentListByActivityId Err:", err.Error())
-		//								return err
-		//							}
-		//							var appointmentActivityName string
-		//							if len(appointmentByMobileList) > 0 {
-		//								for _, vAppM := range appointmentByMobileList {
-		//									appointmentActivityName += vAppM.ActivityName + ","
-		//								}
-		//							}
-		//							appointmentActivityName = strings.TrimRight(appointmentActivityName, ",")
-		//							if vApp.Mobile != "" {
-		//								openIdListByAppointment, err := models.GetUserRecordListByMobile(4, vApp.Mobile)
-		//								if err != nil {
-		//									fmt.Println(err)
-		//									return err
-		//								}
-		//								keyword1 := "您预约的调研,有关联的纪要发布/更新了"
-		//								keyword2 := appointmentActivityName
-		//								keyword3 := v.Title
-		//								keyword4 := v.PublishDate.Format(utils.FormatDateTime)
-		//								SendWxMsgWithArticleClassToAdmin(keyword1, keyword2, keyword3, keyword4, openIdListByAppointment, artcleId)
-		//
-		//							}
-		//						}
-		//					}
-		//				}
-		//			}
-		//		}
-		//	}
-		//}
-
 		//【公司调研】系列纪要发布/更新后 end
 
 		//查研观向6.9模板消息推送规则
@@ -1222,6 +1099,32 @@ func HandleArticleListByApi(artcleId int) (err error) {
 	}
 	go models.UpdateCygxArticleCeluePush(artcleId)
 
+	if len(listArticleData) > 0 {
+		for _, v := range listArticleData {
+			count, err := models.GetCygxArticleDataCount(v.ArticleId)
+			if err != nil {
+				fmt.Println("GetCygxArticleDataCount Err:", err.Error())
+				return err
+			}
+			if count == 0 {
+				_, err := models.AddCygxArticleData(v)
+				if err != nil {
+					fmt.Println("AddCygxArticleData Err:", err.Error())
+					return err
+				}
+			}
+			//} else {
+			//	updateParams := make(map[string]interface{})
+			//	updateParams["Cover"] = v.Cover
+			//	whereParam := map[string]interface{}{"article_id": v.ArticleId}
+			//	err = models.UpdateByExpr(models.CygxArticleData{}, whereParam, updateParams)
+			//	if err != nil {
+			//		fmt.Println("UpdateByExpr CygxArticleData Err:" + err.Error())
+			//		return err
+			//	}
+			//}
+		}
+	}
 	return err
 }
 

+ 77 - 0
services/company_permission.go

@@ -0,0 +1,77 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strings"
+)
+
+//GetCompanyPermission 获取公司对应的权限名称
+func GetCompanyPermission(companyId int) (permissionStr string, err error) {
+	permissionStr, err = models.GetCompanyPermission(companyId)
+	if err != nil {
+		return
+	}
+	permissionStr = strings.Replace(permissionStr, "(主观)", "", -1)
+	permissionStr = strings.Replace(permissionStr, "(客观)", "", -1)
+	return
+}
+
+//GetCompanyPermissionUpgrade 获取公司对应的升级权限名称
+func GetCompanyPermissionUpgrade(companyId int) (permissionStr string, err error) {
+	permissionStr, err = models.GetCompanyPermissionByUserTrip(companyId)
+	if err != nil {
+		return
+	}
+	permissionStr = strings.Replace(permissionStr, "(主观)", "", -1)
+	permissionStr = strings.Replace(permissionStr, "(客观)", "", -1)
+	return
+}
+
+//获取用户对应的权限申请状态
+func GetUserHasPermission(user *models.WxUserItem) (hasPermission int, sellerName, sellerMobile, popupMsg string, err error) {
+	//HasPermission     int    `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请,5:有IFCC、无权益"`
+	uid := user.UserId
+	applyCount, e := models.GetApplyRecordCount(uid)
+	if e != nil {
+		err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
+		return
+	}
+	if user.CompanyId <= 1 {
+		if applyCount == 0 {
+			hasPermission = 3
+		} else {
+			hasPermission = 4
+		}
+	} else {
+		companyPermission, e := models.GetCompanyPermission(user.CompanyId)
+		if e != nil {
+			err = errors.New("GetCompanyPermission, Err: " + e.Error())
+			return
+		}
+		if companyPermission != "" {
+			if applyCount > 0 {
+				hasPermission = 4
+			} else {
+				//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
+				sellerItemQy, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+				if e != nil && e.Error() != utils.ErrNoRow() {
+					err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
+					return
+				}
+				fmt.Println(sellerItemQy)
+				if sellerItemQy != nil {
+					hasPermission = 2
+					sellerName = sellerItemQy.Mobile
+					sellerMobile = sellerItemQy.RealName
+				} else {
+					hasPermission = 5
+				}
+			}
+		}
+	}
+	popupMsg = "需要升级行业套餐权限才可参与此活动,请联系对口销售"
+	return
+}

+ 12 - 0
services/config.go

@@ -17,3 +17,15 @@ func GetShowSustainable() (isShowSustainable bool) {
 	}
 	return
 }
+
+func GetShowSustainableNew() (isShowSustainable bool, err error) {
+	total, err := models.GetShowSustainable()
+	if err != nil {
+		fmt.Println("GetShowSustainable Err:", err.Error())
+		return
+	}
+	if total > 0 {
+		isShowSustainable = true
+	}
+	return
+}

+ 9 - 5
services/micro_roadshow.go

@@ -3,6 +3,7 @@ package services
 import (
 	"encoding/json"
 	"errors"
+	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
 )
@@ -162,7 +163,7 @@ func GetHomeNewestList(userId, companyId, startSize, pageSize int, condition str
 }
 
 // GetMicroRoadShowPageList 获取微路演列表添加活动视频 更新与8.1版本
-func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId int, keywords string) (respList []*models.MicroRoadShowPageList, total int, err error) {
+func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter int, keywords string) (respList []*models.MicroRoadShowPageList, total int, err error) {
 	var e error
 	// 根据每页数据量获取音视频配比
 	startSize := utils.StartIndex(currentIndex, pageSize)
@@ -174,8 +175,10 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 	//音频的查询
 	var audioCond string
 	var audioPars []interface{}
-	// 如果筛选条件为指定视频ID则不做音频查询
-	if videoId > 0 || activityVideoId > 0 {
+	// 如果筛选条件为指定视频ID或只看视频则不做音频查询
+	fmt.Println("filter:", filter)
+	if videoId > 0 || activityVideoId > 0 || filter == 1{
+		fmt.Println("11111")
 		audioCond = ""
 	} else {
 		// 活动已发布且已结束
@@ -198,7 +201,8 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 	var videoCondAct string
 	var videoPars []interface{}
 	var videoParsAct []interface{}
-	if audioId > 0 {
+	if audioId > 0 || filter == 2{
+		fmt.Println("22222")
 		videoCond = ""
 	} else {
 		if keywords != "" {
@@ -230,7 +234,7 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 		//}
 		videoCond += ` AND publish_status = 1`
 	}
-	total, videoList, e = models.GetMicroRoadShowVideoPageListV8(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars, audioId, videoId, activityVideoId)
+	total, videoList, e = models.GetMicroRoadShowVideoPageListV8(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars, audioId, videoId, activityVideoId, filter)
 	if e != nil {
 		err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
 		return

+ 2 - 2
services/report_billboard.go

@@ -12,7 +12,7 @@ import (
 func UpdateDailyMonthReadBillboard(cont context.Context) (err error) {
 	defer func() {
 		if err != nil {
-			go utils.SendAlarmMsg("查研观向-每日更新月阅读飙升榜单失败, ErrMsg: " + err.Error(), 3)
+			go utils.SendAlarmMsg("查研观向-每日更新月阅读飙升榜单失败, ErrMsg: "+err.Error(), 3)
 		}
 	}()
 
@@ -38,4 +38,4 @@ func UpdateDailyMonthReadBillboard(cont context.Context) (err error) {
 		return
 	}
 	return
-}
+}

+ 11 - 0
services/send_company_user.go

@@ -146,6 +146,17 @@ func DotongbuShangHai(cont context.Context) (err error) {
 		}
 	}
 
+	//获取指定时间内被移动的客户
+	listOperationRecord, err := models.GetCompanyOperationRecord(updateTime)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return err
+	}
+	if len(listOperationRecord) > 0 {
+		for _, v := range listOperationRecord {
+			companyIds += strconv.Itoa(v.CompanyId) + ","
+		}
+	}
+
 	condition = ` AND p.is_suspend = 0  AND p.modify_time > ` + "'" + updateTime + "'"
 	companyIds = strings.TrimRight(companyIds, ",")
 

+ 6 - 0
services/task.go

@@ -96,6 +96,12 @@ func Task() {
 		addctivitySignupDetail := task.NewTask("addctivitySignupDetail", "0 0 23 * * *", AddctivitySignupDetail) // 获取当天已结束的活动的报名信息。添加到到会详情
 		task.AddTask("addctivitySignupDetail", addctivitySignupDetail)
 
+		sendWxMsgActivitySpecialTwoDays := task.NewTask("sendWxMsgActivitySpecialTwoDays", "0 0 8 * * *", SendWxMsgActivitySpecialTwoDays)
+		task.AddTask("sendWxMsgActivitySpecialTwoDays", sendWxMsgActivitySpecialTwoDays) //活动开始前两天08:00,提醒报名客户 \提醒报名客户的对口销售
+
+		sendWxMsgActivitySpecialCancel := task.NewTask("sendWxMsgActivitySpecialCancel", "0 0 8 * * *", SendWxMsgActivitySpecialCancel)
+		task.AddTask("sendWxMsgActivitySpecialCancel", sendWxMsgActivitySpecialCancel) // 线下活动前4天08:00报名人数不足7人,线上活动前3天08:00报名人数不足10人,活动自动取消发布,并推送模板消息至报名客户及对口销售
+
 	}
 	if utils.RunMode != "release" {
 		getArticleListByApi := task.NewTask("getArticleListByApi", "0 */60 * * * *", GetArticleListByApi) //通过三方接口获取策略平台上的文章

+ 57 - 0
services/wechat_send_msg.go

@@ -3,11 +3,13 @@ package services
 import (
 	"bytes"
 	"encoding/json"
+	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
 	"io/ioutil"
 	"net/http"
+	"strings"
 	"time"
 )
 
@@ -225,3 +227,58 @@ type SendTemplateResponse struct {
 	Errmsg  string `json:"errmsg"`
 	MsgID   int    `json:"msgid"`
 }
+
+type SendWxTemplate struct {
+	WxAppId        string   `description:"公众号appId"`
+	First          string   `description:"模板消息first字段"`
+	Keyword1       string   `description:"模板消息keyword1字段"`
+	Keyword2       string   `description:"模板消息keyword2字段"`
+	Keyword3       string   `description:"模板消息keyword3字段"`
+	Keyword4       string   `description:"模板消息keyword4字段"`
+	Remark         string   `description:"模板消息remark字段"`
+	TemplateId     string   `description:"模板id"`
+	RedirectUrl    string   `description:"跳转地址"`
+	RedirectTarget int      `description:"小程序跳转目标:1:弘则研报小程序,2:随手办公小程序"`
+	Resource       string   `description:"资源唯一标识"`
+	SendType       int      `description:"发送的消息类型:1:报告,2:指标更新提醒,3:审批通知,4:销售领取客户通知,5:活动取消通知,6活动更改时间通知,7:关注的作者发布报告通知,8:发送日报(周报、双周报、月报)模板消息,9:活动预约/报名时间通知"`
+	OpenIdArr      []string `description:"消息接收者openid"`
+}
+
+//推送模板消息
+func PublicSendTemplateMsg(sendInfo *SendWxTemplate) (err error) {
+	postData, err := json.Marshal(sendInfo)
+	if err != nil {
+		utils.SendAlarmMsg("SendTemplateMsg json.Marshal Err:"+err.Error(), 1)
+		return err
+	}
+	body := ioutil.NopCloser(strings.NewReader(string(postData)))
+	client := &http.Client{}
+	req, err := http.NewRequest("POST", utils.SendWxTemplateMsgUrl, body)
+	if err != nil {
+		utils.SendAlarmMsg("SendTemplateMsg http.NewRequest Err:"+err.Error(), 1)
+		return err
+	}
+	contentType := "application/json;charset=utf-8"
+	req.Header.Set("Content-Type", contentType)
+	req.Header.Set("Authorization", utils.SendTemplateMsgAuthorization)
+	resp, err := client.Do(req)
+	if err != nil {
+		fmt.Println("http client.Do Err:" + err.Error())
+		return err
+	}
+	defer resp.Body.Close()
+	b, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		return err
+	}
+	result := new(models.BaseResponse)
+	err = json.Unmarshal(b, &result)
+	if err != nil {
+		return err
+	}
+	if result.Ret != 200 {
+		err = errors.New(string(b))
+		return err
+	}
+	return
+}

+ 93 - 27
services/wx_template_msg.go

@@ -61,43 +61,68 @@ func SendWxMsgWithAsk(name, askTime, askMsg, title string, openIdList []*models.
 		}
 		fmt.Println("line 21", err, msg)
 	}()
-	utils.FileLog.Info("%s", "services SendMsg")
-	//accessToken, err := models.GetWxAccessToken()
-	accessToken, err := models.GetWxAccessTokenByXzs()
-	if err != nil {
-		msg = "GetWxAccessToken Err:" + err.Error()
-		return
-	}
-	if accessToken == "" {
-		msg = "accessToken is empty"
-		return
-	}
+	//utils.FileLog.Info("%s", "services SendMsg")
+	////accessToken, err := models.GetWxAccessToken()
+	//accessToken, err := models.GetWxAccessTokenByXzs()
+	//if err != nil {
+	//	msg = "GetWxAccessToken Err:" + err.Error()
+	//	return
+	//}
+	//if accessToken == "" {
+	//	msg = "accessToken is empty"
+	//	return
+	//}
 	var first string
 	var keyword1 string
+	var keyword2 string
 	var keyword3 string
 	var keyword4 string
 	var remark string
 	first = "研选报告有新的提问,请及时处理"
 	keyword1 = name
 	keyword3 = askTime
+	keyword2 = ""
 	keyword4 = askMsg
 	remark = title
-	sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
-	//templateId := utils.WxMsgTemplateIdAskMsg
-	templateId := utils.WxMsgTemplateIdAskMsgXzs
-	sendMap := make(map[string]interface{})
-	sendData := make(map[string]interface{})
-	sendMap["template_id"] = templateId
-	sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "pagepath": "pageMy/reportDetail/reportDetail?id=" + strconv.Itoa(articleId)}
-	//sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "path": "article/detail?ArticleId=1000001"}
-	sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
-	sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
-	sendData["keyword2"] = map[string]interface{}{"value": "", "color": "#173177"}
-	sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": "#173177"}
-	sendData["keyword4"] = map[string]interface{}{"value": keyword4, "color": "#173177"}
-	sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
-	sendMap["data"] = sendData
-	WxSendTemplateMsg(sendUrl, sendMap, openIdList, strconv.Itoa(articleId), utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD)
+	//sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
+	////templateId := utils.WxMsgTemplateIdAskMsg
+	//templateId := utils.WxMsgTemplateIdAskMsgXzs
+	//sendMap := make(map[string]interface{})
+	//sendData := make(map[string]interface{})
+	//sendMap["template_id"] = templateId
+	//sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "pagepath": "pageMy/reportDetail/reportDetail?id=" + strconv.Itoa(articleId)}
+	////sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "path": "article/detail?ArticleId=1000001"}
+	//sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
+	//sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
+	//sendData["keyword2"] = map[string]interface{}{"value": "", "color": "#173177"}
+	//sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": "#173177"}
+	//sendData["keyword4"] = map[string]interface{}{"value": keyword4, "color": "#173177"}
+	//sendData["remark"] = map[string]interface{}{"value": remark, "color": "#173177"}
+	//sendMap["data"] = sendData
+	//WxSendTemplateMsg(sendUrl, sendMap, openIdList, strconv.Itoa(articleId), utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD)
+
+	openIdArr := make([]string, 0)
+	for _, v := range openIdList {
+		openIdArr = append(openIdArr, v.OpenId)
+	}
+	redirectUrl := utils.WX_MSG_PATH_ARTICLE_DETAIL + strconv.Itoa(articleId)
+	sendInfo := new(SendWxTemplate)
+	sendInfo.First = first
+	sendInfo.Keyword1 = keyword1
+	sendInfo.Keyword2 = keyword2
+	sendInfo.Keyword3 = keyword3
+	sendInfo.Keyword4 = keyword4
+	sendInfo.Remark = remark
+	sendInfo.TemplateId = utils.WxMsgTemplateIdAskMsgXzs
+	sendInfo.RedirectUrl = redirectUrl
+	sendInfo.RedirectTarget = 3
+	sendInfo.Resource = strconv.Itoa(articleId)
+	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD
+	sendInfo.OpenIdArr = openIdArr
+	err = PublicSendTemplateMsg(sendInfo)
+	if err != nil {
+		return
+	}
 	return
 }
 
@@ -633,3 +658,44 @@ func SendActivityOnenIdWxTemplateMsg(first, keyWord1, keyWord2, keyWord3, keyWor
 	WxSendTemplateMsg(sendUrl, sendMap, openIdList, "", utils.TEMPLATE_MSG_CYGX_ARTICLE_ADD)
 	return
 }
+
+//发送用户留言提醒
+func SendCommentWxTemplateMsg(title, companyName, userName, sellerName, createTime, content string, openIdList []*models.OpenIdList, articleId int) (err error) {
+	var msg string
+	defer func() {
+		if err != nil {
+			go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
+			go utils.SendAlarmMsg(fmt.Sprint("发送用户用户留言提醒失败,文章ID:", articleId), 2)
+			utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
+		}
+	}()
+	accessToken, err := models.GetWxAccessTokenByXzs()
+	if err != nil {
+		msg = "GetWxAccessToken Err:" + err.Error()
+		return
+	}
+	if accessToken == "" {
+		msg = "accessToken is empty"
+		return
+	}
+	var first string
+	first = "【"+title+"】有新的留言,请及时处理"
+	keyword1 := companyName + "--" + userName + "(" + sellerName + ")"
+	keyword2 := "-"
+	keyword3 := createTime
+	keyword4 := content
+	sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
+	templateId := utils.WxMsgTemplateIdAskMsgXzs
+	sendMap := make(map[string]interface{})
+	sendData := make(map[string]interface{})
+	sendMap["template_id"] = templateId
+	sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "pagepath": utils.WX_MSG_PATH_ARTICLE_DETAIL + strconv.Itoa(articleId)}
+	sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
+	sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
+	sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
+	sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": "#173177"}
+	sendData["keyword4"] = map[string]interface{}{"value": keyword4, "color": "#173177"}
+	sendMap["data"] = sendData
+	WxSendTemplateMsg(sendUrl, sendMap, openIdList, strconv.Itoa(articleId), utils.TEMPLATE_MSG_CYGX_COMMENT)
+	return
+}

+ 1 - 1
utils/common.go

@@ -753,4 +753,4 @@ func InArrayByStr(idStrList []string, searchId string) (has bool) {
 		}
 	}
 	return
-}
+}

+ 7 - 1
utils/config.go

@@ -82,6 +82,11 @@ var (
 	ShangHaiCrmApiLink        string //上海CRM用户同步api调用地址
 )
 
+//模板消息推送
+var (
+	SendWxTemplateMsgUrl string
+)
+
 func init() {
 	tmpRunMode, err := web.AppConfig.String("run_mode")
 	if err != nil {
@@ -170,7 +175,7 @@ func init() {
 		ArticleTaskClassMobile = "15557270714,18767183922,15216736473,15000123056,18701809782,17706316791,18652179672"
 
 		ShangHaiCrmApiLink = "https://crm.hzinsights.com/"
-
+		SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"
 	} else {
 		WxAppId = "wxcc32b61f96720d2f"
 		WxAppSecret = "06894933fafb24dafead7eaae09c08e0"
@@ -204,6 +209,7 @@ func init() {
 		ArticleTaskClassMobile = "15557270714,18767183922,17706316791"
 
 		ShangHaiCrmApiLink = "http://106.15.192.100:8100/"
+		SendWxTemplateMsgUrl = "http://127.0.0.1:8086/v1/wechat/send_template_msg"
 	}
 
 	//查研观向小助手

+ 20 - 0
utils/constants.go

@@ -70,6 +70,7 @@ const (
 	TEMPLATE_MSG_CYGX_ACTIVITY_ADD = 12 //查研观向小程序活动更新推送 12
 	TEMPLATE_MSG_CYGX_ARTICLE_ADD  = 13 //查研观向报告更新推送  13
 	TEMPLATE_MSG_CYGX_APPLY        = 14 //查研观向审批通知
+	TEMPLATE_MSG_CYGX_COMMENT      = 15 //查研观向留言通知
 )
 
 const (
@@ -89,6 +90,7 @@ const (
 	ZHI_ZAO_NAME                     string = "智造"
 	ZHI_ZAO_ID                       int    = 19
 	LINK_WX_EXPLAIN                         = "https://mp.weixin.qq.com/s?__biz=Mzg2OTYzODk0Nw==&mid=2247483662&idx=1&sn=3752df99025189b9d77fe658bfc0edbd&chksm=ce98b742f9ef3e54b49986e647dd951a3aad74f323174b252174e0938c264c0562c8ec455106#rd" //用户阅读数据
+	ACTIVITY_SPECIAL_EXPLAIN                = "预报名专项调研行程持续更新中,满10家即开团,欢迎点击感兴趣预报名"                                                                                                                                                                //用户阅读数据
 	HZ_COMPANY_ID                    int    = 16                                                                                                                                                                                                 // 弘则公司的ID
 	HONG_GUAN_NAME                   string = "宏观"
 	HONG_GUAN_ID                     int    = 1
@@ -132,3 +134,21 @@ const (
 	COMPANY_PRODUCT_RAI_ID    = 2
 	COMPANY_PRODUCT_RAI_NAME  = "权益"
 )
+
+//微信模板消息推送公共接口的秘钥
+const (
+	SendTemplateMsgAuthorization = "dc855fce962a639faa779cbdd4cd332f"
+)
+
+//模板消息地址路由
+const (
+	WX_MSG_PATH_ARTICLE_DETAIL          = "pageMy/reportDetail/reportDetail?id="          //文章详情模板消息地址
+	WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL = "activityPages/specialDetail/specialDetail?id=" //专项调研活动模板消息地址
+)
+
+//模板消息地址路由
+const (
+	ACtIVITY_SPECIAL_EXPLAIN      = "此类调研具体行程尚未确定,待预报名人数满10人后弘则会确定行程并推送给您活动日期,只有在确定行程中再次报名才完成占位。"                        //专项调研说明
+	ACtIVITY_SPECIAL_TRIP_EXPLAIN = "此类调研时间安排已经确定,点击报名后按人次扣除对应机构的服务点数。由于每场活动人数有限,如果不能参加请提前48小时取消,未及时取消导致影响其他客户报名将会维持扣点。" //专项调研说明
+
+)