cygx_user.go 58 KB

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