cygx_user.go 57 KB

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