user.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "hongze/hongze_cygx/models"
  5. "hongze/hongze_cygx/services"
  6. "hongze/hongze_cygx/utils"
  7. "rdluck_tools/paging"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. //用户
  13. type UserController struct {
  14. BaseAuthController
  15. }
  16. // @Title 登录
  17. // @Description 登录接口
  18. // @Param request body models.LoginReq true "type json string"
  19. // @Success 200 {object} models.LoginResp
  20. // @router /login [post]
  21. func (this *UserController) Login() {
  22. br := new(models.BaseResponse).Init()
  23. defer func() {
  24. this.Data["json"] = br
  25. this.ServeJSON()
  26. }()
  27. var req models.LoginReq
  28. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  29. if err != nil {
  30. br.Msg = "参数解析异常!"
  31. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  32. return
  33. }
  34. user := this.User
  35. if user == nil {
  36. br.Msg = "请登录"
  37. br.ErrMsg = "请登录"
  38. br.Ret = 408
  39. return
  40. }
  41. unionId := this.User.UnionId
  42. userId := this.User.UserId
  43. if unionId == "" {
  44. br.Msg = "参数错误"
  45. br.ErrMsg = "参数错误,unionId 为空"
  46. return
  47. }
  48. newUserId := 0
  49. if req.LoginType == 1 {
  50. //BindMobile(openId, mobile string, userId, loginType int) (err error) {
  51. req.Mobile = strings.Trim(req.Mobile, " ")
  52. newUserId, err = models.PcBindMobile(unionId, req.Mobile, userId, req.LoginType)
  53. } else if req.LoginType == 2 {
  54. if req.Email == "" {
  55. br.ErrMsg = "邮箱不能为空,请输入邮箱"
  56. br.Msg = "邮箱不能为空,请输入邮箱"
  57. return
  58. }
  59. if !utils.ValidateEmailFormatat(req.Email) {
  60. br.ErrMsg = "邮箱格式错误,请重新输入"
  61. br.Msg = "邮箱格式错误,请重新输入"
  62. return
  63. }
  64. newUserId, err = models.PcBindMobile(unionId, req.Email, userId, req.LoginType)
  65. } else {
  66. br.Msg = "无效的登录方式"
  67. br.ErrMsg = "无效的登录方式,Err:" + err.Error()
  68. return
  69. }
  70. var token string
  71. tokenItem, err := models.GetTokenByUid(newUserId)
  72. if err != nil && err.Error() != utils.ErrNoRow() {
  73. br.Msg = "登录失败"
  74. br.ErrMsg = "登录失败,获取token失败:" + err.Error()
  75. return
  76. }
  77. if tokenItem == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
  78. timeUnix := time.Now().Unix()
  79. timeUnixStr := strconv.FormatInt(timeUnix, 10)
  80. token = utils.MD5(strconv.Itoa(userId)) + utils.MD5(timeUnixStr)
  81. //新增session
  82. {
  83. session := new(models.CygxSession)
  84. session.OpenId = unionId
  85. session.UnionId = unionId
  86. session.UserId = userId
  87. session.CreatedTime = time.Now()
  88. session.LastUpdatedTime = time.Now()
  89. session.ExpireTime = time.Now().AddDate(0, 1, 0)
  90. session.AccessToken = token
  91. err = models.AddSession(session)
  92. if err != nil {
  93. br.Msg = "登录失败"
  94. br.ErrMsg = "登录失败,新增用户session信息失败:" + err.Error()
  95. return
  96. }
  97. }
  98. } else {
  99. token = tokenItem.AccessToken
  100. }
  101. //新增登录日志
  102. {
  103. loginLog := new(models.WxUserLog)
  104. loginLog.UserId = userId
  105. loginLog.OpenId = unionId
  106. loginLog.Mobile = req.Mobile
  107. loginLog.Email = req.Email
  108. loginLog.CreateTime = time.Now()
  109. loginLog.Handle = "wechat_user_login"
  110. loginLog.Remark = token
  111. go models.AddWxUserLog(loginLog)
  112. }
  113. resp := new(models.LoginResp)
  114. resp.UserId = newUserId
  115. resp.Authorization = token
  116. br.Ret = 200
  117. br.Success = true
  118. br.Data = resp
  119. br.Msg = "登录成功"
  120. }
  121. // @Title 获取用户详情
  122. // @Description 获取用户详情接口
  123. // @Success 200 {object} models.UserDetail
  124. // @router /detail [get]
  125. func (this *UserController) Detail() {
  126. br := new(models.BaseResponse).Init()
  127. defer func() {
  128. this.Data["json"] = br
  129. this.ServeJSON()
  130. }()
  131. user := this.User
  132. if user == nil {
  133. br.Msg = "请登录"
  134. br.ErrMsg = "请登录,用户信息为空"
  135. br.Ret = 408
  136. return
  137. }
  138. uid := user.UserId
  139. item, err := models.GetUserDetailByUserId(uid)
  140. if err != nil {
  141. br.Msg = "获取信息失败"
  142. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  143. return
  144. }
  145. var hasPermission int
  146. if user.CompanyId > 0 {
  147. companyItem, err := models.GetCompanyDetailById(user.CompanyId)
  148. if err != nil && err.Error() != utils.ErrNoRow() {
  149. br.Msg = "获取信息失败"
  150. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  151. return
  152. }
  153. if companyItem != nil {
  154. item.CompanyName = companyItem.CompanyName
  155. if companyItem.Status == "试用" || companyItem.Status == "永续" || companyItem.Status == "正式" {
  156. permissionStr, err := models.GetCompanyPermission(companyItem.CompanyId)
  157. if err != nil {
  158. br.Msg = "获取信息失败"
  159. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  160. return
  161. }
  162. item.PermissionName = permissionStr
  163. }else{
  164. hasPermission = 1
  165. }
  166. item.SellerName = companyItem.SellerName
  167. item.SellerMobile = companyItem.Mobile
  168. }
  169. } else {
  170. //判断是否已经申请过
  171. applyCount, err := models.GetApplyRecordCount(uid)
  172. if err != nil && err.Error() != utils.ErrNoRow() {
  173. br.Msg = "获取信息失败"
  174. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  175. return
  176. }
  177. if applyCount > 0 {
  178. hasPermission = 3
  179. } else {
  180. hasPermission = 2
  181. }
  182. }
  183. item.HasPermission=hasPermission
  184. br.Ret = 200
  185. br.Success = true
  186. br.Msg = "获取成功"
  187. br.Data = item
  188. }
  189. // @Title 校验用户状态信息
  190. // @Description 校验用户状态信息
  191. // @Success 200 {object} models.CheckStatusResp
  192. // @router /check/status [get]
  193. func (this *UserController) CheckLogin() {
  194. br := new(models.BaseResponse).Init()
  195. defer func() {
  196. this.Data["json"] = br
  197. this.ServeJSON()
  198. }()
  199. if this.User == nil {
  200. br.Msg = "请登录"
  201. br.ErrMsg = "请登录"
  202. br.Ret = 408
  203. return
  204. }
  205. uid := this.User.UserId
  206. //判断token是否过期
  207. userItem, err := models.GetWxUserItemByUserId(uid)
  208. if err != nil {
  209. br.Msg = "获取用户信息失败"
  210. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  211. return
  212. }
  213. resp := new(models.CheckStatusResp)
  214. permissionStr, err := models.GetCompanyPermission(userItem.CompanyId)
  215. if err != nil {
  216. br.Msg = "获取信息失败"
  217. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  218. return
  219. }
  220. resp.PermissionName = permissionStr
  221. if userItem.Mobile == "" && userItem.Email == "" {
  222. resp.IsBind = true
  223. }
  224. if userItem.UnionId == "" {
  225. resp.IsAuth = true
  226. }
  227. br.Success = true
  228. br.Msg = "获取成功"
  229. br.Data = resp
  230. br.Ret = 200
  231. }
  232. //
  233. //// @Title 绑定手机号或邮箱
  234. //// @Description 绑定手机号或邮箱
  235. //// @Param request body models.WxGetPhoneNumberReq true "type json string"
  236. //// @Success 200 {object} models.WxGetPhoneNumberResp
  237. //// @router /bind [post]
  238. //func (this *WechatController) Bind() {
  239. // br := new(models.BaseResponse).Init()
  240. // defer func() {
  241. // this.Data["json"] = br
  242. // this.ServeJSON()
  243. // }()
  244. // var req models.WxGetPhoneNumberReq
  245. // err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  246. // if err != nil {
  247. // br.Msg = "参数解析异常!"
  248. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  249. // return
  250. // }
  251. // if req.EncryptedData == "" || req.Iv == "" {
  252. // br.Msg = "参数错误"
  253. // return
  254. // }
  255. // user := this.User
  256. // if user == nil {
  257. // br.Msg = "请登陆"
  258. // br.Ret = 408
  259. // return
  260. // }
  261. // sessionKey := user.SessionKey
  262. // wxMobile, err := weapp.DecryptMobile(sessionKey, req.EncryptedData, req.Iv)
  263. // if err != nil {
  264. // br.Msg = "解析用户手机号信息失败"
  265. // br.ErrMsg = "解析用户手机号信息失败,Err:" + err.Error()
  266. // return
  267. // }
  268. // err = models.ModifyUsersMobile(user.UserId, wxMobile.PurePhoneNumber)
  269. // if err != nil {
  270. // br.Msg = "获取失败"
  271. // br.ErrMsg = "获取失败,Err:" + err.Error()
  272. // return
  273. // }
  274. // resp := new(models.WxGetPhoneNumberResp)
  275. // resp.Authorization = this.Token
  276. // resp.PhoneNumber = wxMobile.PhoneNumber
  277. // resp.PurePhoneNumber = wxMobile.PurePhoneNumber
  278. // resp.CountryCode = wxMobile.CountryCode
  279. // br.Msg = "获取成功!"
  280. // br.Ret = 200
  281. // br.Success = true
  282. // br.Data = resp
  283. //}
  284. // @Title 获取我的收藏
  285. // @Description 获取我的收藏列表
  286. // @Param PageSize query int true "PageSize"
  287. // @Param CurrentIndex query int true "CurrentIndex"
  288. // @Success 200 {object} models.ArticleCollectListResp
  289. // @router /collect/list [get]
  290. func (this *UserController) CollectList() {
  291. br := new(models.BaseResponse).Init()
  292. defer func() {
  293. this.Data["json"] = br
  294. this.ServeJSON()
  295. }()
  296. userId := this.User.UserId
  297. var pageSize, currentIndex, startSize int
  298. pageSize, _ = this.GetInt("PageSize")
  299. currentIndex, _ = this.GetInt("CurrentIndex")
  300. if pageSize <= 0 {
  301. pageSize = utils.PageSize20
  302. }
  303. if currentIndex <= 0 {
  304. currentIndex = 1
  305. }
  306. startSize = utils.StartIndex(currentIndex, pageSize)
  307. total, err := models.GetArticleUserCollectCount(userId)
  308. if err != nil {
  309. br.Msg = "获取数据失败"
  310. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  311. return
  312. }
  313. list, err := models.GetArticleUserCollectList(startSize, pageSize, userId)
  314. if err != nil {
  315. br.Msg = "获取数据失败"
  316. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  317. return
  318. }
  319. var articleIds []string
  320. for _, v := range list {
  321. articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
  322. }
  323. articleIdStr := strings.Join(articleIds, ",")
  324. articleMap := make(map[int]*models.ArticleDetail)
  325. if articleIdStr != "" {
  326. articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
  327. if err != nil {
  328. br.Msg = "获取数据失败"
  329. br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
  330. return
  331. }
  332. for _, v := range articleList {
  333. if _, ok := articleMap[v.ArticleId]; !ok {
  334. articleMap[v.ArticleId] = v
  335. }
  336. }
  337. }
  338. lenList := len(list)
  339. for i := 0; i < lenList; i++ {
  340. item := list[i]
  341. article := articleMap[item.ArticleId]
  342. list[i].Title = article.Title
  343. list[i].TitleEn = article.TitleEn
  344. list[i].UpdateFrequency = article.UpdateFrequency
  345. list[i].CreateDate = article.CreateDate
  346. list[i].PublishDate = article.PublishDate
  347. list[i].Body, _ = services.GetReportContentTextSub(article.Body)
  348. list[i].Abstract = article.Abstract
  349. list[i].CategoryName = article.CategoryName
  350. list[i].SubCategoryName = article.SubCategoryName
  351. }
  352. page := paging.GetPaging(currentIndex, pageSize, total)
  353. resp := new(models.ArticleCollectListResp)
  354. resp.List = list
  355. resp.Paging = page
  356. br.Msg = "获取成功!"
  357. br.Ret = 200
  358. br.Success = true
  359. br.Data = resp
  360. }
  361. // @Title 获取申请访谈列表
  362. // @Description 获取申请访谈列表
  363. // @Param PageSize query int true "PageSize"
  364. // @Param CurrentIndex query int true "CurrentIndex"
  365. // @Success 200 {object} models.ArticleInterviewApplyListResp
  366. // @router /interview/apply/list [get]
  367. func (this *UserController) InterviewApplyList() {
  368. br := new(models.BaseResponse).Init()
  369. defer func() {
  370. this.Data["json"] = br
  371. this.ServeJSON()
  372. }()
  373. userId := this.User.UserId
  374. var pageSize, currentIndex, startSize int
  375. pageSize, _ = this.GetInt("PageSize")
  376. currentIndex, _ = this.GetInt("CurrentIndex")
  377. if pageSize <= 0 {
  378. pageSize = utils.PageSize20
  379. }
  380. if currentIndex <= 0 {
  381. currentIndex = 1
  382. }
  383. startSize = utils.StartIndex(currentIndex, pageSize)
  384. total, err := models.GetArticleUserInterviewApplyCount(userId)
  385. if err != nil {
  386. br.Msg = "获取数据失败"
  387. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  388. return
  389. }
  390. list, err := models.GetArticleUserInterviewApplyList(startSize, pageSize, userId)
  391. if err != nil {
  392. br.Msg = "获取数据失败"
  393. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  394. return
  395. }
  396. var articleIds []string
  397. for _, v := range list {
  398. articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
  399. }
  400. articleIdStr := strings.Join(articleIds, ",")
  401. articleMap := make(map[int]*models.ArticleDetail)
  402. if articleIdStr != "" {
  403. articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
  404. if err != nil {
  405. br.Msg = "获取数据失败"
  406. br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
  407. return
  408. }
  409. for _, v := range articleList {
  410. if _, ok := articleMap[v.ArticleId]; !ok {
  411. articleMap[v.ArticleId] = v
  412. }
  413. }
  414. }
  415. lenList := len(list)
  416. for i := 0; i < lenList; i++ {
  417. item := list[i]
  418. article := articleMap[item.ArticleId]
  419. list[i].Title = article.Title
  420. list[i].TitleEn = article.TitleEn
  421. list[i].UpdateFrequency = article.UpdateFrequency
  422. list[i].CreateDate = article.CreateDate
  423. list[i].PublishDate = article.PublishDate
  424. list[i].Body, _ = services.GetReportContentTextSub(article.Body)
  425. list[i].Abstract = article.Abstract
  426. list[i].CategoryName = article.CategoryName
  427. list[i].SubCategoryName = article.SubCategoryName
  428. }
  429. page := paging.GetPaging(currentIndex, pageSize, total)
  430. resp := new(models.ArticleInterviewApplyListResp)
  431. resp.List = list
  432. resp.Paging = page
  433. br.Msg = "获取成功!"
  434. br.Ret = 200
  435. br.Success = true
  436. br.Data = resp
  437. }
  438. // @Title 获取浏览历史列表
  439. // @Description 获取浏览历史列表
  440. // @Param PageSize query int true "PageSize"
  441. // @Param CurrentIndex query int true "CurrentIndex"
  442. // @Success 200 {object} models.ArticleBrowseHistoryListResp
  443. // @router /browse/history/list [get]
  444. func (this *UserController) BrowseHistoryList() {
  445. br := new(models.BaseResponse).Init()
  446. defer func() {
  447. this.Data["json"] = br
  448. this.ServeJSON()
  449. }()
  450. userId := this.User.UserId
  451. var pageSize, currentIndex, startSize int
  452. pageSize, _ = this.GetInt("PageSize")
  453. currentIndex, _ = this.GetInt("CurrentIndex")
  454. if pageSize <= 0 {
  455. pageSize = utils.PageSize20
  456. }
  457. if currentIndex <= 0 {
  458. currentIndex = 1
  459. }
  460. startSize = utils.StartIndex(currentIndex, pageSize)
  461. endDate := time.Now().AddDate(0, -1, 0).Format(utils.FormatDate)
  462. total, err := models.GetArticleUserBrowseHistoryCount(userId, endDate)
  463. if err != nil {
  464. br.Msg = "获取数据失败"
  465. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  466. return
  467. }
  468. list, err := models.GetArticleUserBrowseHistoryList(startSize, pageSize, userId, endDate)
  469. if err != nil {
  470. br.Msg = "获取数据失败"
  471. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  472. return
  473. }
  474. var articleIds []string
  475. for _, v := range list {
  476. articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
  477. }
  478. articleIdStr := strings.Join(articleIds, ",")
  479. articleMap := make(map[int]*models.ArticleDetail)
  480. if articleIdStr != "" {
  481. articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
  482. if err != nil {
  483. br.Msg = "获取数据失败"
  484. br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
  485. return
  486. }
  487. for _, v := range articleList {
  488. if _, ok := articleMap[v.ArticleId]; !ok {
  489. articleMap[v.ArticleId] = v
  490. }
  491. }
  492. }
  493. lenList := len(list)
  494. for i := 0; i < lenList; i++ {
  495. item := list[i]
  496. article := articleMap[item.ArticleId]
  497. if article != nil {
  498. list[i].Title = article.Title
  499. list[i].TitleEn = article.TitleEn
  500. list[i].UpdateFrequency = article.UpdateFrequency
  501. list[i].CreateDate = article.CreateDate
  502. list[i].PublishDate = article.PublishDate
  503. list[i].Body, _ = services.GetReportContentTextSub(article.Body)
  504. list[i].Abstract = article.Abstract
  505. list[i].CategoryName = article.CategoryName
  506. list[i].SubCategoryName = article.SubCategoryName
  507. }
  508. }
  509. page := paging.GetPaging(currentIndex, pageSize, total)
  510. resp := new(models.ArticleBrowseHistoryListResp)
  511. resp.List = list
  512. resp.Paging = page
  513. br.Msg = "获取成功!"
  514. br.Ret = 200
  515. br.Success = true
  516. br.Data = resp
  517. }
  518. // @Title 未付费申请试用
  519. // @Description 未付费申请试用
  520. // @Param request body models.ApplyTryReq true "type json string"
  521. // @Success 200
  522. // @router /apply/try [post]
  523. func (this *UserController) ApplyTryOut() {
  524. br := new(models.BaseResponse).Init()
  525. defer func() {
  526. this.Data["json"] = br
  527. this.ServeJSON()
  528. }()
  529. user := this.User
  530. if user == nil {
  531. br.Msg = "请登录"
  532. br.ErrMsg = "请登录,SysUser Is Empty"
  533. br.Ret = 408
  534. return
  535. }
  536. mobile := user.Mobile
  537. var req models.ApplyTryReq
  538. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  539. if err != nil {
  540. br.Msg = "参数解析异常!"
  541. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  542. return
  543. }
  544. //判断是否存在申请
  545. var sellerMobile string
  546. if req.ApplyMethod == 2 {
  547. if req.BusinessCardUrl == "" {
  548. br.Msg = "请上传名片"
  549. return
  550. }
  551. if req.RealName == "" {
  552. br.Msg = "请输入姓名"
  553. return
  554. }
  555. if req.CompanyName == "" {
  556. br.Msg = "请输入公司名称"
  557. return
  558. }
  559. if req.BusinessCardUrl != "" && utils.RunMode == "release" {
  560. card, err := services.GetBusinessCard(req.BusinessCardUrl)
  561. if err != nil {
  562. br.Msg = "名片识别失败"
  563. br.ErrMsg = "名片识别失败,Err:" + err.Error()
  564. return
  565. }
  566. mobileStr := strings.Join(card.WordsResult.MOBILE, ",")
  567. isFlag := true
  568. if mobile != "" {
  569. if strings.Contains(mobileStr, mobile) || mobileStr == "" {
  570. isFlag = true
  571. } else {
  572. isFlag = false
  573. }
  574. }
  575. if !isFlag {
  576. //阿里云识别
  577. if utils.RunMode == "release" {
  578. aliyunResult, err := services.AliyunBusinessCard(req.BusinessCardUrl)
  579. if err != nil {
  580. br.Msg = "识别失败"
  581. br.ErrMsg = "识别失败,Err:" + err.Error()
  582. return
  583. }
  584. if !aliyunResult.Success {
  585. br.Msg = "识别失败"
  586. br.ErrMsg = "识别失败"
  587. return
  588. }
  589. mobileStr := strings.Join(aliyunResult.TelCell, ",")
  590. if mobile != "" {
  591. if strings.Contains(mobileStr, mobile) {
  592. isFlag = true
  593. } else {
  594. isFlag = false
  595. }
  596. }
  597. }
  598. }
  599. if !isFlag {
  600. br.Msg = "名片手机号与所填手机号不匹配,请重新填写"
  601. br.ErrMsg = "mobile:" + mobile
  602. return
  603. }
  604. }
  605. } else {
  606. //获取销售信息
  607. sellerItem, err := models.GetSellerByCompanyId(user.CompanyId)
  608. if err != nil {
  609. br.Msg = "申请失败"
  610. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  611. return
  612. }
  613. sellerMobile = sellerItem.Mobile
  614. }
  615. err = models.AddApplyRecord(&req, user.Mobile, user.CompanyName, user.UserId, user.CompanyId)
  616. if err != nil {
  617. br.Msg = "申请失败"
  618. br.ErrMsg = "申请失败,Err:" + err.Error()
  619. return
  620. }
  621. br.Msg = "申请成功!"
  622. br.Ret = 200
  623. br.Success = true
  624. br.Data = sellerMobile
  625. }