cygx_user.go 57 KB

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