Browse Source

海通国际接口文档

xingzai 3 years ago
parent
commit
51bad5f82f

+ 304 - 0
controllers/article.go

@@ -965,3 +965,307 @@ func (this *ArticleController) Pdfwatermark() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 获取报告详情(无需token)
+// @Description 获取报告详情接口
+// @Param   ArticleId   query   int  true       "报告ID"
+// @Param   UserName     query string  true       "用户名称"
+// @Param   Sign   query   string  true       "加密签名"
+// @Success 200 {object} models.ArticleDetailHtgjResp
+// @router /detailPublic [get]
+func (this *ArticleCommonController) DetailPublic() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	articleId, _ := this.GetInt("ArticleId")
+	userName := this.GetString("UserName")
+	sign := this.GetString("Sign")
+	errMsg, err, wxUser, companyName := services.CheckHtgj(userName, sign)
+	if articleId <= 0 {
+		br.Msg = "文章不存在"
+		br.ErrMsg = "文章不存在,文章ID错误"
+		return
+	}
+	if errMsg != "" {
+		br.Msg = errMsg
+		return
+	}
+	companyPermission, err := models.GetCompanyPermission(wxUser.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户权限失败,Err:" + err.Error() + ";articleId" + strconv.Itoa(articleId)
+		return
+	}
+	hasPermission := 0
+
+	detail, err := models.GetArticleDetailById(articleId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		return
+	}
+	detail.Body = html.UnescapeString(detail.Body)
+	detail.Body = strings.Replace(detail.Body, "<p data-f-id=\"pbf\" style=\"text-align: center; font-size: 14px; margin-top: 30px; opacity: 0.65; font-family: sans-serif;\">Powered by <a href=\"https://www.froala.com/wysiwyg-editor?pb=1\" title=\"Froala Editor\">Froala Editor</a></p>", "", -1)
+	detail.Body = strings.Replace(detail.Body, "pre", "div", -1)
+	detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
+
+	var articlePermissionPermissionName string
+	if detail.CategoryId > 0 {
+		articlePermission, err := models.GetArticlePermission(detail.CategoryId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(wxUser.UserId) + ";articleId" + strconv.Itoa(articleId)
+			return
+		}
+		if articlePermission == nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(wxUser.UserId) + ";articleId" + strconv.Itoa(articleId)
+			return
+		}
+		articlePermissionPermissionName = articlePermission.PermissionName
+	} else {
+		articlePermissionPermissionName = detail.CategoryName
+	}
+	var hasPersion bool
+	slice := strings.Split(articlePermissionPermissionName, ",")
+	for _, v := range slice {
+		if strings.Contains(companyPermission, v) {
+			hasPersion = true
+		}
+	}
+	if hasPersion {
+		hasPermission = 1
+	}
+	resp := new(models.ArticleDetailHtgjResp)
+	resp.HasPermission = hasPermission
+	if hasPermission == 1 {
+		resp.Detail = detail
+		historyRecord := new(models.CygxArticleHistoryRecord)
+		historyRecord.UserId = wxUser.UserId
+		historyRecord.ArticleId = articleId
+		historyRecord.CreateTime = time.Now()
+		historyRecord.Mobile = wxUser.Mobile
+		historyRecord.Email = wxUser.Email
+		historyRecord.CompanyId = wxUser.CompanyId
+		historyRecord.CompanyName = companyName
+		recordCount, _ := models.GetNoAddStoptimeArticleCount(wxUser.UserId, articleId)
+		if recordCount == 0 {
+			go models.AddCygxArticleHistoryRecord(historyRecord)
+		} else {
+			detailNew, err := models.GetNewArticleHistoryRecord(wxUser.UserId, articleId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取信息失败,Err:" + err.Error()
+				return
+			}
+			if detailNew.StopTime > 0 {
+				go models.AddCygxArticleHistoryRecord(historyRecord)
+			}
+		}
+		key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(wxUser.UserId)
+		if !utils.Rc.IsExist(key) {
+			//新增浏览记录
+			record := new(models.CygxArticleViewRecord)
+			record.UserId = wxUser.UserId
+			record.ArticleId = articleId
+			record.CreateTime = time.Now()
+			record.Mobile = wxUser.Mobile
+			record.Email = wxUser.Email
+			record.CompanyId = wxUser.CompanyId
+			record.CompanyName = companyName
+			go models.AddCygxArticleViewRecord(record)
+			utils.Rc.Put(key, 1, 5*time.Second)
+			models.ModifyReportLastViewTime(wxUser.UserId)
+		}
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 上传文章阅读时间(无需token)
+// @Description 上传文章阅读时间接口(无需token)
+// @Param  request	body models.AddStopTimeHtgjRep true "type json string"
+// @Success 200 {object} models.ArticleDetailResp
+// @router /addStopTimePublic [post]
+func (this *ArticleCommonController) AddStopTimePublic() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	var req models.AddStopTimeHtgjRep
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	articleId := req.ArticleId
+	stopTime := req.StopTime
+	outType := req.OutType
+	source := req.Source
+	userName := req.UserName
+	sign := req.Sign
+
+	var companyName, wxuUserName string
+	userNameList := strings.Split(userName, "-")
+	if len(userNameList) != 2 {
+		br.Msg = "用户信息格式错误"
+		br.ErrMsg = "用户信息格式错误" + userName
+		return
+	}
+	if sign == "" {
+		br.Msg = "签名错误"
+		br.ErrMsg = "签名错误" + sign
+		return
+	}
+	companyName = userNameList[0]
+	wxuUserName = userNameList[1]
+	companyInfo, err := models.GetCompanyByName(companyName)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+		return
+	}
+	user, err := models.GetUserByName(companyInfo.CompanyId, wxuUserName)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
+		return
+	}
+	uid := user.UserId
+	if articleId <= 0 {
+		br.Msg = "参数错误"
+		br.ErrMsg = "参数错误"
+		return
+	}
+	if stopTime == 0 {
+		stopTime = 1
+	}
+	if outType != 2 {
+		outType = 1
+	}
+	if source != "PC" {
+		source = "MOBILE"
+	}
+	detail := new(models.ArticleDetail)
+	hasPermission := 0
+	hasFree := 0
+	//判断是否已经申请过
+	applyCount, err := models.GetApplyRecordCount(uid)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+		return
+	}
+	//`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
+	if user.CompanyId > 1 {
+		companyPermission, err := models.GetCompanyPermission(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+			return
+		}
+		detail, err = models.GetArticleDetailById(articleId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取文章信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+			return
+		}
+		if companyPermission == "" {
+			if applyCount > 0 {
+				hasPermission = 5
+			} else {
+				hasPermission = 2
+			}
+			hasFree = 2
+			goto Loop
+		} else {
+			hasFree = 1
+			var articlePermissionPermissionName string
+			if detail.CategoryId > 0 {
+				articlePermission, err := models.GetArticlePermission(detail.CategoryId)
+				if err != nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+					return
+				}
+				if articlePermission == nil {
+					br.Msg = "获取信息失败"
+					br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
+					return
+				}
+				articlePermissionPermissionName = articlePermission.PermissionName
+			} else {
+				articlePermissionPermissionName = detail.CategoryName
+			}
+			var hasPersion bool
+			slice := strings.Split(articlePermissionPermissionName, ",")
+			for _, v := range slice {
+				if strings.Contains(companyPermission, v) {
+					hasPersion = true
+				}
+			}
+			if hasPersion {
+				detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
+				if err == nil {
+					hasPermission = 1
+					historyRecord := new(models.AddStopTimeNewRep)
+					historyRecord.StopTime = detailNew.StopTime + stopTime
+					historyRecord.Id = detailNew.Id
+					historyRecord.OutType = outType
+					go models.UpdateArticleStopTime(historyRecord)
+				}
+
+				//不统计本公司的阅读记录、正常退出的不做时间差统计
+				if user.CompanyId != 16 && stopTime > 3 {
+					key := "CYGX_ARTICLE_PV" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid) + "_" + strconv.Itoa(user.CompanyId) + "_" + strconv.Itoa(outType)
+					record := new(models.CygxArticleHistoryRecordNewpv)
+					record.UserId = uid
+					record.ArticleId = articleId
+					record.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
+					record.ModifyTime = time.Now()
+					record.Mobile = user.Mobile
+					record.Email = user.Email
+					record.CompanyId = user.CompanyId
+					record.CompanyName = companyInfo.CompanyName
+					record.StopTime = stopTime
+					record.OutType = outType
+					record.Source = source
+					if !utils.Rc.IsExist(key) || outType != 2 {
+						//新增浏览记录
+						go models.AddCygxArticleViewRecordNewpv(record)
+					} else {
+						go models.UpdateCygxArticleViewRecordNewpv(record, stopTime)
+					}
+					utils.Rc.Put(key, 1, 10*time.Minute)
+				}
+
+				models.ModifyReportLastViewTime(uid)
+			} else { //无该行业权限
+				hasPermission = 3
+			}
+		}
+	} else { //潜在客户
+		if applyCount > 0 {
+			hasPermission = 5
+		} else {
+			hasPermission = 4
+		}
+	}
+Loop:
+	resp := new(models.ArticleDetailAddStopTimeRep)
+	resp.HasPermission = hasPermission
+	resp.HasFree = hasFree
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+	br.Data = resp
+}

