xingzai 2 лет назад
Родитель
Сommit
ca50063848
54 измененных файлов с 9277 добавлено и 44 удалено
  1. 1732 0
      controllers/activity.go
  2. 547 0
      controllers/activity_special.go
  3. 48 7
      controllers/article.go
  4. 50 0
      controllers/chart_permission.go
  5. 121 1
      controllers/home.go
  6. 125 0
      controllers/micro_roadshow.go
  7. 8 6
      controllers/report.go
  8. 406 0
      models/activity.go
  9. 238 0
      models/activity_appointment.go
  10. 92 0
      models/activity_help_ask.go
  11. 168 0
      models/activity_meeting_reminder.go
  12. 586 0
      models/activity_signup.go
  13. 157 0
      models/activity_special.go
  14. 159 0
      models/activity_special_signup.go
  15. 117 0
      models/activity_special_trip.go
  16. 66 0
      models/activity_type.go
  17. 135 0
      models/activity_video.go
  18. 106 0
      models/activity_voice.go
  19. 17 0
      models/admin.go
  20. 17 2
      models/article.go
  21. 5 7
      models/chart.go
  22. 19 1
      models/chart_permission.go
  23. 127 0
      models/company_activity_trip.go
  24. 11 0
      models/db.go
  25. 103 0
      models/industrial_activity_group_management.go
  26. 56 0
      models/industrial_article_group_management.go
  27. 29 3
      models/industrial_management.go
  28. 119 13
      models/micro_roadshow.go
  29. 2 2
      models/report_mapping.go
  30. 85 0
      models/resource_data.go
  31. 7 0
      models/seller.go
  32. 48 0
      models/user.go
  33. 40 0
      models/user_follow_special.go
  34. 2 0
      models/wx_user.go
  35. 139 0
      models/yidong.go
  36. 189 0
      routers/commentsRouter.go
  37. 11 0
      routers/router.go
  38. 862 0
      services/activity.go
  39. 369 0
      services/activity_button.go
  40. 782 0
      services/activity_special.go
  41. 127 0
      services/activity_special_trip.go
  42. 17 0
      services/admin.go
  43. 89 0
      services/article.go
  44. 122 0
      services/company_permission.go
  45. 31 0
      services/config.go
  46. 107 0
      services/micro_roadshow.go
  47. 336 0
      services/resource_data.go
  48. 3 1
      services/user_permission.go
  49. 57 0
      services/wechat_send_msg.go
  50. 57 0
      services/wx_template_msg.go
  51. 291 0
      services/yidong.go
  52. 58 0
      utils/common.go
  53. 35 1
      utils/config.go
  54. 47 0
      utils/constants.go

+ 1732 - 0
controllers/activity.go

@@ -0,0 +1,1732 @@
+package controllers
+
+import (
+	"encoding/json"
+	"fmt"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/services"
+	"hongze/hongze_clpt/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+type ActivityController struct {
+	BaseAuthController
+}
+
+// @Title 活动类型下的主题列表
+// @Description 获取活动类型下的主题列表接口
+// @Param   ChartPermissionIds   query   string  false     "行业id 多个用 , 隔开"
+// @Param   ActivityTypeIds   query   string  false     "活动类型id 多个用 , 隔开"
+// @Param   ActiveState   query   string  false       "活动进行状态 未开始:1、进行中2、已结束3 多个用 , 隔开"
+// @Param   WhichDay   query   string  false       "哪一天 今天:1、明天:2,多个用 , 隔开"
+// @Param   IsPower   query   int  false       "是否选择有权限行业 ,1是 0 否 默认0"
+// @Success 200 {object} models.ActivityTypeListHomeResp
+// @router /labelTypeList [get]
+func (this *ActivityController) LabelTypeList() {
+	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
+	}
+	chartPermissionIds := this.GetString("ChartPermissionIds")
+	isPower, _ := this.GetInt("IsPower")
+	whichDay := this.GetString("WhichDay")
+	activeState := this.GetString("ActiveState")
+	var condition string
+	var pars []interface{}
+
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
+
+	condition += `AND art.activity_time > ?  `
+	pars = append(pars, time.Now().AddDate(0, -3, 0).Format(utils.FormatDate))
+
+	conditionActivity, err := services.GetActivityonditionList(user, "", chartPermissionIds, whichDay, activeState, "", isPower, 0, "", 0)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
+		return
+	}
+	condition += `AND art.is_limit_people = 1 ` + conditionActivity
+	sortTime := ` mintimesort ASC `
+	if activeState == "3" {
+		sortTime = ` timesort DESC  `
+	}
+
+	activityList, err := models.GetCygxActivityList(condition, pars, sortTime, 0, 1000)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+
+	list, err := models.GetActivityTypeHomeList()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	list, err = services.HandleActivityTypeHomeList(list, activityList, user)
+
+	conditionActivitySpecial := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState)
+
+	speciaItem, err := services.GetActivityLabelSpecialList(user, conditionActivitySpecial)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	if len(speciaItem.List) == 0 {
+		speciaItem.List = make([]*models.CygxActivityLabelList, 0)
+	}
+	if speciaItem.ActivityTypeId > 0 {
+		list = append(list, speciaItem)
+	}
+
+	resp := new(models.ActivityTypeListHomeResp)
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 活动列表
+// @Description 获取活动列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   Label   query   string  false       "搜索主题 多个用 , 隔开"
+// @Param   ChartPermissionIds   query   string  false     "行业id 多个用 , 隔开"
+// @Param   WhichDay   query   string  false       "哪一天 今天:1、明天:2, 本周:3 上周:4,本月:5上月:6多个用 , 隔开"
+// @Param   ActiveState   query   string  false       "活动进行状态 未开始:1、进行中2、已结束3"
+// @Param   ActivityTypeId   query   string  false     "活动类型id 多个用 , 隔开"
+// @Param   Source   query   int  false     "来源 0手机 ,1Pc 默认0"
+// @Param   IsPower   query   int  false       "是否选择有权限行业 ,1是 0 否 默认0"
+// @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 /list [get]
+func (this *ActivityController) ActivityListNew() {
+	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
+	}
+	uid := user.UserId
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	source, _ := this.GetInt("Source")
+	label := this.GetString("Label")
+	chartPermissionIds := this.GetString("ChartPermissionIds")
+	whichDay := this.GetString("WhichDay")
+	//whichTime := this.GetString("WhichTime")
+	activeState := this.GetString("ActiveState")
+	activityTypeId := this.GetString("ActivityTypeId")
+	keyWord := this.GetString("KeyWord")
+	playBack, _ := this.GetInt("PlayBack")
+	filter, _ := this.GetInt("Filter")
+	activityId, _ := this.GetInt("ActivityId") // 仅用于判断【新】标签
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = utils.StartIndex(currentIndex, pageSize)
+	var condition string
+	var pars []interface{}
+	//var activityList []*models.ActivityDetail
+	//mapDingActivityId := make(map[int]int)
+	condition = ""
+	//活动可见限制
+	conditionActivity, err := services.GetActivityonditionList(user, activityTypeId, chartPermissionIds, whichDay, activeState, label, 0, source, 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
+	total, err := models.GetActivityCount(condition, playBack, pars, filter)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	var conditionOrder string
+	if activeState == "2" || activeState == "3" {
+		conditionOrder = ` ORDER BY art.activity_time DESC  `
+	} else if activeState == "2,3" {
+		conditionOrder = ` ORDER BY art.active_state ASC, art.activity_time DESC  `
+	} else {
+		conditionOrder = ` ORDER BY art.activity_time DESC ,  art.active_state ASC   `
+	}
+
+	if label != "" && activeState == "1" {
+		conditionOrder = ` ORDER BY art.activity_time ASC  `
+	}
+
+	if activeState == "1" {
+		conditionOrder = ` ORDER BY art.activity_time ASC  `
+	}
+
+	condition += conditionOrder
+	list, errList := models.GetActivityListNew(condition, pars, uid, startSize, pageSize, playBack, filter)
+	if errList != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + errList.Error()
+		return
+	}
+	var isShow bool
+	isShow = services.GetShowSustainable()
+	detail, err := models.GetConfigByCode("city_img_url")
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
+		return
+	}
+	detailChart, err := models.GetConfigByCode("chart_img_url")
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "行业配置信息失败,Err:" + err.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, _ := services.GetReportContentTextSub(v.Expert)
+		list[k].Expert = expertTxt
+		if v.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
+			list[k].IsCClassMeeting = true
+		}
+		mapActivityId = append(mapActivityId, v.ActivityId)
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(models.GetCygxActivityListRep)
+	var activityList []*models.ActivityListResp
+	resp.Label = label
+	if activityTypeId != "" && label == "" {
+		activityTypeIdint, err := strconv.Atoi(activityTypeId)
+		if err == nil {
+			detail, errDetail := models.GetActivityTypeDetailById(activityTypeIdint)
+			if errDetail != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取信息失败,Err:" + errDetail.Error()
+				return
+			}
+			resp.ImgUrl = detail.OnlineIco
+			resp.Label = detail.ActivityTypeName
+		}
+	}
+	//处理音频回放
+	mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
+		return
+	}
+
+	//处理视频回放
+	mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
+		return
+	}
+
+	//用户权限
+	authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
+		return
+	}
+
+	for k, v := range list {
+
+		au := new(models.UserPermissionAuthInfo)
+		au.SellerName = authInfo.SellerName
+		au.SellerMobile = authInfo.SellerMobile
+		au.HasPermission = authInfo.HasPermission
+		au.OperationMode = authInfo.OperationMode
+		if au.HasPermission == 1 {
+			// 非宏观权限进一步判断是否有权限
+			if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
+				au.HasPermission = 2
+			}
+		}
+
+		// 无权限的弹框提示
+		if au.HasPermission != 1 {
+			if au.OperationMode == services.UserPermissionOperationModeCall {
+				if v.FileType == 1 {
+					au.PopupMsg = services.UserPermissionPopupMsgCallMicroVoice
+				} else {
+					au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
+				}
+			} else {
+				if v.FileType == 1 {
+					au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVoice
+				} else {
+					au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
+				}
+			}
+		}
+		list[k].AuthInfo = au
+		if mapActivityVoice[v.ActivityId] != nil {
+			list[k].FileType = 1
+			list[k].AudioLink = true
+			if au.HasPermission == 1 {
+				list[k].VoiceList = mapActivityVoice[v.ActivityId]
+			}
+		}
+		if mapActivityVideo[v.ActivityId] != nil {
+			list[k].FileType = 2
+			list[k].AudioLink = true
+			if au.HasPermission == 1 {
+				list[k].VideoDetail = mapActivityVideo[v.ActivityId]
+			}
+		}
+		activityList = append(activityList, services.ActivityButtonShow(list[k], user))
+	}
+
+	// 查研观向7.4-判断标签是否为产业, 为产业时是否跳转资源包
+	if label != "" {
+		industry, e := models.GetIndustryByName(label)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取标签产业失败, Err:" + e.Error()
+			return
+		}
+		if industry != nil {
+			sourceIndustry, e := models.GetSourceIndustryByName(label)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取标签产业资源包失败, Err:" + e.Error()
+				return
+			}
+			if sourceIndustry != nil {
+				resp.IndustrialManagementId = sourceIndustry.IndustrialManagementId
+				resp.ChartPermissionId = sourceIndustry.ChartPermissionId
+				resp.IsJump = true
+				// 研选产业不跳资源包
+				if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
+					resp.IsJump = false
+				}
+			}
+		}
+		// 新标签
+		if activityId > 0 && activeState != "3" {
+			activityIds := []int{activityId}
+
+			activityNewMap, _, e := services.GetActivityNewLabelMap(activityIds)
+			if e != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取活动新标签失败, Err: " + e.Error()
+				return
+			}
+			resp.IndustryNewLabel = activityNewMap[activityId]
+		}
+	}
+
+	//添加活动搜索记录
+	//if keyWord != "" {
+	//	go services.AddActivitykeyWordSearch(keyWord, user)
+	//}
+	fmt.Println(resp.Label)
+	//预处理返给前端的字段
+	resp.List = activityList
+	fmt.Println(len(resp.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.CygxActivityResp
+// @router /detail [get]
+func (this *ActivityController) Detail() {
+	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.CygxActivityResp)
+	activityInfo, err := models.GetAddActivityInfoByIdShow(uid, activityId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取活动详情信息失败,Err:" + err.Error()
+		return
+	}
+	if activityInfo == nil {
+		br.Msg = "活动不存在"
+		br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if activityInfo.ActivityTypeId == utils.C_CLASS_ACTIVITY_TYPE_ID {
+		activityInfo.IsCClassMeeting = true
+	}
+	havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
+		return
+	}
+	if havePower {
+		resp.HasPermission = 1
+		detailResp := services.ActivityButtonShow(activityInfo, user)
+		detailResp, err = services.ActivityDetaailShow(detailResp)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "ActivityDetaailShow Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
+			return
+		}
+		//处理活动关联的产业
+		industrialList, err := models.GetIndustrialActivityGroupManagementList(activityId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
+			return
+		}
+		if activityInfo.TemporaryLabel != "" {
+			industrialList = make([]*models.IndustrialManagementRep, 0)
+			item := new(models.IndustrialManagementRep)
+			item.IndustryName = activityInfo.Label
+			industrialList = append(industrialList, item)
+		} else {
+			industryIds := make([]int, 0)
+			var industrialManagementId string
+			for k, v := range industrialList {
+				if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
+					industrialList[k].IsResearch = true
+				}
+				industryIds = append(industryIds, v.IndustrialManagementId)
+				industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
+			}
+
+			// 查研观向7.4-行业新标签
+			industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
+			if e != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
+				return
+			}
+			//判断产业下是否有关联的报告,并处理是否跳转
+			industrialManagementId = strings.TrimRight(industrialManagementId, ",")
+			if industrialManagementId != "" {
+				var condition string
+				condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
+				condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
+				listIndustrialGrop, err := models.GetSearchResourceList(condition)
+				if err != nil && err.Error() != utils.ErrNoRow() {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
+					return
+				}
+				mapIndustrial := make(map[int]int)
+				if len(listIndustrialGrop) > 0 {
+					for _, v := range listIndustrialGrop {
+						mapIndustrial[v.IndustrialManagementId] = v.IndustrialManagementId
+					}
+				}
+				for k, v := range industrialList {
+					if mapIndustrial[v.IndustrialManagementId] > 0 && !industrialList[k].IsResearch {
+						industrialList[k].IsJump = true
+					}
+					if activityInfo.ActivityTypeId == 1 {
+						industrialList[k].IndustryNewLabel = industryNewMap[v.IndustrialManagementId]
+					}
+				}
+			}
+		}
+		//if activityInfo.YidongActivityId != "" {
+		//	ydTgc, _ := services.GetYiDongCreateUserInfo(user)
+		//	yidongLongLink, err := services.GetYiDongOriginalLink(activityInfo)
+		//	if err != nil {
+		//		br.Msg = "获取信息失败"
+		//		br.ErrMsg = "GetYiDongOriginalLink,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
+		//		return
+		//	}
+		//	detailResp.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
+		//}
+		if len(industrialList) > 0 {
+			detailResp.Label = ""
+		}
+		detailResp.Listndustrial = industrialList
+
+		//处理音频回放
+		var mapActivityId []int
+		mapActivityId = append(mapActivityId, activityId)
+		mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)
+			return
+		}
+		if mapActivityVoice[activityId] != nil {
+			detailResp.FileType = 1
+			detailResp.AudioLink = true
+			detailResp.VoiceDetail = mapActivityVoice[activityId]
+		}
+		//处理视频回放
+		mapActivityVideo, err := services.GetActivityVideoResp(mapActivityId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "GetActivityVideoResp,Err:" + err.Error()
+			return
+		}
+
+		if mapActivityVideo[activityId] != nil {
+			detailResp.FileType = 2
+			detailResp.AudioLink = true
+			detailResp.VideoDetail = mapActivityVideo[activityId]
+		}
+
+		resp.Detail = detailResp
+	} else {
+		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		popupMsg = "暂无查看权限"
+		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.ActivitySingnupRep true "type json string"
+// @Success Ret=200 {object} models.SignupStatus
+// @router /signup/add [post]
+func (this *ActivityController) SignupAdd() {
+	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
+	signupStatus := ""
+	var req models.ActivitySingnupRep
+	resp := new(models.SignupStatus)
+	var total int
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	signupType := req.SignupType
+	hasPermission := 0
+	if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
+		resp.GoBindEmail = true
+	}
+	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+
+	havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
+		return
+	}
+	if havePower {
+		item := new(models.CygxActivitySignup)
+		item.RegisterPlatform = utils.REGISTER_PLATFORM
+		resp.HasPermission = 1
+		hasPermission = 1
+		signupStatus = "Success"
+		resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
+		if time.Now().After(resultTime.Add(-time.Minute * 60)) {
+			signupStatus = "Overtime"
+			resp.SignupType = signupType
+			resp.SignupStatus = signupStatus
+			resp.HasPermission = hasPermission
+			resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
+			br.Ret = 200
+			br.Success = true
+			br.Msg = ""
+			br.Data = resp
+			return
+		}
+		var sellerName string
+		sellerName, err = models.GetCompanySellerName(user.CompanyId)
+		if err != nil {
+			br.Msg = "报名失败!"
+			br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+			return
+		}
+		//人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
+		//如果是下面几种情况则对报名信息做判断限制 (公司调研电话会(限制人数)、公司线下调研、专家/分析师线下沙龙)
+		//if (activityInfo.ActivityTypeId == 3 && activityInfo.IsLimitPeople == 1) || activityInfo.ActivityTypeId > 3 {
+		if activityInfo.IsLimitPeople == 1 {
+			//判断优先级:总人数限制→单机构2人限制→爽约3次限制
+			totalRestrict, err := models.GetUserRestrictCount(user.Mobile)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+				return
+			}
+			if totalRestrict >= 1 {
+				signupStatus = "BreakPromise"
+				resp.PopupMsg = "由于爽约次数过多,您暂时被限制报名资格"
+				item.FailType = 3
+			}
+			totalSignupCompany, err := models.GetActivitySignupCompanyCount(activityId, user.CompanyId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+				return
+			}
+			if totalSignupCompany >= 2 {
+				signupStatus = "TwoPeople"
+				resp.PopupMsg = "单机构最多2人报名同一活动,您所在机构报名人数已满"
+				item.FailType = 2
+			}
+			totaSignupPeopleNum, err := models.GetActivitySignupSuccessCount(activityId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+				return
+			}
+			if totaSignupPeopleNum >= activityInfo.LimitPeopleNum {
+				signupStatus = "FullStarffed"
+				resp.PopupMsg = "此活动报名人数已满,请留意下期活动"
+				item.FailType = 1
+			}
+			totalUserRestrictCount, err := models.GetActivitySignupByUserRestrictCount(uid, activityId)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取失败,Err:" + err.Error()
+				return
+			}
+			//解除报名限制之后二次报名相同活动
+			if totalUserRestrictCount > 0 && totalRestrict == 0 && resp.GoBindEmail != true {
+				item.UserId = uid
+				item.RealName = user.RealName
+				item.SellerName = sellerName
+				item.ActivityId = activityId
+				item.CreateTime = time.Now()
+				item.Mobile = user.Mobile
+				item.Email = user.Email
+				item.CompanyId = user.CompanyId
+				item.CompanyName = user.CompanyName
+				item.SignupType = signupType
+				item.FailType = 0
+				item.DoFailType = 0
+				_, errSignup := models.AddActivitySignupByRestrict(item)
+				if errSignup != nil {
+					br.Msg = "操作失败"
+					br.ErrMsg = "操作失败,Err:" + errSignup.Error()
+					return
+				}
+				resp.HaqveJurisdiction = true
+				resp.SignupType = signupType
+				resp.SignupStatus = "Success"
+				resp.HasPermission = hasPermission
+				resp.ActivityId = activityId
+				total, err = models.GetUserMeetingReminderCount(user.UserId)
+				if err != nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
+					return
+				}
+				if total == 0 {
+					resp.GoFollow = true
+				}
+				br.Ret = 200
+				br.Success = true
+				br.Msg = "操作成功"
+				br.Data = resp
+				return
+			}
+			totalMy, err := models.GetActivitySignupByUserCount(uid, activityId)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取失败,Err:" + err.Error()
+				return
+			}
+
+			if signupStatus != "Success" && totalMy == 0 && resp.GoBindEmail != true {
+				item.UserId = uid
+				item.RealName = user.RealName
+				item.SellerName = sellerName
+				item.ActivityId = activityId
+				item.CreateTime = time.Now()
+				item.Mobile = user.Mobile
+				item.Email = user.Email
+				item.CompanyId = user.CompanyId
+				item.CompanyName = user.CompanyName
+				item.SignupType = signupType
+				item.DoFailType = item.FailType
+				if user.OutboundMobile != "" {
+					item.OutboundMobile = user.OutboundMobile
+					if user.OutboundCountryCode == "" {
+						item.CountryCode = "86"
+					} else {
+						item.CountryCode = user.OutboundCountryCode
+					}
+				} else {
+					item.OutboundMobile = user.Mobile
+					if user.CountryCode == "" {
+						item.CountryCode = "86"
+					} else {
+						item.CountryCode = user.CountryCode
+					}
+				}
+				//添加报名信息,但是不加入日程
+				_, errSignup := models.AddActivitySignupNoSchedule(item)
+				if errSignup != nil {
+					br.Msg = "操作失败"
+					br.ErrMsg = "操作失败,Err:" + errSignup.Error()
+					return
+				}
+			}
+		}
+		totalMySuccess, err := models.GetActivitySignupCount(uid, activityId)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + err.Error()
+			return
+		}
+		if totalMySuccess > 0 {
+			br.Msg = "您已报名这个活动"
+			return
+		}
+		if signupStatus == "Success" && resp.GoBindEmail != true {
+			item.UserId = uid
+			item.RealName = user.RealName
+			item.SellerName = sellerName
+			item.ActivityId = activityId
+			item.CreateTime = time.Now()
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.CompanyId = user.CompanyId
+			item.CompanyName = user.CompanyName
+			item.SignupType = signupType
+			item.FailType = 0
+			item.DoFailType = 0
+			item.OutboundMobile = user.Mobile
+			if user.OutboundMobile != "" {
+				item.OutboundMobile = user.OutboundMobile
+				if user.OutboundCountryCode == "" {
+					item.CountryCode = "86"
+				} else {
+					item.CountryCode = user.OutboundCountryCode
+				}
+			} else {
+				item.OutboundMobile = user.Mobile
+				if user.CountryCode == "" {
+					item.CountryCode = "86"
+				} else {
+					item.CountryCode = user.CountryCode
+				}
+			}
+			_, errSignup := models.AddActivitySignup(item)
+			if errSignup != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "操作失败,Err:" + errSignup.Error()
+				return
+			}
+			resp.HaqveJurisdiction = true
+			//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 {
+		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		popupMsg = "暂无查看权限"
+		resp.PopupMsg = popupMsg
+		resp.HasPermission = hasPermission
+		resp.SellerName = sellerName
+		resp.SellerMobile = sellerMobile
+	}
+
+	if signupType == 1 && user.IsMsgOutboundMobile == 0 {
+		resp.GoOutboundMobile = true
+		if user.Mobile != "" || user.OutboundMobile != "" {
+			go models.ModifyWxUserIsMsgOutboundMobile(user.UserId)
+		}
+	}
+	if user.OutboundMobile == "" {
+		resp.Mobile = user.Mobile
+		if user.CountryCode == "" && len(user.Mobile) == 11 {
+			resp.CountryCode = "86"
+		} else {
+			resp.CountryCode = user.CountryCode
+		}
+	} else {
+		resp.Mobile = user.OutboundMobile
+		resp.CountryCode = user.OutboundCountryCode
+	}
+	//如果用户有绑定手机号,但是没有绑定外呼手机号
+	if signupType == 1 && user.Mobile != "" && user.OutboundMobile == "" {
+		var countryCode string
+		if len(user.Mobile) == 8 {
+			countryCode = "852"
+		} else if len(user.Mobile) == 9 {
+			countryCode = "886"
+		} else if len(user.Mobile) == 10 {
+			countryCode = "1"
+		} else if len(user.Mobile) >= 11 {
+			countryCode = "86"
+		}
+		models.BindUserOutboundMobileByMobile(user.Mobile, countryCode, uid)
+	}
+	resp.SignupType = signupType
+	resp.SignupStatus = signupStatus
+	//resp.HasPermission = hasPermission
+	//if signupStatus == "Success" {
+	resp.ActivityId = activityId
+	//}
+	total, err = models.GetUserSignupCount(user.UserId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
+		return
+	}
+	if total <= 1 {
+		resp.GoFollow = true
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+	br.Data = resp
+}
+
+// @Title 活动取消报名
+// @Description 活动取消报名接口
+// @Param	request	body models.ActivitySingnupRep true "type json string"
+// @Success Ret=200 {object} models.SignupStatus
+// @router /signup/cancel [post]
+func (this *ActivityController) SignupCancel() {
+	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.ActivitySingnupRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	signupType := req.SignupType
+	item := new(models.CygxActivitySignup)
+	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+	resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
+	if time.Now().After(resultTime.Add(-time.Minute * 60)) {
+		if signupType == 1 {
+			br.Msg = "活动开始前1小时内无法取消预约外呼,请联系对口销售处理"
+		} else {
+			br.Msg = "活动开始前1小时内无法取消报名,请联系对口销售处理"
+		}
+		return
+	}
+	total, err := models.GetActivitySignupCount(uid, activityId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	if total == 0 {
+		br.Msg = "您暂未报名这个活动"
+		return
+	}
+	item.UserId = uid
+	item.ActivityId = activityId
+	item.CreateTime = time.Now()
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	_, errSignup := models.CancelActivitySignup(item)
+	if errSignup != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errSignup.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+}
+
+// @Title 添加会议提醒
+// @Description 添加会议提醒接口
+// @Param	request	body models.ActivityIdRep true "type json string"
+// @Success Ret=200 {object} models.SignupStatus
+// @router /meetingReminder/add [post]
+func (this *ActivityController) MeetingReminderAdd() {
+	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
+	signupStatus := ""
+	var req models.ActivitySingnupRep
+	resp := new(models.SignupStatus)
+
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	signupType := req.SignupType
+	hasPermission := 0
+	if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
+		resp.GoBindEmail = true
+	}
+	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+
+	havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
+		return
+	}
+	if havePower {
+		item := new(models.CygxActivityMeetingReminder)
+		item.RegisterPlatform = utils.REGISTER_PLATFORM
+		resp.HasPermission = 1
+		hasPermission = 1
+		signupStatus = "Success"
+		resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
+		if time.Now().After(resultTime.Add(-time.Minute * 15)) {
+			signupStatus = "Overtime"
+			resp.SignupType = signupType
+			resp.SignupStatus = signupStatus
+			resp.HasPermission = hasPermission
+			resp.PopupMsg = "活动开始前15分钟无法设置会议提醒"
+			br.Ret = 200
+			br.Success = true
+			br.Msg = ""
+			br.Data = resp
+			return
+		}
+		hasPermission = 1
+		signupStatus = "Success"
+		totalMeeting, errMeeting := models.GetActivityMeetingReminderCount(uid, activityId)
+		if errMeeting != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
+			return
+		}
+		if totalMeeting > 0 {
+			br.Msg = "您已预约,请勿重复预约"
+			return
+		}
+		item.UserId = uid
+		item.ActivityId = activityId
+		item.CreateTime = time.Now()
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		_, errSignup := models.AddActivityMeetingReminder(item)
+		if errSignup != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,Err:" + errSignup.Error()
+			return
+		}
+		br.Msg = "设置成功,会前15分钟会为您推送微信消息提醒"
+		resp.PopupMsg = "设置成功,会前15分钟会为您推送微信消息提醒<br/><br/>请关注【查研观向小助手】公众号,以获取微信消息提醒"
+	} else {
+		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		popupMsg = "暂无查看权限"
+		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.SignupStatus
+// @router /meetingReminder/cancel [post]
+func (this *ActivityController) MeetingReminderCancel() {
+	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
+	signupStatus := "Success"
+	item := new(models.CygxActivityMeetingReminder)
+	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+	total, err := models.GetActivityMeetingReminderCount(uid, activityId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	if total == 0 {
+		br.Msg = "您暂未添加该活动会议提醒"
+		return
+	}
+	item.UserId = uid
+	item.ActivityId = activityId
+	item.CreateTime = time.Now()
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	_, errSignup := models.CancelActivityMeetingReminder(item)
+	if errSignup != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errSignup.Error()
+		return
+	}
+	resp := new(models.SignupStatus)
+	resp.SignupStatus = signupStatus
+	resp.HasPermission = 1
+	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.AppointmentResp
+// @router /appointment/add [post]
+func (this *ActivityController) ActivityAppointmentAdd() {
+	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.ActivitySingnupRep
+	resp := new(models.SignupStatus)
+
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	activityId := req.ActivityId
+	signupType := req.SignupType
+
+	if signupType == 1 && user.Mobile == "" && user.OutboundMobile == "" {
+		resp.GoBindEmail = true
+	}
+	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+
+	havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
+		return
+	}
+	if havePower {
+		item := new(models.CygxActivityAppointment)
+		item.RegisterPlatform = utils.REGISTER_PLATFORM
+		resp.HasPermission = 1
+		totalMeeting, errMeeting := models.GetUserCygxActivityAppointmentCount(uid, activityId)
+		if errMeeting != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,Err:" + errMeeting.Error()
+			return
+		}
+		if totalMeeting > 0 {
+			br.Msg = "您已预约,请勿重复预约"
+			return
+		}
+		var sellerName string
+		sellerName, err = models.GetCompanySellerName(user.CompanyId)
+		if err != nil {
+			br.Msg = "报名失败!"
+			br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+			return
+		}
+		item.UserId = uid
+		item.ActivityId = activityId
+		item.CreateTime = time.Now()
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		item.SellerName = sellerName
+		item.RealName = user.RealName
+		err = models.AddCygxActivityAppointment(item)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,Err:" + err.Error()
+			return
+		}
+		resp.SignupStatus = "Success"
+		//1:预约外呼 、2:设置会议提醒 、 3:预约纪要 、4:活动报名
+		//go services.ActivityUserRemind(user, activityInfo, 3)
+	} else {
+		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		popupMsg = "暂无查看权限"
+		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.SignupStatus
+// @router /appointment/cancel [post]
+func (this *ActivityController) ActivityAppointmentCancel() {
+	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
+	signupStatus := "Success"
+	item := new(models.CygxActivityAppointment)
+	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+	total, err := models.GetUserCygxActivityAppointmentCount(uid, activityId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	if total == 0 {
+		br.Msg = "您暂未预约该纪要"
+		return
+	}
+
+	item.UserId = uid
+	item.ActivityId = activityId
+	item.CreateTime = time.Now()
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	_, errSignup := models.CancelcygxActivityAppointment(item)
+	if errSignup != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errSignup.Error()
+		return
+	}
+	resp := new(models.SignupStatus)
+	resp.SignupStatus = signupStatus
+	resp.ActivityId = activityId
+	resp.HasPermission = 1
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "已取消"
+	br.Data = resp
+}
+
+// @Title 活动带问
+// @Description 新增活动带问接口
+// @Param	request	body models.AddCygxActivityHelpAsk true "type json string"
+// @Success Ret=200 新增成功
+// @router /askAdd [post]
+func (this *ActivityController) AskAdd() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req models.CygxActivityHelpAsk
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		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
+	//}
+	activityId := req.ActivityId
+	activityInfo, errInfo := models.GetAddActivityInfoById(activityId)
+	if activityInfo == nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	if errInfo != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+		return
+	}
+	resp := new(models.SignupStatus)
+
+	havePower, err := services.GetActivityDetailUserPower(user, activityInfo)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
+		return
+	}
+	if havePower {
+		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
+		}
+		resp.SignupStatus = "Success"
+		resp.HasPermission = 1
+		item := new(models.CygxActivityHelpAsk)
+		item.RegisterPlatform = utils.REGISTER_PLATFORM
+		item.UserId = user.UserId
+		item.ActivityId = req.ActivityId
+		item.CompanyId = user.CompanyId
+		item.CompanyName = companyDetail.CompanyName
+		item.CreateTime = time.Now()
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.Content = content
+		_, err = models.AddActivityHelpAsk(item)
+		if err != nil {
+			br.Msg = "提交失败"
+			br.ErrMsg = "提交带问失败,Err:" + err.Error()
+			return
+		}
+
+		var isSendMsg bool
+		resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
+		if activityInfo.ActivityTypeId == 1 && activityInfo.ChartPermissionId != 31 {
+			if time.Now().After(resultTime.Add(-time.Minute * 15)) {
+				isSendMsg = true
+			}
+		} else {
+			if time.Now().After(resultTime.Add(-time.Minute * 60)) {
+				isSendMsg = true
+			}
+		}
+		if isSendMsg {
+			listEmail, err := models.GetAskEmail()
+			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
+			}
+			//给研究员发送消息
+			if sendMobile != "" {
+				openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
+				if openIpItem != nil && openIpItem.OpenId != "" {
+					if sellerItem != nil {
+
+						services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
+					}
+				}
+			}
+			// 给所属销售发送消息
+			if sellerItem != nil {
+				openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
+				if openIpItem != nil && openIpItem.OpenId != "" {
+					services.SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), req.Content, activityInfo.ActivityName, openIpItem, activityInfo)
+				}
+			}
+		}
+	} else {
+		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		popupMsg = "暂无查看权限"
+		resp.PopupMsg = popupMsg
+		resp.HasPermission = hasPermission
+		resp.SellerName = sellerName
+		resp.SellerMobile = sellerMobile
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+	br.Msg = "提交成功"
+}
+
+// @Title 视频详情
+// @Description 时间线接口
+// @Param   VideoId   query   int  true       "视频ID"
+// @Success 200 {object} models.IndustryVideoDetailResp
+// @router /detailVideo [get]
+func (this *ActivityController) DetailVideo() {
+	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
+	}
+	videoId, _ := this.GetInt("VideoId")
+	videoSimple, au, err := services.GetActivityVideoDetailById(user, videoId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取用户权限失败, Err: " + err.Error()
+		return
+	}
+	resp := new(models.ActivityVideoDetailResp)
+	resp.VideoDetail = videoSimple
+	resp.AuthInfo = au
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 活动、专项调研搜索
+// @Description 活动、专项调研搜索接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  false       "搜索关键词 多个用 , 隔开"
+// @Param   PlayBack   query   int  false       "是否仅展示回放 1:是、0:否 默认0"
+// @Success 200 {object} models.GetCygxActivityListRep
+// @router /listSearch [get]
+func (this *ActivityController) 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, "", "", "", "3", "", 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
+	listActivity, total, err := services.GetActivitySpecialSearcheList(user, condition, startSize, pageSize, keyWord, playBack)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	//用户权限
+	authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
+		return
+	}
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(models.HomeResourceDataListResp)
+	var list []*models.CygxResourceDataResp
+	for _, v := range listActivity {
+		var item = new(models.CygxResourceDataResp)
+		//resp.List = append(resp.List, &models.CygxResourceDataResp{
+		item.SourceId = v.ActivityId
+		if v.SourceType == 1 {
+			item.Source = "activity"
+		} else {
+			item.Source = "activityspecial"
+		}
+		item.Title = v.ActivityName
+		item.City = v.City
+		item.IsSignup = v.IsSignup
+		item.IsCancelMeetingReminder = v.IsCancelMeetingReminder
+		item.IsAppointment = v.IsAppointment
+		item.ActiveState = v.ActiveState
+		item.ImgUrlText = v.ImgUrlText
+		item.ImgUrl = v.ImgUrl
+		item.ActivityType = v.ActivityType
+		item.IsShowOutboundCall = v.IsShowOutboundCall
+		item.IsShowMeetingReminder = v.IsShowMeetingReminder
+		item.IsShowHelpSsk = v.IsShowHelpSsk
+		item.IsShowSignup = v.IsShowSignup
+		item.IsShowAppointment = v.IsShowAppointment
+		item.IsShowDetails = v.IsShowDetails
+		item.ActivityTimeText = v.ActivityTimeText
+		item.Expert = v.Expert
+		item.Speaker = v.Speaker
+		item.PublishDate = v.ActivityTime
+		item.TripImgLink = v.TripImgLink
+		item.TripStatus = 2
+		item.ActiveState = v.ActiveState
+		item.PublishDate = v.ActivityTime
+		item.FileType = v.FileType
+		if v.VoiceList != nil || v.VideoDetail != nil {
+			item.AudioLink = true
+			if v.FileType == 1 {
+				if v.VoiceList != nil {
+					item.VoiceDetail = v.VoiceList
+				}
+			} else {
+				if v.VideoDetail != nil {
+					item.VideoDetail = v.VideoDetail
+				}
+			}
+			au := new(models.UserPermissionAuthInfo)
+			au.SellerName = authInfo.SellerName
+			au.SellerMobile = authInfo.SellerMobile
+			au.HasPermission = authInfo.HasPermission
+			au.OperationMode = authInfo.OperationMode
+			if au.HasPermission == 1 {
+				// 非宏观权限进一步判断是否有权限
+				if v.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, v.ChartPermissionName) {
+					au.HasPermission = 2
+				}
+			}
+			// 无权限的弹框提示
+			if au.HasPermission != 1 {
+				if au.OperationMode == services.UserPermissionOperationModeCall {
+					if v.FileType == 1 {
+						au.PopupMsg = services.UserPermissionPopupMsgCallActivity
+					} else {
+						au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
+					}
+				} else {
+					if v.FileType == 1 {
+						au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
+					} else {
+						au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
+					}
+				}
+			}
+			item.AuthInfo = au
+		}
+		list = append(list, item)
+	}
+	if len(resp.List) == 0 {
+		resp.List = make([]*models.CygxResourceDataResp, 0)
+	}
+	//添加活动搜索记录
+	if keyWord != "" {
+		//go services.AddActivitykeyWordSearch(keyWord, user)
+	}
+	resp.Paging = page
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 547 - 0
controllers/activity_special.go

