cygx_user.go 58 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. HaveMoveButton bool `description:"是否移动过"`
  54. MfyxIsBinding bool `description:"买方研选是否绑定"`
  55. }
  56. type CompanyUserListResp struct {
  57. Paging *paging.PagingItem
  58. List []*CygxCompanyUser
  59. }
  60. // 获取数量
  61. func GetCompanyListCount(userCondition, keyWord, kwywordcondition, condition, roleTypeCode string, pars []interface{}) (count int, err error) {
  62. o := orm.NewOrm()
  63. 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 `
  64. kwywordcondition = companyCondition + kwywordcondition
  65. if condition != "" {
  66. companyCondition += condition
  67. }
  68. sql := `SELECT COUNT(DISTINCT u.user_id) AS count
  69. FROM
  70. wx_user AS u
  71. INNER JOIN company AS c ON c.company_id = u.company_id
  72. INNER JOIN company_product AS cp ON cp.company_id = c.company_id
  73. INNER JOIN admin AS m ON m.admin_id = cp.seller_id
  74. INNER JOIN user_seller_relation AS sr ON sr.user_id = u.user_id
  75. WHERE u.company_id IN (` + companyCondition + `)`
  76. if userCondition != "" {
  77. sql += userCondition
  78. }
  79. if keyWord != "" {
  80. if strings.Count(roleTypeCode, "admin") > 0 {
  81. 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 + ` )`
  82. } else {
  83. 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 + ` )`
  84. }
  85. }
  86. err = o.Raw(sql, pars).QueryRow(&count)
  87. return
  88. }
  89. // 列表
  90. func GetCygxCompanyUserList(userCondition, keyWord, kwywordcondition, condition, roleTypeCode, sqlOrder string, pars []interface{}, startSize, pageSize int) (items []*CygxCompanyUser, err error) {
  91. o := orm.NewOrm()
  92. 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 `
  93. kwywordcondition = companyCondition + kwywordcondition
  94. if condition != "" {
  95. companyCondition += condition
  96. }
  97. sql := `SELECT
  98. u.user_id,
  99. u.mobile,
  100. u.email,
  101. date_format(u.register_time,'%Y-%m-%d') as register_time,
  102. u.real_name,
  103. u.is_register,
  104. u.is_maker,
  105. u.user_label as labels,
  106. u.cygx_subscribe as is_subscribe_cygx,
  107. c.company_name,
  108. c.company_id,
  109. c.interaction_num as company_interaction_num,
  110. c.interaction_num_seller as company_interaction_num_seller,
  111. cp.status,
  112. cp.try_stage,
  113. cp.package_type,
  114. m.real_name as seller_name ,
  115. ( SELECT COUNT( 1 ) FROM user_remarks AS rm WHERE rm.user_id = u.user_id ) AS is_show_see_num
  116. FROM
  117. wx_user AS u
  118. INNER JOIN company AS c ON c.company_id = u.company_id
  119. INNER JOIN company_product AS cp ON cp.company_id = c.company_id
  120. INNER JOIN admin AS m ON m.admin_id = cp.seller_id
  121. INNER JOIN user_seller_relation AS sr ON sr.user_id = u.user_id
  122. WHERE u.company_id IN (` + companyCondition + `)`
  123. if userCondition != "" {
  124. sql += userCondition
  125. }
  126. if keyWord != "" {
  127. if strings.Count(roleTypeCode, "admin") > 0 {
  128. 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 + ` )`
  129. } else {
  130. 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 + ` )`
  131. }
  132. }
  133. if sqlOrder != "" {
  134. sql += sqlOrder + ` LIMIT ?,? `
  135. } else {
  136. sql += ` GROUP by u.user_id ORDER BY c.created_time DESC, u.register_time DESC LIMIT ?,? `
  137. }
  138. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  139. return
  140. }
  141. type CygxCompanyUserAndSellerResp struct {
  142. UserId int `description:"用户ID"`
  143. Mobile string `description:"手机号"`
  144. Email string `description:"邮箱"`
  145. CompanyId int `description:"公司id"`
  146. CompanyName string `description:"公司名称"`
  147. RealName string `description:"姓名"`
  148. SellerName string `description:"销售名称"`
  149. }
  150. // 给所有已绑定手机号的客户(除流失)列表
  151. func GetCygxCompanyUserListByNoLoss() (items []*CygxCompanyUserAndSellerResp, err error) {
  152. o := orm.NewOrm()
  153. sql := `SELECT
  154. u.user_id,
  155. u.mobile,
  156. u.email,
  157. u.real_name,
  158. c.company_name,
  159. c.company_id,
  160. m.real_name AS seller_name
  161. FROM
  162. wx_user AS u
  163. INNER JOIN company AS c ON c.company_id = u.company_id
  164. INNER JOIN company_product AS cp ON cp.company_id = c.company_id
  165. INNER JOIN admin AS m ON m.admin_id = cp.seller_id
  166. INNER JOIN user_seller_relation AS sr ON sr.user_id = u.user_id
  167. WHERE
  168. 1 = 1
  169. AND c.enabled = 1
  170. AND cp.STATUS != '流失'
  171. AND cp.product_id = 2
  172. AND sr.product_id = 2
  173. GROUP BY
  174. u.user_id `
  175. _, err = o.Raw(sql).QueryRows(&items)
  176. return
  177. }
  178. // 对于上面的SQL的拆分优化查询速度
  179. func GetCygxCompanyUserListSplit(userIds string) (items []*CygxCompanyUser, err error) {
  180. databaseName := utils.GetWeeklyDatabase()
  181. o := orm.NewOrmUsingDB("hz_cygx")
  182. sql := `SELECT
  183. u.user_id,
  184. ( 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,
  185. ( SELECT COUNT( 1 ) FROM cygx_article_collect AS h WHERE h.user_id = u.user_id ) AS count_num,
  186. ( SELECT COUNT( 1 ) FROM cygx_chart_collect AS h WHERE h.user_id = u.user_id ) AS chart_num,
  187. ( 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,
  188. ( 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,
  189. ( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.user_id = u.user_id ) AS key_word_num,
  190. ( 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
  191. AND t.activity_type = 1 AND h.do_fail_type = 0 ) AS on_line_num,
  192. ( 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
  193. AND t.activity_type = 0 AND h.do_fail_type = 0 ) AS office_num,
  194. ( 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,
  195. ( 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,
  196. ( 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,
  197. ( 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,
  198. ( 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,
  199. ( SELECT COUNT(1) FROM cygx_user_feedback as h WHERE h.mobile = u.mobile ) AS feedback_num,
  200. ( SELECT COUNT(1) FROM ` + databaseName + `.rs_calendar_meeting_user as h WHERE h.mobile = u.mobile ) AS rs_calendar_num
  201. FROM ` + databaseName + `.wx_user AS u WHERE u.user_id IN (` + userIds + `) AND u.mobile != '' GROUP BY u.user_id `
  202. _, err = o.Raw(sql).QueryRows(&items)
  203. return
  204. }
  205. type UserRemarks struct {
  206. Id int `orm:"column(id);pk"`
  207. UserId int `description:"用户ID"`
  208. AdminId int `description:"销售/管理员ID"`
  209. Content string `description:"备注信息"`
  210. CreateTime time.Time `description:"创建时间"`
  211. }
  212. type UserRemarksResp struct {
  213. Id int `orm:"column(id);pk"`
  214. UserId int `description:"用户ID"`
  215. AdminId int `description:"销售/管理员ID"`
  216. Content string `description:"备注信息"`
  217. CreateTime string `description:"创建时间"`
  218. }
  219. type UserRemarAddReq struct {
  220. UserId int `description:"用户ID"`
  221. Content string `description:"备注信息"`
  222. SourceType int `description:"操作类型,1:对联系人单独设置,2:对机构批量设置"`
  223. DoType int `description:"操作方式,1:添加,2:取消"`
  224. }
  225. // 添加UserRemarks
  226. func AddUserRemarks(item *UserRemarks) (err error) {
  227. o := orm.NewOrm()
  228. _, err = o.Insert(item)
  229. return
  230. }
  231. // 获取备注列表
  232. func GetUserRemarksList(userId int) (items []*UserRemarksResp, err error) {
  233. o := orm.NewOrm()
  234. sql := ` SELECT * FROM user_remarks WHERE user_id=? ORDER BY create_time DESC`
  235. _, err = o.Raw(sql, userId).QueryRows(&items)
  236. return
  237. }
  238. // 获取备注列表(多用户)
  239. func GetUserRemarksListByUserIds(uids string) (items []*UserRemarksResp, err error) {
  240. o := orm.NewOrm()
  241. sql := ` SELECT * FROM user_remarks WHERE user_id IN(` + uids + `) ORDER BY create_time DESC`
  242. _, err = o.Raw(sql).QueryRows(&items)
  243. return
  244. }
  245. type UserRemarksListResp struct {
  246. List []*UserRemarksResp
  247. }
  248. // 切换列表
  249. type CygxUserTableRep struct {
  250. PermissionName string `description:"名称"`
  251. Source int `description:"类型"`
  252. TotalNum int `description:"总数"`
  253. }
  254. type CygxUserTableListRep struct {
  255. List []*CygxUserTableRep
  256. UserName string `description:"用户名称"`
  257. ComapnyName string `description:"公司名称"`
  258. Mobile string `description:"手机号"`
  259. }
  260. // @Param TryStage query int false "试用客户子标签:0全部、1未分类、2 推进、3 跟踪、4 预备"
  261. // 状态搜索列表
  262. type CygxTryStageRep struct {
  263. Name string `description:"试用客户子标签"`
  264. TryStage int `description:"试用客户子标签:0全部、1未分类、2 推进、3 跟踪、4 预备"`
  265. }
  266. type CygxUserTableStatusRep struct {
  267. List []*CygxTryStageRep
  268. Name string `description:"状态"`
  269. TryStage string `description:"状态"`
  270. }
  271. type CygxUserTableStatusListRep struct {
  272. List []*CygxUserTableStatusRep
  273. }
  274. type UserInteractionListResp struct {
  275. Paging *paging.PagingItem
  276. List []*UserInteraction
  277. MeetingNum int `description:"已到会"`
  278. NoMeetingNum int `description:"未到会"`
  279. }
  280. type UserInteraction struct {
  281. ArticleId int `description:"文章id"`
  282. ReportId int `description:"研报文章id"`
  283. ActivityId int `description:"活动ID"`
  284. ArticleType int `description:"文章类型 1:查研观向, 2:策略平台"`
  285. ArticleIdMd5 string `description:"文章MD5id"`
  286. Title string `description:"标题"`
  287. MediaTitle string `description:"音视频标题"`
  288. CategoryName string `description:"行业2"`
  289. PublishDate string `description:"发布时间"`
  290. CreateTime string `description:"创建时间"`
  291. CreateDate string `orm:"column(create_time);" description:"创建时间"`
  292. PermissionName string `orm:"column(chart_permission_name);" description:"行业"`
  293. ChartPermissionId int `description:"行业id"`
  294. IndustryName string `description:"产业名称"`
  295. IndustrialManagementId int `description:"产业id"`
  296. SubjectNameStr string `description:"关联标的"`
  297. MatchTypeName string `description:"匹配类型"`
  298. StopTime string `description:"阅读停留时间"`
  299. NickName string `description:"作者昵称"`
  300. DepartmentId int `description:"作者ID "`
  301. KeyWord string `description:"关键词"`
  302. LabelKeyWord string `description:"标签关键词"`
  303. Source int `description:"关键词来源;1:纪要、2:图表、3:纪要/图表、4:产业资源包、5:报告、6:活动、7:搜索关键词、8:专项产业调研、9音视频播放"`
  304. ActivityName string `description:"活动名称"`
  305. ActivityType int `description:"1 线上,0、2线下"`
  306. IsMeeting int `description:"是否到会, 1是,0否"`
  307. ActivityTypeName string `description:"活动类型名称"`
  308. Label string `description:"标签"`
  309. ActivityTime string `description:"活动时间"`
  310. ActivityTimeText string `description:"活动时间"`
  311. FirstMeetingTime string `description:"首次入会时间"`
  312. LastMeetingTime string `description:"最后退出时间"`
  313. Duration string `description:"参会时长"`
  314. MeetingTypeStr string `description:"参会方式"`
  315. MeetingAuthentication string `description:"参会权鉴"`
  316. MeetingStatusStr string `description:"参会状态"`
  317. SignupType string `description:"参会方式 "`
  318. InteractionType string `description:"互动类型 "`
  319. ReminderNum int `description:"预约外呼数量 "`
  320. TitleEn string `description:"英文标题 "`
  321. PtagName string `description:"父类名称"`
  322. CtagName string `description:"子类名称"`
  323. PtagNameTwo string `description:"父类名称"`
  324. CtagNameTwo string `description:"子类名称"`
  325. CtagNamePc string `description:"Pc端所有的分类名称"`
  326. BodyHtml string `orm:"column(cover)";description:"图片链接"`
  327. HttpUrl string `orm:"column(iframe)";description:"文章链接跳转地址"`
  328. ChartId int `description:"图表id"`
  329. RealName string `description:"姓名"`
  330. CompanyName string `description:"公司名称"`
  331. CompanyId int `description:"公司ID"`
  332. SellerName string `description:"所属销售"`
  333. Mobile string `description:"手机号"`
  334. UserId int `description:"用户ID"`
  335. City string `description:"城市"`
  336. FileType string `description:"文件类型"`
  337. ListChart []*HomeChartListResp
  338. Paging *paging.PagingItem
  339. IsEnd bool `description:"是否最后一页,配合前端分页添加的参数"`
  340. CurrentIndex int `description:"当前页页码,配合前端分页添加的参数"`
  341. RegisterPlatform int `description:"来源 1小程序,2:网页 ,3:策略平台"`
  342. RegisterPlatformText string `description:"阅读来源(文本描述)"`
  343. SourcePlatform string `description:"来源 'MOBILE:移动端小程序','PC:PC端小程序','CELUE:上海策略平台','WEB:查研观向网页版'"`
  344. TagId int
  345. TagName string // 标签名
  346. ArticleTypes string // 报告系列
  347. ActivityTypes string // 活动类型
  348. Industries string // 产业
  349. SubjectNames string // 标的
  350. SpecialType int `description:"专栏类型 1:笔记,2:观点"`
  351. ArticleNum int // 已发布的文章数量
  352. FansNum int // 粉丝数量
  353. ResearcherName string `description:"研究员姓名"`
  354. RoadShowTheme string `description:"路演主题"`
  355. }
  356. // 查研观向图表
  357. type CygxChartResp struct {
  358. Title string `description:"标题"`
  359. PublishDate string `description:"发布时间"`
  360. CreateTime string `description:"创建时间"`
  361. TitleEn string `description:"英文标题 "`
  362. PtagName string `description:"父类名称"`
  363. CtagName string `description:"子类名称"`
  364. PtagNameTwo string `description:"父类名称"`
  365. CtagNameTwo string `description:"子类名称"`
  366. CtagNamePc string `description:"Pc端所有的分类名称"`
  367. BodyHtml string `orm:"column(cover)";description:"图片链接"`
  368. HttpUrl string `orm:"column(iframe)";description:"文章链接跳转地址"`
  369. ChartId int `description:"图表id"`
  370. RealyName string `description:"姓名"`
  371. Mobile string `description:"手机号"`
  372. }
  373. // 获取阅读记录数量
  374. func GetCygxArticleHistoryCount(mobile, email, condition string) (count int, err error) {
  375. o := orm.NewOrmUsingDB("hz_cygx")
  376. 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
  377. err = o.Raw(sqlCount).QueryRow(&count)
  378. return
  379. }
  380. // 阅读记录列表
  381. func GetCygxArticleHistoryRecordByUser(mobile, email, condition string, startSize, pageSize int) (items []*UserInteraction, err error) {
  382. o := orm.NewOrmUsingDB("hz_cygx")
  383. sql := ` SELECT
  384. art.title,
  385. art.article_id,
  386. art.article_id_md5,
  387. art.publish_date,
  388. art.category_name,
  389. re.chart_permission_name,
  390. re.chart_permission_id,
  391. r.create_time,
  392. r.stop_time,
  393. r.source as source_platform,
  394. (
  395. SELECT
  396. GROUP_CONCAT( DISTINCT s.subject_name SEPARATOR '/' )
  397. FROM
  398. cygx_industrial_subject AS s
  399. WHERE
  400. s.industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_article_group_subject AS sg WHERE sg.article_id = art.article_id )
  401. ) AS subject_name_str,
  402. (
  403. SELECT
  404. GROUP_CONCAT( DISTINCT man.industry_name SEPARATOR '/' )
  405. FROM
  406. cygx_industrial_management AS man
  407. WHERE
  408. 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 )
  409. ) AS industry_name
  410. FROM
  411. cygx_article_history_record_all AS r
  412. INNER JOIN cygx_article AS art ON art.article_id = r.article_id
  413. LEFT JOIN cygx_report_mapping AS re ON re.category_id = art.category_id_two
  414. LEFT JOIN cygx_industrial_article_group_management AS man ON man.article_id = art.article_id
  415. WHERE
  416. r.mobile = ? AND is_del = 0 ` + condition + ` OR ( email = ? AND email <>'' AND is_del = 0 ` + condition + ` )
  417. GROUP BY r.id ORDER BY r.create_time DESC `
  418. if startSize > 0 || pageSize > 0 {
  419. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  420. }
  421. _, err = o.Raw(sql, mobile, email).QueryRows(&items)
  422. return
  423. }
  424. // 用户阅读记录列表 2023-08-02 优化拆分
  425. func GetCygxArticleHistoryRecordByUserNew(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  426. o := orm.NewOrmUsingDB("hz_cygx")
  427. var sql string
  428. sql += `SELECT
  429. art.title,
  430. art.article_id,
  431. art.article_id_md5,
  432. art.publish_date,
  433. art.category_name,
  434. r.create_time,
  435. r.stop_time,
  436. r.source AS source_platform,
  437. '' AS register_platform,
  438. '' AS special_type
  439. FROM
  440. cygx_article_history_record_all AS r
  441. INNER JOIN cygx_article AS art ON art.article_id = r.article_id
  442. WHERE
  443. 1= 1
  444. AND is_del = 0 ` + condition
  445. //sql += ` UNION ALL `
  446. //sql += ` SELECT
  447. // art.title,
  448. // art.id AS article_id,
  449. // '' AS article_id_md5,
  450. // art.publish_time AS publish_date,
  451. // '' AS category_name,
  452. // r.create_time,
  453. // r.stop_time,
  454. // r.register_platform AS source_platform,
  455. // r.register_platform,
  456. // art.type AS special_type
  457. // FROM
  458. // cygx_yanxuan_special_record AS r
  459. // INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  460. // WHERE 1 = 1 ` + condition
  461. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  462. err = o.Raw(totalSql).QueryRow(&total)
  463. if err != nil {
  464. return
  465. }
  466. sql += ` ORDER BY create_time DESC, article_id DESC `
  467. if startSize > 0 || pageSize > 0 {
  468. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  469. }
  470. _, err = o.Raw(sql).QueryRows(&items)
  471. return
  472. }
  473. // 用户阅读记录列表
  474. func GetCygxYanxuaSspecialHistoryRecordByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  475. o := orm.NewOrmUsingDB("hz_cygx")
  476. var sql string
  477. sql += ` SELECT
  478. art.title,
  479. art.id AS article_id,
  480. art.publish_time AS publish_date,
  481. r.create_time,
  482. r.stop_time,
  483. r.user_id,
  484. r.mobile,
  485. r.company_id,
  486. r.company_name,
  487. r.real_name,
  488. r.register_platform AS source_platform,
  489. art.type AS special_type,
  490. art.industry_tags as industry_name
  491. FROM
  492. cygx_yanxuan_special_record AS r
  493. INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  494. WHERE 1 = 1 ` + condition
  495. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  496. err = o.Raw(totalSql).QueryRow(&total)
  497. if err != nil {
  498. return
  499. }
  500. sql += ` ORDER BY create_time DESC, article_id DESC `
  501. if startSize > 0 || pageSize > 0 {
  502. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  503. }
  504. _, err = o.Raw(sql).QueryRows(&items)
  505. return
  506. }
  507. // 用户阅读记录列表
  508. func GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  509. o := orm.NewOrmUsingDB("hz_cygx")
  510. var sql string
  511. sql += ` SELECT
  512. art.title,
  513. art.id AS article_id,
  514. art.publish_time AS publish_date,
  515. r.create_time,
  516. r.stop_time,
  517. r.user_id,
  518. r.mobile,
  519. r.company_id,
  520. r.company_name,
  521. r.real_name,
  522. r.register_platform AS source_platform,
  523. art.type AS special_type,
  524. art.industry_tags as industry_name
  525. FROM
  526. cygx_yanxuan_special_record AS r
  527. INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  528. INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id AND us.product_id = 2
  529. WHERE 1 = 1 ` + condition
  530. databaseName := utils.GetWeeklyDatabase()
  531. sql = fmt.Sprintf(sql, databaseName)
  532. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  533. err = o.Raw(totalSql).QueryRow(&total)
  534. if err != nil {
  535. return
  536. }
  537. sql += ` ORDER BY create_time DESC, article_id DESC `
  538. if startSize > 0 || pageSize > 0 {
  539. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  540. }
  541. _, err = o.Raw(sql).QueryRows(&items)
  542. return
  543. }
  544. // 用户阅读记录列表
  545. func GetCygxYanxuanSpecialCollectByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  546. o := orm.NewOrmUsingDB("hz_cygx")
  547. var sql string
  548. sql += ` SELECT
  549. art.title,
  550. art.id AS article_id,
  551. art.publish_time AS publish_date,
  552. r.create_time,
  553. r.user_id,
  554. r.mobile,
  555. r.company_id,
  556. r.company_name,
  557. r.real_name,
  558. r.register_platform AS source_platform,
  559. art.type AS special_type,
  560. art.industry_tags as industry_name
  561. FROM
  562. cygx_yanxuan_special_collect AS r
  563. INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  564. WHERE 1 = 1 ` + condition
  565. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  566. err = o.Raw(totalSql).QueryRow(&total)
  567. if err != nil {
  568. return
  569. }
  570. sql += ` ORDER BY create_time DESC, article_id DESC `
  571. if startSize > 0 || pageSize > 0 {
  572. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  573. }
  574. _, err = o.Raw(sql).QueryRows(&items)
  575. return
  576. }
  577. // 用户阅读记录列表
  578. func GetCygxYanxuanSpecialCollectByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  579. o := orm.NewOrmUsingDB("hz_cygx")
  580. var sql string
  581. sql += ` SELECT
  582. art.title,
  583. art.id AS article_id,
  584. art.publish_time AS publish_date,
  585. r.create_time,
  586. r.user_id,
  587. r.mobile,
  588. r.company_id,
  589. r.company_name,
  590. r.real_name,
  591. r.register_platform AS source_platform,
  592. art.type AS special_type,
  593. art.industry_tags as industry_name
  594. FROM
  595. cygx_yanxuan_special_collect AS r
  596. INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  597. INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id AND us.product_id = 2
  598. WHERE 1 = 1 ` + condition
  599. databaseName := utils.GetWeeklyDatabase()
  600. sql = fmt.Sprintf(sql, databaseName)
  601. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  602. err = o.Raw(totalSql).QueryRow(&total)
  603. if err != nil {
  604. return
  605. }
  606. sql += ` ORDER BY create_time DESC, article_id DESC `
  607. if startSize > 0 || pageSize > 0 {
  608. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  609. }
  610. _, err = o.Raw(sql).QueryRows(&items)
  611. return
  612. }
  613. // 用户阅读记录列表
  614. func GetCygxYanxuanSpecialAuthorByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  615. o := orm.NewOrmUsingDB("hz_cygx")
  616. var sql string
  617. sql += ` SELECT
  618. art.special_name as title,
  619. art.id AS department_id,
  620. art.nick_name,
  621. art.article_num,
  622. art.fans_num,
  623. art.mobile_init,
  624. r.create_time,
  625. r.user_id,
  626. r.mobile,
  627. r.company_id,
  628. r.company_name,
  629. r.real_name,
  630. r.register_platform AS source_platform
  631. FROM
  632. cygx_yanxuan_special_follow AS r
  633. INNER JOIN cygx_yanxuan_special_author AS art ON art.user_id = r.follow_user_id
  634. WHERE 1 = 1 ` + condition
  635. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  636. err = o.Raw(totalSql).QueryRow(&total)
  637. if err != nil {
  638. return
  639. }
  640. sql += ` ORDER BY create_time DESC, department_id DESC `
  641. if startSize > 0 || pageSize > 0 {
  642. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  643. }
  644. _, err = o.Raw(sql).QueryRows(&items)
  645. return
  646. }
  647. // 用户阅读记录列表
  648. func GetCygxYanxuanSpecialAuthorByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  649. o := orm.NewOrmUsingDB("hz_cygx")
  650. var sql string
  651. sql += ` SELECT
  652. art.special_name as title,
  653. art.id AS department_id,
  654. art.nick_name,
  655. art.article_num,
  656. art.fans_num,
  657. art.mobile_init,
  658. r.create_time,
  659. r.user_id,
  660. r.mobile,
  661. r.company_id,
  662. r.company_name,
  663. r.real_name,
  664. r.register_platform AS source_platform
  665. FROM
  666. cygx_yanxuan_special_follow AS r
  667. INNER JOIN cygx_yanxuan_special_author AS art ON art.user_id = r.follow_user_id
  668. INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id AND us.product_id = 2
  669. WHERE 1 = 1 ` + condition
  670. databaseName := utils.GetWeeklyDatabase()
  671. sql = fmt.Sprintf(sql, databaseName)
  672. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  673. err = o.Raw(totalSql).QueryRow(&total)
  674. if err != nil {
  675. return
  676. }
  677. sql += ` ORDER BY create_time DESC, department_id DESC `
  678. if startSize > 0 || pageSize > 0 {
  679. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  680. }
  681. _, err = o.Raw(sql).QueryRows(&items)
  682. return
  683. }
  684. // 收藏列表数量
  685. func GetCygxArticleCollectCount(uid int, condition string) (count int, err error) {
  686. o := orm.NewOrmUsingDB("hz_cygx")
  687. 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
  688. err = o.Raw(sqlCount, uid).QueryRow(&count)
  689. return
  690. }
  691. // 收藏列表
  692. func GetCygxArticleCollectByUser(uid, startSize, pageSize int, condition string) (items []*UserInteraction, err error) {
  693. o := orm.NewOrmUsingDB("hz_cygx")
  694. sql := ` SELECT
  695. art.title,
  696. art.article_id,
  697. art.report_id,
  698. art.article_id_md5,
  699. art.publish_date,
  700. re.chart_permission_name,
  701. re.chart_permission_id,
  702. r.create_time,
  703. re.match_type_name,
  704. (
  705. SELECT
  706. GROUP_CONCAT( DISTINCT s.subject_name SEPARATOR '/' )
  707. FROM
  708. cygx_industrial_subject AS s
  709. WHERE
  710. s.industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_article_group_subject AS sg WHERE sg.article_id = art.article_id )
  711. ) AS subject_name_str,
  712. (
  713. SELECT
  714. GROUP_CONCAT( DISTINCT man.industry_name SEPARATOR '/' )
  715. FROM
  716. cygx_industrial_management AS man
  717. WHERE
  718. 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 )
  719. ) AS industry_name
  720. FROM
  721. cygx_article_collect AS r
  722. INNER JOIN cygx_article AS art ON art.article_id = r.article_id
  723. LEFT JOIN cygx_report_mapping AS re ON re.category_id = art.category_id_two
  724. LEFT JOIN cygx_industrial_article_group_management AS man ON man.article_id = art.article_id
  725. WHERE
  726. user_id = ? ` + condition + ` GROUP BY r.article_id
  727. ORDER BY r.create_time DESC `
  728. if startSize > 0 || pageSize > 0 {
  729. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  730. }
  731. _, err = o.Raw(sql, uid).QueryRows(&items)
  732. return
  733. }
  734. // 关注作者数量
  735. func GetCygArticleDepartmentFollowCount(uid int) (count int, err error) {
  736. o := orm.NewOrmUsingDB("hz_cygx")
  737. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_article_department_follow WHERE user_id = ? AND type = 1 `
  738. err = o.Raw(sqlCount, uid).QueryRow(&count)
  739. return
  740. }
  741. // 关注作者列表
  742. func GetCygArticleDepartmentFollowByUser(uid, startSize, pageSize int) (items []*UserInteraction, err error) {
  743. o := orm.NewOrmUsingDB("hz_cygx")
  744. sql := `SELECT
  745. m.department_id,
  746. m.nick_name,
  747. f.modify_time as create_time,
  748. m.department_id,
  749. i.industry_name,
  750. a.title,
  751. a.article_id,
  752. ( 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,
  753. ( 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
  754. FROM
  755. cygx_article_department_follow AS f
  756. INNER JOIN cygx_article_department AS m ON m.department_id = f.department_id
  757. LEFT JOIN cygx_article AS a ON a.department_id = m.department_id
  758. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  759. LEFT JOIN cygx_industrial_management AS i ON i.industrial_management_id = mg.industrial_management_id
  760. WHERE f.user_id = ? AND f.type = 1 GROUP BY m.department_id
  761. ORDER BY f.create_time DESC LIMIT ?,? `
  762. _, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
  763. return
  764. }
  765. // 用户搜索关键词统计
  766. func GetCygxSearchKeyWordCount(uid int, condition string) (count int, err error) {
  767. o := orm.NewOrmUsingDB("hz_cygx")
  768. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_search_key_word WHERE user_id = ? ` + condition
  769. err = o.Raw(sqlCount, uid).QueryRow(&count)
  770. return
  771. }
  772. // 用户搜索关键词列表
  773. func GetCygxSearchKeyWordByUser(condition string, uid, startSize, pageSize int) (items []*UserInteraction, err error) {
  774. o := orm.NewOrmUsingDB("hz_cygx")
  775. sql := `SELECT
  776. key_word,create_time
  777. FROM
  778. cygx_search_key_word as k
  779. WHERE user_id = ? ` + condition + `
  780. ORDER BY k.create_time DESC LIMIT ?,? `
  781. _, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
  782. return
  783. }
  784. // 用户专项产业调研统计
  785. func GetCygxActivitySpecialTripCount(condition string, pars []interface{}) (count int, err error) {
  786. o := orm.NewOrmUsingDB("hz_cygx")
  787. sqlCount := `SELECT
  788. COUNT( 1 )
  789. FROM
  790. cygx_activity_special_meeting_detail AS h
  791. INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id
  792. WHERE
  793. 1 = 1
  794. AND a.publish_status = 1 AND a.activity_time_end < NOW() ` + condition
  795. err = o.Raw(sqlCount, pars).QueryRow(&count)
  796. return
  797. }
  798. // 用户专项产业调研列表
  799. func GetCygxActivitySpecialTripByUser(uid, startSize, pageSize int) (items []*UserInteraction, err error) {
  800. o := orm.NewOrmUsingDB("hz_cygx")
  801. sql := `SELECT
  802. a.research_theme AS activity_name,
  803. a.chart_permission_name,
  804. a.activity_time_text_by_day AS activity_time_text,
  805. a.city,
  806. a.activity_id,
  807. a.special_type AS activity_type,
  808. h.is_meeting
  809. FROM
  810. cygx_activity_special_meeting_detail AS h
  811. INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id
  812. WHERE
  813. 1 = 1
  814. AND a.publish_status = 1 AND a.activity_time_end < NOW()
  815. AND h.user_id = ?
  816. ORDER BY a.activity_time DESC LIMIT ?,? `
  817. _, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
  818. return
  819. }
  820. // 用户音视频浏览统计
  821. func GetCygxRoadshowCount(uid int) (count int, err error) {
  822. o := orm.NewOrmUsingDB("hz_cygx")
  823. sqlCount := `SELECT
  824. COUNT( 1 ) total
  825. FROM
  826. (
  827. SELECT
  828. ""
  829. FROM
  830. cygx_micro_roadshow_video_history AS r
  831. INNER JOIN cygx_micro_roadshow_video AS v ON r.video_id = v.video_id
  832. WHERE
  833. r.user_id = ? UNION ALL
  834. SELECT
  835. ""
  836. FROM
  837. cygx_activity_video_history AS r
  838. INNER JOIN cygx_activity_video AS v ON r.video_id = v.video_id
  839. WHERE
  840. r.user_id = ? UNION ALL
  841. SELECT
  842. ""
  843. FROM
  844. cygx_activity_voice_history AS r
  845. INNER JOIN cygx_activity_voice AS v ON r.activity_id = v.activity_id
  846. WHERE
  847. r.user_id = ?
  848. )z `
  849. err = o.Raw(sqlCount, uid, uid, uid).QueryRow(&count)
  850. return
  851. }
  852. // 用户专项产业调研列表
  853. func GetCygxRoadshowByUser(uid, startSize, pageSize int) (items []*UserInteraction, err error) {
  854. o := orm.NewOrmUsingDB("hz_cygx")
  855. sql := `SELECT
  856. v.video_name AS media_title,
  857. r.create_time,
  858. "逻辑解析" AS file_type
  859. FROM
  860. cygx_micro_roadshow_video_history AS r
  861. INNER JOIN cygx_micro_roadshow_video AS v ON r.video_id = v.video_id
  862. WHERE
  863. r.user_id = ? UNION ALL
  864. SELECT
  865. v.video_name AS media_title,
  866. r.create_time,
  867. "路演回放" AS file_type
  868. FROM
  869. cygx_activity_video_history AS r
  870. INNER JOIN cygx_activity_video AS v ON r.video_id = v.video_id
  871. WHERE
  872. r.user_id = ? UNION ALL
  873. SELECT
  874. v.voice_name AS media_title,
  875. r.create_time,
  876. "路演回放" AS file_type
  877. FROM
  878. cygx_activity_voice_history AS r
  879. INNER JOIN cygx_activity_voice AS v ON r.activity_id = v.activity_id
  880. WHERE
  881. r.user_id = ?
  882. ORDER BY create_time DESC LIMIT ?,? `
  883. _, err = o.Raw(sql, uid, uid, uid, startSize, pageSize).QueryRows(&items)
  884. return
  885. }
  886. // 线上已到会列表
  887. func GetAttendanceDetailListByUser(isMeeting int, mobile string, startSize, pageSize int) (item []*UserInteraction, err error) {
  888. o := orm.NewOrmUsingDB("hz_cygx")
  889. sql := `SELECT
  890. s.signup_type,
  891. a.activity_name,
  892. a.chart_permission_name,
  893. a.activity_type_name,
  894. a.label,
  895. a.activity_time,
  896. d.first_meeting_time,
  897. d.last_meeting_time,
  898. d.meeting_type_str,
  899. d.meeting_authentication,
  900. d.meeting_status_str,
  901. d.duration
  902. FROM
  903. cygx_activity_signup AS s
  904. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  905. INNER JOIN cygx_activity_attendance_detail AS d ON d.activity_id = s.activity_id
  906. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  907. WHERE
  908. 1 = 1
  909. AND s.do_fail_type = 0
  910. AND s.is_cancel = 0
  911. AND s.is_meeting = ?
  912. AND s.mobile = ?
  913. AND a.is_submit_meeting = 1
  914. AND t.activity_type = 1
  915. GROUP BY
  916. a.activity_id
  917. ORDER BY
  918. a.activity_time DESC
  919. LIMIT ?,?`
  920. _, err = o.Raw(sql, isMeeting, mobile, startSize, pageSize).QueryRows(&item)
  921. return
  922. }
  923. // 线上未来到会列表
  924. func GetAttendanceDetailListNoMeetingByUser(isMeeting int, mobile string, startSize, pageSize int) (item []*UserInteraction, err error) {
  925. o := orm.NewOrmUsingDB("hz_cygx")
  926. sql := `SELECT
  927. s.signup_type,
  928. a.activity_name,
  929. a.chart_permission_name,
  930. a.activity_type_name,
  931. a.label,
  932. a.activity_time,
  933. ( 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
  934. FROM
  935. cygx_activity_signup AS s
  936. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  937. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  938. WHERE
  939. 1 = 1
  940. AND s.do_fail_type = 0
  941. AND s.is_cancel = 0
  942. AND s.is_meeting = ?
  943. AND s.mobile = ?
  944. AND a.is_submit_meeting = 1
  945. AND t.activity_type = 1
  946. GROUP BY
  947. a.activity_id
  948. ORDER BY
  949. a.activity_time DESC
  950. LIMIT ?,?`
  951. _, err = o.Raw(sql, isMeeting, mobile, startSize, pageSize).QueryRows(&item)
  952. return
  953. }
  954. // 用户参会统计
  955. func GetAttendanceDetaiCount(mobile string, meetType, isMeeting int) (count int, err error) {
  956. o := orm.NewOrmUsingDB("hz_cygx")
  957. sqlCount := ` SELECT
  958. COUNT( DISTINCT a.activity_id ) as count
  959. FROM
  960. cygx_activity_signup AS s
  961. INNER JOIN cygx_activity as a ON a.activity_id = s.activity_id
  962. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  963. WHERE
  964. mobile = ?
  965. AND is_meeting =?
  966. AND s.do_fail_type = 0
  967. AND a.is_submit_meeting = 1 `
  968. if meetType == 1 {
  969. sqlCount += ` AND t.activity_type = 1 `
  970. } else {
  971. sqlCount += ` AND t.activity_type = 0 `
  972. }
  973. err = o.Raw(sqlCount, mobile, isMeeting).QueryRow(&count)
  974. return
  975. }
  976. // 线下已到会列表
  977. func GetAttendanceOfflineListByUser(isMeeting int, mobile string, startSize, pageSize int) (item []*UserInteraction, err error) {
  978. o := orm.NewOrmUsingDB("hz_cygx")
  979. sql := `SELECT
  980. a.activity_name,
  981. a.chart_permission_name,
  982. a.activity_type_name,
  983. a.label,
  984. a.activity_time
  985. FROM
  986. cygx_activity_signup AS s
  987. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  988. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  989. WHERE
  990. 1 = 1
  991. AND s.do_fail_type = 0
  992. AND s.is_cancel = 0
  993. AND s.is_meeting = ?
  994. AND s.mobile = ?
  995. AND a.is_submit_meeting = 1
  996. AND t.activity_type = 0
  997. GROUP BY
  998. a.activity_id
  999. ORDER BY
  1000. a.activity_time DESC
  1001. LIMIT ?,?`
  1002. _, err = o.Raw(sql, isMeeting, mobile, startSize, pageSize).QueryRows(&item)
  1003. return
  1004. }
  1005. // 获取用户参会记录数量
  1006. func GetActivityMeetByUserCount(condition string) (count int, err error) {
  1007. o := orm.NewOrmUsingDB("hz_cygx")
  1008. sqlCount := ` SELECT
  1009. COUNT( DISTINCT a.activity_id ) as count
  1010. FROM
  1011. cygx_activity_signup_detail AS s
  1012. INNER JOIN cygx_activity as a ON a.activity_id = s.activity_id
  1013. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  1014. WHERE
  1015. 1=1
  1016. AND s.do_fail_type = 0 `
  1017. if condition != "" {
  1018. sqlCount += condition
  1019. }
  1020. err = o.Raw(sqlCount).QueryRow(&count)
  1021. return
  1022. }
  1023. // 获取用户参会记录
  1024. func GetActivityMeetByUser(condition string, startSize, pageSize int) (item []*UserInteraction, err error) {
  1025. o := orm.NewOrmUsingDB("hz_cygx")
  1026. sql := `SELECT
  1027. t.activity_type,
  1028. s.signup_type,
  1029. s.is_meeting,
  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.activity_id,s.outbound_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.follow_type = 1 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.follow_type = 1 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. }