cygx_user.go 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429
  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. LabelKeyWord string `description:"标签关键词"`
  294. Source int `description:"关键词来源;1:纪要、2:图表、3:纪要/图表、4:产业资源包、5:报告、6:活动、7:搜索关键词、8:专项产业调研、9音视频播放"`
  295. ActivityName string `description:"活动名称"`
  296. ActivityType int `description:"1 线上,0、2线下"`
  297. IsMeeting int `description:"是否到会, 1是,0否"`
  298. ActivityTypeName string `description:"活动类型名称"`
  299. Label string `description:"标签"`
  300. ActivityTime string `description:"活动时间"`
  301. ActivityTimeText string `description:"活动时间"`
  302. FirstMeetingTime string `description:"首次入会时间"`
  303. LastMeetingTime string `description:"最后退出时间"`
  304. Duration string `description:"参会时长"`
  305. MeetingTypeStr string `description:"参会方式"`
  306. MeetingAuthentication string `description:"参会权鉴"`
  307. MeetingStatusStr string `description:"参会状态"`
  308. SignupType string `description:"参会方式 "`
  309. InteractionType string `description:"互动类型 "`
  310. ReminderNum int `description:"预约外呼数量 "`
  311. TitleEn string `description:"英文标题 "`
  312. PtagName string `description:"父类名称"`
  313. CtagName string `description:"子类名称"`
  314. PtagNameTwo string `description:"父类名称"`
  315. CtagNameTwo string `description:"子类名称"`
  316. CtagNamePc string `description:"Pc端所有的分类名称"`
  317. BodyHtml string `orm:"column(cover)";description:"图片链接"`
  318. HttpUrl string `orm:"column(iframe)";description:"文章链接跳转地址"`
  319. ChartId int `description:"图表id"`
  320. RealName string `description:"姓名"`
  321. CompanyName string `description:"公司名称"`
  322. CompanyId int `description:"公司ID"`
  323. SellerName string `description:"所属销售"`
  324. Mobile string `description:"手机号"`
  325. UserId int `description:"用户ID"`
  326. City string `description:"城市"`
  327. FileType string `description:"文件类型"`
  328. ListChart []*HomeChartListResp
  329. Paging *paging.PagingItem
  330. IsEnd bool `description:"是否最后一页,配合前端分页添加的参数"`
  331. CurrentIndex int `description:"当前页页码,配合前端分页添加的参数"`
  332. RegisterPlatform int `description:"来源 1小程序,2:网页 ,3:策略平台"`
  333. RegisterPlatformText string `description:"阅读来源(文本描述)"`
  334. SourcePlatform string `description:"来源 'MOBILE:移动端小程序','PC:PC端小程序','CELUE:上海策略平台','WEB:查研观向网页版'"`
  335. TagId int
  336. TagName string // 标签名
  337. ArticleTypes string // 报告系列
  338. ActivityTypes string // 活动类型
  339. Industries string // 产业
  340. SubjectNames string // 标的
  341. SpecialType int `description:"专栏类型 1:笔记,2:观点"`
  342. ArticleNum int // 已发布的文章数量
  343. FansNum int // 粉丝数量
  344. ResearcherName string `description:"研究员姓名"`
  345. }
  346. // 查研观向图表
  347. type CygxChartResp struct {
  348. Title string `description:"标题"`
  349. PublishDate string `description:"发布时间"`
  350. CreateTime string `description:"创建时间"`
  351. TitleEn string `description:"英文标题 "`
  352. PtagName string `description:"父类名称"`
  353. CtagName string `description:"子类名称"`
  354. PtagNameTwo string `description:"父类名称"`
  355. CtagNameTwo string `description:"子类名称"`
  356. CtagNamePc string `description:"Pc端所有的分类名称"`
  357. BodyHtml string `orm:"column(cover)";description:"图片链接"`
  358. HttpUrl string `orm:"column(iframe)";description:"文章链接跳转地址"`
  359. ChartId int `description:"图表id"`
  360. RealyName string `description:"姓名"`
  361. Mobile string `description:"手机号"`
  362. }
  363. // 获取阅读记录数量
  364. func GetCygxArticleHistoryCount(mobile, email, condition string) (count int, err error) {
  365. o := orm.NewOrmUsingDB("hz_cygx")
  366. 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
  367. err = o.Raw(sqlCount).QueryRow(&count)
  368. return
  369. }
  370. // 阅读记录列表
  371. func GetCygxArticleHistoryRecordByUser(mobile, email, condition string, startSize, pageSize int) (items []*UserInteraction, err error) {
  372. o := orm.NewOrmUsingDB("hz_cygx")
  373. sql := ` SELECT
  374. art.title,
  375. art.article_id,
  376. art.article_id_md5,
  377. art.publish_date,
  378. art.category_name,
  379. re.chart_permission_name,
  380. re.chart_permission_id,
  381. r.create_time,
  382. r.stop_time,
  383. r.source as source_platform,
  384. (
  385. SELECT
  386. GROUP_CONCAT( DISTINCT s.subject_name SEPARATOR '/' )
  387. FROM
  388. cygx_industrial_subject AS s
  389. WHERE
  390. s.industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_article_group_subject AS sg WHERE sg.article_id = art.article_id )
  391. ) AS subject_name_str,
  392. (
  393. SELECT
  394. GROUP_CONCAT( DISTINCT man.industry_name SEPARATOR '/' )
  395. FROM
  396. cygx_industrial_management AS man
  397. WHERE
  398. 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 )
  399. ) AS industry_name
  400. FROM
  401. cygx_article_history_record_all AS r
  402. INNER JOIN cygx_article AS art ON art.article_id = r.article_id
  403. LEFT JOIN cygx_report_mapping AS re ON re.category_id = art.category_id_two
  404. LEFT JOIN cygx_industrial_article_group_management AS man ON man.article_id = art.article_id
  405. WHERE
  406. r.mobile = ? AND is_del = 0 ` + condition + ` OR ( email = ? AND email <>'' AND is_del = 0 ` + condition + ` )
  407. GROUP BY r.id ORDER BY r.create_time DESC `
  408. if startSize > 0 || pageSize > 0 {
  409. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  410. }
  411. _, err = o.Raw(sql, mobile, email).QueryRows(&items)
  412. return
  413. }
  414. // 用户阅读记录列表 2023-08-02 优化拆分
  415. func GetCygxArticleHistoryRecordByUserNew(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  416. o := orm.NewOrmUsingDB("hz_cygx")
  417. var sql string
  418. sql += `SELECT
  419. art.title,
  420. art.article_id,
  421. art.article_id_md5,
  422. art.publish_date,
  423. art.category_name,
  424. r.create_time,
  425. r.stop_time,
  426. r.source AS source_platform,
  427. '' AS register_platform,
  428. '' AS special_type
  429. FROM
  430. cygx_article_history_record_all AS r
  431. INNER JOIN cygx_article AS art ON art.article_id = r.article_id
  432. WHERE
  433. 1= 1
  434. AND is_del = 0 ` + condition
  435. //sql += ` UNION ALL `
  436. //sql += ` SELECT
  437. // art.title,
  438. // art.id AS article_id,
  439. // '' AS article_id_md5,
  440. // art.publish_time AS publish_date,
  441. // '' AS category_name,
  442. // r.create_time,
  443. // r.stop_time,
  444. // r.register_platform AS source_platform,
  445. // r.register_platform,
  446. // art.type AS special_type
  447. // FROM
  448. // cygx_yanxuan_special_record AS r
  449. // INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  450. // WHERE 1 = 1 ` + condition
  451. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  452. err = o.Raw(totalSql).QueryRow(&total)
  453. if err != nil {
  454. return
  455. }
  456. sql += ` ORDER BY create_time DESC, article_id DESC `
  457. if startSize > 0 || pageSize > 0 {
  458. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  459. }
  460. _, err = o.Raw(sql).QueryRows(&items)
  461. return
  462. }
  463. // 用户阅读记录列表
  464. func GetCygxYanxuaSspecialHistoryRecordByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  465. o := orm.NewOrmUsingDB("hz_cygx")
  466. var sql string
  467. sql += ` SELECT
  468. art.title,
  469. art.id AS article_id,
  470. art.publish_time AS publish_date,
  471. r.create_time,
  472. r.stop_time,
  473. r.user_id,
  474. r.mobile,
  475. r.company_id,
  476. r.company_name,
  477. r.real_name,
  478. r.register_platform AS source_platform,
  479. art.type AS special_type,
  480. art.industry_tags as industry_name
  481. FROM
  482. cygx_yanxuan_special_record AS r
  483. INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  484. WHERE 1 = 1 ` + condition
  485. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  486. err = o.Raw(totalSql).QueryRow(&total)
  487. if err != nil {
  488. return
  489. }
  490. sql += ` ORDER BY create_time DESC, article_id DESC `
  491. if startSize > 0 || pageSize > 0 {
  492. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  493. }
  494. _, err = o.Raw(sql).QueryRows(&items)
  495. return
  496. }
  497. // 用户阅读记录列表
  498. func GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  499. o := orm.NewOrmUsingDB("hz_cygx")
  500. var sql string
  501. sql += ` SELECT
  502. art.title,
  503. art.id AS article_id,
  504. art.publish_time AS publish_date,
  505. r.create_time,
  506. r.stop_time,
  507. r.user_id,
  508. r.mobile,
  509. r.company_id,
  510. r.company_name,
  511. r.real_name,
  512. r.register_platform AS source_platform,
  513. art.type AS special_type,
  514. art.industry_tags as industry_name
  515. FROM
  516. cygx_yanxuan_special_record AS r
  517. INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  518. INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id AND us.product_id = 2
  519. WHERE 1 = 1 ` + condition
  520. databaseName := utils.GetWeeklyDatabase()
  521. sql = fmt.Sprintf(sql, databaseName)
  522. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  523. err = o.Raw(totalSql).QueryRow(&total)
  524. if err != nil {
  525. return
  526. }
  527. sql += ` ORDER BY create_time DESC, article_id DESC `
  528. if startSize > 0 || pageSize > 0 {
  529. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  530. }
  531. _, err = o.Raw(sql).QueryRows(&items)
  532. return
  533. }
  534. // 用户阅读记录列表
  535. func GetCygxYanxuanSpecialCollectByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  536. o := orm.NewOrmUsingDB("hz_cygx")
  537. var sql string
  538. sql += ` SELECT
  539. art.title,
  540. art.id AS article_id,
  541. art.publish_time AS publish_date,
  542. r.create_time,
  543. r.register_platform AS source_platform,
  544. art.type AS special_type,
  545. art.industry_tags as industry_name
  546. FROM
  547. cygx_yanxuan_special_collect AS r
  548. INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  549. WHERE 1 = 1 ` + condition
  550. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  551. err = o.Raw(totalSql).QueryRow(&total)
  552. if err != nil {
  553. return
  554. }
  555. sql += ` ORDER BY create_time DESC, article_id DESC `
  556. if startSize > 0 || pageSize > 0 {
  557. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  558. }
  559. _, err = o.Raw(sql).QueryRows(&items)
  560. return
  561. }
  562. // 用户阅读记录列表
  563. func GetCygxYanxuanSpecialCollectByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  564. o := orm.NewOrmUsingDB("hz_cygx")
  565. var sql string
  566. sql += ` SELECT
  567. art.title,
  568. art.id AS article_id,
  569. art.publish_time AS publish_date,
  570. r.create_time,
  571. r.register_platform AS source_platform,
  572. art.type AS special_type,
  573. art.industry_tags as industry_name
  574. FROM
  575. cygx_yanxuan_special_collect AS r
  576. INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
  577. INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id AND us.product_id = 2
  578. WHERE 1 = 1 ` + condition
  579. databaseName := utils.GetWeeklyDatabase()
  580. sql = fmt.Sprintf(sql, databaseName)
  581. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  582. err = o.Raw(totalSql).QueryRow(&total)
  583. if err != nil {
  584. return
  585. }
  586. sql += ` ORDER BY create_time DESC, article_id DESC `
  587. if startSize > 0 || pageSize > 0 {
  588. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  589. }
  590. _, err = o.Raw(sql).QueryRows(&items)
  591. return
  592. }
  593. // 用户阅读记录列表
  594. func GetCygxYanxuanSpecialAuthorByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  595. o := orm.NewOrmUsingDB("hz_cygx")
  596. var sql string
  597. sql += ` SELECT
  598. art.special_name as title,
  599. art.id AS department_id,
  600. art.nick_name,
  601. art.article_num,
  602. art.fans_num,
  603. art.company_id,
  604. art.company_name,
  605. art.mobile_init as mobile,
  606. r.create_time,
  607. r.register_platform AS source_platform
  608. FROM
  609. cygx_yanxuan_special_follow AS r
  610. INNER JOIN cygx_yanxuan_special_author AS art ON art.user_id = r.follow_user_id
  611. WHERE 1 = 1 ` + condition
  612. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  613. err = o.Raw(totalSql).QueryRow(&total)
  614. if err != nil {
  615. return
  616. }
  617. sql += ` ORDER BY create_time DESC, department_id DESC `
  618. if startSize > 0 || pageSize > 0 {
  619. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  620. }
  621. _, err = o.Raw(sql).QueryRows(&items)
  622. return
  623. }
  624. // 用户阅读记录列表
  625. func GetCygxYanxuanSpecialAuthorByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
  626. o := orm.NewOrmUsingDB("hz_cygx")
  627. var sql string
  628. sql += ` SELECT
  629. art.special_name as title,
  630. art.id AS department_id,
  631. art.nick_name,
  632. art.article_num,
  633. art.fans_num,
  634. art.company_id,
  635. art.company_name,
  636. art.mobile_init as mobile,
  637. r.create_time,
  638. r.register_platform AS source_platform
  639. FROM
  640. cygx_yanxuan_special_follow AS r
  641. INNER JOIN cygx_yanxuan_special_author AS art ON art.user_id = r.follow_user_id
  642. INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id AND us.product_id = 2
  643. WHERE 1 = 1 ` + condition
  644. databaseName := utils.GetWeeklyDatabase()
  645. sql = fmt.Sprintf(sql, databaseName)
  646. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  647. err = o.Raw(totalSql).QueryRow(&total)
  648. if err != nil {
  649. return
  650. }
  651. sql += ` ORDER BY create_time DESC, department_id DESC `
  652. if startSize > 0 || pageSize > 0 {
  653. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  654. }
  655. _, err = o.Raw(sql).QueryRows(&items)
  656. return
  657. }
  658. // 收藏列表数量
  659. func GetCygxArticleCollectCount(uid int, condition string) (count int, err error) {
  660. o := orm.NewOrmUsingDB("hz_cygx")
  661. 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
  662. err = o.Raw(sqlCount, uid).QueryRow(&count)
  663. return
  664. }
  665. // 收藏列表
  666. func GetCygxArticleCollectByUser(uid, startSize, pageSize int, condition string) (items []*UserInteraction, err error) {
  667. o := orm.NewOrmUsingDB("hz_cygx")
  668. sql := ` SELECT
  669. art.title,
  670. art.article_id,
  671. art.article_id_md5,
  672. art.publish_date,
  673. re.chart_permission_name,
  674. re.chart_permission_id,
  675. r.create_time,
  676. re.match_type_name,
  677. (
  678. SELECT
  679. GROUP_CONCAT( DISTINCT s.subject_name SEPARATOR '/' )
  680. FROM
  681. cygx_industrial_subject AS s
  682. WHERE
  683. s.industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_article_group_subject AS sg WHERE sg.article_id = art.article_id )
  684. ) AS subject_name_str,
  685. (
  686. SELECT
  687. GROUP_CONCAT( DISTINCT man.industry_name SEPARATOR '/' )
  688. FROM
  689. cygx_industrial_management AS man
  690. WHERE
  691. 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 )
  692. ) AS industry_name
  693. FROM
  694. cygx_article_collect AS r
  695. INNER JOIN cygx_article AS art ON art.article_id = r.article_id
  696. LEFT JOIN cygx_report_mapping AS re ON re.category_id = art.category_id_two
  697. LEFT JOIN cygx_industrial_article_group_management AS man ON man.article_id = art.article_id
  698. WHERE
  699. user_id = ? ` + condition + ` GROUP BY r.article_id
  700. ORDER BY r.create_time DESC `
  701. if startSize > 0 || pageSize > 0 {
  702. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  703. }
  704. _, err = o.Raw(sql, uid).QueryRows(&items)
  705. return
  706. }
  707. // 关注作者数量
  708. func GetCygArticleDepartmentFollowCount(uid int) (count int, err error) {
  709. o := orm.NewOrmUsingDB("hz_cygx")
  710. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_article_department_follow WHERE user_id = ? AND type = 1 `
  711. err = o.Raw(sqlCount, uid).QueryRow(&count)
  712. return
  713. }
  714. // 关注作者列表
  715. func GetCygArticleDepartmentFollowByUser(uid, startSize, pageSize int) (items []*UserInteraction, err error) {
  716. o := orm.NewOrmUsingDB("hz_cygx")
  717. sql := `SELECT
  718. m.department_id,
  719. m.nick_name,
  720. f.modify_time as create_time,
  721. m.department_id,
  722. i.industry_name,
  723. a.title,
  724. a.article_id,
  725. ( 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,
  726. ( 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
  727. FROM
  728. cygx_article_department_follow AS f
  729. INNER JOIN cygx_article_department AS m ON m.department_id = f.department_id
  730. LEFT JOIN cygx_article AS a ON a.department_id = m.department_id
  731. LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  732. LEFT JOIN cygx_industrial_management AS i ON i.industrial_management_id = mg.industrial_management_id
  733. WHERE f.user_id = ? AND f.type = 1 GROUP BY m.department_id
  734. ORDER BY f.create_time DESC LIMIT ?,? `
  735. _, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
  736. return
  737. }
  738. // 用户搜索关键词统计
  739. func GetCygxSearchKeyWordCount(uid int, condition string) (count int, err error) {
  740. o := orm.NewOrmUsingDB("hz_cygx")
  741. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_search_key_word WHERE user_id = ? ` + condition
  742. err = o.Raw(sqlCount, uid).QueryRow(&count)
  743. return
  744. }
  745. // 用户搜索关键词列表
  746. func GetCygxSearchKeyWordByUser(condition string, uid, startSize, pageSize int) (items []*UserInteraction, err error) {
  747. o := orm.NewOrmUsingDB("hz_cygx")
  748. sql := `SELECT
  749. key_word,create_time
  750. FROM
  751. cygx_search_key_word as k
  752. WHERE user_id = ? ` + condition + `
  753. ORDER BY k.create_time DESC LIMIT ?,? `
  754. _, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
  755. return
  756. }
  757. // 用户专项产业调研统计
  758. func GetCygxActivitySpecialTripCount(condition string, pars []interface{}) (count int, err error) {
  759. o := orm.NewOrmUsingDB("hz_cygx")
  760. sqlCount := `SELECT
  761. COUNT( 1 )
  762. FROM
  763. cygx_activity_special_meeting_detail AS h
  764. INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id
  765. WHERE
  766. 1 = 1
  767. AND a.publish_status = 1 AND a.activity_time_end < NOW() ` + condition
  768. err = o.Raw(sqlCount, pars).QueryRow(&count)
  769. return
  770. }
  771. // 用户专项产业调研列表
  772. func GetCygxActivitySpecialTripByUser(uid, startSize, pageSize int) (items []*UserInteraction, err error) {
  773. o := orm.NewOrmUsingDB("hz_cygx")
  774. sql := `SELECT
  775. a.research_theme AS activity_name,
  776. a.chart_permission_name,
  777. a.activity_time_text_by_day AS activity_time_text,
  778. a.city,
  779. a.activity_id,
  780. a.special_type AS activity_type,
  781. h.is_meeting
  782. FROM
  783. cygx_activity_special_meeting_detail AS h
  784. INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id
  785. WHERE
  786. 1 = 1
  787. AND a.publish_status = 1 AND a.activity_time_end < NOW()
  788. AND h.user_id = ?
  789. ORDER BY a.activity_time DESC LIMIT ?,? `
  790. _, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
  791. return
  792. }
  793. // 用户音视频浏览统计
  794. func GetCygxRoadshowCount(uid int) (count int, err error) {
  795. o := orm.NewOrmUsingDB("hz_cygx")
  796. sqlCount := `SELECT
  797. COUNT( 1 ) total
  798. FROM
  799. (
  800. SELECT
  801. ""
  802. FROM
  803. cygx_micro_roadshow_video_history AS r
  804. INNER JOIN cygx_micro_roadshow_video AS v ON r.video_id = v.video_id
  805. WHERE
  806. r.user_id = ? UNION ALL
  807. SELECT
  808. ""
  809. FROM
  810. cygx_activity_video_history AS r
  811. INNER JOIN cygx_activity_video AS v ON r.video_id = v.video_id
  812. WHERE
  813. r.user_id = ? UNION ALL
  814. SELECT
  815. ""
  816. FROM
  817. cygx_activity_voice_history AS r
  818. INNER JOIN cygx_activity_voice AS v ON r.activity_id = v.activity_id
  819. WHERE
  820. r.user_id = ?
  821. )z `
  822. err = o.Raw(sqlCount, uid, uid, uid).QueryRow(&count)
  823. return
  824. }
  825. // 用户专项产业调研列表
  826. func GetCygxRoadshowByUser(uid, startSize, pageSize int) (items []*UserInteraction, err error) {
  827. o := orm.NewOrmUsingDB("hz_cygx")
  828. sql := `SELECT
  829. v.video_name AS media_title,
  830. r.create_time,
  831. "逻辑解析" AS file_type
  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. v.video_name AS media_title,
  839. r.create_time,
  840. "路演回放" AS file_type
  841. FROM
  842. cygx_activity_video_history AS r
  843. INNER JOIN cygx_activity_video AS v ON r.video_id = v.video_id
  844. WHERE
  845. r.user_id = ? UNION ALL
  846. SELECT
  847. v.voice_name AS media_title,
  848. r.create_time,
  849. "路演回放" AS file_type
  850. FROM
  851. cygx_activity_voice_history AS r
  852. INNER JOIN cygx_activity_voice AS v ON r.activity_id = v.activity_id
  853. WHERE
  854. r.user_id = ?
  855. ORDER BY create_time DESC LIMIT ?,? `
  856. _, err = o.Raw(sql, uid, uid, uid, startSize, pageSize).QueryRows(&items)
  857. return
  858. }
  859. // 线上已到会列表
  860. func GetAttendanceDetailListByUser(isMeeting int, mobile string, startSize, pageSize int) (item []*UserInteraction, err error) {
  861. o := orm.NewOrmUsingDB("hz_cygx")
  862. sql := `SELECT
  863. s.signup_type,
  864. a.activity_name,
  865. a.chart_permission_name,
  866. a.activity_type_name,
  867. a.label,
  868. a.activity_time,
  869. d.first_meeting_time,
  870. d.last_meeting_time,
  871. d.meeting_type_str,
  872. d.meeting_authentication,
  873. d.meeting_status_str,
  874. d.duration
  875. FROM
  876. cygx_activity_signup AS s
  877. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  878. INNER JOIN cygx_activity_attendance_detail AS d ON d.activity_id = s.activity_id
  879. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  880. WHERE
  881. 1 = 1
  882. AND s.do_fail_type = 0
  883. AND s.is_cancel = 0
  884. AND s.is_meeting = ?
  885. AND s.mobile = ?
  886. AND a.is_submit_meeting = 1
  887. AND t.activity_type = 1
  888. GROUP BY
  889. a.activity_id
  890. ORDER BY
  891. a.activity_time DESC
  892. LIMIT ?,?`
  893. _, err = o.Raw(sql, isMeeting, mobile, startSize, pageSize).QueryRows(&item)
  894. return
  895. }
  896. // 线上未来到会列表
  897. func GetAttendanceDetailListNoMeetingByUser(isMeeting int, mobile string, startSize, pageSize int) (item []*UserInteraction, err error) {
  898. o := orm.NewOrmUsingDB("hz_cygx")
  899. sql := `SELECT
  900. s.signup_type,
  901. a.activity_name,
  902. a.chart_permission_name,
  903. a.activity_type_name,
  904. a.label,
  905. a.activity_time,
  906. ( 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
  907. FROM
  908. cygx_activity_signup AS s
  909. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  910. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  911. WHERE
  912. 1 = 1
  913. AND s.do_fail_type = 0
  914. AND s.is_cancel = 0
  915. AND s.is_meeting = ?
  916. AND s.mobile = ?
  917. AND a.is_submit_meeting = 1
  918. AND t.activity_type = 1
  919. GROUP BY
  920. a.activity_id
  921. ORDER BY
  922. a.activity_time DESC
  923. LIMIT ?,?`
  924. _, err = o.Raw(sql, isMeeting, mobile, startSize, pageSize).QueryRows(&item)
  925. return
  926. }
  927. // 用户参会统计
  928. func GetAttendanceDetaiCount(mobile string, meetType, isMeeting int) (count int, err error) {
  929. o := orm.NewOrmUsingDB("hz_cygx")
  930. sqlCount := ` SELECT
  931. COUNT( DISTINCT a.activity_id ) as count
  932. FROM
  933. cygx_activity_signup AS s
  934. INNER JOIN cygx_activity as a ON a.activity_id = s.activity_id
  935. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  936. WHERE
  937. mobile = ?
  938. AND is_meeting =?
  939. AND s.do_fail_type = 0
  940. AND a.is_submit_meeting = 1 `
  941. if meetType == 1 {
  942. sqlCount += ` AND t.activity_type = 1 `
  943. } else {
  944. sqlCount += ` AND t.activity_type = 0 `
  945. }
  946. err = o.Raw(sqlCount, mobile, isMeeting).QueryRow(&count)
  947. return
  948. }
  949. // 线下已到会列表
  950. func GetAttendanceOfflineListByUser(isMeeting int, mobile string, startSize, pageSize int) (item []*UserInteraction, err error) {
  951. o := orm.NewOrmUsingDB("hz_cygx")
  952. sql := `SELECT
  953. a.activity_name,
  954. a.chart_permission_name,
  955. a.activity_type_name,
  956. a.label,
  957. a.activity_time
  958. FROM
  959. cygx_activity_signup AS s
  960. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  961. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  962. WHERE
  963. 1 = 1
  964. AND s.do_fail_type = 0
  965. AND s.is_cancel = 0
  966. AND s.is_meeting = ?
  967. AND s.mobile = ?
  968. AND a.is_submit_meeting = 1
  969. AND t.activity_type = 0
  970. GROUP BY
  971. a.activity_id
  972. ORDER BY
  973. a.activity_time DESC
  974. LIMIT ?,?`
  975. _, err = o.Raw(sql, isMeeting, mobile, startSize, pageSize).QueryRows(&item)
  976. return
  977. }
  978. // 获取用户参会记录数量
  979. func GetActivityMeetByUserCount(condition string) (count int, err error) {
  980. o := orm.NewOrmUsingDB("hz_cygx")
  981. sqlCount := ` SELECT
  982. COUNT( DISTINCT a.activity_id ) as count
  983. FROM
  984. cygx_activity_signup_detail AS s
  985. INNER JOIN cygx_activity as a ON a.activity_id = s.activity_id
  986. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  987. WHERE
  988. 1=1
  989. AND s.do_fail_type = 0 `
  990. if condition != "" {
  991. sqlCount += condition
  992. }
  993. err = o.Raw(sqlCount).QueryRow(&count)
  994. return
  995. }
  996. // 获取用户参会记录
  997. func GetActivityMeetByUser(condition string, startSize, pageSize int) (item []*UserInteraction, err error) {
  998. o := orm.NewOrmUsingDB("hz_cygx")
  999. sql := `SELECT
  1000. t.activity_type,
  1001. s.signup_type,
  1002. s.is_meeting,
  1003. a.activity_name,
  1004. a.chart_permission_name,
  1005. a.activity_type_name,
  1006. a.label,
  1007. a.activity_time,
  1008. s.first_meeting_time,
  1009. s.last_meeting_time,
  1010. s.meeting_type_str,
  1011. s.meeting_authentication,
  1012. s.meeting_status_str,
  1013. s.duration
  1014. FROM
  1015. cygx_activity_signup_detail AS s
  1016. INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  1017. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  1018. WHERE
  1019. 1 = 1
  1020. AND s.do_fail_type = 0 ` + condition + `
  1021. GROUP BY
  1022. s.activity_id,s.outbound_mobile
  1023. ORDER BY
  1024. a.activity_time DESC `
  1025. if startSize > 0 || pageSize > 0 {
  1026. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  1027. }
  1028. _, err = o.Raw(sql).QueryRows(&item)
  1029. return
  1030. }
  1031. // 获取用户参会记录
  1032. func GetActivitySpecialMeetByUser(condition string, startSize, pageSize int) (item []*UserInteraction, err error) {
  1033. o := orm.NewOrmUsingDB("hz_cygx")
  1034. sql := `SELECT
  1035. a.activity_id,
  1036. a.research_theme AS activity_name,
  1037. a.chart_permission_name,
  1038. special_type AS activity_type,
  1039. a.activity_time,
  1040. a.activity_time_text_by_day AS activity_time_text
  1041. FROM
  1042. cygx_activity_special_meeting_detail AS s
  1043. INNER JOIN cygx_activity_special AS a ON a.activity_id = s.activity_id
  1044. WHERE
  1045. 1 = 1 ` + condition + `
  1046. GROUP BY
  1047. s.activity_id,
  1048. s.mobile
  1049. ORDER BY
  1050. a.activity_time DESC `
  1051. if startSize > 0 || pageSize > 0 {
  1052. sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
  1053. }
  1054. _, err = o.Raw(sql).QueryRows(&item)
  1055. return
  1056. }
  1057. type GetUserInteractionTableCountResp struct {
  1058. HistoryNum int `description:"报告阅读"`
  1059. CountNum int `description:"报告收藏"`
  1060. IndustryFllowNum int `description:"产业关注"`
  1061. DepartmentFollowNum int `description:"作者关注"`
  1062. KeyWordNum int `description:"搜索关键词"`
  1063. OnLineNum int `description:"线上互动活动"`
  1064. OfficeNum int `description:"线下互动活动"`
  1065. ActivityNum int `description:"活动数量"`
  1066. ChartNum int `description:"图表数量"`
  1067. TripNum int `description:"图表数量"`
  1068. RoadshowVideoNum int `description:"产业视频播放量"`
  1069. ActivityVideoNum int `description:"活动视频播放量"`
  1070. ActivityVoiceNum int `description:"活动音频播放量"`
  1071. TagNum int `description:"首页标签点击量"`
  1072. YanxuanSpecialNum int `description:"研选专栏阅读数量"`
  1073. YanxuanSpecialCollectNum int `description:"研选专栏收藏数量"`
  1074. YanxuanSpecialFollowNum int `description:"研选专栏作者关注数量"`
  1075. FeedbackNum int `description:"交流反馈数量"`
  1076. }
  1077. // 用户互动总数统计
  1078. func GetUserInteractionTableCount(uid int) (item *GetUserInteractionTableCountResp, err error) {
  1079. o := orm.NewOrmUsingDB("hz_cygx")
  1080. sql := `SELECT
  1081. ( 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,
  1082. ( 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,
  1083. ( 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,
  1084. ( 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,
  1085. ( 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,
  1086. ( 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 = ?
  1087. AND t.activity_type=1 AND h.do_fail_type = 0 AND a.chart_permission_id != 31 ) AS on_line_num,
  1088. ( 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 = ?
  1089. AND t.activity_type = 0 AND h.do_fail_type = 0 AND a.chart_permission_id != 31 ) AS office_num,
  1090. ( 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,
  1091. ( 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,
  1092. ( 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,
  1093. ( 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,
  1094. ( 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,
  1095. ( SELECT COUNT(1) FROM cygx_user_feedback as h WHERE h.user_id = ? ) AS feedback_num
  1096. FROM dual `
  1097. err = o.Raw(sql, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid).QueryRow(&item)
  1098. return
  1099. }
  1100. // 用户互动总数统计
  1101. func GetUserInteractionTableCountByYanXuan(uid int) (item *GetUserInteractionTableCountResp, err error) {
  1102. o := orm.NewOrmUsingDB("hz_cygx")
  1103. sql := `SELECT
  1104. ( 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,
  1105. ( 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,
  1106. ( 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,
  1107. ( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS h WHERE h.user_id = ? AND h.type = 1 ) AS department_follow_num,
  1108. ( 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,
  1109. ( 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 = ?
  1110. AND t.activity_type=1 AND h.do_fail_type = 0 AND a.chart_permission_id = 31 ) AS on_line_num,
  1111. ( 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 = ?
  1112. AND t.activity_type = 0 AND h.do_fail_type = 0 AND a.chart_permission_id = 31 ) AS office_num,
  1113. ( 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,
  1114. ( SELECT COUNT(1) FROM cygx_yanxuan_special_follow as h WHERE h.user_id = ? ) AS yanxuan_special_follow_num,
  1115. ( 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
  1116. FROM dual `
  1117. err = o.Raw(sql, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid).QueryRow(&item)
  1118. return
  1119. }
  1120. // 根据时间获取用户互动总数统计
  1121. func GetUserInteractionTableCountBytime(uid int, startDate, endDate string) (item *GetUserInteractionTableCountResp, err error) {
  1122. o := orm.NewOrm()
  1123. sql := `SELECT
  1124. ( 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,
  1125. ( 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,
  1126. ( 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,
  1127. ( 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,
  1128. ( 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,
  1129. ( 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,
  1130. ( 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
  1131. 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,
  1132. ( 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
  1133. 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
  1134. FROM
  1135. wx_user as u
  1136. WHERE
  1137. u.user_id = ?`
  1138. err = o.Raw(sql, uid).QueryRow(&item)
  1139. return
  1140. }
  1141. type ArticlePvCountResp struct {
  1142. ArticleId int `description:"文章ID"`
  1143. Pv int `description:"Pv"`
  1144. }
  1145. // 阅读记录
  1146. func GetArticlePvCount(mobile, email, dateTime string) (item []*ArticlePvCountResp, err error) {
  1147. o := orm.NewOrmUsingDB("hz_cygx")
  1148. sql := `SELECT
  1149. article_id,
  1150. COUNT(article_id) as pv
  1151. FROM
  1152. cygx_article_history_record_all as h
  1153. WHERE
  1154. mobile = ?
  1155. AND create_time >= ?
  1156. AND is_del = 0
  1157. OR ( email = ? AND email <>'' AND create_time >= ? AND is_del = 0 )
  1158. GROUP BY article_id `
  1159. _, err = o.Raw(sql, mobile, dateTime, email, dateTime).QueryRows(&item)
  1160. return
  1161. }
  1162. type ArticleIndustryNameResp struct {
  1163. ArticleId int `description:"文章ID"`
  1164. IndustryName string `description:"产业名称"`
  1165. SubjectName string `description:"标的名称"`
  1166. }
  1167. // 产业名称
  1168. func GetArticleGroupyIndustryName(articleIds string) (item []*ArticleIndustryNameResp, err error) {
  1169. o := orm.NewOrmUsingDB("hz_cygx")
  1170. sql := `SELECT
  1171. art.article_id,
  1172. (
  1173. SELECT
  1174. GROUP_CONCAT( DISTINCT s.subject_name SEPARATOR '/' )
  1175. FROM
  1176. cygx_industrial_subject AS s
  1177. WHERE
  1178. s.industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_article_group_subject AS sg WHERE sg.article_id = art.article_id )
  1179. ) AS subject_name,
  1180. (
  1181. SELECT
  1182. GROUP_CONCAT( DISTINCT man.industry_name SEPARATOR '/' )
  1183. FROM
  1184. cygx_industrial_management AS man
  1185. WHERE
  1186. 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 )
  1187. ) AS industry_name
  1188. FROM
  1189. cygx_article_history_record_all AS r
  1190. INNER JOIN cygx_article AS art ON art.article_id = r.article_id
  1191. LEFT JOIN cygx_report_mapping AS re ON re.category_id = art.category_id_two
  1192. LEFT JOIN cygx_industrial_article_group_management AS man ON man.article_id = art.article_id
  1193. WHERE
  1194. art.article_id IN ( ` + articleIds + `) GROUP BY art.article_id `
  1195. _, err = o.Raw(sql).QueryRows(&item)
  1196. return
  1197. }
  1198. // 标的名称
  1199. func GetArticleGroupySubjectName(articleIds string) (item []*ArticleIndustryNameResp, err error) {
  1200. o := orm.NewOrmUsingDB("hz_cygx")
  1201. sql := `SELECT
  1202. article_id,
  1203. subject_name
  1204. FROM
  1205. cygx_industrial_article_group_subject AS mg
  1206. INNER JOIN cygx_industrial_subject AS m ON m.industrial_subject_id = mg.industrial_subject_id
  1207. WHERE
  1208. article_id IN ( ` + articleIds + `)`
  1209. _, err = o.Raw(sql).QueryRows(&item)
  1210. return
  1211. }
  1212. type UserLabel struct {
  1213. Label string `description:"标签 多个用 , 隔开"`
  1214. }
  1215. type ActivityLabelCountResp struct {
  1216. Label string `description:"标签"`
  1217. Pv int `description:"Pv"`
  1218. }
  1219. // 活动标签记录(我的日程)
  1220. func GetActivitySignCount(mobile, dateTime string) (item []*ActivityLabelCountResp, err error) {
  1221. o := orm.NewOrmUsingDB("hz_cygx")
  1222. sql := `SELECT
  1223. label ,
  1224. COUNT( label ) AS pv
  1225. FROM
  1226. cygx_activity
  1227. WHERE
  1228. activity_id IN ( SELECT activity_id FROM cygx_my_schedule WHERE mobile = ? )
  1229. AND label != ''
  1230. AND activity_time >= ?
  1231. GROUP BY
  1232. label`
  1233. _, err = o.Raw(sql, mobile, dateTime).QueryRows(&item)
  1234. return
  1235. }
  1236. // 活动标签记录(会议提醒)
  1237. func GetActivityMeetingReminder(mobile, dateTime string) (item []*ActivityLabelCountResp, err error) {
  1238. o := orm.NewOrmUsingDB("hz_cygx")
  1239. sql := `SELECT
  1240. label ,
  1241. COUNT( label ) AS pv
  1242. FROM
  1243. cygx_activity
  1244. WHERE
  1245. activity_id IN ( SELECT activity_id FROM cygx_activity_meeting_reminder WHERE mobile = ? )
  1246. AND label != ''
  1247. AND activity_time >= ?
  1248. GROUP BY
  1249. label`
  1250. _, err = o.Raw(sql, mobile, dateTime).QueryRows(&item)
  1251. return
  1252. }
  1253. func GetCygxArticleCollectId(uid int, dateTime string) (articleIds string, err error) {
  1254. sql := `SELECT
  1255. GROUP_CONCAT( DISTINCT article_id SEPARATOR ',' ) AS permission
  1256. FROM
  1257. cygx_article_collect
  1258. WHERE
  1259. user_id = ?
  1260. AND create_time >= ? `
  1261. o := orm.NewOrmUsingDB("hz_cygx")
  1262. err = o.Raw(sql, uid, dateTime).QueryRow(&articleIds)
  1263. return
  1264. }
  1265. // 用户互动量
  1266. type CygxInteractionNumResp struct {
  1267. DateTime string `description:"时间"`
  1268. InteractionNum int `description:"互动量"`
  1269. }
  1270. type CygxCygxInteractionNumRespListResp struct {
  1271. List []*CygxInteractionNumResp
  1272. }
  1273. // 用户互动详情
  1274. type UserInteractionrelevantListResp struct {
  1275. IndustryName string `description:"产业名称"`
  1276. IsFllow bool `description:"是否关注"`
  1277. List []*UserInteraction
  1278. }
  1279. type EsUserInteraction struct {
  1280. Id int `description:"主键ID"`
  1281. ArticleId int `description:"文章id"`
  1282. ArticleType int `description:"文章类型 1:查研观向, 2:策略平台"`
  1283. Title string `description:"标题"`
  1284. PublishDate string `description:"发布时间"`
  1285. CreateTime string `description:"创建时间"`
  1286. StopTime string `description:"阅读停留时间"`
  1287. RealName string `description:"姓名"`
  1288. CompanyName string `description:"公司名称"`
  1289. CompanyId int `description:"公司ID"`
  1290. SellerName string `description:"所属销售"`
  1291. SellerId int `description:"所属销售ID"`
  1292. Mobile string `description:"手机号"`
  1293. Email string `description:"邮箱"`
  1294. UserId int `description:"用户ID"`
  1295. UserArticleHistoryNum int `description:"用户阅读数量"`
  1296. CompanyArticleHistoryNum int `description:"机构阅读数量"`
  1297. }
  1298. func GetCompanyIdsCondition(ondition string) (companyIds string, err error) {
  1299. sql := ondition
  1300. o := orm.NewOrm()
  1301. err = o.Raw(sql).QueryRow(&companyIds)
  1302. return
  1303. }
  1304. type InteractiveList struct {
  1305. TotalMap map[int]int
  1306. EsList []*EsUserInteraction
  1307. ActivityList []*company.CompanyReportRecordGroup
  1308. CollectList []*company.CompanyReportRecordGroup
  1309. IndustryFllowList []*company.CompanyReportRecordGroup
  1310. DepartmentFollowList []*company.CompanyReportRecordGroup
  1311. KeyWordList []*company.CompanyReportRecordGroup
  1312. Chartist []*company.CompanyReportRecordGroup
  1313. }
  1314. func GetAllOverseasRaiEmail() (emails []string, err error) {
  1315. sql := `
  1316. SELECT
  1317. *
  1318. FROM
  1319. (
  1320. SELECT
  1321. wu.email
  1322. FROM
  1323. wx_user AS wu
  1324. INNER JOIN company AS c
  1325. WHERE
  1326. wu.company_id = c.company_id
  1327. AND wu.email <> ""
  1328. AND c.region_type = "海外"
  1329. ) AS a UNION
  1330. (
  1331. SELECT
  1332. wu.email
  1333. FROM
  1334. company_product AS cp
  1335. INNER JOIN wx_user AS wu
  1336. WHERE
  1337. cp.industry_id = 10
  1338. AND cp.product_id = 2
  1339. AND wu.email <> ""
  1340. AND cp.status IN ( "正式", "试用" )
  1341. )`
  1342. o := orm.NewOrm()
  1343. _, err = o.Raw(sql).QueryRows(&emails)
  1344. return
  1345. }