interview_apply.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. package cygx
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hz_crm_api/controllers"
  6. "hongze/hz_crm_api/models"
  7. "hongze/hz_crm_api/models/cygx"
  8. "hongze/hz_crm_api/utils"
  9. "strings"
  10. )
  11. // 访谈申请
  12. type InterviewApplyController struct {
  13. controllers.BaseAuthController
  14. }
  15. // @Title 访谈申请列表
  16. // @Description 访谈申请列表接口
  17. // @Param PageSize query int true "每页数据条数"
  18. // @Param CurrentIndex query int true "当前页页码,从1开始"
  19. // @Param KeyWord query string true "搜索关键词"
  20. // @Success 200 {object} cygx.InterviewApplyListResp
  21. // @router /interview/list [get]
  22. func (this *InterviewApplyController) List() {
  23. br := new(models.BaseResponse).Init()
  24. defer func() {
  25. this.Data["json"] = br
  26. this.ServeJSON()
  27. }()
  28. sysUser := this.SysUser
  29. if sysUser == nil {
  30. br.Msg = "请登录"
  31. br.ErrMsg = "请登录,SysUser Is Empty"
  32. br.Ret = 408
  33. return
  34. }
  35. pageSize, _ := this.GetInt("PageSize")
  36. currentIndex, _ := this.GetInt("CurrentIndex")
  37. keyWord := this.GetString("KeyWord")
  38. keyWord = strings.Trim(keyWord, " ")
  39. keyWord = strings.Replace(keyWord, "'", "", -1)
  40. roleTypeCode := sysUser.RoleTypeCode
  41. var condition string
  42. var pars []interface{}
  43. {
  44. if roleTypeCode != utils.ROLE_TYPE_CODE_ADMIN {
  45. if roleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
  46. condition += ` AND c.product_id=? `
  47. pars = append(pars, 1)
  48. } else if roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN {
  49. condition += ` AND c.product_id=? `
  50. pars = append(pars, 2)
  51. } else {
  52. if sysUser.Authority <= 0 {
  53. condition += ` AND c.seller_id=? `
  54. pars = append(pars, sysUser.AdminId)
  55. } else {
  56. if sysUser.Authority == 1 {
  57. condition += ` AND c.department_id=? `
  58. pars = append(pars, sysUser.DepartmentId)
  59. }
  60. if sysUser.Authority == 2 {
  61. condition += ` AND c.group_id=? `
  62. pars = append(pars, sysUser.GroupId)
  63. }
  64. }
  65. }
  66. }
  67. }
  68. var startSize int
  69. if pageSize <= 0 {
  70. pageSize = utils.PageSize20
  71. }
  72. if currentIndex <= 0 {
  73. currentIndex = 1
  74. }
  75. startSize = paging.StartIndex(currentIndex, pageSize)
  76. if keyWord != "" {
  77. condition += ` AND (b.mobile LIKE '%` + keyWord + `%' OR b.email LIKE '%` + keyWord + `%' OR b.real_name LIKE '%` + keyWord + `%') `
  78. }
  79. total, err := cygx.GetInterviewApplyListCount(condition, pars)
  80. if err != nil {
  81. br.Msg = "获取失败"
  82. br.ErrMsg = "获取数据总数失败,Err:" + err.Error()
  83. return
  84. }
  85. list, err := cygx.GetInterviewApplyList(condition, pars, startSize, pageSize)
  86. if err != nil {
  87. br.Msg = "获取失败"
  88. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  89. return
  90. }
  91. if list == nil {
  92. list = make([]*cygx.CygxInterviewApply, 0)
  93. }
  94. resp := new(cygx.InterviewApplyListResp)
  95. page := paging.GetPaging(currentIndex, pageSize, total)
  96. resp.List = list
  97. resp.Paging = page
  98. br.Ret = 200
  99. br.Success = true
  100. br.Msg = "获取成功"
  101. br.Data = resp
  102. }
  103. // @Title 访谈申请状态变更接口
  104. // @Description 访谈申请状态变更接口(包含取消和状态更新)
  105. // @Param request body cygx.InterviewApplyStatusReq true "type json string"
  106. // @Success Ret=200 访谈申请取消成功
  107. // @router /interview/status/modify [post]
  108. func (this *InterviewApplyController) InterviewApplyCancel() {
  109. br := new(models.BaseResponse).Init()
  110. defer func() {
  111. this.Data["json"] = br
  112. this.ServeJSON()
  113. }()
  114. sysUser := this.SysUser
  115. if sysUser == nil {
  116. br.Msg = "请登录"
  117. br.ErrMsg = "请登录,SysUser Is Empty"
  118. br.Ret = 408
  119. return
  120. }
  121. var req cygx.InterviewApplyStatusReq
  122. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  123. if err != nil {
  124. br.Msg = "参数解析异常!"
  125. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  126. return
  127. }
  128. if req.InterviewApplyId <= 0 {
  129. br.Msg = "参数错误"
  130. br.ErrMsg = "参数错误,访谈申请id小于等于0"
  131. return
  132. }
  133. item, err := cygx.GetCygxInterviewApplyDetail(req.InterviewApplyId)
  134. if err != nil {
  135. br.Msg = "获取数据失败"
  136. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  137. return
  138. }
  139. var status string
  140. if req.HandleType == 2 {
  141. if item.Status == "已取消" || item.Status == "已完成" {
  142. br.Msg = "当前状态为:" + item.Status + ",不可进行取消操作"
  143. br.ErrMsg = "当前状态为:" + item.Status + ",不可进行取消操作"
  144. return
  145. }
  146. status = "已取消"
  147. } else {
  148. if req.InterviewTime != "" {
  149. status = "待访谈"
  150. } else {
  151. status = "已完成"
  152. }
  153. }
  154. err = cygx.InterviewApplyStatusModify(req.InterviewApplyId, status, req.InterviewTime)
  155. if err != nil {
  156. br.Msg = "状态更新失败"
  157. br.ErrMsg = "状态更新失败,Err:" + err.Error()
  158. return
  159. }
  160. br.Ret = 200
  161. br.Success = true
  162. br.Msg = "状态更新成功"
  163. }