+ 30 - 43
controllers/chart_permission.go

@@ -199,46 +199,33 @@ func (this *ChartPermissionAuthController) StrategyDetail() {
 	br.Data = resp
 }
 
-//func init() {
-//
-//	list, err := models.GetCompanyReportPermissionAll()
-//	if err != nil {
-//		fmt.Println("获取品种信息失败,Err:" + err.Error())
-//		return
-//	}
-//	fmt.Println("len", len(list))
-//
-//	for _, v := range list {
-//		var newChartPermissionId int
-//		item := new(models.CompanyReportPermission)
-//		item.CompanyId = v.CompanyId
-//		item.ReportPermissionId = v.ReportPermissionId
-//		item.CreatedTime = time.Now()
-//		item.LastUpdatedTime = time.Now()
-//
-//		if v.ChartPermissionId == 19 {
-//			newChartPermissionId = 34
-//		} else if v.ChartPermissionId == 20 {
-//			newChartPermissionId = 35
-//		} else if v.ChartPermissionId == 21 {
-//			newChartPermissionId = 36
-//		} else if v.ChartPermissionId == 22 {
-//			newChartPermissionId = 37
-//		}
-//		item.ChartPermissionId = newChartPermissionId
-//		item.StartDate = v.StartDate
-//		item.EndDate = v.EndDate
-//		item.ProductId = v.ProductId
-//		item.ProductName = v.ProductName
-//		item.ModifyTime = v.ModifyTime
-//		item.CompanyContractId = v.CompanyContractId
-//		item.Status = v.Status
-//
-//		newId, err := models.AddChartPersion(item)
-//		if err != nil {
-//			fmt.Println("新增品种信息失败,Err:" + err.Error())
-//			//return
-//		}
-//		fmt.Println("新增", newId)
-//	}
-//}
+// @Title 获取所有品种(无需token)
+// @Description 获取所有品种(无需token)
+// @Success 200 {object} models.ChartPermissionResp
+// @router /allPublic [get]
+func (this *ChartPermissionController) DetailPublic() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	var condition string
+	list, err := models.GetChartPermissionAll(condition)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	resp := new(models.ChartPermissionResp)
+	for k, v := range list {
+		resp.List = append(resp.List, v)
+		if services.GetShowSustainable() && v.PermissionName == "研选" {
+			resp.List[k].IsShowSustainable = true
+		}
+	}
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 30 - 0
controllers/config.go

@@ -10,6 +10,10 @@ type ConfigController struct {
 	BaseAuthController
 }
 
+type BaseConfigController struct {
+	BaseCommonController
+}
+
 // @Title 获取搜索推荐词
 // @Description 获取搜索推荐词
 // @Success 200 {object} models.ConfigResp
@@ -122,3 +126,29 @@ func (this *ConfigController) DescriptionOfResearch() {
 	br.Success = true
 	br.Data = resp
 }
+
+// @Title 获取搜索推荐词(无需token)
+// @Description 获取搜索推荐词(无需token)
+// @Success 200 {object} models.ConfigResp
+// @router /detailPublic [get]
+func (this *BaseConfigController) HotDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	detail := new(models.CygxConfig)
+	hotSearch, err := models.GetHotSearch()
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	detail.ConfigValue = hotSearch
+	resp := new(models.ConfigResp)
+	resp.Item = detail
+	br.Msg = "获取成功!"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}

+ 170 - 0
controllers/home.go

@@ -13,6 +13,10 @@ type HomeController struct {
 	BaseAuthController
 }
 
+type BaseHomeController struct {
+	BaseCommonController
+}
+
 // @Title 首页列表接口
 // @Description 首页列表接口
 // @Param   PageSize   query   int  true       "每页数据条数"
