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