user.go 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hongze_cygx/models"
  7. "hongze/hongze_cygx/services"
  8. "hongze/hongze_cygx/utils"
  9. "strconv"
  10. "strings"
  11. "time"
  12. )
  13. // 用户
  14. type UserController struct {
  15. BaseAuthController
  16. }
  17. type UserCommonController struct {
  18. BaseCommonController
  19. }
  20. // @Title 登录
  21. // @Description 登录接口
  22. // @Param request body models.LoginReq true "type json string"
  23. // @Success 200 {object} models.LoginResp
  24. // @router /login [post]
  25. func (this *UserController) Login() {
  26. br := new(models.BaseResponse).Init()
  27. defer func() {
  28. this.Data["json"] = br
  29. this.ServeJSON()
  30. }()
  31. var req models.LoginReq
  32. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  33. if err != nil {
  34. br.Msg = "参数解析异常!"
  35. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  36. return
  37. }
  38. user := this.User
  39. if user == nil {
  40. br.Msg = "请登录"
  41. br.ErrMsg = "请登录"
  42. br.Ret = 408
  43. return
  44. }
  45. unionId := this.User.UnionId
  46. openId := this.User.OpenId
  47. if unionId == "" {
  48. br.Msg = "参数错误"
  49. br.ErrMsg = "参数错误,unionId 为空"
  50. return
  51. }
  52. if req.LoginType == 1 || req.LoginType == 3 {
  53. if req.Mobile == "" {
  54. br.Msg = "参数错误"
  55. br.ErrMsg = "参数错误,手机号为空 为空"
  56. return
  57. }
  58. if req.LoginType == 3 {
  59. item, err := models.GetMsgCode(req.Mobile, req.VCode)
  60. if err != nil {
  61. if err.Error() == utils.ErrNoRow() {
  62. br.Msg = "验证码错误,请重新输入"
  63. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  64. return
  65. } else {
  66. br.Msg = "验证码错误,请重新输入"
  67. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  68. return
  69. }
  70. }
  71. if item == nil {
  72. br.Msg = "验证码错误,请重新输入"
  73. return
  74. }
  75. }
  76. req.Mobile = strings.Trim(req.Mobile, " ")
  77. } else if req.LoginType == 2 {
  78. if req.Email == "" {
  79. br.ErrMsg = "邮箱不能为空,请输入邮箱"
  80. br.Msg = "邮箱不能为空,请输入邮箱"
  81. return
  82. }
  83. if !utils.ValidateEmailFormatat(req.Email) {
  84. br.ErrMsg = "邮箱格式错误,请重新输入"
  85. br.Msg = "邮箱格式错误,请重新输入"
  86. return
  87. }
  88. item, err := models.GetMsgCode(req.Email, req.VCode)
  89. if err != nil {
  90. if err.Error() == utils.ErrNoRow() {
  91. br.Msg = "验证码错误,请重新输入"
  92. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  93. return
  94. } else {
  95. br.Msg = "验证码错误,请重新输入"
  96. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  97. return
  98. }
  99. }
  100. if item == nil {
  101. br.Msg = "验证码错误,请重新输入"
  102. return
  103. }
  104. } else {
  105. br.Msg = "无效的登录方式"
  106. br.ErrMsg = "无效的登录方式,Err:"
  107. return
  108. }
  109. if len(req.Mobile) >= 11 && req.CountryCode == "" {
  110. req.CountryCode = "86"
  111. }
  112. user, err = services.BindWxUser(openId, req.Mobile, req.Email, req.CountryCode)
  113. if err != nil {
  114. br.Msg = "登录失败"
  115. br.ErrMsg = "绑定手机号失败:" + err.Error()
  116. return
  117. }
  118. userId := user.UserId
  119. var token string
  120. tokenItem, err := models.GetTokenByOpenId(openId)
  121. if err != nil && err.Error() != utils.ErrNoRow() {
  122. br.Msg = "登录失败"
  123. br.ErrMsg = "登录失败,获取token失败:" + err.Error()
  124. return
  125. }
  126. if tokenItem == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
  127. timeUnix := time.Now().Unix()
  128. timeUnixStr := strconv.FormatInt(timeUnix, 10)
  129. token = utils.MD5(openId) + utils.MD5(timeUnixStr)
  130. //新增session
  131. {
  132. session := new(models.CygxSession)
  133. session.OpenId = unionId
  134. session.UnionId = unionId
  135. session.UserId = userId
  136. session.CreatedTime = time.Now()
  137. session.LastUpdatedTime = time.Now()
  138. session.ExpireTime = time.Now().AddDate(0, 1, 0)
  139. session.AccessToken = token
  140. err = models.AddSession(session)
  141. if err != nil {
  142. br.Msg = "登录失败"
  143. br.ErrMsg = "登录失败,新增用户session信息失败:" + err.Error()
  144. return
  145. }
  146. }
  147. } else {
  148. token = tokenItem.AccessToken
  149. }
  150. //新增登录日志
  151. {
  152. loginLog := new(models.WxUserLog)
  153. loginLog.UserId = userId
  154. loginLog.OpenId = openId
  155. loginLog.Mobile = req.Mobile
  156. loginLog.Email = req.Email
  157. loginLog.CreateTime = time.Now()
  158. loginLog.Handle = "wechat_user_login"
  159. loginLog.Remark = token
  160. go models.AddWxUserLog(loginLog)
  161. }
  162. //添加邀请绑定关系
  163. {
  164. if req.ShareUserCode != "" {
  165. count, _ := models.GetUserInviteeCount(userId)
  166. if count == 0 {
  167. userItem := new(models.UserInvitee)
  168. userItem.CreateTime = time.Now()
  169. userItem.InviteedUserId = strconv.Itoa(userId)
  170. userItem.InviteeUserId = req.ShareUserCode
  171. shareUserId, _ := strconv.Atoi(req.ShareUserCode)
  172. inviteeUser, _ := models.GetWxUserItemByUserId(shareUserId)
  173. if inviteeUser != nil {
  174. userItem.InviteeMobile = inviteeUser.Mobile
  175. userItem.InviteeCompany = inviteeUser.CompanyName
  176. userItem.InviteeCompanyId = inviteeUser.CompanyId
  177. userItem.InviteeEmail = inviteeUser.Email
  178. }
  179. models.AddUserInvite(userItem)
  180. }
  181. }
  182. }
  183. //先关注后登录,更新用户是否关注过查研观向小助手公众号
  184. {
  185. services.UpdateCygxSubscribe(userId, unionId)
  186. }
  187. //记录通过三方合作机构过来的公司
  188. {
  189. services.AddInviteCompany(user)
  190. }
  191. resp := new(models.LoginResp)
  192. resp.UserId = userId
  193. resp.Authorization = token
  194. if user.CompanyId == 1 {
  195. resp.IsPotential = true
  196. }
  197. br.Ret = 200
  198. br.Success = true
  199. br.Data = resp
  200. br.Msg = "登录成功"
  201. }
  202. // @Title 获取用户详情
  203. // @Description 获取用户详情接口
  204. // @Success 200 {object} models.UserDetail
  205. // @router /detail [get]
  206. func (this *UserController) Detail() {
  207. br := new(models.BaseResponse).Init()
  208. defer func() {
  209. this.Data["json"] = br
  210. this.ServeJSON()
  211. }()
  212. user := this.User
  213. if user == nil {
  214. br.Msg = "请登录"
  215. br.ErrMsg = "请登录,用户信息为空"
  216. br.Ret = 408
  217. return
  218. }
  219. uid := user.UserId
  220. var hasPermission int
  221. detail := new(models.UserDetail)
  222. if uid > 0 {
  223. var err error
  224. detail, err = models.GetUserDetailByUserId(uid)
  225. if err != nil && err.Error() != utils.ErrNoRow() {
  226. br.Msg = "获取信息失败"
  227. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  228. return
  229. }
  230. if detail == nil {
  231. br.Msg = "获取信息失败"
  232. br.ErrMsg = "获取信息失败,Err:用户不存在"
  233. return
  234. }
  235. userRecord, _ := models.GetUserRecordByUserId(uid, utils.WxPlatform)
  236. if userRecord != nil {
  237. detail.NickName = userRecord.NickName
  238. if detail.Headimgurl == "" {
  239. detail.Headimgurl = userRecord.Headimgurl
  240. }
  241. if detail.Headimgurl == "" {
  242. userRecord, _ = models.GetUserRecordByUserId(uid, 1)
  243. if userRecord != nil {
  244. detail.NickName = userRecord.NickName
  245. detail.Headimgurl = userRecord.Headimgurl
  246. }
  247. }
  248. }
  249. if user.CompanyId > 1 {
  250. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  251. if err != nil && err.Error() != utils.ErrNoRow() {
  252. br.Msg = "获取信息失败"
  253. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  254. return
  255. }
  256. if companyItem != nil && companyItem.CompanyId > 0 {
  257. detail.CompanyName = companyItem.CompanyName
  258. //if companyItem.Status == "试用" || companyItem.Status == "永续" || companyItem.Status == "正式" {
  259. //permissionStr, err := models.GetCompanyPermissionByUser(companyItem.CompanyId)
  260. //if err != nil {
  261. // br.Msg = "获取信息失败"
  262. // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  263. // return
  264. //}
  265. var permissionStr string
  266. permissionList, err := models.GetCompanyPermissionList(companyItem.CompanyId)
  267. if err != nil {
  268. br.Msg = "获取信息失败"
  269. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  270. return
  271. }
  272. mapIsUpgrade := make(map[string]string)
  273. mapZhukKeGuan := make(map[string]int)
  274. for _, v := range permissionList {
  275. mapZhukKeGuan[v.PermissionName] += 1
  276. if v.IsUpgrade == 1 {
  277. mapIsUpgrade[v.PermissionName] = v.PermissionName + "(升级)"
  278. }
  279. }
  280. mapPermissionName := make(map[string]string)
  281. //处理升级,并且合并主客观
  282. for _, v := range permissionList {
  283. if _, ok := mapPermissionName[v.PermissionName]; ok {
  284. continue
  285. }
  286. if _, ok := mapIsUpgrade[v.PermissionName]; ok {
  287. permissionStr += mapIsUpgrade[v.PermissionName] + ","
  288. } else {
  289. if mapZhukKeGuan[v.PermissionName] == 1 {
  290. permissionStr += v.Remark + ","
  291. } else {
  292. permissionStr += v.PermissionName + ","
  293. }
  294. }
  295. mapPermissionName[v.PermissionName] = v.PermissionName
  296. }
  297. permissionStr = strings.TrimRight(permissionStr, ",")
  298. //permissionStrOld, err := models.GetCompanyPermission(companyItem.CompanyId)
  299. //if err != nil {
  300. // br.Msg = "获取信息失败"
  301. // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  302. // return
  303. //}
  304. //permissionStrListOld := strings.Split(permissionStrOld, ",")
  305. //for _, v := range permissionStrListOld {
  306. // if strings.Count(permissionStr, v) > 1 {
  307. // permissionStr = strings.Replace(permissionStr, v+"(主观)", v, -1)
  308. // permissionStr = strings.Replace(permissionStr, v+"(客观),", "", -1)
  309. // }
  310. //}
  311. detail.PermissionName = permissionStr
  312. //} else {
  313. if permissionStr == "" {
  314. hasPermission = 1
  315. }
  316. //}
  317. detail.SellerName = companyItem.SellerName
  318. detail.SellerMobile = companyItem.Mobile
  319. tatolSpecil, err := services.GetSpecialTripUserSchedule(user.UserId)
  320. if err != nil {
  321. br.Msg = "获取信息失败"
  322. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  323. return
  324. }
  325. detail.ScheduleNum += tatolSpecil
  326. microRoadshowCollectcount, err := models.GetUserMicroRoadshowCollectcount(user.UserId)
  327. if err != nil {
  328. br.Msg = "获取信息失败"
  329. br.ErrMsg = "获取微路演收藏信息失败,GetUserMicroRoadshowCollectcount Err:" + err.Error()
  330. return
  331. }
  332. detail.ConNum += microRoadshowCollectcount
  333. } else {
  334. hasPermission = 1
  335. }
  336. } else {
  337. //判断是否已经申请过
  338. applyCount, err := models.GetApplyRecordCount(uid)
  339. if err != nil && err.Error() != utils.ErrNoRow() {
  340. br.Msg = "获取信息失败"
  341. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  342. return
  343. }
  344. if applyCount > 0 {
  345. hasPermission = 3
  346. } else {
  347. hasPermission = 2
  348. }
  349. detail.CompanyName = detail.Note
  350. }
  351. detail.HasPermission = hasPermission
  352. } else {
  353. ur, _ := models.GetUserRecordByOpenId(user.OpenId)
  354. if ur != nil {
  355. detail.NickName = ur.NickName
  356. detail.Email = ur.BindAccount
  357. detail.Mobile = ur.BindAccount
  358. detail.NickName = ur.NickName
  359. detail.Headimgurl = ur.Headimgurl
  360. }
  361. hasPermission = 2
  362. detail.HasPermission = hasPermission
  363. }
  364. if detail.Headimgurl == "" {
  365. detail.Headimgurl = utils.DefaultHeadimgurl
  366. }
  367. br.Ret = 200
  368. br.Success = true
  369. br.Msg = "获取成功"
  370. br.Data = detail
  371. }
  372. // @Title 校验用户状态信息
  373. // @Description 校验用户状态信息
  374. // @Success 200 {object} models.CheckStatusResp
  375. // @router /check/status [get]
  376. func (this *UserController) CheckLogin() {
  377. br := new(models.BaseResponse).Init()
  378. defer func() {
  379. this.Data["json"] = br
  380. this.ServeJSON()
  381. }()
  382. user := this.User
  383. if user == nil {
  384. br.Msg = "请登录"
  385. br.ErrMsg = "请登录"
  386. br.Ret = 408
  387. return
  388. }
  389. uid := user.UserId
  390. resp := new(models.CheckStatusResp)
  391. if uid > 0 {
  392. //判断token是否过期
  393. userRecord, err := models.GetUserRecordByUserId(uid, utils.WxPlatform)
  394. if err != nil {
  395. br.Msg = "获取用户信息失败"
  396. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  397. return
  398. }
  399. permissionStr, err := models.GetCompanyPermission(user.CompanyId)
  400. if err != nil {
  401. br.Msg = "获取信息失败"
  402. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  403. return
  404. }
  405. resp.PermissionName = permissionStr
  406. if user.Mobile == "" && user.Email == "" {
  407. resp.IsBind = true
  408. }
  409. if userRecord.UnionId == "" {
  410. resp.IsAuth = true
  411. }
  412. } else {
  413. resp.IsBind = true
  414. if user.UnionId == "" {
  415. resp.IsAuth = true
  416. }
  417. resp.PermissionName = ""
  418. }
  419. br.Success = true
  420. br.Msg = "获取成功"
  421. br.Data = resp
  422. br.Ret = 200
  423. }
  424. // @Title 获取我的收藏
  425. // @Description 获取我的收藏列表
  426. // @Param PageSize query int true "PageSize"
  427. // @Param CurrentIndex query int true "CurrentIndex"
  428. // @Success 200 {object} models.ArticleCollectListResp
  429. // @router /collect/list [get]
  430. func (this *UserController) CollectList() {
  431. br := new(models.BaseResponse).Init()
  432. defer func() {
  433. this.Data["json"] = br
  434. this.ServeJSON()
  435. }()
  436. userId := this.User.UserId
  437. var pageSize, currentIndex, startSize int
  438. pageSize, _ = this.GetInt("PageSize")
  439. currentIndex, _ = this.GetInt("CurrentIndex")
  440. if pageSize <= 0 {
  441. pageSize = utils.PageSize20
  442. }
  443. if currentIndex <= 0 {
  444. currentIndex = 1
  445. }
  446. startSize = utils.StartIndex(currentIndex, pageSize)
  447. total, err := models.GetArticleUserCollectCount(userId)
  448. if err != nil {
  449. br.Msg = "获取数据失败"
  450. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  451. return
  452. }
  453. list, err := models.GetArticleUserCollectList(startSize, pageSize, userId)
  454. if err != nil {
  455. br.Msg = "获取数据失败"
  456. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  457. return
  458. }
  459. resp := new(models.ArticleReportBillboardLIstPageResp)
  460. if len(list) == 0 {
  461. page := paging.GetPaging(currentIndex, pageSize, total)
  462. resp.List = list
  463. resp.Paging = page
  464. br.Msg = "获取成功!"
  465. br.Ret = 200
  466. br.Success = true
  467. br.Data = resp
  468. return
  469. }
  470. var condition string
  471. var pars []interface{}
  472. var articleIds []string
  473. for _, v := range list {
  474. articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
  475. }
  476. articleIdStr := strings.Join(articleIds, ",")
  477. //获取文章关联的产业
  478. pars = make([]interface{}, 0)
  479. condition = ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(articleIds)) + ` ) `
  480. pars = append(pars, articleIds)
  481. industrialList, err := models.GetIndustrialListByarticleId(pars, condition)
  482. if err != nil {
  483. br.Msg = "获取失败"
  484. br.ErrMsg = "获取失败,GetSubjectList Err:" + err.Error()
  485. return
  486. }
  487. industrialMap := make(map[int][]*models.IndustrialManagementIdInt)
  488. if len(industrialList) > 0 {
  489. for _, v := range industrialList {
  490. item := new(models.IndustrialManagementIdInt)
  491. item.ArticleId = v.ArticleId
  492. if v.ArticleId > utils.SummaryArticleId {
  493. item.IsResearch = true
  494. }
  495. item.IndustrialManagementId = v.IndustrialManagementId
  496. item.IndustryName = v.IndustryName
  497. industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
  498. }
  499. }
  500. for k, v := range list {
  501. if len(industrialMap[v.ArticleId]) > 0 {
  502. list[k].List = industrialMap[v.ArticleId]
  503. } else {
  504. list[k].List = make([]*models.IndustrialManagementIdInt, 0)
  505. }
  506. }
  507. articleMap := make(map[int]*models.ArticleDetail)
  508. if articleIdStr != "" {
  509. articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
  510. if err != nil {
  511. br.Msg = "获取数据失败"
  512. br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
  513. return
  514. }
  515. for _, v := range articleList {
  516. if _, ok := articleMap[v.ArticleId]; !ok {
  517. articleMap[v.ArticleId] = v
  518. }
  519. }
  520. }
  521. //处理文章PV收藏等数量
  522. mapArticleCollectNum := make(map[int]*models.CygxArticleNum)
  523. if len(articleIds) > 0 {
  524. articleCollectNumList, err := models.GetArticleCollectNum(articleIds, userId)
  525. if err != nil && err.Error() != utils.ErrNoRow() {
  526. br.Msg = "获取失败"
  527. br.ErrMsg = "获取失败,GetArticleCollectNum Err:" + err.Error()
  528. return
  529. }
  530. for _, v := range articleCollectNumList {
  531. mapArticleCollectNum[v.ArticleId] = v
  532. }
  533. }
  534. lyjhTypeMap, _ := services.GetLyjhTypeMap()
  535. lenList := len(list)
  536. for i := 0; i < lenList; i++ {
  537. item := list[i]
  538. article := articleMap[item.ArticleId]
  539. list[i].Title = article.Title
  540. list[i].DepartmentId = article.DepartmentId
  541. list[i].NickName = article.NickName
  542. list[i].PublishDate = article.PublishDate
  543. if article.ArticleId < utils.SummaryArticleId {
  544. list[i].Source = 1
  545. } else {
  546. list[i].Source = 2
  547. }
  548. if mapArticleCollectNum[article.ArticleId] != nil {
  549. list[i].CollectNum = mapArticleCollectNum[article.ArticleId].CollectNum
  550. list[i].Pv = mapArticleCollectNum[article.ArticleId].Pv
  551. list[i].IsCollect = mapArticleCollectNum[article.ArticleId].IsCollect
  552. }
  553. if _, ok := lyjhTypeMap[item.CategoryId]; ok && list[i].ArticleId >= utils.SummaryArticleId {
  554. list[i].IsRoadShow = true
  555. }
  556. }
  557. page := paging.GetPaging(currentIndex, pageSize, total)
  558. resp.List = list
  559. resp.Paging = page
  560. br.Msg = "获取成功!"
  561. br.Ret = 200
  562. br.Success = true
  563. br.Data = resp
  564. }
  565. // @Title 获取申请访谈列表
  566. // @Description 获取申请访谈列表
  567. // @Param PageSize query int true "PageSize"
  568. // @Param CurrentIndex query int true "CurrentIndex"
  569. // @Success 200 {object} models.ArticleInterviewApplyListResp
  570. // @router /interview/apply/list [get]
  571. func (this *UserController) InterviewApplyList() {
  572. br := new(models.BaseResponse).Init()
  573. defer func() {
  574. this.Data["json"] = br
  575. this.ServeJSON()
  576. }()
  577. userId := this.User.UserId
  578. var pageSize, currentIndex, startSize int
  579. pageSize, _ = this.GetInt("PageSize")
  580. currentIndex, _ = this.GetInt("CurrentIndex")
  581. if pageSize <= 0 {
  582. pageSize = utils.PageSize20
  583. }
  584. if currentIndex <= 0 {
  585. currentIndex = 1
  586. }
  587. startSize = utils.StartIndex(currentIndex, pageSize)
  588. total, err := models.GetArticleUserInterviewApplyCount(userId)
  589. if err != nil {
  590. br.Msg = "获取数据失败"
  591. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  592. return
  593. }
  594. list, err := models.GetArticleUserInterviewApplyList(startSize, pageSize, userId)
  595. if err != nil {
  596. br.Msg = "获取数据失败"
  597. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  598. return
  599. }
  600. var articleIds []string
  601. for _, v := range list {
  602. articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
  603. }
  604. articleIdStr := strings.Join(articleIds, ",")
  605. articleMap := make(map[int]*models.ArticleDetail)
  606. if articleIdStr != "" {
  607. articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
  608. if err != nil {
  609. br.Msg = "获取数据失败"
  610. br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
  611. return
  612. }
  613. for _, v := range articleList {
  614. if _, ok := articleMap[v.ArticleId]; !ok {
  615. articleMap[v.ArticleId] = v
  616. }
  617. }
  618. }
  619. lenList := len(list)
  620. for i := 0; i < lenList; i++ {
  621. item := list[i]
  622. if articleMap[item.ArticleId] == nil {
  623. continue
  624. }
  625. article := articleMap[item.ArticleId]
  626. bodySub, _ := services.GetReportContentTextSub(article.Body)
  627. list[i].Title = article.Title
  628. list[i].TitleEn = article.TitleEn
  629. list[i].UpdateFrequency = article.UpdateFrequency
  630. list[i].CreateDate = article.CreateDate
  631. list[i].PublishDate = article.PublishDate
  632. list[i].Body = bodySub
  633. list[i].Abstract = article.Abstract
  634. list[i].CategoryName = article.CategoryName
  635. list[i].SubCategoryName = article.SubCategoryName
  636. list[i].ExpertBackground = article.ExpertBackground
  637. list[i].ExpertNumber = article.ExpertNumber
  638. }
  639. page := paging.GetPaging(currentIndex, pageSize, total)
  640. resp := new(models.ArticleInterviewApplyListResp)
  641. resp.List = list
  642. resp.Paging = page
  643. br.Msg = "获取成功!"
  644. br.Ret = 200
  645. br.Success = true
  646. br.Data = resp
  647. }
  648. // @Title 获取浏览历史列表
  649. // @Description 获取浏览历史列表
  650. // @Param PageSize query int true "PageSize"
  651. // @Param CurrentIndex query int true "CurrentIndex"
  652. // @Success 200 {object} models.ArticleBrowseHistoryListResp
  653. // @router /browse/history/list [get]
  654. func (this *UserController) BrowseHistoryList() {
  655. br := new(models.BaseResponse).Init()
  656. defer func() {
  657. this.Data["json"] = br
  658. this.ServeJSON()
  659. }()
  660. userId := this.User.UserId
  661. var pageSize, currentIndex, startSize int
  662. pageSize, _ = this.GetInt("PageSize")
  663. currentIndex, _ = this.GetInt("CurrentIndex")
  664. if pageSize <= 0 {
  665. pageSize = utils.PageSize20
  666. }
  667. if currentIndex <= 0 {
  668. currentIndex = 1
  669. }
  670. startSize = utils.StartIndex(currentIndex, pageSize)
  671. endDate := time.Now().AddDate(0, -1, 0).Format(utils.FormatDate)
  672. total, err := models.GetArticleUserBrowseHistoryCount(userId, endDate)
  673. if err != nil {
  674. br.Msg = "获取数据失败"
  675. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  676. return
  677. }
  678. list, err := models.GetArticleUserBrowseHistoryList(startSize, pageSize, userId, endDate)
  679. if err != nil {
  680. br.Msg = "获取数据失败"
  681. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  682. return
  683. }
  684. resp := new(models.ArticleReportBillboardLIstPageResp)
  685. if len(list) == 0 {
  686. page := paging.GetPaging(currentIndex, pageSize, total)
  687. resp.List = list
  688. resp.Paging = page
  689. br.Msg = "获取成功!"
  690. br.Ret = 200
  691. br.Success = true
  692. br.Data = resp
  693. return
  694. }
  695. var articleIds []string
  696. var condition string
  697. var pars []interface{}
  698. for _, v := range list {
  699. articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
  700. }
  701. articleIdStr := strings.Join(articleIds, ",")
  702. //获取文章关联的产业
  703. pars = make([]interface{}, 0)
  704. condition = ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(articleIds)) + ` ) `
  705. pars = append(pars, articleIds)
  706. industrialList, err := models.GetIndustrialListByarticleId(pars, condition)
  707. if err != nil {
  708. br.Msg = "获取失败"
  709. br.ErrMsg = "获取失败,GetSubjectList Err:" + err.Error()
  710. return
  711. }
  712. industrialMap := make(map[int][]*models.IndustrialManagementIdInt)
  713. if len(industrialList) > 0 {
  714. for _, v := range industrialList {
  715. item := new(models.IndustrialManagementIdInt)
  716. item.ArticleId = v.ArticleId
  717. if v.ArticleId > utils.SummaryArticleId {
  718. item.IsResearch = true
  719. }
  720. item.IndustrialManagementId = v.IndustrialManagementId
  721. item.IndustryName = v.IndustryName
  722. industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
  723. }
  724. }
  725. for k, v := range list {
  726. if len(industrialMap[v.ArticleId]) > 0 {
  727. list[k].List = industrialMap[v.ArticleId]
  728. } else {
  729. list[k].List = make([]*models.IndustrialManagementIdInt, 0)
  730. }
  731. }
  732. articleMap := make(map[int]*models.ArticleDetail)
  733. if articleIdStr != "" {
  734. articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
  735. if err != nil {
  736. br.Msg = "获取数据失败"
  737. br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
  738. return
  739. }
  740. for _, v := range articleList {
  741. if _, ok := articleMap[v.ArticleId]; !ok {
  742. articleMap[v.ArticleId] = v
  743. }
  744. }
  745. }
  746. //处理文章PV收藏等数量
  747. mapArticleCollectNum := make(map[int]*models.CygxArticleNum)
  748. if len(articleIds) > 0 {
  749. articleCollectNumList, err := models.GetArticleCollectNum(articleIds, userId)
  750. if err != nil && err.Error() != utils.ErrNoRow() {
  751. br.Msg = "获取失败"
  752. br.ErrMsg = "获取失败,GetArticleCollectNum Err:" + err.Error()
  753. return
  754. }
  755. for _, v := range articleCollectNumList {
  756. mapArticleCollectNum[v.ArticleId] = v
  757. }
  758. }
  759. lenList := len(list)
  760. for i := 0; i < lenList; i++ {
  761. item := list[i]
  762. article := articleMap[item.ArticleId]
  763. if article != nil {
  764. list[i].Title = article.Title
  765. list[i].PublishDate = utils.TimeRemoveHms2(article.PublishDate)
  766. list[i].DepartmentId = article.DepartmentId
  767. list[i].NickName = article.NickName
  768. if article.ArticleId < utils.SummaryArticleId {
  769. list[i].Source = 1
  770. } else {
  771. list[i].Source = 2
  772. }
  773. if mapArticleCollectNum[article.ArticleId] != nil {
  774. list[i].CollectNum = mapArticleCollectNum[article.ArticleId].CollectNum
  775. list[i].Pv = mapArticleCollectNum[article.ArticleId].Pv
  776. list[i].IsCollect = mapArticleCollectNum[article.ArticleId].IsCollect
  777. }
  778. //list[i].TitleEn = article.TitleEn
  779. //list[i].UpdateFrequency = article.UpdateFrequency
  780. //list[i].CreateDate = article.CreateDate
  781. //list[i].Body, _ = services.GetReportContentTextSub(article.Body)
  782. //list[i].Abstract = article.Abstract
  783. //list[i].CategoryName = article.CategoryName
  784. //list[i].SubCategoryName = article.SubCategoryName
  785. }
  786. }
  787. page := paging.GetPaging(currentIndex, pageSize, total)
  788. resp.List = list
  789. resp.Paging = page
  790. br.Msg = "获取成功!"
  791. br.Ret = 200
  792. br.Success = true
  793. br.Data = resp
  794. }
  795. // @Title 未付费申请试用
  796. // @Description 未付费申请试用
  797. // @Param request body models.ApplyTryReq true "type json string"
  798. // @Success 200
  799. // @router /apply/try [post]
  800. func (this *UserController) ApplyTryOut() {
  801. br := new(models.BaseResponse).Init()
  802. defer func() {
  803. this.Data["json"] = br
  804. this.ServeJSON()
  805. }()
  806. user := this.User
  807. if user == nil {
  808. br.Msg = "请登录"
  809. br.ErrMsg = "请登录,SysUser Is Empty"
  810. br.Ret = 408
  811. return
  812. }
  813. mobile := user.Mobile
  814. var req models.ApplyTryReq
  815. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  816. if err != nil {
  817. br.Msg = "参数解析异常!"
  818. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  819. return
  820. }
  821. if req.RealName == "" {
  822. req.RealName = user.RealName
  823. }
  824. if req.CompanyName == "" {
  825. req.CompanyName = user.CompanyName
  826. }
  827. uid := user.UserId
  828. var title string
  829. tryType := req.TryType
  830. detailId := req.DetailId
  831. var isResearch bool // 是否属于研选
  832. if tryType == "Article" {
  833. detail, err := models.GetArticleDetailById(detailId)
  834. if err != nil {
  835. br.Msg = "获取信息失败"
  836. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  837. return
  838. }
  839. title = detail.Title
  840. if detail.ArticleTypeId > 0 {
  841. isResearch = true
  842. }
  843. } else if tryType == "Activity" {
  844. detail, err := models.GetAddActivityInfoById(detailId)
  845. if err != nil {
  846. br.Msg = "操作失败"
  847. br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(detailId)
  848. return
  849. }
  850. title = detail.ActivityName
  851. if strings.Contains(detail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
  852. isResearch = true
  853. }
  854. } else if tryType == "MicroAudio" {
  855. // 微路演音频
  856. microAudio, e := models.GetCygxActivityVoiceById(detailId)
  857. if e != nil {
  858. br.Msg = "操作失败"
  859. br.ErrMsg = "微路演音频信息有误, 不存在的VoiceId: " + strconv.Itoa(detailId)
  860. return
  861. }
  862. title = microAudio.VoiceName
  863. } else if tryType == "MicroVideo" {
  864. // 微路演视频
  865. microVideo, e := models.GetMicroRoadshowVideoById(detailId)
  866. if e != nil {
  867. br.Msg = "操作失败"
  868. br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(detailId)
  869. return
  870. }
  871. title = microVideo.VideoName
  872. } else if tryType == "Researchsummary" {
  873. // 本周研究汇总
  874. ResearchSummaryInfo, e := models.GetCygxResearchSummaryInfoById(detailId)
  875. if e != nil {
  876. br.Msg = "操作失败"
  877. br.ErrMsg = "本周研究汇总信息有误, 不存在的detailId: " + strconv.Itoa(detailId)
  878. return
  879. }
  880. title = ResearchSummaryInfo.Title
  881. } else if tryType == "Minutessummary" {
  882. // 上周纪要汇总
  883. MinutesSummaryInfo, e := models.GetCygxMinutesSummaryInfoById(detailId)
  884. if e != nil {
  885. br.Msg = "操作失败"
  886. br.ErrMsg = "上周纪要汇总信息有误, 不存在的detailId: " + strconv.Itoa(detailId)
  887. return
  888. }
  889. title = MinutesSummaryInfo.Title
  890. } else if tryType == "ReportSelection" {
  891. // 报告精选
  892. ReportSelectionInfo, e := models.GetCygxReportSelectionInfoById(detailId)
  893. if e != nil {
  894. br.Msg = "操作失败"
  895. br.ErrMsg = "报告精选信息有误, 不存在的detailId: " + strconv.Itoa(detailId)
  896. return
  897. }
  898. title = ReportSelectionInfo.Title
  899. } else if tryType == "ProductInterior" {
  900. // 产品内测
  901. ProductInteriorDetail, e := models.GetCygxProductInteriorDetail(detailId)
  902. if e != nil {
  903. br.Msg = "操作失败"
  904. br.ErrMsg = "产品内测信息有误, 不存在的detailId: " + strconv.Itoa(detailId)
  905. return
  906. }
  907. title = ProductInteriorDetail.Title
  908. }
  909. fmt.Println(title)
  910. //缓存校验
  911. cacheKey := fmt.Sprint("xygx:apply_record:add:", uid)
  912. ttlTime := utils.Rc.GetRedisTTL(cacheKey)
  913. if ttlTime > 0 {
  914. br.Msg = "申请失败,申请过于频繁"
  915. br.ErrMsg = "申请失败,申请过于频繁"
  916. return
  917. }
  918. utils.Rc.SetNX(cacheKey, user.Mobile, time.Second*10)
  919. //判断是否已经申请过
  920. applyCount, err := models.GetApplyRecordCount(uid)
  921. if err != nil && err.Error() != utils.ErrNoRow() {
  922. br.Msg = "获取信息失败"
  923. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  924. return
  925. }
  926. if applyCount > 0 {
  927. br.Msg = "您已提交申请,请耐心等待。"
  928. br.IsSendEmail = false
  929. return
  930. }
  931. //判断是否存在申请
  932. var sellerMobile string
  933. if req.ApplyMethod == 2 {
  934. if req.BusinessCardUrl == "" {
  935. br.Msg = "请上传名片"
  936. return
  937. }
  938. if req.RealName == "" {
  939. br.Msg = "请输入姓名"
  940. return
  941. }
  942. if req.CompanyName == "" {
  943. br.Msg = "请输入公司名称"
  944. return
  945. }
  946. if req.BusinessCardUrl != "" && utils.RunMode == "release" {
  947. card, err := services.GetBusinessCard(req.BusinessCardUrl)
  948. if err != nil {
  949. br.Msg = "名片识别失败"
  950. br.ErrMsg = "名片识别失败,Err:" + err.Error()
  951. return
  952. }
  953. mobileStr := strings.Join(card.WordsResult.MOBILE, ",")
  954. isFlag := true
  955. if mobile != "" {
  956. if strings.Contains(mobileStr, mobile) || mobileStr == "" {
  957. isFlag = true
  958. } else {
  959. isFlag = false
  960. }
  961. }
  962. if !isFlag {
  963. //阿里云识别
  964. if utils.RunMode == "release" {
  965. aliyunResult, err := services.AliyunBusinessCard(req.BusinessCardUrl)
  966. if err != nil {
  967. br.Msg = "识别失败"
  968. br.ErrMsg = "识别失败,Err:" + err.Error()
  969. return
  970. }
  971. if !aliyunResult.Success {
  972. br.Msg = "识别失败"
  973. br.ErrMsg = "识别失败"
  974. return
  975. }
  976. mobileStr := strings.Join(aliyunResult.TelCell, ",")
  977. if mobile != "" {
  978. if strings.Contains(mobileStr, mobile) {
  979. isFlag = true
  980. } else {
  981. isFlag = false
  982. }
  983. }
  984. }
  985. }
  986. if !isFlag {
  987. br.Msg = "名片手机号与所填手机号不匹配,请重新填写"
  988. br.ErrMsg = "mobile:" + mobile
  989. return
  990. }
  991. }
  992. }
  993. //获取销售信息
  994. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  995. if err != nil && err.Error() != utils.ErrNoRow() {
  996. br.Msg = "申请失败"
  997. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  998. return
  999. }
  1000. //用户状态,1:潜在客户 、2:现有客户 、3:FICC客户 、4:现有客户(正式,无对应权限) 、5:现有客户(试用,无对应权限) 、6:现有客户(试用暂停) 、7:现有客户(冻结) 、8:现有客户(流失)?
  1001. CompanyIdType := 1
  1002. applyMethod := ""
  1003. if sellerItem != nil {
  1004. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  1005. if err != nil && err.Error() != utils.ErrNoRow() {
  1006. br.Msg = "获取信息失败"
  1007. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1008. return
  1009. }
  1010. if companyItem != nil && companyItem.CompanyId > 0 {
  1011. companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
  1012. if err != nil && err.Error() != utils.ErrNoRow() {
  1013. br.Msg = "获取信息失败"
  1014. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1015. return
  1016. }
  1017. if companyProduct != nil && companyProduct.IsSuspend == 1 {
  1018. CompanyIdType = 6
  1019. } else {
  1020. switch companyItem.Status {
  1021. case "正式":
  1022. CompanyIdType = 4
  1023. case "试用":
  1024. CompanyIdType = 5
  1025. case "冻结":
  1026. CompanyIdType = 7
  1027. case "流失":
  1028. CompanyIdType = 8
  1029. }
  1030. }
  1031. applyMethod = companyItem.Status + "客户申请"
  1032. if detailId > 0 {
  1033. if companyProduct != nil && companyProduct.IsSuspend == 1 {
  1034. applyMethod = "试用暂停客户"
  1035. } else {
  1036. if companyItem.Status == "正式" || companyItem.Status == "试用" {
  1037. applyMethod = companyItem.Status + "客户申请,无对应权限"
  1038. } else if companyItem.Status == "冻结" || companyItem.Status == "流失" {
  1039. applyMethod = companyItem.Status + "客户"
  1040. }
  1041. }
  1042. applyMethod = applyMethod + "," + title
  1043. }
  1044. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  1045. if openIpItem != nil && openIpItem.OpenId != "" {
  1046. if req.ApplyMethod != 2 {
  1047. req.RealName = user.RealName
  1048. req.CompanyName = user.CompanyName
  1049. }
  1050. //go services.SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, mobile, applyMethod, openIpItem)
  1051. }
  1052. }
  1053. } else {
  1054. //获取销售信息
  1055. sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
  1056. if err != nil && err.Error() != utils.ErrNoRow() {
  1057. br.Msg = "申请失败"
  1058. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1059. return
  1060. }
  1061. if sellerItem != nil {
  1062. CompanyIdType = 3
  1063. applyMethod = "FICC客户"
  1064. } else {
  1065. CompanyIdType = 1
  1066. applyMethod = "潜在客户"
  1067. }
  1068. if detailId > 0 {
  1069. applyMethod = applyMethod + "," + title
  1070. }
  1071. }
  1072. //如果对应销售不存在就给王芳,汪洋推模版消息
  1073. item := new(models.CygxApplyRecord)
  1074. item.UserId = user.UserId
  1075. item.BusinessCardUrl = req.BusinessCardUrl
  1076. item.RealName = req.RealName
  1077. item.CompanyName = req.CompanyName
  1078. item.Mobile = user.Mobile
  1079. item.CreateTime = time.Now()
  1080. item.ApplyMethod = req.ApplyMethod
  1081. item.CompanyIdPay = user.CompanyId
  1082. item.CompanyNamePay = user.CompanyName
  1083. item.CompanyIdType = CompanyIdType
  1084. if user.InviteCompany == utils.LUODING_CODE && user.CompanyId == 1 {
  1085. //如果是潜在客户就标记来源
  1086. item.InviteCompanySource = 2
  1087. }
  1088. item.RegisterPlatform = utils.REGISTER_PLATFORM
  1089. err = models.AddApplyRecord(item)
  1090. if err != nil {
  1091. br.Msg = "申请失败"
  1092. br.ErrMsg = "申请失败,Err:" + err.Error()
  1093. return
  1094. }
  1095. if sellerItem == nil {
  1096. go services.SendPermissionApplyTemplateMsgAdmin(req, mobile, applyMethod, isResearch)
  1097. } else {
  1098. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  1099. if openIpItem != nil && openIpItem.OpenId != "" {
  1100. go services.SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, mobile, applyMethod, openIpItem)
  1101. }
  1102. }
  1103. //添加成功后,设置5分钟缓存,不允许重复添加
  1104. //utils.Rc.SetNX(cacheKey, user.Mobile, time.Second*60)
  1105. br.Msg = "申请成功!"
  1106. br.Ret = 200
  1107. br.Success = true
  1108. br.Data = sellerMobile
  1109. }
  1110. // @Title 是否需要填写区号
  1111. // @Description 获取是否需要填写区号接口
  1112. // @Success 200 {object} models.CountryCode
  1113. // @router /countryCcode/isNeedAdd [get]
  1114. func (this *UserController) CountryCcode() {
  1115. br := new(models.BaseResponse).Init()
  1116. defer func() {
  1117. this.Data["json"] = br
  1118. this.ServeJSON()
  1119. }()
  1120. user := this.User
  1121. uid := user.UserId
  1122. if user == nil {
  1123. br.Msg = "请登录"
  1124. br.ErrMsg = "请登录,用户信息为空"
  1125. br.Ret = 408
  1126. return
  1127. }
  1128. //if uid == 0 {
  1129. // br.Msg = "请登录"
  1130. // br.ErrMsg = "请登录,用户信息为空"
  1131. // br.Ret = 408
  1132. // return
  1133. //}
  1134. resp := new(models.CountryCode)
  1135. if user.CountryCode == "" && len(user.Mobile) >= 11 {
  1136. err := models.ChangeUserOutboundMobileByMobile(uid)
  1137. if err != nil {
  1138. br.Msg = "操作失败"
  1139. br.ErrMsg = "操作失败,Err:" + err.Error()
  1140. return
  1141. }
  1142. }
  1143. if user.CountryCode == "" && user.Mobile != "" && len(user.Mobile) < 11 {
  1144. resp.IsNeedAddCountryCode = true
  1145. }
  1146. if user.OutboundMobile != "" {
  1147. resp.IsNeedAddCountryCode = false
  1148. }
  1149. br.Ret = 200
  1150. br.Success = true
  1151. br.Msg = "获取成功"
  1152. br.Data = resp
  1153. }
  1154. // @Title 上传用户区号
  1155. // @Description 上传用户区号接口
  1156. // @Param request body models.CountryCodeItem true "type json string"
  1157. // @Success Ret=200 新增成功
  1158. // @router /countryCcode/Add [POST]
  1159. func (this *UserController) AddCountryCcode() {
  1160. br := new(models.BaseResponse).Init()
  1161. defer func() {
  1162. this.Data["json"] = br
  1163. this.ServeJSON()
  1164. }()
  1165. user := this.User
  1166. if user == nil {
  1167. br.Msg = "请登录"
  1168. br.ErrMsg = "请登录,用户信息为空"
  1169. br.Ret = 408
  1170. return
  1171. }
  1172. var req models.CountryCodeItem
  1173. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1174. if err != nil {
  1175. br.Msg = "参数解析异常!"
  1176. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1177. return
  1178. }
  1179. err = models.AddCountryCode(req.CountryCode, user)
  1180. if err != nil {
  1181. br.Msg = "获取信息失败"
  1182. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1183. return
  1184. }
  1185. br.Ret = 200
  1186. br.Success = true
  1187. br.Msg = "新增成功"
  1188. }
  1189. // @Title 用户修改外呼手机号以及区号
  1190. // @Description 用户修改外呼手机号以及区号接口
  1191. // @Param request body models.OutboundMobileItem true "type json string"
  1192. // @Success Ret=200 操作成功
  1193. // @router /countryCcode/addOutboundMobile [POST]
  1194. func (this *UserController) AddOutboundMobile() {
  1195. br := new(models.BaseResponse).Init()
  1196. defer func() {
  1197. this.Data["json"] = br
  1198. this.ServeJSON()
  1199. }()
  1200. user := this.User
  1201. uid := user.UserId
  1202. if user == nil {
  1203. br.Msg = "请登录"
  1204. br.ErrMsg = "请登录,用户信息为空"
  1205. br.Ret = 408
  1206. return
  1207. }
  1208. var req models.OutboundMobileItem
  1209. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1210. if err != nil {
  1211. br.Msg = "参数解析异常!"
  1212. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1213. return
  1214. }
  1215. if !utils.ValidateFixedTelephoneFormatatEasy(req.OutboundMobile) {
  1216. br.Msg = "号码格式有误,请重新填写!"
  1217. br.ErrMsg = "号码格式有误,请重新填写" + req.OutboundMobile
  1218. return
  1219. }
  1220. if req.OutboundMobile == "" {
  1221. br.Msg = "请填写区号!"
  1222. return
  1223. }
  1224. item := new(models.OutboundMobileItem)
  1225. item.OutboundMobile = req.OutboundMobile
  1226. item.OutboundCountryCode = req.OutboundCountryCode
  1227. item.ActivityId = req.ActivityId
  1228. if req.ActivityId == 0 {
  1229. err = models.AddOutboundMobile(item, uid)
  1230. } else {
  1231. if user.Mobile == "" && user.OutboundMobile == "" {
  1232. items := new(models.CygxActivitySignup)
  1233. items.UserId = uid
  1234. items.ActivityId = req.ActivityId
  1235. items.CreateTime = time.Now()
  1236. items.Mobile = user.Mobile
  1237. items.Email = user.Email
  1238. items.CompanyId = user.CompanyId
  1239. items.CompanyName = user.CompanyName
  1240. items.SignupType = 1
  1241. items.FailType = 0
  1242. items.DoFailType = 0
  1243. items.OutboundMobile = req.OutboundMobile
  1244. items.CountryCode = req.OutboundCountryCode
  1245. _, err = models.AddActivitySignupFromEmail(items)
  1246. } else {
  1247. total, err := models.GetActivityCountByIdWithUid(item.ActivityId, uid)
  1248. if total == 0 {
  1249. br.Msg = "报名信息不存在"
  1250. br.ErrMsg = "报名信息不存在,Err:" + "活动ActivityId:" + strconv.Itoa(item.ActivityId) + "用户Uid:" + strconv.Itoa(uid)
  1251. return
  1252. }
  1253. if err != nil {
  1254. br.Msg = "操作失败"
  1255. br.ErrMsg = "操作失败,Err:" + err.Error()
  1256. return
  1257. }
  1258. err = models.AddOutboundMobile(item, uid)
  1259. }
  1260. }
  1261. if err != nil {
  1262. br.Msg = "操作失败"
  1263. br.ErrMsg = "操作失败,Err:" + err.Error()
  1264. return
  1265. }
  1266. br.Ret = 200
  1267. br.Success = true
  1268. br.Msg = "操作成功"
  1269. }
  1270. // @Title 获取我的提问
  1271. // @Description 获取我的提问列表
  1272. // @Success 200 {object} models.CygxAskListResp
  1273. // @router /ask/list [get]
  1274. func (this *UserController) AskList() {
  1275. br := new(models.BaseResponse).Init()
  1276. defer func() {
  1277. this.Data["json"] = br
  1278. this.ServeJSON()
  1279. }()
  1280. user := this.User
  1281. if user == nil {
  1282. br.Msg = "请登录"
  1283. br.ErrMsg = "请登录,用户信息为空"
  1284. br.Ret = 408
  1285. return
  1286. }
  1287. userId := this.User.UserId
  1288. listActcivity, err := models.GetActivityAskList(userId)
  1289. if err != nil && err.Error() != utils.ErrNoRow() {
  1290. br.Msg = "获取失败"
  1291. br.ErrMsg = "获取活动问题失败,Err:" + err.Error()
  1292. return
  1293. }
  1294. for _, v := range listActcivity {
  1295. v.AskType = "Activity"
  1296. }
  1297. listArticle, err := models.GetArticleAskList(userId)
  1298. if err != nil && err.Error() != utils.ErrNoRow() {
  1299. br.Msg = "获取失败"
  1300. br.ErrMsg = "获取文章问题失败,Err:" + err.Error()
  1301. return
  1302. }
  1303. for _, v := range listArticle {
  1304. v.AskType = "Report"
  1305. listActcivity = append(listActcivity, v)
  1306. }
  1307. resp := new(models.CygxAskListResp)
  1308. resp.List = listActcivity
  1309. br.Msg = "获取成功!"
  1310. br.Ret = 200
  1311. br.Success = true
  1312. br.Data = resp
  1313. }
  1314. // @Title 是否展示免费试用按钮
  1315. // @Description 获取是否展示免费试用按钮接口
  1316. // @Param request body models.IsShow true "type json string"
  1317. // @Success 200
  1318. // @router /isShow/freeButton [get]
  1319. func (this *UserController) IsShow() {
  1320. br := new(models.BaseResponse).Init()
  1321. defer func() {
  1322. this.Data["json"] = br
  1323. this.ServeJSON()
  1324. }()
  1325. user := this.User
  1326. if user == nil {
  1327. br.Msg = "请重新登录"
  1328. br.Ret = 408
  1329. return
  1330. }
  1331. var resp models.IsShow
  1332. detail, err := models.GetConfigByCode("free_trial_card")
  1333. if err != nil {
  1334. br.Msg = "获取数据失败"
  1335. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  1336. return
  1337. }
  1338. companyDetail, err := models.GetCompanyDetailByIdGroup(user.CompanyId)
  1339. if err != nil && err.Error() != utils.ErrNoRow() {
  1340. br.Msg = "获取数据失败!"
  1341. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1342. return
  1343. }
  1344. count, err := models.CountCygxUserFreeeButton(user.UserId)
  1345. if err != nil && err.Error() != utils.ErrNoRow() {
  1346. br.Msg = "获取数据失败!"
  1347. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1348. return
  1349. }
  1350. if companyDetail != nil && companyDetail.IsSuspend == 0 {
  1351. if detail.ConfigValue == "1" && (companyDetail.Status == "正式" || companyDetail.Status == "试用" || companyDetail.Status == "永续") && count == 0 {
  1352. resp.IsShow = true
  1353. }
  1354. }
  1355. br.Ret = 200
  1356. br.Success = true
  1357. br.Data = resp
  1358. }
  1359. // @Title 隐藏当天的按钮
  1360. // @Description 隐藏当天的按钮接口
  1361. // @Success 200
  1362. // @router /freeButton/update [post]
  1363. func (this *UserController) FreeButtonUpdate() {
  1364. br := new(models.BaseResponse).Init()
  1365. defer func() {
  1366. this.Data["json"] = br
  1367. this.ServeJSON()
  1368. }()
  1369. user := this.User
  1370. if user == nil {
  1371. br.Msg = "请重新登录"
  1372. br.Ret = 408
  1373. return
  1374. }
  1375. count, err := models.CountCygxUserFreeeButtonByUser(user.UserId)
  1376. if err != nil {
  1377. br.Msg = "获取数据失败!"
  1378. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1379. return
  1380. }
  1381. if count == 0 {
  1382. item := new(models.CygxUserFreeeButton)
  1383. item.UserId = user.UserId
  1384. item.CompanyId = user.CompanyId
  1385. item.CreateTime = time.Now()
  1386. item.ModifyTime = time.Now()
  1387. item.EffectiveTime = time.Now().Format(utils.FormatDate)
  1388. _, err := models.AddCygxUserFreeeButton(item)
  1389. if err != nil {
  1390. br.Msg = "操作失败!"
  1391. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1392. return
  1393. }
  1394. } else {
  1395. err := models.UpdateCygxUserFreeeButton(user.UserId)
  1396. if err != nil {
  1397. br.Msg = "操作失败!"
  1398. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  1399. return
  1400. }
  1401. }
  1402. br.Ret = 200
  1403. br.Success = true
  1404. br.Msg = "操作成功!"
  1405. }
  1406. // @Title 权限弹窗是否展示免费月卡
  1407. // @Description 获取权限弹窗是否展示免费月卡接口
  1408. // @Param request body models.IsShow true "type json string"
  1409. // @Success 200
  1410. // @router /isShow/alert [get]
  1411. func (this *UserController) AlertIsShow() {
  1412. br := new(models.BaseResponse).Init()
  1413. defer func() {
  1414. this.Data["json"] = br
  1415. this.ServeJSON()
  1416. }()
  1417. user := this.User
  1418. if user == nil {
  1419. br.Msg = "请重新登录"
  1420. br.Ret = 408
  1421. return
  1422. }
  1423. var resp models.IsShow
  1424. detail, err := models.GetConfigByCode("free_trial_card")
  1425. if err != nil {
  1426. br.Msg = "获取数据失败"
  1427. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  1428. return
  1429. }
  1430. if user.CompanyId == 1 && detail.ConfigValue == "1" {
  1431. resp.IsShow = true
  1432. }
  1433. br.Ret = 200
  1434. br.Success = true
  1435. br.Data = resp
  1436. }
  1437. // @Title 分享的时候是否展示免费月卡
  1438. // @Description 获取权限弹窗是否展示免费月卡接口
  1439. // @Param request body models.IsShow true "type json string"
  1440. // @Success 200
  1441. // @router /isShow/share [get]
  1442. func (this *UserController) ShareIsShow() {
  1443. br := new(models.BaseResponse).Init()
  1444. defer func() {
  1445. this.Data["json"] = br
  1446. this.ServeJSON()
  1447. }()
  1448. user := this.User
  1449. if user == nil {
  1450. br.Msg = "请重新登录"
  1451. br.Ret = 408
  1452. return
  1453. }
  1454. var resp models.IsShow
  1455. detail, err := models.GetConfigByCode("free_trial_card")
  1456. if err != nil {
  1457. br.Msg = "获取数据失败"
  1458. br.ErrMsg = "城市配置信息失败,Err:" + err.Error()
  1459. return
  1460. }
  1461. if user.CompanyId != 16 && detail.ConfigValue == "1" {
  1462. resp.IsShow = true
  1463. }
  1464. resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
  1465. br.Ret = 200
  1466. br.Success = true
  1467. br.Data = resp
  1468. }
  1469. // @Title 更改用户微信头像
  1470. // @Description 更改用户微信头像
  1471. // @Param request body models.Headimgurl true "type json string"
  1472. // @Success 200 {object} models.ArticleDetailFileLink
  1473. // @router /headimgurl/update [post]
  1474. func (this *UserController) HeadimgurlUpdate() {
  1475. br := new(models.BaseResponse).Init()
  1476. defer func() {
  1477. this.Data["json"] = br
  1478. this.ServeJSON()
  1479. }()
  1480. user := this.User
  1481. if user == nil {
  1482. br.Msg = "请登录"
  1483. br.ErrMsg = "请登录,用户信息为空"
  1484. br.Ret = 408
  1485. return
  1486. }
  1487. var req models.Headimgurl
  1488. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1489. if err != nil {
  1490. br.Msg = "参数解析异常!"
  1491. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1492. return
  1493. }
  1494. uid := user.UserId
  1495. headimgurl := req.Headimgurl
  1496. if headimgurl == "" {
  1497. br.Msg = "操作失败"
  1498. br.ErrMsg = "头像信息不能为空"
  1499. return
  1500. }
  1501. err = models.UpdateUserHeadimgurl(headimgurl, uid)
  1502. if err != nil {
  1503. br.Msg = "操作失败"
  1504. br.ErrMsg = "头像信息不能为空"
  1505. }
  1506. br.Ret = 200
  1507. br.Success = true
  1508. br.Msg = "操作成功"
  1509. }
  1510. // @Title 登录 (无需token)
  1511. // @Description 登录接口 (无需token)
  1512. // @Param request body models.LoginReq true "type json string"
  1513. // @Success 200 {object} models.LoginResp
  1514. // @router /loginPublic [post]
  1515. func (this *UserCommonController) LoginPublic() {
  1516. br := new(models.BaseResponse).Init()
  1517. defer func() {
  1518. this.Data["json"] = br
  1519. this.ServeJSON()
  1520. }()
  1521. var req models.LoginReq
  1522. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1523. if err != nil {
  1524. br.Msg = "参数解析异常!"
  1525. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1526. return
  1527. }
  1528. mobile := strings.Trim(req.Mobile, " ")
  1529. if req.Mobile == "" {
  1530. br.Msg = "参数错误"
  1531. br.ErrMsg = "参数错误,手机号为空 为空"
  1532. return
  1533. }
  1534. item, err := models.GetMsgCode(req.Mobile, req.VCode)
  1535. if err != nil {
  1536. if err.Error() == utils.ErrNoRow() {
  1537. br.Msg = "验证码错误,请重新输入"
  1538. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  1539. return
  1540. } else {
  1541. br.Msg = "验证码错误,请重新输入"
  1542. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  1543. return
  1544. }
  1545. }
  1546. if item == nil {
  1547. br.Msg = "验证码错误,请重新输入"
  1548. return
  1549. }
  1550. if len(req.Mobile) >= 11 && req.CountryCode == "" {
  1551. req.CountryCode = "86"
  1552. }
  1553. var token string
  1554. tokenItem, err := models.GetSessionMobileTokenByOpenId(mobile)
  1555. if err != nil && err.Error() != utils.ErrNoRow() {
  1556. br.Msg = "登录失败"
  1557. br.ErrMsg = "登录失败,获取token失败:" + err.Error()
  1558. return
  1559. }
  1560. if tokenItem == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
  1561. timeUnix := time.Now().Unix()
  1562. timeUnixStr := strconv.FormatInt(timeUnix, 10)
  1563. token = utils.MD5(mobile) + utils.MD5(timeUnixStr)
  1564. //新增session
  1565. {
  1566. session := new(models.CygxSessionMobile)
  1567. session.Mobile = mobile
  1568. session.CreatedTime = time.Now()
  1569. session.LastUpdatedTime = time.Now()
  1570. session.ExpireTime = time.Now().AddDate(0, 1, 0)
  1571. session.AccessToken = token
  1572. err = models.AddCygxSessionMobile(session)
  1573. if err != nil {
  1574. br.Msg = "登录失败"
  1575. br.ErrMsg = "登录失败,新增用户session信息失败:" + err.Error()
  1576. return
  1577. }
  1578. }
  1579. } else {
  1580. token = tokenItem.AccessToken
  1581. }
  1582. resp := new(models.LoginResp)
  1583. resp.Authorization = token
  1584. br.Ret = 200
  1585. br.Success = true
  1586. br.Data = resp
  1587. br.Msg = "登录成功"
  1588. }
  1589. // @Title 获取我的留言
  1590. // @Description 获取我的留言列表
  1591. // @Success 200 {object} models.CygxCommentListResp
  1592. // @router /comment/list [get]
  1593. func (this *UserController) CommnetList() {
  1594. br := new(models.BaseResponse).Init()
  1595. defer func() {
  1596. this.Data["json"] = br
  1597. this.ServeJSON()
  1598. }()
  1599. user := this.User
  1600. if user == nil {
  1601. br.Msg = "请登录"
  1602. br.ErrMsg = "请登录,用户信息为空"
  1603. br.Ret = 408
  1604. return
  1605. }
  1606. userId := this.User.UserId
  1607. commentlist, err := models.GetCommentList(userId)
  1608. if err != nil && err.Error() != utils.ErrNoRow() {
  1609. br.Msg = "获取失败"
  1610. br.ErrMsg = "获取我的留言列表失败,Err:" + err.Error()
  1611. return
  1612. }
  1613. articleLyjhMap, _ := services.GetLyjhArticleMap()
  1614. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)
  1615. resp := new(models.CygxCommentListResp)
  1616. for _, comment := range commentlist {
  1617. item := models.CygxArticleCommentResp{
  1618. Id: comment.Id,
  1619. UserId: comment.UserId,
  1620. ArticleId: comment.ArticleId,
  1621. IndustryId: comment.IndustryId,
  1622. ActivityId: comment.ActivityId,
  1623. CreateTime: comment.CreateTime,
  1624. Mobile: comment.Mobile,
  1625. Email: comment.Email,
  1626. CompanyId: comment.CompanyId,
  1627. CompanyName: comment.CompanyName,
  1628. Content: comment.Content,
  1629. Title: comment.Title,
  1630. }
  1631. if comment.ArticleId > 0 {
  1632. item.RedirectType = 1
  1633. } else if comment.IndustryId > 0 {
  1634. item.RedirectType = 3
  1635. } else if comment.ActivityId > 0 {
  1636. item.RedirectType = 2
  1637. }
  1638. item.IsCollect = articleCollectMap[comment.ArticleId]
  1639. item.IsRoadShow = articleLyjhMap[comment.ArticleId]
  1640. resp.List = append(resp.List, &item)
  1641. }
  1642. br.Msg = "获取成功!"
  1643. br.Ret = 200
  1644. br.Success = true
  1645. br.Data = resp
  1646. }
  1647. // @Title 获取我的收藏
  1648. // @Description 获取我的收藏列表
  1649. // @Success 200 {object} models.ArticleCollectListResp
  1650. // @router /collect/list/microRoadshow [get]
  1651. func (this *UserController) MicroRoadshowCollectList() {
  1652. br := new(models.BaseResponse).Init()
  1653. defer func() {
  1654. this.Data["json"] = br
  1655. this.ServeJSON()
  1656. }()
  1657. userId := this.User.UserId
  1658. list, err := models.GetUserMicroRoadshowCollectList(userId)
  1659. if err != nil {
  1660. br.Msg = "获取数据失败"
  1661. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1662. return
  1663. }
  1664. resp := new(models.MicroRoadshowCollectList)
  1665. var audioIds []string
  1666. var videoIds []string
  1667. var activityVideoIds []string
  1668. for _, item := range list {
  1669. if item.ActivityVoiceId > 0 {
  1670. audioIds = append(audioIds, strconv.Itoa(item.ActivityVoiceId))
  1671. } else if item.VideoId > 0 {
  1672. videoIds = append(videoIds, strconv.Itoa(item.VideoId))
  1673. } else if item.ActivityVideoId > 0 {
  1674. activityVideoIds = append(activityVideoIds, strconv.Itoa(item.ActivityVideoId))
  1675. }
  1676. }
  1677. resp.AudioIds = strings.Join(audioIds, ",")
  1678. resp.VideoIds = strings.Join(videoIds, ",")
  1679. resp.ActivityVideoIds = strings.Join(activityVideoIds, ",")
  1680. br.Msg = "获取成功!"
  1681. br.Ret = 200
  1682. br.Success = true
  1683. br.Data = resp
  1684. }
  1685. // @Title 新增埋点
  1686. // @Description 新增埋点接口
  1687. // @Success 200 "新增成功!"
  1688. // @router /tracking [get]
  1689. func (this *UserController) Tracking() {
  1690. br := new(models.BaseResponse).Init()
  1691. defer func() {
  1692. this.Data["json"] = br
  1693. this.ServeJSON()
  1694. }()
  1695. user := this.User
  1696. if user == nil {
  1697. br.Msg = "请登录"
  1698. br.ErrMsg = "请登录,用户信息为空"
  1699. br.Ret = 408
  1700. return
  1701. }
  1702. //item := new(models.CygxPageHistoryRecord)
  1703. //item.UserId = user.UserId
  1704. //item.CreateTime = time.Now()
  1705. //item.Mobile = user.Mobile
  1706. //item.Email = user.Email
  1707. //item.CompanyId = user.CompanyId
  1708. //item.CompanyName = user.CompanyName
  1709. //item.Router = this.Ctx.Request.RequestURI
  1710. //item.PageRouter = this.Ctx.Input.Query("PageRouter")
  1711. //
  1712. //go models.AddCygxPageHistoryRecord(item)
  1713. //
  1714. br.Msg = "新增成功!"
  1715. br.Ret = 200
  1716. br.Success = true
  1717. }
  1718. // @Title 未付费申请试用详情
  1719. // @Description 未付费申请试用详情接口
  1720. // @Param ApplyRecordId query int true "申请ID"
  1721. // @Success 200 {object} models.ArticleCollectListResp
  1722. // @Success 200
  1723. // @router /apply/detail [get]
  1724. func (this *UserController) ApplyDetail() {
  1725. br := new(models.BaseResponse).Init()
  1726. defer func() {
  1727. this.Data["json"] = br
  1728. this.ServeJSON()
  1729. }()
  1730. user := this.User
  1731. if user == nil {
  1732. br.Msg = "请登录"
  1733. br.ErrMsg = "请登录,SysUser Is Empty"
  1734. br.Ret = 408
  1735. return
  1736. }
  1737. resp := new(models.CygxApplyRecordDetialResp)
  1738. applyRecordId, _ := this.GetInt("ApplyRecordId")
  1739. detail, err := models.GetCygxApplyRecordById(applyRecordId)
  1740. if err != nil {
  1741. br.Msg = "获取数据失败"
  1742. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1743. return
  1744. }
  1745. switch detail.RegisterPlatform {
  1746. case 1:
  1747. detail.ApplicationSource = "小程序"
  1748. case 2:
  1749. detail.ApplicationSource = "网页版"
  1750. }
  1751. switch detail.InviteCompanySource {
  1752. case 2:
  1753. detail.ApplicationSource += "(络町)"
  1754. }
  1755. resp.Detail = detail
  1756. br.Msg = "申请成功!"
  1757. br.Ret = 200
  1758. br.Success = true
  1759. br.Data = resp
  1760. }