@@ -0,0 +1,547 @@
+package controllers
+
+import (
+	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/services"
+	"hongze/hongze_clpt/utils"
+	"strconv"
+	"time"
+)
+
+//专项调研活动
+type ActivitySpecialController struct {
+	BaseAuthController
+}
+
+// @Title 专项产业调研列表
+// @Description 获取专项产业调研列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   ChartPermissionIds   query   string  false     "行业id 多个用 , 隔开"
+// @Param   ActiveState   query   string  false       "活动进行状态 未开始:1、进行中2、已结束3"
+// @Param   WhichDay   query   string  false       "哪一天 今天:1、明天:2, 本周:3 上周:4,本月:5上月:6多个用 , 隔开"
+// @Success 200 {object} models.GetCygxActivitySpecialDetailListResp
+// @router /list [get]
+func (this *ActivitySpecialController) 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")
+	chartPermissionIds := this.GetString("ChartPermissionIds")
+	whichDay := this.GetString("WhichDay")
+	activeState := this.GetString("ActiveState")
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+
+	conditionActivity := services.ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState)
+
+	list, total, errList := services.GetActivitySpecialList(user, currentIndex, pageSize, "", conditionActivity, activeState)
+	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
+	}
+
+	if len(list) == 0 {
+		list = make([]*models.CygxActivitySpecialDetail, 0)
+	}
+	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 *ActivitySpecialController) 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 /trip/add [post]
+func (this *ActivitySpecialController) 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.RegisterPlatform = utils.REGISTER_PLATFORM
+				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 *ActivitySpecialController) 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 = "已取消"
+}
+
+// @Title 感兴趣、不感兴趣
+// @Description 感兴趣、不感兴趣接口
+// @Param	request	body models.ActivityIdRep true "type json string"
+// @Success Ret=200 {object} models.SignupSpecialStatus
+// @router /signup/add [post]
+func (this *ActivitySpecialController) SpecialSignupAdd() {
+	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
+		total, err := models.GetUserCygxActivitySpecialSignup(user.UserId, activityId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
+			return
+		}
+		resp.SignupStatus = 1
+		//判断是删除还是添加
+		if total == 0 {
+			//获取销售信息
+			sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+				return
+			}
+			item := new(models.CygxActivitySpecialSignup)
+			item.RegisterPlatform = utils.REGISTER_PLATFORM
+			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
+			if sellerItem != nil {
+				item.SellerName = sellerItem.RealName
+			}
+			err = models.AddCygxActivitySpecialSignup(item)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "操作失败,Err:" + err.Error()
+				return
+			}
+			resp.Status = 1
+			resp.PopupMsg = "感谢反馈"
+			resp.PopupMsg2 = "此调研具体行程尚未确认,待预报名人数满10人后弘则会确定行程并推送给您活动日期,只有在确认行程中再次报名才完成占位。"
+			//给所属销售发送消息
+			if sellerItem.Mobile != "" {
+				openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
+				if openIpItem != nil && openIpItem.OpenId != "" {
+					if sellerItem != nil {
+						//go services.SendSpecialTemplateMsg(user.RealName+"【"+user.CompanyName+"】", time.Now().Format(utils.FormatDateTime), user.Mobile, activityInfo.ResearchTheme, "sale", openIpItem)
+					}
+				}
+			}
+			// 给芳姐发消息
+			actList, _ := models.GetActivityListSpecialByActivityId(activityId)
+			if len(actList) == 10 {
+				go services.SendWxMsgActivitySpecial10(activityInfo)
+			}
+			//用户专项调研操作行为,模板消息推送
+			//go services.SpecialActivityUserRemind(user, activityInfo, 1)
+		} else {
+			err = models.DeleteCygxActivitySpecialSignup(user.UserId, activityId)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "操作失败,Err:" + err.Error()
+				return
+			}
+			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 = "操作成功"
+	br.Data = resp
+}
+
+// @Title 新调研通知取消跟添加
+// @Description 新调研通知取消跟添加接口
+// @Param	request	body models.ArticleCollectResp true "type json string"
+// @Success 200
+// @router /follow [post]
+func (this *ActivitySpecialController) SpecialMsg() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	resp := new(models.ArticleCollectResp)
+	count, err := models.GetCygxUserFollowSpecial(user.UserId)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+		return
+	}
+	if count == 0 {
+		item := new(models.CygxUserFollowSpecial)
+		item.UserId = user.UserId
+		item.RealName = user.RealName
+		item.CreateTime = time.Now()
+		item.Mobile = user.Mobile
+		item.Email = user.Email
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		item.CreateTime = time.Now()
+		err := models.AddUserFollowSpecial(item)
+		if err != nil {
+			br.Msg = "操作失败!"
+			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+			return
+		}
+		resp.Status = 1
+	} else {
+		err := models.DeleteCygxUserFollowSpecial(user.UserId)
+		if err != nil {
+			br.Msg = "操作失败!"
+			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+			return
+		}
+		resp.Status = 2
+	}
+	br.Ret = 200
+	br.Data = resp
+	br.Success = true
+	br.Msg = "操作成功!"
+}

+ 48 - 7
controllers/article.go

@@ -56,6 +56,50 @@ func (this *ArticleController) Detail() {
 		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
 		return
 	}
