company.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package roadshow
  2. import (
  3. "hongze/hongze_mobile_admin/models/roadshow"
  4. "hongze/hongze_mobile_admin/models/tables/english_company"
  5. "hongze/hongze_mobile_admin/services"
  6. "hongze/hongze_mobile_admin/utils"
  7. "strings"
  8. )
  9. // @Title 我的日历列表
  10. // @Description 我的日历列表接口
  11. // @Param KeyWord query string true "搜索关键词"
  12. // @Success 200 {object} rs.CalendarListResp
  13. // @router /company/search [get]
  14. func (this *CalendarController) CompanySearch() {
  15. sysUser := this.AdminWx
  16. if sysUser == nil {
  17. this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
  18. return
  19. }
  20. KeyWord := this.GetString("KeyWord")
  21. if KeyWord == "" {
  22. this.FailWithMessage("请输入搜索词!", "请输入搜索词!")
  23. return
  24. }
  25. KeyWord = "%" + KeyWord + "%"
  26. var groupId int
  27. if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
  28. groupId = sysUser.GroupId
  29. } else {
  30. groupId = -1
  31. }
  32. list, err := roadshow.CompanySearchV2(sysUser.AdminId, groupId, KeyWord, sysUser.RoleTypeCode)
  33. if err != nil && err.Error() != utils.ErrNoRow() {
  34. this.FailWithMessage("搜索客户失败!", "搜索客户失败!Err:"+err.Error())
  35. return
  36. }
  37. if list == nil {
  38. list = make([]*roadshow.CompanySearchView, 0)
  39. }
  40. this.OkDetailed(list, "获取成功")
  41. }
  42. // CompanyDetail
  43. // @Title 我的日历列表
  44. // @Description 我的日历列表接口
  45. // @Param CompanyId query int true "公司id"
  46. // @Param EnglishCompany query int true "是否为英文客户"
  47. // @Success 200 {object} rs.CompanyDetailView
  48. // @router /company/detail [get]
  49. func (this *CalendarController) CompanyDetail() {
  50. sysUser := this.AdminWx
  51. if sysUser == nil {
  52. this.FailWithMessage("请登录", "请登录,SysUser Is Empty")
  53. return
  54. }
  55. companyId, _ := this.GetInt("CompanyId")
  56. if companyId <= 0 {
  57. this.FailWithMessage("参数错误!", "参数错误!")
  58. return
  59. }
  60. englishCompany, _ := this.GetInt("EnglishCompany")
  61. productId := services.GetProductId(sysUser.RoleTypeCode)
  62. if productId == 0 {
  63. productId = 1
  64. }
  65. detailView := new(roadshow.CompanyDetailView)
  66. if englishCompany == 0 {
  67. companyProductItem, err := roadshow.GetCompanyProductByCompanyIdAndProductId(companyId, productId)
  68. if err != nil {
  69. this.FailWithMessage("搜索客户失败!", "搜索客户失败!Err:"+err.Error())
  70. return
  71. }
  72. permissionList, err := roadshow.GetCompanyProductReportPermissionList(companyId, productId)
  73. if err != nil {
  74. this.FailWithMessage("搜索客户权限失败!", "搜索客户权限失败!Err:"+err.Error())
  75. return
  76. }
  77. var permissionArr []string
  78. for _, v := range permissionList {
  79. permissionArr = append(permissionArr, v.PermissionName)
  80. }
  81. //readMap, err := services.GetFiccCountUserViewHistoryByCompanyIds(strconv.Itoa(companyId))
  82. //if err != nil {
  83. // this.FailWithMessage("获取阅读次数失败!", "获取阅读次数失败!Err:"+err.Error())
  84. // return
  85. //}
  86. //readNum, ok := readMap[companyId]
  87. //if !ok {
  88. // readNum = 0
  89. //}
  90. detailView.CompanyId = companyProductItem.CompanyId
  91. detailView.CompanyName = companyProductItem.CompanyName
  92. detailView.Status = companyProductItem.Status
  93. detailView.IndustryId = companyProductItem.IndustryId
  94. detailView.IndustryName = companyProductItem.IndustryName
  95. detailView.PermissionName = strings.Join(permissionArr, "/")
  96. detailView.ReportReadTotal = companyProductItem.ViewTotal //ficc报告-累计阅读次数
  97. this.OkDetailed(detailView, "获取成功")
  98. return
  99. }
  100. // 英文客户
  101. enItem, e := english_company.GetEnglishCompanyById(companyId)
  102. if e != nil {
  103. this.FailWithMessage("搜索客户失败!", "获取英文客户详情失败, Err: "+e.Error())
  104. return
  105. }
  106. detailView.CompanyId = enItem.CompanyId
  107. detailView.CompanyName = enItem.CompanyName
  108. detailView.Status = "正常"
  109. detailView.EnglishCompany = 1
  110. detailView.EnglishCountry = enItem.Country
  111. detailView.EnglishViewTotal = enItem.ViewTotal
  112. this.OkDetailed(detailView, "获取成功")
  113. }