@@ -163,3 +167,169 @@ func (this *HomeController) ListHome() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 首页列表接口(无需token)
+// @Description 首页列表接口(无需token)
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   ChartPermissionId   query   int  true       "品类id,最新传0"
+// @Param   UserName     query string  true       "用户名称"
+// @Param   Sign   query   string  true       "加密签名"
+// @Success 200 {object} models.HomeListResp
+// @router /listPublic [get]
+func (this *BaseHomeController) ListHomePublic() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	userName := this.GetString("UserName")
+	sign := this.GetString("Sign")
+	errMsg, errHt, wxUser, _ := services.CheckHtgj(userName, sign)
+	if errHt != nil {
+		br.Msg = "获取"
+		br.ErrMsg = "获取数据失败,Err:" + errHt.Error()
+		return
+	}
+	if errMsg != "" {
+		br.Msg = errMsg
+		return
+	}
+	user := wxUser
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	chartPermissionId, _ := this.GetInt("ChartPermissionId")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var pars []interface{}
+	var total int
+	resp := new(models.HomeListResp)
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp.HaveResearch = true
+	userType, _, err := services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
+		return
+	}
+	condition += ` AND is_summary = 1  `
+	if chartPermissionId > 0 {
+		categoryId, err := models.GetCategoryId(chartPermissionId)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取分类权限信息失败,Err:" + err.Error()
+			return
+		}
+		categoryinfo, err := models.GetChartPermissionById(chartPermissionId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		if userType == 1 && categoryinfo.PermissionName == "研选" {
+			resp.HaveResearch = false
+			resp.Paging = page
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+		page = paging.GetPaging(currentIndex, pageSize, total)
+		if categoryId != "" {
+			condition += ` AND category_id IN(` + categoryId + `)`
+			condition += ` OR ( category_name  LIKE '%` + categoryinfo.PermissionName + `%' AND publish_status = 1 AND is_summary = 1 )`
+		} else {
+			condition += ` AND  category_name   LIKE '%` + categoryinfo.PermissionName + `%'`
+		}
+	}
+	//永续客户无法查看研选分类的内容
+	if userType == 1 {
+		condition += ` AND  category_name  NOT LIKE '%研选` + `%'`
+	}
+	total, err = models.GetHomeCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.Msg = "获取帖子总数失败,Err:" + err.Error()
+		return
+	}
+	page = paging.GetPaging(currentIndex, pageSize, total)
+	list, err := models.GetHomeList(condition, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.Msg = "获取帖子数据失败,Err:" + err.Error()
+		return
+	}
+	//研选的五张图片
+	detailResearch, err := models.GetConfigByCode("category_research_img_url")
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据研选分类图片失败,Err:" + err.Error()
+		return
+	}
+	researchList := strings.Split(detailResearch.ConfigValue, "{|}")
+	//对应分类的所图片
+	detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
+		return
+	}
+	categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
+	mapCategoryUrl := make(map[string]string)
+	var categoryId string
+	var imgUrlChart string
+	for _, v := range categoryUrlList {
+		vslice := strings.Split(v, "_")
+		categoryId = vslice[0]
+		imgUrlChart = vslice[len(vslice)-1]
+		mapCategoryUrl[categoryId] = imgUrlChart
+	}
+
+	for k, v := range list {
+		item := list[k]
+		//如果文章一开始的内容是图片,优先展示第一张图片
+		imgurl, _ := services.FixArticleImgUrl(html.UnescapeString(list[k].Body))
+		newBody, _ := services.GetReportContentTextSub(item.Body)
+		list[k].Body = newBody
+		if imgurl != "" {
+			list[k].BodyHtml = imgurl
+		}
+		list[k].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDateTimeNoSecond) //时间字符串格式转时间格式
+		if strings.Contains(item.CategoryName, "研选") {
+			list[k].IsResearch = true
+		}
+		if item.Pv > 999 {
+			list[k].Pv = 999
+		}
+		//如果是研选系列的任意取五张图片的中的一张
+		if v.CategoryId == "0" {
+			knum := v.ArticleId % 5
+			list[k].ImgUrlPc = researchList[knum]
+		} else {
+			list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
+		}
+	}
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 135 - 0
controllers/search.go

@@ -13,6 +13,10 @@ type SearchController struct {
 	BaseAuthController
 }
 
+type BaseSearchController struct {
+	BaseCommonController
+}
+
 // @Title 搜索接口
 // @Description 搜索接口
 // @Param   PageSize   query   int  true       "每页数据条数"
