apply_record.go 7.7 KB

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