123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- package roadshow
- import (
- "hongze/hz_crm_api/models"
- "hongze/hz_crm_api/models/company"
- "hongze/hz_crm_api/models/roadshow"
- "hongze/hz_crm_api/services"
- "hongze/hz_crm_api/utils"
- "strings"
- )
- // @Title 我的日历列表
- // @Description 我的日历列表接口
- // @Param KeyWord query string true "搜索关键词"
- // @Success 200 {object} roadshow.CalendarListResp
- // @router /company/search [get]
- func (this *CalendarController) CompanySearch() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- KeyWord := this.GetString("KeyWord")
- if KeyWord == "" {
- br.Msg = "请输入搜索词!"
- return
- }
- KeyWord = "%" + KeyWord + "%"
- var groupId int
- if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
- groupId = sysUser.GroupId
- } else {
- groupId = -1
- }
- list, err := roadshow.CompanySearchV2(sysUser.AdminId, groupId, KeyWord, sysUser.RoleTypeCode)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "搜索客户失败!"
- br.ErrMsg = "搜索客户失败!Err:" + err.Error()
- return
- }
- if list == nil {
- list = make([]*roadshow.CompanySearchView, 0)
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = list
- }
- // CompanyDetail
- // @Title 我的日历列表
- // @Description 我的日历列表接口
- // @Param CompanyId query int true "公司id"
- // @Param EnglishCompany query int true "是否为英文客户"
- // @Success 200 {object} roadshow.CompanyDetailView
- // @router /company/detail [get]
- func (this *CalendarController) CompanyDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- if br.ErrMsg == "" {
- br.IsSendEmail = false
- }
- this.Data["json"] = br
- this.ServeJSON()
- }()
- sysUser := this.SysUser
- if sysUser == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,SysUser Is Empty"
- br.Ret = 408
- return
- }
- companyId, _ := this.GetInt("CompanyId")
- if companyId <= 0 {
- br.Msg = "参数错误!"
- return
- }
- englishCompany, _ := this.GetInt("EnglishCompany")
- productId := services.GetProductId(sysUser.RoleTypeCode)
- if productId == 0 {
- productId = 1
- }
- detailView := new(roadshow.CompanyDetailView)
- if englishCompany == 0 {
- companyProductItem, err := company.GetCompanyProductByCompanyIdAndProductId(companyId, productId)
- if err != nil {
- if err.Error() == utils.ErrNoRow() {
- br.Msg = "该客户已被删除"
- return
- }
- br.Msg = "搜索客户失败!"
- br.ErrMsg = "搜索客户失败!Err:" + err.Error()
- return
- }
- permissionList, err := company.GetCompanyProductReportPermissionList(companyId, productId)
- if err != nil {
- br.Msg = "搜索客户权限失败!"
- br.ErrMsg = "搜索客户权限失败!Err:" + err.Error()
- return
- }
- var permissionArr []string
- for _, v := range permissionList {
- permissionArr = append(permissionArr, v.PermissionName)
- }
- detailView.CompanyId = companyProductItem.CompanyId
- detailView.CompanyName = companyProductItem.CompanyName
- detailView.Status = companyProductItem.Status
- detailView.IndustryId = companyProductItem.IndustryId
- detailView.IndustryName = companyProductItem.IndustryName
- detailView.PermissionName = strings.Join(permissionArr, "/")
- detailView.ReportReadTotal = companyProductItem.ViewTotal //ficc报告-累计阅读次数
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = detailView
- return
- }
- // 英文客户
- enItem, e := models.GetEnglishCompanyById(companyId)
- if e != nil {
- br.Msg = "搜索英文客户失败!"
- br.ErrMsg = "获取英文客户详情失败!Err:" + e.Error()
- return
- }
- detailView.CompanyId = enItem.CompanyId
- detailView.CompanyName = enItem.CompanyName
- detailView.Status = "正常"
- detailView.EnglishCompany = 1
- detailView.EnglishCountry = enItem.Country
- detailView.EnglishViewTotal = enItem.ViewTotal
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = detailView
- }
|