@@ -217,3 +221,134 @@ func (this *SearchController) SearchReport() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 搜索接口(无需token)
+// @Description 搜索接口(无需token)
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   KeyWord   query   string  true       "搜索关键词"
+// @Param   OrderColumn   query   int  true       "排序字段 ,Comprehensive综合 ,Matching匹配度 ,PublishDate 发布时间 "
+// @Param   UserName     query string  true       "用户名称"
+// @Param   Sign   query   string  true       "加密签名"
+// @Success 200 {object} models.SearchItem
+// @router /listPublic [get]
+func (this *BaseSearchController) SearchListPublic() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	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)
+	keyWord := this.GetString("KeyWord")
+	orderColumn := this.GetString("OrderColumn")
+	if keyWord == "" {
+		br.Msg = "请输入搜索词"
+		br.ErrMsg = "请输入搜索词"
+		return
+	}
+	userName := this.GetString("UserName")
+	sign := this.GetString("Sign")
+	errMsg, errHt, wxUser, _ := services.CheckHtgj(userName, sign)
+	if errHt != nil {
+		br.Msg = "获取"
+		br.ErrMsg = "获取数据失败,Err:" + errHt.Error()
+		return
+	}
+	if errMsg != "" {
+		br.Msg = errMsg
+		return
+	}
+	user := wxUser
+	//研选的五张图片
+	detailResearch, errConfig := models.GetConfigByCode("category_research_img_url")
+	if errConfig != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据研选分类图片失败,Err:" + errConfig.Error()
+		return
+	}
+	researchList := strings.Split(detailResearch.ConfigValue, "{|}")
+	//对应分类的所图片
+	detailCategoryUrl, errConfig := models.GetConfigByCode("category_map_img_url")
+	if errConfig != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "行业配置信息失败,Err:" + errConfig.Error()
+		return
+	}
+	categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
+	mapCategoryUrl := make(map[string]string)
+	var categoryId string
+	var imgUrlChart string
+	for _, v := range categoryUrlList {
+		vslice := strings.Split(v, "_")
+		categoryId = vslice[0]
+		imgUrlChart = vslice[len(vslice)-1]
+		mapCategoryUrl[categoryId] = imgUrlChart
+	}
+	if orderColumn == "" {
+		orderColumn = "Matching"
+	}
+	indexName := utils.IndexName
+	pageSize = 20
+	var result []*models.SearchItem
+	var total int64
+	var err error
+	if orderColumn == "PublishDate" {
+		tmpResult, tmpTotal, tmpErr := services.EsMultiMatchFunctionScoreQueryTimeSort(indexName, keyWord, startSize, 100, user.UserId)
+		result = tmpResult
+		total = tmpTotal
+		err = tmpErr
+	} else {
+		tmpResult, tmpTotal, tmpErr := services.EsMultiMatchFunctionScoreQuerySort(indexName, keyWord, startSize, pageSize, user.UserId, orderColumn)
+		result = tmpResult
+		total = tmpTotal
+		err = tmpErr
+	}
+	if err != nil {
+		br.Msg = "检索失败"
+		br.ErrMsg = "检索失败,Err:" + err.Error()
+		return
+	}
+	if len(result) == 0 {
+		result = make([]*models.SearchItem, 0)
+	}
+	detail, errKey := models.GetNewSearchKeyWordByThisUser(user.UserId, keyWord)
+	if errKey != nil && errKey.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取信息失败,Err:" + errKey.Error()
+		return
+	}
+	//同一个用户一分钟之内搜索的词不重复记录
+	if detail == nil || time.Now().After(detail.CreateTime.Add(+time.Minute*1)) {
+		keyWordItem := new(models.CygxSearchKeyWord)
+		keyWordItem.UserId = user.UserId
+		keyWordItem.KeyWord = keyWord
+		keyWordItem.CreateTime = time.Now()
+		go models.AddSearchKeyWord(keyWordItem)
+	}
+	for k, v := range result {
+		//如果是研选系列的任意取五张图片的中的一张
+		if v.CategoryId == "0" {
+			knum := v.ArticleId % 5
+			result[k].ImgUrlPc = researchList[knum]
+		} else {
+			result[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
+		}
+	}
+	resp := new(models.SearchResp)
+	page := paging.GetPaging(currentIndex, pageSize, int(total))
+	resp.Paging = page
+	resp.List = result
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 5 - 0
models/article.go

@@ -219,6 +219,11 @@ type ArticleDetailResp struct {
 	Mobile        string `description:"用户手机号"`
 }
 
+type ArticleDetailHtgjResp struct {
+	HasPermission int `description:"1:有该行业权限,正常展示,0:试用期已过期"`
+	Detail        *ArticleDetail
+}
+
 func ModifyArticleExpert(articleId int, expertNumStr, expertContentStr, interviewDateStr, bodyText string) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE cygx_article SET expert_background=?,expert_number=?,interview_date=?,body_text=? WHERE article_id=? `

+ 9 - 1
models/article_history_record.go

@@ -71,6 +71,15 @@ type AddStopTimeRep struct {
 	Source    string `description:"来源,MOBILE:手机端,PC:电脑端"`
 }
 
+type AddStopTimeHtgjRep struct {
+	ArticleId int    `description:"文章ID"`
+	StopTime  int    `description:"停留时间"`
+	OutType   int    `description:"退出方式,1正常退出,2强制关闭"`
+	Source    string `description:"来源,MOBILE:手机端,PC:电脑端"`
+	UserName  string `description:"用户信息"`
+	Sign      string `description:"签名"`
+}
+
 type AddStopTimeNewRep struct {
 	Id        int `description:"ID"`
 	ArticleId int `description:"文章ID"`
@@ -101,7 +110,6 @@ func GetNewArticleHistoryRecord(uid, articleId int) (item *AddStopTimeNewRep, er
 //获取用户阅读记录
 func GetNoAddStoptimeArticleCount(uid, articleId int) (count int, err error) {
 	sqlCount := `SELECT COUNT(1) AS count FROM cygx_article_history_record WHERE user_id=? AND article_id=? AND create_time > '` + utils.OnlineTime + `' AND stop_time = 0 `
-	//sqlCount := `SELECT COUNT(1) AS count FROM cygx_article_history_record WHERE id = ? AND stop_time = 0 `
 	o := orm.NewOrm()
 	err = o.Raw(sqlCount, uid, articleId).QueryRow(&count)
 	return

+ 10 - 0
models/chart_permission.go

@@ -141,3 +141,13 @@ func AddChartPersion(item *CompanyReportPermission) (newId int64, err error) {
 	newId, err = o.Insert(item)
 	return
 }
+
+//获取海通国际开通的默认权限
+func GetCompanyPermissionIdWithHtgj() (chartpermissionids string, err error) {
+	sql := ` SELECT GROUP_CONCAT(DISTINCT chart_permission_id  ORDER BY b.sort ASC  SEPARATOR ',') AS chartpermissionids
+			FROM chart_permission as  b 
+			WHERE chart_permission_name IN ('医药','消费','科技','智造','研选')`
+	o := orm.NewOrm()
+	err = o.Raw(sql).QueryRow(&chartpermissionids)
+	return
+}

+ 10 - 2
models/company.go

@@ -160,14 +160,22 @@ func GetCompanySellerName(companyId int) (sellerName string, err error) {
 	return
 }
 
-type CompanyProduct struct {
+type CompanyProductStatus struct {
 	IsSuspend int `description:"1:暂停,0:启用"`
 }
 
 //获取对应销售以及销售的手机号
-func GetCompanyProductDetail(companyId, productId int) (item *CompanyProduct, err error) {
+func GetCompanyProductDetail(companyId, productId int) (item *CompanyProductStatus, err error) {
 	sql := ` SELECT * FROM company_product WHERE company_id = ? AND product_id = ?; `
 	o := orm.NewOrm()
 	err = o.Raw(sql, companyId, productId).QueryRow(&item)
 	return
 }
+
+//获取公司详情详情
+func GetCompanyByName(companyName string) (item *Company, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *  FROM company WHERE company_name = ? LIMIT 1`
+	err = o.Raw(sql, companyName).QueryRow(&item)
+	return
+}

+ 279 - 0
models/crm_company.go

