apply_record.go 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. cygxService "hongze/hz_crm_api/services/cygx"
  9. "hongze/hz_crm_api/utils"
  10. "strconv"
  11. )
  12. // 权益小程序
  13. type ApplyRecordController struct {
  14. controllers.BaseAuthController
  15. }
  16. // @Title 权益申请记录列表
  17. // @Description权益申请记录接口
  18. // @Param PageSize query int true "每页数据条数"
  19. // @Param CurrentIndex query int true "当前页页码,从1开始"
  20. // @Param KeyWord query string true "搜索关键词"
  21. // @Param CustomType query int true "用户类型1:潜在用户,2:现有客户"
  22. // @Success 200 {object} cygx.CygxApplyRecordListResp
  23. // @router /apply/record/list [get]
  24. func (this *ApplyRecordController) ListSysRole() {
  25. br := new(models.BaseResponse).Init()
  26. defer func() {
  27. this.Data["json"] = br
  28. this.ServeJSON()
  29. }()
  30. sysUser := this.SysUser
  31. if sysUser == nil {
  32. br.Msg = "请登录"
  33. br.ErrMsg = "请登录,SysUser Is Empty"
  34. return
  35. }
  36. pageSize, _ := this.GetInt("PageSize")
  37. currentIndex, _ := this.GetInt("CurrentIndex")
  38. keyWord := this.GetString("KeyWord")
  39. var startSize int
  40. if pageSize <= 0 {
  41. pageSize = utils.PageSize20
  42. }
  43. if currentIndex <= 0 {
  44. currentIndex = 1
  45. }
  46. startSize = utils.StartIndex(currentIndex, pageSize)
  47. var condition string
  48. var pars []interface{}
  49. if keyWord != "" {
  50. condition += ` AND (b.seller_name LIKE '%` + keyWord + `%' OR a.mobile LIKE '%` + keyWord + `%' OR c.email LIKE '%` + keyWord + `%' ) `
  51. }
  52. customType, _ := this.GetInt("CustomType")
  53. if customType > 0 {
  54. if customType == 1 {
  55. condition += ` AND a.company_id_type=1 `
  56. } else if customType == 3 {
  57. condition += ` AND a.company_id_type = 3 `
  58. } else {
  59. condition += ` AND a.company_id_type NOT IN (1,3) `
  60. }
  61. }
  62. //权益申请销售只能看到自己名下的客户的申请 查研观向11.1
  63. companyIds, err := cygxService.GetAdminLookUserCompanyIds(sysUser)
  64. if err != nil {
  65. br.Msg = "获取失败"
  66. br.ErrMsg = "获取失败,GetAdminLookUserCompanyIds Err:" + err.Error()
  67. return
  68. }
  69. lencompanyIds := len(companyIds)
  70. if lencompanyIds > 0 {
  71. condition = ` AND a.company_id_pay IN (` + utils.GetOrmInReplace(lencompanyIds) + `)`
  72. pars = append(pars, companyIds)
  73. }
  74. total, err := cygx.GetCygxApplyRecordCount(condition, pars)
  75. if err != nil {
  76. br.Msg = "获取失败"
  77. br.ErrMsg = "获取失败,Err:" + err.Error()
  78. return
  79. }
  80. list, err := cygx.GetCygxApplyRecord(condition, pars, startSize, pageSize)
  81. if err != nil {
  82. br.Msg = "获取失败"
  83. br.ErrMsg = "获取失败,Err:" + err.Error()
  84. return
  85. }
  86. var microvideoIds []int
  87. for _, v := range list {
  88. if v.Source == "microvideo" {
  89. microvideoIds = append(microvideoIds, v.SourceId)
  90. }
  91. }
  92. lenmicrovideoIds := len(microvideoIds)
  93. mapmicrovideoChartPermissionId := make(map[int]int) //产业视频ID所对应的行业ID
  94. mapmicrovideoIndustryId := make(map[int]int) //产业视频ID所对应的行业ID
  95. if lenmicrovideoIds > 0 {
  96. var conditionmicrovideo string
  97. var parsmicrovideo []interface{}
  98. conditionmicrovideo = ` AND video_id IN (` + utils.GetOrmInReplace(lenmicrovideoIds) + `)`
  99. parsmicrovideo = append(parsmicrovideo, microvideoIds)
  100. listmicrovideo, err := cygx.GetMicroRoadshowVideoList(conditionmicrovideo, "", parsmicrovideo, 0, lenmicrovideoIds)
  101. if err != nil {
  102. br.Msg = "获取失败"
  103. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  104. return
  105. }
  106. for _, v := range listmicrovideo {
  107. mapmicrovideoChartPermissionId[v.VideoId] = v.ChartPermissionId
  108. mapmicrovideoIndustryId[v.VideoId] = v.IndustryId
  109. }
  110. }
  111. for i, v := range list {
  112. if list[i].SellerName == "/" {
  113. list[i].SellerName = ""
  114. }
  115. if v.InviteeCompanyNum == 1 {
  116. list[i].IsInviteeComanyExistence = true
  117. }
  118. if v.InviteeMobile == "" && v.InviteeEmail != "" {
  119. list[i].InviteeMobile = v.InviteeEmail
  120. }
  121. if v.InviteeCompany != "" {
  122. list[i].ApplySource = "免费送月卡"
  123. }
  124. //用户状态,1:潜在客户 、2:现有客户 、3:FICC客户 、4:现有客户(正式,无对应权限) 、5:现有客户(试用,无对应权限) 、6:现有客户(试用暂停) 、7:现有客户(冻结) 、8:现有客户(流失)
  125. switch v.CompanyIdType {
  126. case 1:
  127. list[i].CompanyIdTypeName = "潜在客户"
  128. case 2:
  129. list[i].CompanyIdTypeName = "现有客户"
  130. case 3:
  131. list[i].CompanyIdTypeName = "FICC客户"
  132. case 4:
  133. list[i].CompanyIdTypeName = "现有客户(正式,无对应权限) "
  134. case 5:
  135. list[i].CompanyIdTypeName = "现有客户(试用,无对应权限)"
  136. case 6:
  137. list[i].CompanyIdTypeName = "现有客户(试用暂停)"
  138. case 7:
  139. list[i].CompanyIdTypeName = "现有客户(冻结)"
  140. case 8:
  141. list[i].CompanyIdTypeName = "现有客户(流失)"
  142. }
  143. switch v.RegisterPlatform {
  144. case 1:
  145. list[i].ApplicationSource = "小程序"
  146. case 2:
  147. list[i].ApplicationSource = "网页版"
  148. }
  149. switch v.InviteCompanySource {
  150. case 2:
  151. list[i].ApplicationSource += "(络町)"
  152. }
  153. switch v.Source {
  154. case "article": //文章详情
  155. list[i].HttpUrl = utils.CYGX_WEB_URL + "/material/info/" + strconv.Itoa(v.SourceId)
  156. case "activity": //活动详情
  157. list[i].HttpUrl = utils.CYGX_WEB_URL + "/activity/detail/" + strconv.Itoa(v.SourceId)
  158. case "activityvoice": //活动音频详情
  159. list[i].HttpUrl = utils.CYGX_WEB_URL + "/activity/detail/" + strconv.Itoa(v.SourceId)
  160. case "activityvideo": //活动视频详情
  161. list[i].HttpUrl = utils.CYGX_WEB_URL + "/activity/detail/" + strconv.Itoa(v.SourceId)
  162. case "productinterior": //产品内测
  163. list[i].HttpUrl = utils.CYGX_WEB_URL + "/internal/article/" + strconv.Itoa(v.SourceId)
  164. case "roadshow": //产业视频
  165. list[i].HttpUrl = utils.CYGX_WEB_URL + "/indepth/info/" + strconv.Itoa(mapmicrovideoChartPermissionId[v.SourceId]) + "/" + strconv.Itoa(mapmicrovideoIndustryId[v.SourceId])
  166. case "researchsummary": //本周研究汇总
  167. list[i].HttpUrl = utils.CYGX_WEB_URL + "/summary/2/" + strconv.Itoa(v.SourceId)
  168. case "minutessummary": //上周纪要汇总
  169. list[i].HttpUrl = utils.CYGX_WEB_URL + "/summary/1/" + strconv.Itoa(v.SourceId)
  170. case "reportselection": //报告精选(重点公司)
  171. list[i].HttpUrl = utils.CYGX_WEB_URL + "/recent/" + strconv.Itoa(v.SourceId)
  172. }
  173. }
  174. page := paging.GetPaging(currentIndex, pageSize, total)
  175. resp := new(cygx.CygxApplyRecordListResp)
  176. resp.List = list
  177. resp.Paging = page
  178. br.Ret = 200
  179. br.Success = true
  180. br.Msg = "获取成功"
  181. br.Data = resp
  182. }
  183. // @Title 处理
  184. // @Description 处理接口
  185. // @Param request body cygx.CygxDealReq true "type json string"
  186. // @Success 200 删除成功
  187. // @router /apply/record/deal [post]
  188. func (this *ApplyRecordController) Delete() {
  189. br := new(models.BaseResponse).Init()
  190. defer func() {
  191. this.Data["json"] = br
  192. this.ServeJSON()
  193. }()
  194. var req cygx.CygxDealReq
  195. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  196. if err != nil {
  197. br.Msg = "参数解析异常!"
  198. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  199. return
  200. }
  201. if req.ApplyRecordId <= 0 {
  202. br.Msg = "参数错误"
  203. br.ErrMsg = "参数错误,ApplyRecordId 小于等于0 "
  204. return
  205. }
  206. err = cygx.DealCygxApplyRecord(req.ApplyRecordId, this.SysUser.AdminId)
  207. if err != nil {
  208. br.Msg = "处理失败"
  209. br.ErrMsg = "处理失败,Err:" + err.Error()
  210. return
  211. }
  212. br.Ret = 200
  213. br.Success = true
  214. br.Msg = "处理成功"
  215. }