user.go 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/services"
  7. "hongze/hongze_cygx/utils"
  8. "rdluck_tools/paging"
  9. "strconv"
  10. "strings"
  11. "time"
  12. )
  13. //用户
  14. type UserController struct {
  15. BaseAuthController
  16. }
  17. /*
  18. // @Title 登录
  19. // @Description 登录接口
  20. // @Param request body models.LoginReq true "type json string"
  21. // @Success 200 {object} models.LoginResp
  22. // @router /login [post]
  23. func (this *UserController) Login() {
  24. br := new(models.BaseResponse).Init()
  25. defer func() {
  26. this.Data["json"] = br
  27. this.ServeJSON()
  28. }()
  29. var req models.LoginReq
  30. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  31. if err != nil {
  32. br.Msg = "参数解析异常!"
  33. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  34. return
  35. }
  36. user := this.User
  37. if user == nil {
  38. br.Msg = "请登录"
  39. br.ErrMsg = "请登录"
  40. br.Ret = 408
  41. return
  42. }
  43. unionId := this.User.UnionId
  44. userId := this.User.UserId
  45. if unionId == "" {
  46. br.Msg = "参数错误"
  47. br.ErrMsg = "参数错误,unionId 为空"
  48. return
  49. }
  50. newUserId := 0
  51. if req.LoginType == 1 || req.LoginType == 3 {
  52. if req.Mobile == "" {
  53. br.Msg = "参数错误"
  54. br.ErrMsg = "参数错误,手机号为空 为空"
  55. return
  56. }
  57. if req.LoginType == 3 {
  58. item, err := models.GetMsgCode(req.Mobile, req.VCode)
  59. if err != nil {
  60. if err.Error() == utils.ErrNoRow() {
  61. br.Msg = "验证码错误,请重新输入"
  62. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  63. return
  64. } else {
  65. br.Msg = "验证码错误,请重新输入"
  66. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  67. return
  68. }
  69. }
  70. if item == nil {
  71. br.Msg = "验证码错误,请重新输入"
  72. return
  73. }
  74. }
  75. //BindMobile(openId, mobile string, userId, loginType int) (err error) {
  76. req.Mobile = strings.Trim(req.Mobile, " ")
  77. req.LoginType = 1
  78. newUserId, err = models.PcBindMobile(unionId, req.Mobile, userId, req.LoginType)
  79. } else if req.LoginType == 2 {
  80. if req.Email == "" {
  81. br.ErrMsg = "邮箱不能为空,请输入邮箱"
  82. br.Msg = "邮箱不能为空,请输入邮箱"
  83. return
  84. }
  85. if !utils.ValidateEmailFormatat(req.Email) {
  86. br.ErrMsg = "邮箱格式错误,请重新输入"
  87. br.Msg = "邮箱格式错误,请重新输入"
  88. return
  89. }
  90. item, err := models.GetMsgCode(req.Email, req.VCode)
  91. if err != nil {
  92. if err.Error() == utils.ErrNoRow() {
  93. br.Msg = "验证码错误,请重新输入"
  94. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  95. return
  96. } else {
  97. br.Msg = "验证码错误,请重新输入"
  98. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  99. return
  100. }
  101. }
  102. if item == nil {
  103. br.Msg = "验证码错误,请重新输入"
  104. return
  105. }
  106. newUserId, err = models.PcBindMobile(unionId, req.Email, userId, req.LoginType)
  107. } else {
  108. br.Msg = "无效的登录方式"
  109. br.ErrMsg = "无效的登录方式,Err:" + err.Error()
  110. return
  111. }
  112. var token string
  113. tokenItem, err := models.GetTokenByUid(newUserId)
  114. if err != nil && err.Error() != utils.ErrNoRow() {
  115. br.Msg = "登录失败"
  116. br.ErrMsg = "登录失败,获取token失败:" + err.Error()
  117. return
  118. }
  119. if tokenItem == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
  120. timeUnix := time.Now().Unix()
  121. timeUnixStr := strconv.FormatInt(timeUnix, 10)
  122. token = utils.MD5(strconv.Itoa(userId)) + utils.MD5(timeUnixStr)
  123. //新增session
  124. {
  125. session := new(models.CygxSession)
  126. session.OpenId = unionId
  127. session.UnionId = unionId
  128. session.UserId = userId
  129. session.CreatedTime = time.Now()
  130. session.LastUpdatedTime = time.Now()
  131. session.ExpireTime = time.Now().AddDate(0, 1, 0)
  132. session.AccessToken = token
  133. err = models.AddSession(session)
  134. if err != nil {
  135. br.Msg = "登录失败"
  136. br.ErrMsg = "登录失败,新增用户session信息失败:" + err.Error()
  137. return
  138. }
  139. }
  140. } else {
  141. token = tokenItem.AccessToken
  142. }
  143. //新增登录日志
  144. {
  145. loginLog := new(models.WxUserLog)
  146. loginLog.UserId = userId
  147. loginLog.OpenId = unionId
  148. loginLog.Mobile = req.Mobile
  149. loginLog.Email = req.Email
  150. loginLog.CreateTime = time.Now()
  151. loginLog.Handle = "wechat_user_login"
  152. loginLog.Remark = token
  153. go models.AddWxUserLog(loginLog)
  154. }
  155. resp := new(models.LoginResp)
  156. resp.UserId = newUserId
  157. resp.Authorization = token
  158. br.Ret = 200
  159. br.Success = true
  160. br.Data = resp
  161. br.Msg = "登录成功"
  162. }
  163. */
  164. // @Title 登录
  165. // @Description 登录接口
  166. // @Param request body models.LoginReq true "type json string"
  167. // @Success 200 {object} models.LoginResp
  168. // @router /login [post]
  169. func (this *UserController) Login() {
  170. br := new(models.BaseResponse).Init()
  171. defer func() {
  172. this.Data["json"] = br
  173. this.ServeJSON()
  174. }()
  175. var req models.LoginReq
  176. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  177. if err != nil {
  178. br.Msg = "参数解析异常!"
  179. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  180. return
  181. }
  182. user := this.User
  183. if user == nil {
  184. br.Msg = "请登录"
  185. br.ErrMsg = "请登录"
  186. br.Ret = 408
  187. return
  188. }
  189. unionId := this.User.UnionId
  190. openId := this.User.OpenId
  191. if unionId == "" {
  192. br.Msg = "参数错误"
  193. br.ErrMsg = "参数错误,unionId 为空"
  194. return
  195. }
  196. if req.LoginType == 1 || req.LoginType == 3 {
  197. if req.Mobile == "" {
  198. br.Msg = "参数错误"
  199. br.ErrMsg = "参数错误,手机号为空 为空"
  200. return
  201. }
  202. if req.LoginType == 3 {
  203. item, err := models.GetMsgCode(req.Mobile, req.VCode)
  204. if err != nil {
  205. if err.Error() == utils.ErrNoRow() {
  206. br.Msg = "验证码错误,请重新输入"
  207. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  208. return
  209. } else {
  210. br.Msg = "验证码错误,请重新输入"
  211. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  212. return
  213. }
  214. }
  215. if item == nil {
  216. br.Msg = "验证码错误,请重新输入"
  217. return
  218. }
  219. }
  220. req.Mobile = strings.Trim(req.Mobile, " ")
  221. } else if req.LoginType == 2 {
  222. if req.Email == "" {
  223. br.ErrMsg = "邮箱不能为空,请输入邮箱"
  224. br.Msg = "邮箱不能为空,请输入邮箱"
  225. return
  226. }
  227. if !utils.ValidateEmailFormatat(req.Email) {
  228. br.ErrMsg = "邮箱格式错误,请重新输入"
  229. br.Msg = "邮箱格式错误,请重新输入"
  230. return
  231. }
  232. item, err := models.GetMsgCode(req.Email, req.VCode)
  233. if err != nil {
  234. if err.Error() == utils.ErrNoRow() {
  235. br.Msg = "验证码错误,请重新输入"
  236. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  237. return
  238. } else {
  239. br.Msg = "验证码错误,请重新输入"
  240. br.ErrMsg = "校验验证码失败,Err:" + err.Error()
  241. return
  242. }
  243. }
  244. if item == nil {
  245. br.Msg = "验证码错误,请重新输入"
  246. return
  247. }
  248. } else {
  249. br.Msg = "无效的登录方式"
  250. br.ErrMsg = "无效的登录方式,Err:" + err.Error()
  251. return
  252. }
  253. user, err = services.BindWxUser(openId, req.Mobile, req.Email, req.CountryCode)
  254. userId := user.UserId
  255. var token string
  256. tokenItem, err := models.GetTokenByOpenId(openId)
  257. if err != nil && err.Error() != utils.ErrNoRow() {
  258. br.Msg = "登录失败"
  259. br.ErrMsg = "登录失败,获取token失败:" + err.Error()
  260. return
  261. }
  262. if tokenItem == nil || (err != nil && err.Error() == utils.ErrNoRow()) {
  263. timeUnix := time.Now().Unix()
  264. timeUnixStr := strconv.FormatInt(timeUnix, 10)
  265. token = utils.MD5(openId) + utils.MD5(timeUnixStr)
  266. //新增session
  267. {
  268. session := new(models.CygxSession)
  269. session.OpenId = unionId
  270. session.UnionId = unionId
  271. session.UserId = userId
  272. session.CreatedTime = time.Now()
  273. session.LastUpdatedTime = time.Now()
  274. session.ExpireTime = time.Now().AddDate(0, 1, 0)
  275. session.AccessToken = token
  276. err = models.AddSession(session)
  277. if err != nil {
  278. br.Msg = "登录失败"
  279. br.ErrMsg = "登录失败,新增用户session信息失败:" + err.Error()
  280. return
  281. }
  282. }
  283. } else {
  284. token = tokenItem.AccessToken
  285. }
  286. //新增登录日志
  287. {
  288. loginLog := new(models.WxUserLog)
  289. loginLog.UserId = userId
  290. loginLog.OpenId = unionId
  291. loginLog.Mobile = req.Mobile
  292. loginLog.Email = req.Email
  293. loginLog.CreateTime = time.Now()
  294. loginLog.Handle = "wechat_user_login"
  295. loginLog.Remark = token
  296. go models.AddWxUserLog(loginLog)
  297. }
  298. resp := new(models.LoginResp)
  299. resp.UserId = userId
  300. resp.Authorization = token
  301. br.Ret = 200
  302. br.Success = true
  303. br.Data = resp
  304. br.Msg = "登录成功"
  305. }
  306. // @Title 获取用户详情
  307. // @Description 获取用户详情接口
  308. // @Success 200 {object} models.UserDetail
  309. // @router /detail [get]
  310. func (this *UserController) Detail() {
  311. br := new(models.BaseResponse).Init()
  312. defer func() {
  313. this.Data["json"] = br
  314. this.ServeJSON()
  315. }()
  316. user := this.User
  317. if user == nil {
  318. br.Msg = "请登录"
  319. br.ErrMsg = "请登录,用户信息为空"
  320. br.Ret = 408
  321. return
  322. }
  323. uid := user.UserId
  324. fmt.Println("uid:", uid)
  325. var hasPermission int
  326. detail := new(models.UserDetail)
  327. if uid > 0 {
  328. var err error
  329. detail, err = models.GetUserDetailByUserId(uid)
  330. if err != nil && err.Error() != utils.ErrNoRow() {
  331. br.Msg = "获取信息失败"
  332. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  333. return
  334. }
  335. userRecord, _ := models.GetUserRecordByUserId(uid, utils.WxPlatform)
  336. if userRecord != nil {
  337. detail.NickName = userRecord.NickName
  338. detail.Headimgurl = userRecord.Headimgurl
  339. if detail.Headimgurl == "" {
  340. userRecord, _ = models.GetUserRecordByUserId(uid, 1)
  341. if userRecord != nil {
  342. detail.NickName = userRecord.NickName
  343. detail.Headimgurl = userRecord.Headimgurl
  344. }
  345. }
  346. }
  347. if user.CompanyId > 1 {
  348. companyItem, err := models.GetCompanyDetailAllById(user.CompanyId)
  349. if err != nil && err.Error() != utils.ErrNoRow() {
  350. br.Msg = "获取信息失败"
  351. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  352. return
  353. }
  354. if companyItem != nil && companyItem.CompanyId > 0 {
  355. detail.CompanyName = companyItem.CompanyName
  356. if companyItem.Status == "试用" || companyItem.Status == "永续" || companyItem.Status == "正式" {
  357. permissionStr, err := models.GetCompanyPermission(companyItem.CompanyId)
  358. if err != nil {
  359. br.Msg = "获取信息失败"
  360. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  361. return
  362. }
  363. detail.PermissionName = permissionStr
  364. } else {
  365. hasPermission = 1
  366. }
  367. detail.SellerName = companyItem.SellerName
  368. detail.SellerMobile = companyItem.Mobile
  369. } else {
  370. hasPermission = 1
  371. }
  372. } else {
  373. //判断是否已经申请过
  374. applyCount, err := models.GetApplyRecordCount(uid)
  375. if err != nil && err.Error() != utils.ErrNoRow() {
  376. br.Msg = "获取信息失败"
  377. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  378. return
  379. }
  380. if applyCount > 0 {
  381. hasPermission = 3
  382. } else {
  383. hasPermission = 2
  384. }
  385. detail.CompanyName = detail.Note
  386. }
  387. detail.HasPermission = hasPermission
  388. } else {
  389. ur, _ := models.GetUserRecordByOpenId(user.OpenId)
  390. if ur != nil {
  391. detail.NickName = ur.NickName
  392. detail.Email = ur.BindAccount
  393. detail.Mobile = ur.BindAccount
  394. detail.NickName = ur.NickName
  395. detail.Headimgurl = ur.Headimgurl
  396. }
  397. hasPermission = 2
  398. detail.HasPermission = hasPermission
  399. }
  400. br.Ret = 200
  401. br.Success = true
  402. br.Msg = "获取成功"
  403. br.Data = detail
  404. }
  405. // @Title 校验用户状态信息
  406. // @Description 校验用户状态信息
  407. // @Success 200 {object} models.CheckStatusResp
  408. // @router /check/status [get]
  409. func (this *UserController) CheckLogin() {
  410. br := new(models.BaseResponse).Init()
  411. defer func() {
  412. this.Data["json"] = br
  413. this.ServeJSON()
  414. }()
  415. user := this.User
  416. if user == nil {
  417. br.Msg = "请登录"
  418. br.ErrMsg = "请登录"
  419. br.Ret = 408
  420. return
  421. }
  422. uid := user.UserId
  423. resp := new(models.CheckStatusResp)
  424. if uid > 0 {
  425. //判断token是否过期
  426. userRecord, err := models.GetUserRecordByUserId(uid, utils.WxPlatform)
  427. if err != nil {
  428. br.Msg = "获取用户信息失败"
  429. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  430. return
  431. }
  432. permissionStr, err := models.GetCompanyPermission(user.CompanyId)
  433. if err != nil {
  434. br.Msg = "获取信息失败"
  435. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  436. return
  437. }
  438. resp.PermissionName = permissionStr
  439. if user.Mobile == "" && user.Email == "" {
  440. resp.IsBind = true
  441. }
  442. if userRecord.UnionId == "" {
  443. resp.IsAuth = true
  444. }
  445. } else {
  446. resp.IsBind = true
  447. if user.UnionId == "" {
  448. resp.IsAuth = true
  449. }
  450. resp.PermissionName = ""
  451. }
  452. br.Success = true
  453. br.Msg = "获取成功"
  454. br.Data = resp
  455. br.Ret = 200
  456. }
  457. //
  458. //// @Title 绑定手机号或邮箱
  459. //// @Description 绑定手机号或邮箱
  460. //// @Param request body models.WxGetPhoneNumberReq true "type json string"
  461. //// @Success 200 {object} models.WxGetPhoneNumberResp
  462. //// @router /bind [post]
  463. //func (this *WechatController) Bind() {
  464. // br := new(models.BaseResponse).Init()
  465. // defer func() {
  466. // this.Data["json"] = br
  467. // this.ServeJSON()
  468. // }()
  469. // var req models.WxGetPhoneNumberReq
  470. // err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  471. // if err != nil {
  472. // br.Msg = "参数解析异常!"
  473. // br.ErrMsg = "参数解析失败,Err:" + err.Error()
  474. // return
  475. // }
  476. // if req.EncryptedData == "" || req.Iv == "" {
  477. // br.Msg = "参数错误"
  478. // return
  479. // }
  480. // user := this.User
  481. // if user == nil {
  482. // br.Msg = "请登陆"
  483. // br.Ret = 408
  484. // return
  485. // }
  486. // sessionKey := user.SessionKey
  487. // wxMobile, err := weapp.DecryptMobile(sessionKey, req.EncryptedData, req.Iv)
  488. // if err != nil {
  489. // br.Msg = "解析用户手机号信息失败"
  490. // br.ErrMsg = "解析用户手机号信息失败,Err:" + err.Error()
  491. // return
  492. // }
  493. // err = models.ModifyUsersMobile(user.UserId, wxMobile.PurePhoneNumber)
  494. // if err != nil {
  495. // br.Msg = "获取失败"
  496. // br.ErrMsg = "获取失败,Err:" + err.Error()
  497. // return
  498. // }
  499. // resp := new(models.WxGetPhoneNumberResp)
  500. // resp.Authorization = this.Token
  501. // resp.PhoneNumber = wxMobile.PhoneNumber
  502. // resp.PurePhoneNumber = wxMobile.PurePhoneNumber
  503. // resp.CountryCode = wxMobile.CountryCode
  504. // br.Msg = "获取成功!"
  505. // br.Ret = 200
  506. // br.Success = true
  507. // br.Data = resp
  508. //}
  509. // @Title 获取我的收藏
  510. // @Description 获取我的收藏列表
  511. // @Param PageSize query int true "PageSize"
  512. // @Param CurrentIndex query int true "CurrentIndex"
  513. // @Success 200 {object} models.ArticleCollectListResp
  514. // @router /collect/list [get]
  515. func (this *UserController) CollectList() {
  516. br := new(models.BaseResponse).Init()
  517. defer func() {
  518. this.Data["json"] = br
  519. this.ServeJSON()
  520. }()
  521. userId := this.User.UserId
  522. var pageSize, currentIndex, startSize int
  523. pageSize, _ = this.GetInt("PageSize")
  524. currentIndex, _ = this.GetInt("CurrentIndex")
  525. if pageSize <= 0 {
  526. pageSize = utils.PageSize20
  527. }
  528. if currentIndex <= 0 {
  529. currentIndex = 1
  530. }
  531. startSize = utils.StartIndex(currentIndex, pageSize)
  532. total, err := models.GetArticleUserCollectCount(userId)
  533. if err != nil {
  534. br.Msg = "获取数据失败"
  535. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  536. return
  537. }
  538. list, err := models.GetArticleUserCollectList(startSize, pageSize, userId)
  539. if err != nil {
  540. br.Msg = "获取数据失败"
  541. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  542. return
  543. }
  544. var articleIds []string
  545. for _, v := range list {
  546. articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
  547. }
  548. articleIdStr := strings.Join(articleIds, ",")
  549. articleMap := make(map[int]*models.ArticleDetail)
  550. if articleIdStr != "" {
  551. articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
  552. if err != nil {
  553. br.Msg = "获取数据失败"
  554. br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
  555. return
  556. }
  557. for _, v := range articleList {
  558. if _, ok := articleMap[v.ArticleId]; !ok {
  559. articleMap[v.ArticleId] = v
  560. }
  561. }
  562. }
  563. lenList := len(list)
  564. for i := 0; i < lenList; i++ {
  565. item := list[i]
  566. article := articleMap[item.ArticleId]
  567. list[i].Title = article.Title
  568. list[i].TitleEn = article.TitleEn
  569. list[i].UpdateFrequency = article.UpdateFrequency
  570. list[i].CreateDate = article.CreateDate
  571. list[i].PublishDate = article.PublishDate
  572. list[i].Body, _ = services.GetReportContentTextSub(article.Body)
  573. list[i].Abstract = article.Abstract
  574. list[i].CategoryName = article.CategoryName
  575. list[i].SubCategoryName = article.SubCategoryName
  576. }
  577. page := paging.GetPaging(currentIndex, pageSize, total)
  578. resp := new(models.ArticleCollectListResp)
  579. resp.List = list
  580. resp.Paging = page
  581. br.Msg = "获取成功!"
  582. br.Ret = 200
  583. br.Success = true
  584. br.Data = resp
  585. }
  586. // @Title 获取申请访谈列表
  587. // @Description 获取申请访谈列表
  588. // @Param PageSize query int true "PageSize"
  589. // @Param CurrentIndex query int true "CurrentIndex"
  590. // @Success 200 {object} models.ArticleInterviewApplyListResp
  591. // @router /interview/apply/list [get]
  592. func (this *UserController) InterviewApplyList() {
  593. br := new(models.BaseResponse).Init()
  594. defer func() {
  595. this.Data["json"] = br
  596. this.ServeJSON()
  597. }()
  598. userId := this.User.UserId
  599. var pageSize, currentIndex, startSize int
  600. pageSize, _ = this.GetInt("PageSize")
  601. currentIndex, _ = this.GetInt("CurrentIndex")
  602. if pageSize <= 0 {
  603. pageSize = utils.PageSize20
  604. }
  605. if currentIndex <= 0 {
  606. currentIndex = 1
  607. }
  608. startSize = utils.StartIndex(currentIndex, pageSize)
  609. total, err := models.GetArticleUserInterviewApplyCount(userId)
  610. if err != nil {
  611. br.Msg = "获取数据失败"
  612. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  613. return
  614. }
  615. list, err := models.GetArticleUserInterviewApplyList(startSize, pageSize, userId)
  616. if err != nil {
  617. br.Msg = "获取数据失败"
  618. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  619. return
  620. }
  621. var articleIds []string
  622. for _, v := range list {
  623. articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
  624. }
  625. articleIdStr := strings.Join(articleIds, ",")
  626. articleMap := make(map[int]*models.ArticleDetail)
  627. if articleIdStr != "" {
  628. articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
  629. if err != nil {
  630. br.Msg = "获取数据失败"
  631. br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
  632. return
  633. }
  634. for _, v := range articleList {
  635. if _, ok := articleMap[v.ArticleId]; !ok {
  636. articleMap[v.ArticleId] = v
  637. }
  638. }
  639. }
  640. lenList := len(list)
  641. for i := 0; i < lenList; i++ {
  642. item := list[i]
  643. article := articleMap[item.ArticleId]
  644. bodySub, _ := services.GetReportContentTextSub(article.Body)
  645. list[i].Title = article.Title
  646. list[i].TitleEn = article.TitleEn
  647. list[i].UpdateFrequency = article.UpdateFrequency
  648. list[i].CreateDate = article.CreateDate
  649. list[i].PublishDate = article.PublishDate
  650. list[i].Body = bodySub
  651. list[i].Abstract = article.Abstract
  652. list[i].CategoryName = article.CategoryName
  653. list[i].SubCategoryName = article.SubCategoryName
  654. list[i].ExpertBackground = article.ExpertBackground
  655. list[i].ExpertNumber = article.ExpertNumber
  656. }
  657. page := paging.GetPaging(currentIndex, pageSize, total)
  658. resp := new(models.ArticleInterviewApplyListResp)
  659. resp.List = list
  660. resp.Paging = page
  661. br.Msg = "获取成功!"
  662. br.Ret = 200
  663. br.Success = true
  664. br.Data = resp
  665. }
  666. // @Title 获取浏览历史列表
  667. // @Description 获取浏览历史列表
  668. // @Param PageSize query int true "PageSize"
  669. // @Param CurrentIndex query int true "CurrentIndex"
  670. // @Success 200 {object} models.ArticleBrowseHistoryListResp
  671. // @router /browse/history/list [get]
  672. func (this *UserController) BrowseHistoryList() {
  673. br := new(models.BaseResponse).Init()
  674. defer func() {
  675. this.Data["json"] = br
  676. this.ServeJSON()
  677. }()
  678. userId := this.User.UserId
  679. var pageSize, currentIndex, startSize int
  680. pageSize, _ = this.GetInt("PageSize")
  681. currentIndex, _ = this.GetInt("CurrentIndex")
  682. if pageSize <= 0 {
  683. pageSize = utils.PageSize20
  684. }
  685. if currentIndex <= 0 {
  686. currentIndex = 1
  687. }
  688. startSize = utils.StartIndex(currentIndex, pageSize)
  689. endDate := time.Now().AddDate(0, -1, 0).Format(utils.FormatDate)
  690. total, err := models.GetArticleUserBrowseHistoryCount(userId, endDate)
  691. if err != nil {
  692. br.Msg = "获取数据失败"
  693. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  694. return
  695. }
  696. list, err := models.GetArticleUserBrowseHistoryList(startSize, pageSize, userId, endDate)
  697. if err != nil {
  698. br.Msg = "获取数据失败"
  699. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  700. return
  701. }
  702. var articleIds []string
  703. for _, v := range list {
  704. articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
  705. }
  706. articleIdStr := strings.Join(articleIds, ",")
  707. articleMap := make(map[int]*models.ArticleDetail)
  708. if articleIdStr != "" {
  709. articleList, err := models.GetArticleDetailByIdStr(articleIdStr)
  710. if err != nil {
  711. br.Msg = "获取数据失败"
  712. br.ErrMsg = "获取报告详情信息失败,Err:" + err.Error()
  713. return
  714. }
  715. for _, v := range articleList {
  716. if _, ok := articleMap[v.ArticleId]; !ok {
  717. articleMap[v.ArticleId] = v
  718. }
  719. }
  720. }
  721. lenList := len(list)
  722. for i := 0; i < lenList; i++ {
  723. item := list[i]
  724. article := articleMap[item.ArticleId]
  725. if article != nil {
  726. list[i].Title = article.Title
  727. list[i].TitleEn = article.TitleEn
  728. list[i].UpdateFrequency = article.UpdateFrequency
  729. list[i].CreateDate = article.CreateDate
  730. list[i].PublishDate = article.PublishDate
  731. list[i].Body, _ = services.GetReportContentTextSub(article.Body)
  732. list[i].Abstract = article.Abstract
  733. list[i].CategoryName = article.CategoryName
  734. list[i].SubCategoryName = article.SubCategoryName
  735. }
  736. }
  737. page := paging.GetPaging(currentIndex, pageSize, total)
  738. resp := new(models.ArticleBrowseHistoryListResp)
  739. resp.List = list
  740. resp.Paging = page
  741. br.Msg = "获取成功!"
  742. br.Ret = 200
  743. br.Success = true
  744. br.Data = resp
  745. }
  746. // @Title 未付费申请试用
  747. // @Description 未付费申请试用
  748. // @Param request body models.ApplyTryReq true "type json string"
  749. // @Success 200
  750. // @router /apply/try [post]
  751. func (this *UserController) ApplyTryOut() {
  752. br := new(models.BaseResponse).Init()
  753. defer func() {
  754. this.Data["json"] = br
  755. this.ServeJSON()
  756. }()
  757. user := this.User
  758. if user == nil {
  759. br.Msg = "请登录"
  760. br.ErrMsg = "请登录,SysUser Is Empty"
  761. br.Ret = 408
  762. return
  763. }
  764. mobile := user.Mobile
  765. var req models.ApplyTryReq
  766. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  767. if err != nil {
  768. br.Msg = "参数解析异常!"
  769. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  770. return
  771. }
  772. if req.RealName == "" {
  773. req.RealName = user.RealName
  774. }
  775. if req.CompanyName == "" {
  776. req.CompanyName = user.CompanyName
  777. }
  778. uid := user.UserId
  779. //缓存校验
  780. cacheKey := fmt.Sprint("xygx:apply_record:add:", uid)
  781. ttlTime := utils.Rc.GetRedisTTL(cacheKey)
  782. if ttlTime > 0 {
  783. br.Msg = "申请失败,申请过于频繁"
  784. br.ErrMsg = "申请失败,申请过于频繁"
  785. return
  786. }
  787. utils.Rc.SetNX(cacheKey, user.Mobile, time.Second*10)
  788. //判断是否已经申请过
  789. applyCount, err := models.GetApplyRecordCount(uid)
  790. if err != nil && err.Error() != utils.ErrNoRow() {
  791. br.Msg = "获取信息失败"
  792. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  793. return
  794. }
  795. if applyCount > 0 {
  796. br.Msg = "您已提交申请,请耐心等待。"
  797. br.IsSendEmail = false
  798. return
  799. }
  800. //判断是否存在申请
  801. var sellerMobile string
  802. if req.ApplyMethod == 2 {
  803. if req.BusinessCardUrl == "" {
  804. br.Msg = "请上传名片"
  805. return
  806. }
  807. if req.RealName == "" {
  808. br.Msg = "请输入姓名"
  809. return
  810. }
  811. if req.CompanyName == "" {
  812. br.Msg = "请输入公司名称"
  813. return
  814. }
  815. if req.BusinessCardUrl != "" && utils.RunMode == "release" {
  816. card, err := services.GetBusinessCard(req.BusinessCardUrl)
  817. if err != nil {
  818. br.Msg = "名片识别失败"
  819. br.ErrMsg = "名片识别失败,Err:" + err.Error()
  820. return
  821. }
  822. mobileStr := strings.Join(card.WordsResult.MOBILE, ",")
  823. isFlag := true
  824. if mobile != "" {
  825. if strings.Contains(mobileStr, mobile) || mobileStr == "" {
  826. isFlag = true
  827. } else {
  828. isFlag = false
  829. }
  830. }
  831. if !isFlag {
  832. //阿里云识别
  833. if utils.RunMode == "release" {
  834. aliyunResult, err := services.AliyunBusinessCard(req.BusinessCardUrl)
  835. if err != nil {
  836. br.Msg = "识别失败"
  837. br.ErrMsg = "识别失败,Err:" + err.Error()
  838. return
  839. }
  840. if !aliyunResult.Success {
  841. br.Msg = "识别失败"
  842. br.ErrMsg = "识别失败"
  843. return
  844. }
  845. mobileStr := strings.Join(aliyunResult.TelCell, ",")
  846. if mobile != "" {
  847. if strings.Contains(mobileStr, mobile) {
  848. isFlag = true
  849. } else {
  850. isFlag = false
  851. }
  852. }
  853. }
  854. }
  855. if !isFlag {
  856. br.Msg = "名片手机号与所填手机号不匹配,请重新填写"
  857. br.ErrMsg = "mobile:" + mobile
  858. return
  859. }
  860. }
  861. }
  862. //获取销售信息
  863. sellerItem, err := models.GetSellerByCompanyId(user.CompanyId)
  864. if err != nil && err.Error() != utils.ErrNoRow() {
  865. br.Msg = "申请失败"
  866. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  867. return
  868. }
  869. if sellerItem != nil {
  870. sellerMobile = sellerItem.Mobile
  871. //推送模板消息
  872. mobile := user.Mobile
  873. if mobile == "" {
  874. mobile = user.Email
  875. }
  876. }
  877. applyMethod := ""
  878. if req.ApplyMethod == 1 {
  879. applyMethod = "已有客户申请"
  880. } else {
  881. applyMethod = "潜在客户申请"
  882. }
  883. cnf, _ := models.GetConfigByCode("tpl_msg")
  884. if cnf != nil {
  885. openIpItem, _ := models.GetUserRecordByMobile(1, cnf.ConfigValue)
  886. if openIpItem != nil && openIpItem.OpenId != "" {
  887. fmt.Println("推送消息", req.RealName, req.CompanyName, mobile, openIpItem.OpenId, applyMethod)
  888. utils.FileLog.Info("推送消息 %s %s,%s,%s,%s", req.RealName, req.CompanyName, mobile, openIpItem.OpenId, applyMethod)
  889. go services.SendPermissionApplyTemplateMsg(req.RealName, req.CompanyName, mobile, openIpItem.OpenId, applyMethod)
  890. }
  891. }
  892. err = models.AddApplyRecord(&req, user.Mobile, user.CompanyName, uid, user.CompanyId)
  893. if err != nil {
  894. br.Msg = "申请失败"
  895. br.ErrMsg = "申请失败,Err:" + err.Error()
  896. return
  897. }
  898. //添加成功后,设置5分钟缓存,不允许重复添加
  899. //utils.Rc.SetNX(cacheKey, user.Mobile, time.Second*60)
  900. br.Msg = "申请成功!"
  901. br.Ret = 200
  902. br.Success = true
  903. br.Data = sellerMobile
  904. }
  905. func sentMsgToSeller() {
  906. }
  907. //func init() {
  908. // fmt.Println("start")
  909. // realName:="沈涛"
  910. // companyName:="弘则研究"
  911. // mobile:="18767183922"
  912. // openId:="oN0jD1eTfIAf68Y2n24RrvIGXFw4"
  913. // applyMethod:="xxx"
  914. // services.SendPermissionApplyTemplateMsg(realName, companyName, mobile, openId, applyMethod)
  915. // return
  916. // fmt.Println("end")
  917. //}
  918. // @Title 是否需要填写区号
  919. // @Description 获取是否需要填写区号接口
  920. // @Success 200 {object} models.CountryCode
  921. // @router /countryCcode/isNeedAdd [get]
  922. func (this *UserController) CountryCcode() {
  923. br := new(models.BaseResponse).Init()
  924. defer func() {
  925. this.Data["json"] = br
  926. this.ServeJSON()
  927. }()
  928. user := this.User
  929. uid := user.UserId
  930. if user == nil {
  931. br.Msg = "请登录"
  932. br.ErrMsg = "请登录,用户信息为空"
  933. br.Ret = 408
  934. return
  935. }
  936. if uid == 0 {
  937. br.Msg = "请登录"
  938. br.ErrMsg = "请登录,用户信息为空"
  939. br.Ret = 408
  940. return
  941. }
  942. resp := new(models.CountryCode)
  943. if user.CountryCode == "" && len(user.Mobile) >= 11 {
  944. err := models.ChangeUserOutboundMobileByMobile(uid)
  945. if err != nil {
  946. br.Msg = "操作失败"
  947. br.ErrMsg = "操作失败,Err:" + err.Error()
  948. return
  949. }
  950. }
  951. if user.CountryCode == "" && user.Mobile != "" && len(user.Mobile) < 11 {
  952. resp.IsNeedAddCountryCode = true
  953. }
  954. if user.OutboundMobile != "" {
  955. resp.IsNeedAddCountryCode = false
  956. }
  957. br.Ret = 200
  958. br.Success = true
  959. br.Msg = "获取成功"
  960. br.Data = resp
  961. }
  962. // @Title 上传用户区号
  963. // @Description 上传用户区号接口
  964. // @Param request body models.CountryCodeItem true "type json string"
  965. // @Success Ret=200 新增成功
  966. // @router /countryCcode/Add [POST]
  967. func (this *UserController) AddCountryCcode() {
  968. br := new(models.BaseResponse).Init()
  969. defer func() {
  970. this.Data["json"] = br
  971. this.ServeJSON()
  972. }()
  973. user := this.User
  974. if user == nil {
  975. br.Msg = "请登录"
  976. br.ErrMsg = "请登录,用户信息为空"
  977. br.Ret = 408
  978. return
  979. }
  980. var req models.CountryCodeItem
  981. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  982. if err != nil {
  983. br.Msg = "参数解析异常!"
  984. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  985. return
  986. }
  987. err = models.AddCountryCode(req.CountryCode, user)
  988. if err != nil {
  989. br.Msg = "获取信息失败"
  990. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  991. return
  992. }
  993. br.Ret = 200
  994. br.Success = true
  995. br.Msg = "新增成功"
  996. }
  997. //// @Title 是否需要填写外呼手机号
  998. //// @Description 获取是否需要填写外呼手机号接口
  999. //// @Success 200 {object} models.CountryCode
  1000. //// @router /countryCcode/isNeedAddOutbound [get]
  1001. //func (this *UserController) OutboundMobile() {
  1002. // br := new(models.BaseResponse).Init()
  1003. // defer func() {
  1004. // this.Data["json"] = br
  1005. // this.ServeJSON()
  1006. // }()
  1007. // user := this.User
  1008. // uid := user.UserId
  1009. // if user == nil {
  1010. // br.Msg = "请登录"
  1011. // br.ErrMsg = "请登录,用户信息为空"
  1012. // br.Ret = 408
  1013. // return
  1014. // }
  1015. // if uid == 0 {
  1016. // br.Msg = "请登录"
  1017. // br.ErrMsg = "请登录,用户信息为空"
  1018. // br.Ret = 408
  1019. // return
  1020. // }
  1021. // resp := new(models.OutboundMobile)
  1022. // if user.OutboundMobile == "" && user.CountryCode == "" {
  1023. // resp.IsNeedAddOutboundMobile = true
  1024. // }
  1025. // br.Ret = 200
  1026. // br.Success = true
  1027. // br.Msg = "获取成功"
  1028. // br.Data = resp
  1029. //}
  1030. // @Title 用户修改外呼手机号以及区号
  1031. // @Description 用户修改外呼手机号以及区号接口
  1032. // @Param request body models.OutboundMobileItem true "type json string"
  1033. // @Success Ret=200 操作成功
  1034. // @router /countryCcode/addOutboundMobile [POST]
  1035. func (this *UserController) AddOutboundMobile() {
  1036. br := new(models.BaseResponse).Init()
  1037. defer func() {
  1038. this.Data["json"] = br
  1039. this.ServeJSON()
  1040. }()
  1041. user := this.User
  1042. uid := user.UserId
  1043. if user == nil {
  1044. br.Msg = "请登录"
  1045. br.ErrMsg = "请登录,用户信息为空"
  1046. br.Ret = 408
  1047. return
  1048. }
  1049. var req models.OutboundMobileItem
  1050. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1051. if err != nil {
  1052. br.Msg = "参数解析异常!"
  1053. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1054. return
  1055. }
  1056. if !utils.ValidateFixedTelephoneFormatat(req.OutboundMobile) && !utils.ValidateMobileFormatat(req.OutboundMobile) {
  1057. br.Msg = "号码格式有误,请重新填写!"
  1058. br.ErrMsg = "号码格式有误,请重新填写" + req.OutboundMobile
  1059. return
  1060. }
  1061. if req.OutboundMobile == "" {
  1062. br.Msg = "请填写区号!"
  1063. return
  1064. }
  1065. item := new(models.OutboundMobileItem)
  1066. item.OutboundMobile = req.OutboundMobile
  1067. item.OutboundCountryCode = req.OutboundCountryCode
  1068. item.ActivityId = req.ActivityId
  1069. if req.ActivityId == 0 {
  1070. err = models.AddOutboundMobile(item, uid)
  1071. } else {
  1072. if user.Mobile == "" && user.OutboundMobile == "" {
  1073. items := new(models.CygxActivitySignup)
  1074. items.UserId = uid
  1075. items.ActivityId = req.ActivityId
  1076. items.CreateTime = time.Now()
  1077. items.Mobile = user.Mobile
  1078. items.Email = user.Email
  1079. items.CompanyId = user.CompanyId
  1080. items.CompanyName = user.CompanyName
  1081. items.SignupType = 1
  1082. items.FailType = 0
  1083. items.DoFailType = 0
  1084. items.OutboundMobile = req.OutboundMobile
  1085. items.CountryCode = req.OutboundCountryCode
  1086. _, err = models.AddActivitySignupFromEmail(items)
  1087. } else {
  1088. total, err := models.GetActivityCountByIdWithUid(item.ActivityId, uid)
  1089. if total == 0 {
  1090. br.Msg = "报名信息不存在"
  1091. br.ErrMsg = "报名信息不存在,Err:" + "活动ActivityId:" + strconv.Itoa(item.ActivityId) + "用户Uid:" + strconv.Itoa(uid)
  1092. return
  1093. }
  1094. if err != nil {
  1095. br.Msg = "操作失败"
  1096. br.ErrMsg = "操作失败,Err:" + err.Error()
  1097. return
  1098. }
  1099. err = models.AddOutboundMobile(item, uid)
  1100. }
  1101. }
  1102. if err != nil {
  1103. br.Msg = "操作失败"
  1104. br.ErrMsg = "操作失败,Err:" + err.Error()
  1105. return
  1106. }
  1107. br.Ret = 200
  1108. br.Success = true
  1109. br.Msg = "操作成功"
  1110. }
  1111. // @Title 白名单同步
  1112. // @Description 获取是否需要填写区号接口
  1113. // @Param Keypd query string false "搜索主题 多个用 , 隔开 (空为活动主题,非空为更多主题)"
  1114. // @Success 200 {object} models.CountryCode
  1115. // @router /whiteUser [get]
  1116. func (this *UserController) WhiteUser() {
  1117. br := new(models.BaseResponse).Init()
  1118. defer func() {
  1119. this.Data["json"] = br
  1120. this.ServeJSON()
  1121. }()
  1122. user := this.User
  1123. uid := user.UserId
  1124. if user == nil {
  1125. br.Msg = "请登录"
  1126. br.ErrMsg = "请登录,用户信息为空"
  1127. br.Ret = 408
  1128. return
  1129. }
  1130. if uid == 0 {
  1131. br.Msg = "请登录"
  1132. br.ErrMsg = "请登录,用户信息为空"
  1133. br.Ret = 408
  1134. return
  1135. }
  1136. keypd := this.GetString("Keypd")
  1137. if keypd != "888" {
  1138. br.Msg = "密码错误"
  1139. return
  1140. }
  1141. item := new(models.WxUserWhite)
  1142. fmt.Println(item)
  1143. var fieldStr string
  1144. var condition string
  1145. fieldStr = ` u.mobile,u.country_code,u.real_name,c.company_name,u.company_id,cp.seller_name,u.created_time,cp.status,`
  1146. condition = ` AND cp.status IN ( '正式', '试用' ) AND u.mobile != '' `
  1147. list1, err := models.GetFormalUserWhiteList(fieldStr, condition)
  1148. if err != nil {
  1149. br.Msg = "获取失败,Err:" + err.Error()
  1150. return
  1151. }
  1152. fieldStr = ` u.outbound_mobile as mobile,u.outbound_country_code as country_code,u.real_name,c.company_name,u.company_id,u.created_time,cp.status,`
  1153. condition = ` AND u.mobile != u.outbound_mobile AND cp.status IN ( '正式', '试用' ) AND u.outbound_mobile != '' `
  1154. list2, err := models.GetFormalUserWhiteList(fieldStr, condition)
  1155. if err != nil {
  1156. br.Msg = "获取失败,Err:" + err.Error()
  1157. return
  1158. }
  1159. fmt.Println(len(list1))
  1160. for k, v := range list1 {
  1161. item.Mobile = v.Mobile
  1162. item.CountryCode = v.CountryCode
  1163. item.CompanyName = v.CompanyName
  1164. item.PermissionName = v.Permission
  1165. item.CreatedTime = time.Now()
  1166. item.UserCreatedTime = v.CreatedTime
  1167. item.RealName = v.RealName
  1168. item.SellerName = v.SellerName
  1169. item.Status = v.Status
  1170. _, err := models.AddWxUserWhite(item)
  1171. if err != nil {
  1172. br.Msg = "获取失败,Err:" + err.Error()
  1173. return
  1174. }
  1175. fmt.Println(k)
  1176. }
  1177. item = new(models.WxUserWhite)
  1178. fmt.Println(len(list2))
  1179. for _, v := range list2 {
  1180. item.OutboundMobile = v.Mobile
  1181. item.OutboundCountryCode = v.CountryCode
  1182. item.CreatedTime = time.Now()
  1183. item.CompanyName = v.CompanyName
  1184. item.PermissionName = v.Permission
  1185. item.UserCreatedTime = v.CreatedTime
  1186. item.RealName = v.RealName
  1187. item.SellerName = v.SellerName
  1188. item.Status = v.Status
  1189. _, err := models.AddWxUserWhite(item)
  1190. if err != nil {
  1191. br.Msg = "获取失败,Err:" + err.Error()
  1192. return
  1193. }
  1194. }
  1195. br.Ret = 200
  1196. br.Success = true
  1197. br.Msg = "获取成功"
  1198. }