@@ -0,0 +1,279 @@
+package models
+
+import (
+	"fmt"
+	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_cygx/utils"
+	"time"
+)
+
+type Company struct {
+	CompanyId       int       `orm:"column(company_id);pk"`
+	CompanyName     string    `description:"客户名称"`
+	CompanyType     int       `orm:"column(type)"`
+	CreditCode      string    `description:"社会统一信用码"`
+	CompanyCode     string    `description:"客户编码"`
+	Sort            int       `description:"优先级"`
+	IsFeeCustomer   int       `description:"是否付费用户"`
+	Country         string    `description:"国家编码"`
+	Province        string    `description:"省"`
+	City            string    `description:"市"`
+	Address         string    `description:"详细地址"`
+	Enabled         int       `description:"用户状态"`
+	CreatedTime     time.Time `description:"创建时间"`
+	LastUpdatedTime time.Time `description:"最后一次阅读时间"`
+	Seller          string    `description:"销售员"`
+	SellsId         int       `description:"销售员id"`
+	CompanyBelong   string    `description:"客户所属,ficc:ficc客户,public_offering:公募客户,partner:合作伙伴"`
+	StartDate       string    `description:"合同开始日期"`
+	EndDate         string    `description:"合同结束日期"`
+	LastType        int       `description:"原客户标签"`
+	IsVip           int       `description:"0:普通用户,1:大客户"`
+	FirstStartDate  string    `description:"首次设置为试用客户开始时间"`
+	FirstEndDate    string    `description:"首次设置为试用客户结束时间"`
+	DateType        int       `description:"设置流失类型,1:1个月,2:2个月,3:3个月"`
+	Remark          string    `description:"备注信息"`
+	RegionType      string    `description:"地区类型,国内,国外"`
+	OpenCompanyCode string    `description:"开放给第三方的客户编码,不让第三方定位我们的客户信息"`
+}
+
+type CompanyLog struct {
+	Id              int       `orm:"column(id);pk"`
+	CompanyId       int       `description:"客户id"`
+	CompanyName     string    `description:"客户名称"`
+	CreditCode      string    `description:"统一社会信用码"`
+	CompanyCode     string    `description:"客户编码"`
+	Sort            int       `description:"优先级"`
+	IsFeeCustomer   int       `description:"是否付费用户"`
+	Country         string    `description:"国家编码"`
+	ProvinceId      int       `description:"省id"`
+	CityId          int       `description:"市id"`
+	Address         string    `description:"详细地址"`
+	Ctype           int       `orm:"column(type)" description:"客户标签,1:付费客户,2:试用客户,3:流失客户,4:潜在客户" `
+	Enabled         int       `description:"用户状态"`
+	CreatedTime     time.Time `description:"创建时间"`
+	LastUpdatedTime time.Time `description:"最后修改时间"`
+	Seller          string    `description:"销售员"`
+	SellsId         int       `description:"销售员ID"`
+	CompanyBelong   string    `description:"客户所属,ficc:ficc客户,public_offering:公募客户,partner:合作伙伴"`
+	StartDate       string    `description:"合同开始日期"`
+	EndDate         string    `description:"合同结束日期"`
+	LoseReason      string    `description:"流失原因"`
+	LastType        int       `description:"原客户标签"`
+	FirstStartDate  string    `description:"首次设置为试用客户开始时间"`
+	FirstEndDate    string    `description:"首次设置为试用客户结束时间"`
+	DateType        int       `description:"日期类型"`
+	AdminId         int       `description:"操作人id"`
+	LogType         string    `description:"日志类型"`
+	LogCreateTime   time.Time `description:"日志创建时间"`
+	Province        string    `description:"省"`
+	City            string    `description:"市"`
+}
+
+type CompanyOperationRecord struct {
+	Id              int       `orm:"column(id);pk"`
+	CompanyId       int       `description:"客户id"`
+	CompanyName     string    `description:"客户名称"`
+	SellerId        int       `description:"销售员id"`
+	SysUserId       int       `description:"操作者id"`
+	SysRealName     string    `description:"操作者名称"`
+	Remark          string    `description:"备注"`
+	Operation       string    `description:"操作"`
+	CreateTime      time.Time `description:"操作时间"`
+	ProductId       int       `description:"产品id"`
+	ProductName     string    `description:"产品名称"`
+	ApproveUserId   int       `description:"审批人id"`
+	ApproveRealName string    `description:"审批人姓名"`
+	ApproveContent  string    `description:"审批人内容"`
+	ApproveRemark   string    `description:"审批人内容"`
+	Status          string    `description:"状态"`
+}
+
+type CompanyPermissionLog struct {
+	Id                int `orm:"column(id);pk"`
+	CompanyId         int
+	ChartPermissionId int
+	CreateTime        time.Time
+	SysUserId         int
+	SysUserName       string
+	StartDate         string
+	EndDate           string
+	ProductId         int
+	ProductName       string
+}
+
+type CompanyProduct struct {
+	CompanyProductId    int       `orm:"column(company_product_id);pk" description:"客户产品id"`
+	CompanyId           int       `description:"客户id"`
+	ProductId           int       `description:"产品id"`
+	ProductName         string    `description:"产品名称"`
+	CompanyName         string    `description:"客户名称"`
+	Source              string    `description:"来源"`
+	Reasons             string    `description:"新增理由"`
+	Status              string    `description:"客户状态"`
+	IndustryId          int       `description:"行业id"`
+	IndustryName        string    `description:"行业名称"`
+	SellerId            int       `description:"销售id"`
+	SellerName          string    `description:"销售名称"`
+	GroupId             int       `description:"销售分组id"`
+	DepartmentId        int       `description:"销售部门id"`
+	IsSuspend           int       `description:"1:暂停,0:启用"`
+	SuspendTime         time.Time `description:"暂停启用时间"`
+	TryOutTime          time.Time `description:"正式转试用时间"`
+	RenewalReason       string    `description:"正式转试用后的续约情况说明"`
+	LastDescriptionTime time.Time `description:"上次添加说明时间"`
+	RenewalIntention    int       `description:"是否勾选无续约意向,1:确认,0:未确认"`
+	ApproveStatus       string    `description:"审批状态:'审批中','通过','驳回'"`
+	FreezeTime          time.Time `description:"冻结时间"`
+	FreezeReason        time.Time `description:"冻结理由"`
+	Remark              string    `description:"备注信息"`
+	CreateTime          time.Time `description:"创建时间"`
+	ModifyTime          time.Time `description:"修改时间"`
+	StartDate           string    `description:"开始日期"`
+	EndDate             string    `description:"结束日期"`
+	ContractEndDate     time.Time `description:"合同结束日期"`
+	LoseReason          string    `description:"流失原因"`
+	LossTime            time.Time `description:"流失时间"`
+	CompanyType         string    `description:"客户类型"`
+	OpenCode            string    `description:"开放给第三方的编码,不让第三方定位我们的客户信息"`
+}
+
+type CompanyProductLog struct {
+	Id               int       `orm:"column(id);pk"`
+	CompanyProductId int       `description:"产品id"`
+	CompanyId        int       `description:"客户id"`
+	ProductId        int       `description:"产品id"`
+	ProductName      string    `description:"产品名称"`
+	CompanyName      string    `description:"客户名称"`
+	Source           string    `description:"来源"`
+	Reasons          string    `description:"新增理由"`
+	Status           string    `description:"客户状态"`
+	IndustryId       int       `description:"行业id"`
+	IndustryName     string    `description:"行业名称"`
+	SellerId         int       `description:"所属销售id"`
+	SellerName       string    `description:"所属销售名称"`
+	GroupId          int       `description:"所属销售分组id"`
+	DepartmentId     int       `description:"所属销售部门id"`
+	IsSuspend        int       `description:"1:暂停,0:启用"`
+	SuspendTime      time.Time `description:"暂停时间"`
+	FreezeTime       time.Time `description:"冻结时间"`
+	Remark           string    `description:"备注信息"`
+	StartDate        string    `description:"开始日期"`
+	EndDate          string    `description:"结束日期"`
+	CreateTime       time.Time `description:"创建时间"`
+	ModifyTime       time.Time `description:"修改时间"`
+	LoseReason       string    `description:"流失原因"`
+	LossTime         time.Time `description:"流失时间"`
+	LogType          string    `description:"日志类型"`
+	LogCreateTime    time.Time `description:"日志创建时间"`
+	AdminId          int       `description:"操作人id"`
+	ApproveStatus    string    `description:"审批状态:'审批中','通过','驳回'"`
+	FreezeStartDate  string    `description:"冻结开始日期"`
+	FreezeEndDate    string    `description:"冻结结束日期"`
+}
+
+//type CompanyReportPermission struct {
+//之前的结构体已存在
+//}
+
+type CompanySource struct {
+	SourceId   int    `orm:"column(source_id);pk"`
+	SourceName string `description:"来源名称"`
+}
+
+//判断公司名称是否存在
+func GetCompanyCountByName(companyName string) (count int, err error) {
+	sql := `SELECT  COUNT(1) AS count FROM company WHERE company_name = ?`
+	err = orm.NewOrm().Raw(sql, companyName).QueryRow(&count)
+	return
+}
+
+//获取来源详情
+func GetCompanySourceByName(companyName string) (item *CompanySource, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *  FROM company_source WHERE source_name = ?`
+	err = o.Raw(sql, companyName).QueryRow(&item)
+	return
+}
+
+func GetCompanyCode() (companyCode string, err error) {
+	var num int
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) AS num FROM company WHERE created_time >=? `
+	err = o.Raw(sql, time.Now().Format(utils.FormatDate)).QueryRow(&num)
+	if err != nil {
+		return
+	}
+	companyCode = "KH" + time.Now().Format("20060102") + fmt.Sprintf("%03d", num)
+	return
+}
+
+//新增客户
+func AddCompany(item *Company) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+//更新客户基础信息
+func (company *Company) Update(cols []string) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Update(company, cols...)
+	return
+}
+
+//新增客户产品
+func AddCompanyProduct(item *CompanyProduct) (newId int64, err error) {
+	o := orm.NewOrm()
+	newId, err = o.Insert(item)
+	return
+}
+
+//新增客户产品
+func AddCompanyProductLog(item *CompanyProductLog) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+func GetCompanyReportPermissionCount(companyId, productId int) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) AS count FROM company_report_permission WHERE company_id=? AND product_id=? `
+	err = o.Raw(sql, companyId, productId).QueryRow(&count)
+	return
+}
+
+func DeleteCompanyReportPermission(companyId, productId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` DELETE FROM company_report_permission WHERE company_id=? AND product_id=? `
+	_, err = o.Raw(sql, companyId, productId).Exec()
+	return
+}
+
+//新增客户权限
+func AddCompanyReportPermission(item *CompanyReportPermission) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+//新增客户权限日志
+func AddCompanyPermissionLog(item *CompanyPermissionLog) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+//新增客户操作记录
+func AddCompanyOperationRecord(item *CompanyOperationRecord) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+//新增客户产品
+func AddCompanyLog(item *CompanyLog) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}

+ 6 - 0
models/db.go

@@ -86,5 +86,11 @@ func init() {
 		new(CygxActivityMeetDetailLog),
 		new(CygxUserSearchKeyWord),
 		new(CompanyReportPermission),
+		new(Company),
+		new(CompanyLog),
+		new(CompanyOperationRecord),
+		new(CompanyPermissionLog),
+		new(CompanyProduct),
+		new(CompanyProductLog),
 	)
 }

+ 1 - 1
models/seller.go

@@ -42,7 +42,7 @@ func GetSellerByCompanyIdCheckFicc(companyId, productId int) (item *AdminItem, e
 
 func GetSellerByName(userName string) (item *AdminItem, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT * FROM admin WHERE admin_name=? `
