article.go 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642
  1. package controllers
  2. import (
  3. "bufio"
  4. "github.com/pdfcpu/pdfcpu/pkg/api"
  5. "github.com/pdfcpu/pdfcpu/pkg/pdfcpu"
  6. "io"
  7. //"bufio"
  8. "encoding/json"
  9. "fmt"
  10. "github.com/medivhzhan/weapp/v2"
  11. "os"
  12. //"github.com/pdfcpu/pdfcpu/pkg/api"
  13. //"github.com/pdfcpu/pdfcpu/pkg/pdfcpu"
  14. "hongze/hongze_cygx/models"
  15. "hongze/hongze_cygx/services"
  16. "hongze/hongze_cygx/utils"
  17. "html"
  18. nhttp "net/http"
  19. "strconv"
  20. "strings"
  21. "time"
  22. )
  23. type ArticleController struct {
  24. BaseAuthController
  25. }
  26. type ArticleCommonController struct {
  27. BaseCommonController
  28. }
  29. type ArticleControllerMobile struct {
  30. BaseAuthMobileController
  31. }
  32. // @Title 获取报告详情
  33. // @Description 获取报告详情接口
  34. // @Param ArticleId query int true "报告ID"
  35. // @Success 200 {object} models.ArticleDetailResp
  36. // @router /detail [get]
  37. func (this *ArticleController) Detail() {
  38. br := new(models.BaseResponse).Init()
  39. defer func() {
  40. this.Data["json"] = br
  41. this.ServeJSON()
  42. }()
  43. user := this.User
  44. if user == nil {
  45. br.Msg = "请登录"
  46. br.ErrMsg = "请登录,用户信息为空"
  47. br.Ret = 408
  48. return
  49. }
  50. uid := user.UserId
  51. articleId, err := this.GetInt("ArticleId")
  52. if articleId <= 0 {
  53. br.Msg = "文章不存在"
  54. br.ErrMsg = "文章不存在,文章ID错误"
  55. return
  56. }
  57. detail := new(models.ArticleDetail)
  58. hasPermission := 0
  59. hasFree := 0
  60. var haveResearch bool
  61. //判断是否已经申请过
  62. applyCount, err := models.GetApplyRecordCount(uid)
  63. if err != nil && err.Error() != utils.ErrNoRow() {
  64. br.Msg = "获取信息失败"
  65. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  66. return
  67. }
  68. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  69. if user.CompanyId > 1 {
  70. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  71. if err != nil {
  72. br.Msg = "获取信息失败"
  73. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  74. return
  75. }
  76. detail, err = models.GetArticleDetailById(articleId)
  77. if err != nil {
  78. br.Msg = "获取信息失败"
  79. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  80. return
  81. }
  82. //是否属于专项调研报告
  83. if detail.SubCategoryName == "专项调研" {
  84. detail.IsSpecialArticle = true
  85. }
  86. detail.PublishDate = utils.TimeRemoveHms(detail.PublishDate)
  87. detail.Body = html.UnescapeString(detail.Body)
  88. detail.Body = strings.Replace(detail.Body, "<p data-f-id=\"pbf\" style=\"text-align: center; font-size: 14px; margin-top: 30px; opacity: 0.65; font-family: sans-serif;\">Powered by <a href=\"https://www.froala.com/wysiwyg-editor?pb=1\" title=\"Froala Editor\">Froala Editor</a></p>", "", -1)
  89. detail.Body = strings.Replace(detail.Body, "pre", "div", -1)
  90. //detail.Abstract = html.UnescapeString(detail.Abstract)
  91. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  92. if companyPermission == "" {
  93. if applyCount > 0 {
  94. hasPermission = 5
  95. } else {
  96. hasPermission = 2
  97. }
  98. hasFree = 2
  99. goto Loop
  100. } else {
  101. hasFree = 1
  102. var articlePermissionPermissionName string
  103. if detail.CategoryId > 0 {
  104. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  105. if err != nil {
  106. br.Msg = "获取信息失败"
  107. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  108. return
  109. }
  110. if articlePermission == nil {
  111. br.Msg = "获取信息失败"
  112. br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  113. return
  114. }
  115. articlePermissionPermissionName = articlePermission.PermissionName
  116. } else {
  117. articlePermissionPermissionName = detail.CategoryName
  118. }
  119. var hasPersion bool
  120. slice := strings.Split(articlePermissionPermissionName, ",")
  121. for _, v := range slice {
  122. if strings.Contains(companyPermission, v) {
  123. hasPersion = true
  124. }
  125. }
  126. if strings.Contains(detail.CategoryName, "研选") {
  127. detail.IsResearch = true
  128. }
  129. userType, _, err := services.GetUserType(user.CompanyId)
  130. if err != nil {
  131. br.Msg = "获取信息失败"
  132. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  133. return
  134. }
  135. if userType == 1 && strings.Contains(detail.CategoryName, "研选") {
  136. hasPersion = false
  137. }
  138. if detail.IsReport == 1 {
  139. detailCategory, err := models.GetdetailByCategoryIdSando(detail.CategoryId)
  140. if err != nil && err.Error() != utils.ErrNoRow() {
  141. br.Msg = "获取信息失败"
  142. br.ErrMsg = "获取信息失败,Err:" + err.Error() + "categoryID 不存在:" + strconv.Itoa(detail.CategoryId)
  143. return
  144. }
  145. permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
  146. if err != nil {
  147. br.Msg = "获取信息失败"
  148. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  149. return
  150. }
  151. if detailCategory != nil {
  152. if detailCategory.PermissionType == 1 {
  153. if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(主观)") {
  154. hasPersion = false
  155. }
  156. } else if detailCategory.PermissionType == 2 {
  157. if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(客观)") {
  158. hasPersion = false
  159. }
  160. }
  161. }
  162. }
  163. if hasPersion {
  164. hasPermission = 1
  165. historyRecord := new(models.CygxArticleHistoryRecord)
  166. historyRecord.UserId = uid
  167. historyRecord.ArticleId = articleId
  168. historyRecord.CreateTime = time.Now()
  169. historyRecord.Mobile = user.Mobile
  170. historyRecord.Email = user.Email
  171. historyRecord.CompanyId = user.CompanyId
  172. historyRecord.CompanyName = user.CompanyName
  173. recordCount, _ := models.GetNoAddStoptimeArticleCount(uid, articleId)
  174. if recordCount == 0 {
  175. go models.AddCygxArticleHistoryRecord(historyRecord)
  176. } else {
  177. detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
  178. if err != nil {
  179. br.Msg = "获取信息失败"
  180. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  181. return
  182. }
  183. if detailNew.StopTime > 0 {
  184. go models.AddCygxArticleHistoryRecord(historyRecord)
  185. }
  186. }
  187. //30分钟之内阅读同一篇文章不错二次推送
  188. key := "CYGX_ARTICLE_READ" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  189. if !utils.Rc.IsExist(key) {
  190. go services.ArticleUserRemind(user, detail, 1)
  191. utils.Rc.Put(key, 1, 30*time.Second)
  192. }
  193. } else { //无该行业权限
  194. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  195. if err == nil && companyDetail.ProductId == 1 {
  196. hasPermission = 2
  197. } else {
  198. hasPermission = 3
  199. }
  200. }
  201. if hasPermission == 1 {
  202. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  203. if !utils.Rc.IsExist(key) {
  204. //新增浏览记录
  205. record := new(models.CygxArticleViewRecord)
  206. record.UserId = uid
  207. record.ArticleId = articleId
  208. record.CreateTime = time.Now()
  209. record.Mobile = user.Mobile
  210. record.Email = user.Email
  211. record.CompanyId = user.CompanyId
  212. record.CompanyName = user.CompanyName
  213. go models.AddCygxArticleViewRecord(record)
  214. utils.Rc.Put(key, 1, 5*time.Second)
  215. models.ModifyReportLastViewTime(uid)
  216. }
  217. }
  218. }
  219. collectCount, err := models.GetArticleCollectCount(uid, articleId)
  220. if err != nil && err.Error() != utils.ErrNoRow() {
  221. br.Msg = "获取信息失败"
  222. br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  223. return
  224. }
  225. if collectCount > 0 {
  226. detail.IsCollect = true
  227. }
  228. interviewApplyItem, err := models.GetArticleInterviewApply(uid, articleId)
  229. if err != nil && err.Error() != utils.ErrNoRow() {
  230. br.Msg = "获取信息失败"
  231. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  232. return
  233. }
  234. if interviewApplyItem != nil && interviewApplyItem.InterviewApplyId > 0 {
  235. detail.IsInterviewApply = true
  236. detail.InterviewApplyStatus = interviewApplyItem.Status
  237. }
  238. //获取销售手机号
  239. sellerItem, err := models.GetSellerByCompanyId(user.CompanyId)
  240. if err != nil && err.Error() != utils.ErrNoRow() {
  241. br.Msg = "获取信息失败"
  242. br.ErrMsg = "获取销售数据失败2,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  243. return
  244. }
  245. if sellerItem != nil {
  246. detail.SellerMobile = sellerItem.Mobile
  247. detail.SellerName = sellerItem.RealName
  248. }
  249. sellerList, err := models.GetSellerList(articleId)
  250. if err != nil {
  251. br.Msg = "获取信息失败"
  252. br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  253. return
  254. }
  255. if detail.ArticleId >= utils.SummaryArticleId && strings.Contains(detail.SellerAndMobile, "-") {
  256. strnum := strings.Index(detail.SellerAndMobile, "-")
  257. detail.SellerAndMobile = detail.SellerAndMobile[0:strnum]
  258. if strnum > 0 {
  259. nickName := detail.SellerAndMobile[0:strnum]
  260. sellerAndMobile := &models.SellerRep{
  261. SellerMobile: "",
  262. SellerName: nickName,
  263. }
  264. sellerList = append(sellerList, sellerAndMobile)
  265. }
  266. }
  267. detail.SellerList = sellerList
  268. //作者头像
  269. if detail.DepartmentId > 0 {
  270. departmentDetail, err := models.GetArticleDepartmentDateilById(detail.DepartmentId)
  271. if err == nil {
  272. detail.DepartmentImgUrl = departmentDetail.ImgUrl
  273. }
  274. }
  275. } else { //潜在客户
  276. if applyCount > 0 {
  277. hasPermission = 5
  278. } else {
  279. hasPermission = 4
  280. }
  281. }
  282. Loop:
  283. if hasPermission != 1 {
  284. detail.Body = ""
  285. detail.BodyText = ""
  286. } else {
  287. articleFollowdetail, err := models.GetArticleFollowDetail(articleId, uid)
  288. if err != nil {
  289. br.Msg = "获取信息失败"
  290. br.ErrMsg = "获取关注信息失败,Err:" + err.Error()
  291. return
  292. }
  293. detail.FollowNum = articleFollowdetail.DNum
  294. detail.CollectionNum = articleFollowdetail.AcNum
  295. if articleFollowdetail.MdNum > 0 {
  296. detail.IsFollow = true
  297. }
  298. if detail.IsSummary == 1 {
  299. detail.IsBelongSummary = true
  300. }
  301. if detail.IsReport == 1 {
  302. detail.IsBelongReport = true
  303. }
  304. haveResearch = true
  305. }
  306. if hasPermission == 5 {
  307. companyPermissionNoStatus, err := models.GetCompanyPermissionByUserNoStatus(user.CompanyId)
  308. if err != nil {
  309. br.Msg = "获取信息失败"
  310. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  311. return
  312. }
  313. if companyPermissionNoStatus != "" {
  314. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  315. if err != nil && err.Error() != utils.ErrNoRow() {
  316. br.Msg = "获取信息失败"
  317. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  318. return
  319. }
  320. if sellerItemQy != nil {
  321. hasPermission = 3
  322. detail.SellerMobile = sellerItemQy.Mobile
  323. detail.SellerName = sellerItemQy.RealName
  324. }
  325. }
  326. }
  327. if hasPermission == 2 || hasPermission == 4 {
  328. //获取销售手机号
  329. sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  330. if err != nil && err.Error() != utils.ErrNoRow() {
  331. br.Msg = "获取信息失败"
  332. br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  333. return
  334. }
  335. if sellerItemQy != nil {
  336. hasPermission = 3
  337. detail.SellerMobile = sellerItemQy.Mobile
  338. detail.SellerName = sellerItemQy.RealName
  339. }
  340. }
  341. if detail.ArticleId < utils.SummaryArticleId {
  342. if user.Mobile != "" {
  343. chartUserTokenByMobile, _ := services.GetUserTokenByMobile(user.Mobile)
  344. detail.HttpUrl = utils.StrategyPlatform + strconv.Itoa(articleId) + "?token=" + chartUserTokenByMobile
  345. } else {
  346. detail.HttpUrl = utils.StrategyPlatform + strconv.Itoa(articleId)
  347. }
  348. detail.IsNeedJump = true
  349. }
  350. // 处理研选下面的路演精华 的报告链接是否跳转
  351. if hasPermission == 1 && detail.ArticleId > utils.SummaryArticleId && detail.ArticleTypeId > 0 {
  352. //articleTYpeDetail, err := models.GetArticleTypeInfo(detail.ArticleTypeId)
  353. //if err != nil && err.Error() != utils.ErrNoRow() {
  354. // br.Msg = "获取信息失败"
  355. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  356. // return
  357. //}
  358. //if articleTYpeDetail != nil {
  359. // detail.IsShowLinkButton = articleTYpeDetail.IsShowLinkButton
  360. //}
  361. detail.PublishDate = utils.TimeRemoveHms2(detail.PublishDate)
  362. if detail.ReportLink != "" {
  363. chartUserTokenByMobile, _ := services.GetUserTokenByMobile(user.Mobile)
  364. detail.ReportLink += "?token=" + chartUserTokenByMobile
  365. }
  366. }
  367. resp := new(models.ArticleDetailResp)
  368. resp.HasPermission = hasPermission
  369. resp.HaveResearch = haveResearch
  370. resp.HasFree = hasFree
  371. resp.Detail = detail
  372. if user.Mobile != "" {
  373. resp.Mobile = user.Mobile
  374. } else {
  375. resp.Mobile = user.Email
  376. }
  377. br.Ret = 200
  378. br.Success = true
  379. br.Msg = "获取成功"
  380. br.Data = resp
  381. }
  382. // @Title 收藏
  383. // @Description 收藏
  384. // @Param request body models.ArticleCollectReq true "type json string"
  385. // @Success 200 {object} models.FontsCollectResp
  386. // @router /collect [post]
  387. func (this *ArticleController) ArticleCollect() {
  388. br := new(models.BaseResponse).Init()
  389. defer func() {
  390. this.Data["json"] = br
  391. this.ServeJSON()
  392. }()
  393. user := this.User
  394. if user == nil {
  395. br.Msg = "请重新登录"
  396. br.Ret = 408
  397. return
  398. }
  399. uid := user.UserId
  400. var req models.ArticleCollectReq
  401. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  402. if err != nil {
  403. br.Msg = "参数解析异常!"
  404. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  405. return
  406. }
  407. articleId := req.ArticleId
  408. detail, err := models.GetArticleDetailById(articleId)
  409. if err != nil {
  410. br.Msg = "获取信息失败"
  411. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  412. return
  413. }
  414. count, err := models.GetArticleCollectCount(uid, articleId)
  415. if err != nil {
  416. br.Msg = "获取数据失败!"
  417. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  418. return
  419. }
  420. resp := new(models.ArticleCollectResp)
  421. if count <= 0 {
  422. item := new(models.CygxArticleCollect)
  423. item.ArticleId = req.ArticleId
  424. item.UserId = uid
  425. item.CreateTime = time.Now()
  426. item.Mobile = user.Mobile
  427. item.Email = user.Email
  428. item.CompanyId = user.CompanyId
  429. item.CompanyName = user.CompanyName
  430. item.RealName = user.RealName
  431. _, err = models.AddCygxArticleCollect(item)
  432. if err != nil {
  433. br.Msg = "收藏失败"
  434. br.ErrMsg = "收藏失败,Err:" + err.Error()
  435. return
  436. }
  437. br.Msg = "收藏成功"
  438. resp.Status = 1
  439. // 文章收藏消息发送
  440. go services.ArticleUserRemind(user, detail, 2)
  441. } else {
  442. err = models.RemoveArticleCollect(uid, articleId)
  443. if err != nil {
  444. br.Msg = "取消收藏失败"
  445. br.ErrMsg = "取消收藏失败,Err:" + err.Error()
  446. return
  447. }
  448. br.Msg = "已取消收藏"
  449. resp.Status = 2
  450. }
  451. collectTotal, err := models.GetArticleCollectUsersCount(articleId)
  452. if err != nil {
  453. br.Msg = "获取数据失败"
  454. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  455. return
  456. }
  457. resp.CollectCount = collectTotal
  458. br.Ret = 200
  459. br.Success = true
  460. br.Data = resp
  461. }
  462. // @Title 访谈申请
  463. // @Description 访谈申请
  464. // @Param request body models.ArticleInterviewApplyReq true "type json string"
  465. // @Success 200 {object} models.FontsCollectResp
  466. // @router /interview/apply [post]
  467. func (this *ArticleController) InterviewApply() {
  468. br := new(models.BaseResponse).Init()
  469. defer func() {
  470. this.Data["json"] = br
  471. this.ServeJSON()
  472. }()
  473. user := this.User
  474. if user == nil {
  475. br.Msg = "请重新登录"
  476. br.Ret = 408
  477. return
  478. }
  479. uid := user.UserId
  480. var req models.ArticleInterviewApplyReq
  481. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  482. if err != nil {
  483. br.Msg = "参数解析异常!"
  484. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  485. return
  486. }
  487. article, err := models.GetArticleDetailById(req.ArticleId)
  488. if err != nil {
  489. br.Msg = "获取纪要失败!"
  490. br.ErrMsg = "获取纪要失败,Err:" + err.Error()
  491. return
  492. }
  493. count, err := models.GetArticleInterviewApplyCount(uid, req.ArticleId)
  494. if err != nil {
  495. br.Msg = "获取数据失败!"
  496. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  497. return
  498. }
  499. resp := new(models.ArticleInterviewApplyResp)
  500. if count <= 0 {
  501. item := new(models.CygxInterviewApply)
  502. item.ArticleId = req.ArticleId
  503. item.UserId = uid
  504. item.CompanyId = user.CompanyId
  505. item.Status = "待邀请"
  506. item.Sort = 1
  507. item.ArticleTitle = article.Title
  508. item.CreateTime = time.Now()
  509. item.ModifyTime = time.Now()
  510. item.ArticleIdMd5 = article.ArticleIdMd5
  511. _, err = models.AddCygxInterviewApply(item)
  512. if err != nil {
  513. br.Msg = "申请失败"
  514. br.ErrMsg = "申请失败,Err:" + err.Error()
  515. return
  516. }
  517. br.Msg = "申请成功"
  518. resp.Status = 1
  519. //发送模板消息
  520. if user.CompanyId > 1 {
  521. mobile := user.Mobile
  522. if mobile == "" {
  523. mobile = user.Email
  524. }
  525. sellerItem, _ := models.GetSellerByCompanyId(user.CompanyId)
  526. if sellerItem != nil && sellerItem.AdminId > 0 && user.Mobile != "" {
  527. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  528. if openIpItem != nil && openIpItem.OpenId != "" {
  529. go services.SendInterviewApplyTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, article.Title, openIpItem)
  530. }
  531. }
  532. }
  533. } else {
  534. err = models.RemoveArticleInterviewApply(uid, req.ArticleId)
  535. if err != nil {
  536. br.Msg = "取消申请失败"
  537. br.ErrMsg = "取消申请失败,Err:" + err.Error()
  538. return
  539. }
  540. br.Msg = "已取消申请"
  541. resp.Status = 2
  542. if user.CompanyId > 1 {
  543. mobile := user.Mobile
  544. if mobile == "" {
  545. mobile = user.Email
  546. }
  547. sellerItem, _ := models.GetSellerByCompanyId(user.CompanyId)
  548. if sellerItem != nil && sellerItem.AdminId > 0 && user.Mobile != "" {
  549. openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
  550. if openIpItem != nil && openIpItem.OpenId != "" {
  551. go services.SendInterviewApplyCancelTemplateMsg(user.RealName, sellerItem.CompanyName, mobile, article.Title, openIpItem)
  552. }
  553. }
  554. }
  555. }
  556. br.Ret = 200
  557. br.Success = true
  558. br.Data = resp
  559. }
  560. // @Title 获取报告详情
  561. // @Description 获取报告详情接口
  562. // @Param ArticleIdMd5 query int true "报告ID"
  563. // @Success 200 {object} models.ArticleDetailResp
  564. // @router /look/detail [get]
  565. func (this *ArticleControllerMobile) DetailMd5() {
  566. br := new(models.BaseResponse).Init()
  567. defer func() {
  568. this.Data["json"] = br
  569. this.ServeJSON()
  570. }()
  571. user := this.User
  572. if user == nil {
  573. br.Msg = "请登录"
  574. br.ErrMsg = "请登录,用户信息为空"
  575. br.Ret = 408
  576. return
  577. }
  578. uid := user.UserId
  579. articleIdMd5 := this.GetString("ArticleIdMd5")
  580. if articleIdMd5 == "" {
  581. br.Msg = "参数错误"
  582. br.ErrMsg = "参数错误"
  583. return
  584. }
  585. resp := new(models.ArticleDetailResp)
  586. detail, err := models.GetArticleDetailByIdMd5(articleIdMd5)
  587. if err != nil {
  588. br.Msg = "获取信息失败"
  589. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  590. return
  591. }
  592. articleId := detail.ArticleId
  593. detail.Body = html.UnescapeString(detail.Body)
  594. hasPermission := 2
  595. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  596. if user.CompanyId > 1 {
  597. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  598. if err != nil {
  599. br.Msg = "获取信息失败"
  600. br.ErrMsg = "获取公司权限失败,Err:" + err.Error()
  601. return
  602. }
  603. detail.Body = html.UnescapeString(detail.Body)
  604. detail.Body = strings.Replace(detail.Body, "<p data-f-id=\"pbf\" style=\"text-align: center; font-size: 14px; margin-top: 30px; opacity: 0.65; font-family: sans-serif;\">Powered by <a href=\"https://www.froala.com/wysiwyg-editor?pb=1\" title=\"Froala Editor\">Froala Editor</a></p>", "", -1)
  605. detail.Body = strings.Replace(detail.Body, "pre", "div", -1)
  606. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  607. if companyPermission == "" {
  608. hasPermission = 2
  609. } else {
  610. var articlePermissionPermissionName string
  611. if detail.CategoryId > 0 {
  612. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  613. if err != nil {
  614. br.Msg = "获取信息失败"
  615. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + articleIdMd5
  616. return
  617. }
  618. if articlePermission == nil {
  619. br.Msg = "获取信息失败"
  620. br.ErrMsg = "报告权限不存在,Err:" + articleIdMd5
  621. return
  622. }
  623. articlePermissionPermissionName = articlePermission.PermissionName
  624. } else {
  625. articlePermissionPermissionName = detail.CategoryName
  626. }
  627. var hasPersion bool
  628. slice := strings.Split(articlePermissionPermissionName, ",")
  629. for _, v := range slice {
  630. if strings.Contains(companyPermission, v) {
  631. hasPersion = true
  632. }
  633. }
  634. userType, _, err := services.GetUserType(user.CompanyId)
  635. if err != nil {
  636. br.Msg = "获取信息失败"
  637. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  638. return
  639. }
  640. if userType == 1 && strings.Contains(detail.CategoryName, "研选") {
  641. hasPersion = false
  642. }
  643. if detail.IsReport == 1 {
  644. detailCategory, err := models.GetdetailByCategoryIdSando(detail.CategoryId)
  645. if err != nil && err.Error() != utils.ErrNoRow() {
  646. br.Msg = "获取信息失败"
  647. br.ErrMsg = "获取信息失败,Err:" + err.Error() + "categoryID 不存在:" + strconv.Itoa(detail.CategoryId)
  648. return
  649. }
  650. permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
  651. if err != nil {
  652. br.Msg = "获取信息失败"
  653. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  654. return
  655. }
  656. if detailCategory != nil {
  657. if detailCategory.PermissionType == 1 {
  658. if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(主观)") {
  659. hasPersion = false
  660. }
  661. } else if detailCategory.PermissionType == 2 {
  662. if !strings.Contains(permissionStr, detailCategory.ChartPermissionName+"(客观)") {
  663. hasPersion = false
  664. }
  665. }
  666. }
  667. }
  668. if hasPersion {
  669. hasPermission = 1
  670. record := new(models.CygxArticleHistoryRecordNewpv)
  671. record.UserId = uid
  672. record.ArticleId = articleId
  673. record.CreateTime = time.Now()
  674. record.ModifyTime = time.Now()
  675. record.Mobile = user.Mobile
  676. record.Email = user.Email
  677. record.CompanyId = user.CompanyId
  678. record.CompanyName = user.CompanyName
  679. //新增浏览记录
  680. go models.AddCygxArticleViewRecordNewpv(record)
  681. //30分钟之内阅读同一篇文章不错二次推送
  682. key := "CYGX_ARTICLE_READ" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  683. if !utils.Rc.IsExist(key) {
  684. go services.ArticleUserRemind(user, detail, 1)
  685. utils.Rc.Put(key, 1, 30*time.Second)
  686. }
  687. }
  688. if hasPermission == 1 {
  689. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  690. if !utils.Rc.IsExist(key) {
  691. //新增浏览记录
  692. record := new(models.CygxArticleViewRecord)
  693. record.UserId = uid
  694. record.ArticleId = articleId
  695. record.CreateTime = time.Now()
  696. record.Mobile = user.Mobile
  697. record.Email = user.Email
  698. record.CompanyId = user.CompanyId
  699. record.CompanyName = user.CompanyName
  700. go models.AddCygxArticleViewRecord(record)
  701. utils.Rc.Put(key, 1, 5*time.Second)
  702. models.ModifyReportLastViewTime(uid)
  703. }
  704. }
  705. }
  706. //作者头像
  707. if detail.DepartmentId > 0 {
  708. departmentDetail, err := models.GetArticleDepartmentDateilById(detail.DepartmentId)
  709. if err == nil {
  710. detail.DepartmentImgUrl = departmentDetail.ImgUrl
  711. detail.NickName = departmentDetail.NickName
  712. }
  713. }
  714. }
  715. detail.SellerAndMobile = "" //业务需要强制处理为空
  716. resp.HasPermission = hasPermission
  717. if hasPermission == 1 {
  718. detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
  719. resp.Detail = detail
  720. } else {
  721. if user.Mobile != "" {
  722. resp.Mobile = user.Mobile
  723. } else {
  724. resp.Mobile = user.Email
  725. }
  726. }
  727. br.Ret = 200
  728. br.Success = true
  729. br.Msg = "获取成功"
  730. br.Data = resp
  731. }
  732. // @Title 上传文章阅读时间
  733. // @Description 上传文章阅读时间接口
  734. // @Param request body models.AddStopTimeRep true "type json string"
  735. // @Success 200 {object} models.ArticleDetailResp
  736. // @router /addStopTime [post]
  737. func (this *ArticleController) AddStopTime() {
  738. br := new(models.BaseResponse).Init()
  739. defer func() {
  740. this.Data["json"] = br
  741. this.ServeJSON()
  742. }()
  743. user := this.User
  744. if user == nil {
  745. br.Msg = "请登录"
  746. br.ErrMsg = "请登录,用户信息为空"
  747. br.Ret = 408
  748. return
  749. }
  750. var req models.AddStopTimeRep
  751. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  752. if err != nil {
  753. br.Msg = "参数解析异常!"
  754. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  755. return
  756. }
  757. uid := user.UserId
  758. articleId := req.ArticleId
  759. stopTime := req.StopTime
  760. outType := req.OutType
  761. source := req.Source
  762. if articleId <= 0 {
  763. br.Msg = "参数错误"
  764. br.ErrMsg = "参数错误"
  765. return
  766. }
  767. if stopTime == 0 {
  768. stopTime = 1
  769. }
  770. if outType != 2 {
  771. outType = 1
  772. }
  773. if source != "PC" {
  774. source = "MOBILE"
  775. }
  776. detail := new(models.ArticleDetail)
  777. hasPermission := 0
  778. hasFree := 0
  779. //判断是否已经申请过
  780. applyCount, err := models.GetApplyRecordCount(uid)
  781. if err != nil && err.Error() != utils.ErrNoRow() {
  782. br.Msg = "获取信息失败"
  783. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  784. return
  785. }
  786. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  787. if user.CompanyId > 1 {
  788. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  789. if err != nil {
  790. br.Msg = "获取信息失败"
  791. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  792. return
  793. }
  794. detail, err = models.GetArticleDetailById(articleId)
  795. if err != nil {
  796. br.Msg = "获取信息失败"
  797. br.ErrMsg = "获取文章信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  798. return
  799. }
  800. if companyPermission == "" {
  801. if applyCount > 0 {
  802. hasPermission = 5
  803. } else {
  804. hasPermission = 2
  805. }
  806. hasFree = 2
  807. goto Loop
  808. } else {
  809. hasFree = 1
  810. var articlePermissionPermissionName string
  811. if detail.CategoryId > 0 {
  812. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  813. if err != nil {
  814. br.Msg = "获取信息失败"
  815. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  816. return
  817. }
  818. if articlePermission == nil {
  819. br.Msg = "获取信息失败"
  820. br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  821. return
  822. }
  823. articlePermissionPermissionName = articlePermission.PermissionName
  824. } else {
  825. articlePermissionPermissionName = detail.CategoryName
  826. }
  827. var hasPersion bool
  828. slice := strings.Split(articlePermissionPermissionName, ",")
  829. for _, v := range slice {
  830. if strings.Contains(companyPermission, v) {
  831. hasPersion = true
  832. }
  833. }
  834. if hasPersion {
  835. detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
  836. if err == nil {
  837. hasPermission = 1
  838. historyRecord := new(models.AddStopTimeNewRep)
  839. historyRecord.StopTime = detailNew.StopTime + stopTime
  840. historyRecord.Id = detailNew.Id
  841. historyRecord.OutType = outType
  842. go models.UpdateArticleStopTime(historyRecord)
  843. }
  844. //不统计本公司的阅读记录、正常退出的不做时间差统计
  845. if stopTime > 3 {
  846. key := "CYGX_ARTICLE_PV" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid) + "_" + strconv.Itoa(user.CompanyId) + "_" + strconv.Itoa(outType)
  847. record := new(models.CygxArticleHistoryRecordNewpv)
  848. record.UserId = uid
  849. record.ArticleId = articleId
  850. record.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
  851. record.ModifyTime = time.Now()
  852. record.Mobile = user.Mobile
  853. record.Email = user.Email
  854. record.CompanyId = user.CompanyId
  855. record.CompanyName = user.CompanyName
  856. record.StopTime = stopTime
  857. record.OutType = outType
  858. record.Source = source
  859. if !utils.Rc.IsExist(key) || outType != 2 {
  860. //新增浏览记录
  861. go models.AddCygxArticleViewRecordNewpv(record)
  862. recordRedis := new(services.ReportViewRecord)
  863. recordRedis.UserId = user.UserId
  864. recordRedis.ReportId = articleId
  865. recordRedis.Mobile = user.Mobile
  866. recordRedis.Email = user.Email
  867. recordRedis.RealName = user.RealName
  868. recordRedis.CompanyName = user.CompanyName
  869. recordRedis.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
  870. go services.PushViewRecordNewRedisData(recordRedis, user.CompanyId)
  871. } else {
  872. go models.UpdateCygxArticleViewRecordNewpv(record, stopTime)
  873. }
  874. utils.Rc.Put(key, 1, 10*time.Minute)
  875. }
  876. models.ModifyReportLastViewTime(uid)
  877. } else { //无该行业权限
  878. hasPermission = 3
  879. }
  880. }
  881. } else { //潜在客户
  882. if applyCount > 0 {
  883. hasPermission = 5
  884. } else {
  885. hasPermission = 4
  886. }
  887. }
  888. Loop:
  889. resp := new(models.ArticleDetailAddStopTimeRep)
  890. resp.HasPermission = hasPermission
  891. resp.HasFree = hasFree
  892. br.Ret = 200
  893. br.Success = true
  894. br.Msg = "操作成功"
  895. br.Data = resp
  896. }
  897. // @Title 文章带问
  898. // @Description 新增文章带问接口
  899. // @Param request body models.AddArticleAskRep true "type json string"
  900. // @Success Ret=200 新增成功
  901. // @router /askAdd [post]
  902. func (this *ArticleController) AskAdd() {
  903. br := new(models.BaseResponse).Init()
  904. defer func() {
  905. this.Data["json"] = br
  906. this.ServeJSON()
  907. }()
  908. user := this.User
  909. if user == nil {
  910. br.Msg = "请登录"
  911. br.ErrMsg = "请登录,SysUser Is Empty"
  912. br.Ret = 408
  913. return
  914. }
  915. var req models.AddArticleAskRep
  916. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  917. if err != nil {
  918. br.Msg = "参数解析异常!"
  919. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  920. return
  921. }
  922. if req.Content == "" {
  923. br.Msg = "建议内容不可为空"
  924. return
  925. }
  926. content := req.Content
  927. itemToken, err := services.WxGetToken()
  928. if err != nil {
  929. br.Msg = "GetWxAccessToken Err:" + err.Error()
  930. return
  931. }
  932. if itemToken.AccessToken == "" {
  933. br.Msg = "accessToken is empty"
  934. return
  935. }
  936. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  937. if err != nil {
  938. br.Msg = "内容校验失败!"
  939. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  940. return
  941. }
  942. if commerr.ErrCode != 0 {
  943. br.Msg = "内容违规,请重新提交!"
  944. br.ErrMsg = "颜文字内容违规,Err:" + commerr.ErrMSG
  945. return
  946. }
  947. articleId := req.ArticleId
  948. count, _ := models.GetArticleCountById(articleId)
  949. if count == 0 {
  950. br.Msg = "操作失败"
  951. br.ErrMsg = "文章ID错误,不存在 articleId:" + strconv.Itoa(articleId)
  952. return
  953. }
  954. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  955. if err != nil {
  956. br.Msg = "提交失败!"
  957. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  958. return
  959. }
  960. if companyDetail == nil {
  961. br.Msg = "提交失败!"
  962. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  963. return
  964. }
  965. item := new(models.CygxArticleAsk)
  966. item.UserId = user.UserId
  967. item.ArticleId = req.ArticleId
  968. item.CompanyId = user.CompanyId
  969. item.CompanyName = companyDetail.CompanyName
  970. item.CreateTime = time.Now()
  971. item.Mobile = user.Mobile
  972. item.Email = user.Email
  973. item.Content = content
  974. _, err = models.AddArticleAsk(item)
  975. if err != nil {
  976. br.Msg = "提交失败"
  977. br.ErrMsg = "提交失败,Err:" + err.Error()
  978. return
  979. }
  980. companyItem, err := models.GetSellerDetailAllByCompanyId(user.CompanyId)
  981. if err != nil {
  982. br.Msg = "获取信息失败"
  983. br.ErrMsg = "获取所属销售信息失败,Err:" + err.Error()
  984. return
  985. }
  986. var mobile string
  987. if utils.RunMode == "release" {
  988. //mobile = utils.WxMsgTemplateIdAskMsgMobileAll + "," + companyItem.Mobile
  989. mobile = utils.WxMsgTemplateIdAskMsgMobileAll
  990. } else {
  991. mobile = utils.WxMsgTemplateIdAskMsgMobile
  992. }
  993. openIdList, err := models.GetWxOpenIdByMobileList(mobile)
  994. if err != nil {
  995. br.Msg = "提交失败"
  996. br.ErrMsg = "提交失败,Err:" + err.Error()
  997. return
  998. }
  999. detail, err := models.GetArticleDetailById(articleId)
  1000. if err != nil {
  1001. br.Msg = "获取信息失败"
  1002. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1003. return
  1004. }
  1005. companyName := user.CompanyName + "-" + user.RealName + "(" + companyItem.SellerName + ")"
  1006. go services.SendWxMsgWithAsk(companyName, time.Now().Format(utils.FormatDateTime), content, detail.Title, openIdList, req.ArticleId)
  1007. br.Ret = 200
  1008. br.Success = true
  1009. br.Msg = "提交成功"
  1010. }
  1011. // @Title 下载PDF打水印
  1012. // @Description 下载PDF打水印接口
  1013. // @Param ArticleId query int true "报告ID"
  1014. // @Success 200 {object} models.ArticleDetailFileLink
  1015. // @router /pdfwatermark [get]
  1016. func (this *ArticleController) Pdfwatermark() {
  1017. br := new(models.BaseResponse).Init()
  1018. defer func() {
  1019. this.Data["json"] = br
  1020. this.ServeJSON()
  1021. }()
  1022. user := this.User
  1023. if user == nil {
  1024. br.Msg = "请登录"
  1025. br.ErrMsg = "请登录,用户信息为空"
  1026. br.Ret = 408
  1027. return
  1028. }
  1029. uid := user.UserId
  1030. articleId, err := this.GetInt("ArticleId")
  1031. if articleId <= 0 {
  1032. br.Msg = "文章不存在"
  1033. br.ErrMsg = "文章不存在,文章ID错误"
  1034. return
  1035. }
  1036. //缓存校验
  1037. cacheKey := fmt.Sprint("xygx:apply_record:add:", uid, "ArticleId_", articleId)
  1038. ttlTime := utils.Rc.GetRedisTTL(cacheKey)
  1039. if ttlTime > 0 && user.CompanyId != 16 {
  1040. br.Msg = "下载失败,下载过于频繁"
  1041. br.ErrMsg = "下载失败,下载过于频繁:mobile" + user.Mobile
  1042. return
  1043. }
  1044. resp := new(models.ArticleDetailFileLink)
  1045. detail := new(models.ArticleDetail)
  1046. detail, err = models.GetArticleDetailById(articleId)
  1047. if err != nil {
  1048. br.Msg = "获取信息失败"
  1049. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1050. return
  1051. }
  1052. fileLink := detail.FileLink
  1053. if fileLink == "" {
  1054. br.Msg = "下载失败"
  1055. br.ErrMsg = "下载失败,报告链接不存在"
  1056. return
  1057. }
  1058. mobile := user.Mobile
  1059. if mobile == "" {
  1060. mobile = user.Email
  1061. }
  1062. sliceLink := strings.Split(fileLink, "/")
  1063. uploadDir := "static/pdf/"
  1064. //判断文件夹是否存在,不存在则创建
  1065. if !utils.FileIsExist(uploadDir) {
  1066. err = os.MkdirAll(uploadDir, 0755)
  1067. if err != nil {
  1068. br.Msg = "下载失败"
  1069. br.ErrMsg = "存储目录创建失败,Err:" + err.Error()
  1070. return
  1071. }
  1072. }
  1073. var oldFile string
  1074. var newFile string
  1075. //获取PDF源文件名称
  1076. pdfName := sliceLink[len(sliceLink)-1]
  1077. pdfName = utils.MD5(pdfName) + ".pdf"
  1078. oldFile = uploadDir + pdfName
  1079. //判断PDF本地是否存在,不存在则保存到本地
  1080. if !utils.FileIsExist(oldFile) {
  1081. res, err := nhttp.Get(fileLink)
  1082. if err != nil {
  1083. br.Msg = "下载失败"
  1084. br.ErrMsg = "获取源文件失败,Err:" + err.Error()
  1085. return
  1086. }
  1087. defer res.Body.Close()
  1088. // 获得get请求响应的reader对象
  1089. reader := bufio.NewReaderSize(res.Body, 32*1024)
  1090. file, err := os.Create(oldFile)
  1091. if err != nil {
  1092. br.Msg = "下载失败"
  1093. br.ErrMsg = "保存源文件到本地失败,Err:" + err.Error()
  1094. return
  1095. }
  1096. defer file.Close()
  1097. //获得文件的writer对象
  1098. writer := bufio.NewWriter(file)
  1099. written, _ := io.Copy(writer, reader)
  1100. fmt.Printf("Total length: %d", written)
  1101. }
  1102. newFile = uploadDir + "new_" + pdfName
  1103. onTop := true
  1104. wm, err := pdfcpu.ParseTextWatermarkDetails(mobile, " op:.4, pos:c ,points:16 ", onTop, 1)
  1105. if err != nil {
  1106. br.Msg = "下载失败"
  1107. br.ErrMsg = "生成水印文件失败,Err:" + err.Error()
  1108. return
  1109. }
  1110. err = api.AddWatermarksFile(oldFile, newFile, nil, wm, nil)
  1111. if err != nil {
  1112. //br.Msg = "下载失败"
  1113. //br.ErrMsg = "生成水印PDF失败,Err:" + err.Error()
  1114. resp.FileLink = fileLink
  1115. br.Ret = 200
  1116. br.Success = true
  1117. br.Msg = "获取成功"
  1118. br.Data = resp
  1119. return
  1120. }
  1121. randStr := utils.GetRandStringNoSpecialChar(28)
  1122. fileName := randStr + ".pdf"
  1123. savePath := uploadDir + time.Now().Format("200601/20060102/")
  1124. savePath += fileName
  1125. //上传到阿里云
  1126. err = services.UploadFileToAliyun(fileName, newFile, savePath)
  1127. if err != nil {
  1128. br.Msg = "下载失败"
  1129. br.ErrMsg = "文件上传失败,Err:" + err.Error()
  1130. return
  1131. }
  1132. fileHost := "https://hzstatic.hzinsights.com/"
  1133. resourceUrl := fileHost + savePath
  1134. defer func() {
  1135. os.Remove(newFile)
  1136. }()
  1137. utils.Rc.SetNX(cacheKey, user.Mobile, time.Minute*5)
  1138. resp.FileLink = resourceUrl
  1139. br.Ret = 200
  1140. br.Success = true
  1141. br.Msg = "获取成功"
  1142. br.Data = resp
  1143. }
  1144. // @Title 获取报告详情(无需token)
  1145. // @Description 获取报告详情接口
  1146. // @Param ArticleId query int true "报告ID"
  1147. // @Param CompanyCode query string false "机构编号"
  1148. // @Param CompanyName query string false "机构名称"
  1149. // @Param Email query string false "邮箱"
  1150. // @Param Sign query string false "加密签名"
  1151. // @Success 200 {object} models.ArticleDetailHtgjResp
  1152. // @router /detailPublic [get]
  1153. func (this *ArticleCommonController) DetailPublic() {
  1154. br := new(models.BaseResponse).Init()
  1155. defer func() {
  1156. this.Data["json"] = br
  1157. this.ServeJSON()
  1158. }()
  1159. articleId, _ := this.GetInt("ArticleId")
  1160. companyCode := this.GetString("CompanyCode")
  1161. companyNameHt := this.GetString("CompanyName")
  1162. email := this.GetString("Email")
  1163. sign := this.GetString("Sign")
  1164. resp := new(models.ArticleDetailHtgjResp)
  1165. if companyCode == "" || email == "" {
  1166. resp.HasPermission = 2
  1167. br.Ret = 200
  1168. br.Success = true
  1169. br.Msg = "获取成功"
  1170. br.Data = resp
  1171. return
  1172. }
  1173. if articleId <= 0 {
  1174. br.Msg = "文章不存在"
  1175. br.ErrMsg = "文章不存在,文章ID错误"
  1176. return
  1177. }
  1178. errMsg, err, wxUser, companyName := services.CheckHtgj(companyCode, companyNameHt, email, sign)
  1179. if errMsg != "" {
  1180. br.Msg = errMsg
  1181. return
  1182. }
  1183. companyPermission, err := models.GetCompanyPermission(wxUser.CompanyId)
  1184. if err != nil {
  1185. br.Msg = "获取信息失败"
  1186. br.ErrMsg = "获取用户权限失败,Err:" + err.Error() + ";articleId" + strconv.Itoa(articleId)
  1187. return
  1188. }
  1189. hasPermission := 0
  1190. uid := wxUser.UserId
  1191. detail, err := models.GetArticleDetailById(articleId)
  1192. if err != nil {
  1193. br.Msg = "获取信息失败"
  1194. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1195. return
  1196. }
  1197. detail.Body = html.UnescapeString(detail.Body)
  1198. detail.Body = strings.Replace(detail.Body, "<p data-f-id=\"pbf\" style=\"text-align: center; font-size: 14px; margin-top: 30px; opacity: 0.65; font-family: sans-serif;\">Powered by <a href=\"https://www.froala.com/wysiwyg-editor?pb=1\" title=\"Froala Editor\">Froala Editor</a></p>", "", -1)
  1199. detail.Body = strings.Replace(detail.Body, "pre", "div", -1)
  1200. detail.Abstract, _ = services.GetReportContentTextSub(detail.Abstract)
  1201. var articlePermissionPermissionName string
  1202. if detail.CategoryId > 0 {
  1203. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  1204. if err != nil {
  1205. br.Msg = "获取信息失败"
  1206. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(wxUser.UserId) + ";articleId" + strconv.Itoa(articleId)
  1207. return
  1208. }
  1209. if articlePermission == nil {
  1210. br.Msg = "获取信息失败"
  1211. br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(wxUser.UserId) + ";articleId" + strconv.Itoa(articleId)
  1212. return
  1213. }
  1214. articlePermissionPermissionName = articlePermission.PermissionName
  1215. } else {
  1216. articlePermissionPermissionName = detail.CategoryName
  1217. }
  1218. var hasPersion bool
  1219. slice := strings.Split(articlePermissionPermissionName, ",")
  1220. for _, v := range slice {
  1221. if strings.Contains(companyPermission, v) {
  1222. hasPersion = true
  1223. }
  1224. }
  1225. if hasPersion {
  1226. hasPermission = 1
  1227. }
  1228. if strings.Contains(detail.CategoryName, "研选") {
  1229. detail.IsResearch = true
  1230. }
  1231. resp.HasPermission = hasPermission
  1232. if hasPermission == 1 {
  1233. //获取销售手机号
  1234. sellerItem, err := models.GetSellerByCompanyId(wxUser.CompanyId)
  1235. if err != nil {
  1236. br.Msg = "获取信息失败"
  1237. br.ErrMsg = "获取销售数据失败2,Err:" + strconv.Itoa(wxUser.UserId) + ";articleId" + strconv.Itoa(articleId)
  1238. return
  1239. }
  1240. if sellerItem != nil {
  1241. detail.SellerMobile = sellerItem.Mobile
  1242. detail.SellerName = sellerItem.RealName
  1243. }
  1244. sellerList, err := models.GetSellerList(articleId)
  1245. if err != nil {
  1246. br.Msg = "获取信息失败"
  1247. br.ErrMsg = "获取销售数据失败,Err:" + err.Error() + strconv.Itoa(wxUser.UserId) + ";articleId" + strconv.Itoa(articleId)
  1248. return
  1249. }
  1250. if detail.ArticleId >= utils.SummaryArticleId && strings.Contains(detail.SellerAndMobile, "-") {
  1251. strnum := strings.Index(detail.SellerAndMobile, "-")
  1252. detail.SellerAndMobile = detail.SellerAndMobile[0:strnum]
  1253. if strnum > 0 {
  1254. nickName := detail.SellerAndMobile[0:strnum]
  1255. sellerAndMobile := &models.SellerRep{
  1256. SellerMobile: "",
  1257. SellerName: nickName,
  1258. }
  1259. sellerList = append(sellerList, sellerAndMobile)
  1260. }
  1261. }
  1262. detail.SellerList = sellerList
  1263. resp.Detail = detail
  1264. historyRecord := new(models.CygxArticleHistoryRecord)
  1265. historyRecord.UserId = wxUser.UserId
  1266. historyRecord.ArticleId = articleId
  1267. historyRecord.CreateTime = time.Now()
  1268. historyRecord.Mobile = wxUser.Mobile
  1269. historyRecord.Email = wxUser.Email
  1270. historyRecord.CompanyId = wxUser.CompanyId
  1271. historyRecord.CompanyName = companyName
  1272. recordCount, _ := models.GetNoAddStoptimeArticleCount(wxUser.UserId, articleId)
  1273. if recordCount == 0 {
  1274. go models.AddCygxArticleHistoryRecord(historyRecord)
  1275. } else {
  1276. detailNew, err := models.GetNewArticleHistoryRecord(wxUser.UserId, articleId)
  1277. if err != nil {
  1278. br.Msg = "获取信息失败"
  1279. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1280. return
  1281. }
  1282. if detailNew.StopTime > 0 {
  1283. go models.AddCygxArticleHistoryRecord(historyRecord)
  1284. }
  1285. }
  1286. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(wxUser.UserId)
  1287. if !utils.Rc.IsExist(key) {
  1288. //新增浏览记录
  1289. record := new(models.CygxArticleViewRecord)
  1290. record.UserId = wxUser.UserId
  1291. record.ArticleId = articleId
  1292. record.CreateTime = time.Now()
  1293. record.Mobile = wxUser.Mobile
  1294. record.Email = wxUser.Email
  1295. record.CompanyId = wxUser.CompanyId
  1296. record.CompanyName = companyName
  1297. go models.AddCygxArticleViewRecord(record)
  1298. utils.Rc.Put(key, 1, 5*time.Second)
  1299. models.ModifyReportLastViewTime(wxUser.UserId)
  1300. }
  1301. if detail.ArticleId < utils.SummaryArticleId {
  1302. chartUserTokenByMobile, _ := services.GetUserTokenByMobile(utils.HtgjPublicMobile)
  1303. detail.HttpUrl = utils.StrategyPlatform + strconv.Itoa(articleId) + "?token=" + chartUserTokenByMobile
  1304. detail.IsNeedJump = true
  1305. }
  1306. if detail.ArticleId < utils.SummaryArticleId {
  1307. chartUserTokenByMobile, _ := services.GetUserTokenByMobile(utils.HtgjPublicMobile)
  1308. detail.HttpUrl = utils.StrategyPlatform + strconv.Itoa(articleId) + "?token=" + chartUserTokenByMobile
  1309. detail.IsNeedJump = true
  1310. }
  1311. collectCount, err := models.GetArticleCollectCount(uid, articleId)
  1312. if err != nil && err.Error() != utils.ErrNoRow() {
  1313. br.Msg = "获取信息失败"
  1314. br.ErrMsg = "判断是否已收藏失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1315. return
  1316. }
  1317. if collectCount > 0 {
  1318. detail.IsCollect = true
  1319. }
  1320. interviewApplyItem, err := models.GetArticleInterviewApply(uid, articleId)
  1321. if err != nil && err.Error() != utils.ErrNoRow() {
  1322. br.Msg = "获取信息失败"
  1323. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1324. return
  1325. }
  1326. if interviewApplyItem != nil && interviewApplyItem.InterviewApplyId > 0 {
  1327. detail.IsInterviewApply = true
  1328. detail.InterviewApplyStatus = interviewApplyItem.Status
  1329. }
  1330. articleFollowdetail, err := models.GetArticleFollowDetail(articleId, uid)
  1331. if err != nil {
  1332. br.Msg = "获取信息失败"
  1333. br.ErrMsg = "获取关注信息失败,Err:" + err.Error()
  1334. return
  1335. }
  1336. detail.FollowNum = articleFollowdetail.DNum
  1337. detail.CollectionNum = articleFollowdetail.AcNum
  1338. resp.Detail = detail
  1339. }
  1340. resp.CompanyName = companyName
  1341. br.Ret = 200
  1342. br.Success = true
  1343. br.Msg = "获取成功"
  1344. br.Data = resp
  1345. }
  1346. // @Title 上传文章阅读时间(无需token)
  1347. // @Description 上传文章阅读时间接口(无需token)
  1348. // @Param request body models.AddStopTimeHtgjRep true "type json string"
  1349. // @Success 200 {object} models.ArticleDetailResp
  1350. // @router /addStopTimePublic [post]
  1351. func (this *ArticleCommonController) AddStopTimePublic() {
  1352. br := new(models.BaseResponse).Init()
  1353. defer func() {
  1354. this.Data["json"] = br
  1355. this.ServeJSON()
  1356. }()
  1357. var req models.AddStopTimeHtgjRep
  1358. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1359. if err != nil {
  1360. br.Msg = "参数解析异常!"
  1361. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1362. return
  1363. }
  1364. articleId := req.ArticleId
  1365. stopTime := req.StopTime
  1366. outType := req.OutType
  1367. source := req.Source
  1368. companyCode := req.CompanyCode
  1369. companyName := req.CompanyName
  1370. wxuUserName := req.Email
  1371. sign := req.Sign
  1372. if companyCode == "" || companyName == "" || wxuUserName == "" || sign == "" {
  1373. br.Msg = "上传失败"
  1374. br.ErrMsg = "必填参数不能为空"
  1375. return
  1376. }
  1377. companyNameHt := companyCode + "_" + companyName
  1378. errMsg := services.CheckSign(companyCode+companyName+wxuUserName, sign)
  1379. if errMsg != "" {
  1380. br.Msg = errMsg
  1381. return
  1382. }
  1383. companyInfo, err := models.GetCompanyByThirdName(companyNameHt)
  1384. if err != nil {
  1385. br.Msg = "获取信息失败"
  1386. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1387. return
  1388. }
  1389. user, err := models.GetUserByThirdName(companyInfo.CompanyId, wxuUserName)
  1390. if err != nil {
  1391. br.Msg = "获取信息失败"
  1392. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1393. return
  1394. }
  1395. uid := user.UserId
  1396. if articleId <= 0 {
  1397. br.Msg = "文章ID不存在"
  1398. br.ErrMsg = "参数错误"
  1399. return
  1400. }
  1401. if stopTime == 0 {
  1402. stopTime = 1
  1403. }
  1404. if outType != 2 {
  1405. outType = 1
  1406. }
  1407. if source != "PC" {
  1408. source = "MOBILE"
  1409. }
  1410. detail := new(models.ArticleDetail)
  1411. hasPermission := 0
  1412. hasFree := 0
  1413. //判断是否已经申请过
  1414. applyCount, err := models.GetApplyRecordCount(uid)
  1415. if err != nil && err.Error() != utils.ErrNoRow() {
  1416. br.Msg = "获取信息失败"
  1417. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1418. return
  1419. }
  1420. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1421. if user.CompanyId > 1 {
  1422. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1423. if err != nil {
  1424. br.Msg = "获取信息失败"
  1425. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1426. return
  1427. }
  1428. detail, err = models.GetArticleDetailById(articleId)
  1429. if err != nil {
  1430. br.Msg = "获取信息失败"
  1431. br.ErrMsg = "获取文章信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1432. return
  1433. }
  1434. if companyPermission == "" {
  1435. if applyCount > 0 {
  1436. hasPermission = 5
  1437. } else {
  1438. hasPermission = 2
  1439. }
  1440. hasFree = 2
  1441. goto Loop
  1442. } else {
  1443. hasFree = 1
  1444. var articlePermissionPermissionName string
  1445. if detail.CategoryId > 0 {
  1446. articlePermission, err := models.GetArticlePermission(detail.CategoryId)
  1447. if err != nil {
  1448. br.Msg = "获取信息失败"
  1449. br.ErrMsg = "获取报告权限失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1450. return
  1451. }
  1452. if articlePermission == nil {
  1453. br.Msg = "获取信息失败"
  1454. br.ErrMsg = "报告权限不存在,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1455. return
  1456. }
  1457. articlePermissionPermissionName = articlePermission.PermissionName
  1458. } else {
  1459. articlePermissionPermissionName = detail.CategoryName
  1460. }
  1461. var hasPersion bool
  1462. slice := strings.Split(articlePermissionPermissionName, ",")
  1463. for _, v := range slice {
  1464. if strings.Contains(companyPermission, v) {
  1465. hasPersion = true
  1466. }
  1467. }
  1468. if hasPersion {
  1469. detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
  1470. if err == nil {
  1471. hasPermission = 1
  1472. historyRecord := new(models.AddStopTimeNewRep)
  1473. historyRecord.StopTime = detailNew.StopTime + stopTime
  1474. historyRecord.Id = detailNew.Id
  1475. historyRecord.OutType = outType
  1476. go models.UpdateArticleStopTime(historyRecord)
  1477. }
  1478. //不统计本公司的阅读记录、正常退出的不做时间差统计
  1479. if user.CompanyId != 16 && stopTime > 3 {
  1480. key := "CYGX_ARTICLE_PV" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid) + "_" + strconv.Itoa(user.CompanyId) + "_" + strconv.Itoa(outType)
  1481. record := new(models.CygxArticleHistoryRecordNewpv)
  1482. record.UserId = uid
  1483. record.ArticleId = articleId
  1484. record.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
  1485. record.ModifyTime = time.Now()
  1486. record.Mobile = user.Mobile
  1487. record.Email = user.Email
  1488. record.CompanyId = user.CompanyId
  1489. record.CompanyName = companyInfo.CompanyName
  1490. record.StopTime = stopTime
  1491. record.OutType = outType
  1492. record.Source = source
  1493. if !utils.Rc.IsExist(key) || outType != 2 {
  1494. //新增浏览记录
  1495. go models.AddCygxArticleViewRecordNewpv(record)
  1496. recordRedis := new(services.ReportViewRecord)
  1497. recordRedis.UserId = user.UserId
  1498. recordRedis.ReportId = articleId
  1499. recordRedis.Mobile = user.Mobile
  1500. recordRedis.Email = user.Email
  1501. recordRedis.RealName = user.RealName
  1502. recordRedis.CompanyName = companyName
  1503. recordRedis.CreateTime = time.Now().Add(-time.Second * time.Duration(stopTime))
  1504. go services.PushViewRecordNewRedisData(recordRedis, user.CompanyId)
  1505. } else {
  1506. go models.UpdateCygxArticleViewRecordNewpv(record, stopTime)
  1507. }
  1508. utils.Rc.Put(key, 1, 10*time.Minute)
  1509. }
  1510. models.ModifyReportLastViewTime(uid)
  1511. } else { //无该行业权限
  1512. hasPermission = 3
  1513. }
  1514. }
  1515. } else { //潜在客户
  1516. if applyCount > 0 {
  1517. hasPermission = 5
  1518. } else {
  1519. hasPermission = 4
  1520. }
  1521. }
  1522. Loop:
  1523. resp := new(models.ArticleDetailAddStopTimeRep)
  1524. resp.HasPermission = hasPermission
  1525. resp.HasFree = hasFree
  1526. br.Ret = 200
  1527. br.Success = true
  1528. br.Msg = "操作成功"
  1529. br.Data = resp
  1530. }
  1531. // @Title 页面访问统计(无需token)
  1532. // @Description 上传页面访问统计(无需token)
  1533. // @Param request body models.CygxPageHistoryRecordHtgjRep true "type json string"
  1534. // @Success Ret=200 新增成功
  1535. // @router /pageHistoryPublic [post]
  1536. func (this *ArticleCommonController) PageHistoryPublic() {
  1537. br := new(models.BaseResponse).Init()
  1538. defer func() {
  1539. this.Data["json"] = br
  1540. this.ServeJSON()
  1541. }()
  1542. var req models.CygxPageHistoryRecordHtgjRep
  1543. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1544. if err != nil {
  1545. br.Msg = "参数解析异常!"
  1546. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1547. return
  1548. }
  1549. companyCode := req.CompanyCode
  1550. companyName := req.CompanyName
  1551. wxuUserName := req.Email
  1552. sign := req.Sign
  1553. if companyCode == "" || companyName == "" || wxuUserName == "" || sign == "" {
  1554. br.Msg = "上传失败"
  1555. br.ErrMsg = "必填参数不能为空"
  1556. return
  1557. }
  1558. companyNameHt := companyCode + "_" + companyName
  1559. errMsg := services.CheckSign(companyCode+companyName+wxuUserName, sign)
  1560. if errMsg != "" {
  1561. br.Msg = errMsg
  1562. return
  1563. }
  1564. companyInfo, err := models.GetCompanyByThirdName(companyNameHt)
  1565. if err != nil {
  1566. br.Msg = "获取信息失败"
  1567. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1568. return
  1569. }
  1570. user, err := models.GetUserByThirdName(companyInfo.CompanyId, wxuUserName)
  1571. if err != nil {
  1572. br.Msg = "获取信息失败"
  1573. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1574. return
  1575. }
  1576. item := new(models.CygxPageHistoryRecord)
  1577. item.UserId = user.UserId
  1578. item.CreateTime = time.Now()
  1579. item.Mobile = user.Mobile
  1580. item.Email = user.Email
  1581. item.CompanyId = user.CompanyId
  1582. item.CompanyName = companyName
  1583. item.DetailId = req.DetailId
  1584. item.ChartPermissionId = req.ChartPermissionId
  1585. item.IndustrialManagementId = req.IndustrialManagementId
  1586. item.PageType = "ArticleCopy"
  1587. _, err = models.AddCygxPageHistoryRecord(item)
  1588. if err != nil {
  1589. br.Msg = "记录信息失败"
  1590. br.ErrMsg = "新增访问记录失败,Err:" + err.Error()
  1591. return
  1592. }
  1593. br.Ret = 200
  1594. br.Success = true
  1595. br.Msg = "新增成功"
  1596. }