cygx_user.go 57 KB

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