+	sql := ` SELECT * FROM admin WHERE real_name=? `
 	err = o.Raw(sql, userName).QueryRow(&item)
 	return
 }

+ 22 - 0
models/wx_user.go

@@ -250,3 +250,25 @@ func UPdateUserCountryCode(item *WxUserItem) (err error) {
 
 	return
 }
+
+//判断公司下用户名称是否存在
+func GetUserCountByName(companyId int, name string) (count int, err error) {
+	sql := `SELECT  COUNT(1) AS count FROM wx_user WHERE company_id = ? AND real_name = ?`
+	err = orm.NewOrm().Raw(sql, companyId, name).QueryRow(&count)
+	return
+}
+
+func UpdateUserMobile(uid int, mobile string) (err error) {
+	sql := ` UPDATE wx_user SET mobile=?
+			WHERE user_id=? `
+	_, err = orm.NewOrm().Raw(sql, mobile, uid).Exec()
+	return
+}
+
+//获取公司下用户详情详情详情
+func GetUserByName(companyId int, name string) (item *WxUser, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *  FROM wx_user WHERE company_id = ? AND real_name = ? `
+	err = o.Raw(sql, companyId, name).QueryRow(&item)
+	return
+}

+ 54 - 0
routers/commentsRouter_controllers.go

@@ -169,6 +169,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ArticleCommonController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ArticleCommonController"],
+        beego.ControllerComments{
+            Method: "AddStopTimePublic",
+            Router: "/addStopTimePublic",
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ArticleCommonController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ArticleCommonController"],
+        beego.ControllerComments{
+            Method: "DetailPublic",
+            Router: "/detailPublic",
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ArticleCommonController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ArticleCommonController"],
         beego.ControllerComments{
             Method: "Detail",
@@ -232,6 +250,33 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BaseConfigController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BaseConfigController"],
+        beego.ControllerComments{
+            Method: "HotDetail",
+            Router: "/detailPublic",
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BaseHomeController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BaseHomeController"],
+        beego.ControllerComments{
+            Method: "ListHomePublic",
+            Router: "/listPublic",
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BaseSearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:BaseSearchController"],
+        beego.ControllerComments{
+            Method: "SearchListPublic",
+            Router: "/listPublic",
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ChartPermissionAuthController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ChartPermissionAuthController"],
         beego.ControllerComments{
             Method: "Detail",
@@ -259,6 +304,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ChartPermissionController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ChartPermissionController"],
+        beego.ControllerComments{
+            Method: "DetailPublic",
+            Router: "/allPublic",
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ConfigController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ConfigController"],
         beego.ControllerComments{
             Method: "DescriptionOfResearch",

+ 9 - 0
routers/router.go

@@ -27,6 +27,9 @@ func init() {
 			web.NSInclude(
 				&controllers.HomeController{},
 			),
+			web.NSInclude(
+				&controllers.BaseHomeController{},
+			),
 		),
 		web.NSNamespace("/wechat",
 			web.NSInclude(
@@ -55,11 +58,17 @@ func init() {
 			web.NSInclude(
 				&controllers.ConfigController{},
 			),
+			web.NSInclude(
+				&controllers.BaseConfigController{},
+			),
 		),
 		web.NSNamespace("/search",
 			web.NSInclude(
 				&controllers.SearchController{},
 			),
+			web.NSInclude(
+				&controllers.BaseSearchController{},
+			),
 		),
 		web.NSNamespace("/resource",
 			web.NSInclude(

+ 0 - 4
services/elastic.go

@@ -707,9 +707,6 @@ func EsMultiMatchFunctionScoreQuerySort(indexName, keyWord string, startSize, pa
 		keyWordArr = append(keyWordArr, keyWord)
 		keyWordLen = len(keyWordArr)
 	}
-	for _, v := range keyWordArr {
-		fmt.Println(v)
-	}
 
 	// @Param   OrderColumn   query   int  true       "排序字段 ,Comprehensive综合 ,Matching匹配度 ,PublishDate 发布时间 "
 	utils.FileLog.Info("SearchKeyWord:%s, userId:%s", keyWordArr, strconv.Itoa(userId))
@@ -823,7 +820,6 @@ func EsMultiMatchFunctionScoreQueryTimeSort(indexName, keyWord string, startSize
 		keyWordArr = append(keyWordArr, keyWord)
 		keyWordLen = len(keyWordArr)
 	}
-	fmt.Println(keyWordArr)
 	utils.FileLog.Info("SearchKeyWord:%s, userId:%s", keyWordArr, strconv.Itoa(userId))
 	for _, v := range keyWordArr {
 		if v != "" {

+ 295 - 0
services/htgj.go

@@ -0,0 +1,295 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"strings"
+	"time"
+)
+
+func CheckHtgj(userName, sign string) (errMsg string, errHt error, user *models.WxUser, companyName string) {
+	if sign == "" {
+		errMsg = "签名方式错误"
+		return
+	}
+	var wxuUserName string
+	var startDate, endDate string
+	var companyId int64
+
+	wxUser := new(models.WxUser)
+	productId := 2
+	productName := "权益"
+	itemCompany := new(models.Company)
+	userNameList := strings.Split(userName, "-")
+	if len(userNameList) != 2 {
+		errMsg = "用户信息格式错误" + userName
+		return
+	}
+	sellerInfo, err := models.GetSellerByName(utils.HtgjDefaultSaleName)
+	if err != nil {
+		errHt = err
+		return
+	}
+	companyName = userNameList[0]
+	wxuUserName = userNameList[1]
+	countCompay, err := models.GetCompanyCountByName(companyName)
+	if err != nil {
+		errHt = err
+		return
+	}
+	if countCompay == 0 {
+		defaultPermissionIds, err := models.GetCompanyPermissionIdWithHtgj()
+		if err != nil {
+			errHt = err
+			return
+		}
+		companySourceInfo, err := models.GetCompanySourceByName(utils.HtgjName)
+		if err != nil {
+			errHt = err
+			return
+		}
+
+		companyCode, err := models.GetCompanyCode()
+		if err != nil {
+			errHt = err
+			return
+		}
+		startDate = time.Now().Format(utils.FormatDate)
+		endDate = time.Now().AddDate(0, 2, 0).Format(utils.FormatDate)
+		itemCompany.CompanyName = companyName
+		itemCompany.CreditCode = ""
+		itemCompany.CompanyCode = companyCode
+
+		itemCompany.StartDate = startDate
+		itemCompany.EndDate = endDate
+		itemCompany.CreatedTime = time.Now()
+		itemCompany.LastUpdatedTime = time.Now()
+		itemCompany.Enabled = 1
+		itemCompany.CompanyType = 2
+		itemCompany.RegionType = "海外"
+		companyId, err = models.AddCompany(itemCompany)
+		if err != nil {
+			errHt = err
+			return
+		}
+		itemCompany.OpenCompanyCode = GenerateOpenCompanyCode(int(companyId))
+		itemCompany.Update([]string{"OpenCompanyCode"})
+
+		companyProduct := new(models.CompanyProduct)
+		companyProduct.CompanyId = int(companyId)
+		companyProduct.ProductId = productId
+		companyProduct.ProductName = productName
+		companyProduct.CompanyName = companyName
+		companyProduct.Source = companySourceInfo.SourceName
+		companyProduct.Reasons = ""
+		companyProduct.Status = "试用"
+		companyProduct.StartDate = startDate
+		companyProduct.EndDate = endDate
+		companyProduct.IndustryId = 11
+		companyProduct.IndustryName = "其他类型"
+		companyProduct.SellerId = sellerInfo.AdminId
+		companyProduct.SellerName = sellerInfo.RealName
+		companyProduct.GroupId = sellerInfo.GroupId
+		companyProduct.DepartmentId = sellerInfo.DepartmentId
+		companyProduct.IsSuspend = 0
+		companyProduct.CreateTime = time.Now()
+		companyProduct.ModifyTime = time.Now()
+		companyProduct.CompanyType = "权益"
+		companyProduct.OpenCode = GenerateOpenCompanyProductCode(int(companyId), 2)
+		companyProductId, err := models.AddCompanyProduct(companyProduct)
+		if err != nil {
+			errHt = err
+			return
+		}
+		err = AddCompanyPermission(int(companyId), sellerInfo.AdminId, productId, productName, sellerInfo.RealName, defaultPermissionIds, startDate, endDate)
+		if err != nil {
+			errHt = err
+			return
+		}
+
+		{
+			record := new(models.CompanyOperationRecord)
+			record.CompanyId = int(companyId)
+			record.CompanyName = companyName
+			record.SellerId = sellerInfo.AdminId
+			record.SysUserId = sellerInfo.AdminId
+			record.SysRealName = sellerInfo.RealName
+			record.Remark = "新增客户"
+			record.Operation = "add"
+			record.CreateTime = time.Now()
+			record.ProductId = productId
+			record.ProductName = productName
+			record.Status = "试用"
+			_, err = models.AddCompanyOperationRecord(record)
+			if err != nil {
+				errHt = err
+				go utils.SendEmail(utils.APPNAME+"失败提醒"+utils.RunMode, "海通国际添加客户失败"+err.Error(), utils.EmailSendToUsers)
+			}
+		}
+		//新增客户日志
+		{
+			companyLog := new(models.CompanyLog)
+			companyLog.CompanyId = int(companyId)
+			companyLog.CompanyName = companyName
+			companyLog.CreditCode = ""
+			companyLog.CompanyCode = companyCode
+			companyLog.Sort = itemCompany.Sort
+			companyLog.IsFeeCustomer = itemCompany.IsFeeCustomer
+			companyLog.Country = itemCompany.Country
+			companyLog.Address = itemCompany.Address
+			companyLog.City = itemCompany.City
+			companyLog.Province = itemCompany.Province
+			companyLog.Enabled = itemCompany.Enabled
+			companyLog.CreatedTime = itemCompany.CreatedTime
+			companyLog.LastUpdatedTime = itemCompany.LastUpdatedTime
+			companyLog.Seller = itemCompany.Seller
+			companyLog.SellsId = itemCompany.SellsId
+			companyLog.CompanyBelong = itemCompany.CompanyBelong
+			companyLog.StartDate = itemCompany.StartDate
+			companyLog.EndDate = itemCompany.EndDate
+			companyLog.FirstStartDate = itemCompany.FirstStartDate
+			companyLog.FirstEndDate = itemCompany.FirstEndDate
+			companyLog.DateType = itemCompany.DateType
+			companyLog.AdminId = sellerInfo.AdminId
+			companyLog.LogType = "add"
+			companyLog.LogCreateTime = time.Now()
+			go models.AddCompanyLog(companyLog)
+		}
+
+		//新增客户产品日志
+		{
+			productLog := new(models.CompanyProductLog)
+			productLog.CompanyProductId = int(companyProductId)
+			productLog.CompanyId = companyProduct.CompanyId
+			productLog.ProductId = companyProduct.ProductId
+			productLog.ProductName = companyProduct.ProductName
+			productLog.CompanyName = companyProduct.CompanyName
+			productLog.CompanyName = companyProduct.CompanyName
+			productLog.Source = companyProduct.Source
+			productLog.Reasons = companyProduct.Reasons
+			productLog.Status = companyProduct.Status
+			productLog.IndustryId = companyProduct.IndustryId
+			productLog.IndustryName = companyProduct.IndustryName
+			productLog.SellerId = companyProduct.SellerId
+			productLog.SellerName = companyProduct.SellerName
+			productLog.GroupId = companyProduct.GroupId
+			productLog.DepartmentId = companyProduct.DepartmentId
+			productLog.IsSuspend = companyProduct.IsSuspend
+			productLog.SuspendTime = companyProduct.SuspendTime
+			productLog.ApproveStatus = companyProduct.ApproveStatus
+			productLog.FreezeTime = companyProduct.FreezeTime
+			productLog.Remark = companyProduct.Remark
+			productLog.StartDate = companyProduct.StartDate
+			productLog.EndDate = companyProduct.EndDate
+			productLog.CreateTime = companyProduct.CreateTime
+			productLog.ModifyTime = companyProduct.ModifyTime
+			productLog.LoseReason = companyProduct.LoseReason
+			productLog.LossTime = companyProduct.LossTime
+			productLog.LogType = "add"
+			productLog.LogCreateTime = time.Now()
+			productLog.AdminId = sellerInfo.AdminId
+			go models.AddCompanyProductLog(productLog)
+		}
+
+	} else {
+		companyInfo, err := models.GetCompanyByName(companyName)
+		if err != nil {
+			errHt = err
+			return
+		}
+		companyId = int64(companyInfo.CompanyId)
+	}
+	countUser, err := models.GetUserCountByName(int(companyId), wxuUserName)
+	if countUser == 0 {
+		wxUser.CompanyId = int(companyId)
+		wxUser.RealName = wxuUserName
+		wxUser.CreatedTime = time.Now()
+		newUserId, err := models.AddWxUser(wxUser)
+		if err != nil {
+			errHt = err
+			return
+		}
+		md5Mobile := utils.Get16MD5Encode(strconv.Itoa(int(newUserId)))
+		wxUser.Mobile = md5Mobile
+		wxUser.UserId = int(newUserId)
+		err = models.UpdateUserMobile(int(newUserId), md5Mobile)
+		if err != nil {
+			errHt = err
+			return
+		}
+	} else {
+		wxUser, err = models.GetUserByName(int(companyId), wxuUserName)
+		if err != nil {
+			errHt = err
+			return
+		}
+	}
+	user = wxUser
+	return
+}
+
+// GenerateOpenCompanyCode 生成第三方code编号
+func GenerateOpenCompanyCode(companyId int) (openCode string) {
+	openCode = utils.MD5(fmt.Sprint(companyId, "hzyj20210902"))
+	return
+}
+
+// GenerateOpenCompanyProductCode 生成客户产品第三方code编号
+func GenerateOpenCompanyProductCode(companyId, productId int) (openCode string) {
+	openCode = utils.MD5(fmt.Sprint(companyId, "_", productId, "hzyj20210902"))
+	return
+}
+
+//新增客户权限
+func AddCompanyPermission(companyId, sysUserId, productId int, productName, sysUserName, permissionStr, startDate, endDate string) (err error) {
+	if permissionStr == "" {
+		return
+	}
+	permissionArr := strings.Split(permissionStr, ",")
+	count, _ := models.GetCompanyReportPermissionCount(companyId, productId)
+
+	//删除权限
+	if count > 0 {
+		err = models.DeleteCompanyReportPermission(companyId, productId)
+		if err != nil {
+			return
+		}
+	}
+	for _, pv := range permissionArr {
+		permissionId, err := strconv.Atoi(pv)
+		if err != nil {
+			return err
+		}
+		permission := new(models.CompanyReportPermission)
+		permission.CompanyId = companyId
+		permission.ReportPermissionId = permissionId
+		permission.CreatedTime = time.Now()
+		permission.LastUpdatedTime = time.Now()
+		permission.ChartPermissionId = permissionId
+		permission.StartDate = startDate
+		permission.EndDate = endDate
+		permission.ProductId = productId
+		permission.ProductName = productName
+		permission.ModifyTime = time.Now().Format(utils.FormatDateTime)
+		permission.Status = "试用"
+		err = models.AddCompanyReportPermission(permission)
+		if err != nil {
+			return err
+		}
+
+		cpLog := new(models.CompanyPermissionLog)
+		cpLog.CompanyId = companyId
+		cpLog.ChartPermissionId = permissionId
+		cpLog.CreateTime = time.Now()
+		cpLog.SysUserId = sysUserId
+		cpLog.SysUserName = sysUserName
+		cpLog.StartDate = startDate
+		cpLog.EndDate = endDate
+		cpLog.ProductId = productId
+		cpLog.ProductName = productName
+		go models.AddCompanyPermissionLog(cpLog)
+	}
+	return
+}

+ 1 - 1
services/user.go

@@ -222,7 +222,7 @@ func BindWxUser(openid, mobile, email, countryCode string) (wxUser *models.WxUse
 			OutboundCountryCode: countryCode,
 		}
 		tmpUserId, addUserErr := models.AddWxUser(user)
-		if err != nil {
+		if addUserErr != nil {
 			err = addUserErr
 			return
 		}

+ 7 - 0
utils/common.go

@@ -68,6 +68,13 @@ func MD5(data string) string {
 	return hex.EncodeToString(m[:])
 }
 
+//md5加密
+func Get16MD5Encode(data string) string {
+	m := md5.Sum([]byte(data))
+	encodehex := hex.EncodeToString(m[:])
+	return encodehex[8:24]
+}
+
 // 获取数字随机字符
 func GetRandDigit(n int) string {
 	return fmt.Sprintf("%0"+strconv.Itoa(n)+"d", rnd.Intn(int(math.Pow10(n))))

+ 6 - 0
utils/config.go

@@ -63,6 +63,9 @@ var (
 	EmailExpert               string //研选行业专家邮箱
 	EmaiWhiteUserList         string //白名单邮箱
 	IsTask                    bool   //是否执行定时任务
+	HtgjDefaultSaleName       string //海通默认销售名称
+	HtgjSalt                  string //海通加密使用的盐
+	HtgjName                  string //海通国际名称
 )
 
 func init() {
@@ -108,6 +111,9 @@ func init() {
 	YanxSummaryPermissionId = 1001     //研选纪要分类ID
 	YanxViewpointPermissionId = 1002   //研选观点分类ID
 	WxMsgTemplateIdAskMsgMobileAll = "15557270714,18767183922,18621268829"
+	HtgjDefaultSaleName = "王芳"
+	HtgjSalt = "HTGJ&HZ"
+	HtgjName = "海通国际"
 	if RunMode == "release" {
 		WxAppId = "wxcc32b61f96720d2f"
 		WxAppSecret = "06894933fafb24dafead7eaae09c08e0"