company.go 3.7 KB

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