+
+	//resp := new(models.ArticleDetailResp)
+	detail, err = models.GetArticleDetailById(articleId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	//是否属于专项调研报告
+	if detail.SubCategoryName == "专项调研" {
+		detail.IsSpecialArticle = true
+		havePower, err := services.GetSpecialArticleDetailUserPower(user, detail)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+			return
+		}
+		resp.IsSpecialArticle = true
+		if !havePower {
+			hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermissionArticle(user)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+				return
+			}
+			resp.PopupMsg = popupMsg
+			resp.HasPermission = hasPermission
+			resp.SellerName = sellerName
+			resp.SellerMobile = sellerMobile
+			detail.Body = ""
+			detail.Abstract = ""
+			detail.Seller.SellerName = sellerName
+			detail.Seller.SellerMobile = sellerMobile
+			resp.Detail = detail
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+	}
+
+	fmt.Println("2342")
+
 	//HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下(ficc),3:无该品类权限,已提交过申请,4:无该品类权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
 	if user.CompanyId > 1 {
 		companyPermission, err := models.GetCompanyPermission(user.CompanyId)
@@ -179,12 +223,6 @@ func (this *ArticleController) Detail() {
 			detail.Seller.SellerMobile = sellerItem.Mobile
 			detail.Seller.SellerName = sellerItem.RealName
 		}
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
-			return
-		}
-
 		//作者头像
 		if detail.DepartmentId > 0 {
 			departmentDetail, err := models.GetArticleDepartmentDateilById(detail.DepartmentId)
@@ -243,8 +281,11 @@ Loop:
 	//var haveResearch bool
 	fmt.Println(hasFree)
 	fmt.Println(haveResearch)
-
+	if detail.SubCategoryName == "专项调研" {
+		detail.IsSpecialArticle = true
+	}
 	resp.HasPermission = hasPermission
+	resp.IsSpecialArticle = detail.IsSpecialArticle
 	resp.Detail = detail
 	br.Ret = 200
 	br.Success = true

+ 50 - 0
controllers/chart_permission.go

@@ -15,6 +15,10 @@ type ChartPermissionAuthController struct {
 	BaseAuthController
 }
 
+type MobileChartPermissionAuthController struct {
+	BaseAuthMobileController
+}
+
 // @Title 获取所有品种
 // @Description 获取所有品种接口
 // @Success 200 {object} models.ChartPermissionListResp
@@ -70,3 +74,49 @@ func (this *ChartPermissionController) ListByReport() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 获取活动所有品种
+// @Description 获取活动所有品种接口
+// @Success 200 {object} models.ChartPermissionListResp
+// @router /listByActivity [get]
+func (this *MobileChartPermissionAuthController) ListByActivity() {
+	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 condition string
+	var chartPermissionId string
+	chartPermissionId = strconv.Itoa(utils.YI_YAO_ID) + "," + strconv.Itoa(utils.XIAO_FEI_ID) + "," + strconv.Itoa(utils.KE_JI_ID) + "," + strconv.Itoa(utils.ZHI_ZAO_ID) + "," + strconv.Itoa(utils.CE_LUE_ID) + "," + strconv.Itoa(utils.CHART_PERMISSION_ID_YANXUAN)
+	condition += ` AND  chart_permission_id IN ( ` + chartPermissionId + `)`
+	list, err := models.GetChartPermissionReportAll(condition)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.ChartPermissionListResp)
+	if user.CompanyId > 1 {
+		chartList, err := models.GetUserCompanyPermissionSand(user.CompanyId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+			return
+		}
+		for _, v := range chartList {
+			resp.CheckList = append(resp.CheckList, v.ChartPermissionId)
+		}
+	}
+
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 121 - 1
controllers/home.go

@@ -7,6 +7,7 @@ import (
 	"hongze/hongze_clpt/utils"
 	"strconv"
 	"strings"
+	"time"
 )
 
 type HomeController struct {
@@ -91,7 +92,6 @@ func (this *MobileHomeController) List() {
 				br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
 				return
 			}
-
 		}
 	} else if listType == 3 {
 		if chartPermissionId > 0 {
@@ -223,6 +223,7 @@ func (this *MobileHomeController) List() {
 					ArticleId:   v.ArticleId,
 					Title:       v.Title,
 					Annotation:  v.Annotation,
+					Abstract:    v.Abstract,
 					ImgUrlPc:    v.ImgUrlPc,
 					PublishDate: v.PublishDate,
 				})
@@ -240,3 +241,122 @@ func (this *MobileHomeController) List() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 首页列表接口
+// @Description 首页列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.HomeArtAndChartListResp
+// @router /new [get]
+func (this *MobileHomeController) NewList() {
+	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
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var conditionInit string
+	var pars []interface{}
+	var total int
+	resp := new(models.HomeResourceDataListResp)
+	//查询近一个月的数据
+	conditionInit = " AND publish_date  >   '" + time.Now().AddDate(0, 0, -30).Format(utils.FormatDateTime) + "'"
+	//conditionInit += `  AND source IN ('newchart')`
+	if user.CompanyId <= 1 {
+		condition += " AND source IN ('roadshow','article','newchart') "
+		startSize = 0
+		pageSize = utils.PageSize5
+	} else {
+		condition += ` AND source NOT IN ('activity','activityspecial') ` + conditionInit
+		conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "1,2,3", "", 0, 0, "", 0)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
+			return
+		}
+		conditionActivity += ` AND art.is_limit_people = 1 AND art.publish_status = 1 `
+		var conditionOrder string
+		conditionOrder = ` ORDER BY art.activity_time DESC ,  art.active_state ASC   `
+		conditionActivity += conditionOrder
+		listActivity, err := models.GetActivityListHomeNew(conditionActivity, 0, 200)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取可见活动数据失败,Err:" + err.Error()
+			return
+		}
+
+		var activityIds []int
+		for _, v := range listActivity {
+			activityIds = append(activityIds, v.ActivityId)
+		}
+		lenActivityIds := len(activityIds)
+		if lenActivityIds > 0 {
+			condition += ` OR ( source = 'activity' AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `) ` + conditionInit + ` )    `
+			pars = append(pars, activityIds)
+		}
+
+		listActivitySpecial, _, err := services.GetActivitySpecialList(user, 0, 200, "", "", "")
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取专项调研可见权限失败失败,Err:" + err.Error()
+			return
+		}
+
+		var activityspecialIds []int
+		for _, v := range listActivitySpecial {
+			activityspecialIds = append(activityspecialIds, v.ActivityId)
+		}
+		lenActivityspecialIds := len(activityspecialIds)
+		if lenActivityspecialIds > 0 {
+			condition += ` OR ( source = 'activityspecial' AND source_id IN (` + utils.GetOrmInReplace(lenActivityspecialIds) + `) ` + conditionInit + ` )   `
+			pars = append(pars, activityspecialIds)
+		}
+	}
+	total, err := models.GetResourceDataCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+
+	if user.CompanyId <= 1 {
+		total = utils.PageSize5
+	}
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+	list, err := services.GetResourceDataList(condition, pars, startSize, pageSize, user)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	page = paging.GetPaging(currentIndex, pageSize, total)
+	resp.Paging = page
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 125 - 0
controllers/micro_roadshow.go

@@ -2,8 +2,10 @@ package controllers
 
 import (
 	"encoding/json"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/services"
+	"hongze/hongze_clpt/utils"
 	"strconv"
 	"time"
 )
@@ -13,6 +15,129 @@ type MicroRoadShowController struct {
 	BaseAuthController
 }
 
+// @Title 微路演列表
+// @Description 微路演列表接口
+// @Param   PageSize		query	int		true	"每页数据条数"
+// @Param   CurrentIndex	query	int		true	"当前页页码,从1开始"
+// @Param   KeyWord			query	string	false	"搜索关键词"
+// @Param   AudioId			query	int		false	"音频ID"
+// @Param   VideoId			query	int		false	"视频ID"
+// @Param   ActivityVideoId			query	int		false	"活动视频ID"
+// @Param   Filter			query	string		false	"筛选条件 为空:全部 1:视频 2:音频 3:逻辑解析 4:路演回放 多个用 , 隔开"
+// @Success 200 {object} models.HomeListResp
+// @router /list [get]
+func (this *MicroRoadShowController) List() {
+	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
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	keywords := this.GetString("KeyWord")
+	audioId, _ := this.GetInt("AudioId")
+	videoId, _ := this.GetInt("VideoId")
+	activityVideoId, _ := this.GetInt("ActivityVideoId")
+	filter := this.GetString("Filter")
+
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+
+	// 微路演列表
+	list, total, e := services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter, keywords)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
+		return
+	}
+
+	// 用户权限
+	authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
+		return
+	}
+
+	// 获取默认图配置
+	audioMap, videoMap, audioShareMap, videoShareMap, e := services.GetMicroRoadShowDefaultImgConfig()
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
+		return
+	}
+
+	for i := range list {
+		// 权限
+		au := new(models.UserPermissionAuthInfo)
+		au.SellerName = authInfo.SellerName
+		au.SellerMobile = authInfo.SellerMobile
+		au.HasPermission = authInfo.HasPermission
+		au.OperationMode = authInfo.OperationMode
+		if au.HasPermission == 1 {
+			// 非宏观权限进一步判断是否有权限
+			if list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
+				au.HasPermission = 2
+			}
+		}
+		// 无权限的弹框提示
+		if au.HasPermission != 1 {
+			if au.OperationMode == services.UserPermissionOperationModeCall {
+				if list[i].Type == 1 {
+					au.PopupMsg = services.UserPermissionPopupMsgCallActivity
+				} else {
+					au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
+				}
+			} else {
+				if list[i].Type == 1 {
+					au.PopupMsg = services.UserPermissionPopupMsgApplyActivity
+				} else {
+					au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
+				}
+			}
+		}
+		list[i].AuthInfo = au
+		list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
+		// 默认图
+		if list[i].BackgroundImg == "" {
+			if list[i].Type == 1 {
+				list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
+			} else {
+				list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
+			}
+		}
+		// 分享图
+		if list[i].ShareImg == "" {
+			if list[i].Type == 1 {
+				list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
+			} else {
+				list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
+			}
+		}
+	}
+
+	resp := new(models.MicroRoadShowListResp)
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.List = list
+	resp.Paging = page
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
 // @Title 视频详情
 // @Description 时间线接口
 // @Param   VideoId   query   int  true       "视频ID"

+ 8 - 6
controllers/report.go

@@ -112,11 +112,13 @@ func (this *MobileReportController) TradeList() {
 
 		if ChartPermissionId != utils.CE_LUE_ID {
 			var pageSize int
-			if ChartPermissionId == utils.KE_JI_ID {
-				pageSize = 12
-			} else {
-				pageSize = 3
-			}
+			//if ChartPermissionId == utils.KE_JI_ID {
+			//	pageSize = 12
+			//} else {
+			//	pageSize = 3
+			//}
+
+			pageSize = 3
 			listArticle, err := models.GetHomeList(condition, pars, 0, pageSize)
 			if err != nil {
 				br.Msg = "获取信息失败"
@@ -641,7 +643,7 @@ func (this *ReportController) IndustrialFllow() {
 		br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
 		return
 	}
-	count, err := models.GetCountCygxIndustryFllow(industrialManagementId, user.Mobile, condition)
+	count, err := models.GetCountCygxIndustryFllow(industrialManagementId, user.UserId, condition)
 	if err != nil {
 		br.Msg = "获取数据失败!"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()

+ 406 - 0
models/activity.go

@@ -0,0 +1,406 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+//活动详情
+type CygxActivity struct {
+	ActivityId              int       `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
+	ActivityTypeId          int       `description:"活动类型id"`
+	ActivityTypeName        string    `description:"活动类型名称"`
+	ChartPermissionId       int       `description:"行业id"`
+	ChartPermissionName     string    `description:"行业名称"`
+	ChartPermissionNames    string    `description:"行业名称辅助字段,区分研选子分类"`
+	Body                    string    `description:"内容"`
+	CreateTime              time.Time `description:"创建时间"`
+	PublishDate             time.Time `description:"发布时间"`
+	IsLimitPeople           int       `description:"是否限制人数 1是,0否"`
+	LimitPeopleNum          int       `description:"限制的人数数量"`
+	CustomerTypeIds         string    `description:"活动可见的客户类型,多个ID用 , 隔开"`
+	PublishStatus           int       `description:"发布状态 1已发布,0未发布"`
+	LastUpdatedTime         time.Time `description:"更新时间"`
+	ActivityTime            string    `description:"活动时间"`
+	ActivityTimeText        string    `description:"活动时间带文字"`
+	DistinguishedGuest      string    `description:"嘉宾"`
+	Host                    string    `description:"主持人"`
+	MainlandTell            string    `description:"大陆拨入号"`
+	HongKongTell            string    `description:"香港拨入号"`
+	TaiwanTell              string    `description:"台湾拨入号"`
+	AmericaTell             string    `description:"美国拨入号"`
+	ParticipationCode       string    `description:"参会密码"`
+	Theme                   string    `description:"主题"`
+	Expert                  string    `description:"专家"`
+	ActivityName            string    `description:"活动名称"`
+	ActivityNameTask        string    `description:"活动名称定时任务同步的时候使用"`
+	OnlineParticipation     string    `description:"网络参会"`
+	ReportLink              string    `description:"报告链接"`
+	City                    string    `description:"城市"`
+	Address                 string    `description:"活动地址"`
+	Highlights              string    `description:"活动亮点"`
+	Remarks                 string    `description:"备注"`
+	Speaker                 string    `description:"主讲人"`
+	ArticleId               int       `description:"关联报告id"`
+	Label                   string    `description:"标签"`
+	LinkParticipants        string    `description:"链接参会"`
+	AppAttendance           string    `description:"App参会"`
+	ConferencePassword      string    `description:"会议密码"`
+	TemporaryLabel          string    `description:"临时标签"`
+	IsMakerShow             int       `description:"是否仅决策人可见 0,否 、1,是"`
+	VisibleRange            int       `description:"可见范围 1,仅本组可见 、2,全部客户可见"`
+	Scale                   string    `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
+	IsShowSubjectName       int       `description:"小程序内是否展示标的名称 1是 ,0 否 默认0 "`
+	IsHideAppointment       int       `description:"是否隐藏预约纪要按钮 1是 ,0 否 默认0 "`
+	AdminId                 int       `description:"销售/管理员ID"`
+	AdminName               string    `description:"销售/管理员姓名"`
+	IsCanAppointmentMinutes int       `description:"是否可预约纪要 1是 ,0 否 默认0 "`
+	YidongActivityId        string    `description:"易董活动ID"`
+}
+
+//活动详情
+type ActivityDetail struct {
+	ActivityId              int                        `orm:"column(activity_id);pk";description:"活动ID "`
+	ActivityTypeId          int                        `description:"活动类型id"`
+	ActivityTypeName        string                     `description:"活动类型名称"`
+	ChartPermissionId       int                        `description:"行业id"`
+	ChartPermissionName     string                     `description:"行业名称"`
+	ChartPermissionNames    string                     `description:"行业名称辅助字段,区分研选子分类"`
+	Body                    string                     `description:"内容"`
+	CreateTime              string                     `description:"创建时间"`
+	IsLimitPeople           int                        `description:"是否限制人数 1是,0否"`
+	LimitPeopleNum          int                        `description:"限制的人数数量"`
+	LastUpdatedTime         string                     `description:"更新时间"`
+	ActivityTime            string                     `description:"活动时间"`
+	ActivityTimeText        string                     `description:"活动时间带文字"`
+	DistinguishedGuest      string                     `description:"嘉宾"`
+	Host                    string                     `description:"主持人"`
+	Speaker                 string                     `description:"主讲人"`
+	MainlandTell            string                     `description:"大陆拨入号"`
+	HongKongTell            string                     `description:"香港拨入号"`
+	TaiwanTell              string                     `description:"台湾拨入号"`
+	AmericaTell             string                     `description:"美国拨入号"`
+	ParticipationCode       string                     `description:"参会密码"`
+	Theme                   string                     `description:"主题"`
+	Expert                  string                     `description:"专家"`
+	ActivityName            string                     `description:"活动名称"`
+	OnlineParticipation     string                     `description:"网络参会"`
+	ReportLink              string                     `description:"报告链接"`
+	City                    string                     `description:"城市"`
+	Address                 string                     `description:"活动地址"`
+	Highlights              string                     `description:"活动亮点"`
+	Remarks                 string                     `description:"备注"`
+	ShowType                string                     `description:"人数限制类型,1不展示限制,2可选限制,3强制限制"`
+	IsSignup                int                        `description:"是否已报名 1是 ,0 否"`
+	IsAppointment           int                        `description:"是否已预约纪要 1是 ,0 否"`
+	SignupNum               int                        `description:"已报名人数"`
+	SignupType              int                        `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
+	ActiveState             string                     `description:"活动进行状态 未开始:1、进行中2、已结束3"`
+	IsCancelMeetingReminder int                        `description:"是否取消会议提醒 1展示取消会议提醒 ,0展示会议提醒"`
+	ArticleId               int                        `description:"报告id(报告链接跳转使用)"`
+	CustomerTypeIds         string                     `description:"活动可见的客户类型,多个ID用 , 隔开"`
+	IsShowSustainable       bool                       `description:"是否展示限免标签"`
+	Description             string                     `description:"研选内容说明"`
+	IsResearch              bool                       `description:"是否属于研选"`
+	LinkParticipants        string                     `description:"链接参会"`
+	AppAttendance           string                     `description:"App参会"`
+	ConferencePassword      string                     `description:"会议密码"`
+	Scale                   string                     `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
+	IsShowAppointment       bool                       `description:"是否展示预约纪要"`
+	IsHideAppointment       int                        `description:"是否隐藏预约纪要按钮  1是,0 否"`
+	IsCClassMeeting         bool                       `description:"是否是c类电话会"`
+	ArticleList             []*ActivityArticleResp     // 下面是列表添加的部分结构体
+	IsBrackets              int                        `description:"是否有方括号 1是 ,0 否"`
+	Label                   string                     `description:"主题标签"`
+	ImgUrl                  string                     `description:"图片链接"`
+	ImgUrlText              string                     `description:"图片链接文字"`
+	ActivityType            int                        `description:"活动线上线下类型 1线上,0 线下"`
+	JmcjRoadshowTitle       string                     `description:"进门财经手动匹配的活动名称"`
+	Listndustrial           []*IndustrialManagementRep `description:"活动关联的产业信息"`
+	IsShowOutboundCall      bool                       `description:"是否展示预约外呼"`
+	IsShowMeetingReminder   bool                       `description:"是否展示会议提醒"`
+	IsShowHelpSsk           bool                       `description:"是否展示帮我带问"`
+	IsShowSignup            bool                       `description:"是否展示我要报名"`
+	IsShowDetails           bool                       `description:"是否展示查看详情按钮"`
+	TemporaryLabel          string                     `description:"临时标签"`
+	IsCanAppointmentMinutes int                        `description:"是否可预约纪要 1是 ,0 否 默认0 "`
+	YidongActivityId        string                     `description:"易董活动ID"`
+	YidongActivityUrl       string                     `description:"易董活动跳转地址"`
+	AudioLink               bool                       `description:"是否展示回放按钮"`
+	VoiceList               *CygxActivityVoiceReq      `description:"音频数据"`
+	AdminId                 int                        `description:"管理员、销售ID "`
+	IsMakerShow             int                        `description:"是否仅决策人可见 0,否 、1,是"`
+	VisibleRange            int                        `description:"可见范围 1,仅本组可见 、2,全部客户可见"`
+	VideoDetail             *CygxActivityVideoListResp `description:"视频数据"`
+	FileType                int                        `description:"类型: 1-音频; 2-视频"`
+	SourceType              int                        `description:"活动来源。 1:活动 、2:专项产业调研"`
+	TripImgLink             string                     `description:"专项产业调研行程链接"`
+	ActivityTimeEnd         string                     `description:"专项产业调研活动预期结束时间"`
+	AuthInfo                *UserPermissionAuthInfo    `description:"用户查看视频的权限"`
+}
+
+//活动详情
+type ActivityListResp struct {
+	ActivityId              int                        `description:"活动ID "`
+	ActivityTypeId          int                        `description:"活动类型id"`
+	ActivityTypeName        string                     `description:"活动类型名称"`
+	ChartPermissionId       int                        `description:"行业id"`
+	ChartPermissionName     string                     `description:"行业名称"`
+	IsLimitPeople           int                        `description:"是否限制人数 1是,0否"`
+	LimitPeopleNum          int                        `description:"限制的人数数量"`
+	LastUpdatedTime         string                     `description:"更新时间"`
+	ActivityTime            string                     `description:"活动时间"`
+	ActivityTimeText        string                     `description:"活动时间带文字"`
+	DistinguishedGuest      string                     `description:"嘉宾"`
+	Host                    string                     `description:"主持人"`
+	Speaker                 string                     `description:"主讲人"`
+	MainlandTell            string                     `description:"大陆拨入号"`
+	HongKongTell            string                     `description:"香港拨入号"`
+	TaiwanTell              string                     `description:"台湾拨入号"`
+	AmericaTell             string                     `description:"美国拨入号"`
+	ParticipationCode       string                     `description:"参会密码"`
+	Theme                   string                     `description:"主题"`
+	Expert                  string                     `description:"专家"`
+	ActivityName            string                     `description:"活动名称"`
+	OnlineParticipation     string                     `description:"网络参会"`
+	ReportLink              string                     `description:"报告链接"`
+	City                    string                     `description:"城市"`
+	Address                 string                     `description:"活动地址"`
+	Highlights              string                     `description:"活动亮点"`
+	Remarks                 string                     `description:"备注"`
+	IsSignup                int                        `description:"是否已报名 1是 ,0 否"`
+	SignupNum               int                        `description:"已报名人数"`
+	IsAppointment           int                        `description:"是否已预约纪要 1是 ,0 否"`
+	IsCancelMeetingReminder int                        `description:"是否添加了消息消息提醒   1是 ,0 否"`
+	ActiveState             string                     `description:"活动进行状态 未开始:1、进行中2、已结束3"`
+	IsShowSustainable       bool                       `description:"是否展示限免标签"`
+	Description             string                     `description:"研选内容说明"`
+	IsResearch              bool                       `description:"是否属于研选"`
+	IsHideAppointment       int                        `description:"是否隐藏预约纪要按钮  1是,0 否"`
+	IsCClassMeeting         bool                       `description:"是否是c类电话会"`
+	Label                   string                     `description:"主题标签"`
+	ImgUrl                  string                     `description:"行业图片链接"`
+	ImgUrlText              string                     `description:"活动类型图片链接"`
+	ActivityType            int                        `description:"活动线上线下类型 1线上,0 线下"`
+	IsShowOutboundCall      bool                       `description:"是否展示预约外呼"`
+	IsShowMeetingReminder   bool                       `description:"是否展示会议提醒"`
+	IsShowHelpSsk           bool                       `description:"是否展示帮我带问"`
+	IsShowSignup            bool                       `description:"是否展示我要报名"`
+	IsShowAppointment       bool                       `description:"是否展示预约纪要"`
+	IsShowDetails           bool                       `description:"是否展示查看详情按钮"`
+	AudioLink               bool                       `description:"是否展示回放按钮"`
+	VoiceDetail             *CygxActivityVoiceReq      `description:"音频数据"`
+	VideoDetail             *CygxActivityVideoListResp `description:"视频数据"`
+	FileType                int                        `description:"类型: 1-音频; 2-视频"`
+	SourceType              int                        `description:"活动来源。 1:活动 、2:专项产业调研"`
+	YidongActivityUrl       string                     `description:"易董活动跳转地址"`
+	ArticleList             []*ActivityArticleResp
+	Listndustrial           []*IndustrialManagementRep `description:"活动关联的产业信息"`
+	AuthInfo                *UserPermissionAuthInfo    `description:"用户查看视频的权限"`
+}
+
+type ActivityArticleResp struct {
+	ReportLink string `description:"报告链接"`
+	ArticleId  int    `description:"报告id(报告链接跳转使用)"`
+}
+
+type CygxActivityResp struct {
+	HasPermission int    `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下(ficc),3:无该品类权限,已提交过申请,4:无该品类权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	PopupMsg      string `description:"权限弹窗信息"`
+	SellerMobile  string `description:"销售电话"`
+	SellerName    string `description:"销售姓名"`
+	Detail        *ActivityListResp
+}
+
+//列表
+func GetCygxActivityList(condition string, pars []interface{}, sortTime string, startSize, pageSize int) (items []*CygxActivity, 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 , yidong_activity_id , activity_type_id 
+		FROM cygx_activity as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY art.label ORDER BY ` + sortTime + ` ,art.activity_id DESC  LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+//通过纪要ID获取活动详情
+func GetAddActivityInfoById(ActivityId int) (item *ActivityDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity  WHERE activity_id=? AND publish_status = 1 `
+	err = o.Raw(sql, ActivityId).QueryRow(&item)
+	return
+}
+
+//获取数量
+func GetActivityCount(condition string, playBack int, pars []interface{}, filter int) (count int, 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 `
+	}
+
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity as art ` + sqlJiontable + ` WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	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, uid, uid, uid, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+//列表
+func GetActivityListHomeNew(condition string, startSize, pageSize int) (items []*ActivityDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT activity_id
+		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  WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type GetCygxActivityListRep struct {
+	Paging                 *paging.PagingItem `description:"分页数据"`
+	List                   []*ActivityListResp
+	Label                  string `description:"主题"`
+	ImgUrl                 string `description:"图片路径"`
+	IsResearch             bool   `description:"是否属于研选"`
+	IsJump                 bool   `description:"是否跳转"`
+	IndustrialManagementId int    `description:"产业ID"`
+	IndustryNewLabel       bool   `description:"产业是否新标签"`
+	ChartPermissionId      int    `description:"权限id"`
+}
+
+type GetCygxActivityListSearchResp struct {
+	Paging                 *paging.PagingItem `description:"分页数据"`
+	List                   []*ActivityDetail
+	Label                  string `description:"主题"`
+	ImgUrl                 string `description:"图片路径"`
+	IsResearch             bool   `description:"是否属于研选"`
+	IsJump                 bool   `description:"是否跳转"`
+	IndustrialManagementId int    `description:"产业ID"`
+	IndustryNewLabel       bool   `description:"产业是否新标签"`
+	ChartPermissionId      int    `description:"权限id"`
+}
+
+//通过纪要ID获取活动详情
+func GetAddActivityInfoByIdShow(uid, ActivityId int) (item *ActivityDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *,( SELECT COUNT( 1 ) FROM cygx_activity_signup AS s WHERE s.activity_id = a.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 = a.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 = a.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 = a.activity_id AND ap.user_id = ? ) AS is_appointment
+			FROM cygx_activity AS a  WHERE activity_id=? AND publish_status = 1 `
+	err = o.Raw(sql, uid, uid, uid, ActivityId).QueryRow(&item)
+	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,
+            t.img_url_text,
+			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
+}

+ 238 - 0
models/activity_appointment.go

@@ -0,0 +1,238 @@
+package models
+
+import (
+	"fmt"
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivityAppointment struct {
+	Id               int       `orm:"column(id);pk"`
+	ActivityId       int       `description:"活动ID"`
+	UserId           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:"所属销售"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+}
+
+type AppointmentResp struct {
+	ActivityId    int    `description:"活动ID"`
+	HasPermission int    `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
+	PopupMsg      string `description:"权限弹窗信息"`
+	SellerMobile  string `description:"销售电话"`
+	SellerName    string `description:"销售姓名"`
+	GoFollow      bool   `description:"是否去关注"`
+}
+
+//添加
+func AddCygxActivityAppointment(item *CygxActivityAppointment) (err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	var countMySchedule int
+	sql := `SELECT COUNT(1) AS count FROM cygx_my_schedule WHERE user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countMySchedule)
+	if err != nil {
+		return
+	}
+	if countMySchedule == 0 {
+		itemMy := new(CygxMySchedule)
+		itemMy.UserId = item.UserId
+		itemMy.ActivityId = item.ActivityId
+		itemMy.CreateTime = time.Now()
+		itemMy.Mobile = item.Mobile
+		itemMy.Email = item.Email
+		itemMy.CompanyId = item.CompanyId
+		itemMy.CompanyName = item.CompanyName
+		_, err = o.Insert(itemMy)
+		if err != nil {
+			return
+		}
+	}
+	_, err = o.Insert(item)
+	return
+}
+
+//获取某一用户的报名的数量
+func GetUserCygxActivityAppointmentCount(uid, activityId int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_appointment  WHERE  user_id=?  AND   activity_id =? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
+	return
+}
+
+//获取某一用户的报名的数量
+func GetUserCygxActivityAppointmentCountByUid(uid int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_appointment  WHERE  user_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid).QueryRow(&count)
+	return
+}
+
+//删除
+func DeleteCygxActivityAppointment(uid, activityId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE  FROM cygx_activity_special_signup   WHERE   user_id=?   AND  activity_id=?    `
+	_, err = o.Raw(sql, uid, activityId).Exec()
+	return
+}
+
+//取消纪要预约
+func CancelcygxActivityAppointment(item *CygxActivityAppointment) (lastId int64, err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	//判断是否删除我的日程
+	var countSingup int
+	var countReminder int
+	sql := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE  is_cancel = 0  AND user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countSingup)
+	sql = `SELECT COUNT(1) AS count FROM cygx_activity_meeting_reminder WHERE   user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countReminder)
+	if err != nil {
+		return
+	}
+	if countSingup == 0 && countReminder == 0 {
+		sql = `DELETE  FROM cygx_my_schedule   WHERE user_id=?  AND activity_id=? `
+		_, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
+		if err != nil {
+			return
+		}
+	}
+	//删除预约的纪要
+	sql = `DELETE  FROM cygx_activity_appointment   WHERE user_id=?  AND activity_id=? `
+	_, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
+	if err != nil {
+		return
+	}
+	return
+}
+
+type CygxAppointmentAndActivity struct {
+	Mobile         string `description:"手机号"`
+	ActivityName   string `description:"所属销售"`
+	ActivityTypeId int    `description:"活动类型"`
+}
+
+//通过活动ID获取预约列表
+func GetAppointmentListByActivityId(activityIds, activityTypeIds string) (items []*CygxAppointmentAndActivity, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			m.*,a.activity_name,
+			a.activity_type_id
+		FROM
+			cygx_activity_appointment AS m
+			INNER JOIN cygx_activity AS a ON a.activity_id = m.activity_id 
+		WHERE
+			a.activity_id IN ( ` + activityIds + ` ) 
+			AND a.activity_type_id IN (` + activityTypeIds + `) 
+			AND DATE_SUB( CURDATE(), INTERVAL 14 DAY ) <= date( a.activity_time ) 
+			AND a.active_state = 3 	GROUP BY m.mobile`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//通过活动ID、手机号获取预约列表
+func GetAppointmentListByActivityIdAndMobile(activityIds, mobile string) (items []*CygxAppointmentAndActivity, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			m.*,a.activity_name
+		FROM
+			cygx_activity_appointment AS m
+			INNER JOIN cygx_activity AS a ON a.activity_id = m.activity_id 
+		WHERE
+			a.activity_id IN ( ` + activityIds + ` ) 
+			AND a.activity_type_id IN ( 1, 2, 5 ) 
+			AND DATE_SUB( CURDATE(), INTERVAL 14 DAY ) <= date( a.activity_time ) 
+			AND a.active_state = 3
+			AND  m.mobile= ?`
+	_, err = o.Raw(sql, mobile).QueryRows(&items)
+	return
+}
+
+//通过活动ID获取预约纪要的人数列表
+func GetCygxAppointmentSummaryListBySubjectId(subjectIds string) (item []*CygxAppointmentAndActivity, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			ap.mobile,
+			ap.activity_id,
+			a.activity_name 
+		FROM
+			cygx_activity_appointment AS ap
+			INNER JOIN cygx_activity AS a ON a.activity_id = ap.activity_id
+			INNER JOIN cygx_industrial_activity_group_subject AS sg ON sg.activity_id = a.activity_id 
+		WHERE
+			a.active_state = 3 
+			AND a.chart_permission_id = 31 
+			AND DATE_SUB( CURDATE(), INTERVAL 14 DAY ) <= date( a.activity_time ) 
+			AND a.activity_type_id = 1 
+			AND sg.industrial_subject_id IN (` + subjectIds + `) 
+		GROUP BY
+			ap.mobile,
+			ap.activity_id `
+	_, err = o.Raw(sql).QueryRows(&item)
+	return
+}
+
+type CygxAppointment struct {
+	Mobile         string `description:"手机号"`
+	UserId         int    `description:"userId"`
+	ActivityName   string `description:"所属销售"`
+	ActivityTypeId int    `description:"活动类型"`
+}
+
+//通过活动ID获取预约纪要的人数列表
+func GetCygxAppointmentSummaryBySubjectId(subjectIds string) (item []*CygxAppointment, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			ap.user_id,
+			ap.mobile,
+			ap.activity_id,
+			a.activity_name 
+		FROM
+			cygx_activity_appointment AS ap
+			INNER JOIN cygx_activity AS a ON a.activity_id = ap.activity_id
+			INNER JOIN cygx_industrial_activity_group_subject AS sg ON sg.activity_id = a.activity_id 
+		WHERE
+			a.active_state = 3
+			AND sg.industrial_subject_id IN (` + subjectIds + `) 
+		GROUP BY
+			ap.mobile,
+			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
+}

+ 92 - 0
models/activity_help_ask.go

@@ -0,0 +1,92 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivityHelpAsk struct {
+	AskId            int       `orm:"column(ask_id);pk" description:"带问id"`
+	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:"公司名称"`
+	Content          string    `description:"内容"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+}
+
+//添加优化建议
+func AddActivityHelpAsk(item *CygxActivityHelpAsk) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+type AddCygxActivityHelpAsk struct {
+	ActivityId int    `description:"活动id"`
+	Content    string `description:"内容"`
+}
+
+type CygxAskList struct {
+	ReportOrActivityId int    ` description:"对应的文章或者活动Id"`
+	Title              string `description:"标题"`
+	Content            string `description:"内容"`
+	AskType            string `description:"类型 Activity 活动 、Report 文章报告"`
+	CreateTime         string `description:"创建时间"`
+}
+
+type CygxAskListResp struct {
+	List []*CygxAskList
+}
+
+//report_or_activity_id
+
+//主题列表
+func GetActivityAskList(userId int) (items []*CygxAskList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			k.activity_id as report_or_activity_id,
+			k.content,
+			k.create_time,
+			a.activity_name as title
+		FROM
+			cygx_activity_help_ask AS k
+			INNER JOIN cygx_activity AS a ON a.activity_id = k.activity_id 
+		WHERE
+			user_id = ? AND a.publish_status = 1 ORDER BY k.ask_id DESC`
+	_, err = o.Raw(sql, userId).QueryRows(&items)
+	return
+}
+
+//列表
+func GetArticleAskList(userId int) (items []*CygxAskList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			k.article_id as report_or_activity_id,
+			k.content,
+			k.create_time,
+			a.title as title
+		FROM
+			cygx_article_ask AS k
+			INNER JOIN cygx_article AS a ON a.article_id = k.article_id 
+		WHERE
+			user_id = ? AND a.publish_status = 1 ORDER BY k.ask_id DESC`
+	_, err = o.Raw(sql, userId).QueryRows(&items)
+	return
+}
+
+type AskEmailRep struct {
+	Name   string `description:"姓名"`
+	Email  string `description:"邮箱"`
+	Mobile string `description:"手机号"`
+}
+
+func GetAskEmail() (item []*AskEmailRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_ask_email`
+	_, err = o.Raw(sql).QueryRows(&item)
+	return
+}

+ 168 - 0
models/activity_meeting_reminder.go

@@ -0,0 +1,168 @@
+package models
+
+import (
+	"fmt"
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivityMeetingReminder struct {
+	Id               int       `orm:"column(id);pk"`
+	ActivityId       int       `description:"活动ID"`
+	UserId           int       `description:"用户ID"`
+	CreateTime       time.Time `description:"创建时间"`
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司id"`
+	CompanyName      string    `description:"公司名称"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+}
+
+//记录日志
+type CygxActivityMeetingReminderLog struct {
+	Id          int       `orm:"column(id);pk"`
+	ActivityId  int       `description:"活动ID"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	Type        int       `description:"操作方式,1报名,2取消报名"`
+}
+
+//添加会议提醒信息
+func AddActivityMeetingReminder(item *CygxActivityMeetingReminder) (lastId int64, err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	var count int
+	var countMySchedule int
+	sql := `SELECT COUNT(1) AS count FROM cygx_my_schedule WHERE user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countMySchedule)
+	if err != nil {
+		return
+	}
+	if countMySchedule == 0 {
+		itemMy := new(CygxMySchedule)
+		itemMy.UserId = item.UserId
+		itemMy.ActivityId = item.ActivityId
+		itemMy.CreateTime = time.Now()
+		itemMy.Mobile = item.Mobile
+		itemMy.Email = item.Email
+		itemMy.CompanyId = item.CompanyId
+		itemMy.CompanyName = item.CompanyName
+		lastId, err = o.Insert(itemMy)
+		if err != nil {
+			return
+		}
+	}
+	sql = `SELECT COUNT(1) AS count FROM cygx_activity_meeting_reminder WHERE user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&count)
+	if err != nil {
+		return
+	}
+	if count > 0 {
+		sql := `UPDATE cygx_activity_meeting_reminder SET is_cancel = 0  WHERE user_id=?  AND activity_id=? `
+		_, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
+	} else {
+		lastId, err = o.Insert(item)
+	}
+	itemLog := new(CygxActivityMeetingReminderLog)
+	itemLog.UserId = item.UserId
+	itemLog.ActivityId = item.ActivityId
+	itemLog.CreateTime = time.Now()
+	itemLog.Mobile = item.Mobile
+	itemLog.Email = item.Email
+	itemLog.CompanyId = item.CompanyId
+	itemLog.CompanyName = item.CompanyName
+	itemLog.Type = 1
+	lastId, err = o.Insert(itemLog)
+	return
+}
+
+//获取用户报名数量
+func GetActivityMeetingReminderCount(uid, activityId int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_meeting_reminder WHERE is_cancel=0 AND user_id=? AND activity_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
+	return
+}
+
+//取消会议提醒
+func CancelActivityMeetingReminder(item *CygxActivityMeetingReminder) (lastId int64, err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	//判断是否删除我的日程
+	var countSignup int
+	var countAppointment int
+	sql := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE  is_cancel = 0  AND user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countSignup)
+
+	sql = `SELECT COUNT(1) AS count FROM cygx_activity_appointment WHERE  user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countAppointment)
+	if err != nil {
+		return
+	}
+	if countSignup == 0 && countAppointment == 0 {
+		sql = `DELETE  FROM cygx_my_schedule   WHERE user_id=?  AND activity_id=? `
+		_, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
+		if err != nil {
+			return
+		}
+	}
+	sql = `DELETE  FROM cygx_activity_meeting_reminder   WHERE user_id=?  AND activity_id=? `
+	_, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
+	if err != nil {
+		return
+	}
+	itemLog := new(CygxActivityMeetingReminderLog)
+	itemLog.UserId = item.UserId
+	itemLog.ActivityId = item.ActivityId
+	itemLog.CreateTime = time.Now()
+	itemLog.Mobile = item.Mobile
+	itemLog.Email = item.Email
+	itemLog.CompanyId = item.CompanyId
+	itemLog.CompanyName = item.CompanyName
+	itemLog.Type = 2
+	lastId, err = o.Insert(itemLog)
+	return
+}
+
+//获取某一用户的日程数量
+func GetUserActivityMeetingReminderCount(uid int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_meeting_reminder_log WHERE  user_id=? `
+	o := orm.NewOrm()
+	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
+}

+ 586 - 0
models/activity_signup.go

@@ -0,0 +1,586 @@
+package models
+
+import (
+	"fmt"
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivitySignup struct {
+	Id               int       `orm:"column(id);pk"`
+	ActivityId       int       `description:"活动ID"`
+	UserId           int       `description:"用户ID"`
+	CreateTime       time.Time `description:"创建时间"`
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司id"`
+	CompanyName      string    `description:"公司名称"`
+	FailType         int       `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
+	SignupType       int       `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
+	DoFailType       int       `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
+	OutboundMobile   string    `description:"外呼手机号"`
+	CountryCode      string    `description:"手机国家区号"`
+	RealName         string    `description:"用户实际名称"`
+	SellerName       string    `description:"所属销售"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+}
+
+type SignupStatus struct {
+	SignupStatus      string `description:"返回状态:人数已满:FullStarffed、单机构超过两人:TwoPeople、爽约次数过多:BreakPromise、超时:Overtime 、成功:Success"`
+	GoFollow          bool   `description:"是否去关注"`
+	SignupType        int    `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
+	ActivityId        int    `description:"活动ID"`
+	HaqveJurisdiction bool   `description:"是否有权限"`
+	HasPermission     int    `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下(ficc),3:无该品类权限,已提交过申请,4:无该品类权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	PopupMsg          string `description:"权限弹窗信息"`
+	SellerMobile      string `description:"销售电话"`
+	SellerName        string `description:"销售姓名"`
+	Mobile            string `description:"外呼手机号"`
+	CountryCode       string `description:"外呼手机号区号"`
+	GoOutboundMobile  bool   `description:"是否去绑定手机号"`
+	GoBindEmail       bool   `description:"是否去绑定邮箱"`
+}
+type ActivitySingnupRep struct {
+	ActivityId int `description:"活动id"`
+	SignupType int `description:"报名方式,,1预约外呼,2自主拨入,3我要报名"`
+}
+
+//我的日程
+type CygxMySchedule struct {
+	Id          int       `orm:"column(id);pk"`
+	ActivityId  int       `description:"活动ID"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+}
+
+//报名记录日志
+type CygxActivitySignupLog struct {
+	Id          int       `orm:"column(id);pk"`
+	ActivityId  int       `description:"活动ID"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	Type        int       `description:"操作方式,1报名,2取消报名"`
+}
+
+//添加报名信息
+func AddActivitySignup(item *CygxActivitySignup) (lastId int64, err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	var count int
+	var countMySchedule int
+	sql := `SELECT COUNT(1) AS count FROM cygx_my_schedule WHERE user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countMySchedule)
+	if err != nil {
+		return
+	}
+	if countMySchedule == 0 {
+		itemMy := new(CygxMySchedule)
+		itemMy.UserId = item.UserId
+		itemMy.ActivityId = item.ActivityId
+		itemMy.CreateTime = time.Now()
+		itemMy.Mobile = item.Mobile
+		itemMy.Email = item.Email
+		itemMy.CompanyId = item.CompanyId
+		itemMy.CompanyName = item.CompanyName
+		lastId, err = o.Insert(itemMy)
+		if err != nil {
+			return
+		}
+	}
+	sql = `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&count)
+	if err != nil {
+		return
+	}
+	if count > 0 {
+		sql := `UPDATE cygx_activity_signup SET is_cancel = 0 ,do_fail_type = 0, signup_type=? WHERE user_id=?  AND activity_id=? `
+		_, err = o.Raw(sql, item.SignupType, item.UserId, item.ActivityId).Exec()
+	} else {
+		lastId, err = o.Insert(item)
+	}
+	if err != nil {
+		return
+	}
+	itemLog := new(CygxActivitySignupLog)
+	itemLog.UserId = item.UserId
+	itemLog.ActivityId = item.ActivityId
+	itemLog.CreateTime = time.Now()
+	itemLog.Mobile = item.Mobile
+	itemLog.Email = item.Email
+	itemLog.CompanyId = item.CompanyId
+	itemLog.CompanyName = item.CompanyName
+	itemLog.Type = 1
+	lastId, err = o.Insert(itemLog)
+	return
+}
+
+//仅绑定邮箱的用户修改报名后,添加报名信息
+func AddActivitySignupFromEmail(item *CygxActivitySignup) (lastId int64, err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	var count int
+	var countMySchedule int
+	sql := `UPDATE wx_user SET outbound_mobile=? ,outbound_country_code = ? ,is_msg_outbound_mobile = 1   WHERE user_id=? `
+	_, err = o.Raw(sql, item.OutboundMobile, item.CountryCode, item.UserId).Exec()
+	if err != nil {
+		return
+	}
+	sql = `SELECT COUNT(1) AS count FROM cygx_my_schedule WHERE user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countMySchedule)
+	if err != nil {
+		return
+	}
+	if countMySchedule == 0 {
+		itemMy := new(CygxMySchedule)
+		itemMy.UserId = item.UserId
+		itemMy.ActivityId = item.ActivityId
+		itemMy.CreateTime = time.Now()
+		itemMy.Mobile = item.Mobile
+		itemMy.Email = item.Email
+		itemMy.CompanyId = item.CompanyId
+		itemMy.CompanyName = item.CompanyName
+		lastId, err = o.Insert(itemMy)
+		if err != nil {
+			return
+		}
+	}
+	sql = `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&count)
+	if err != nil {
+		return
+	}
+	if count > 0 {
+		sql := `UPDATE cygx_activity_signup SET is_cancel = 0 ,do_fail_type = 0, signup_type=? WHERE user_id=?  AND activity_id=? `
+		_, err = o.Raw(sql, item.SignupType, item.UserId, item.ActivityId).Exec()
+	} else {
+		lastId, err = o.Insert(item)
+	}
+	if err != nil {
+		return
+	}
+	itemLog := new(CygxActivitySignupLog)
+	itemLog.UserId = item.UserId
+	itemLog.ActivityId = item.ActivityId
+	itemLog.CreateTime = time.Now()
+	itemLog.Mobile = item.Mobile
+	itemLog.Email = item.Email
+	itemLog.CompanyId = item.CompanyId
+	itemLog.CompanyName = item.CompanyName
+	itemLog.Type = 1
+	lastId, err = o.Insert(itemLog)
+	return
+}
+
+//添加报名信息
+func AddActivitySignupNoSchedule(item *CygxActivitySignup) (lastId int64, err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	lastId, err = o.Insert(item)
+	if err != nil {
+		return
+	}
+	itemLog := new(CygxActivitySignupLog)
+	itemLog.UserId = item.UserId
+	itemLog.ActivityId = item.ActivityId
+	itemLog.CreateTime = time.Now()
+	itemLog.Mobile = item.Mobile
+	itemLog.Email = item.Email
+	itemLog.CompanyId = item.CompanyId
+	itemLog.CompanyName = item.CompanyName
+	itemLog.Type = 1
+	lastId, err = o.Insert(itemLog)
+	return
+}
+
+//获取用户报名成功数量
+func GetActivitySignupCount(uid, activityId int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE is_cancel=0  AND do_fail_type = 0 AND user_id=? AND activity_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
+	return
+}
+
+//获取用户报名数量
+func GetActivitySignupByUserCount(uid, activityId int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE is_cancel=0 AND user_id=? AND activity_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
+	return
+}
+
+//获取用户报名禁止数量
+func GetActivitySignupByUserRestrictCount(uid, activityId int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE do_fail_type=3 AND user_id=? AND activity_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
+	return
+}
+
+//获取某一活动已经报名的数量
+func GetActivitySignupSuccessCount(activityId int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE is_cancel=0 AND do_fail_type = 0 AND activity_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, activityId).QueryRow(&count)
+	return
+}
+
+//获取某一活动某个机构已经报名的数量
+func GetActivitySignupCompanyCount(activityId, companyId int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup WHERE is_cancel=0 AND fail_type = 0 AND activity_id=? AND company_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, activityId, companyId).QueryRow(&count)
+	return
+}
+
+//获取某一用户是否被限制报名
+func GetUserRestrictCount(mobile string) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_restrict_signup WHERE is_restrict=1  AND mobile=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, mobile).QueryRow(&count)
+	return
+}
+
+//获取某一用户的日程数量
+func GetUserMeetingReminderCount(uid int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_my_schedule WHERE  user_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid).QueryRow(&count)
+	return
+}
+
+//获取某一用户的报名的数量
+func GetUserSignupCount(uid int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_signup_log WHERE  user_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid).QueryRow(&count)
+	return
+}
+
+//取消报名
+func CancelActivitySignup(item *CygxActivitySignup) (lastId int64, err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	//判断是否删除我的日程
+	var countReminder int
+	var countAppointment int
+	sql := `SELECT COUNT(1) AS count FROM cygx_activity_meeting_reminder WHERE is_cancel = 0  AND  user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countReminder)
+
+	sql = `SELECT COUNT(1) AS count FROM cygx_activity_appointment WHERE  user_id=? AND activity_id=? `
+	err = o.Raw(sql, item.UserId, item.ActivityId).QueryRow(&countAppointment)
+	if err != nil {
+		return
+	}
+	if countReminder == 0 && countAppointment == 0 {
+		sql = `DELETE  FROM cygx_my_schedule   WHERE user_id=?  AND activity_id=? `
+		_, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
+		if err != nil {
+			return
+		}
+	}
+	sql = `DELETE  FROM cygx_activity_signup   WHERE user_id=?  AND activity_id=? `
+	_, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
+	if err != nil {
+		return
+	}
+	itemLog := new(CygxActivitySignupLog)
+	itemLog.UserId = item.UserId
+	itemLog.ActivityId = item.ActivityId
+	itemLog.CreateTime = time.Now()
+	itemLog.Mobile = item.Mobile
+	itemLog.Email = item.Email
+	itemLog.CompanyId = item.CompanyId
+	itemLog.CompanyName = item.CompanyName
+	itemLog.Type = 2
+	lastId, err = o.Insert(itemLog)
+	return
+}
+
+//详情
+func GetActivitySignupDetail(activityId, uid int) (item *CygxActivitySignup, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_signup WHERE  activity_id = ? AND user_id =? `
+	err = o.Raw(sql, activityId, uid).QueryRow(&item)
+	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()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	itemMy := new(CygxMySchedule)
+	itemMy.UserId = item.UserId
+	itemMy.ActivityId = item.ActivityId
+	itemMy.CreateTime = time.Now()
+	itemMy.Mobile = item.Mobile
+	itemMy.Email = item.Email
+	itemMy.CompanyId = item.CompanyId
+	itemMy.CompanyName = item.CompanyName
+	lastId, err = o.Insert(itemMy)
+	if err != nil {
+		return
+	}
+	sql := `UPDATE cygx_activity_signup SET do_fail_type = 0 , fail_type=0 WHERE user_id=?  AND activity_id=? `
+	_, err = o.Raw(sql, item.UserId, item.ActivityId).Exec()
+	itemLog := new(CygxActivitySignupLog)
+	itemLog.UserId = item.UserId
+	itemLog.ActivityId = item.ActivityId
+	itemLog.CreateTime = time.Now()
+	itemLog.Mobile = item.Mobile
+	itemLog.Email = item.Email
+	itemLog.CompanyId = item.CompanyId
+	itemLog.CompanyName = item.CompanyName
+	itemLog.Type = 1
+	lastId, err = o.Insert(itemLog)
+	return
+}
+
+//列表
+func GetActivitySignupListAll() (items []*CygxActivitySignup, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_signup `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//修改是否推送消息状态
+func UPdateSignup(item *CygxActivitySignup) (err error) {
+	sql := ` UPDATE cygx_activity_signup SET  outbound_mobile= ? , country_code=86  WHERE id = ?`
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, item.Mobile, item.Id).Exec()
+	return
+}
+
+//获取数量
+func GetActivityCountByIdWithUid(activityId, Uid int) (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := `SELECT COUNT(1) AS count  FROM cygx_activity_signup WHERE activity_id = ? AND user_id = ?`
+	err = o.Raw(sqlCount, activityId, Uid).QueryRow(&count)
+	return
+}
+
+//获取用户报名数量
+func GetActivitySignupNomeetingCount(activityId int) (count int, err error) {
+	sqlCount := `SELECT
+	COUNT( 1 ) count 
+FROM
+	cygx_activity_signup AS s
+	INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id 
+WHERE
+	1 = 1 
+	AND a.is_limit_people > 0 
+	AND s.is_meeting = 0 
+	AND a.is_submit_meeting = 1
+	AND a.activity_id = ?`
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, activityId).QueryRow(&count)
+	return
+}
+
+func GetUserMeetingMobile(activityId int) (items []*CygxActivitySignup, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *
+FROM
+	cygx_activity_signup AS s 
+WHERE
+	s.is_meeting = 1 
+	AND s.activity_id = ?`
+	_, err = o.Raw(sql, activityId).QueryRows(&items)
+	return
+}
+
+//获取用户是否被限制报名
+func GetRestrictSignupCountByUid(uid int) (count int, err error) {
+	sqlCount := `SELECT COUNT( 1 ) count FROM cygx_activity_restrict_signup  WHERE user_id = ?`
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid).QueryRow(&count)
+	return
+}
+
+//获取用户爽约次数
+func GetActivitySignupNomeetingCountByUid(uid int) (count int, err error) {
+	sqlCount := `SELECT
+	COUNT( 1 ) count 
+FROM
+	cygx_activity_signup AS s
+	INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id 
+WHERE
+	1 = 1 
+	AND a.is_limit_people > 0 
+	AND s.is_meeting = 0 
+	AND a.is_submit_meeting = 1
+	AND s.do_fail_type = 0
+	AND s.user_id = ?`
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid).QueryRow(&count)
+	return
+}
+
+//删除
+func DeleteCygxActivityRestrictSignup(uid int) (err error) {
+	o := orm.NewOrm()
+	sql := ` DELETE FROM cygx_activity_restrict_signup  WHERE user_id=?`
+	_, err = o.Raw(sql, uid).Exec()
+	return
+}
+
+type CygxActivitySignupList struct {
+	Id          int    `orm:"column(id);pk"`
+	UserId      int    `description:"用户id"`
+	ActivityId  int    `description:"活动ID"`
+	CompanyName string `description:"公司名称"`
+	RealName    string `description:"姓名"`
+	CreateTime  string `description:"创建时间"`
+	IsMeeting   int    `description:"是否到会 ,1是, 0否"`
+	Operation   bool   `description:"操作按钮,true,到会,false 未到会"`
+	Channel     int    `description:"报名渠道,0 空降、 1小程序报名"`
+}
+
+//获取用户报名列表
+func GetActivitySignupNomeetingCountList(activityId int) (items []*CygxActivitySignupList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	s.user_id
+FROM
+	cygx_activity_signup AS s
+	INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id 
+WHERE
+	1 = 1 
+	AND a.is_limit_people > 0 
+	AND s.is_meeting = 0 
+	AND a.is_submit_meeting = 1
+	AND a.activity_id = ?`
+	_, err = o.Raw(sql, activityId).QueryRows(&items)
+	return
+}
+
+type UserAndCompanyName struct {
+	UserId              int `orm:"column(user_id);pk"`
+	Mobile              string
+	Email               string
+	CompanyId           int
+	CompanyName         string `description:"公司名称"`
+	CountryCode         string `description:"手机国家区号"`
+	OutboundMobile      string `description:"外呼手机号"`
+	OutboundCountryCode string `description:"外呼手机号区号"`
+}
+
+func GetUserAndCompanyNameList(uid int) (item *UserAndCompanyName, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT u.*,c.company_name 
+			FROM wx_user AS u
+	INNER JOIN company AS c ON c.company_id = u.company_id
+	WHERE user_id =?`
+	err = o.Raw(sql, uid).QueryRow(&item)
+	return
+}
+
+type CygxActivityRestrictSignup struct {
+	Id          int       `orm:"column(id);pk"`
+	UserId      int       `description:"用户id,多个用,隔开"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱号"`
+	CompanyId   int       `description:"公司ID"`
+	CompanyName string    `description:"公司名称"`
+	IsRestrict  int       `description:"是否限制报名,1是,0否"`
+}
+
+//添加
+func AddCygxActivityRestrictSignup(item *CygxActivityRestrictSignup) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+//获取列表信息根据手机号分组
+func GetCygxActivitySignupByMobileList(condition string) (items []*CygxActivitySignup, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_signup  WHERE  1= 1 ` + condition + `  GROUP BY mobile  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//修改用户报名的相关信息
+func UpdateCygxActivitySignup(wxUser *WxUserItem) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_activity_signup SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE  mobile=? `
+	_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
+	return
+}
+
+//UpdateCygxActivitySignupisMeet 修改易董的活动,用户已到会
+func UpdateCygxActivitySignupisMeet(activityId int, mobile string) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_activity_signup SET is_meeting=1 WHERE activity_id=?  AND mobile = ? `
+	_, err = o.Raw(sql, activityId, mobile).Exec()
+	return
+}

