cygx_user.go 58 KB

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