cygx_user.go 58 KB

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