cygx_user.go 57 KB

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