+ 157 - 0
models/activity_special.go

@@ -0,0 +1,157 @@
+package models
+
+import (
+	//"fmt"
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+)
+
+//专项调研活动列表
+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           string `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
+}
+
+//主题列表
+func GetActivityLabelSpecialListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityLabelList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT	label,activity_id,is_show_subject_name
+		FROM cygx_activity_special as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `  LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+//获取专项调研活动列表
+func GetCygxActivitySpecialDetailList(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*CygxActivitySpecialDetail, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT
+	art.*,
+	c.image_url AS img_url,
+	(
+	SELECT
+		COUNT( 1 ) 
+	FROM
+		cygx_activity_special_signup AS s 
+	WHERE
+		s.activity_id = art.activity_id 
+		AND s.user_id = ?
+	) AS is_signup
+FROM
+	cygx_activity_special AS art
+	INNER JOIN chart_permission AS c ON c.chart_permission_id = art.chart_permission_id 
+WHERE
+	1 = 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `  LIMIT ?,? `
+	_, err = o.Raw(sql, uid, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+type GetCygxActivitySpecialDetailListResp struct {
+	IsFollow        bool               `description:"是否关注新调研通知"`
+	IsBindingMobile bool               `description:"是否绑定了手机号"`
+	Paging          *paging.PagingItem `description:"分页数据"`
+	List            []*CygxActivitySpecialDetail
+}
+
+type CygxActivitySpecialResp struct {
+	HasPermission int    `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下(ficc),3:无该品类权限,已提交过申请,4:无该品类权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	PopupMsg      string `description:"权限弹窗信息"`
+	SellerMobile  string `description:"销售电话"`
+	SellerName    string `description:"销售姓名"`
+	IsFollow      bool   `description:"是否关注新调研通知"`
+	Detail        *CygxActivitySpecialDetail
+}
+
+//通过活动ID获取活动详情
+func GetCygxActivitySpecialDetailById(uid, ActivityId int) (item *CygxActivitySpecialDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *,( SELECT COUNT( 1 ) FROM cygx_activity_special_signup AS s WHERE s.activity_id = a.activity_id AND s.user_id = ? ) AS is_signup 
+FROM
+	cygx_activity_special AS a 
+WHERE
+	activity_id = ?
+	AND publish_status = 1 	AND is_offline = 0  `
+	err = o.Raw(sql, uid, ActivityId).QueryRow(&item)
+	return
+}
+
+type ActivityIdRep struct {
+	ActivityId  int `description:"活动id"`
+	PlaySeconds int `description:"播放时长"`
+}
+
+//通过活动ID获取活动详情
+func GetCygxActivitySpecialDetail(ActivityId int) (item *CygxActivitySpecialDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_special  WHERE activity_id=? AND publish_status = 1 `
+	err = o.Raw(sql, ActivityId).QueryRow(&item)
+	return
+}

+ 159 - 0
models/activity_special_signup.go

@@ -0,0 +1,159 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivitySpecialSignup struct {
+	Id               int       `orm:"column(id);pk"`
+	ActivityId       int       `description:"活动ID"`
+	UserId           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:"所属销售"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+}
+
+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:超时"`
+}
+
+//添加
+func AddCygxActivitySpecialSignup(item *CygxActivitySpecialSignup) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+//获取某一用户的报名的数量
+func GetUserCygxActivitySpecialSignup(uid, activityId int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_signup  WHERE  user_id=?  AND   activity_id =? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid, activityId).QueryRow(&count)
+	return
+}
+
+//删除
+func DeleteCygxActivitySpecialSignup(uid, activityId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE  FROM cygx_activity_special_signup   WHERE   user_id=?   AND  activity_id=?    `
+	_, err = o.Raw(sql, uid, activityId).Exec()
+	return
+}
+
+//列表
+func GetActivityListSpecialAll(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 = ?  GROUP BY company_id`
+	_, err = o.Raw(sql, activityId).QueryRows(&items)
+	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"`
+	UserId      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:"所属销售"`
+	Count       string    `description:"所属销售"`
+}
+
+//列表
+func GetActivityListSpecialGroupByMobile(condition string, pars []interface{}) (items []*CygxActivitySpecialSignupResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT s.*,	COUNT( 1 ) AS count   FROM cygx_activity_special_signup as s INNER JOIN cygx_activity_special AS a ON a.activity_id = s.activity_id
+			INNER JOIN wx_user AS u ON u.user_id = s.user_id ` + condition + `  GROUP BY s.mobile`
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+//列表
+func GetActivityListSpecialGroupByCompanyId(condition string, pars []interface{}) (items []*CygxActivitySpecialSignupResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *,	COUNT( 1 ) AS count   FROM cygx_activity_special_signup   as s INNER JOIN cygx_activity_special AS a ON a.activity_id = s.activity_id
+			INNER JOIN wx_user AS u ON u.user_id = s.user_id ` + condition + `  GROUP BY s.company_id`
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+// UpdateActivitySpecialSignupNumMulti 批量修改专项调研感兴趣的人数排名
+func UpdateActivitySpecialSignupNumMulti(items []*CygxActivitySpecialSignupResp) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw("UPDATE cygx_activity_special_signup SET user_num = ? WHERE mobile = ?").Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for _, v := range items {
+		_, err = p.Exec(v.Count, v.Mobile)
+		if err != nil {
+			return
+		}
+	}
+	return
+}
+
+// UpdateActivitySpecialSignupCompanyIdMulti 批量修改专项调研感兴趣的用户的对应公司ID
+func UpdateActivitySpecialSignupCompanyIdMulti(items []*WxUser) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw("UPDATE cygx_activity_special_signup SET company_id = ? WHERE mobile = ?").Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for _, v := range items {
+		_, err = p.Exec(v.CompanyId, v.Mobile)
+		if err != nil {
+			return
+		}
+	}
+	return
+}
+
+// UpdateActivitySpecialSignupCompanyNumMulti 批量修改专项调研感兴趣的公司对应的数量
+func UpdateActivitySpecialSignupCompanyNumMulti(items []*CygxActivitySpecialSignupResp) (err error) {
+	o := orm.NewOrm()
+	p, err := o.Raw("UPDATE cygx_activity_special_signup SET company_num = ? WHERE company_id = ?").Prepare()
+	if err != nil {
+		return
+	}
+	defer func() {
+		_ = p.Close() // 别忘记关闭 statement
+	}()
+	for _, v := range items {
+		_, err = p.Exec(v.Count, v.CompanyId)
+		if err != nil {
+			return
+		}
+	}
+	return
+}

+ 117 - 0
models/activity_special_trip.go

@@ -0,0 +1,117 @@
+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"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+}
+
+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
+}

+ 66 - 0
models/activity_type.go

@@ -0,0 +1,66 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type ActivityType struct {
+	ActivityTypeId   int    `description:"活动类型id"`
+	ActivityTypeName string `description:"活动名称"`
+	ShowType         string `description:"人数限制类型,1不展示限制,2可选限制,3强制限制"`
+	IsChoose         bool   `description:"是否选择"`
+	OnlineIco        string `description:"线上线下Ico图标"`
+}
+
+type ActivityTypeListResp struct {
+	List []*ActivityType
+}
+
+//列表
+func GetActivityTypeList() (items []*ActivityType, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_type ORDER BY sort DESC`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+func GetActivityTypeDetailById(activityTypeId int) (item *ActivityType, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_type WHERE activity_type_id = ? `
+	err = o.Raw(sql, activityTypeId).QueryRow(&item)
+	return
+}
+
+type ActivityTypeListHomeResp struct {
+	List []*ActivityTypeHome
+}
+
+type ActivityTypeHome struct {
+	ActivityTypeId   int    `description:"活动类型id"`
+	Resource         int    `description:"来源 ,1:活动 ,2:专项产业调研"`
+	ActivityTypeName string `description:"活动类型名称"`
+	OnlineIco        string `description:"线上线下Ico图标"`
+	ImgUrlBgPc       string `description:"Pc端背景图片"`
+	List             []*CygxActivityLabelList
+}
+
+//活动详情
+type CygxActivityLabelList struct {
+	KeyWord           string `orm:"column(label)";description:"主题"`
+	ImgUrlBg          string `description:"背景图片"`
+	ActivityId        int    `description:"活动ID "`
+	Resource          int    `description:"来源 ,1:活动 ,2:专项产业调研"`
+	IsNew             bool   `description:"是否为新:活动存在关联的的产业所关联的报告均在3个月内/无报告则标记新"`
+	YidongActivityId  int    `description:"易董活动ID"`
+	IsExternalLabel   bool   `description:"是否为外部资源"`
+	IsShowSubjectName int    `description:"小程序内是否展示标的名称 1是 ,0否 默认0 "`
+	TemporaryLabel    string `description:"临时标签"`
+}
+
+//列表
+func GetActivityTypeHomeList() (items []*ActivityTypeHome, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_type WHERE activity_type_id != 7   ORDER BY sort DESC`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 135 - 0
models/activity_video.go

@@ -0,0 +1,135 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+)
+
+type CygxActivityVideo struct {
+	VideoId       int    `orm:"column(video_id);pk"description:"视频id"`
+	VideoName     string `description:"视频名称"`
+	ActivityId    int    ` description:"活动ID"`
+	ModifyDate    string `description:"更新时间"`
+	VideoDuration string `description:"视频时长"`
+	VideoCounts   int    `description:"播放量"`
+	VideoUrl      string `description:"视频地址"`
+	CreateTime    string `description:"创建时间"`
+}
+
+type CygxActivityVideoResp struct {
+	VideoId           int    `orm:"column(video_id);pk"description:"视频id"`
+	ChartPermissionId int    `description:"权限id"`
+	VideoName         string `description:"视频名称"`
+	ActivityId        int    ` description:"活动ID"`
+	ModifyDate        string `description:"更新时间"`
+	VideoDuration     string `description:"视频时长"`
+	VideoCounts       int    `description:"播放量"`
+	VideoUrl          string `description:"视频地址"`
+	CreateTime        string `description:"创建时间"`
+}
+
+type CygxActivityVideoReq struct {
+	VideoName     string `description:"视频名称"`
+	VideoDuration string `description:"视频时长"`
+	VideoUrl      string `description:"视频地址"`
+}
+
+//活动详情
+type CygxActivityVideoListResp struct {
+	ActivityId    int    `description:"活动ID 等于0新增活动,大于0修改活动"`
+	Id            int    `orm:"column(video_id)";description:"视频id"`
+	Title         string `orm:"column(video_name)";description:"视频名称"`
+	ResourceUrl   string `orm:"column(video_url)";description:"视频地址"`
+	VideoDuration string `description:"视频时长"`
+}
+
+type CygxActivityVideoListRep struct {
+	Paging *paging.PagingItem `description:"分页数据"`
+	List   []*CygxActivityVideoListResp
+}
+
+//列表
+func GetActivityVideoListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVideoListResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT art.*,v.video_id,v.video_name,v.video_url,video_duration FROM cygx_activity as art  INNER JOIN cygx_activity_video AS v ON v.activity_id = art.activity_id   WHERE 1= 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+//列表
+func GetActivityVideoList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVideoResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	v.*,art.chart_permission_id
+FROM
+	cygx_activity_video AS v 
+	INNER JOIN cygx_activity as art ON art.activity_id = v.activity_id    WHERE 1= 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+func UpdateActivityVideoCounts(activityId int) (err error) {
+	sql := `UPDATE cygx_activity_video SET video_counts = video_counts+1 WHERE activity_id = ?  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, activityId).Exec()
+	return
+}
+
+// GetCygxActivityVideoByActivityId 获取活动视频
+func GetCygxActivityVideoByActivityId(activityId int) (item *CygxActivityVideo, err error) {
+	sql := `SELECT * FROM cygx_activity_video WHERE activity_id = ? LIMIT 1 `
+	err = orm.NewOrm().Raw(sql, activityId).QueryRow(&item)
+	return
+}
+
+type CygxActivityVideoDetailResp struct {
+	ActivityId          int    ` description:"活动ID"`
+	Id                  int    `description:"视频ID"`
+	Title               string `description:"标题"`
+	ResourceUrl         string `description:"链接"`
+	BackgroundImg       string `description:"背景图"`
+	PlaySeconds         int    `description:"音视频时长"`
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业名称"`
+}
+
+// GetCygxActivityVideoById 获取活动视频
+func GetCygxActivityVideoById(videoId int) (item *CygxActivityVideoDetailResp, err error) {
+	sql := `SELECT
+			v.video_id AS id,
+			v.video_name AS title,
+			v.video_url AS resource_url,
+			v.video_duration AS play_seconds,
+			v.activity_id,
+			a.chart_permission_id 
+		FROM
+			cygx_activity_video AS v
+			INNER JOIN cygx_activity AS a 
+		WHERE
+			video_id = ? 
+			LIMIT 1 `
+	err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
+	return
+}
+
+//GetMicroRoadshowVideoByVideoIdCount  根据视频ID查询产业视频是否存在
+func GetActivityVideoByVideoIdCount(videoId int) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) count
+			FROM cygx_activity_video WHERE video_id = ? `
+	err = o.Raw(sql, videoId).QueryRow(&count)
+	return
+}
+
+type ActivityVideoDetailResp struct {
+	VideoDetail *CygxActivityVideoDetailResp
+	AuthInfo    *UserPermissionAuthInfo
+}

+ 106 - 0
models/activity_voice.go

@@ -0,0 +1,106 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_clpt/utils"
+	"time"
+)
+
+// ActivityVoice 活动语音表结构体
+type CygxActivityVoice struct {
+	ActivityVoiceId  int       `orm:"column(activity_voice_id);pk" description:"活动音频ID"`
+	ActivityId       int       ` description:"活动ID"`
+	VoiceUrl         string    `description:"音频地址"`
+	VoiceName        string    `description:"音频名称"`
+	VoicePlaySeconds string    `description:"音频时长"`
+	VoiceCounts      int       `description:"播放量"`
+	ModifyTime       string    `description:"更新时间"`
+	CreateTime       time.Time `description:"创建时间"`
+}
+
+// ActivityVoice 活动语音表结构体
+type CygxActivityVoiceResp struct {
+	ActivityVoiceId     int    `orm:"column(activity_voice_id);pk" description:"活动音频ID"`
+	ActivityId          int    ` description:"活动ID"`
+	VoiceUrl            string `description:"音频地址"`
+	VoiceName           string `description:"音频名称"`
+	VoicePlaySeconds    string `description:"音频时长"`
+	VoiceCounts         int    `description:"播放量"`
+	ModifyTime          string `description:"更新时间"`
+	CreateTime          string `description:"创建时间"`
+	ChartPermissionId   int    `description:"权限id"`
+	ChartPermissionName string `description:"行业名称"`
+}
+
+// ActivityVoiceReq 音频数据
+type CygxActivityVoiceReq struct {
+	ActivityId  int    ` description:"活动ID"`
+	Url         string `description:"音频资源url地址"`
+	Name        string `description:"音频名称"`
+	PlaySeconds int    `description:"音频时长"`
+}
+
+// GetCygxActivityVoiceReqList 获取活动ID的音频
+func GetCygxActivityVoiceReqList(activityIds []int) (items []*CygxActivityVoiceReq, err error) {
+	lenactivityIds := len(activityIds)
+	if lenactivityIds == 0 {
+		return
+	}
+	//活动音频,设置有效时间为30天,失效后该活动就不再支持音频回放。有效期起始时间为活动的开始时间
+	//endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
+	sql := `SELECT
+			v.activity_id,
+			v.voice_url AS url,
+			v.voice_name AS name,
+			v.voice_play_seconds AS play_seconds 
+		FROM
+			cygx_activity_voice AS v
+			INNER JOIN cygx_activity AS a ON a.activity_id = v.activity_id 
+		WHERE
+			1 = 1 	 AND  v.activity_id IN (` + utils.GetOrmInReplace(lenactivityIds) + `)  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, activityIds).QueryRows(&items)
+	return
+}
+
+func UpdateCygxActivityVoiceCounts(activityId int) (err error) {
+	sql := `UPDATE cygx_activity_voice SET voice_counts = voice_counts+1 WHERE activity_id = ?  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, activityId).Exec()
+	return
+}
+
+// GetCygxActivityVoiceById 主键获取活动音频
+func GetCygxActivityVoiceById(videoId int) (item *CygxActivityVoice, err error) {
+	sql := `SELECT * FROM cygx_activity_voice WHERE activity_voice_id = ? LIMIT 1`
+	err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
+	return
+}
+
+//列表
+func GetActivityVoiceListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVideoListResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT art.*  FROM cygx_activity as art  INNER JOIN cygx_activity_voice AS v ON v.activity_id = art.activity_id   WHERE 1= 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+//列表
+func GetActivityVoiceList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVoiceResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	v.*,art.chart_permission_id,art.chart_permission_name
+FROM
+	cygx_activity_voice AS v 
+	INNER JOIN cygx_activity as art ON art.activity_id = v.activity_id    WHERE 1= 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 17 - 0
models/admin.go

@@ -0,0 +1,17 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type AdminMobileResp struct {
+	Mobile string `description:"手机号"`
+}
+
+// 获取销售所能查看到的手机号
+func GetAdminByRole() (items []*AdminMobileResp, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT mobile  FROM admin  WHERE role = 'admin' `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 17 - 2
models/article.go

@@ -30,6 +30,8 @@ type ArticleDetail struct {
 	Seller               SellerResp      `description:"作者昵称"`
 	DepartmentDetail     *DepartmentResp `description:"作者昵称"`
 	Disclaimers          string          `description:"免责声明"`
+	IsSpecialArticle     bool            `description:"是否属于专项调研报告"`
+	SubCategoryName      string          `description:"二级分类"`
 }
 
 type SellerResp struct {
@@ -38,8 +40,13 @@ type SellerResp struct {
 }
 
 type ArticleDetailResp struct {
-	Detail        *ArticleDetail
-	HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	Mobile           string `description:"用户手机号"`
+	PopupMsg         string `description:"权限弹窗信息"`
+	SellerMobile     string `description:"销售电话"`
+	SellerName       string `description:"销售姓名"`
+	Detail           *ArticleDetail
+	IsSpecialArticle bool `description:"是否属于专项调研报告"`
+	HasPermission    int  `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,已提交过申请,4:无该行业权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
 }
 
 func GetArticleDetailById(articleId int) (item *ArticleDetail, err error) {
@@ -181,3 +188,11 @@ type CygxArticleEs struct {
 	FileLink         string `description:"下载预览链接"`
 	MatchTypeName    string `description:"匹配类型"`
 }
+
+//获取文章列表
+func GetArticleList(condition string, pars []interface{}) (items []*ArticleDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT	article_id FROM cygx_article  WHERE 1= 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 5 - 7
models/chart.go

@@ -139,8 +139,6 @@ type ChartUserTokenResultApi struct {
 	Msg  string               `json:"msg"`
 }
 
-
-
 type HomeChartListItem struct {
 	IsBindingMobile bool `description:"是否绑定过手机号"`
 	Paging          *paging.PagingItem
@@ -180,26 +178,26 @@ func GetChartListAll() (items []*HomeChartListResp, err error) {
 //}
 
 //获取图表列表
-func GetChartListCollection(chartIds string, userId, startSize, pageSize int) (items []*HomeChartListResp, err error) {
+func GetChartListCollection(condition string, pars []interface{}, userId, startSize, pageSize int) (items []*HomeChartListResp, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT a.*,
 			t.create_time AS t_create_time,
 			c.create_time AS c_create_time,
-			( SELECT COUNT(*) FROM cygx_chart_top AS t WHERE t.chart_id = a.chart_id AND t.user_id = ? ) AS num_top,
+			( SELECT COUNT(*) FROM cygx_chart_top AS t WHERE t.chart_id = a.chart_id AND t.user_id = ? ) AS is_top,
 			( SELECT COUNT(*) FROM cygx_chart_collect AS c WHERE c.chart_id = a.chart_id AND c.user_id = ? ) AS num_c 
 		FROM
 			cygx_chart_all AS a
 			LEFT JOIN cygx_chart_top AS t ON t.chart_id = a.chart_id
 			LEFT JOIN cygx_chart_collect AS c ON c.chart_id = a.chart_id 
 		WHERE
-			a.publish_status = 1 
-			AND a.chart_id IN (` + chartIds + `) 
+			a.publish_status = 1 ` + condition + `
+			
 		GROUP BY
 			a.chart_id 
 		ORDER BY
 			t_create_time DESC,
 			c_create_time DESC LIMIT ?,? `
-	_, err = o.Raw(sql, userId, userId, startSize, pageSize).QueryRows(&items)
+	_, err = o.Raw(sql, userId, userId, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
 

+ 19 - 1
models/chart_permission.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"time"
 )
 
 type ChartPermissionResp struct {
@@ -15,8 +16,25 @@ type ChartPermission struct {
 	IsShowSustainable bool   `description:"是否展示限免标签"`
 }
 
+type CompanyReportPermission struct {
+	CompanyReportPermissionId int `orm:"column(company_report_permission_id);pk"`
+	CompanyId                 int `description:"客户id"`
+	ReportPermissionId        int `description:"报告权限id"`
+	CreatedTime               time.Time
+	LastUpdatedTime           time.Time
+	ChartPermissionId         int    `description:"权限id"`
+	StartDate                 string `description:"权限开始日期"`
+	EndDate                   string `description:"权限结束日期"`
+	ProductId                 int    `description:"产品id"`
+	ProductName               string `description:"产品名称"`
+	ModifyTime                string `description:"修改时间"`
+	CompanyContractId         string `description:"合同id"`
+	Status                    string `description:"状态  '正式','试用','关闭','永续','潜在' "`
+}
+
 type ChartPermissionListResp struct {
-	List []*ChartPermissionResp
+	List      []*ChartPermissionResp
+	CheckList []int `description:"权限"`
 }
 
 func GetChartPermissionReportAll(condition string) (items []*ChartPermissionResp, err error) {

+ 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
+}

+ 11 - 0
models/db.go

@@ -42,6 +42,17 @@ func init() {
 		new(CygxXzsChooseCategory),
 		new(CygxReportIndustrialSeaarchHistory),
 		new(CygxMicroRoadshowVideoHistory),
+		new(CygxActivitySignup),
+		new(CygxActivitySignupLog),
+		new(CygxMySchedule),
+		new(CygxActivitySpecialSignup),
+		new(CygxUserFollowSpecial),
+		new(CygxActivitySpecialTrip),
+		new(CygxActivityMeetingReminder),
+		new(CygxActivityMeetingReminderLog),
+		new(CygxActivityAppointment),
+		new(CygxActivityHelpAsk),
+		new(UserTemplateRecord),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 103 - 0
models/industrial_activity_group_management.go

@@ -0,0 +1,103 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxIndustrialActivityGroupManagement struct {
+	Id                     int       `orm:"column(id);pk" description:"主键ID"`
+	ActivityId             int       `description:"活动ID"`
+	IndustrialManagementId int       `description:"cygx_industrial_management表的主键ID"`
+	Source                 int       `description:"来源,1 活动,2专项调研"`
+	CreateTime             time.Time `description:"创建时间"`
+}
+
+type CygxIndustrialActivityGroupSubject struct {
+	Id                  int       `orm:"column(id);pk" description:"主键ID"`
+	ActivityId          int       `description:"活动ID"`
+	IndustrialSubjectId int       `description:"cygx_industrial_subject表的文章ID"`
+	Source              int       `description:"来源,1 活动,2专项调研"`
+	CreateTime          time.Time `description:"创建时间"`
+}
+
+type CygxIndustrialSubject struct {
+	IndustrialSubjectId    int       `orm:"column(industrial_subject_id);pk" description:"标的id"`
+	IndustrialManagementId int       `description:"产业id"`
+	SubjectName            string    `description:"标的名称"`
+	CreateTime             time.Time `description:"创建时间"`
+	Source                 int       `description:"来源,1正常添加,2:通过文章添加,3通过活动添加(默认为1)"`
+}
+
+//获取标的列表
+func GetCygxIndustrialSubjectList(subjectName string) (items []*CygxIndustrialSubject, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+				s.*
+			FROM
+				cygx_industrial_subject as s 
+				INNER JOIN  cygx_industrial_management as m ON  m.industrial_management_id = s.industrial_management_id
+			WHERE
+				subject_name = ? `
+	_, err = o.Raw(sql, subjectName).QueryRows(&items)
+	return
+}
+
+// AddCygxActiuvityGroupMulti 批量添加
+func AddCygxActiuvityGroupMulti(items []*CygxIndustrialActivityGroupManagement, itemsSubject []*CygxIndustrialActivityGroupSubject) (err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	if len(items) > 0 {
+		//批量添加关联的产业
+		_, err = o.InsertMulti(len(items), items)
+	}
+	if len(itemsSubject) > 0 {
+		//批量添加关联的标的
+		_, err = o.InsertMulti(len(itemsSubject), itemsSubject)
+	}
+	return
+}
+
+// GetActivityIndustryRelationList 获取活动与产业关联列表
+func GetActivityIndustryRelationList(condition string, pars []interface{}) (list []*CygxIndustrialActivityGroupManagement, err error) {
+	sql := `SELECT
+				a.activity_id,
+				b.industrial_management_id
+			FROM
+				cygx_activity AS a
+			JOIN cygx_industrial_activity_group_management AS b ON a.activity_id = b.activity_id
+			WHERE
+				1 = 1  AND b.source = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
+	return
+}
+
+//列表
+func GetIndustrialActivityGroupManagementList(activityId int) (items []*IndustrialManagementRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			p.permission_name,
+			p.chart_permission_id,
+			m.industrial_management_id,
+			m.industry_name 
+			FROM
+			cygx_industrial_activity_group_management AS am
+			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = am.industrial_management_id
+			INNER JOIN chart_permission AS p ON p.chart_permission_id = m.chart_permission_id 
+			WHERE
+			am.activity_id = ? AND am.source = 1`
+	_, err = o.Raw(sql, activityId).QueryRows(&items)
+	return
+}

+ 56 - 0
models/industrial_article_group_management.go

@@ -0,0 +1,56 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxIndustrialArticleGroupManagement struct {
+	Id                     int       `orm:"column(id);pk" description:"主键ID"`
+	CygxArticleId          int       `description:"cygx_article表id"`
+	ArticleId              int       `description:"文章ID"`
+	IndustrialManagementId int       `description:"cygx_industrial_management表的主键ID"`
+	Source                 int       `description:"来源,1 活动,2专项调研"`
+	CreateTime             time.Time `description:"创建时间"`
+}
+
+// IndustryArticleMinMaxPublishTime 产业文章最大最小发布时间
+type IndustryArticleMinMaxPublishTime struct {
+	IndustrialManagementId int       `description:"产业ID"`
+	MinPublishTime         time.Time `description:"文章最小发布时间"`
+	MaxPublishTime         time.Time `description:"文章最大发布时间"`
+}
+
+// GetIndustryArticleMinMaxPublishTime 获取产业文章最大最小发布时间
+func GetIndustryArticleMinMaxPublishTime(condition string, pars []interface{}) (list []*IndustryArticleMinMaxPublishTime, err error) {
+	sql := `SELECT
+				a.industrial_management_id,
+				MIN(b.publish_date) AS min_publish_time,
+				MAX(b.publish_date) AS max_publish_time
+			FROM
+				cygx_industrial_article_group_management AS a
+			JOIN cygx_article AS b ON a.article_id = b.article_id
+			WHERE
+				1 = 1`
+	if condition != `` {
+		sql += condition
+	}
+	sql += `GROUP BY a.industrial_management_id`
+	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
+	return
+}
+
+// GetIndustrialArticleGroupManagementList  查询产业
+func GetIndustrialArticleGroupManagementList(condition string, pars []interface{}) (list []*CygxIndustrialArticleGroupManagement, err error) {
+	sql := `SELECT
+				*
+			FROM
+				cygx_industrial_article_group_management AS a
+			WHERE
+				1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	_, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
+	return
+}

+ 29 - 3
models/industrial_management.go

@@ -16,6 +16,7 @@ type IndustrialManagementRep struct {
 	ArticleReadNum         int    `description:"文章阅读数量"`
 	IsResearch             bool   `description:"是否属于研选"`
 	IsJump                 bool   `description:"是否跳转"`
+	IndustryNewLabel       bool   `description:"是否产业新标签"`
 }
 
 type IndustrialManagementCount struct {
@@ -205,9 +206,9 @@ func GetIndustrialManagementCount(IndustrialManagementId int) (count int, err er
 }
 
 //获取关注数量
-func GetCountCygxIndustryFllow(industrialManagementId int, mobile, condition string) (count int, err error) {
-	sql := `SELECT COUNT(1) AS count FROM cygx_industry_fllow WHERE mobile=? AND industrial_management_id=? ` + condition
-	err = orm.NewOrm().Raw(sql, mobile, industrialManagementId).QueryRow(&count)
+func GetCountCygxIndustryFllow(industrialManagementId, userId int, condition string) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_industry_fllow WHERE user_id=? AND industrial_management_id=? ` + condition
+	err = orm.NewOrm().Raw(sql, userId, industrialManagementId).QueryRow(&count)
 	return
 }
 
@@ -341,3 +342,28 @@ func GetActiveArticleIndustryIds() (ids []int, err error) {
 	_, err = orm.NewOrm().Raw(sql).QueryRows(&ids)
 	return
 }
+
+// GetIndustryByName 通过名称获取产业
+func GetIndustryByName(industryName string) (item *IndustrialManagement, err error) {
+	sql := `SELECT * FROM cygx_industrial_management WHERE industry_name = ? LIMIT 1`
+	err = orm.NewOrm().Raw(sql, industryName).QueryRow(&item)
+	return
+}
+
+// GetSourceIndustryByName 通过名称获取资源包产业
+func GetSourceIndustryByName(industryName string) (item *IndustrialManagement, err error) {
+	sql := `SELECT
+				m.industry_name,
+				m.industrial_management_id,
+				m.chart_permission_id
+			FROM
+				cygx_industrial_management AS m
+			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
+			INNER JOIN cygx_article AS a ON a.article_id = mg.article_id AND a.article_type != 'lyjh'
+			WHERE
+				1 = 1 AND m.industry_name = ? AND a.publish_status = 1 AND a.article_id < 1000000
+			GROUP BY
+				m.industrial_management_id`
+	err = orm.NewOrm().Raw(sql, industryName).QueryRow(&item)
+	return
+}

+ 119 - 13
models/micro_roadshow.go

@@ -15,19 +15,21 @@ type MicroRoadShowListResp struct {
 
 // MicroRoadShowPageList 微路演列表
 type MicroRoadShowPageList struct {
-	Id                  int    `description:"音视频ID"`
-	Title               string `description:"标题"`
-	ResourceUrl         string `description:"链接"`
-	Type                int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频"`
-	PublishTime         string `description:"发布时间"`
-	BackgroundImg       string `description:"背景图"`
-	ShareImg            string `description:"分享封面图"`
-	ChartPermissionId   int    `description:"行业ID"`
-	ChartPermissionName string `description:"行业名称"`
-	IndustryName        string `description:"产业名称"`
-	PlaySeconds         string `description:"音视频时长"`
-	ActivityId          int    `description:"活动ID"`
-	AuthInfo            *UserPermissionAuthInfo
+	Id                     int    `description:"音视频ID"`
+	Title                  string `description:"标题"`
+	ResourceUrl            string `description:"链接"`
+	Type                   int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频"`
+	PublishTime            string `description:"发布时间"`
+	BackgroundImg          string `description:"背景图"`
+	ShareImg               string `description:"分享封面图"`
+	ChartPermissionId      int    `description:"行业ID"`
+	ChartPermissionName    string `description:"行业名称"`
+	IndustryName           string `description:"产业名称"`
+	PlaySeconds            string `description:"音视频时长"`
+	ActivityId             int    `description:"活动ID"`
+	IndustrialManagementId int    `description:"产业ID"`
+	CreateTime             string `description:"视频创建时间"`
+	AuthInfo               *UserPermissionAuthInfo
 }
 
 type AddVideoHistoryReq struct {
@@ -152,6 +154,17 @@ func GetMicroRoadshowVideoByIndustryIds(industrialIdArr []int) (list []*MicroRoa
 	return
 }
 
+// GetMicroRoadshowVideoListBycondition 根据搜索条件获取搜索列表
+func GetMicroRoadshowVideoListBycondition(condition string, pars []interface{}, startSize, pageSize int) (list []*MicroRoadshowVideo, err error) {
+	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE  1 =1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `  LIMIT ?,? `
+	_, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+	return
+}
+
 // GetMicroRoadshowVideoByIndustryId 根据行业ID查询产业视频列表
 func GetMicroRoadshowVideoByIndustryId(industryId int) (item *MicroRoadshowVideo, err error) {
 	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE industry_id = ? and publish_status = 1`
@@ -183,3 +196,96 @@ func GetMicroRoadshowVideoList() (list []*MicroRoadshowVideo, err error) {
 	_, err = orm.NewOrm().Raw(sql).QueryRows(&list)
 	return
 }
+
+// GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
+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 && filter != 2 {
+	sql += `SELECT
+			video_id AS id,
+			video_name AS title,
+			video_url AS resource_url,
+			3 AS type,
+			publish_date AS publish_time,
+			chart_permission_id,
+			chart_permission_name,
+			video_duration AS play_seconds,
+			img_url AS background_img,            
+			industry_name,
+
+			share_img_url AS share_img,
+			industry_id AS industrial_management_id,
+			"" as  activity_id
+		FROM
+			cygx_micro_roadshow_video 
+		WHERE
+			publish_status = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	//}
+	//if audioId+videoId+activityVideoId == 0 && filter != 2 {
+	sql += `  UNION ALL `
+	//}
+
+	//if audioId+videoId == 0 && filter != 2 {
+	sql += `
+		SELECT
+			video_id AS id,
+			video_name AS title,
+			video_url AS resource_url,
+			2 AS type,
+		art.activity_time as publish_time,
+			art.chart_permission_id,
+			art.chart_permission_name,
+			"" AS play_seconds,
+			"" AS background_img,
+			"" AS industry_name,
+			"" AS share_img,
+			0 AS industrial_management_id,
+			v.activity_id
+		FROM
+			cygx_activity_video as v
+			INNER JOIN cygx_activity as art on art.activity_id = v.activity_id WHERE 1= 1  `
+	if conditionAct != `` {
+		sql += conditionAct
+	}
+	//}
+	//if audioId+videoId+activityVideoId == 0 && filter == 0 {
+	sql += `  UNION ALL `
+	//}
+
+	//if videoId+activityVideoId == 0 && filter != 1 {
+	sql += `
+			SELECT
+			a.activity_voice_id AS id,
+			a.voice_name AS title,
+			a.voice_url AS resource_url,
+			1 AS type,
+			b.activity_time AS publish_time,
+			b.chart_permission_id,
+			b.chart_permission_name,
+			a.voice_play_seconds AS play_seconds,
+			a.img_url AS background_img,
+			"" AS industry_name,
+			"" AS share_img,
+			0 AS industrial_management_id,
+			a.activity_id 
+		FROM
+			cygx_activity_voice AS a
+			JOIN cygx_activity AS b ON a.activity_id = b.activity_id  WHERE 1= 1  `
+	if conditionAudio != `` {
+		sql += conditionAudio
+	}
+	//}
+	sql += ` ORDER BY publish_time DESC`
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql, pars, parsAct, parsAudio).QueryRow(&total)
+	if err != nil {
+		return
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, parsAct, parsAudio, startSize, pageSize).QueryRows(&list)
+	return
+}

+ 2 - 2
models/report_mapping.go

@@ -43,10 +43,10 @@ type TradeReportMappingResp struct {
 	List []*TradeReportMapping
 }
 
-//获取策略下面的所有分类
+//获取所有分类
 func GetReportMappingStrategyAll() (items []*ReportMapping, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_report_mapping WHERE report_type=1 AND chart_permission_id=23 ORDER BY sort ASC `
+	sql := `SELECT * FROM cygx_report_mapping WHERE 1=1 ORDER BY sort ASC `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }

+ 85 - 0
models/resource_data.go

@@ -0,0 +1,85 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"time"
+)
+
+type CygxResourceData struct {
+	Id          int       `orm:"column(id);pk"`
+	SourceId    int       `description:"资源ID"`
+	Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+	Title       string    `description:"标题"`
+	Annotation  string    `description:"核心观点"`
+	CreateTime  time.Time `description:"创建时间"`
+	PublishDate string    `description:"发布时间"`
+	Abstract    string    `description:"摘要"`
+}
+
+type CygxResourceDataResp struct {
+	Id                      int    `orm:"column(id);pk"`
+	SourceId                int    `description:"资源ID"`
+	Source                  string `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+	Title                   string `description:"标题"`
+	Annotation              string `description:"核心观点"`
+	PublishDate             string `description:"发布时间"`
+	Abstract                string `description:"摘要"`
+	IsTop                   bool   `description:"是否置顶"`
+	IsCollection            bool   `description:"是否收藏 "`
+	BackgroundImg           string `description:"背景图"`
+	City                    string `description:"城市"`
+	IsSignup                int    `description:"是否已报名 1是 ,0 否"`
+	IsAppointment           int    `description:"是否已预约纪要 1是 ,0 否"`
+	IsCancelMeetingReminder int    `description:"是否添加了消息消息提醒   1是 ,0 否"`
+	ActiveState             string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
+	ImgUrl                  string `description:"行业图片链接"`
+	ImgUrlText              string `description:"活动类型图片链接"`
+	ActivityType            int    `description:"活动线上线下类型 1线上,0 线下,2线下"`
+	IsShowOutboundCall      bool   `description:"是否展示预约外呼"`
+	IsShowMeetingReminder   bool   `description:"是否展示会议提醒"`
+	IsShowHelpSsk           bool   `description:"是否展示帮我带问"`
+	IsShowSignup            bool   `description:"是否展示我要报名"`
+	IsShowAppointment       bool   `description:"是否展示预约纪要"`
+	IsShowDetails           bool   `description:"是否展示查看详情按钮"`
+	YidongActivityUrl       string `description:"易董活动跳转地址"`
+	TripStatus              int    `description:"行程进行状态 1:预报名,2:确定行程"`
+	IsTrip                  int    `description:"确定行程是否报名 1是 ,0 否"`
+	ActivityTimeText        string `description:"活动预期时间带文字"`
+	TripImgLink             string `description:"行程图片链接"`
+	ChartPermissionId       int    `description:"权限id"`
+	Expert                  string `description:"专家"`
+	Speaker                 string `description:"主讲人"`
+	ActivityTime            string `description:"活动预期时间"`
+	ResourceUrl             string `description:"链接"`
+	AuthInfo                *UserPermissionAuthInfo
+	VoiceDetail             *CygxActivityVoiceReq      `description:"音频数据"`
+	VideoDetail             *CygxActivityVideoListResp `description:"视频数据"`
+	AudioLink               bool                       `description:"是否展示回放按钮"`
+	FileType                int                        `description:"类型: 1-音频; 2-视频"`
+}
+
+type HomeResourceDataListResp struct {
+	Paging *paging.PagingItem
+	List   []*CygxResourceDataResp `description:"列表"`
+}
+
+//列表
+func GetResourceDataList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxResourceData, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT	 *   FROM cygx_resource_data  WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY publish_date  DESC ,  id  DESC   LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+//获取用户报名成功数量
+func GetResourceDataCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_resource_data    WHERE 1= 1 ` + condition
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}

+ 7 - 0
models/seller.go

@@ -69,3 +69,10 @@ func GetSelleridWhichGroup(companyId, productId int) (adminId string, err error)
 	err = o.Raw(sql, companyId, productId).QueryRow(&adminId)
 	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
+}

+ 48 - 0
models/user.go

@@ -247,3 +247,51 @@ type UserPermissionAuthInfo struct {
 	OperationMode string `description:"操作方式:Apply-立即申请; Call-拨号"`
 	PopupMsg      string `description:"权限弹窗信息"`
 }
+
+//修改用户是否绑定外呼手机号弹窗
+func ModifyWxUserIsMsgOutboundMobile(userId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE wx_user SET is_msg_outbound_mobile=1 WHERE user_id=? `
+	_, err = o.Raw(sql, userId).Exec()
+	return
+}
+
+//已经绑定手机号,没有绑定外呼手机号的的用户,预约外呼的时候,将外呼手机号同步成手机号
+func BindUserOutboundMobileByMobile(mobile, countryCode string, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE wx_user SET outbound_mobile=? ,outbound_country_code = ? WHERE user_id=? `
+	_, err = o.Raw(sql, mobile, countryCode, userId).Exec()
+	return
+}
+
+// GetWxUserByMobiles 根据用户手机号获取用户详情
+func GetWxUserByMobiles(mobiles []string) (items []*WxUser, err error) {
+	lenmobiles := len(mobiles)
+	if lenmobiles == 0 {
+		return
+	}
+	sql := `SELECT* FROM wx_user  WHERE mobile in (` + utils.GetOrmInReplace(lenmobiles) + `)  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, mobiles).QueryRows(&items)
+	return
+}
+
+func GetUserCompanyPermissionSand(companyId int) (items []*ChartPermissionResp, err error) {
+	sql := ` SELECT b.*
+			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 a.product_id=2
+			AND c.is_suspend=0
+            AND b.cygx_auth=1
+            AND b.is_other=0
+			AND c.status IN('正式','试用','永续')
+			AND a.status IN('正式','试用','永续') 
+			AND b.chart_permission_name != '专家'
+			GROUP BY b.chart_permission_name
+			ORDER BY b.sort ASC `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, companyId).QueryRows(&items)
+	return
+}

+ 40 - 0
models/user_follow_special.go

@@ -0,0 +1,40 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxUserFollowSpecial struct {
+	Id          int       `orm:"column(id);pk"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+}
+
+//添加
+func AddUserFollowSpecial(item *CygxUserFollowSpecial) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+//获取某一用户的报名的数量
+func GetCygxUserFollowSpecial(uid int) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_user_follow_special  WHERE  user_id=? `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid).QueryRow(&count)
+	return
+}
+
+//删除
+func DeleteCygxUserFollowSpecial(uid int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE  FROM cygx_user_follow_special   WHERE  user_id=? `
+	_, err = o.Raw(sql, uid).Exec()
+	return
+}

+ 2 - 0
models/wx_user.go

@@ -76,6 +76,8 @@ type WxUserItem struct {
 	OutboundCountryCode string    `description:"外呼手机号区号"`
 	IsMsgOutboundMobile int       `description:"是否弹窗过绑定外呼手机号区号"`
 	Source              int
+	IsMaker             int    `description:"是否是决策人"`
+	Position            string `description:"职务"`
 }
 
 func GetWxUserItemByUserId(userId int) (item *WxUserItem, err error) {

+ 139 - 0
models/yidong.go

@@ -0,0 +1,139 @@
+package models
+
+type ApifoxModal struct {
+	ErrorCode interface{} `json:"errorCode"`
+	ErrorMsg  interface{} `json:"errorMsg"`
+	Result    []Result    `json:"result"`
+	Success   bool        `json:"success"`
+	Timestamp int64       `json:"timestamp"`
+}
+
+type Result struct {
+	ActivityJoinType               string  `json:"activityJoinType"`               // 活动入会类型,01报名审核后可入会 02预约即可入会 03仅定向邀请人员可入会
+	Banner                         string  `json:"banner"`                         // 宣传图
+	BusinessCardOpen               string  `json:"businessCardOpen"`               // 上传名片是否开启,1是 0否
+	BusinessCardRequired           string  `json:"businessCardRequired"`           // 上传名片是否必填,1是 0否
+	CertificateInformationOpen     string  `json:"certificateInformationOpen"`     // 证件信息是否开启,1是 0否
+	CertificateInformationRequired string  `json:"certificateInformationRequired"` // 证件信息是否必填,1是 0否
+	CompanyCodeOpen                string  `json:"companyCodeOpen"`                // 公司代码是否开启,1是 0否
+	CompanyCodeRequired            string  `json:"companyCodeRequired"`            // 公司代码是否必填,1是 0否
+	CompanyInfo                    string  `json:"companyInfo"`                    // 公司名称
+	CompanyShortNameOpen           string  `json:"companyShortNameOpen"`           // 公司名称是否开启,1是 0否
+	CompanyShortNameRequired       string  `json:"companyShortNameRequired"`       // 公司名称是否必填,1是 0否
+	End                            string  `json:"end"`                            // 活动结束时间
+	ID                             string  `json:"id"`                             // 活动主键id
+	IndustrySwName                 string  `json:"industrySwName"`                 // 行业
+	InviteeOpen                    *string `json:"inviteeOpen"`                    // 邀请机构是否开启,1是 0否
+	InviteeRequired                *string `json:"inviteeRequired"`                // 邀请机构是否必填,1是 0否
+	JobNameOpen                    string  `json:"jobNameOpen"`                    // 职务是否开启,1是 0否
+	JobNameRequired                string  `json:"jobNameRequired"`                // 职务是否必填,1是 0否
+	MailOpen                       string  `json:"mailOpen"`                       // 邮箱是否开启,1是 0否
+	MailRequired                   string  `json:"mailRequired"`                   // 邮箱是否必填,1是 0否
+	PersonNameOpen                 string  `json:"personNameOpen"`                 // 姓名是否开启,1是 0否
+	PersonNameRequired             string  `json:"personNameRequired"`             // 姓名是否必填,1是 0否
+	PersonTelephoneOpen            string  `json:"personTelephoneOpen"`            // 手机号是否开启,1是 0否
+	PersonTelephoneRequired        string  `json:"personTelephoneRequired"`        // 手机号是否必填,1是 0否
+	SignUpEnd                      string  `json:"signUpEnd"`                      // 报名结束时间,适应于报名审核后可入会,为空表示不限制报名时间
+	SignUpStart                    string  `json:"signUpStart"`                    // 报名开始时间,适应于报名审核后可入会,为空表示不限制报名时间
+	Start                          string  `json:"start"`                          // 活动开始时间
+	SyncFlag                       string  `json:"syncFlag"`                       // 同步有效性,同步有效性 1有效,0失效
+	Title                          string  `json:"title"`                          // 活动主题
+	Type                           string  `json:"type"`                           // 路演类型
+	URL                            string  `json:"url"`                            // 活动短链接
+}
+
+type ApifoxModalDetail struct {
+	ErrorCode interface{} `json:"errorCode"`
+	ErrorMsg  interface{} `json:"errorMsg"`
+	Result    Result      `json:"result"`
+	Success   bool        `json:"success"`
+	Timestamp int64       `json:"timestamp"`
+}
+
+type ResultDetail struct {
+	GuestIntroduceType string     `json:"guestIntroduceType"` // 嘉宾类型,嘉宾类型(0-列表,1-图片)
+	GuestPersonList    []UserList `json:"guestPersonList"`    // 嘉宾列表,适用列表类型
+	GuestPicURL        string     `json:"guestPicUrl"`        // 嘉宾图片链接,适用图片类型
+}
+
+type UserList struct {
+	CompanyName        string  `json:"companyName"`        // 公司
+	HeadPortraitURL    string  `json:"headPortraitUrl"`    // 头像
+	ID                 string  `json:"id"`                 // 嘉宾主键id
+	JobName            string  `json:"jobName"`            // 职务
+	PersonIntroduction *string `json:"personIntroduction"` // 嘉宾介绍
+	PersonName         string  `json:"personName"`         // 姓名
+}
+
+type ApifoxModaldetail struct {
+	ErrorCode    interface{}  `json:"errorCode"`
+	ErrorMsg     interface{}  `json:"errorMsg"`
+	Resultdetail Resultdetail `json:"result"`
+	Success      bool         `json:"success"`
+	Timestamp    int64        `json:"timestamp"`
+}
+
+type Resultdetail struct {
+	GuestIntroduceType string `json:"guestIntroduceType"` // 嘉宾类型,嘉宾类型(0-列表,1-图片)
+	GuestPersonList    []嘉宾列表 `json:"guestPersonList"`    // 嘉宾列表,适用列表类型
+	GuestPicURL        string `json:"guestPicUrl"`        // 嘉宾图片链接,适用图片类型
+}
+
+type 嘉宾列表 struct {
+	CompanyName        string  `json:"companyName"`        // 公司
+	HeadPortraitURL    string  `json:"headPortraitUrl"`    // 头像
+	ID                 string  `json:"id"`                 // 嘉宾主键id
+	JobName            string  `json:"jobName"`            // 职务
+	PersonIntroduction *string `json:"personIntroduction"` // 嘉宾介绍
+	PersonName         string  `json:"personName"`         // 姓名
+}
+
+type ApifoxModaluser struct {
+	ErrorCode interface{}  `json:"errorCode"`
+	ErrorMsg  interface{}  `json:"errorMsg"`
+	Result    []Resultuser `json:"result"`
+	Success   bool         `json:"success"`
+	Timestamp int64        `json:"timestamp"`
+}
+
+type Resultuser struct {
+	DeviceType      *int64  `json:"deviceType"`                // 参会方式,1-PC,2-Mac,3-Android,4-IOS,5-Web,6-iPad,7-Android Pad,8-小程序
+	Duration        *string `json:"duration"`                  // 参会时长
+	EndTime         string  `json:"endTime"`                   // 最后退会时间
+	ID              string  `json:"id,omitempty"`              // 主键id
+	PersonTelephone string  `json:"personTelephone,omitempty"` // 用户手机号
+	StartTime       string  `json:"startTime"`                 // 最早入会时间
+	Status          string  `json:"status"`                    // 状态,D表示被删除
+	UserID          string  `json:"userId,omitempty"`          // 用户id
+}
+
+type ApifoxModalUserTgc struct {
+	Result  结果Map `json:"result"`  // 结果Map
+	Success bool  `json:"success"` // 成功标识,可作为请求是否成功标识
+}
+
+// 结果Map
+type 结果Map struct {
+	Tgc    string `json:"tgc"`    // tgc,跳转H5时拼接用
+	UserID string `json:"userId"` // 用户ID
+}
+
+type ApifoxModalSingUpClass struct {
+	ErrorCode *string   `json:"errorCode"` // 错误码,001:活动不存在;002:该活动不支持此渠道报名;003:该手机号或邮箱已经被其他账号提交报名;004:不在报名时间;005:报名人数已满
+	ErrorMsg  *string   `json:"errorMsg"`  // 错误信息
+	Result    SingUpMap `json:"result"`    // 结果Map,成功
+	Success   bool      `json:"success"`   // 成功标识,true:成功;false:失败。可作为判断报名是否成功的标识
+	Timestamp float64   `json:"timestamp"` // 时间戳
+}
+
+type SingUpMap struct {
+	Msg string `json:"msg"` // 请求信息,成功信息
+}
+
+type ApifoxgetOriginalLink struct {
+	Result    string  `json:"result"`    // 结果Map
+	Success   bool    `json:"success"`   // 成功标识,可作为请求是否成功标识
+	ErrorCode *string `json:"errorCode"` // 错误码,001:活动不存在;002:该活动不支持此渠道报名;003:该手机号或邮箱已经被其他账号提交报名;004:不在报名时间;005:报名人数已满
+	ErrorMsg  *string `json:"errorMsg"`  // 错误信息
+	Timestamp float64 `json:"timestamp"` // 时间戳
+}

+ 189 - 0
routers/commentsRouter.go

@@ -7,6 +7,168 @@ import (
 
 func init() {
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "ActivityAppointmentAdd",
+            Router: `/appointment/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "ActivityAppointmentCancel",
+            Router: `/appointment/cancel`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "AskAdd",
+            Router: `/askAdd`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "Detail",
+            Router: `/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "DetailVideo",
+            Router: `/detailVideo`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "LabelTypeList",
+            Router: `/labelTypeList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "ActivityListNew",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "ActivityListSearch",
+            Router: `/listSearch`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "MeetingReminderAdd",
+            Router: `/meetingReminder/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "MeetingReminderCancel",
+            Router: `/meetingReminder/cancel`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "SignupAdd",
+            Router: `/signup/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivityController"],
+        beego.ControllerComments{
+            Method: "SignupCancel",
+            Router: `/signup/cancel`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivitySpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivitySpecialController"],
+        beego.ControllerComments{
+            Method: "SpecialDetail",
+            Router: `/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivitySpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivitySpecialController"],
+        beego.ControllerComments{
+            Method: "SpecialMsg",
+            Router: `/follow`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivitySpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivitySpecialController"],
+        beego.ControllerComments{
+            Method: "SpecialList",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivitySpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivitySpecialController"],
+        beego.ControllerComments{
+            Method: "SpecialSignupAdd",
+            Router: `/signup/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivitySpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivitySpecialController"],
+        beego.ControllerComments{
+            Method: "SpecialTripAdd",
+            Router: `/trip/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivitySpecialController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ActivitySpecialController"],
+        beego.ControllerComments{
+            Method: "Tripcancel",
+            Router: `/trip/cancel`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ArticleController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:ArticleController"],
         beego.ControllerComments{
             Method: "AskAdd",
@@ -88,6 +250,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MicroRoadShowController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MicroRoadShowController"],
         beego.ControllerComments{
             Method: "VideoHistoryAdd",
@@ -97,6 +268,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileChartPermissionAuthController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileChartPermissionAuthController"],
+        beego.ControllerComments{
+            Method: "ListByActivity",
+            Router: `/listByActivity`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileHomeController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileHomeController"],
         beego.ControllerComments{
             Method: "List",
@@ -106,6 +286,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileHomeController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileHomeController"],
+        beego.ControllerComments{
+            Method: "NewList",
+            Router: `/new`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportBillboardController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportBillboardController"],
         beego.ControllerComments{
             Method: "ReadList",

+ 11 - 0
routers/router.go

@@ -40,6 +40,7 @@ func init() {
 			web.NSInclude(
 				&controllers.ChartPermissionController{},
 				&controllers.ChartPermissionAuthController{},
+				&controllers.MobileChartPermissionAuthController{},
 			),
 		),
 		web.NSNamespace("/resource",
@@ -85,6 +86,16 @@ func init() {
 				&controllers.MicroRoadShowController{},
 			),
 		),
+		web.NSNamespace("/activity",
+			web.NSInclude(
+				&controllers.ActivityController{},
+			),
+		),
+		web.NSNamespace("/activity_special",
+			web.NSInclude(
+				&controllers.ActivitySpecialController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 862 - 0
services/activity.go

@@ -0,0 +1,862 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+//获取活动列表查询权限的SQL
+// @Param   ChartPermissionIds   query   string  false     "行业id 多个用 , 隔开"
+// @Param   ActivityTypeIds   query   string  false     "活动类型id 多个用 , 隔开"
+// @Param   ActiveState   query   string  false       "活动进行状态 未开始:1、进行中2、已结束3"
+// @Param   WhichDay   query   string  false       "哪一天 今天:1、明天:2,多个用 , 隔开"
+// @Param   WhichTime   query   string  false       "已结束的时间筛选项 本周:1、上周:2 、本月:3、上月:4"
+// @Param   Label   query   string  false       "搜索主题 多个用 , 隔开"
+// @Param   PlayBack   query   int  false       "是否仅展示回放 1:是、0:否 默认0"
+// @Param   KeyWord   query   string  false       "搜索关键词"
+func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermissionIds, whichDay, activeState, label string, isPower, source int, keyWord string, playBack int) (conditionActivity string, err error) {
+	adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
+	if err != nil {
+		return
+	}
+	userType, permissionStr, err := GetUserType(user.CompanyId)
+	if err != nil {
+		return
+	}
+	//判断客户规模是否属于可见范围的活动
+	companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+	isMaker := user.IsMaker
+	slicePer := strings.Split(permissionStr, ",")
+	var permissionSqlStr string
+	var permissionNameStr string
+	for _, v := range slicePer {
+		if userType == 1 {
+			//研选权限处理
+			if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
+				permissionNameStr += "'" + v + "',"
+			}
+		} else {
+			permissionNameStr += "'" + v + "',"
+		}
+	}
+	permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
+	permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
+	permissionNameStr = strings.TrimRight(permissionNameStr, ",")
+
+	// 查研观向7.4-始终查询宏观的权限(无论是否有权限)
+	if permissionNameStr == `` {
+		permissionNameStr = `'宏观'`
+	} else {
+		permissionNameStr += `, '宏观'`
+	}
+
+	var condition string
+	var conditionAdmin string
+	var conditionHz string // 弘则权限处理
+	var sqlExport string   // 专家权限处理
+	//permissionSqlStr = `  AND art.chart_permission_name  IN (` + permissionNameStr + `)`
+	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
+	if userType == 2 {
+		sqlExport += ` OR  art.customer_type_ids LIKE '%3%' `
+	}
+	if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
+		sqlExport += ` OR  art.customer_type_ids LIKE '%4%' `
+	}
+	sqlExport += `) `
+	// 如果是C类电话会就不展示内容,且合并到分析师电话会
+	if activityTypeId != "" {
+		if activityTypeId == strconv.Itoa(utils.ANALYST_TELL_ACTIVITY_TYPE_ID) {
+			condition = ` AND art.publish_status = 1  AND art.label != ''  AND art.activity_type_id IN (` + activityTypeId + "," + strconv.Itoa(utils.C_CLASS_ACTIVITY_TYPE_ID) + `)`
+		} else {
+			condition = ` AND art.publish_status = 1  AND art.label != ''  AND art.activity_type_id = ` + activityTypeId
+		}
+	}
+
+	//主题
+	if label != "" {
+		condition = ` AND art.label  LIKE '%` + label + `%' `
+
+	}
+
+	if isPower == 1 {
+		condition += permissionSqlStr
+	}
+
+	//行业名称
+	if len(chartPermissionIds) > 0 {
+
+		condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
+	}
+	//如果是PC的,则不看易董的
+	if source == 1 {
+		condition += ` AND art.yidong_activity_id = '' `
+	}
+
+	var conditionOr string
+	if whichDay != "" {
+		var startDate string
+		var endDate string
+		if whichDay == "1" {
+			startDate = time.Now().Format(utils.FormatDate)
+			endDate = startDate
+		} else if whichDay == "2" {
+			startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
+			endDate = startDate
+		} else if whichDay == "1,2" || whichDay == "2,1" {
+			startDate = time.Now().Format(utils.FormatDate)
+			endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
+		} else if whichDay == "3" {
+			startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "4" {
+			startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "5" {
+			startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
+		} else if whichDay == "6" {
+			startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
+		} else if whichDay == "3,4" || whichDay == "4,3" {
+			startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "5,6" || whichDay == "6,5" {
+			startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
+		} else {
+			startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		}
+		condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
+		condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
+
+	}
+
+	//有搜索条件传过来时,不判进行状态条件
+	if keyWord != "" {
+		condition += ` AND (art.label  LIKE '%` + keyWord + `%' OR art.activity_name  LIKE '%` + keyWord + `%' ) `
+	} else {
+		if activeState != "" {
+			// 默认查看未开始跟进行中
+			if activeState == "1" {
+				condition += ` AND art.active_state  IN (1,2)`
+			} else {
+				condition += ` AND art.active_state  IN (` + activeState + `)`
+			}
+		} else {
+			condition += ` AND art.active_state  IN (1,2)`
+		}
+	}
+
+	if playBack == 1 {
+		var pars []interface{}
+		ativityVIdArry := make([]string, 0)
+		voiceList, e := models.GetActivityVoiceListAll("", pars, 0, 1000)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = e
+			return
+		}
+		for _, v := range voiceList {
+			ativityVIdArry = append(ativityVIdArry, strconv.Itoa(v.ActivityId))
+		}
+
+		videoList, e := models.GetActivityVideoListAll("", pars, 0, 1000)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = e
+			return
+		}
+		for _, v := range videoList {
+			ativityVIdArry = append(ativityVIdArry, strconv.Itoa(v.ActivityId))
+		}
+
+		//活动音频,设置有效时间为30天,失效后该活动就不再支持音频回放。有效期起始时间为活动的开始时间
+		//endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
+		//condition += ` AND art.activity_time > '` + endTime + `'  `
+		if len(ativityVIdArry) > 0 {
+			ativityVIdstr := strings.Join(ativityVIdArry, ",")
+			condition += ` AND art.activity_id IN  (` + ativityVIdstr + `) `
+		}
+	}
+
+	//查询全部可见的数据(是否全部客户可见)
+	condition += `   AND art.publish_status = 1 `
+	conditionHz = condition
+
+	//活动仅决策人可见
+	if isMaker == 0 {
+		condition += ` AND art.is_maker_show = 0  `
+	}
+	conditionAdmin = condition + `  AND art.visible_range = 1 `
+	condition += `  AND art.visible_range != 1 `
+	if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
+		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%'	 ` + condition + `) `
+	}
+	if (userType == 5) && strings.Contains(permissionStr, "专家") {
+		conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%'	 ` + condition + `) `
+	}
+	if userType == 1 {
+		conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
+	} else {
+		conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
+	}
+	if userType == 6 || userType == 7 {
+		conditionOr += ` OR (   art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%'	 ` + condition + `) `
+	}
+	if companyProduct != nil {
+		if companyProduct.Scale != "" {
+			conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+		}
+	}
+
+	if adminIds != "" {
+		conditionOr += ` OR (  art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' ` + ` AND  art.admin_id IN (` + adminIds + `) ` + conditionAdmin + `) `
+		if companyProduct != nil {
+			if companyProduct.Scale != "" {
+				conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'` + ` AND  art.admin_id IN (` + adminIds + `) ` + conditionAdmin + `) `
+			}
+		}
+	}
+
+	//弘则研究下的客户不做权限,限制,C类电话会,仅本组销售、部门管理员、admin、权益研究员账号能看到
+	if user.CompanyId == 16 {
+		mapMobile, e := GetAdminMobileMap()
+		if e != nil {
+			err = e
+			return
+		}
+		if _, ok := mapMobile[user.Mobile]; ok {
+			conditionOr += ` OR (  art.publish_status = 1 ` + conditionHz + `) `
+		}
+	}
+
+	conditionActivity = condition + permissionSqlStr + sqlExport + conditionOr
+	return
+}
+
+//获取可见的活动
+func HandleActivityPowerList(listActivity []*models.CygxActivity, user *models.WxUserItem) (items []*models.CygxActivity, err error) {
+
+	return
+}
+
+//5.3版本活动标签字符串处理
+func LabelStr(label string, isShowSubjectName int, temporaryLabel string) (labelNew string) {
+	slicebr := strings.Split(label, "-")
+	if len(slicebr) > 1 {
+		if isShowSubjectName == 1 {
+			labelNew = slicebr[1]
+		} else {
+			labelNew = slicebr[0]
+		}
+	} else {
+		labelNew = label
+	}
+	if temporaryLabel != "" {
+		labelNew = temporaryLabel
+	}
+	return labelNew
+}
+
+//列表
+func HandleActivityTypeHomeList(listType []*models.ActivityTypeHome, listActivity []*models.CygxActivity, user *models.WxUserItem) (items []*models.ActivityTypeHome, err error) {
+	mapActivity := make(map[int][]*models.CygxActivityLabelList)
+	activityIds := make([]int, 0) // 用于查询活动【新】标签Map
+	for _, v := range listActivity {
+		// 如果是C类电话会就不展示内容,且合并到分析师电话会
+		if v.ActivityTypeId == 7 {
+			v.ActivityTypeId = 2
+		}
+		if v.ActivityTypeId == 1 {
+			activityIds = append(activityIds, v.ActivityId)
+		}
+	}
+
+	// 活动【新】标签Map
+	newLabelMap, _, e := GetActivityNewLabelMap(activityIds)
+	if e != nil {
+		err = errors.New("获取产业新标签Map失败,GetActivityNewLabelMap Err: " + e.Error())
+		return
+	}
+
+	mapkeyWord := make(map[string]string)
+	for _, v := range listActivity {
+		if v.Label == "" {
+			continue
+		}
+		// 如果是C类电话会就不展示内容,且合并到分析师电话会
+		if v.ActivityTypeId == 7 {
+			v.ActivityTypeId = 2
+		}
+		item := new(models.CygxActivityLabelList)
+		item.KeyWord = LabelStr(v.Label, v.IsShowSubjectName, v.TemporaryLabel)
+		if _, ok := mapkeyWord[fmt.Sprint(v.ActivityTypeId, "-", item.KeyWord)]; ok {
+			continue
+		}
+		item.Resource = 1
+		item.ActivityId = v.ActivityId
+		if v.YidongActivityId != "" {
+			item.IsExternalLabel = true
+		}
+		item.IsNew = newLabelMap[v.ActivityId]
+		mapActivity[v.ActivityTypeId] = append(mapActivity[v.ActivityTypeId], item)
+		mapkeyWord[fmt.Sprint(v.ActivityTypeId, "-", item.KeyWord)] = item.KeyWord
+	}
+
+	for _, v := range listType {
+		v.Resource = 1
+		if len(mapActivity[v.ActivityTypeId]) > 0 {
+			v.List = mapActivity[v.ActivityTypeId]
+		} else {
+			v.List = make([]*models.CygxActivityLabelList, 0)
+		}
+	}
+
+	items = listType
+	fmt.Println(len(mapActivity))
+	return
+}
+
+//GetActivityVoiceResp 处理活动音频回放
+func GetActivityVoiceResp(mapActivityId []int) (mapItem map[int]*models.CygxActivityVoiceReq, err error) {
+	activityVoiceList, err := models.GetCygxActivityVoiceReqList(mapActivityId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		return
+	}
+
+	mapActivityVoice := make(map[int]*models.CygxActivityVoiceReq)
+	if len(activityVoiceList) > 0 {
+		for _, v := range activityVoiceList {
+			mapActivityVoice[v.ActivityId] = v
+		}
+	}
+	mapItem = mapActivityVoice
+	return
+}
+
+//GetActivityVideoResp 处理活动视频频回放
+func GetActivityVideoResp(mapActivityId []int) (mapItem map[int]*models.CygxActivityVideoListResp, err error) {
+	var condition string
+	var ativityVIdstr string
+	for _, v := range mapActivityId {
+		ativityVIdstr += strconv.Itoa(v) + ","
+	}
+	if ativityVIdstr == "" {
+		return
+	}
+
+	ativityVIdstr = strings.TrimRight(ativityVIdstr, ",")
+	condition += ` AND art.activity_id IN  (` + ativityVIdstr + `) `
+	var pars []interface{}
+	//endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
+	//condition += ` AND art.activity_time > ? `
+	//pars = append(pars, endTime)
+	videoList, e := models.GetActivityVideoListAll(condition, pars, 0, 1000)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = e
+		return
+	}
+	mapActivityVideo := make(map[int]*models.CygxActivityVideoListResp)
+	if len(videoList) > 0 {
+		for _, v := range videoList {
+			mapActivityVideo[v.ActivityId] = v
+		}
+	}
+	mapItem = mapActivityVideo
+	return
+}
+
+func ActivityButtonShow(item *models.ActivityDetail, user *models.WxUserItem) (itemActivity *models.ActivityListResp) {
+	articleDetail := item
+	//IsShowAppointment       bool                       `description:"是否展示预约纪要"`
+	//IsShowOutboundCall      bool                       `description:"是否展示预约外呼"`
+	//IsShowMeetingReminder   bool                       `description:"是否展示会议提醒"`
+	//IsShowHelpSsk           bool                       `description:"是否展示帮我带问"`
+	//IsShowSignup            bool                       `description:"是否展示我要报名"`
+
+	activityTimeText := articleDetail.ActivityTimeText
+	activityTimeText = strings.Replace(activityTimeText, "(", "(", -1)
+	activityTimeText = strings.Replace(activityTimeText, ")", ")", -1)
+	articleDetail.ActivityTimeText = activityTimeText
+	var yidongActivityUrl string
+	articleDetail.IsShowAppointment = false
+	//易董的操作按钮都隐藏
+	if articleDetail.YidongActivityId != "" {
+		articleDetail.IsShowSignup = false
+		articleDetail.IsShowDetails = true
+
+		if articleDetail.YidongActivityId != "" {
+			ydTgc, _ := GetYiDongCreateUserInfo(user)
+			yidongLongLink, _ := GetYiDongOriginalLink(articleDetail)
+			if yidongLongLink != "" {
+				yidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
+			}
+		}
+	} else {
+
+		//专家电话会 1
+		if articleDetail.ActivityTypeId == 1 && articleDetail.IsLimitPeople == 0 && (articleDetail.ActiveState == "1" || articleDetail.ActiveState == "2") {
+			articleDetail.IsShowHelpSsk = true
+		}
+		if articleDetail.ActiveState == "1" {
+			//新的是否展示规则
+			if articleDetail.IsCanAppointmentMinutes == 1 {
+				articleDetail.IsShowAppointment = true
+			}
+
+			//专家电话会 1
+			if articleDetail.ActivityTypeId == 1 {
+				articleDetail.IsShowOutboundCall = true
+				if articleDetail.IsLimitPeople == 0 {
+					articleDetail.IsShowMeetingReminder = true
+					articleDetail.IsShowHelpSsk = true
+				}
+			}
+
+			//分析师电话会 2
+			if articleDetail.ActivityTypeId == 2 {
+				articleDetail.IsShowOutboundCall = true
+				if articleDetail.LimitPeopleNum == 0 {
+					articleDetail.IsShowMeetingReminder = true
+				}
+			}
+
+			//公司调研电话会 3
+			if articleDetail.ActivityTypeId == 3 {
+				if articleDetail.LimitPeopleNum == 0 {
+					articleDetail.IsShowMeetingReminder = true
+					articleDetail.IsShowOutboundCall = true
+				} else {
+					articleDetail.IsShowSignup = true
+				}
+			}
+
+			//公司线下调研 4
+			if articleDetail.ActivityTypeId == 4 {
+				articleDetail.IsShowSignup = true
+			}
+
+			//专家线下沙龙 5
+			if articleDetail.ActivityTypeId == 5 {
+				articleDetail.IsShowSignup = true
+			}
+
+			//分析师线下沙龙 6
+			if articleDetail.ActivityTypeId == 6 {
+				articleDetail.IsShowSignup = true
+			}
+
+			//分析师电话会(C类) 7
+			if articleDetail.ActivityTypeId == 7 {
+				articleDetail.IsShowSignup = true
+			}
+		}
+	}
+
+	v := articleDetail
+	itemActivity = &models.ActivityListResp{
+		ActivityId:              v.ActivityId,
+		ActivityTypeId:          v.ActivityTypeId,
+		ActivityTypeName:        v.ActivityTypeName,
+		ChartPermissionId:       v.ChartPermissionId,
+		ChartPermissionName:     v.ChartPermissionName,
+		IsLimitPeople:           v.IsLimitPeople,
+		LimitPeopleNum:          v.LimitPeopleNum,
+		LastUpdatedTime:         v.LastUpdatedTime,
+		ActivityTime:            v.ActivityTime,
+		ActivityTimeText:        v.ActivityTimeText,
+		DistinguishedGuest:      v.DistinguishedGuest,
+		Host:                    v.Host,
+		Speaker:                 v.Speaker,
+		MainlandTell:            v.MainlandTell,
+		HongKongTell:            v.HongKongTell,
+		TaiwanTell:              v.TaiwanTell,
+		AmericaTell:             v.AmericaTell,
+		ParticipationCode:       v.ParticipationCode,
+		Theme:                   v.Theme,
+		Expert:                  v.Expert,
+		ActivityName:            v.ActivityName,
+		OnlineParticipation:     v.OnlineParticipation,
+		ReportLink:              v.ReportLink,
+		City:                    v.City,
+		Address:                 v.Address,
+		Highlights:              v.Highlights,
+		Remarks:                 v.Remarks,
+		IsSignup:                v.IsSignup,
+		IsCancelMeetingReminder: v.IsCancelMeetingReminder,
+		IsAppointment:           v.IsAppointment,
+		ActiveState:             v.ActiveState,
+		IsShowSustainable:       v.IsShowSustainable,
+		Description:             v.Description,
+		IsResearch:              v.IsResearch,
+		IsHideAppointment:       v.IsHideAppointment,
+		IsCClassMeeting:         v.IsCClassMeeting,
+		Label:                   v.Label,
+		ImgUrl:                  v.ImgUrl,
+		ImgUrlText:              v.ImgUrlText,
+		ActivityType:            v.ActivityType,
+		IsShowOutboundCall:      v.IsShowOutboundCall,
+		IsShowMeetingReminder:   v.IsShowMeetingReminder,
+		IsShowHelpSsk:           v.IsShowHelpSsk,
+		IsShowSignup:            v.IsShowSignup,
+		IsShowAppointment:       v.IsShowAppointment,
+		IsShowDetails:           v.IsShowDetails,
+		AudioLink:               v.AudioLink,
+		VoiceDetail:             v.VoiceList,
+		VideoDetail:             v.VideoDetail,
+		FileType:                v.FileType,
+		SourceType:              v.SourceType,
+		SignupNum:               v.SignupNum,
+		YidongActivityUrl:       yidongActivityUrl,
+		AuthInfo:                v.AuthInfo,
+	}
+	return
+}
+
+func ActivityDetaailShow(activityInfo *models.ActivityListResp) (itemActivity *models.ActivityListResp, err error) {
+	itemActivity = activityInfo
+	if GetShowSustainable() && strings.Contains(itemActivity.ChartPermissionName, "研选") {
+		itemActivity.IsShowSustainable = true
+	}
+	if activityInfo.SignupNum > activityInfo.LimitPeopleNum {
+		activityInfo.SignupNum = activityInfo.LimitPeopleNum
+	}
+	if activityInfo.ReportLink != "" {
+		artList := strings.Split(activityInfo.ReportLink, "{|}")
+		if len(artList) > 0 {
+			for _, v := range artList {
+				artitem := new(models.ActivityArticleResp)
+				artitem.ReportLink = v
+				artIdSlice := strings.Split(v, "/")
+				if len(artIdSlice) > 0 {
+					articleId, _ := strconv.Atoi(artIdSlice[len(artIdSlice)-1])
+					artitem.ArticleId = articleId
+				}
+				activityInfo.ArticleList = append(activityInfo.ArticleList, artitem)
+			}
+		}
+	} else {
+		activityInfo.ArticleList = make([]*models.ActivityArticleResp, 0)
+	}
+	activityInfo.ActivityTypeName = strings.Replace(activityInfo.ActivityTypeName, "(C类)", "", -1)
+	return
+}
+
+// GetActivityNewLabelMap 获取活动【新】标签Map
+func GetActivityNewLabelMap(activityIds []int) (labelMap map[int]bool, industryNewMap map[int]bool, err error) {
+	labelMap = make(map[int]bool, 0)
+	industryNewMap = make(map[int]bool, 0)
+	if len(activityIds) == 0 {
+		return
+	}
+
+	// 获取活动关联的产业
+	var groupCond string
+	var groupPars []interface{}
+	groupCond += ` AND a.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `) AND b.source = 1  AND  a.active_state != 3 `
+	groupPars = append(groupPars, activityIds)
+	groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars)
+	if e != nil {
+		err = errors.New("获取活动产业关联列表失败, Err: " + e.Error())
+		return
+	}
+	activityIndustryMap := make(map[int][]int, 0)
+	industryIds := make([]int, 0)
+	for i := range groups {
+		industryIds = append(industryIds, groups[i].IndustrialManagementId)
+		activityIndustryMap[groups[i].ActivityId] = append(activityIndustryMap[groups[i].ActivityId], groups[i].IndustrialManagementId)
+	}
+
+	// 获取新产业Map
+	industryLabelMap, e := GetIndustryNewLabelMap(industryIds)
+	if e != nil {
+		err = errors.New("获取产业新标签Map失败, Err: " + e.Error())
+		return
+	}
+
+	// 判断活动是否为新
+	for k := range industryLabelMap {
+		for k2, v2 := range activityIndustryMap {
+			if labelMap[k2] {
+				continue
+			}
+			// 活动的产业ID中存在一个新产业即为新活动
+			if utils.InArrayByInt(v2, k) {
+				labelMap[k2] = true
+			}
+		}
+	}
+
+	//for _, v := range activityIds {
+	//	labelMap[v] = true
+	//}
+	//fmt.Println(labelMap)
+	////产业关联的弘则报告发布日期在三个月以内的活动、产业显示 NEW标签
+	articNewLabel, e := GetArticNewLabelWhithActivity3Month()
+	if e != nil {
+		err = errors.New("获取产业新标签Map失败, Err: " + e.Error())
+		return
+	}
+	for k := range articNewLabel {
+		labelMap[k] = false
+	}
+
+	return
+}
+
+// GetIndustryNewLabelMap 获取产业【新】标签Map
+func GetIndustryNewLabelMap(industryIds []int) (labelMap map[int]bool, err error) {
+	labelMap = make(map[int]bool, 0)
+	industryIdLen := len(industryIds)
+	if industryIdLen == 0 {
+		return
+	}
+
+	// 获取产业关联的报告最早发布时间及最近的发布时间
+	var timeCond string
+	var timePars []interface{}
+	timeCond += ` AND b.publish_status = 1`
+	if industryIdLen > 0 {
+		timeCond += ` AND a.industrial_management_id IN (` + utils.GetOrmInReplace(industryIdLen) + `)`
+		timePars = append(timePars, industryIds)
+	}
+	industryTimeList, e := models.GetIndustryArticleMinMaxPublishTime(timeCond, timePars)
+	if e != nil {
+		err = errors.New("获取产业文章最大最小发布时间失败, Err: " + e.Error())
+		return
+	}
+
+	// 判断产业是否为新
+	nowTime := time.Now().Local()
+	threeMonthBefore := nowTime.AddDate(0, -3, 0)
+	nullTime, _ := time.ParseInLocation(utils.FormatDateTime, "0001-01-01 00:00:00", time.Local)
+	industryMap := make(map[int]*models.IndustryArticleMinMaxPublishTime, 0)
+	for i := range industryTimeList {
+		industryMap[industryTimeList[i].IndustrialManagementId] = industryTimeList[i]
+	}
+	for i := range industryIds {
+		iid := industryIds[i]
+		item := industryMap[iid]
+		if item != nil {
+			// 最早发布时间为空 / 最早发布时间在三个月前之后
+			if item.MinPublishTime.Equal(nullTime) || (item.MinPublishTime.After(threeMonthBefore)) {
+				labelMap[iid] = true
+			}
+		} else {
+			// 产业无报告, 则为新产业
+			labelMap[iid] = true
+		}
+	}
+	return
+}
+
+//GetSpecialDetailUserPower 处理用户查看专项调研详情的权限
+func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.ActivityDetail) (havePower bool, err error) {
+	var companyDetailStatus string
+	userType, permissionStr, e := GetUserType(user.CompanyId)
+	if e != nil {
+		err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
+		return
+	}
+	if user.CompanyId <= 1 {
+		return
+	} else {
+		if permissionStr == "" {
+			return
+		} else {
+			companyDetail, e := models.GetCompanyDetailById(user.CompanyId)
+			if e != nil {
+				err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
+				return
+			}
+			if companyDetail == nil {
+				err = errors.New("客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId))
+				return
+			}
+			companyDetailStatus = companyDetail.Status
+		}
+	}
+	if activityInfo.ChartPermissionId == 1 {
+		havePower = true
+		return
+	}
+	if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3) && strings.Contains(permissionStr, "专家") && activityInfo.LimitPeopleNum == 0 {
+		havePower = true
+	} else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "正式" && strings.Contains(activityInfo.CustomerTypeIds, "4") {
+		havePower = true
+	} else if activityInfo.ActivityTypeId == 3 && strings.Contains(permissionStr, "专家") && companyDetailStatus == "试用" && strings.Contains(activityInfo.CustomerTypeIds, "5") {
+		havePower = true
+	} else if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3 || activityInfo.ActivityTypeId == 4 || activityInfo.ActivityTypeId == 5) && strings.Contains(permissionStr, "专家") {
+		havePower = true
+	}
+	if activityInfo.ActivityTypeId == 2 || activityInfo.ActivityTypeId == 6 || activityInfo.ActivityTypeId == 7 {
+		if strings.Contains(permissionStr, activityInfo.ChartPermissionName+"(主观)") {
+			havePower = true
+		}
+	} else {
+		if strings.Contains(permissionStr, activityInfo.ChartPermissionName+"(客观)") {
+			havePower = true
+		}
+	}
+	if (strings.Contains(activityInfo.ChartPermissionName, "研选") || activityInfo.ChartPermissionName == "策略") && strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
+		havePower = true
+	}
+	//如果是易董的活动且属于研选类型,只要开通任何权限就可以查看详情
+	if activityInfo.YidongActivityId != "" && permissionStr != "" && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
+		havePower = true
+	}
+	if havePower && activityInfo.LimitPeopleNum > 0 {
+		//对于一些特殊的活动,即使权限满足也不给产看
+		noPower, e := GetShareNoPowe(activityInfo, permissionStr, userType, user)
+		if e != nil {
+			err = errors.New("GetShareNoPowe, Err: " + e.Error())
+			return
+		}
+		if noPower {
+			havePower = false
+		}
+	}
+	return
+}
+
+// 校验被分享的用户是否有查看详情的权限
+func GetShareNoPowe(activityInfo *models.ActivityDetail, permissionStr string, userType int, user *models.WxUserItem) (noPower bool, err error) {
+	//如果是弘则的就不进行可见权限校验
+	if user.CompanyId == utils.HZ_COMPANY_ID {
+		return
+	}
+	if (userType == 1 || userType == 4 || userType == 5) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) {
+		noPower = true
+	}
+	//1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户
+	if userType == 2 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) {
+		noPower = true
+	}
+	if userType == 2 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(2)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) {
+		noPower = true
+	}
+	if userType == 3 && strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(4)) {
+		noPower = true
+	}
+	if userType == 3 && !strings.Contains(permissionStr, "专家") && !strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(3)) {
+		noPower = true
+	}
+	if !noPower {
+		noPower, err = CheckUserPowerByActivityChoose(user, activityInfo)
+	}
+	return
+}
+
+//处理活动本组们是否决策人权限
+func CheckUserPowerByActivityChoose(user *models.WxUserItem, activityInfo *models.ActivityDetail) (noPower bool, err error) {
+	//处理 见范围 1,仅本组可见 、2,全部客户可见
+	if activityInfo.VisibleRange == 1 {
+		adminIds, errAdmin := models.GetSelleridWhichGroup(user.CompanyId, 2)
+		if errAdmin != nil {
+			err = errAdmin
+			return
+		}
+		sliceAdminIds := strings.Split(adminIds, ",")
+		var haveAdminId bool
+		for _, v := range sliceAdminIds {
+			if v == strconv.Itoa(activityInfo.AdminId) {
+				haveAdminId = true
+			}
+		}
+		if !haveAdminId {
+			noPower = true
+		}
+	}
+	//处理 是否仅决策人可见 0,否 、1,是
+	if activityInfo.IsMakerShow == 1 {
+		if user.IsMaker == 0 {
+			noPower = true
+		}
+	}
+	return
+}
+
+//判断预约纪要按钮是否显示
+func IsShowAppointment(activityTypeId int, chartPermissionName string) (isShowAppointment bool) {
+	if activityTypeId == 1 || activityTypeId == 2 || activityTypeId == 3 || activityTypeId == 4 {
+		isShowAppointment = true
+	}
+	if activityTypeId == 5 && chartPermissionName == "医药" {
+		isShowAppointment = true
+	}
+	return
+}
+
+//GetindustryVideoDetailById 通过视频ID获取视频详情
+func GetActivityVideoDetailById(user *models.WxUserItem, videoId int) (industryVideo *models.CygxActivityVideoDetailResp, AuthInfo *models.UserPermissionAuthInfo, err error) {
+	total, e := models.GetActivityVideoByVideoIdCount(videoId)
+	if e != nil {
+		err = errors.New("获取活动的视频失败,GetActivityVideoByVideoIdCount " + e.Error())
+		return
+	}
+	if total == 0 {
+		err = errors.New("视频不存在,或已取消发布")
+		return
+	}
+	// 用户权限
+	authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+	if e != nil {
+		err = errors.New("获取用户权限失败,GetUserRaiPermissionInfo " + e.Error())
+		return
+	}
+	videoSimple := new(models.CygxActivityVideoDetailResp)
+	// 权限
+	var au *models.UserPermissionAuthInfo
+	videoSimple, e = models.GetCygxActivityVideoById(videoId)
+	if e != nil {
+		err = errors.New("获取产业关联的视频失败,GetMicroRoadshowVideoByIndustryId " + e.Error())
+		return
+	} else {
+		//videoSimple.Id = video.Id
+		//videoSimple.Title = video.Title
+		//videoSimple.ResourceUrl = video.ResourceUrl
+		//videoSimple.PlaySeconds = video.PlaySeconds
+		//videoSimple.ActivityId = video.ActivityId
+		//videoSimple.ChartPermissionId = video.ChartPermissionId
+
+		if videoSimple.BackgroundImg == "" {
+			// 获取默认图配置
+			_, videoMap, _, _, e := GetMicroRoadShowDefaultImgConfig()
+			if e != nil {
+				err = errors.New("获取视频默认配置图失败,GetMicroRoadshowVideoByIndustryId " + e.Error())
+				return
+			}
+			videoSimple.BackgroundImg = videoMap[videoSimple.ChartPermissionId]
+		}
+		au = new(models.UserPermissionAuthInfo)
+		au.SellerName = authInfo.SellerName
+		au.SellerMobile = authInfo.SellerMobile
+		au.HasPermission = authInfo.HasPermission
+		au.OperationMode = authInfo.OperationMode
+		if au.HasPermission == 1 {
+			// 非宏观权限进一步判断是否有权限
+			if videoSimple.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, videoSimple.ChartPermissionName) {
+				au.HasPermission = 2
+			}
+		}
+		// 无权限的弹框提示
+		if au.HasPermission != 1 {
+			if au.OperationMode == UserPermissionOperationModeCall {
+				au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
+			} else {
+				au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
+			}
+			videoSimple.ResourceUrl = ""
+		}
+	}
+	industryVideo = videoSimple
+	AuthInfo = au
+	return
+}

+ 369 - 0
services/activity_button.go

@@ -0,0 +1,369 @@
+package services
+
+import (
+	"errors"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/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, ActivityButtonShowSearch(v, user))
+	}
+	return
+}
+
+func ActivityButtonShowSearch(item *models.ActivityDetail, user *models.WxUserItem) (articleDetail *models.ActivityDetail) {
+	articleDetail = item
+	//IsShowAppointment       bool                       `description:"是否展示预约纪要"`
+	//IsShowOutboundCall      bool                       `description:"是否展示预约外呼"`
+	//IsShowMeetingReminder   bool                       `description:"是否展示会议提醒"`
+	//IsShowHelpSsk           bool                       `description:"是否展示帮我带问"`
+	//IsShowSignup            bool                       `description:"是否展示我要报名"`
+
+	//如果后台在添加活的时候,关联的报告类型不隐藏预约纪要按钮,而且满足以下展示预约纪要按钮类型就展示
+	//if articleDetail.IsHideAppointment == 0 {
+	//	articleDetail.IsShowAppointment = IsShowAppointmentByactivityInfo(articleDetail, articleDetail.ChartPermissionName)
+	//}
+
+	//articleDetail.SourceType = 1
+	activityTimeText := articleDetail.ActivityTimeText
+	activityTimeText = strings.Replace(activityTimeText, "(", "(", -1)
+	activityTimeText = strings.Replace(activityTimeText, ")", ")", -1)
+	articleDetail.ActivityTimeText = activityTimeText
+
+	articleDetail.IsShowAppointment = false
+	//易董的操作按钮都隐藏
+	if articleDetail.YidongActivityId != "" {
+		articleDetail.IsShowSignup = false
+		articleDetail.IsShowDetails = true
+		if articleDetail.YidongActivityId != "" {
+			ydTgc, _ := GetYiDongCreateUserInfo(user)
+			yidongLongLink, _ := GetYiDongOriginalLink(articleDetail)
+			if yidongLongLink != "" {
+				articleDetail.YidongActivityUrl = yidongLongLink + "%26source=11%26fromHz=true%26tgc=" + ydTgc
+			}
+		}
+	} else {
+		//专家电话会 1
+		if articleDetail.ActivityTypeId == 1 && articleDetail.IsLimitPeople == 0 && (articleDetail.ActiveState == "1" || articleDetail.ActiveState == "2") {
+			articleDetail.IsShowHelpSsk = true
+		}
+		if articleDetail.ActiveState == "1" {
+			//新的是否展示规则
+			if articleDetail.IsCanAppointmentMinutes == 1 {
+				articleDetail.IsShowAppointment = true
+			}
+			//专家电话会 1
+			if articleDetail.ActivityTypeId == 1 {
+				articleDetail.IsShowOutboundCall = true
+				if articleDetail.IsLimitPeople == 0 {
+					articleDetail.IsShowMeetingReminder = true
+					articleDetail.IsShowHelpSsk = true
+				}
+			}
+
+			//分析师电话会 2
+			if articleDetail.ActivityTypeId == 2 {
+				articleDetail.IsShowOutboundCall = true
+				if articleDetail.LimitPeopleNum == 0 {
+					articleDetail.IsShowMeetingReminder = true
+				}
+			}
+
+			//公司调研电话会 3
+			if articleDetail.ActivityTypeId == 3 {
+				if articleDetail.LimitPeopleNum == 0 {
+					articleDetail.IsShowMeetingReminder = true
+					articleDetail.IsShowOutboundCall = true
+				} else {
+					articleDetail.IsShowSignup = true
+				}
+			}
+
+			//公司线下调研 4
+			if articleDetail.ActivityTypeId == 4 {
+				articleDetail.IsShowSignup = true
+			}
+
+			//专家线下沙龙 5
+			if articleDetail.ActivityTypeId == 5 {
+				articleDetail.IsShowSignup = true
+			}
+
+			//分析师线下沙龙 6
+			if articleDetail.ActivityTypeId == 6 {
+				articleDetail.IsShowSignup = true
+			}
+
+			//分析师电话会(C类) 7
+			if articleDetail.ActivityTypeId == 7 {
+				articleDetail.IsShowSignup = true
+			}
+		}
+	}
+	return
+}

+ 782 - 0
services/activity_special.go

@@ -0,0 +1,782 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+//func init() {
+//	UpdateCygxActivitySpecialSignupNum()
+//}
+
+func ActivityLabelSpecialSql(chartPermissionIds, whichDay, activeState string) (condition string) {
+
+	//行业名称
+	if len(chartPermissionIds) > 0 {
+		condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
+	}
+	if whichDay != "" {
+		var startDate string
+		var endDate string
+		if whichDay == "1" {
+			startDate = time.Now().Format(utils.FormatDate)
+			endDate = startDate
+		} else if whichDay == "2" {
+			startDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
+			endDate = startDate
+		} else if whichDay == "1,2" || whichDay == "2,1" {
+			startDate = time.Now().Format(utils.FormatDate)
+			endDate = time.Now().AddDate(0, 0, +1).Format(utils.FormatDate)
+		} else if whichDay == "3" {
+			startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "4" {
+			startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "5" {
+			startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
+		} else if whichDay == "6" {
+			startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
+		} else if whichDay == "3,4" || whichDay == "4,3" {
+			startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "5,6" || whichDay == "6,5" {
+			startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
+		} else {
+			startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		}
+		condition += `    AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
+		condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
+	}
+	if activeState == "2" {
+		condition += ` AND art.days > 0  AND art.activity_time <= ` + "'" + time.Now().Format(utils.FormatDateTime) + " '"
+		condition += ` AND art.activity_time_end >= ` + "'" + time.Now().Format(utils.FormatDateTime) + " '"
+	}
+
+	if activeState == "3" {
+		condition += ` AND art.days > 0  AND art.activity_time_end <= ` + "'" + time.Now().Format(utils.FormatDateTime) + " '"
+	}
+
+	//if activeState == "" && whichDay == "" {
+	//	condition += ` AND art.activity_time_end > ` + "'" + time.Now().Format(utils.FormatDateTime) + " '"
+	//}
+
+	if whichDay != "" {
+		condition += `  AND art.days > 0  `
+	}
+
+	return
+}
+
+//处理专项调研的展示
+func GetActivityLabelSpecialList(user *models.WxUserItem, conditionActivitySpecial 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)
+	fmt.Println(e)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
+		return
+	}
+	if companyDetail == nil {
+		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 != ''  AND art.is_offline = 0 ` + conditionActivitySpecial
+
+	////行业名称
+	//if isPower == 1 {
+	//	condition += ` AND art.chart_permission_name  IN (` + permissionNameStr + `) `
+	//}
+	//if chartPermissionIds != "" {
+	//	condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `) `
+	//}
+	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 {
+		condition += ` AND art.days = 0  ORDER BY art.last_updated_time DESC`
+		specialListNotrip, e := models.GetActivityLabelSpecialListAll(condition, pars, 0, 20)
+		if e != nil {
+			err = e
+			return
+		}
+		for _, v := range specialListNotrip {
+			specialList = append(specialList, v)
+		}
+	}
+	for k2, v2 := range specialList {
+		v2.Resource = 2
+		specialList[k2].KeyWord = LabelStr(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.ActivityTypeName = "专项产业调研"
+	itemList.Resource = 2
+	itemList.List = specialList
+	itemList.ActivityTypeId = 7
+	itemList.OnlineIco = utils.ACTIVITY_ZXDY_ImgUrl1
+	itemList.ImgUrlBgPc = utils.ACTIVITY_ZXDY_ImgUrl2
+	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, conditionActivity string) (list []*models.CygxActivitySpecialDetail, totalPrepare int, err error) {
+	companyDetail, e := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
+		return
+	}
+	if companyDetail == nil {
+		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   ` + conditionActivity
+	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, conditionActivity string) (list []*models.CygxActivitySpecialDetail, totalConfirm int, err error) {
+	//var condition string
+	companyDetail, e := models.GetCompanyDetailByIdGroupTrip(user.CompanyId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
+		return
+	}
+	if companyDetail == nil {
+		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  ` + conditionActivity
+	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 = strconv.Itoa(1)
+		} else if time.Now().After(resultTimeEnd) {
+			list[k].ActiveState = strconv.Itoa(3)
+		} else {
+			list[k].ActiveState = strconv.Itoa(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, conditionActivity, activeState string) (list []*models.CygxActivitySpecialDetail, total int, err error) {
+
+	state := 4
+	if activeState == "3" {
+		state = 3
+	}
+
+	listConfirm, totalConfirm, e := GetActivityLabelSpecialConfirmList(user, (currentIndex-1)*pageSize, pageSize, state, keywords, conditionActivity)
+	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, conditionActivity)
+	if e != nil {
+		err = errors.New("GetActivitySpecialPrepareList, 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 = strconv.Itoa(1)
+	} else if time.Now().After(resultTimeEnd) {
+		activityDetail.ActiveState = strconv.Itoa(3)
+	} else {
+		activityDetail.ActiveState = strconv.Itoa(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, playBack int) (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.publish_status = 1 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)
+	}
+
+	if playBack == 1 {
+		conditionSpecil += ` AND art.activity_id = 0 `
+	}
+	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 && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCompanyDetailByIdGroupTrip, Err: " + e.Error())
+		return
+	}
+	if companyDetail == nil {
+		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
+}

+ 127 - 0
services/activity_special_trip.go

@@ -0,0 +1,127 @@
+package services
+
+import (
+	"errors"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/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
+}

+ 17 - 0
services/admin.go

@@ -0,0 +1,17 @@
+package services
+
+import "hongze/hongze_clpt/models"
+
+func GetAdminMobileMap() (mapItem map[string]string, err error) {
+	adminList, e := models.GetAdminByRole()
+	if e != nil {
+		err = e
+		return
+	}
+	mapMobile := make(map[string]string)
+	for _, v := range adminList {
+		mapMobile[v.Mobile] = v.Mobile
+	}
+	mapItem = mapMobile
+	return
+}

+ 89 - 0
services/article.go

@@ -9,6 +9,7 @@ import (
 	"html"
 	"strconv"
 	"strings"
+	"time"
 	"unicode/utf8"
 )
 
@@ -103,16 +104,29 @@ func HandleArticleCategoryImg(list []*models.ArticleListResp) (items []*models.A
 		imgUrlChart = vslice[len(vslice)-1]
 		mapCategoryUrl[categoryId] = imgUrlChart
 	}
+
+	mapChartPerssion := make(map[string]string)
+	reportMappingList, err := models.GetReportMappingStrategyAll()
+	if err != nil {
+		err = errors.New("GetReportMappingStrategyAll err" + err.Error())
+		return
+	}
+
+	for _, v := range reportMappingList {
+		mapChartPerssion[strconv.Itoa(v.CategoryId)] = v.ChartPermissionName
+	}
 	for k, v := range list {
 		item := list[k]
 		//如果文章一开始的内容是图片,优先展示第一张图片
 		newBody, _ := GetReportContentTextSubByarticle(item.Body, item.Annotation, item.ArticleId)
 		list[k].Annotation = newBody
 		list[k].Body = ""
+		list[k].Abstract, _ = GetReportContentTextSub(v.Abstract)
 		list[k].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
 		if item.Pv > 999 {
 			list[k].Pv = 999
 		}
+		list[k].ChartPermissionName = mapChartPerssion[v.CategoryId]
 		//如果是研选系列的任意取五张图片的中的一张
 		if v.CategoryId == "0" || v.ArticleId > utils.SummaryArticleId {
 			knum := v.ArticleId % 5
@@ -193,3 +207,78 @@ func HandleArticleStock(stock string) (items []*models.ComapnyNameResp) {
 	}
 	return
 }
+
+//弘则报告发布日期在三个月以内的
+func GetArticNewLabelWhithActivity3Month() (labelMap map[int]bool, err error) {
+	var condition string
+	var pars []interface{}
+	condition += ` AND publish_date  <= ?  AND article_id < ? `
+	pars = append(pars, time.Now().AddDate(0, -3, 0), utils.SummaryArticleId)
+	articleList, e := models.GetArticleList(condition, pars)
+	if e != nil {
+		err = errors.New("GetArticleList, Err: " + e.Error())
+		return
+	}
+	var articleIds []int
+	for _, v := range articleList {
+		articleIds = append(articleIds, v.ArticleId)
+	}
+	if len(articleIds) == 0 {
+		return
+	}
+
+	pars = make([]interface{}, 0)
+	condition = ` AND article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
+	pars = append(pars, articleIds)
+	industrialList, e := models.GetIndustrialArticleGroupManagementList(condition, pars)
+	if e != nil {
+		err = errors.New("GetIndustrialArticleGroupManagementList, Err: " + e.Error())
+		return
+	}
+	labelMap = make(map[int]bool, 0)
+	var industrialIds []int
+	for _, v := range industrialList {
+		industrialIds = append(industrialIds, v.IndustrialManagementId)
+	}
+
+	// 获取活动关联的产业
+	var groupCond string
+	var groupPars []interface{}
+	groupCond += ` AND b.industrial_management_id IN (` + utils.GetOrmInReplace(len(industrialIds)) + `)  AND b.source = 1  `
+	groupPars = append(groupPars, industrialIds)
+	groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars)
+	if e != nil {
+		err = errors.New("获取活动产业关联列表失败, Err: " + e.Error())
+		return
+	}
+	for _, v := range groups {
+		labelMap[v.ActivityId] = true
+	}
+	return
+}
+
+//GetSpecialArticleDetailUserPower 处理用户查看专项调研文章详情的权限
+func GetSpecialArticleDetailUserPower(user *models.WxUserItem, articleInfo *models.ArticleDetail) (havePower bool, err error) {
+	permissionStr, e := GetCompanyPermissionUpgrade(user.CompanyId)
+	if e != nil {
+		err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
+		return
+	}
+	reportMapDetail, e := models.GetdetailByCategoryIdPush(articleInfo.CategoryId)
+	if e != nil {
+		err = errors.New("GetdetailByCategoryIdPush, Err: " + e.Error())
+		return
+	}
+	if reportMapDetail == nil {
+		err = errors.New("GetdetailByCategoryIdP,获取详情失败, Err: ")
+		return
+	}
+	fmt.Println(permissionStr)
+	//如果没有对应的升级权限,则返回
+	if !strings.Contains(permissionStr, reportMapDetail.ChartPermissionName) {
+		return
+	} else {
+		havePower = true
+	}
+	return
+}

