cygx_user.go 57 KB

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