cygx_user.go 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456
  1. package cygx
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hz_crm_api/models/company"
  7. "hongze/hz_crm_api/utils"
  8. "strconv"
  9. "strings"
  10. "time"
  11. )
  12. type CygxCompanyUser struct {
  13. UserId int64 `orm:"column(user_id);pk"`
  14. Mobile string `description:"手机号"`
  15. Email string `description:"邮箱"`
  16. CompanyId int `description:"公司id"`
  17. CompanyName string `description:"公司名称"`
  18. RealName string `description:"姓名"`
  19. CreatedTime string `description:"创建时间"`
  20. IsMaker int `description:"是否决策人,1:是,0:否"`
  21. IsRegister bool `description:"是否注册,true:已注册,false:未注册"`
  22. Status string `description:"客户状态"`
  23. RegisterTime string `description:"注册时间"`
  24. SellerName string `description:"销售名称"`
  25. InteractionNum int `description:"互动量"`
  26. CompanyInteractionNum int `description:"企业互动量"`
  27. CompanyInteractionNumSeller int `description:"销售可见企业互动量"`
  28. Labels string `description:"标签,用英文,隔开"`
  29. ActivityLabel string `description:"活动标签,用英文,隔开"`
  30. IsShowSee bool `description:"是否展示查看"`
  31. IsShowSeeNum int `description:"是否展示查看"`
  32. HistoryNum int `description:"报告阅读"`
  33. CountNum int `description:"报告收藏"`
  34. IndustryFllowNum int `description:"产业关注"`
  35. DepartmentFollowNum int `description:"作者关注"`
  36. KeyWordNum int `description:"搜索关键词"`
  37. OnLineNum int `description:"线上互动活动"`
  38. OfficeNum int `description:"线下互动活动"`
  39. ChartNum int `description:"图表收藏数量"`
  40. TripNum int `description:"图表数量"`
  41. RoadshowVideoNum int `description:"产业视频播放量"`
  42. ActivityVideoNum int `description:"活动视频播放量"`
  43. ActivityVoiceNum int `description:"活动音频播放量"`
  44. YanxuanspecialNum int `description:"研选专栏查看数量"`
  45. RsCalendarNum int `description:"1V1 路演数量"`
  46. FeedbackNum int `description:"交流反馈数量"`
  47. PackageType int `description:"套餐类型,0:无,1:大套餐,2:小套餐"`
  48. TryStage int `description:"试用客户子标签:0全部、1未分类、2 推进、3 跟踪、4 预备"`
  49. Content string `description:"备注信息"`
  50. IsRemind bool `description:"是否添加互动提醒"`
  51. IsSubscribeCygx int `description:"是否关注了查研观向微信公众号: 0-未关注; 1-已关注"`
  52. IsUserMaker int `description:"近四周之内是否包含决策人互动过 ,0否,1是"`
  53. }
  54. type CompanyUserListResp struct {
  55. Paging *paging.PagingItem
  56. List []*CygxCompanyUser
  57. }
  58. // 获取数量
  59. func GetCompanyListCount(userCondition, keyWord, kwywordcondition, condition, roleTypeCode string, pars []interface{}) (count int, err error) {
  60. o := orm.NewOrm()
  61. companyCondition := `SELECT a.company_id FROM company AS a INNER JOIN company_product AS b ON a.company_id=b.company_id WHERE a.enabled=1 `
  62. kwywordcondition = companyCondition + kwywordcondition
  63. if condition != "" {
  64. companyCondition += condition
  65. }
  66. sql := `SELECT COUNT(DISTINCT u.user_id) AS count
  67. FROM
  68. wx_user AS u
  69. INNER JOIN company AS c ON c.company_id = u.company_id
  70. INNER JOIN company_product AS cp ON cp.company_id = c.company_id
  71. INNER JOIN admin AS m ON m.admin_id = cp.seller_id
  72. INNER JOIN user_seller_relation AS sr ON sr.user_id = u.user_id
  73. WHERE u.company_id IN (` + companyCondition + `)`
  74. if userCondition != "" {
  75. sql += userCondition
  76. }
  77. if keyWord != "" {
  78. if strings.Count(roleTypeCode, "admin") > 0 {
  79. sql += ` OR ( cp.product_id = 2 AND cp.status IN ('正式','试用','冻结','永续') AND ( u.real_name LIKE '%` + keyWord + `%' OR u.mobile LIKE '%` + keyWord + `%' OR u.email LIKE '%` + keyWord + `%' ) ` + userCondition + ` )`
  80. } else {
  81. sql += ` OR ( cp.product_id = 2 AND u.company_id IN (` + kwywordcondition + `) AND cp.status IN ('正式','试用','冻结','永续') AND ( u.real_name LIKE '%` + keyWord + `%' OR u.mobile LIKE '%` + keyWord + `%' OR u.email LIKE '%` + keyWord + `%' ) ` + userCondition + ` )`
  82. }
  83. }
  84. err = o.Raw(sql, pars).QueryRow(&count)
  85. return
  86. }
  87. // 列表
  88. func GetCygxCompanyUserList(userCondition, keyWord, kwywordcondition, condition, roleTypeCode, sqlOrder string, pars []interface{}, startSize, pageSize int) (items []*CygxCompanyUser, err error) {
  89. o := orm.NewOrm()
  90. companyCondition := `SELECT a.company_id FROM company AS a INNER JOIN company_product AS b ON a.company_id=b.company_id WHERE a.enabled=1 `
  91. kwywordcondition = companyCondition + kwywordcondition
  92. if condition != "" {
  93. companyCondition += condition
  94. }
  95. sql := `SELECT
  96. u.user_id,
  97. u.mobile,
  98. u.email,
  99. date_format(u.register_time,'%Y-%m-%d') as register_time,
  100. u.real_name,
  101. u.is_register,
  102. u.is_maker,
  103. u.user_label as labels,
  104. u.cygx_subscribe as is_subscribe_cygx,
  105. c.company_name,
  106. c.company_id,
  107. c.interaction_num as company_interaction_num,
  108. c.interaction_num_seller as company_interaction_num_seller,
  109. cp.status,
  110. cp.try_stage,
  111. cp.package_type,
  112. m.real_name as seller_name ,
  113. ( SELECT COUNT( 1 ) FROM user_remarks AS rm WHERE rm.user_id = u.user_id ) AS is_show_see_num
  114. FROM
  115. wx_user AS u
  116. INNER JOIN company AS c ON c.company_id = u.company_id
  117. INNER JOIN company_product AS cp ON cp.company_id = c.company_id
  118. INNER JOIN admin AS m ON m.admin_id = cp.seller_id
  119. INNER JOIN user_seller_relation AS sr ON sr.user_id = u.user_id
  120. WHERE u.company_id IN (` + companyCondition + `)`
  121. if userCondition != "" {
  122. sql += userCondition
  123. }
  124. if keyWord != "" {
  125. if strings.Count(roleTypeCode, "admin") > 0 {
  126. sql += ` OR ( cp.product_id = 2 AND cp.status IN ('正式','试用','冻结','永续') AND ( u.real_name LIKE '%` + keyWord + `%' OR u.mobile LIKE '%` + keyWord + `%' OR u.email LIKE '%` + keyWord + `%' ) ` + userCondition + ` )`
  127. } else {
  128. sql += ` OR ( cp.product_id = 2 AND u.company_id IN (` + kwywordcondition + `) AND cp.status IN ('正式','试用','冻结','永续') AND ( u.real_name LIKE '%` + keyWord + `%' OR u.mobile LIKE '%` + keyWord + `%' OR u.email LIKE '%` + keyWord + `%' ) ` + userCondition + ` )`
  129. }
  130. }
  131. if sqlOrder != "" {
  132. sql += sqlOrder + ` LIMIT ?,? `
  133. } else {
  134. sql += ` GROUP by u.user_id ORDER BY c.created_time DESC, u.register_time DESC LIMIT ?,? `
  135. }
  136. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  137. return
  138. }
  139. type CygxCompanyUserAndSellerResp struct {
  140. UserId int `description:"用户ID"`
  141. Mobile string `description:"手机号"`
  142. Email string `description:"邮箱"`
  143. CompanyId int `description:"公司id"`
  144. CompanyName string `description:"公司名称"`
  145. RealName string `description:"姓名"`
  146. SellerName string `description:"销售名称"`
  147. }
  148. // 给所有已绑定手机号的客户(除流失)列表
  149. func GetCygxCompanyUserListByNoLoss() (items []*CygxCompanyUserAndSellerResp, err error) {
  150. o := orm.NewOrm()
  151. sql := `SELECT
  152. u.user_id,
  153. u.mobile,
  154. u.email,
  155. u.real_name,
  156. c.company_name,
  157. c.company_id,
  158. m.real_name AS seller_name
  159. FROM
  160. wx_user AS u
  161. INNER JOIN company AS c ON c.company_id = u.company_id
  162. INNER JOIN company_product AS cp ON cp.company_id = c.company_id
  163. INNER JOIN admin AS m ON m.admin_id = cp.seller_id
  164. INNER JOIN user_seller_relation AS sr ON sr.user_id = u.user_id
  165. WHERE
  166. 1 = 1
  167. AND c.enabled = 1
  168. AND cp.STATUS != '流失'
  169. AND cp.product_id = 2
  170. AND sr.product_id = 2
  171. GROUP BY
  172. u.user_id `
  173. _, err = o.Raw(sql).QueryRows(&items)
  174. return
  175. }
  176. // 对于上面的SQL的拆分优化查询速度
  177. func GetCygxCompanyUserListSplit(userIds string) (items []*CygxCompanyUser, err error) {
  178. databaseName := utils.GetWeeklyDatabase()
  179. o := orm.NewOrmUsingDB("hz_cygx")
  180. sql := `SELECT
  181. u.user_id,
  182. ( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h INNER JOIN cygx_article as art ON art.article_id = h.article_id WHERE h.mobile = u.mobile AND h.is_del = 0 AND h.mobile <>'' ) AS history_num,
  183. ( SELECT COUNT( 1 ) FROM cygx_article_collect AS h WHERE h.user_id = u.user_id ) AS count_num,
  184. ( SELECT COUNT( 1 ) FROM cygx_chart_collect AS h WHERE h.user_id = u.user_id ) AS chart_num,
  185. ( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h WHERE h.user_id = u.user_id AND h.type = 1 AND h.source IN (0,1,2) ) AS industry_fllow_num,
  186. ( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS h WHERE h.user_id = u.user_id AND h.type = 1 ) AS department_follow_num,
  187. ( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.user_id = u.user_id ) AS key_word_num,
  188. ( SELECT COUNT(DISTINCT h.activity_id) FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id WHERE h.mobile = u.mobile
  189. AND t.activity_type = 1 AND h.do_fail_type = 0 ) AS on_line_num,
  190. ( SELECT COUNT( 1 ) FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id WHERE h.mobile = u.mobile
  191. AND t.activity_type = 0 AND h.do_fail_type = 0 ) AS office_num,
  192. ( SELECT COUNT( 1 ) FROM cygx_activity_special_meeting_detail AS h INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id WHERE h.mobile = u.mobile AND a.publish_status = 1 AND a.activity_time_end < NOW()) AS trip_num,
  193. ( SELECT COUNT( 1 ) FROM cygx_micro_roadshow_video_history AS h INNER JOIN cygx_micro_roadshow_video as v ON v.video_id = h.video_id WHERE h.mobile = u.mobile ) AS roadshow_video_num,
  194. ( SELECT COUNT( 1 ) FROM cygx_activity_video_history AS h INNER JOIN cygx_activity_video as v ON v.video_id = h.video_id WHERE h.mobile = u.mobile ) AS activity_video_num,
  195. ( SELECT COUNT( 1 ) FROM cygx_activity_voice_history AS h INNER JOIN cygx_activity_voice as v ON v.activity_voice_id = h.activity_voice_id WHERE h.mobile = u.mobile ) AS activity_voice_num,
  196. ( SELECT COUNT( 1 ) FROM cygx_yanxuan_special_record AS h INNER JOIN cygx_yanxuan_special as v ON v.id = h.yanxuan_special_id WHERE h.mobile = u.mobile ) AS yanxuanspecial_num,
  197. ( SELECT COUNT(1) FROM cygx_user_feedback as h WHERE h.mobile = u.mobile ) AS feedback_num,
  198. ( SELECT COUNT(1) FROM ` + databaseName + `.rs_calendar_meeting_user as h WHERE h.mobile = u.mobile ) AS rs_calendar_num
  199. FROM ` + databaseName + `.wx_user AS u WHERE u.user_id IN (` + userIds + `) AND u.mobile != '' GROUP BY u.user_id `
  200. _, err = o.Raw(sql).QueryRows(&items)
  201. return
  202. }
  203. type UserRemarks struct {
  204. Id int `orm:"column(id);pk"`
  205. UserId int `description:"用户ID"`
  206. AdminId int `description:"销售/管理员ID"`
  207. Content string `description:"备注信息"`
  208. CreateTime time.Time `description:"创建时间"`
  209. }
  210. type UserRemarksResp struct {
  211. Id int `orm:"column(id);pk"`
  212. UserId int `description:"用户ID"`
  213. AdminId int `description:"销售/管理员ID"`
  214. Content string `description:"备注信息"`
  215. CreateTime string `description:"创建时间"`
  216. }
  217. type UserRemarAddReq struct {
  218. UserId int `description:"用户ID"`
  219. Content string `description:"备注信息"`
  220. SourceType int `description:"操作类型,1:对联系人单独设置,2:对机构批量设置"`
  221. DoType int `description:"操作方式,1:添加,2:取消"`
  222. }
  223. // 添加UserRemarks
  224. func AddUserRemarks(item *UserRemarks) (err error) {
  225. o := orm.NewOrm()
  226. _, err = o.Insert(item)
  227. return
  228. }
  229. // 获取备注列表
  230. func GetUserRemarksList(userId int) (items []*UserRemarksResp, err error) {
  231. o := orm.NewOrm()
  232. sql := ` SELECT * FROM user_remarks WHERE user_id=? ORDER BY create_time DESC`
  233. _, err = o.Raw(sql, userId).QueryRows(&items)
  234. return
  235. }
  236. // 获取备注列表(多用户)
  237. func GetUserRemarksListByUserIds(uids string) (items []*UserRemarksResp, err error) {
  238. o := orm.NewOrm()
  239. sql := ` SELECT * FROM user_remarks WHERE user_id IN(` + uids + `) ORDER BY create_time DESC`
  240. _, err = o.Raw(sql).QueryRows(&items)
  241. return
  242. }
  243. type UserRemarksListResp struct {
  244. List []*UserRemarksResp
  245. }
  246. // 切换列表
  247. type CygxUserTableRep struct {
  248. PermissionName string `description:"名称"`
  249. Source int `description:"类型"`
  250. TotalNum int `description:"总数"`
  251. }
  252. type CygxUserTableListRep struct {
  253. List []*CygxUserTableRep
  254. UserName string `description:"用户名称"`
  255. ComapnyName string `description:"公司名称"`
  256. Mobile string `description:"手机号"`
  257. }
  258. // @Param TryStage query int false "试用客户子标签:0全部、1未分类、2 推进、3 跟踪、4 预备"
  259. // 状态搜索列表
  260. type CygxTryStageRep struct {
  261. Name string `description:"试用客户子标签"`
  262. TryStage int `description:"试用客户子标签:0全部、1未分类、2 推进、3 跟踪、4 预备"`
  263. }
  264. type CygxUserTableStatusRep struct {
  265. List []*CygxTryStageRep
  266. Name string `description:"状态"`
  267. TryStage string `description:"状态"`
  268. }
  269. type CygxUserTableStatusListRep struct {
  270. List []*CygxUserTableStatusRep
  271. }
  272. type UserInteractionListResp struct {
  273. Paging *paging.PagingItem
  274. List []*UserInteraction
  275. MeetingNum int `description:"已到会"`
  276. NoMeetingNum int `description:"未到会"`
  277. }
  278. type UserInteraction struct {
  279. ArticleId int `description:"文章id"`
  280. ReportId int `description:"研报文章id"`
  281. ActivityId int `description:"活动ID"`
  282. ArticleType int `description:"文章类型 1:查研观向, 2:策略平台"`
  283. ArticleIdMd5 string `description:"文章MD5id"`
  284. Title string `description:"标题"`
  285. MediaTitle string `description:"音视频标题"`
  286. CategoryName string `description:"行业2"`
  287. PublishDate string `description:"发布时间"`
  288. CreateTime string `description:"创建时间"`
  289. CreateDate string `orm:"column(create_time);" description:"创建时间"`
  290. PermissionName string `orm:"column(chart_permission_name);" description:"行业"`
  291. ChartPermissionId int `description:"行业id"`
  292. IndustryName string `description:"产业名称"`
  293. SubjectNameStr string `description:"关联标的"`
  294. MatchTypeName string `description:"匹配类型"`
  295. StopTime string `description:"阅读停留时间"`
  296. NickName string `description:"作者昵称"`
  297. DepartmentId int `description:"作者ID "`
  298. KeyWord string `description:"关键词"`
  299. LabelKeyWord string `description:"标签关键词"`
  300. Source int `description:"关键词来源;1:纪要、2:图表、3:纪要/图表、4:产业资源包、5:报告、6:活动、7:搜索关键词、8:专项产业调研、9音视频播放"`
  301. ActivityName string `description:"活动名称"`
  302. ActivityType int `description:"1 线上,0、2线下"`
  303. IsMeeting int `description:"是否到会, 1是,0否"`
  304. ActivityTypeName string `description:"活动类型名称"`
  305. Label string `description:"标签"`
  306. ActivityTime string `description:"活动时间"`
  307. ActivityTimeText string `description:"活动时间"`
  308. FirstMeetingTime string `description:"首次入会时间"`
  309. LastMeetingTime string `description:"最后退出时间"`
  310. Duration string `description:"参会时长"`
  311. MeetingTypeStr string `description:"参会方式"`
  312. MeetingAuthentication string `description:"参会权鉴"`
  313. MeetingStatusStr string `description:"参会状态"`
  314. SignupType string `description:"参会方式 "`
  315. InteractionType string `description:"互动类型 "`
  316. ReminderNum int `description:"预约外呼数量 "`
  317. TitleEn string `description:"英文标题 "`
  318. PtagName string `description:"父类名称"`
  319. CtagName string `description:"子类名称"`
  320. PtagNameTwo string `description:"父类名称"`
  321. CtagNameTwo string `description:"子类名称"`
  322. CtagNamePc string `description:"Pc端所有的分类名称"`
  323. BodyHtml string `orm:"column(cover)";description:"图片链接"`
  324. HttpUrl string `orm:"column(iframe)";description:"文章链接跳转地址"`
  325. ChartId int `description:"图表id"`
  326. RealName string `description:"姓名"`
  327. CompanyName string `description:"公司名称"`
  328. CompanyId int `description:"公司ID"`
  329. SellerName string `description:"所属销售"`
  330. Mobile string `description:"手机号"`
  331. UserId int `description:"用户ID"`
  332. City string `description:"城市"`
  333. FileType string `description:"文件类型"`
  334. ListChart []*HomeChartListResp
  335. Paging *paging.PagingItem
  336. IsEnd bool `description:"是否最后一页,配合前端分页添加的参数"`
  337. CurrentIndex int `description:"当前页页码,配合前端分页添加的参数"`
  338. RegisterPlatform int `description:"来源 1小程序,2:网页 ,3:策略平台"`
  339. RegisterPlatformText string `description:"阅读来源(文本描述)"`
  340. SourcePlatform string `description:"来源 'MOBILE:移动端小程序','PC:PC端小程序','CELUE:上海策略平台','WEB:查研观向网页版'"`
  341. TagId int
  342. TagName string // 标签名
  343. ArticleTypes string // 报告系列
  344. ActivityTypes string // 活动类型
  345. Industries string // 产业
  346. SubjectNames string // 标的
  347. SpecialType int `description:"专栏类型 1:笔记,2:观点"`
  348. ArticleNum int // 已发布的文章数量
  349. FansNum int // 粉丝数量
  350. ResearcherName string `description:"研究员姓名"`
  351. RoadShowTheme string `description:"路演主题"`
  352. }
  353. // 查研观向图表
  354. type CygxChartResp struct {
  355. Title string `description:"标题"`
  356. PublishDate string `description:"发布时间"`
  357. CreateTime string `description:"创建时间"`
  358. TitleEn string `description:"英文标题 "`
  359. PtagName string `description:"父类名称"`
  360. CtagName string `description:"子类名称"`
  361. PtagNameTwo string `description:"父类名称"`
  362. CtagNameTwo string `description:"子类名称"`
  363. CtagNamePc string `description:"Pc端所有的分类名称"`
  364. BodyHtml string `orm:"column(cover)";description:"图片链接"`
  365. HttpUrl string `orm:"column(iframe)";description:"文章链接跳转地址"`
  366. ChartId int `description:"图表id"`
  367. RealyName string `description:"姓名"`
  368. Mobile string `description:"手机号"`
  369. }
  370. // 获取阅读记录数量
  371. func GetCygxArticleHistoryCount(mobile, email, condition string) (count int, err error) {
  372. o := orm.NewOrmUsingDB("hz_cygx")
  373. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_article_history_record_all as r INNER JOIN cygx_article as art ON art.article_id = r.article_id WHERE r.mobile = '` + mobile + `' AND is_del = 0 ` + condition
  374. err = o.Raw(sqlCount).QueryRow(&count)
  375. return
  376. }
  377. // 阅读记录列表
  378. func GetCygxArticleHistoryRecordByUser(mobile, email, condition string, startSize, pageSize int) (items []*UserInteraction, err error) {
  379. o := orm.NewOrmUsingDB("hz_cygx")
  380. sql := ` SELECT
  381. art.title,
  382. art.article_id,
  383. art.article_id_md5,
  384. art.publish_date,
  385. art.category_name,
  386. re.chart_permission_name,
  387. re.chart_permission_id,
  388. r.create_time,
  389. r.stop_time,
  390. r.source as source_platform,
  391. (
  392. SELECT
  393. GROUP_CONCAT( DISTINCT s.subject_name SEPARATOR '/' )
  394. FROM
  395. cygx_industrial_subject AS s
  396. WHERE
  397. s.industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_article_group_subject AS sg WHERE sg.article_id = art.article_id )
  398. ) AS subject_name_str,
  399. (
  400. SELECT
  401. GROUP_CONCAT( DISTINCT man.industry_name SEPARATOR '/' )
  402. FROM
  403. cygx_industrial_management AS man
  404. WHERE
  405. man.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_article_group_management AS man_g WHERE man_g.article_id = art.article_id )
  406. ) AS industry_name
  407. FROM
  408. cygx_article_history_record_all AS r
  409. INNER JOIN cygx_article AS art ON art.article_id = r.article_id
  410. LEFT JOIN cygx_report_mapping AS re ON re.category_id = art.category_id_two
  411. LEFT JOIN cygx_industrial_article_group_management AS man ON man.article_id = art.article_id
  412. WHERE
  413. r.mobile = ? AND is_del = 0 ` + condition + ` OR ( email = ? AND email <>'' AND is_del = 0 ` + condition + ` )
  414. GROUP BY r.id ORDER BY r.create_time DESC `
  415. if startSize > 0 || pageSize > 0 {
  416. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  417. }
  418. _, err = o.Raw(sql, mobile, email).QueryRows(&items)
  419. return
  420. }
  421. // 用户阅读记录列表 2023-08-02 优化拆分
  422. func GetCygxArticleHistoryRecordByUserNew(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  423. o := orm.NewOrmUsingDB("hz_cygx")
  424. var sql string
  425. sql += `SELECT
  426. art.title,
  427. art.article_id,
  428. art.article_id_md5,
  429. art.publish_date,
  430. art.category_name,
  431. r.create_time,
  432. r.stop_time,
  433. r.source AS source_platform,
  434. '' AS register_platform,
  435. '' AS special_type
  436. FROM
  437. cygx_article_history_record_all AS r
  438. INNER JOIN cygx_article AS art ON art.article_id = r.article_id
  439. WHERE
  440. 1= 1
  441. AND is_del = 0 ` + condition
  442. //sql += ` UNION ALL `
  443. //sql += ` SELECT
  444. // art.title,
  445. // art.id AS article_id,
  446. // '' AS article_id_md5,
  447. // art.publish_time AS publish_date,
  448. // '' AS category_name,
  449. // r.create_time,
  450. // r.stop_time,
  451. // r.register_platform AS source_platform,
  452. // r.register_platform,
  453. // art.type AS special_type
  454. // FROM
  455. // cygx_yanxuan_special_record AS r
  456. // INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  457. // WHERE 1 = 1 ` + condition
  458. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  459. err = o.Raw(totalSql).QueryRow(&total)
  460. if err != nil {
  461. return
  462. }
  463. sql += ` ORDER BY create_time DESC, article_id DESC `
  464. if startSize > 0 || pageSize > 0 {
  465. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  466. }
  467. _, err = o.Raw(sql).QueryRows(&items)
  468. return
  469. }
  470. // 用户阅读记录列表
  471. func GetCygxYanxuaSspecialHistoryRecordByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  472. o := orm.NewOrmUsingDB("hz_cygx")
  473. var sql string
  474. sql += ` SELECT
  475. art.title,
  476. art.id AS article_id,
  477. art.publish_time AS publish_date,
  478. r.create_time,
  479. r.stop_time,
  480. r.user_id,
  481. r.mobile,
  482. r.company_id,
  483. r.company_name,
  484. r.real_name,
  485. r.register_platform AS source_platform,
  486. art.type AS special_type,
  487. art.industry_tags as industry_name
  488. FROM
  489. cygx_yanxuan_special_record AS r
  490. INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  491. WHERE 1 = 1 ` + condition
  492. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  493. err = o.Raw(totalSql).QueryRow(&total)
  494. if err != nil {
  495. return
  496. }
  497. sql += ` ORDER BY create_time DESC, article_id DESC `
  498. if startSize > 0 || pageSize > 0 {
  499. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  500. }
  501. _, err = o.Raw(sql).QueryRows(&items)
  502. return
  503. }
  504. // 用户阅读记录列表
  505. func GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  506. o := orm.NewOrmUsingDB("hz_cygx")
  507. var sql string
  508. sql += ` SELECT
  509. art.title,
  510. art.id AS article_id,
  511. art.publish_time AS publish_date,
  512. r.create_time,
  513. r.stop_time,
  514. r.user_id,
  515. r.mobile,
  516. r.company_id,
  517. r.company_name,
  518. r.real_name,
  519. r.register_platform AS source_platform,
  520. art.type AS special_type,
  521. art.industry_tags as industry_name
  522. FROM
  523. cygx_yanxuan_special_record AS r
  524. INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  525. INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id AND us.product_id = 2
  526. WHERE 1 = 1 ` + condition
  527. databaseName := utils.GetWeeklyDatabase()
  528. sql = fmt.Sprintf(sql, databaseName)
  529. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  530. err = o.Raw(totalSql).QueryRow(&total)
  531. if err != nil {
  532. return
  533. }
  534. sql += ` ORDER BY create_time DESC, article_id DESC `
  535. if startSize > 0 || pageSize > 0 {
  536. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  537. }
  538. _, err = o.Raw(sql).QueryRows(&items)
  539. return
  540. }
  541. // 用户阅读记录列表
  542. func GetCygxYanxuanSpecialCollectByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  543. o := orm.NewOrmUsingDB("hz_cygx")
  544. var sql string
  545. sql += ` SELECT
  546. art.title,
  547. art.id AS article_id,
  548. art.publish_time AS publish_date,
  549. r.create_time,
  550. r.user_id,
  551. r.mobile,
  552. r.company_id,
  553. r.company_name,
  554. r.real_name,
  555. r.register_platform AS source_platform,
  556. art.type AS special_type,
  557. art.industry_tags as industry_name
  558. FROM
  559. cygx_yanxuan_special_collect AS r
  560. INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  561. WHERE 1 = 1 ` + condition
  562. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  563. err = o.Raw(totalSql).QueryRow(&total)
  564. if err != nil {
  565. return
  566. }
  567. sql += ` ORDER BY create_time DESC, article_id DESC `
  568. if startSize > 0 || pageSize > 0 {
  569. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  570. }
  571. _, err = o.Raw(sql).QueryRows(&items)
  572. return
  573. }
  574. // 用户阅读记录列表
  575. func GetCygxYanxuanSpecialCollectByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  576. o := orm.NewOrmUsingDB("hz_cygx")
  577. var sql string
  578. sql += ` SELECT
  579. art.title,
  580. art.id AS article_id,
  581. art.publish_time AS publish_date,
  582. r.create_time,
  583. r.user_id,
  584. r.mobile,
  585. r.company_id,
  586. r.company_name,
  587. r.real_name,
  588. r.register_platform AS source_platform,
  589. art.type AS special_type,
  590. art.industry_tags as industry_name
  591. FROM
  592. cygx_yanxuan_special_collect AS r
  593. INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  594. INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id AND us.product_id = 2
  595. WHERE 1 = 1 ` + condition
  596. databaseName := utils.GetWeeklyDatabase()
  597. sql = fmt.Sprintf(sql, databaseName)
  598. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  599. err = o.Raw(totalSql).QueryRow(&total)
  600. if err != nil {
  601. return
  602. }
  603. sql += ` ORDER BY create_time DESC, article_id DESC `
  604. if startSize > 0 || pageSize > 0 {
  605. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  606. }
  607. _, err = o.Raw(sql).QueryRows(&items)
  608. return
  609. }
  610. // 用户阅读记录列表
  611. func GetCygxYanxuanSpecialAuthorByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  612. o := orm.NewOrmUsingDB("hz_cygx")
  613. var sql string
  614. sql += ` SELECT
  615. art.special_name as title,
  616. art.id AS department_id,
  617. art.nick_name,
  618. art.article_num,
  619. art.fans_num,
  620. art.mobile_init,
  621. r.create_time,
  622. r.user_id,
  623. r.mobile,
  624. r.company_id,
  625. r.company_name,
  626. r.real_name,
  627. r.register_platform AS source_platform
  628. FROM
  629. cygx_yanxuan_special_follow AS r
  630. INNER JOIN cygx_yanxuan_special_author AS art ON art.user_id = r.follow_user_id
  631. WHERE 1 = 1 ` + condition
  632. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  633. err = o.Raw(totalSql).QueryRow(&total)
  634. if err != nil {
  635. return
  636. }
  637. sql += ` ORDER BY create_time DESC, department_id DESC `
  638. if startSize > 0 || pageSize > 0 {
  639. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  640. }
  641. _, err = o.Raw(sql).QueryRows(&items)
  642. return
  643. }
  644. // 用户阅读记录列表
  645. func GetCygxYanxuanSpecialAuthorByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  646. o := orm.NewOrmUsingDB("hz_cygx")
  647. var sql string
  648. sql += ` SELECT
  649. art.special_name as title,
  650. art.id AS department_id,
  651. art.nick_name,
  652. art.article_num,
  653. art.fans_num,
  654. art.mobile_init,
  655. r.create_time,
  656. r.user_id,
  657. r.mobile,
  658. r.company_id,
  659. r.company_name,
  660. r.real_name,
  661. r.register_platform AS source_platform
  662. FROM
  663. cygx_yanxuan_special_follow AS r
  664. INNER JOIN cygx_yanxuan_special_author AS art ON art.user_id = r.follow_user_id
  665. INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id AND us.product_id = 2
  666. WHERE 1 = 1 ` + condition
  667. databaseName := utils.GetWeeklyDatabase()
  668. sql = fmt.Sprintf(sql, databaseName)
  669. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  670. err = o.Raw(totalSql).QueryRow(&total)
  671. if err != nil {
  672. return
  673. }
  674. sql += ` ORDER BY create_time DESC, department_id DESC `
  675. if startSize > 0 || pageSize > 0 {
  676. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  677. }
  678. _, err = o.Raw(sql).QueryRows(&items)
  679. return
  680. }
  681. // 收藏列表数量
  682. func GetCygxArticleCollectCount(uid int, condition string) (count int, err error) {
  683. o := orm.NewOrmUsingDB("hz_cygx")
  684. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_article_collect as r INNER JOIN cygx_article AS art ON art.article_id = r.article_id WHERE user_id = ? ` + condition
  685. err = o.Raw(sqlCount, uid).QueryRow(&count)
  686. return
  687. }
  688. // 收藏列表
  689. func GetCygxArticleCollectByUser(uid, startSize, pageSize int, condition string) (items []*UserInteraction, err error) {
  690. o := orm.NewOrmUsingDB("hz_cygx")
  691. sql := ` SELECT
  692. art.title,
  693. art.article_id,
  694. art.report_id,
  695. art.article_id_md5,
  696. art.publish_date,
  697. re.chart_permission_name,
  698. re.chart_permission_id,
  699. r.create_time,
  700. re.match_type_name,
  701. (
  702. SELECT
  703. GROUP_CONCAT( DISTINCT s.subject_name SEPARATOR '/' )
  704. FROM
  705. cygx_industrial_subject AS s
  706. WHERE
  707. s.industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_article_group_subject AS sg WHERE sg.article_id = art.article_id )
  708. ) AS subject_name_str,
  709. (
  710. SELECT
  711. GROUP_CONCAT( DISTINCT man.industry_name SEPARATOR '/' )
  712. FROM
  713. cygx_industrial_management AS man
  714. WHERE
  715. man.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_article_group_management AS man_g WHERE man_g.article_id = art.article_id )
  716. ) AS industry_name
  717. FROM
  718. cygx_article_collect AS r
  719. INNER JOIN cygx_article AS art ON art.article_id = r.article_id
  720. LEFT JOIN cygx_report_mapping AS re ON re.category_id = art.category_id_two
  721. LEFT JOIN cygx_industrial_article_group_management AS man ON man.article_id = art.article_id
  722. WHERE
  723. user_id = ? ` + condition + ` GROUP BY r.article_id
  724. ORDER BY r.create_time DESC `
  725. if startSize > 0 || pageSize > 0 {
  726. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  727. }
  728. _, err = o.Raw(sql, uid).QueryRows(&items)
  729. return
  730. }
  731. // 关注作者数量
  732. func GetCygArticleDepartmentFollowCount(uid int) (count int, err error) {
  733. o := orm.NewOrmUsingDB("hz_cygx")
  734. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_article_department_follow WHERE user_id = ? AND type = 1 `
  735. err = o.Raw(sqlCount, uid).QueryRow(&count)
  736. return
  737. }
  738. // 关注作者列表
  739. func GetCygArticleDepartmentFollowByUser(uid, startSize, pageSize int) (items []*UserInteraction, err error) {
  740. o := orm.NewOrmUsingDB("hz_cygx")
  741. sql := `SELECT
  742. m.department_id,
  743. m.nick_name,
  744. f.modify_time as create_time,
  745. m.department_id,
  746. i.industry_name,
  747. a.title,
  748. a.article_id,
  749. ( SELECT GROUP_CONCAT( DISTINCT i.industry_name SEPARATOR '/' ) FROM cygx_industrial_management AS i WHERE i.industrial_management_id = mg.industrial_management_id ) AS industry_name,
  750. ( SELECT GROUP_CONCAT( DISTINCT s.subject_name SEPARATOR '/' ) FROM cygx_industrial_subject AS s WHERE s.industrial_management_id = i.industrial_management_id ) AS subject_name_str
  751. FROM
  752. cygx_article_department_follow AS f
  753. INNER JOIN cygx_article_department AS m ON m.department_id = f.department_id
  754. LEFT JOIN cygx_article AS a ON a.department_id = m.department_id
  755. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  756. LEFT JOIN cygx_industrial_management AS i ON i.industrial_management_id = mg.industrial_management_id
  757. WHERE f.user_id = ? AND f.type = 1 GROUP BY m.department_id
  758. ORDER BY f.create_time DESC LIMIT ?,? `
  759. _, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
  760. return
  761. }
  762. // 用户搜索关键词统计
  763. func GetCygxSearchKeyWordCount(uid int, condition string) (count int, err error) {
  764. o := orm.NewOrmUsingDB("hz_cygx")
  765. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_search_key_word WHERE user_id = ? ` + condition
  766. err = o.Raw(sqlCount, uid).QueryRow(&count)
  767. return
  768. }
  769. // 用户搜索关键词列表
  770. func GetCygxSearchKeyWordByUser(condition string, uid, startSize, pageSize int) (items []*UserInteraction, err error) {
  771. o := orm.NewOrmUsingDB("hz_cygx")
  772. sql := `SELECT
  773. key_word,create_time
  774. FROM
  775. cygx_search_key_word as k
  776. WHERE user_id = ? ` + condition + `
  777. ORDER BY k.create_time DESC LIMIT ?,? `
  778. _, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
  779. return
  780. }
  781. // 用户专项产业调研统计
  782. func GetCygxActivitySpecialTripCount(condition string, pars []interface{}) (count int, err error) {
  783. o := orm.NewOrmUsingDB("hz_cygx")
  784. sqlCount := `SELECT
  785. COUNT( 1 )
  786. FROM
  787. cygx_activity_special_meeting_detail AS h
  788. INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id
  789. WHERE
  790. 1 = 1
  791. AND a.publish_status = 1 AND a.activity_time_end < NOW() ` + condition
  792. err = o.Raw(sqlCount, pars).QueryRow(&count)
  793. return
  794. }
  795. // 用户专项产业调研列表
  796. func GetCygxActivitySpecialTripByUser(uid, startSize, pageSize int) (items []*UserInteraction, err error) {
  797. o := orm.NewOrmUsingDB("hz_cygx")
  798. sql := `SELECT
  799. a.research_theme AS activity_name,
  800. a.chart_permission_name,
  801. a.activity_time_text_by_day AS activity_time_text,
  802. a.city,
  803. a.activity_id,
  804. a.special_type AS activity_type,
  805. h.is_meeting
  806. FROM
  807. cygx_activity_special_meeting_detail AS h
  808. INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id
  809. WHERE
  810. 1 = 1
  811. AND a.publish_status = 1 AND a.activity_time_end < NOW()
  812. AND h.user_id = ?
  813. ORDER BY a.activity_time DESC LIMIT ?,? `
  814. _, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
  815. return
  816. }
  817. // 用户音视频浏览统计
  818. func GetCygxRoadshowCount(uid int) (count int, err error) {
  819. o := orm.NewOrmUsingDB("hz_cygx")
  820. sqlCount := `SELECT
  821. COUNT( 1 ) total
  822. FROM
  823. (
  824. SELECT
  825. ""
  826. FROM
  827. cygx_micro_roadshow_video_history AS r
  828. INNER JOIN cygx_micro_roadshow_video AS v ON r.video_id = v.video_id
  829. WHERE
  830. r.user_id = ? UNION ALL
  831. SELECT
  832. ""
  833. FROM
  834. cygx_activity_video_history AS r
  835. INNER JOIN cygx_activity_video AS v ON r.video_id = v.video_id
  836. WHERE
  837. r.user_id = ? UNION ALL
  838. SELECT
  839. ""
  840. FROM
  841. cygx_activity_voice_history AS r
  842. INNER JOIN cygx_activity_voice AS v ON r.activity_id = v.activity_id
  843. WHERE
  844. r.user_id = ?
  845. )z `
  846. err = o.Raw(sqlCount, uid, uid, uid).QueryRow(&count)
  847. return
  848. }
  849. // 用户专项产业调研列表
  850. func GetCygxRoadshowByUser(uid, startSize, pageSize int) (items []*UserInteraction, err error) {
  851. o := orm.NewOrmUsingDB("hz_cygx")
  852. sql := `SELECT
  853. v.video_name AS media_title,
  854. r.create_time,
  855. "逻辑解析" AS file_type
  856. FROM
  857. cygx_micro_roadshow_video_history AS r
  858. INNER JOIN cygx_micro_roadshow_video AS v ON r.video_id = v.video_id
  859. WHERE
  860. r.user_id = ? UNION ALL
  861. SELECT
  862. v.video_name AS media_title,
  863. r.create_time,
  864. "路演回放" AS file_type
  865. FROM
  866. cygx_activity_video_history AS r
  867. INNER JOIN cygx_activity_video AS v ON r.video_id = v.video_id
  868. WHERE
  869. r.user_id = ? UNION ALL
  870. SELECT
  871. v.voice_name AS media_title,
  872. r.create_time,
  873. "路演回放" AS file_type
  874. FROM
  875. cygx_activity_voice_history AS r
  876. INNER JOIN cygx_activity_voice AS v ON r.activity_id = v.activity_id
  877. WHERE
  878. r.user_id = ?
  879. ORDER BY create_time DESC LIMIT ?,? `
  880. _, err = o.Raw(sql, uid, uid, uid, startSize, pageSize).QueryRows(&items)
  881. return
  882. }
  883. // 线上已到会列表
  884. func GetAttendanceDetailListByUser(isMeeting int, mobile string, startSize, pageSize int) (item []*UserInteraction, err error) {
  885. o := orm.NewOrmUsingDB("hz_cygx")
  886. sql := `SELECT
  887. s.signup_type,
  888. a.activity_name,
  889. a.chart_permission_name,
  890. a.activity_type_name,
  891. a.label,
  892. a.activity_time,
  893. d.first_meeting_time,
  894. d.last_meeting_time,
  895. d.meeting_type_str,
  896. d.meeting_authentication,
  897. d.meeting_status_str,
  898. d.duration
  899. FROM
  900. cygx_activity_signup AS s
  901. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  902. INNER JOIN cygx_activity_attendance_detail AS d ON d.activity_id = s.activity_id
  903. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  904. WHERE
  905. 1 = 1
  906. AND s.do_fail_type = 0
  907. AND s.is_cancel = 0
  908. AND s.is_meeting = ?
  909. AND s.mobile = ?
  910. AND a.is_submit_meeting = 1
  911. AND t.activity_type = 1
  912. GROUP BY
  913. a.activity_id
  914. ORDER BY
  915. a.activity_time DESC
  916. LIMIT ?,?`
  917. _, err = o.Raw(sql, isMeeting, mobile, startSize, pageSize).QueryRows(&item)
  918. return
  919. }
  920. // 线上未来到会列表
  921. func GetAttendanceDetailListNoMeetingByUser(isMeeting int, mobile string, startSize, pageSize int) (item []*UserInteraction, err error) {
  922. o := orm.NewOrmUsingDB("hz_cygx")
  923. sql := `SELECT
  924. s.signup_type,
  925. a.activity_name,
  926. a.chart_permission_name,
  927. a.activity_type_name,
  928. a.label,
  929. a.activity_time,
  930. ( SELECT COUNT( 1 ) FROM cygx_activity_meeting_reminder AS rm WHERE rm.activity_id = s.activity_id AND rm.mobile = s.mobile ) AS reminder_num
  931. FROM
  932. cygx_activity_signup AS s
  933. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  934. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  935. WHERE
  936. 1 = 1
  937. AND s.do_fail_type = 0
  938. AND s.is_cancel = 0
  939. AND s.is_meeting = ?
  940. AND s.mobile = ?
  941. AND a.is_submit_meeting = 1
  942. AND t.activity_type = 1
  943. GROUP BY
  944. a.activity_id
  945. ORDER BY
  946. a.activity_time DESC
  947. LIMIT ?,?`
  948. _, err = o.Raw(sql, isMeeting, mobile, startSize, pageSize).QueryRows(&item)
  949. return
  950. }
  951. // 用户参会统计
  952. func GetAttendanceDetaiCount(mobile string, meetType, isMeeting int) (count int, err error) {
  953. o := orm.NewOrmUsingDB("hz_cygx")
  954. sqlCount := ` SELECT
  955. COUNT( DISTINCT a.activity_id ) as count
  956. FROM
  957. cygx_activity_signup AS s
  958. INNER JOIN cygx_activity as a ON a.activity_id = s.activity_id
  959. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  960. WHERE
  961. mobile = ?
  962. AND is_meeting =?
  963. AND s.do_fail_type = 0
  964. AND a.is_submit_meeting = 1 `
  965. if meetType == 1 {
  966. sqlCount += ` AND t.activity_type = 1 `
  967. } else {
  968. sqlCount += ` AND t.activity_type = 0 `
  969. }
  970. err = o.Raw(sqlCount, mobile, isMeeting).QueryRow(&count)
  971. return
  972. }
  973. // 线下已到会列表
  974. func GetAttendanceOfflineListByUser(isMeeting int, mobile string, startSize, pageSize int) (item []*UserInteraction, err error) {
  975. o := orm.NewOrmUsingDB("hz_cygx")
  976. sql := `SELECT
  977. a.activity_name,
  978. a.chart_permission_name,
  979. a.activity_type_name,
  980. a.label,
  981. a.activity_time
  982. FROM
  983. cygx_activity_signup AS s
  984. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  985. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  986. WHERE
  987. 1 = 1
  988. AND s.do_fail_type = 0
  989. AND s.is_cancel = 0
  990. AND s.is_meeting = ?
  991. AND s.mobile = ?
  992. AND a.is_submit_meeting = 1
  993. AND t.activity_type = 0
  994. GROUP BY
  995. a.activity_id
  996. ORDER BY
  997. a.activity_time DESC
  998. LIMIT ?,?`
  999. _, err = o.Raw(sql, isMeeting, mobile, startSize, pageSize).QueryRows(&item)
  1000. return
  1001. }
  1002. // 获取用户参会记录数量
  1003. func GetActivityMeetByUserCount(condition string) (count int, err error) {
  1004. o := orm.NewOrmUsingDB("hz_cygx")
  1005. sqlCount := ` SELECT
  1006. COUNT( DISTINCT a.activity_id ) as count
  1007. FROM
  1008. cygx_activity_signup_detail AS s
  1009. INNER JOIN cygx_activity as a ON a.activity_id = s.activity_id
  1010. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  1011. WHERE
  1012. 1=1
  1013. AND s.do_fail_type = 0 `
  1014. if condition != "" {
  1015. sqlCount += condition
  1016. }
  1017. err = o.Raw(sqlCount).QueryRow(&count)
  1018. return
  1019. }
  1020. // 获取用户参会记录
  1021. func GetActivityMeetByUser(condition string, startSize, pageSize int) (item []*UserInteraction, err error) {
  1022. o := orm.NewOrmUsingDB("hz_cygx")
  1023. sql := `SELECT
  1024. t.activity_type,
  1025. s.signup_type,
  1026. s.is_meeting,
  1027. s.real_name,
  1028. s.mobile,
  1029. s.company_id,
  1030. a.activity_name,
  1031. a.chart_permission_name,
  1032. a.activity_type_name,
  1033. a.label,
  1034. a.activity_time,
  1035. s.first_meeting_time,
  1036. s.last_meeting_time,
  1037. s.meeting_type_str,
  1038. s.meeting_authentication,
  1039. s.meeting_status_str,
  1040. s.duration
  1041. FROM
  1042. cygx_activity_signup_detail AS s
  1043. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  1044. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  1045. WHERE
  1046. 1 = 1
  1047. AND s.do_fail_type = 0 ` + condition + `
  1048. GROUP BY
  1049. s.mobile
  1050. ORDER BY
  1051. a.activity_time DESC `
  1052. if startSize > 0 || pageSize > 0 {
  1053. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  1054. }
  1055. _, err = o.Raw(sql).QueryRows(&item)
  1056. return
  1057. }
  1058. // 获取用户参会记录
  1059. func GetActivitySpecialMeetByUser(condition string, startSize, pageSize int) (item []*UserInteraction, err error) {
  1060. o := orm.NewOrmUsingDB("hz_cygx")
  1061. sql := `SELECT
  1062. a.activity_id,
  1063. a.research_theme AS activity_name,
  1064. a.chart_permission_name,
  1065. special_type AS activity_type,
  1066. a.activity_time,
  1067. a.activity_time_text_by_day AS activity_time_text
  1068. FROM
  1069. cygx_activity_special_meeting_detail AS s
  1070. INNER JOIN cygx_activity_special AS a ON a.activity_id = s.activity_id
  1071. WHERE
  1072. 1 = 1 ` + condition + `
  1073. GROUP BY
  1074. s.activity_id,
  1075. s.mobile
  1076. ORDER BY
  1077. a.activity_time DESC `
  1078. if startSize > 0 || pageSize > 0 {
  1079. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  1080. }
  1081. _, err = o.Raw(sql).QueryRows(&item)
  1082. return
  1083. }
  1084. type GetUserInteractionTableCountResp struct {
  1085. HistoryNum int `description:"报告阅读"`
  1086. CountNum int `description:"报告收藏"`
  1087. IndustryFllowNum int `description:"产业关注"`
  1088. DepartmentFollowNum int `description:"作者关注"`
  1089. KeyWordNum int `description:"搜索关键词"`
  1090. OnLineNum int `description:"线上互动活动"`
  1091. OfficeNum int `description:"线下互动活动"`
  1092. ActivityNum int `description:"活动数量"`
  1093. ChartNum int `description:"图表数量"`
  1094. TripNum int `description:"图表数量"`
  1095. RoadshowVideoNum int `description:"产业视频播放量"`
  1096. ActivityVideoNum int `description:"活动视频播放量"`
  1097. ActivityVoiceNum int `description:"活动音频播放量"`
  1098. TagNum int `description:"首页标签点击量"`
  1099. YanxuanSpecialNum int `description:"研选专栏阅读数量"`
  1100. YanxuanSpecialCollectNum int `description:"研选专栏收藏数量"`
  1101. YanxuanSpecialFollowNum int `description:"研选专栏作者关注数量"`
  1102. FeedbackNum int `description:"交流反馈数量"`
  1103. }
  1104. // 用户互动总数统计
  1105. func GetUserInteractionTableCount(uid int) (item *GetUserInteractionTableCountResp, err error) {
  1106. o := orm.NewOrmUsingDB("hz_cygx")
  1107. sql := `SELECT
  1108. ( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h INNER JOIN cygx_article as art ON art.article_id = h.article_id WHERE h.user_id = ? AND h.is_del = 0 AND art.article_type_id = 0 ) AS history_num,
  1109. ( SELECT COUNT( 1 ) FROM cygx_article_collect AS h INNER JOIN cygx_article as art ON art.article_id = h.article_id WHERE h.user_id = ? AND art.article_type_id = 0 ) AS count_num,
  1110. ( SELECT COUNT( 1 ) FROM cygx_chart_collect AS h INNER JOIN cygx_chart_all AS a ON h.chart_id = a.chart_id WHERE h.user_id = ? ) AS chart_num,
  1111. ( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h INNER JOIN cygx_industrial_management as a ON a.industrial_management_id = h.industrial_management_id WHERE h.user_id = ? AND h.type = 1 AND h.source IN (0,1,2) AND a.chart_permission_id != 31 ) AS industry_fllow_num,
  1112. ( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.user_id = ? AND h.register_platform IN(1,2) ) AS key_word_num,
  1113. ( SELECT COUNT( DISTINCT a.activity_id ) as count FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id WHERE h.user_id = ?
  1114. AND t.activity_type=1 AND h.do_fail_type = 0 AND a.chart_permission_id != 31 ) AS on_line_num,
  1115. ( SELECT COUNT( DISTINCT a.activity_id ) as count FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id WHERE h.user_id = ?
  1116. AND t.activity_type = 0 AND h.do_fail_type = 0 AND a.chart_permission_id != 31 ) AS office_num,
  1117. ( SELECT COUNT( 1 ) FROM cygx_activity_special_meeting_detail AS h INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id WHERE h.user_id = ? AND a.publish_status = 1 AND a.activity_time_end < NOW()) AS trip_num,
  1118. ( SELECT COUNT( 1 ) FROM cygx_micro_roadshow_video_history AS h INNER JOIN cygx_micro_roadshow_video as v ON v.video_id = h.video_id WHERE h.user_id = ? ) AS roadshow_video_num,
  1119. ( SELECT COUNT( 1 ) FROM cygx_activity_video_history AS h INNER JOIN cygx_activity_video as v ON v.video_id = h.video_id WHERE h.user_id = ? ) AS activity_video_num,
  1120. ( SELECT COUNT( 1 ) FROM cygx_activity_voice_history AS h INNER JOIN cygx_activity_voice as v ON v.activity_id = h.activity_id WHERE h.user_id = ? ) AS activity_voice_num,
  1121. ( SELECT COUNT(1) FROM cygx_tag_history as h INNER JOIN cygx_tag AS b ON h.tag_id = b.tag_id WHERE h.user_id = ? ) AS tag_num,
  1122. ( SELECT COUNT(1) FROM cygx_user_feedback as h WHERE h.user_id = ? ) AS feedback_num
  1123. FROM dual `
  1124. err = o.Raw(sql, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid).QueryRow(&item)
  1125. return
  1126. }
  1127. // 用户互动总数统计
  1128. func GetUserInteractionTableCountByYanXuan(uid int) (item *GetUserInteractionTableCountResp, err error) {
  1129. o := orm.NewOrmUsingDB("hz_cygx")
  1130. sql := `SELECT
  1131. ( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h INNER JOIN cygx_article as art ON art.article_id = h.article_id WHERE h.user_id = ? AND h.is_del = 0 AND art.article_type_id > 0 ) AS history_num,
  1132. ( SELECT COUNT( 1 ) FROM cygx_article_collect AS h INNER JOIN cygx_article as art ON art.article_id = h.article_id WHERE h.user_id = ? AND art.article_type_id > 0 ) AS count_num,
  1133. ( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h INNER JOIN cygx_industrial_management as a ON a.industrial_management_id = h.industrial_management_id WHERE h.user_id = ? AND h.type = 1 AND h.source IN (0,1,2) AND a.chart_permission_id = 31 ) AS industry_fllow_num,
  1134. ( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS h WHERE h.user_id = ? AND h.type = 1 ) AS department_follow_num,
  1135. ( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.user_id = ? AND h.register_platform IN(5,6) ) AS key_word_num,
  1136. ( SELECT COUNT( DISTINCT a.activity_id ) as count FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id WHERE h.user_id = ?
  1137. AND t.activity_type=1 AND h.do_fail_type = 0 AND a.chart_permission_id = 31 ) AS on_line_num,
  1138. ( SELECT COUNT( DISTINCT a.activity_id ) as count FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id WHERE h.user_id = ?
  1139. AND t.activity_type = 0 AND h.do_fail_type = 0 AND a.chart_permission_id = 31 ) AS office_num,
  1140. ( SELECT COUNT(1) FROM cygx_yanxuan_special_collect as h INNER JOIN cygx_yanxuan_special AS b ON h.yanxuan_special_id = b.id WHERE h.user_id = ? ) AS yanxuan_special_collect_num,
  1141. ( SELECT COUNT(1) FROM cygx_yanxuan_special_follow as h WHERE h.user_id = ? ) AS yanxuan_special_follow_num,
  1142. ( SELECT COUNT(1) FROM cygx_yanxuan_special_record as h INNER JOIN cygx_yanxuan_special AS b ON h.yanxuan_special_id = b.id WHERE h.user_id = ? ) AS yanxuan_special_num
  1143. FROM dual `
  1144. err = o.Raw(sql, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid).QueryRow(&item)
  1145. return
  1146. }
  1147. // 根据时间获取用户互动总数统计
  1148. func GetUserInteractionTableCountBytime(uid int, startDate, endDate string) (item *GetUserInteractionTableCountResp, err error) {
  1149. o := orm.NewOrm()
  1150. sql := `SELECT
  1151. ( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h INNER JOIN cygx_article as art ON art.article_id = h.article_id WHERE h.mobile = u.mobile AND h.is_del = 0 AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `' OR ( h.email = u.email AND h.email <>'' AND h.is_del = 0 AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `' ) ) AS history_num,
  1152. ( SELECT COUNT( 1 ) FROM cygx_article_collect AS h WHERE h.user_id = u.user_id AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `' ) AS count_num,
  1153. ( SELECT COUNT( 1 ) FROM cygx_chart_collect AS h WHERE h.user_id = u.user_id AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `' ) AS chart_num,
  1154. ( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h WHERE h.user_id = u.user_id AND h.type = 1 AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `' ) AS industry_fllow_num,
  1155. ( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS h WHERE h.user_id = u.user_id AND h.type = 1 AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `' ) AS department_follow_num,
  1156. ( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.user_id = u.user_id AND create_time BETWEEN '` + startDate + `'AND '` + endDate + `' ) AS key_word_num,
  1157. ( SELECT COUNT( DISTINCT a.activity_id ) as count FROM cygx_activity_signup AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id WHERE h.mobile = u.mobile
  1158. AND a.is_submit_meeting = 1 AND t.activity_type=1 AND h.do_fail_type = 0 AND a.activity_time BETWEEN '` + startDate + `'AND '` + endDate + `' ) AS on_line_num,
  1159. ( SELECT COUNT( DISTINCT a.activity_id ) as count FROM cygx_activity_signup AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id WHERE h.mobile = u.mobile
  1160. AND a.is_submit_meeting = 1 AND t.activity_type = 0 AND h.do_fail_type = 0 AND a.activity_time BETWEEN '` + startDate + `'AND '` + endDate + `') AS office_num
  1161. FROM
  1162. wx_user as u
  1163. WHERE
  1164. u.user_id = ?`
  1165. err = o.Raw(sql, uid).QueryRow(&item)
  1166. return
  1167. }
  1168. type ArticlePvCountResp struct {
  1169. ArticleId int `description:"文章ID"`
  1170. Pv int `description:"Pv"`
  1171. }
  1172. // 阅读记录
  1173. func GetArticlePvCount(mobile, email, dateTime string) (item []*ArticlePvCountResp, err error) {
  1174. o := orm.NewOrmUsingDB("hz_cygx")
  1175. sql := `SELECT
  1176. article_id,
  1177. COUNT(article_id) as pv
  1178. FROM
  1179. cygx_article_history_record_all as h
  1180. WHERE
  1181. mobile = ?
  1182. AND create_time >= ?
  1183. AND is_del = 0
  1184. OR ( email = ? AND email <>'' AND create_time >= ? AND is_del = 0 )
  1185. GROUP BY article_id `
  1186. _, err = o.Raw(sql, mobile, dateTime, email, dateTime).QueryRows(&item)
  1187. return
  1188. }
  1189. type ArticleIndustryNameResp struct {
  1190. ArticleId int `description:"文章ID"`
  1191. IndustryName string `description:"产业名称"`
  1192. SubjectName string `description:"标的名称"`
  1193. }
  1194. // 产业名称
  1195. func GetArticleGroupyIndustryName(articleIds string) (item []*ArticleIndustryNameResp, err error) {
  1196. o := orm.NewOrmUsingDB("hz_cygx")
  1197. sql := `SELECT
  1198. art.article_id,
  1199. (
  1200. SELECT
  1201. GROUP_CONCAT( DISTINCT s.subject_name SEPARATOR '/' )
  1202. FROM
  1203. cygx_industrial_subject AS s
  1204. WHERE
  1205. s.industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_article_group_subject AS sg WHERE sg.article_id = art.article_id )
  1206. ) AS subject_name,
  1207. (
  1208. SELECT
  1209. GROUP_CONCAT( DISTINCT man.industry_name SEPARATOR '/' )
  1210. FROM
  1211. cygx_industrial_management AS man
  1212. WHERE
  1213. man.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_article_group_management AS man_g WHERE man_g.article_id = art.article_id )
  1214. ) AS industry_name
  1215. FROM
  1216. cygx_article_history_record_all AS r
  1217. INNER JOIN cygx_article AS art ON art.article_id = r.article_id
  1218. LEFT JOIN cygx_report_mapping AS re ON re.category_id = art.category_id_two
  1219. LEFT JOIN cygx_industrial_article_group_management AS man ON man.article_id = art.article_id
  1220. WHERE
  1221. art.article_id IN ( ` + articleIds + `) GROUP BY art.article_id `
  1222. _, err = o.Raw(sql).QueryRows(&item)
  1223. return
  1224. }
  1225. // 标的名称
  1226. func GetArticleGroupySubjectName(articleIds string) (item []*ArticleIndustryNameResp, err error) {
  1227. o := orm.NewOrmUsingDB("hz_cygx")
  1228. sql := `SELECT
  1229. article_id,
  1230. subject_name
  1231. FROM
  1232. cygx_industrial_article_group_subject AS mg
  1233. INNER JOIN cygx_industrial_subject AS m ON m.industrial_subject_id = mg.industrial_subject_id
  1234. WHERE
  1235. article_id IN ( ` + articleIds + `)`
  1236. _, err = o.Raw(sql).QueryRows(&item)
  1237. return
  1238. }
  1239. type UserLabel struct {
  1240. Label string `description:"标签 多个用 , 隔开"`
  1241. }
  1242. type ActivityLabelCountResp struct {
  1243. Label string `description:"标签"`
  1244. Pv int `description:"Pv"`
  1245. }
  1246. // 活动标签记录(我的日程)
  1247. func GetActivitySignCount(mobile, dateTime string) (item []*ActivityLabelCountResp, err error) {
  1248. o := orm.NewOrmUsingDB("hz_cygx")
  1249. sql := `SELECT
  1250. label ,
  1251. COUNT( label ) AS pv
  1252. FROM
  1253. cygx_activity
  1254. WHERE
  1255. activity_id IN ( SELECT activity_id FROM cygx_my_schedule WHERE mobile = ? )
  1256. AND label != ''
  1257. AND activity_time >= ?
  1258. GROUP BY
  1259. label`
  1260. _, err = o.Raw(sql, mobile, dateTime).QueryRows(&item)
  1261. return
  1262. }
  1263. // 活动标签记录(会议提醒)
  1264. func GetActivityMeetingReminder(mobile, dateTime string) (item []*ActivityLabelCountResp, err error) {
  1265. o := orm.NewOrmUsingDB("hz_cygx")
  1266. sql := `SELECT
  1267. label ,
  1268. COUNT( label ) AS pv
  1269. FROM
  1270. cygx_activity
  1271. WHERE
  1272. activity_id IN ( SELECT activity_id FROM cygx_activity_meeting_reminder WHERE mobile = ? )
  1273. AND label != ''
  1274. AND activity_time >= ?
  1275. GROUP BY
  1276. label`
  1277. _, err = o.Raw(sql, mobile, dateTime).QueryRows(&item)
  1278. return
  1279. }
  1280. func GetCygxArticleCollectId(uid int, dateTime string) (articleIds string, err error) {
  1281. sql := `SELECT
  1282. GROUP_CONCAT( DISTINCT article_id SEPARATOR ',' ) AS permission
  1283. FROM
  1284. cygx_article_collect
  1285. WHERE
  1286. user_id = ?
  1287. AND create_time >= ? `
  1288. o := orm.NewOrmUsingDB("hz_cygx")
  1289. err = o.Raw(sql, uid, dateTime).QueryRow(&articleIds)
  1290. return
  1291. }
  1292. // 用户互动量
  1293. type CygxInteractionNumResp struct {
  1294. DateTime string `description:"时间"`
  1295. InteractionNum int `description:"互动量"`
  1296. }
  1297. type CygxCygxInteractionNumRespListResp struct {
  1298. List []*CygxInteractionNumResp
  1299. }
  1300. // 用户互动详情
  1301. type UserInteractionrelevantListResp struct {
  1302. IndustryName string `description:"产业名称"`
  1303. IsFllow bool `description:"是否关注"`
  1304. List []*UserInteraction
  1305. }
  1306. type EsUserInteraction struct {
  1307. Id int `description:"主键ID"`
  1308. ArticleId int `description:"文章id"`
  1309. ArticleType int `description:"文章类型 1:查研观向, 2:策略平台"`
  1310. Title string `description:"标题"`
  1311. PublishDate string `description:"发布时间"`
  1312. CreateTime string `description:"创建时间"`
  1313. StopTime string `description:"阅读停留时间"`
  1314. RealName string `description:"姓名"`
  1315. CompanyName string `description:"公司名称"`
  1316. CompanyId int `description:"公司ID"`
  1317. SellerName string `description:"所属销售"`
  1318. SellerId int `description:"所属销售ID"`
  1319. Mobile string `description:"手机号"`
  1320. Email string `description:"邮箱"`
  1321. UserId int `description:"用户ID"`
  1322. UserArticleHistoryNum int `description:"用户阅读数量"`
  1323. CompanyArticleHistoryNum int `description:"机构阅读数量"`
  1324. }
  1325. func GetCompanyIdsCondition(ondition string) (companyIds string, err error) {
  1326. sql := ondition
  1327. o := orm.NewOrm()
  1328. err = o.Raw(sql).QueryRow(&companyIds)
  1329. return
  1330. }
  1331. type InteractiveList struct {
  1332. TotalMap map[int]int
  1333. EsList []*EsUserInteraction
  1334. ActivityList []*company.CompanyReportRecordGroup
  1335. CollectList []*company.CompanyReportRecordGroup
  1336. IndustryFllowList []*company.CompanyReportRecordGroup
  1337. DepartmentFollowList []*company.CompanyReportRecordGroup
  1338. KeyWordList []*company.CompanyReportRecordGroup
  1339. Chartist []*company.CompanyReportRecordGroup
  1340. }
  1341. func GetAllOverseasRaiEmail() (emails []string, err error) {
  1342. sql := `
  1343. SELECT
  1344. *
  1345. FROM
  1346. (
  1347. SELECT
  1348. wu.email
  1349. FROM
  1350. wx_user AS wu
  1351. INNER JOIN company AS c
  1352. WHERE
  1353. wu.company_id = c.company_id
  1354. AND wu.email <> ""
  1355. AND c.region_type = "海外"
  1356. ) AS a UNION
  1357. (
  1358. SELECT
  1359. wu.email
  1360. FROM
  1361. company_product AS cp
  1362. INNER JOIN wx_user AS wu
  1363. WHERE
  1364. cp.industry_id = 10
  1365. AND cp.product_id = 2
  1366. AND wu.email <> ""
  1367. AND cp.status IN ( "正式", "试用" )
  1368. )`
  1369. o := orm.NewOrm()
  1370. _, err = o.Raw(sql).QueryRows(&emails)
  1371. return
  1372. }