+ 122 - 0
services/company_permission.go

@@ -0,0 +1,122 @@
+package services
+
+import (
+	"errors"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/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:无该行业权限,不存在权益客户下(ficc),3:无该品类权限,已提交过申请,4:无该品类权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
+	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 = 5
+		} else {
+			hasPermission = 6
+		}
+	} 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
+				}
+				if sellerItemQy != nil {
+					hasPermission = 3
+					sellerName = sellerItemQy.Mobile
+					sellerMobile = sellerItemQy.RealName
+				} else {
+					hasPermission = 2
+				}
+			}
+		} else {
+			hasPermission = 2
+		}
+	}
+	popupMsg = "需要升级行业套餐权限才可参与此活动,请联系对口销售"
+	return
+}
+
+//获取用户对应的权限申请状态 文章详情
+func GetUserHasPermissionArticle(user *models.WxUserItem) (hasPermission int, sellerName, sellerMobile, popupMsg string, err error) {
+	//`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
+	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 = 4
+		} else {
+			hasPermission = 5
+		}
+	} else {
+		companyPermission, e := models.GetCompanyPermission(user.CompanyId)
+		if e != nil {
+			err = errors.New("GetCompanyPermission, Err: " + e.Error())
+			return
+		}
+		if companyPermission != "" {
+			if applyCount > 0 {
+				hasPermission = 2
+			} else {
+				hasPermission = 3
+				//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
+				sellerItemQy, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+				if e != nil && e.Error() != utils.ErrNoRow() {
+					err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
+					return
+				}
+				if sellerItemQy != nil {
+					sellerName = sellerItemQy.Mobile
+					sellerMobile = sellerItemQy.RealName
+				}
+			}
+		} else {
+			hasPermission = 2
+		}
+	}
+	popupMsg = "需要升级行业套餐权限才可查看此报告,请联系对口销售"
+	return
+}

