apply_record.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. "strconv"
  10. )
  11. // 权益小程序
  12. type ApplyRecordController 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. // @Param CustomType query int true "用户类型1:潜在用户,2:现有客户"
  21. // @Success 200 {object} cygx.CygxApplyRecordListResp
  22. // @router /apply/record/list [get]
  23. func (this *ApplyRecordController) ListSysRole() {
  24. br := new(models.BaseResponse).Init()
  25. defer func() {
  26. this.Data["json"] = br
  27. this.ServeJSON()
  28. }()
  29. sysUser := this.SysUser
  30. if sysUser == nil {
  31. br.Msg = "请登录"
  32. br.ErrMsg = "请登录,SysUser Is Empty"
  33. return
  34. }
  35. pageSize, _ := this.GetInt("PageSize")
  36. currentIndex, _ := this.GetInt("CurrentIndex")
  37. keyWord := this.GetString("KeyWord")
  38. var startSize int
  39. if pageSize <= 0 {
  40. pageSize = utils.PageSize20
  41. }
  42. if currentIndex <= 0 {
  43. currentIndex = 1
  44. }
  45. startSize = utils.StartIndex(currentIndex, pageSize)
  46. var condition string
  47. var pars []interface{}
  48. if keyWord != "" {
  49. condition += ` AND (b.seller_name LIKE '%` + keyWord + `%' OR a.mobile LIKE '%` + keyWord + `%' OR c.email LIKE '%` + keyWord + `%' ) `
  50. }
  51. customType, _ := this.GetInt("CustomType")
  52. if customType > 0 {
  53. if customType == 1 {
  54. condition += ` AND a.company_id_type=1 `
  55. } else if customType == 3 {
  56. condition += ` AND a.company_id_type = 3 `
  57. } else {
  58. condition += ` AND a.company_id_type NOT IN (1,3) `
  59. }
  60. }
  61. total, err := cygx.GetCygxApplyRecordCount(condition, pars)
  62. if err != nil {
  63. br.Msg = "获取失败"
  64. br.ErrMsg = "获取失败,Err:" + err.Error()
  65. return
  66. }
  67. list, err := cygx.GetCygxApplyRecord(condition, pars, startSize, pageSize)
  68. if err != nil {
  69. br.Msg = "获取失败"
  70. br.ErrMsg = "获取失败,Err:" + err.Error()
  71. return
  72. }
  73. for i, v := range list {
  74. if list[i].SellerName == "/" {
  75. list[i].SellerName = ""
  76. }
  77. if v.InviteeCompanyNum == 1 {
  78. list[i].IsInviteeComanyExistence = true
  79. }
  80. if v.InviteeMobile == "" && v.InviteeEmail != "" {
  81. list[i].InviteeMobile = v.InviteeEmail
  82. }
  83. if v.InviteeCompany != "" {
  84. list[i].ApplySource = "免费送月卡"
  85. }
  86. //用户状态,1:潜在客户 、2:现有客户 、3:FICC客户 、4:现有客户(正式,无对应权限) 、5:现有客户(试用,无对应权限) 、6:现有客户(试用暂停) 、7:现有客户(冻结) 、8:现有客户(流失)
  87. switch v.CompanyIdType {
  88. case 1:
  89. list[i].CompanyIdTypeName = "潜在客户"
  90. case 2:
  91. list[i].CompanyIdTypeName = "现有客户"
  92. case 3:
  93. list[i].CompanyIdTypeName = "FICC客户"
  94. case 4:
  95. list[i].CompanyIdTypeName = "现有客户(正式,无对应权限) "
  96. case 5:
  97. list[i].CompanyIdTypeName = "现有客户(试用,无对应权限)"
  98. case 6:
  99. list[i].CompanyIdTypeName = "现有客户(试用暂停)"
  100. case 7:
  101. list[i].CompanyIdTypeName = "现有客户(冻结)"
  102. case 8:
  103. list[i].CompanyIdTypeName = "现有客户(流失)"
  104. }
  105. switch v.RegisterPlatform {
  106. case 1:
  107. list[i].ApplicationSource = "小程序"
  108. case 2:
  109. list[i].ApplicationSource = "网页版"
  110. }
  111. switch v.InviteCompanySource {
  112. case 2:
  113. list[i].ApplicationSource += "(络町)"
  114. }
  115. switch v.Source {
  116. case "article": //文章详情
  117. list[i].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.SourceId)
  118. case "activity": //活动详情
  119. list[i].HttpUrl = utils.CYGX_WEB_URL + "/activity/detail/" + strconv.Itoa(v.SourceId)
  120. case "activityvoice": //活动音频详情
  121. list[i].HttpUrl = utils.CYGX_WEB_URL + "/activity/detail/" + strconv.Itoa(v.SourceId)
  122. case "activityvideo": //活动视频详情
  123. list[i].HttpUrl = utils.CYGX_WEB_URL + "/activity/detail/" + strconv.Itoa(v.SourceId)
  124. case "productinterior": //产品内测
  125. list[i].HttpUrl = utils.CYGX_WEB_URL + "//internal/article/" + strconv.Itoa(v.SourceId)
  126. }
  127. }
  128. page := paging.GetPaging(currentIndex, pageSize, total)
  129. resp := new(cygx.CygxApplyRecordListResp)
  130. resp.List = list
  131. resp.Paging = page
  132. br.Ret = 200
  133. br.Success = true
  134. br.Msg = "获取成功"
  135. br.Data = resp
  136. }
  137. // @Title 处理
  138. // @Description 处理接口
  139. // @Param request body cygx.CygxDealReq true "type json string"
  140. // @Success 200 删除成功
  141. // @router /apply/record/deal [post]
  142. func (this *ApplyRecordController) Delete() {
  143. br := new(models.BaseResponse).Init()
  144. defer func() {
  145. this.Data["json"] = br
  146. this.ServeJSON()
  147. }()
  148. var req cygx.CygxDealReq
  149. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  150. if err != nil {
  151. br.Msg = "参数解析异常!"
  152. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  153. return
  154. }
  155. if req.ApplyRecordId <= 0 {
  156. br.Msg = "参数错误"
  157. br.ErrMsg = "参数错误,ApplyRecordId 小于等于0 "
  158. return
  159. }
  160. err = cygx.DealCygxApplyRecord(req.ApplyRecordId, this.SysUser.AdminId)
  161. if err != nil {
  162. br.Msg = "处理失败"
  163. br.ErrMsg = "处理失败,Err:" + err.Error()
  164. return
  165. }
  166. br.Ret = 200
  167. br.Success = true
  168. br.Msg = "处理成功"
  169. }