article.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  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. "html"
  9. "regexp"
  10. "strconv"
  11. "strings"
  12. "time"
  13. )
  14. type ArticleController struct {
  15. BaseAuthController
  16. }
  17. type ArticleCommonController struct {
  18. BaseCommonController
  19. }
  20. // @Title 获取报告详情
  21. // @Description 获取报告详情接口
  22. // @Param ArticleId query int true "报告ID"
  23. // @Success 200 {object} models.ArticleDetailResp
  24. // @router /detail [get]
  25. func (this *ArticleController) Detail() {
  26. br := new(models.BaseResponse).Init()
  27. defer func() {
  28. this.Data["json"] = br
  29. this.ServeJSON()
  30. }()
  31. user := this.User
  32. if user == nil {
  33. br.Msg = "请登录"
  34. br.ErrMsg = "请登录,用户信息为空"
  35. br.Ret = 408
  36. return
  37. }
  38. uid := user.UserId
  39. articleId, err := this.GetInt("ArticleId")
  40. if articleId <= 0 {
  41. br.Msg = "文章不存在"
  42. br.ErrMsg = "文章不存在,文章ID错误"
  43. return
  44. }
  45. detail := new(models.ArticleDetail)
  46. hasPermission := 0
  47. hasFree := 0
  48. //判断是否已经申请过
  49. applyCount, err := models.GetApplyRecordCount(uid)
  50. if err != nil && err.Error() != utils.ErrNoRow() {
  51. br.Msg = "获取信息失败"
  52. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  53. return
  54. }
  55. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  56. if user.CompanyId > 1 {
  57. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  58. if err != nil {
  59. br.Msg = "获取信息失败"
  60. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  61. return
  62. }
  63. detail, err = models.GetArticleDetailById(articleId)
  64. if err != nil {
  65. br.Msg = "获取信息失败"
  66. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  67. return
  68. }
  69. detail.Body = html.UnescapeString(detail.Body)
  70. //detail.Abstract = html.UnescapeString(detail.Abstract)
  71. detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
  72. if companyPermission == "" {
  73. if applyCount > 0 {
  74. hasPermission = 5
  75. } else {
  76. hasPermission = 2
  77. }
  78. hasFree = 2
  79. goto Loop
  80. } else {
  81. hasFree = 1
  82. // 原有的权限校验 更改于 2021-05-18
  83. //articlePermission, err := models.GetArticlePermission(detail.SubCategoryName)
  84. //fmt.Println(articlePermission)
  85. //fmt.Println(detail.SubCategoryName)
  86. //if err != nil {
  87. // br.Msg = "获取信息失败"
  88. // br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  89. // return
  90. //}
  91. //if articlePermission == nil {
  92. // br.Msg = "获取信息失败"
  93. // br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  94. // return
  95. //}
  96. //for _, p := range articlePermission {
  97. // if strings.Contains(companyPermission, p.PermissionName) {
  98. // hasPermission = 1
  99. // historyRecord := new(models.CygxArticleHistoryRecord)
  100. // historyRecord.UserId = uid
  101. // historyRecord.ArticleId = articleId
  102. // historyRecord.CreateTime = time.Now()
  103. // historyRecord.Mobile = user.Mobile
  104. // historyRecord.Email = user.Email
  105. // historyRecord.CompanyId = user.CompanyId
  106. // historyRecord.CompanyName = user.CompanyName
  107. // go models.AddCygxArticleHistoryRecord(historyRecord)
  108. // break
  109. // } else { //无该行业权限
  110. // hasPermission = 3
  111. // }
  112. //}
  113. var articlePermissionPermissionName string
  114. if detail.CategoryId > 0 {
  115. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  116. if err != nil {
  117. br.Msg = "获取信息失败"
  118. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  119. return
  120. }
  121. if articlePermission == nil {
  122. br.Msg = "获取信息失败"
  123. br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  124. return
  125. }
  126. articlePermissionPermissionName = articlePermission.PermissionName
  127. } else {
  128. articlePermissionPermissionName = detail.CategoryName
  129. }
  130. var hasPersion bool
  131. slice := strings.Split(articlePermissionPermissionName, ",")
  132. for _, v := range slice {
  133. if strings.Contains(companyPermission, v) {
  134. hasPersion = true
  135. }
  136. }
  137. if hasPersion {
  138. hasPermission = 1
  139. historyRecord := new(models.CygxArticleHistoryRecord)
  140. historyRecord.UserId = uid
  141. historyRecord.ArticleId = articleId
  142. historyRecord.CreateTime = time.Now()
  143. historyRecord.Mobile = user.Mobile
  144. historyRecord.Email = user.Email
  145. historyRecord.CompanyId = user.CompanyId
  146. historyRecord.CompanyName = user.CompanyName
  147. recordCount, _ := models.GetNoAddStoptimeArticleCount(uid, articleId)
  148. if recordCount == 0 {
  149. go models.AddCygxArticleHistoryRecord(historyRecord)
  150. } else {
  151. detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
  152. if err != nil {
  153. br.Msg = "获取信息失败"
  154. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  155. return
  156. }
  157. if detailNew.StopTime > 0 {
  158. go models.AddCygxArticleHistoryRecord(historyRecord)
  159. }
  160. }
  161. } else { //无该行业权限
  162. hasPermission = 3
  163. }
  164. if hasPermission == 1 {
  165. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  166. if !utils.Rc.IsExist(key) {
  167. //新增浏览记录
  168. record := new(models.CygxArticleViewRecord)
  169. record.UserId = uid
  170. record.ArticleId = articleId
  171. record.CreateTime = time.Now()
  172. record.Mobile = user.Mobile
  173. record.Email = user.Email
  174. record.CompanyId = user.CompanyId
  175. record.CompanyName = user.CompanyName
  176. go models.AddCygxArticleViewRecord(record)
  177. utils.Rc.Put(key, 1, 5*time.Second)
  178. models.ModifyReportLastViewTime(uid)
  179. }
  180. }
  181. }
  182. if strings.Contains(detail.CategoryName, "研选") {
  183. detail.IsResearch = true
  184. }
  185. collectCount, err := models.GetArticleCollectCount(uid, articleId)
  186. if err != nil && err.Error() != utils.ErrNoRow() {
  187. br.Msg = "获取信息失败"
  188. br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  189. return
  190. }
  191. if collectCount > 0 {
  192. detail.IsCollect = true
  193. }
  194. interviewApplyItem, err := models.GetArticleInterviewApply(uid, articleId)
  195. if err != nil && err.Error() != utils.ErrNoRow() {
  196. br.Msg = "获取信息失败"
  197. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  198. return
  199. }
  200. if interviewApplyItem != nil && interviewApplyItem.InterviewApplyId > 0 {
  201. detail.IsInterviewApply = true
  202. detail.InterviewApplyStatus = interviewApplyItem.Status
  203. }
  204. //获取销售手机号
  205. sellerItem, err := models.GetSellerByCompanyId(user.CompanyId)
  206. if err != nil {
  207. br.Msg = "获取信息失败"
  208. br.ErrMsg = "获取销售数据失败2,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  209. return
  210. }
  211. if sellerItem != nil {
  212. detail.SellerMobile = sellerItem.Mobile
  213. detail.SellerName = sellerItem.RealName
  214. }
  215. sellerList, err := models.GetSellerList(articleId)
  216. if err != nil {
  217. br.Msg = "获取信息失败"
  218. br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  219. return
  220. }
  221. if detail.ArticleId >= utils.SummaryArticleId {
  222. var hrefRegexp = regexp.MustCompile("[0-9]\\d*")
  223. match := hrefRegexp.FindAllString(detail.SellerAndMobile, -1)
  224. if match != nil {
  225. for _, v := range match {
  226. sellerAndMobile := &models.SellerRep{
  227. SellerMobile: v,
  228. SellerName: strings.Replace(detail.SellerAndMobile, v, "", -1),
  229. }
  230. sellerList = append(sellerList, sellerAndMobile)
  231. }
  232. }
  233. }
  234. detail.SellerList = sellerList
  235. } else { //潜在客户
  236. if applyCount > 0 {
  237. hasPermission = 5
  238. } else {
  239. hasPermission = 4
  240. }
  241. }
  242. Loop:
  243. if hasPermission != 1 {
  244. detail.Body = ""
  245. detail.BodyText = ""
  246. }
  247. fmt.Println(hasPermission)
  248. resp := new(models.ArticleDetailResp)
  249. resp.HasPermission = hasPermission
  250. resp.HasFree = hasFree
  251. resp.Detail = detail
  252. br.Ret = 200
  253. br.Success = true
  254. br.Msg = "获取成功"
  255. br.Data = resp
  256. }
  257. // @Title 收藏
  258. // @Description 收藏
  259. // @Param request body models.ArticleCollectReq true "type json string"
  260. // @Success 200 {object} models.FontsCollectResp
  261. // @router /collect [post]
  262. func (this *ArticleController) ArticleCollect() {
  263. br := new(models.BaseResponse).Init()
  264. defer func() {
  265. this.Data["json"] = br
  266. this.ServeJSON()
  267. }()
  268. user := this.User
  269. if user == nil {
  270. br.Msg = "请重新登录"
  271. br.Ret = 408
  272. return
  273. }
  274. uid := user.UserId
  275. var req models.ArticleCollectReq
  276. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  277. if err != nil {
  278. br.Msg = "参数解析异常!"
  279. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  280. return
  281. }
  282. count, err := models.GetArticleCollectCount(uid, req.ArticleId)
  283. if err != nil {
  284. br.Msg = "获取数据失败!"
  285. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  286. return
  287. }
  288. resp := new(models.ArticleCollectResp)
  289. if count <= 0 {
  290. item := new(models.CygxArticleCollect)
  291. item.ArticleId = req.ArticleId
  292. item.UserId = uid
  293. item.CreateTime = time.Now()
  294. _, err = models.AddCygxArticleCollect(item)
  295. if err != nil {
  296. br.Msg = "收藏失败"
  297. br.ErrMsg = "收藏失败,Err:" + err.Error()
  298. return
  299. }
  300. br.Msg = "收藏成功"
  301. resp.Status = 1
  302. } else {
  303. err = models.RemoveArticleCollect(uid, req.ArticleId)
  304. if err != nil {
  305. br.Msg = "取消收藏失败"
  306. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  307. return
  308. }
  309. br.Msg = "已取消收藏"
  310. resp.Status = 2
  311. }
  312. collectTotal, err := models.GetArticleCollectUsersCount(req.ArticleId)
  313. if err != nil {
  314. br.Msg = "获取数据失败"
  315. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  316. return
  317. }
  318. resp.CollectCount = collectTotal
  319. br.Ret = 200
  320. br.Success = true
  321. br.Data = resp
  322. }
  323. // @Title 访谈申请
  324. // @Description 访谈申请
  325. // @Param request body models.ArticleInterviewApplyReq true "type json string"
  326. // @Success 200 {object} models.FontsCollectResp
  327. // @router /interview/apply [post]
  328. func (this *ArticleController) InterviewApply() {
  329. br := new(models.BaseResponse).Init()
  330. defer func() {
  331. this.Data["json"] = br
  332. this.ServeJSON()
  333. }()
  334. user := this.User
  335. if user == nil {
  336. br.Msg = "请重新登录"
  337. br.Ret = 408
  338. return
  339. }
  340. uid := user.UserId
  341. var req models.ArticleInterviewApplyReq
  342. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  343. if err != nil {
  344. br.Msg = "参数解析异常!"
  345. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  346. return
  347. }
  348. article, err := models.GetArticleDetailById(req.ArticleId)
  349. if err != nil {
  350. br.Msg = "获取纪要失败!"
  351. br.ErrMsg = "获取纪要失败,Err:" + err.Error()
  352. return
  353. }
  354. count, err := models.GetArticleInterviewApplyCount(uid, req.ArticleId)
  355. if err != nil {
  356. br.Msg = "获取数据失败!"
  357. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  358. return
  359. }
  360. resp := new(models.ArticleInterviewApplyResp)
  361. if count <= 0 {
  362. item := new(models.CygxInterviewApply)
  363. item.ArticleId = req.ArticleId
  364. item.UserId = uid
  365. item.CompanyId = user.CompanyId
  366. item.Status = "待邀请"
  367. item.Sort = 1
  368. item.ArticleTitle = article.Title
  369. item.CreateTime = time.Now()
  370. item.ModifyTime = time.Now()
  371. item.ArticleIdMd5 = article.ArticleIdMd5
  372. _, err = models.AddCygxInterviewApply(item)
  373. if err != nil {
  374. br.Msg = "申请失败"
  375. br.ErrMsg = "申请失败,Err:" + err.Error()
  376. return
  377. }
  378. br.Msg = "申请成功"
  379. resp.Status = 1
  380. //发送模板消息
  381. if user.CompanyId > 1 {
  382. mobile := user.Mobile
  383. if mobile == "" {
  384. mobile = user.Email
  385. }
  386. sellerItem, _ := models.GetSellerByCompanyId(user.CompanyId)
  387. if sellerItem != nil && sellerItem.AdminId > 0 && user.Mobile != "" {
  388. openIpItem, _ := models.GetUserRecordByUserId(sellerItem.UserId, 1)
  389. if openIpItem != nil && openIpItem.OpenId != "" {
  390. go services.SendInterviewApplyTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, article.Title, openIpItem.OpenId)
  391. }
  392. }
  393. }
  394. } else {
  395. err = models.RemoveArticleInterviewApply(uid, req.ArticleId)
  396. if err != nil {
  397. br.Msg = "取消申请失败"
  398. br.ErrMsg = "取消申请失败,Err:" + err.Error()
  399. return
  400. }
  401. br.Msg = "已取消申请"
  402. resp.Status = 2
  403. if user.CompanyId > 1 {
  404. mobile := user.Mobile
  405. if mobile == "" {
  406. mobile = user.Email
  407. }
  408. sellerItem, _ := models.GetSellerByCompanyId(user.CompanyId)
  409. if sellerItem != nil && sellerItem.AdminId > 0 && user.Mobile != "" {
  410. openIpItem, _ := models.GetUserRecordByUserId(sellerItem.UserId, 1)
  411. if openIpItem != nil && openIpItem.OpenId != "" {
  412. go services.SendInterviewApplyCancelTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, article.Title, openIpItem.OpenId)
  413. }
  414. }
  415. }
  416. }
  417. br.Ret = 200
  418. br.Success = true
  419. br.Data = resp
  420. }
  421. // @Title 获取报告详情
  422. // @Description 获取报告详情接口
  423. // @Param ArticleIdMd5 query int true "报告ID"
  424. // @Success 200 {object} models.ArticleDetailResp
  425. // @router /look/detail [get]
  426. func (this *ArticleCommonController) Detail() {
  427. br := new(models.BaseResponse).Init()
  428. defer func() {
  429. this.Data["json"] = br
  430. this.ServeJSON()
  431. }()
  432. articleIdMd5 := this.GetString("ArticleIdMd5")
  433. if articleIdMd5 == "" {
  434. br.Msg = "参数错误"
  435. br.ErrMsg = "参数错误"
  436. return
  437. }
  438. resp := new(models.ArticleDetailResp)
  439. detail, err := models.GetArticleDetailByIdMd5(articleIdMd5)
  440. if err != nil && err.Error() != utils.ErrNoRow() {
  441. br.Msg = "获取信息失败"
  442. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  443. return
  444. }
  445. if detail == nil {
  446. resp.HasPermission = 2
  447. } else {
  448. resp.HasPermission = 1
  449. }
  450. if detail != nil {
  451. detail.Body = html.UnescapeString(detail.Body)
  452. detail.Abstract = html.UnescapeString(detail.Abstract)
  453. }
  454. sellerList, err := models.GetSellerList(detail.ArticleId)
  455. if err != nil {
  456. br.Msg = "获取信息失败"
  457. br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + ";articleId" + strconv.Itoa(detail.ArticleId)
  458. return
  459. }
  460. if detail.ArticleId > 1000000 {
  461. var hrefRegexp = regexp.MustCompile("[0-9]\\d*")
  462. match := hrefRegexp.FindAllString(detail.SellerAndMobile, -1)
  463. if match != nil {
  464. for _, v := range match {
  465. sellerAndMobile := &models.SellerRep{
  466. SellerMobile: v,
  467. SellerName: strings.Replace(detail.SellerAndMobile, v, "", -1),
  468. }
  469. sellerList = append(sellerList, sellerAndMobile)
  470. }
  471. }
  472. }
  473. detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
  474. detail.SellerList = sellerList
  475. resp.Detail = detail
  476. br.Ret = 200
  477. br.Success = true
  478. br.Msg = "获取成功"
  479. br.Data = resp
  480. }
  481. // @Title 上传文章阅读时间
  482. // @Description 上传文章阅读时间接口
  483. // @Param request body models.AddStopTimeRep true "type json string"
  484. // @Success 200 {object} models.ArticleDetailResp
  485. // @router /addStopTime [post]
  486. func (this *ArticleController) AddStopTime() {
  487. br := new(models.BaseResponse).Init()
  488. defer func() {
  489. this.Data["json"] = br
  490. this.ServeJSON()
  491. }()
  492. user := this.User
  493. if user == nil {
  494. br.Msg = "请登录"
  495. br.ErrMsg = "请登录,用户信息为空"
  496. br.Ret = 408
  497. return
  498. }
  499. var req models.AddStopTimeRep
  500. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  501. if err != nil {
  502. br.Msg = "参数解析异常!"
  503. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  504. return
  505. }
  506. uid := user.UserId
  507. articleId := req.ArticleId
  508. stopTime := req.StopTime
  509. if articleId <= 0 {
  510. br.Msg = "参数错误"
  511. br.ErrMsg = "参数错误"
  512. return
  513. }
  514. if stopTime == 0 {
  515. stopTime = 1
  516. //br.Msg = "时间格式错误"
  517. //br.ErrMsg = "时间错误"
  518. //return
  519. }
  520. detail := new(models.ArticleDetail)
  521. hasPermission := 0
  522. hasFree := 0
  523. //判断是否已经申请过
  524. applyCount, err := models.GetApplyRecordCount(uid)
  525. if err != nil && err.Error() != utils.ErrNoRow() {
  526. br.Msg = "获取信息失败"
  527. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  528. return
  529. }
  530. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  531. if user.CompanyId > 1 {
  532. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  533. if err != nil {
  534. br.Msg = "获取信息失败"
  535. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  536. return
  537. }
  538. detail, err = models.GetArticleDetailById(articleId)
  539. if err != nil {
  540. br.Msg = "获取信息失败"
  541. br.ErrMsg = "获取文章信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  542. return
  543. }
  544. if companyPermission == "" {
  545. if applyCount > 0 {
  546. hasPermission = 5
  547. } else {
  548. hasPermission = 2
  549. }
  550. hasFree = 2
  551. goto Loop
  552. } else {
  553. hasFree = 1
  554. var articlePermissionPermissionName string
  555. if detail.CategoryId > 0 {
  556. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  557. if err != nil {
  558. br.Msg = "获取信息失败"
  559. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  560. return
  561. }
  562. if articlePermission == nil {
  563. br.Msg = "获取信息失败"
  564. br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  565. return
  566. }
  567. articlePermissionPermissionName = articlePermission.PermissionName
  568. } else {
  569. articlePermissionPermissionName = detail.CategoryName
  570. }
  571. if strings.Contains(companyPermission, articlePermissionPermissionName) {
  572. detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
  573. if err == nil {
  574. //br.Msg = "获取信息失败"
  575. //br.ErrMsg = "获取最新阅读信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  576. //return
  577. hasPermission = 1
  578. historyRecord := new(models.AddStopTimeNewRep)
  579. historyRecord.StopTime = detailNew.StopTime + stopTime
  580. historyRecord.Id = detailNew.Id
  581. go models.AddArticleStopTime(historyRecord)
  582. }
  583. } else { //无该行业权限
  584. hasPermission = 3
  585. }
  586. }
  587. } else { //潜在客户
  588. if applyCount > 0 {
  589. hasPermission = 5
  590. } else {
  591. hasPermission = 4
  592. }
  593. }
  594. Loop:
  595. resp := new(models.ArticleDetailAddStopTimeRep)
  596. resp.HasPermission = hasPermission
  597. resp.HasFree = hasFree
  598. br.Ret = 200
  599. br.Success = true
  600. br.Msg = "操作成功"
  601. br.Data = resp
  602. }