+ 31 - 0
services/config.go

@@ -0,0 +1,31 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_clpt/models"
+)
+
+//是否展示限免标签
+func GetShowSustainable() (isShowSustainable bool) {
+	total, err := models.GetShowSustainable()
+	if err != nil {
+		fmt.Println("GetShowSustainable Err:", err.Error())
+		return
+	}
+	if total > 0 {
+		isShowSustainable = true
+	}
+	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
+}

+ 107 - 0
services/micro_roadshow.go

@@ -5,6 +5,7 @@ import (
 	"errors"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/utils"
+	"strings"
 )
 
 // GetMicroRoadShowDefaultImgConfig 获取微路演默认图/分享图配置
@@ -185,3 +186,109 @@ func GetMicroRoadshowVideoMap() (items map[int]int, err error) {
 	items = mapindustrialId
 	return
 }
+
+// GetMicroRoadShowPageList 获取微路演列表添加活动视频 更新与8.1版本
+func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId int, filter, keywords string) (respList []*models.MicroRoadShowPageList, total int, err error) {
+	var e error
+	// 根据每页数据量获取音视频配比
+	startSize := utils.StartIndex(currentIndex, pageSize)
+	videoList := make([]*models.MicroRoadShowPageList, 0)
+	if keywords != "" {
+		keywords = "%" + keywords + "%"
+	}
+
+	//音频的查询
+	var audioCond string
+	var audioPars []interface{}
+	// 如果筛选条件为指定视频ID或只看视频则不做音频查询
+	// @Param   Filter			query	string		false	"筛选条件 为空:全部 1:视频 2:音频 3:逻辑解析 4:路演回放 多个用 , 隔开"
+	if (videoId > 0 || activityVideoId > 0 || (!strings.Contains(filter, "2") && !strings.Contains(filter, "4"))) && filter != "" {
+		audioCond += ` AND a.activity_voice_id = 0 `
+	} else {
+		// 活动已发布且已结束
+		audioCond += ` AND b.publish_status = 1 AND b.active_state = 3`
+		//活动音频,设置有效时间为30天,失效后该活动就不再支持音频回放。有效期起始时间为活动的开始时间
+		//endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
+		//audioCond += ` AND b.activity_time > ? `
+		//audioPars = append(audioPars, endTime)
+		if keywords != "" {
+			audioCond += ` AND a.voice_name LIKE ? OR b.label LIKE ?`
+			audioPars = append(audioPars, keywords, keywords)
+		}
+
+		if audioId > 0 {
+			audioCond += ` AND a.activity_voice_id = ?`
+			audioPars = append(audioPars, audioId)
+		}
+	}
+	//活动视频的处理
+	var videoCondAct string
+	var videoParsAct []interface{}
+	if (audioId > 0 || videoId > 0 || (!strings.Contains(filter, "1") && !strings.Contains(filter, "4"))) && filter != "" {
+		videoCondAct = "AND video_id =  0 "
+	} else {
+		if keywords != "" {
+			videoCondAct += ` AND video_name LIKE ?`
+			videoParsAct = append(videoParsAct, keywords)
+		}
+		if activityVideoId > 0 {
+			videoCondAct += ` AND video_id = ?`
+			videoParsAct = append(videoParsAct, activityVideoId)
+		}
+		videoCondAct += ` AND publish_status = 1`
+	}
+	//产业视频的处理
+	var videoCond string
+	var videoPars []interface{}
+	if (audioId > 0 || videoId > 0 || (!strings.Contains(filter, "1") && !strings.Contains(filter, "3"))) && filter != "" {
+		videoCond += ` AND video_id =  0 `
+	} else {
+		if keywords != "" {
+			videoCond += ` AND video_name LIKE ?`
+			videoPars = append(videoPars, keywords)
+		}
+		if videoId > 0 {
+			videoCond += ` AND video_id = ?`
+			videoPars = append(videoPars, videoId)
+		}
+
+		videoCond += ` AND publish_status = 1`
+	}
+	total, videoList, e = models.GetMicroRoadShowVideoPageListV8(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars, audioId, videoId, activityVideoId, 0)
+	if e != nil {
+		err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
+		return
+	}
+	if total == 0 {
+		return
+	}
+	var activityIds []int
+	for _, v := range videoList {
+		if v.Type == 2 {
+			activityIds = append(activityIds, v.ActivityId)
+		}
+	}
+	if len(activityIds) > 0 {
+		// 获取活动关联的产业
+		var groupCond string
+		var groupPars []interface{}
+		groupCond += ` AND a.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `)`
+		groupPars = append(groupPars, activityIds)
+		groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars)
+		if e != nil {
+			err = errors.New("获取活动产业关联列表失败, Err: " + e.Error())
+			return
+		}
+		activityIndustryMap := make(map[int]int, 0)
+		for _, v := range groups {
+			activityIndustryMap[v.ActivityId] = v.IndustrialManagementId
+		}
+		for _, v := range videoList {
+			if v.Type == 2 {
+				v.IndustrialManagementId = activityIndustryMap[v.ActivityId]
+			}
+		}
+	}
+	respList = videoList
+	return
+}

+ 336 - 0
services/resource_data.go

@@ -0,0 +1,336 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+func GetResourceDataList(condition string, pars []interface{}, startSize, pageSize int, user *models.WxUserItem) (items []*models.CygxResourceDataResp, err error) {
+
+	uid := user.UserId
+	list, e := models.GetResourceDataList(condition, pars, startSize, pageSize)
+	if e != nil {
+		err = errors.New("GetResourceDataList, Err: " + e.Error())
+		return
+	}
+	mapItems := make(map[string]*models.CygxResourceDataResp)
+	for _, v := range list {
+		//预处理文章
+		item := new(models.CygxResourceDataResp)
+		item.Id = v.Id
+		item.SourceId = v.SourceId
+		item.Source = v.Source
+		item.Title = v.Title
+		item.Annotation = v.Annotation
+		item.Abstract = v.Abstract
+		item.PublishDate = utils.TimeRemoveHms(v.PublishDate)
+		mapItems[fmt.Sprint(v.Source, v.SourceId)] = item
+	}
+
+	var articleIds []int
+	var newchartIds []int
+	var roadshowIds []int
+	var activityIds []int
+	var activityvideoIds []int
+	var activityvoiceIds []int
+	var activityspecialIds []int
+
+	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+	for _, v := range list {
+		if v.Source == "article" {
+			articleIds = append(articleIds, v.SourceId)
+		} else if v.Source == "newchart" {
+			newchartIds = append(newchartIds, v.SourceId)
+		} else if v.Source == "roadshow" {
+			roadshowIds = append(roadshowIds, v.SourceId)
+		} else if v.Source == "activity" {
+			activityIds = append(activityIds, v.SourceId)
+		} else if v.Source == "activityvideo" {
+			activityvideoIds = append(activityvideoIds, v.SourceId)
+		} else if v.Source == "activityvoice" {
+			activityvoiceIds = append(activityvoiceIds, v.SourceId)
+		} else if v.Source == "activityspecial" {
+			activityspecialIds = append(activityspecialIds, v.SourceId)
+		}
+	}
+	detail, e := models.GetConfigByCode("city_img_url")
+	if e != nil {
+		err = errors.New("GetResourceDataList, Err: " + e.Error())
+		return
+	}
+	detailChart, e := models.GetConfigByCode("chart_img_url")
+	if e != nil {
+		err = errors.New("GetResourceDataList, 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
+	}
+	var imgUrlResp string
+
+	//处理文章
+	if len(articleIds) > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND a.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
+		pars = append(pars, articleIds)
+		articleList, e := models.GetHomeListPublic(condition, pars, 0, len(articleIds))
+		if e != nil {
+			err = errors.New("GetResourceDataList, Err: " + e.Error())
+			return
+		}
+
+		articleList, e = HandleArticleCategoryImg(articleList)
+		if e != nil {
+			err = errors.New("HandleArticleCategoryImg, Err: " + e.Error())
+			return
+		}
+		for _, v := range articleList {
+			mapItems[fmt.Sprint("article", v.ArticleId)].Title = v.Title
+			mapItems[fmt.Sprint("article", v.ArticleId)].Annotation = v.Annotation
+			mapItems[fmt.Sprint("article", v.ArticleId)].Abstract = v.Abstract
+		}
+	}
+
+	//处理活动
+	if len(activityIds) > 0 {
+		for _, vss := range activityIds {
+			imgUrlResp += strconv.Itoa(vss) + ","
+		}
+		pars = make([]interface{}, 0)
+		condition = ` AND art.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `)   `
+		pars = append(pars, activityIds)
+		activityList, e := models.GetActivityListNew(condition, pars, uid, 0, len(activityIds), 0, 0)
+		if e != nil {
+			err = errors.New("GetResourceDataList, Err: " + e.Error())
+			return
+		}
+		var activityListRersp []*models.ActivityListResp
+		for _, v := range activityList {
+			activityListRersp = append(activityListRersp, ActivityButtonShow(v, user))
+		}
+		for _, v := range activityListRersp {
+			if v == nil {
+				continue
+			}
+			if v.ActivityType == 0 {
+				if mapAddress[v.City] != "" {
+					imgUrlResp = mapAddress[v.City]
+				} else {
+					imgUrlResp = mapAddress["其它"]
+				}
+			} else {
+				if mapChart[v.ChartPermissionName] != "" {
+					imgUrlResp = mapChart[v.ChartPermissionName]
+				}
+			}
+
+			mapItems[fmt.Sprint("activity", v.ActivityId)].Title = v.ActivityName
+			mapItems[fmt.Sprint("activity", v.ActivityId)].City = v.City
+			mapItems[fmt.Sprint("activity", v.ActivityId)].IsSignup = v.IsSignup
+			mapItems[fmt.Sprint("activity", v.ActivityId)].IsCancelMeetingReminder = v.IsCancelMeetingReminder
+			mapItems[fmt.Sprint("activity", v.ActivityId)].IsAppointment = v.IsAppointment
+			mapItems[fmt.Sprint("activity", v.ActivityId)].ActiveState = v.ActiveState
+			mapItems[fmt.Sprint("activity", v.ActivityId)].ImgUrlText = v.ImgUrlText
+			mapItems[fmt.Sprint("activity", v.ActivityId)].ActivityType = v.ActivityType
+			mapItems[fmt.Sprint("activity", v.ActivityId)].IsShowOutboundCall = v.IsShowOutboundCall
+			mapItems[fmt.Sprint("activity", v.ActivityId)].IsShowMeetingReminder = v.IsShowMeetingReminder
+			mapItems[fmt.Sprint("activity", v.ActivityId)].IsShowHelpSsk = v.IsShowHelpSsk
+			mapItems[fmt.Sprint("activity", v.ActivityId)].IsShowSignup = v.IsShowSignup
+			mapItems[fmt.Sprint("activity", v.ActivityId)].IsShowAppointment = v.IsShowAppointment
+			mapItems[fmt.Sprint("activity", v.ActivityId)].IsShowDetails = v.IsShowDetails
+			mapItems[fmt.Sprint("activity", v.ActivityId)].ActivityTimeText = v.ActivityTimeText
+			mapItems[fmt.Sprint("activity", v.ActivityId)].Expert = v.Expert
+			mapItems[fmt.Sprint("activity", v.ActivityId)].Speaker = v.Speaker
+			mapItems[fmt.Sprint("activity", v.ActivityId)].YidongActivityUrl = v.YidongActivityUrl
+			mapItems[fmt.Sprint("activity", v.ActivityId)].ImgUrl = imgUrlResp
+		}
+	}
+
+	//处理图表
+	if len(newchartIds) > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND a.chart_id IN (` + utils.GetOrmInReplace(len(newchartIds)) + `)`
+		pars = append(pars, newchartIds)
+		chartDateList, e := models.GetChartListCollection(condition, pars, uid, 0, len(newchartIds))
+		if e != nil {
+			err = errors.New("GetResourceDataList, Err: " + e.Error())
+			return
+		}
+		for _, v := range chartDateList {
+			mapItems[fmt.Sprint("newchart", v.ChartId)].Title = v.Title
+			mapItems[fmt.Sprint("newchart", v.ChartId)].ImgUrl = v.BodyHtml
+			mapItems[fmt.Sprint("newchart", v.ChartId)].IsTop = v.IsTop
+		}
+	}
+
+	//处理专项调研
+	if len(activityspecialIds) > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND art.activity_id IN (` + utils.GetOrmInReplace(len(activityspecialIds)) + `)`
+		pars = append(pars, activityspecialIds)
+		activitySpeciallist, e := models.GetCygxActivitySpecialDetailList(condition, pars, user.UserId, 0, len(activityspecialIds))
+		if e != nil {
+			err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
+			return
+		}
+		UserMap, e := GetSpecialTripUserMap(activityspecialIds, user.UserId)
+		if e != nil {
+			err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
+			return
+		}
+		for _, v := range activitySpeciallist {
+			if mapChart[v.ChartPermissionName] != "" {
+				imgUrlResp = mapChart[v.ChartPermissionName]
+			}
+			if _, ok := UserMap[v.ActivityId]; ok {
+				mapItems[fmt.Sprint("activityspecial", v.ActivityId)].IsTrip = 1
+			}
+			if v.Days == 0 {
+				mapItems[fmt.Sprint("activityspecial", v.ActivityId)].TripStatus = 1
+				mapItems[fmt.Sprint("activityspecial", v.ActivityId)].TripImgLink = v.TripImgLink
+				mapItems[fmt.Sprint("activityspecial", v.ActivityId)].ActivityTimeText = v.ActivityTimeText
+			} else {
+				mapItems[fmt.Sprint("activityspecial", v.ActivityId)].TripStatus = 2
+				mapItems[fmt.Sprint("activityspecial", v.ActivityId)].TripImgLink = v.TripImgLinkFix
+				mapItems[fmt.Sprint("activityspecial", v.ActivityId)].ActivityTimeText = v.ActivityTimeTextByDay
+				resultTimeStart := utils.StrTimeToTime(v.ActivityTime)  //时间字符串格式转时间格式
+				resultTimeEnd := utils.StrTimeToTime(v.ActivityTimeEnd) //时间字符串格式转时间格式
+				if resultTimeStart.After(time.Now()) {
+					mapItems[fmt.Sprint("activityspecial", v.ActivityId)].ActiveState = strconv.Itoa(1)
+				} else if time.Now().After(resultTimeEnd) {
+					mapItems[fmt.Sprint("activityspecial", v.ActivityId)].ActiveState = strconv.Itoa(3)
+				} else {
+					mapItems[fmt.Sprint("activityspecial", v.ActivityId)].ActiveState = strconv.Itoa(2)
+				}
+			}
+			mapItems[fmt.Sprint("activityspecial", v.ActivityId)].Title = v.ResearchTheme
+			mapItems[fmt.Sprint("activityspecial", v.ActivityId)].ActivityType = v.SpecialType
+			mapItems[fmt.Sprint("activityspecial", v.ActivityId)].City = v.City
+			mapItems[fmt.Sprint("activityspecial", v.ActivityId)].ActivityTime = v.ActivityTime
+			mapItems[fmt.Sprint("activityspecial", v.ActivityId)].IsSignup = v.IsSignup
+			mapItems[fmt.Sprint("activityspecial", v.ActivityId)].ImgUrl = imgUrlResp
+		}
+	}
+
+	//处理路演
+	if len(roadshowIds) > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND video_id IN (` + utils.GetOrmInReplace(len(roadshowIds)) + `)`
+		pars = append(pars, roadshowIds)
+		roadshowVideoList, e := models.GetMicroRoadshowVideoListBycondition(condition, pars, 0, len(roadshowIds))
+		if e != nil {
+			err = errors.New("GetResourceDataList, Err: " + e.Error())
+			return
+		}
+		for _, v := range roadshowVideoList {
+			mapItems[fmt.Sprint("roadshow", v.VideoId)].Title = v.VideoName
+			mapItems[fmt.Sprint("roadshow", v.VideoId)].ImgUrl = v.ImgUrl
+			mapItems[fmt.Sprint("roadshow", v.VideoId)].PublishDate = v.CreateTime.Format(utils.FormatDateTime)
+		}
+	}
+	//处理路活动视频
+	if len(activityvideoIds) > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND video_id IN (` + utils.GetOrmInReplace(len(activityvideoIds)) + `)`
+		pars = append(pars, activityvideoIds)
+		activityVideoList, e := models.GetActivityVideoList(condition, pars, 0, len(activityvideoIds))
+		if e != nil {
+			err = errors.New("GetResourceDataList, Err: " + e.Error())
+			return
+		}
+		//// 获取默认图配置
+		_, videoMap, _, _, e := GetMicroRoadShowDefaultImgConfig()
+		if e != nil {
+			err = errors.New("GetMicroRoadShowDefaultImgConfig, Err: " + e.Error())
+			return
+		}
+		for _, v := range activityVideoList {
+			mapItems[fmt.Sprint("activityvideo", v.VideoId)].Title = v.VideoName
+			mapItems[fmt.Sprint("activityvideo", v.VideoId)].ImgUrl = videoMap[v.ChartPermissionId]
+			mapItems[fmt.Sprint("activityvideo", v.VideoId)].ChartPermissionId = v.ChartPermissionId
+		}
+	}
+
+	//处理路活音频
+	if len(activityvoiceIds) > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND activity_voice_id IN (` + utils.GetOrmInReplace(len(activityvoiceIds)) + `)`
+		pars = append(pars, activityvoiceIds)
+		activityVoiceList, e := models.GetActivityVoiceList(condition, pars, 0, len(activityvoiceIds))
+		if e != nil {
+			err = errors.New("GetResourceDataList, Err: " + e.Error())
+			return
+		}
+
+		// 用户权限
+		authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+		if e != nil {
+			err = errors.New("GetUserRaiPermissionInfo, Err: " + e.Error())
+			return
+		}
+
+		// 获取默认图配置
+		audioMap, _, _, _, e := GetMicroRoadShowDefaultImgConfig()
+		if e != nil {
+			err = errors.New("GetMicroRoadShowDefaultImgConfig, Err: " + e.Error())
+			return
+		}
+		for i, v := range activityVoiceList {
+			au := new(models.UserPermissionAuthInfo)
+			au.SellerName = authInfo.SellerName
+			au.SellerMobile = authInfo.SellerMobile
+			au.HasPermission = authInfo.HasPermission
+			au.OperationMode = authInfo.OperationMode
+			if au.HasPermission == 1 {
+				// 非宏观权限进一步判断是否有权限
+				if activityVoiceList[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, activityVoiceList[i].ChartPermissionName) {
+					au.HasPermission = 2
+				}
+			}
+			// 无权限的弹框提示
+			if au.HasPermission != 1 {
+				if au.OperationMode == UserPermissionOperationModeCall {
+					au.PopupMsg = UserPermissionPopupMsgCallActivity
+				} else {
+					au.PopupMsg = UserPermissionPopupMsgApplyActivity
+				}
+			}
+			mapItems[fmt.Sprint("activityvoice", v.ActivityVoiceId)].AuthInfo = au
+			mapItems[fmt.Sprint("activityvoice", v.ActivityVoiceId)].Title = v.VoiceName
+			mapItems[fmt.Sprint("activityvoice", v.ActivityVoiceId)].ImgUrl = audioMap[v.ChartPermissionId]
+			if au.HasPermission == 1 {
+				mapItems[fmt.Sprint("activityvoice", v.ActivityVoiceId)].ResourceUrl = v.VoiceUrl
+			}
+		}
+	}
+	for _, vList := range list {
+		for _, v := range mapItems {
+			if v.SourceId == vList.SourceId {
+				items = append(items, v)
+			}
+		}
+	}
+	return
+}

+ 3 - 1
services/user_permission.go

@@ -13,7 +13,9 @@ var (
 	UserPermissionPopupMsgApplyActivity   = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
 	UserPermissionPopupMsgCallActivity    = "您暂无权限参加此活动,若想参加可以联系对口销售"
 	UserPermissionPopupMsgApplyMicroVideo = "您暂无权限查看此视频,若想查看可以申请开通对应的试用权限"
-	UserPermissionPopupMsgCallMicroVideo  = "您暂无权限查看此视频若想查看可以联系对口销售"
+	UserPermissionPopupMsgApplyMicroVoice = "您暂无权限查看此音频,若想查看可以申请开通对应的试用权限"
+	UserPermissionPopupMsgCallMicroVoice  = "您暂无权限查看此音频,若想参加可以联系对口销售"
+	UserPermissionPopupMsgCallMicroVideo  = "您暂无权限查看此视频,若想查看可以联系对口销售"
 )
 
 // GetUserRaiPermissionInfo 获取权限类型及信息

+ 57 - 0
services/wechat_send_msg.go

@@ -3,11 +3,13 @@ package services
 import (
 	"bytes"
 	"encoding/json"
+	"errors"
 	"fmt"
 	"hongze/hongze_clpt/models"
 	"hongze/hongze_clpt/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
+}

+ 57 - 0
services/wx_template_msg.go

@@ -124,3 +124,60 @@ func SendTemplateMsg(sendUrl string, data []byte, resource string, sendType int,
 	}
 	return
 }
+
+//活动带问提醒
+func SendActivityAskApplyTemplateMsgV2(keyword1, keyword2, keyword3, keyword4, remark string, itemOpenid *models.OpenIdList, itemAct *models.ActivityDetail) (err error) {
+	var msg string
+	defer func() {
+		if err != nil {
+			go utils.SendEmail("发送模版消息失败"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
+			go utils.SendAlarmMsg("活动带问提醒发送模版消息失败"+remark, 2)
+		}
+		if msg != "" {
+			utils.FileLog.Info("发送模版消息失败,msg:%s", msg)
+		}
+	}()
+
+	var accessToken string
+	accessToken, err = models.GetWxAccessTokenByXzs()
+	if err != nil {
+		msg = "GetWxAccessToken Err:" + err.Error()
+		return
+	}
+	if accessToken == "" {
+		msg = "accessToken is empty"
+		return
+	}
+	activityId := itemAct.ArticleId
+	//fmt.Println("itemAct.Host", itemAct.Host)
+	if itemAct.ChartPermissionId != utils.CHART_PERMISSION_ID_YANXUAN && itemAct.Host != "" {
+		keyword2 += ",会议主持人:" + itemAct.Host
+	}
+	sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
+	sendMap := make(map[string]interface{})
+	sendData := make(map[string]interface{})
+
+	first := "有新的客户提问"
+	//keyword1 := applyName
+	//keyword2 := "-"
+	//keyword3 := applyTime
+	//keyword4 := askContent
+	//remark := activityName
+	fontColor := "#D9001B"
+	sendData["first"] = map[string]interface{}{"value": first, "color": fontColor}
+	sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": fontColor}
+	sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": fontColor}
+	sendData["keyword3"] = map[string]interface{}{"value": keyword3, "color": fontColor}
+	sendData["keyword4"] = map[string]interface{}{"value": keyword4, "color": fontColor}
+	sendData["remark"] = map[string]interface{}{"value": remark, "color": fontColor}
+	if utils.RunMode == "release" {
+		sendMap["template_id"] = utils.WxMsgTemplateIdApplyXzs
+	} else {
+		sendMap["template_id"] = utils.WxMsgTemplateIdApply
+	}
+	sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxAppId, "pagepath": "activityPages/activityDetail/activityDetail?id=" + strconv.Itoa(activityId)}
+	sendMap["data"] = sendData
+	sendTemplateMsg(sendUrl, sendMap, itemOpenid, strconv.Itoa(activityId), utils.TEMPLATE_MSG_CYGX_ACTIVITY_ADD)
+	fmt.Println("send end")
+	return
+}

+ 291 - 0
services/yidong.go

@@ -0,0 +1,291 @@
+package services
+
+import (
+	"encoding/json"
+	"fmt"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+	"io/ioutil"
+	"net/http"
+	"strings"
+	"time"
+)
+
+//GetActivityTypeIdWithYiDong 根据易董同步过来的活动类型,自动匹配行业
+func GetActivityTypeIdWithYiDong(industrySwName string) (chartPermissionId int) {
+	mapIndustrySwName := map[string]int{
+		"家用电器": utils.XIAO_FEI_ID,
+		"纺织服饰": utils.XIAO_FEI_ID,
+		"休闲服务": utils.XIAO_FEI_ID,
+		"食品饮料": utils.XIAO_FEI_ID,
+		"美容护理": utils.XIAO_FEI_ID,
+		//消费
+
+		"汽车":   utils.ZHI_ZAO_ID,
+		"机械设备": utils.ZHI_ZAO_ID,
+		"电力设备": utils.ZHI_ZAO_ID,
+		//智造
+
+		"电子":  utils.KE_JI_ID,
+		"计算机": utils.KE_JI_ID,
+		"通信":  utils.KE_JI_ID,
+		//科技
+
+		"医药生物": utils.YI_YAO_ID,
+		//医药
+
+		"策略": utils.CE_LUE_ID,
+		//策略
+
+		"非银金融": utils.CHART_PERMISSION_ID_YANXUAN,
+		"建筑装饰": utils.CHART_PERMISSION_ID_YANXUAN,
+		"基础化工": utils.CHART_PERMISSION_ID_YANXUAN,
+		"农林牧渔": utils.CHART_PERMISSION_ID_YANXUAN,
+		"传媒":   utils.CHART_PERMISSION_ID_YANXUAN,
+		"公用事业": utils.CHART_PERMISSION_ID_YANXUAN,
+		"建筑材料": utils.CHART_PERMISSION_ID_YANXUAN,
+		"房地产":  utils.CHART_PERMISSION_ID_YANXUAN,
+		"采掘":   utils.CHART_PERMISSION_ID_YANXUAN,
+		"轻工制造": utils.CHART_PERMISSION_ID_YANXUAN,
+		"钢铁":   utils.CHART_PERMISSION_ID_YANXUAN,
+		"交通运输": utils.CHART_PERMISSION_ID_YANXUAN,
+		"国防军工": utils.CHART_PERMISSION_ID_YANXUAN,
+		"银行":   utils.CHART_PERMISSION_ID_YANXUAN,
+		"有色金属": utils.CHART_PERMISSION_ID_YANXUAN,
+		"综合":   utils.CHART_PERMISSION_ID_YANXUAN,
+		"商业贸易": utils.CHART_PERMISSION_ID_YANXUAN,
+
+		"宏观":   utils.CHART_PERMISSION_ID_YANXUAN,
+		"金融工程": utils.CHART_PERMISSION_ID_YANXUAN,
+		"商贸零售": utils.CHART_PERMISSION_ID_YANXUAN,
+		"社会服务": utils.CHART_PERMISSION_ID_YANXUAN,
+		"煤炭":   utils.CHART_PERMISSION_ID_YANXUAN,
+		"石油石化": utils.CHART_PERMISSION_ID_YANXUAN,
+		"环保":   utils.CHART_PERMISSION_ID_YANXUAN,
+		//研选
+	}
+	chartPermissionId = mapIndustrySwName[industrySwName]
+	return
+}
+
+//GetActivityTypeIdWithYiDong 根据易董同步过来的活动类型,自动匹配行业
+func GetActivityTypeNameWithYiDong(industrySwName string) (chartPermissionName string) {
+	mapIndustrySwName := map[string]string{
+		"家用电器": utils.XIAO_FEI_NAME,
+		"纺织服饰": utils.XIAO_FEI_NAME,
+		"休闲服务": utils.XIAO_FEI_NAME,
+		"食品饮料": utils.XIAO_FEI_NAME,
+		"美容护理": utils.XIAO_FEI_NAME,
+		//消费
+
+		"汽车":   utils.ZHI_ZAO_NAME,
+		"机械设备": utils.ZHI_ZAO_NAME,
+		"电力设备": utils.ZHI_ZAO_NAME,
+		//智造
+
+		"电子":  utils.KE_JI_NAME,
+		"计算机": utils.KE_JI_NAME,
+		"通信":  utils.KE_JI_NAME,
+		//科技
+
+		"医药生物": utils.YI_YAO_NAME,
+		//医药
+
+		"策略": utils.CE_LUE_NAME,
+		//策略
+
+		"非银金融": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"建筑装饰": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"基础化工": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"农林牧渔": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"传媒":   utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"公用事业": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"建筑材料": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"房地产":  utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"采掘":   utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"轻工制造": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"钢铁":   utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"交通运输": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"国防军工": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"银行":   utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"有色金属": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"综合":   utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"商业贸易": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+
+		"宏观":   utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"金融工程": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"商贸零售": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"社会服务": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"煤炭":   utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"石油石化": utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		"环保":   utils.CHART_PERMISSION_NAME_MF_YANXUAN,
+		//研选
+	}
+	chartPermissionName = mapIndustrySwName[industrySwName]
+	return
+}
+
+//获取易董token
+func GetYiDongToken() (token string, err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			utils.FileLog.Info(err.Error())
+		}
+	}()
+	cacheKey := utils.YD_TOKEN
+	ttlTime := utils.Rc.GetRedisTTL(cacheKey)
+	if ttlTime > 0 {
+		token, _ = utils.Rc.RedisString(cacheKey)
+	}
+	if token == "" {
+		url := utils.YiDongZhengTongYunUrl + "oauth/token?grant_type=client_credentials&response_type=token&client_id=" + utils.YiDongZhengTongYunAppid + "&client_secret=" + utils.YiDongZhengTongYunSecret
+		method := "GET"
+		client := &http.Client{}
+		req, errReq := http.NewRequest(method, url, nil)
+		if errReq != nil {
+			err = errReq
+			return
+		}
+		res, errReq := client.Do(req)
+		if errReq != nil {
+			err = errReq
+			return
+		}
+		defer res.Body.Close()
+
+		type Ydtoklen struct {
+			Success     bool   `json:"success"`
+			ExpiresIn   int    `json:"expires_in"`
+			AccessToken string `json:"access_token"`
+		}
+		var ydtoklen Ydtoklen
+		body, errReq := ioutil.ReadAll(res.Body)
+		if errReq != nil {
+			err = errReq
+			return
+		}
+		errReq = json.Unmarshal(body, &ydtoklen)
+		if errReq != nil {
+			err = errReq
+			return
+		}
+		token = ydtoklen.AccessToken
+		utils.Rc.Put(cacheKey, ydtoklen.AccessToken, time.Second*7000)
+	}
+	return
+}
+
+//生成用户相关信息接口 获取用户tgc
+func GetYiDongCreateUserInfo(user *models.WxUserItem) (userTgc string, err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("生成用户相关信息接口 获取用户tgc失败:"+err.Error(), 2)
+			utils.FileLog.Info(err.Error())
+		}
+	}()
+	url := utils.YiDongHuaWeiYunUrl + "app/hz/createUserInfo"
+	method := "POST"
+	payload := strings.NewReader(`{
+  "phone": "` + user.Mobile + `",
+  "personName": "` + user.RealName + `",
+  "companyName": "` + user.CompanyName + `",
+  "jobName": "` + user.Position + `",
+  "mobileCountryCode": "+` + user.CountryCode + `",
+  "sourceFrom": "01"
+}`)
+	client := &http.Client{}
+	req, err := http.NewRequest(method, url, payload)
+	if err != nil {
+		fmt.Println(err)
+		utils.FileLog.Info(err.Error())
+		return
+	}
+	req.Header.Add("Content-Type", "application/json")
+	res, err := client.Do(req)
+	if err != nil {
+		fmt.Println(err)
+		utils.FileLog.Info(err.Error())
+		return
+	}
+	defer res.Body.Close()
+	var ApifoxModal *models.ApifoxModalUserTgc
+	body, err := ioutil.ReadAll(res.Body)
+	if err != nil {
+		fmt.Println(err)
+		utils.FileLog.Info(err.Error())
+		return
+	}
+	err = json.Unmarshal(body, &ApifoxModal)
+	if err != nil {
+		fmt.Println("Getres.PublicGetDate Err:", err.Error())
+		utils.FileLog.Info(err.Error())
+		return
+	}
+	userTgc = ApifoxModal.Result.Tgc
+	return
+}
+
+//GetYiDongOriginalLink 将易懂的短连接转为长链接
+func GetYiDongOriginalLink(item *models.ActivityDetail) (yidongLongLink string, err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("将易懂的短连接转为长链接 失败:"+err.Error(), 2)
+			utils.FileLog.Info(err.Error())
+		}
+	}()
+	sliceYidongActivityUrl := strings.Split(item.YidongActivityUrl, "/")
+	var shortLink string
+	if len(sliceYidongActivityUrl) > 1 {
+		shortLink = sliceYidongActivityUrl[len(sliceYidongActivityUrl)-1]
+	}
+	var token string
+	token, err = GetYiDongToken()
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	url := utils.YiDonggetOriginalLink + shortLink + "&access_token=" + token
+	fmt.Println(url)
+	method := "GET"
+
+	client := &http.Client{}
+	req, err := http.NewRequest(method, url, nil)
+
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	res, err := client.Do(req)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	defer res.Body.Close()
+
+	var ApifoxModal *models.ApifoxgetOriginalLink
+	body, err := ioutil.ReadAll(res.Body)
+	if err != nil {
+		fmt.Println(err)
+		utils.FileLog.Info(err.Error())
+		return
+	}
+	err = json.Unmarshal(body, &ApifoxModal)
+	if err != nil {
+		fmt.Println("Getres.PublicGetDate Err:", err.Error())
+		utils.FileLog.Info(err.Error())
+		return
+	}
+	lingLink := ApifoxModal.Result
+	//fmt.Println(lingLink)
+	//
+	//slicelingLink := strings.Split(lingLink, "redirect_uri=")
+	////var shortLink string
+	//if len(slicelingLink) > 1 {
+	//	lingLink = slicelingLink[len(slicelingLink)-1]
+	//}
+	yidongLongLink = lingLink
+	return
+}

+ 58 - 0
utils/common.go

@@ -673,3 +673,61 @@ func InArrayByInt(idIntList []int, searchId int) (has bool) {
 	}
 	return
 }
+
+// GetNowWeekMonday 获取本周周一的时间
+func GetNowWeekMonday() time.Time {
+	offset := int(time.Monday - time.Now().Weekday())
+	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
+		offset = -6
+	}
+	mondayTime := time.Now().AddDate(0, 0, offset)
+	mondayTime = time.Date(mondayTime.Year(), mondayTime.Month(), mondayTime.Day(), 0, 0, 0, 0, mondayTime.Location())
+	return mondayTime
+}
+
+// GetLastWeekMonday 获取上周周一的时间
+func GetLastWeekMonday() time.Time {
+	offset := int(time.Monday - time.Now().Weekday())
+	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
+		offset = -6
+	}
+	mondayTime := time.Now().AddDate(0, 0, offset-7)
+	mondayTime = time.Date(mondayTime.Year(), mondayTime.Month(), mondayTime.Day(), 0, 0, 0, 0, mondayTime.Location())
+	return mondayTime
+}
+
+// GetNowWeekSunDay 获取本周周日的时间
+func GetNowWeekSunday() time.Time {
+	return GetNowWeekMonday().AddDate(0, 0, 6)
+}
+
+// GetLastWeekSunday 获取上周周日的时间
+func GetLastWeekSunday() time.Time {
+	return GetLastWeekMonday().AddDate(0, 0, 6)
+}
+
+// GetNowMonthFirstDay 获取本月第一天的时间
+func GetNowMonthFirstDay() time.Time {
+	nowMonthFirstDay := time.Date(time.Now().Year(), time.Now().Month(), 1, 0, 0, 0, 0, time.Now().Location())
+	return nowMonthFirstDay
+}
+
+// GetNowMonthLastDay 获取本月最后一天的时间
+func GetNowMonthLastDay() time.Time {
+	nowMonthLastDay := time.Date(time.Now().Year(), time.Now().Month(), 1, 0, 0, 0, 0, time.Now().Location()).AddDate(0, 1, -1)
+	nowMonthLastDay = time.Date(nowMonthLastDay.Year(), nowMonthLastDay.Month(), nowMonthLastDay.Day(), 23, 59, 59, 0, nowMonthLastDay.Location())
+	return nowMonthLastDay
+}
+
+// GetNowMonthFirstDay 获取上月第一天的时间
+func GetLastMonthFirstDay() time.Time {
+	nowMonthFirstDay := time.Date(time.Now().Year(), time.Now().AddDate(0, -1, 0).Month(), 1, 0, 0, 0, 0, time.Now().Location())
+	return nowMonthFirstDay
+}
+
+// GetNowMonthLastDay 获取上月最后一天的时间
+func GetLastMonthLastDay() time.Time {
+	nowMonthLastDay := time.Date(time.Now().Year(), time.Now().AddDate(0, -1, 0).Month(), 1, 0, 0, 0, 0, time.Now().Location()).AddDate(0, 1, -1)
+	nowMonthLastDay = time.Date(nowMonthLastDay.Year(), nowMonthLastDay.Month(), nowMonthLastDay.Day(), 23, 59, 59, 0, nowMonthLastDay.Location())
+	return nowMonthLastDay
+}

+ 35 - 1
utils/config.go

@@ -34,8 +34,20 @@ var (
 	WxMsgTemplateIdApply          string //申请待处理
 	WxMsgTemplateIdAskMsgMobile   string //手机号用户【XXX】发送模板消息
 	WxMsgTemplateIdAskMsgXzs      string //手机号用户【XXX】发送模板消息模板ID(小助手)
+	IndexName                     string
 
-	IndexName string
+	ActSendMsgMobile string //活动带问发送模板消息接收者的手机号
+
+	YiDongZhengTongYunUrl    string //易董 证通云请求域名
+	YiDongZhengTongYunAppid  string //易董 证通云请求appid
+	YiDongZhengTongYunSecret string //易董 证通云请求secret
+	YiDongHuaWeiYunUrl       string //易董 华为云请求域名
+	YiDonggetOriginalLink    string //易董 短连接转为长链接
+)
+
+//模板消息推送
+var (
+	SendWxTemplateMsgUrl string
 )
 
 func init() {
@@ -88,6 +100,7 @@ func init() {
 		WxOpenAppSecret = "0851cc85027c6eb74a400016648ecda8" //公众平台AppSecret
 
 		IndexName = "cygx_article_v0718"
+		ActSendMsgMobile = "15618524605"
 	} else {
 		WxPublicAppId = "wx9b5d7291e581233a"                                          //弘则投研公众号 开发者ID(AppID)
 		WxPublicAppSecret = "f4d52e34021eee262dce9682b31f8861"                        //弘则投研公众号秘钥
@@ -101,8 +114,29 @@ func init() {
 		WxOpenAppSecret = "7bf62d2d037280f8b635c6eca2f31db9" //公众平台AppSecret
 
 		IndexName = "cygx_article_v1"
+		ActSendMsgMobile = "17634786714"
 	}
 	HeadimgurlDefault = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202202/20220225/XFBBOUmDC5AXkfxnHiuqKpPtoofH.png"
+
+	//易董开放api配置
+	YiDongApiConfig()
+}
+
+// YiDongApiConfig 易董开放api配置
+func YiDongApiConfig() {
+	if RunMode == "release" {
+		YiDongZhengTongYunUrl = "https://services.valueonline.cn/"
+		YiDongZhengTongYunAppid = "ca86a257ebb46fce"
+		YiDongZhengTongYunSecret = "338db2b2ca86a257ebb46fced9003f53"
+		YiDongHuaWeiYunUrl = "https://achievement.valueonline.cn/"
+		YiDonggetOriginalLink = "https://services.easy-board.com.cn/short-link/getOriginalLink?shortKey="
+	} else {
+		YiDongZhengTongYunUrl = "https://services-dev.valueonline.cn/"
+		YiDongZhengTongYunAppid = "d9bfb79627ac30d0"
+		YiDongZhengTongYunSecret = "96a61dd2d9bfb79627ac30d02188bbe2"
+		YiDongHuaWeiYunUrl = "https://achievement-test.valueonline.cn/"
+		YiDonggetOriginalLink = "https://services-dev.valueonline.cn/short-link/getOriginalLink?shortKey="
+	}
 }
 
 //http://webapi.brilliantstart.cn/api/

+ 47 - 0
utils/constants.go

@@ -26,6 +26,7 @@ const (
 	ApiUrl              = "https://vmp.hzinsights.com/v2api/"
 	CHART_INFO_HTTP_URL = "https://vmp.hzinsights.com/v2/charts/"
 	DISCLAIMERS         = "本文为用户投稿,用户在平台中发表的所有资料、言论等仅代表个人观点,与本平台立场无关,不对您构成任何投资建议。本平台对文中陈述、观点判断保持中立,不对所包含内容及数据的真实性、准确性、可靠性或完整性提供任何明示或暗示的保证。请读者仅作参考,并请自行承担全部责任。"
+	REGISTER_PLATFORM   = 2 // 来源 1小程序,2:网页
 )
 
 //手机号,电子邮箱正则
@@ -82,6 +83,7 @@ const (
 	OPEN_TOKEN_KEY                   string = "CLPT_OPEN_TOKEN_KEY" //策略品台开放平台的token key
 	OnlineTime                       string = "2021-06-01 00:00:01" //上线时间
 	HONG_GUAN_ID                     int    = 1
+	HZ_COMPANY_ID                    int    = 16
 )
 
 //模板消息推送类型
@@ -101,3 +103,48 @@ const (
 const (
 	TIME_CATEGORYID = 99999 //时间线的分类ID
 )
+
+//活动相关
+const (
+	C_CLASS_ACTIVITY_TYPE_ID      int = 7 //C类电话会会议ID
+	ANALYST_TELL_ACTIVITY_TYPE_ID int = 2 //分析师电话会ID
+
+)
+
+const (
+	YI_YAO_QI_TA = "https://hzstatic.hzinsights.com/static/temp/20220922202209/20220922/2OQMBFplQE1R3bX1y3obX7JSwSuA.png"
+	YAN_XUAN_IMG = "https://hzstatic.hzinsights.com/static/temp/20221027202210/20221027/Dd8TrsMh8tNx2tGd5VeaQDyJVQfV.png"
+)
+
+const (
+	YD_TOKEN = "yidong_token"
+)
+
+const (
+	//专项调研背景图片
+	//ACTIVITY_ZXDY_ImgUrl1 = "https://hzstatic.hzinsights.com/static/temp/20220427202204/20220427/b2Bj3fGakP16iJRFKisQohCWnCNl.png"
+	//ACTIVITY_ZXDY_ImgUrl2 = "https://hzstatic.hzinsights.com/static/temp/20220427202204/20220427/OkunjfKEgo5KRLifzwwLX8cDZnnN.png"
+	//ACTIVITY_ZXDY_ImgUrl3 = "https://hzstatic.hzinsights.com/static/temp/20220426202204/20220426/XDLLsjC9XAAy8LIzQr7GsjrBbtX6.png"
+
+	ACTIVITY_ZXDY_ImgUrl1 = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/0H4md6VgZMuIttggMUnJxgrlayxC.png"
+	ACTIVITY_ZXDY_ImgUrl2 = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/rFwAM1c4fIMJM0EGoUkUYl25XH9L.png"
+	ACTIVITY_ZXDY_ImgUrl3 = "https://hzstatic.hzinsights.com/cygx/special_list_bg.png"
+)
+
+//模板消息地址路由
+const (
+	ACtIVITY_SPECIAL_EXPLAIN      = "此类调研具体行程尚未确定,待预报名人数满10人后弘则会确定行程并推送给您活动日期,只有在确定行程中再次报名才完成占位。"                        //专项调研说明
+	ACtIVITY_SPECIAL_TRIP_EXPLAIN = "此类调研时间安排已经确定,点击报名后按人次扣除对应机构的服务点数。由于每场活动人数有限,如果不能参加请提前48小时取消,未及时取消导致影响其他客户报名将会维持扣点。" //专项调研说明
+
+)
+
+//模板消息地址路由
+const (
+	WX_MSG_PATH_ARTICLE_DETAIL          = "pageMy/reportDetail/reportDetail?id="          //文章详情模板消息地址
+	WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL = "activityPages/specialDetail/specialDetail?id=" //专项调研活动模板消息地址
+)
+
+//微信模板消息推送公共接口的秘钥
+const (
+	SendTemplateMsgAuthorization = "dc855fce962a639faa779cbdd4cd332f"
+)