cygx_user.go 56 KB

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