user.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  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. hasPermission = 1
  157. permissionStr, err := models.GetCompanyPermission(companyItem.CompanyId)
  158. if err != nil {
  159. br.Msg = "获取信息失败"
  160. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  161. return
  162. }
  163. item.PermissionName = permissionStr
  164. }
  165. item.SellerName = companyItem.SellerName
  166. item.SellerMobile = companyItem.Mobile
  167. }
  168. } else {
  169. //判断是否已经申请过
  170. applyCount, err := models.GetApplyRecordCount(uid)
  171. if err != nil && err.Error() != utils.ErrNoRow() {
  172. br.Msg = "获取信息失败"
  173. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  174. return
  175. }
  176. if applyCount > 0 {
  177. hasPermission = 3
  178. } else {
  179. hasPermission = 2
  180. }
  181. }
  182. item.HasPermission=hasPermission
  183. br.Ret = 200
  184. br.Success = true
  185. br.Msg = "获取成功"
  186. br.Data = item
  187. }
  188. // @Title 校验用户状态信息
  189. // @Description 校验用户状态信息
  190. // @Success 200 {object} models.CheckStatusResp
  191. // @router /check/status [get]
  192. func (this *UserController) CheckLogin() {
  193. br := new(models.BaseResponse).Init()
  194. defer func() {
  195. this.Data["json"] = br
  196. this.ServeJSON()
  197. }()
  198. if this.User == nil {
  199. br.Msg = "请登录"
  200. br.ErrMsg = "请登录"
  201. br.Ret = 408
  202. return
  203. }
  204. uid := this.User.UserId
  205. //判断token是否过期
  206. userItem, err := models.GetWxUserItemByUserId(uid)
  207. if err != nil {
  208. br.Msg = "获取用户信息失败"
  209. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  210. return
  211. }
  212. resp := new(models.CheckStatusResp)
  213. permissionStr, err := models.GetCompanyPermission(userItem.CompanyId)
  214. if err != nil {
  215. br.Msg = "获取信息失败"
  216. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  217. return
  218. }
  219. resp.PermissionName = permissionStr
  220. if userItem.Mobile == "" && userItem.Email == "" {
  221. resp.IsBind = true
  222. }
  223. if userItem.UnionId == "" {
  224. resp.IsAuth = true
  225. }
  226. br.Success = true
  227. br.Msg = "获取成功"
  228. br.Data = resp
  229. br.Ret = 200
  230. }
  231. //
  232. //// @Title 绑定手机号或邮箱
  233. //// @Description 绑定手机号或邮箱
  234. //// @Param request body models.WxGetPhoneNumberReq true "type json string"
  235. //// @Success 200 {object} models.WxGetPhoneNumberResp
  236. //// @router /bind [post]
  237. //func (this *WechatController) Bind() {
  238. // br := new(models.BaseResponse).Init()
  239. // defer func() {
  240. // this.Data["json"] = br
  241. // this.ServeJSON()
  242. // }()
  243. // var req models.WxGetPhoneNumberReq
  244. // err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  245. // if err != nil {
  246. // br.Msg = "参数解析异常!"
  247. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  248. // return
  249. // }
  250. // if req.EncryptedData == "" || req.Iv == "" {
  251. // br.Msg = "参数错误"
  252. // return
  253. // }
  254. // user := this.User
  255. // if user == nil {
  256. // br.Msg = "请登陆"
  257. // br.Ret = 408
  258. // return
  259. // }
  260. // sessionKey := user.SessionKey
  261. // wxMobile, err := weapp.DecryptMobile(sessionKey, req.EncryptedData, req.Iv)
  262. // if err != nil {
  263. // br.Msg = "解析用户手机号信息失败"
  264. // br.ErrMsg = "解析用户手机号信息失败,Err:" + err.Error()
  265. // return
  266. // }
  267. // err = models.ModifyUsersMobile(user.UserId, wxMobile.PurePhoneNumber)
  268. // if err != nil {
  269. // br.Msg = "获取失败"
  270. // br.ErrMsg = "获取失败,Err:" + err.Error()
  271. // return
  272. // }
  273. // resp := new(models.WxGetPhoneNumberResp)
  274. // resp.Authorization = this.Token
  275. // resp.PhoneNumber = wxMobile.PhoneNumber
  276. // resp.PurePhoneNumber = wxMobile.PurePhoneNumber
  277. // resp.CountryCode = wxMobile.CountryCode
  278. // br.Msg = "获取成功!"
  279. // br.Ret = 200
  280. // br.Success = true
  281. // br.Data = resp
  282. //}
  283. // @Title 获取我的收藏
  284. // @Description 获取我的收藏列表
  285. // @Param PageSize query int true "PageSize"
  286. // @Param CurrentIndex query int true "CurrentIndex"
  287. // @Success 200 {object} models.ArticleCollectListResp
  288. // @router /collect/list [get]
  289. func (this *UserController) CollectList() {
  290. br := new(models.BaseResponse).Init()
  291. defer func() {
  292. this.Data["json"] = br
  293. this.ServeJSON()
  294. }()
  295. userId := this.User.UserId
  296. var pageSize, currentIndex, startSize int
  297. pageSize, _ = this.GetInt("PageSize")
  298. currentIndex, _ = this.GetInt("CurrentIndex")
  299. if pageSize <= 0 {
  300. pageSize = utils.PageSize20
  301. }
  302. if currentIndex <= 0 {
  303. currentIndex = 1
  304. }
  305. startSize = utils.StartIndex(currentIndex, pageSize)
  306. total, err := models.GetArticleUserCollectCount(userId)
  307. if err != nil {
  308. br.Msg = "获取数据失败"
  309. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  310. return
  311. }
  312. list, err := models.GetArticleUserCollectList(startSize, pageSize, userId)
  313. if err != nil {
  314. br.Msg = "获取数据失败"
  315. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  316. return
  317. }
  318. var articleIds []string
  319. for _, v := range list {
  320. articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
  321. }
  322. articleIdStr := strings.Join(articleIds, ",")
  323. articleMap := make(map[int]*models.ArticleDetail)
  324. if articleIdStr != "" {
  325. articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
  326. if err != nil {
  327. br.Msg = "获取数据失败"
  328. br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
  329. return
  330. }
  331. for _, v := range articleList {
  332. if _, ok := articleMap[v.ArticleId]; !ok {
  333. articleMap[v.ArticleId] = v
  334. }
  335. }
  336. }
  337. lenList := len(list)
  338. for i := 0; i < lenList; i++ {
  339. item := list[i]
  340. article := articleMap[item.ArticleId]
  341. list[i].Title = article.Title
  342. list[i].TitleEn = article.TitleEn
  343. list[i].UpdateFrequency = article.UpdateFrequency
  344. list[i].CreateDate = article.CreateDate
  345. list[i].PublishDate = article.PublishDate
  346. list[i].Body, _ = services.GetReportContentTextSub(article.Body)
  347. list[i].Abstract = article.Abstract
  348. list[i].CategoryName = article.CategoryName
  349. list[i].SubCategoryName = article.SubCategoryName
  350. }
  351. page := paging.GetPaging(currentIndex, pageSize, total)
  352. resp := new(models.ArticleCollectListResp)
  353. resp.List = list
  354. resp.Paging = page
  355. br.Msg = "获取成功!"
  356. br.Ret = 200
  357. br.Success = true
  358. br.Data = resp
  359. }
  360. // @Title 获取申请访谈列表
  361. // @Description 获取申请访谈列表
  362. // @Param PageSize query int true "PageSize"
  363. // @Param CurrentIndex query int true "CurrentIndex"
  364. // @Success 200 {object} models.ArticleInterviewApplyListResp
  365. // @router /interview/apply/list [get]
  366. func (this *UserController) InterviewApplyList() {
  367. br := new(models.BaseResponse).Init()
  368. defer func() {
  369. this.Data["json"] = br
  370. this.ServeJSON()
  371. }()
  372. userId := this.User.UserId
  373. var pageSize, currentIndex, startSize int
  374. pageSize, _ = this.GetInt("PageSize")
  375. currentIndex, _ = this.GetInt("CurrentIndex")
  376. if pageSize <= 0 {
  377. pageSize = utils.PageSize20
  378. }
  379. if currentIndex <= 0 {
  380. currentIndex = 1
  381. }
  382. startSize = utils.StartIndex(currentIndex, pageSize)
  383. total, err := models.GetArticleUserInterviewApplyCount(userId)
  384. if err != nil {
  385. br.Msg = "获取数据失败"
  386. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  387. return
  388. }
  389. list, err := models.GetArticleUserInterviewApplyList(startSize, pageSize, userId)
  390. if err != nil {
  391. br.Msg = "获取数据失败"
  392. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  393. return
  394. }
  395. var articleIds []string
  396. for _, v := range list {
  397. articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
  398. }
  399. articleIdStr := strings.Join(articleIds, ",")
  400. articleMap := make(map[int]*models.ArticleDetail)
  401. if articleIdStr != "" {
  402. articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
  403. if err != nil {
  404. br.Msg = "获取数据失败"
  405. br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
  406. return
  407. }
  408. for _, v := range articleList {
  409. if _, ok := articleMap[v.ArticleId]; !ok {
  410. articleMap[v.ArticleId] = v
  411. }
  412. }
  413. }
  414. lenList := len(list)
  415. for i := 0; i < lenList; i++ {
  416. item := list[i]
  417. article := articleMap[item.ArticleId]
  418. list[i].Title = article.Title
  419. list[i].TitleEn = article.TitleEn
  420. list[i].UpdateFrequency = article.UpdateFrequency
  421. list[i].CreateDate = article.CreateDate
  422. list[i].PublishDate = article.PublishDate
  423. list[i].Body, _ = services.GetReportContentTextSub(article.Body)
  424. list[i].Abstract = article.Abstract
  425. list[i].CategoryName = article.CategoryName
  426. list[i].SubCategoryName = article.SubCategoryName
  427. }
  428. page := paging.GetPaging(currentIndex, pageSize, total)
  429. resp := new(models.ArticleInterviewApplyListResp)
  430. resp.List = list
  431. resp.Paging = page
  432. br.Msg = "获取成功!"
  433. br.Ret = 200
  434. br.Success = true
  435. br.Data = resp
  436. }
  437. // @Title 获取浏览历史列表
  438. // @Description 获取浏览历史列表
  439. // @Param PageSize query int true "PageSize"
  440. // @Param CurrentIndex query int true "CurrentIndex"
  441. // @Success 200 {object} models.ArticleBrowseHistoryListResp
  442. // @router /browse/history/list [get]
  443. func (this *UserController) BrowseHistoryList() {
  444. br := new(models.BaseResponse).Init()
  445. defer func() {
  446. this.Data["json"] = br
  447. this.ServeJSON()
  448. }()
  449. userId := this.User.UserId
  450. var pageSize, currentIndex, startSize int
  451. pageSize, _ = this.GetInt("PageSize")
  452. currentIndex, _ = this.GetInt("CurrentIndex")
  453. if pageSize <= 0 {
  454. pageSize = utils.PageSize20
  455. }
  456. if currentIndex <= 0 {
  457. currentIndex = 1
  458. }
  459. startSize = utils.StartIndex(currentIndex, pageSize)
  460. endDate := time.Now().AddDate(0, -1, 0).Format(utils.FormatDate)
  461. total, err := models.GetArticleUserBrowseHistoryCount(userId, endDate)
  462. if err != nil {
  463. br.Msg = "获取数据失败"
  464. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  465. return
  466. }
  467. list, err := models.GetArticleUserBrowseHistoryList(startSize, pageSize, userId, endDate)
  468. if err != nil {
  469. br.Msg = "获取数据失败"
  470. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  471. return
  472. }
  473. var articleIds []string
  474. for _, v := range list {
  475. articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
  476. }
  477. articleIdStr := strings.Join(articleIds, ",")
  478. articleMap := make(map[int]*models.ArticleDetail)
  479. if articleIdStr != "" {
  480. articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
  481. if err != nil {
  482. br.Msg = "获取数据失败"
  483. br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
  484. return
  485. }
  486. for _, v := range articleList {
  487. if _, ok := articleMap[v.ArticleId]; !ok {
  488. articleMap[v.ArticleId] = v
  489. }
  490. }
  491. }
  492. lenList := len(list)
  493. for i := 0; i < lenList; i++ {
  494. item := list[i]
  495. article := articleMap[item.ArticleId]
  496. if article != nil {
  497. list[i].Title = article.Title
  498. list[i].TitleEn = article.TitleEn
  499. list[i].UpdateFrequency = article.UpdateFrequency
  500. list[i].CreateDate = article.CreateDate
  501. list[i].PublishDate = article.PublishDate
  502. list[i].Body, _ = services.GetReportContentTextSub(article.Body)
  503. list[i].Abstract = article.Abstract
  504. list[i].CategoryName = article.CategoryName
  505. list[i].SubCategoryName = article.SubCategoryName
  506. }
  507. }
  508. page := paging.GetPaging(currentIndex, pageSize, total)
  509. resp := new(models.ArticleBrowseHistoryListResp)
  510. resp.List = list
  511. resp.Paging = page
  512. br.Msg = "获取成功!"
  513. br.Ret = 200
  514. br.Success = true
  515. br.Data = resp
  516. }
  517. // @Title 未付费申请试用
  518. // @Description 未付费申请试用
  519. // @Param request body models.ApplyTryReq true "type json string"
  520. // @Success 200
  521. // @router /apply/try [post]
  522. func (this *UserController) ApplyTryOut() {
  523. br := new(models.BaseResponse).Init()
  524. defer func() {
  525. this.Data["json"] = br
  526. this.ServeJSON()
  527. }()
  528. user := this.User
  529. if user == nil {
  530. br.Msg = "请登录"
  531. br.ErrMsg = "请登录,SysUser Is Empty"
  532. br.Ret = 408
  533. return
  534. }
  535. mobile := user.Mobile
  536. var req models.ApplyTryReq
  537. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  538. if err != nil {
  539. br.Msg = "参数解析异常!"
  540. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  541. return
  542. }
  543. //判断是否存在申请
  544. var sellerMobile string
  545. if req.ApplyMethod == 2 {
  546. if req.BusinessCardUrl == "" {
  547. br.Msg = "请上传名片"
  548. return
  549. }
  550. if req.RealName == "" {
  551. br.Msg = "请输入姓名"
  552. return
  553. }
  554. if req.CompanyName == "" {
  555. br.Msg = "请输入公司名称"
  556. return
  557. }
  558. if req.BusinessCardUrl != "" && utils.RunMode == "release" {
  559. card, err := services.GetBusinessCard(req.BusinessCardUrl)
  560. if err != nil {
  561. br.Msg = "名片识别失败"
  562. br.ErrMsg = "名片识别失败,Err:" + err.Error()
  563. return
  564. }
  565. mobileStr := strings.Join(card.WordsResult.MOBILE, ",")
  566. isFlag := true
  567. if mobile != "" {
  568. if strings.Contains(mobileStr, mobile) || mobileStr == "" {
  569. isFlag = true
  570. } else {
  571. isFlag = false
  572. }
  573. }
  574. if !isFlag {
  575. //阿里云识别
  576. if utils.RunMode == "release" {
  577. aliyunResult, err := services.AliyunBusinessCard(req.BusinessCardUrl)
  578. if err != nil {
  579. br.Msg = "识别失败"
  580. br.ErrMsg = "识别失败,Err:" + err.Error()
  581. return
  582. }
  583. if !aliyunResult.Success {
  584. br.Msg = "识别失败"
  585. br.ErrMsg = "识别失败"
  586. return
  587. }
  588. mobileStr := strings.Join(aliyunResult.TelCell, ",")
  589. if mobile != "" {
  590. if strings.Contains(mobileStr, mobile) {
  591. isFlag = true
  592. } else {
  593. isFlag = false
  594. }
  595. }
  596. }
  597. }
  598. if !isFlag {
  599. br.Msg = "名片手机号与所填手机号不匹配,请重新填写"
  600. br.ErrMsg = "mobile:" + mobile
  601. return
  602. }
  603. }
  604. } else {
  605. //获取销售信息
  606. sellerItem, err := models.GetSellerByCompanyId(user.CompanyId)
  607. if err != nil {
  608. br.Msg = "申请失败"
  609. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  610. return
  611. }
  612. sellerMobile = sellerItem.Mobile
  613. }
  614. err = models.AddApplyRecord(&req, user.Mobile, user.CompanyName, user.UserId, user.CompanyId)
  615. if err != nil {
  616. br.Msg = "申请失败"
  617. br.ErrMsg = "申请失败,Err:" + err.Error()
  618. return
  619. }
  620. br.Msg = "申请成功!"
  621. br.Ret = 200
  622. br.Success = true
  623. br.Data = sellerMobile
  624. }