user.go 51 KB

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