activity.go 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "strings"
  6. "time"
  7. )
  8. // 活动详情
  9. type CygxActivity struct {
  10. ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
  11. ActivityTypeId int `description:"活动类型id"`
  12. ActivityTypeName string `description:"活动类型名称"`
  13. ChartPermissionId int `description:"行业id"`
  14. ChartPermissionName string `description:"行业名称"`
  15. ChartPermissionNames string `description:"行业名称辅助字段,区分研选子分类"`
  16. Body string `description:"内容"`
  17. CreateTime time.Time `description:"创建时间"`
  18. PublishDate time.Time `description:"发布时间"`
  19. IsLimitPeople int `description:"是否限制人数 1是,0否"`
  20. LimitPeopleNum int `description:"限制的人数数量"`
  21. CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
  22. PublishStatus int `description:"发布状态 1已发布,0未发布"`
  23. LastUpdatedTime time.Time `description:"更新时间"`
  24. ActivityTime string `description:"活动时间"`
  25. ActivityTimeText string `description:"活动时间带文字"`
  26. DistinguishedGuest string `description:"嘉宾"`
  27. Host string `description:"主持人"`
  28. MainlandTell string `description:"大陆拨入号"`
  29. HongKongTell string `description:"香港拨入号"`
  30. TaiwanTell string `description:"台湾拨入号"`
  31. AmericaTell string `description:"美国拨入号"`
  32. ParticipationCode string `description:"参会密码"`
  33. Theme string `description:"主题"`
  34. Expert string `description:"专家"`
  35. ActivityName string `description:"活动名称"`
  36. ActivityNameTask string `description:"活动名称定时任务同步的时候使用"`
  37. OnlineParticipation string `description:"网络参会"`
  38. ReportLink string `description:"报告链接"`
  39. City string `description:"城市"`
  40. Address string `description:"活动地址"`
  41. Highlights string `description:"活动亮点"`
  42. Remarks string `description:"备注"`
  43. Speaker string `description:"主讲人"`
  44. ArticleId int `description:"关联报告id"`
  45. Label string `description:"标签"`
  46. LinkParticipants string `description:"链接参会"`
  47. AppAttendance string `description:"App参会"`
  48. ConferencePassword string `description:"会议密码"`
  49. TemporaryLabel string `description:"临时标签"`
  50. IsMakerShow int `description:"是否仅决策人可见 0,否 、1,是"`
  51. VisibleRange int `description:"可见范围 1,仅本组可见 、2,全部客户可见"`
  52. Scale string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
  53. IsShowSubjectName int `description:"小程序内是否展示标的名称 1是 ,0 否 默认0 "`
  54. IsHideAppointment int `description:"是否隐藏预约纪要按钮 1是 ,0 否 默认0 "`
  55. AdminId int `description:"销售/管理员ID"`
  56. AdminName string `description:"销售/管理员姓名"`
  57. IsCanAppointmentMinutes int `description:"是否可预约纪要 1是 ,0 否 默认0 "`
  58. YidongActivityId string `description:"易董活动ID"`
  59. IsExternalLabel int `description:"是否为外部资源 1是,0否"`
  60. IsResearchPoints int `description:"是否为研选扣点"`
  61. }
  62. // 活动详情
  63. type ActivityDetail struct {
  64. ActivityId int `orm:"column(activity_id);pk";description:"活动ID "`
  65. ActivityTypeId int `description:"活动类型id"`
  66. ActivityTypeName string `description:"活动类型名称"`
  67. ChartPermissionId int `description:"行业id"`
  68. ChartPermissionName string `description:"行业名称"`
  69. ChartPermissionNames string `description:"行业名称辅助字段,区分研选子分类"`
  70. Body string `description:"内容"`
  71. CreateTime string `description:"创建时间"`
  72. IsLimitPeople int `description:"是否限制人数 1是,0否"`
  73. LimitPeopleNum int `description:"限制的人数数量"`
  74. LastUpdatedTime string `description:"更新时间"`
  75. ActivityTime string `description:"活动时间"`
  76. ActivityTimeText string `description:"活动时间带文字"`
  77. DistinguishedGuest string `description:"嘉宾"`
  78. Host string `description:"主持人"`
  79. Speaker string `description:"主讲人"`
  80. MainlandTell string `description:"大陆拨入号"`
  81. HongKongTell string `description:"香港拨入号"`
  82. TaiwanTell string `description:"台湾拨入号"`
  83. AmericaTell string `description:"美国拨入号"`
  84. ParticipationCode string `description:"参会密码"`
  85. Theme string `description:"主题"`
  86. Expert string `description:"专家"`
  87. ActivityName string `description:"活动名称"`
  88. OnlineParticipation string `description:"网络参会"`
  89. ReportLink string `description:"报告链接"`
  90. City string `description:"城市"`
  91. Address string `description:"活动地址"`
  92. Highlights string `description:"活动亮点"`
  93. Remarks string `description:"备注"`
  94. ShowType string `description:"人数限制类型,1不展示限制,2可选限制,3强制限制"`
  95. IsSignup int `description:"是否已报名 1是 ,0 否"`
  96. IsAppointment int `description:"是否已预约纪要 1是 ,0 否"`
  97. SignupNum int `description:"已报名人数"`
  98. SignupType int `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
  99. ActiveState string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
  100. IsCancelMeetingReminder int `description:"是否取消会议提醒 1展示取消会议提醒 ,0展示会议提醒"`
  101. ArticleId int `description:"报告id(报告链接跳转使用)"`
  102. CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
  103. IsShowSustainable bool `description:"是否展示限免标签"`
  104. Description string `description:"研选内容说明"`
  105. IsResearch bool `description:"是否属于研选"`
  106. LinkParticipants string `description:"链接参会"`
  107. AppAttendance string `description:"App参会"`
  108. ConferencePassword string `description:"会议密码"`
  109. Scale string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
  110. IsShowAppointment bool `description:"是否展示预约纪要"`
  111. IsHideAppointment int `description:"是否隐藏预约纪要按钮 1是,0 否"`
  112. IsCClassMeeting bool `description:"是否是c类电话会"`
  113. ArticleList []*ActivityArticleResp // 下面是列表添加的部分结构体
  114. IsBrackets int `description:"是否有方括号 1是 ,0 否"`
  115. Label string `description:"主题标签"`
  116. ImgUrl string `description:"图片链接"`
  117. ImgUrlText string `description:"图片链接文字"`
  118. ActivityType int `description:"活动线上线下类型 1线上,0 线下"`
  119. JmcjRoadshowTitle string `description:"进门财经手动匹配的活动名称"`
  120. Listndustrial []*IndustrialManagementRep `description:"活动关联的产业信息"`
  121. IsShowOutboundCall bool `description:"是否展示预约外呼"`
  122. IsShowMeetingReminder bool `description:"是否展示会议提醒"`
  123. IsShowHelpSsk bool `description:"是否展示帮我带问"`
  124. IsShowSignup bool `description:"是否展示我要报名"`
  125. IsShowDetails bool `description:"是否展示查看详情按钮"`
  126. TemporaryLabel string `description:"临时标签"`
  127. IsCanAppointmentMinutes int `description:"是否可预约纪要 1是 ,0 否 默认0 "`
  128. YidongActivityId string `description:"易董活动ID"`
  129. IsYidongActivity bool `description:"是否属于易董同步过来的活动"`
  130. YidongActivityUrl string `description:"易董活动跳转地址"`
  131. AudioLink bool `description:"是否展示回放按钮"`
  132. VoiceList *CygxActivityVoiceReq `description:"音频数据"`
  133. AdminId int `description:"管理员、销售ID "`
  134. IsMakerShow int `description:"是否仅决策人可见 0,否 、1,是"`
  135. VisibleRange int `description:"可见范围 1,仅本组可见 、2,全部客户可见"`
  136. VideoDetail *CygxActivityVideoListResp `description:"视频数据"`
  137. FileType int `description:"类型: 1-音频; 2-视频"`
  138. SourceType int `description:"活动来源。 1:活动 、2:专项产业调研"`
  139. TripImgLink string `description:"专项产业调研行程链接"`
  140. ActivityTimeEnd string `description:"专项产业调研活动预期结束时间"`
  141. AuthInfo *UserPermissionAuthInfo `description:"用户查看视频的权限"`
  142. Days int `description:"调研天数"`
  143. Title string `description:"标题"`
  144. IsYidongConduct bool `description:"是否属于易董办会 1:是 、0:否"`
  145. IsCanOutboundCall int `description:"是否提供外呼 1:是 、0:否"`
  146. TencentConferenceNumber string `description:"腾讯会议号"`
  147. IsResearchSpecial bool `description:"是否属于特殊的研选"`
  148. IsNeedEmail int `description:"是否需要提供邮箱 1是,0否"`
  149. SiginupDeadline string `description:"报名截止时间"`
  150. IsExternalLabel bool `description:"是否为外部资源"`
  151. IsResearchPoints bool `description:"是否为研选扣点"`
  152. CancelDeadline string `description:"取消报名截止时间"`
  153. ChartPermissionNameDeputy string `description:"副行业名称"`
  154. TopTime int `description:"置顶时间"`
  155. }
  156. // 活动详情
  157. type ActivityListResp struct {
  158. ActivityId int `description:"活动ID "`
  159. ActivityTypeId int `description:"活动类型id"`
  160. ActivityTypeName string `description:"活动类型名称"`
  161. ChartPermissionId int `description:"行业id"`
  162. ChartPermissionName string `description:"行业名称"`
  163. IsLimitPeople int `description:"是否限制人数 1是,0否"`
  164. LimitPeopleNum int `description:"限制的人数数量"`
  165. LastUpdatedTime string `description:"更新时间"`
  166. ActivityTime string `description:"活动时间"`
  167. ActivityTimeText string `description:"活动时间带文字"`
  168. DistinguishedGuest string `description:"嘉宾"`
  169. Host string `description:"主持人"`
  170. Speaker string `description:"主讲人"`
  171. MainlandTell string `description:"大陆拨入号"`
  172. HongKongTell string `description:"香港拨入号"`
  173. TaiwanTell string `description:"台湾拨入号"`
  174. AmericaTell string `description:"美国拨入号"`
  175. ParticipationCode string `description:"参会密码"`
  176. Theme string `description:"主题"`
  177. Expert string `description:"专家"`
  178. ActivityName string `description:"活动名称"`
  179. OnlineParticipation string `description:"网络参会"`
  180. ReportLink string `description:"报告链接"`
  181. LinkParticipants string `description:"链接参会"`
  182. AppAttendance string `description:"App参会"`
  183. ConferencePassword string `description:"会议密码"`
  184. City string `description:"城市"`
  185. Address string `description:"活动地址"`
  186. Highlights string `description:"活动亮点"`
  187. Remarks string `description:"备注"`
  188. IsSignup int `description:"是否已报名 1是 ,0 否"`
  189. SignupNum int `description:"已报名人数"`
  190. IsAppointment int `description:"是否已预约纪要 1是 ,0 否"`
  191. IsCancelMeetingReminder int `description:"是否添加了消息消息提醒 1是 ,0 否"`
  192. ActiveState string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
  193. IsShowSustainable bool `description:"是否展示限免标签"`
  194. Description string `description:"研选内容说明"`
  195. IsResearch bool `description:"是否属于研选"`
  196. IsHideAppointment int `description:"是否隐藏预约纪要按钮 1是,0 否"`
  197. IsCClassMeeting bool `description:"是否是c类电话会"`
  198. Label string `description:"主题标签"`
  199. ImgUrl string `description:"行业图片链接"`
  200. ImgUrlText string `description:"活动类型图片链接"`
  201. ActivityType int `description:"活动线上线下类型 1线上,0 线下"`
  202. IsShowOutboundCall bool `description:"是否展示预约外呼"`
  203. IsShowMeetingReminder bool `description:"是否展示会议提醒"`
  204. IsShowHelpSsk bool `description:"是否展示帮我带问"`
  205. IsShowSignup bool `description:"是否展示我要报名"`
  206. IsShowAppointment bool `description:"是否展示预约纪要"`
  207. IsShowDetails bool `description:"是否展示查看详情按钮"`
  208. AudioLink bool `description:"是否展示回放按钮"`
  209. VoiceDetail *CygxActivityVoiceReq `description:"音频数据"`
  210. VideoDetail *CygxActivityVideoListResp `description:"视频数据"`
  211. FileType int `description:"类型: 1-音频; 2-视频"`
  212. SourceType int `description:"活动来源。 1:活动 、2:专项产业调研"`
  213. YidongActivityUrl string `description:"易董活动跳转地址"`
  214. ArticleList []*ActivityArticleResp
  215. Listndustrial []*IndustrialManagementRep `description:"活动关联的产业信息"`
  216. AuthInfo *UserPermissionAuthInfo `description:"用户查看视频的权限"`
  217. Explain string `description:"活动右上角提示"`
  218. TripImgLink string `description:"专项产业调研行程链接"`
  219. IsTrip int `description:"是否报名 1是 ,0 否"`
  220. TripStatus int `description:"行程进行状态 1:预报名,2:确定行程"`
  221. Days int `description:"调研天数"`
  222. SignupType int `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
  223. IsYidongConduct bool `description:"是否属于易董办会 1:是 、0:否"`
  224. IsCanOutboundCall int `description:"是否提供外呼 1:是 、0:否"`
  225. TencentConferenceNumber string `description:"腾讯会议号"`
  226. IsResearchSpecial bool `description:"是否属于特殊的研选"`
  227. IsExternalLabel bool `description:"是否为外部资源"`
  228. IsResearchPoints bool `description:"是否为研选扣点"`
  229. SiginupDeadline string `description:"报名截止时间"`
  230. CancelDeadline string `description:"取消报名截止时间"`
  231. IsYidongActivity bool `description:"是否属于易董同步过来的活动"`
  232. TopTime int `description:"置顶时间"`
  233. ShareImg string `description:"分享图片"`
  234. }
  235. type ActivityCheck struct {
  236. CheckPermission bool `description:"权限是否通过校验"`
  237. HasPermission int `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
  238. PopupMsg string `description:"权限弹窗信息"`
  239. CancelPopupMsg string `description:"取消报名时间弹窗信息"`
  240. SellerMobile string `description:"销售电话"`
  241. SellerName string `description:"销售姓名"`
  242. Mobile string `description:"手机号"`
  243. IsResearch bool `description:"是否属于研选"`
  244. IsResearchSpecial bool `description:"是否属于特殊的研选"`
  245. CheckTime bool `description:"时间是否通过校验"`
  246. CheckEmail bool `description:"邮箱是否通过校验"`
  247. CheckPoints bool `description:"扣点是否通过校验"`
  248. CompanyPoints string `description:"公司剩余点数"`
  249. ActivityPoints string `description:"本场活动要扣除的点数"`
  250. }
  251. type ActivityArticleResp struct {
  252. ReportLink string `description:"报告链接"`
  253. Title string `description:"报告标题"`
  254. ArticleId int `description:"报告id(报告链接跳转使用)"`
  255. }
  256. type CygxActivityResp struct {
  257. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下(ficc),3:无该品类权限,已提交过申请,4:无该品类权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  258. PopupMsg string `description:"权限弹窗信息"`
  259. SellerMobile string `description:"销售电话"`
  260. SellerName string `description:"销售姓名"`
  261. IsResearch bool `description:"是否属于研选"`
  262. IsResearchSpecial bool `description:"是否属于特殊的研选"`
  263. Detail *ActivityListResp
  264. }
  265. type CygxYidongActivityUrlResp struct {
  266. HasPermission int `description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下(ficc),3:无该品类权限,已提交过申请,4:无该品类权限,未提交过申请,5:潜在客户,未提交过申请,6:潜在客户,已提交过申请"`
  267. PopupMsg string `description:"权限弹窗信息"`
  268. SellerMobile string `description:"销售电话"`
  269. SellerName string `description:"销售姓名"`
  270. IsResearch bool `description:"是否属于研选"`
  271. IsResearchSpecial bool `description:"是否属于特殊的研选"`
  272. YidongActivityUrl string `description:"易董活动跳转地址"`
  273. }
  274. // 列表
  275. func GetCygxActivityList(condition string, pars []interface{}, sortTime string, startSize, pageSize int) (items []*CygxActivity, err error) {
  276. o := orm.NewOrm()
  277. sql := `SELECT activity_id,chart_permission_id, city, label,temporary_label,is_show_subject_name, MAX( art.activity_time ) AS timesort, MIn( art.activity_time ) AS mintimesort , yidong_activity_id , activity_type_id,is_external_label,is_research_points
  278. FROM cygx_activity as art WHERE 1= 1 `
  279. if condition != "" {
  280. sql += condition
  281. }
  282. sql += ` GROUP BY art.activity_id ORDER BY ` + sortTime + ` ,art.activity_id DESC LIMIT ?,? `
  283. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  284. return
  285. }
  286. // 通过纪要ID获取活动详情
  287. func GetAddActivityInfoById(ActivityId int) (item *ActivityDetail, err error) {
  288. o := orm.NewOrm()
  289. sql := `SELECT * FROM cygx_activity WHERE activity_id=? AND publish_status = 1 `
  290. err = o.Raw(sql, ActivityId).QueryRow(&item)
  291. return
  292. }
  293. // 获取数量
  294. func GetActivityCount(condition string, playBack int, pars []interface{}, filter int) (count int, err error) {
  295. var sqlJiontable string
  296. if playBack == 1 {
  297. //sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  298. }
  299. if filter == 1 {
  300. sqlJiontable = ` INNER JOIN cygx_activity_video AS av ON av.activity_id = art.activity_id `
  301. } else if filter == 2 {
  302. sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  303. }
  304. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_activity as art ` + sqlJiontable + ` WHERE 1= 1 `
  305. if condition != "" {
  306. sqlCount += condition
  307. }
  308. o := orm.NewOrm()
  309. err = o.Raw(sqlCount, pars).QueryRow(&count)
  310. return
  311. }
  312. func GetActivityListNew(condition string, pars []interface{}, uid, startSize, pageSize, playBack, filter int, typeName string) (items []*ActivityDetail, err error) {
  313. var sqlJiontable string
  314. if playBack == 1 {
  315. //sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  316. }
  317. if filter == 1 {
  318. sqlJiontable = ` INNER JOIN cygx_activity_video AS av ON av.activity_id = art.activity_id `
  319. } else if filter == 2 {
  320. sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  321. }
  322. o := orm.NewOrm()
  323. sql := `SELECT art.* ,t.activity_type,t.img_url_text,1 AS source_type,
  324. ( SELECT COUNT( 1 ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id AND s.user_id = ? AND s.is_cancel = 0 AND s.do_fail_type = 0) AS is_signup,
  325. ( SELECT COUNT( DISTINCT user_id ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id AND s.is_cancel = 0 AND s.do_fail_type = 0) AS signup_num,
  326. ( SELECT COUNT( 1 ) FROM cygx_activity_meeting_reminder AS m WHERE m.activity_id = art.activity_id AND m.user_id = ? AND m.is_cancel = 0 ) AS is_cancel_meeting_reminder,
  327. ( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment
  328. FROM cygx_activity as art
  329. INNER JOIN cygx_activity_type as t ON t.activity_type_id = art.activity_type_id ` + sqlJiontable + ` WHERE 1= 1 `
  330. if condition != "" {
  331. sql += condition
  332. }
  333. sql += ` LIMIT ?,?`
  334. if typeName != "" {
  335. typeSlice := strings.Split(typeName, ",")
  336. tempCondition := ""
  337. for _, s := range typeSlice {
  338. if s == "1" {
  339. tempCondition += "'专家电话会',"
  340. } else if s == "2" {
  341. tempCondition += "'分析师电话会',"
  342. } else if s == "1,2" {
  343. tempCondition += "'专家电话会','分析师电话会',"
  344. }
  345. }
  346. tempCondition = strings.TrimRight(tempCondition, ",")
  347. sql = `SELECT * FROM(` + sql + `) AS t WHERE t.activity_type_name IN (` + tempCondition + `)`
  348. }
  349. _, err = o.Raw(sql, uid, uid, uid, pars, startSize, pageSize).QueryRows(&items)
  350. return
  351. }
  352. // 列表
  353. func GetActivityListHomeNew(condition string, startSize, pageSize int) (items []*ActivityDetail, err error) {
  354. o := orm.NewOrm()
  355. sql := `SELECT activity_id
  356. FROM cygx_activity as art
  357. INNER JOIN cygx_activity_type as t ON t.activity_type_id = art.activity_type_id WHERE 1= 1 `
  358. if condition != "" {
  359. sql += condition
  360. }
  361. sql += ` LIMIT ?,?`
  362. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
  363. return
  364. }
  365. type GetCygxActivityListRep struct {
  366. Paging *paging.PagingItem `description:"分页数据"`
  367. List []*ActivityListResp
  368. Label string `description:"主题"`
  369. ImgUrl string `description:"图片路径"`
  370. IsResearch bool `description:"是否属于研选"`
  371. IsJump bool `description:"是否跳转"`
  372. IndustrialManagementId int `description:"产业ID"`
  373. IndustryNewLabel bool `description:"产业是否新标签"`
  374. ChartPermissionId int `description:"权限id"`
  375. IsShowResearchPoints bool `description:"是否展示研选扣点搜索"`
  376. }
  377. type GetCygxActivityListSearchResp struct {
  378. Paging *paging.PagingItem `description:"分页数据"`
  379. List []*ActivityDetail
  380. Label string `description:"主题"`
  381. ImgUrl string `description:"图片路径"`
  382. IsResearch bool `description:"是否属于研选"`
  383. IsJump bool `description:"是否跳转"`
  384. IndustrialManagementId int `description:"产业ID"`
  385. IndustryNewLabel bool `description:"产业是否新标签"`
  386. ChartPermissionId int `description:"权限id"`
  387. }
  388. // 通过纪要ID获取活动详情
  389. func GetAddActivityInfoByIdShow(uid, ActivityId int) (item *ActivityDetail, err error) {
  390. o := orm.NewOrm()
  391. sql := `SELECT *,( SELECT COUNT( 1 ) FROM cygx_activity_signup AS s WHERE s.activity_id = a.activity_id AND s.user_id = ? AND s.is_cancel = 0 AND s.do_fail_type = 0) AS is_signup,
  392. ( SELECT COUNT( DISTINCT user_id ) FROM cygx_activity_signup AS s WHERE s.activity_id = a.activity_id AND s.is_cancel = 0 AND s.do_fail_type = 0) AS signup_num,
  393. ( SELECT COUNT( 1 ) FROM cygx_activity_meeting_reminder AS m WHERE m.activity_id = a.activity_id AND m.user_id = ? AND m.is_cancel = 0 ) AS is_cancel_meeting_reminder,
  394. ( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = a.activity_id AND ap.user_id = ? ) AS is_appointment
  395. FROM cygx_activity AS a WHERE activity_id=? AND publish_status = 1 `
  396. err = o.Raw(sql, uid, uid, uid, ActivityId).QueryRow(&item)
  397. return
  398. }
  399. // GetActivitySpecialSearcheList 活动与专项调研的搜索
  400. func GetActivitySpecialSearcheList(condition string, pars []interface{}, conditionSpecil string, parsSpecil []interface{}, startSize, pageSize int) (items []*ActivityDetail, total int, err error) {
  401. o := orm.NewOrm()
  402. sql := `SELECT
  403. art.activity_id,
  404. art.activity_time_text,
  405. art.activity_name,
  406. art.chart_permission_id,
  407. art.active_state,
  408. t.activity_type,
  409. art.chart_permission_name,
  410. art.distinguished_guest,
  411. art.expert,
  412. art.speaker,
  413. "" AS trip_img_link,
  414. "" AS activity_time_end,
  415. art.yidong_activity_id,
  416. art.is_can_appointment_minutes,
  417. art.activity_type_id,
  418. art.limit_people_num,
  419. art.is_limit_people,
  420. 1 AS source_type,
  421. t.img_url_text,
  422. art.is_yidong_conduct,
  423. art.is_can_outbound_call,
  424. art.city,
  425. art.is_research_points,
  426. art.siginup_deadline,
  427. art.cancel_deadline,
  428. art.activity_time
  429. FROM
  430. cygx_activity AS art
  431. INNER JOIN cygx_activity_type AS t ON t.activity_type_id = art.activity_type_id
  432. WHERE
  433. 1 = 1 `
  434. if condition != `` {
  435. sql += condition
  436. }
  437. sql += ` UNION ALL
  438. SELECT
  439. art.activity_id,
  440. art.activity_time_text_by_day AS activity_time_text,
  441. art.research_theme AS activity_name,
  442. art.chart_permission_id,
  443. "",
  444. art.special_type AS activity_type,
  445. art.chart_permission_name,
  446. "",
  447. "",
  448. "",
  449. art.trip_img_link_fix AS trip_img_link,
  450. art.activity_time_end,
  451. "",
  452. "",
  453. "",
  454. "",
  455. "",
  456. 2 AS source_type,
  457. "",
  458. "",
  459. "",
  460. "",
  461. "",
  462. "",
  463. "",
  464. art.activity_time
  465. FROM
  466. cygx_activity_special AS art
  467. WHERE
  468. 1 = 1 `
  469. if conditionSpecil != "" {
  470. sql += conditionSpecil
  471. }
  472. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  473. err = o.Raw(totalSql, pars, parsSpecil).QueryRow(&total)
  474. if err != nil {
  475. return
  476. }
  477. sql += ` ORDER BY activity_time DESC LIMIT ?,?`
  478. _, err = o.Raw(sql, pars, parsSpecil, startSize, pageSize).QueryRows(&items)
  479. return
  480. }
  481. // 获取我的日程数量
  482. func GetScheduleCount(condition string, uid int) (count int, err error) {
  483. o := orm.NewOrm()
  484. sqlCount := `SELECT COUNT( 1 ) AS count
  485. FROM cygx_my_schedule AS m
  486. INNER JOIN cygx_activity AS art ON art.activity_id = m.activity_id
  487. WHERE
  488. user_id = ?`
  489. if condition != "" {
  490. sqlCount += condition
  491. }
  492. err = o.Raw(sqlCount, uid).QueryRow(&count)
  493. return
  494. }
  495. // 获取我的日程数量
  496. func GetSpecialScheduleCount(uid int) (count int, err error) {
  497. o := orm.NewOrm()
  498. sqlCount := `
  499. SELECT COUNT( 1 ) AS count FROM
  500. cygx_activity_special AS art
  501. INNER JOIN cygx_activity_special_trip AS my ON my.activity_id = art.activity_id
  502. WHERE
  503. 1 = 1 AND my.user_id = ? AND my.is_cancel = 0`
  504. err = o.Raw(sqlCount, uid).QueryRow(&count)
  505. return
  506. }
  507. // 我的日程列表
  508. func GetScheduleList(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*ActivityDetail, err error) {
  509. o := orm.NewOrm()
  510. sql := `SELECT art.*,t.activity_type,t.img_url_text,
  511. ( SELECT COUNT( 1 ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id AND s.user_id = ? AND s.is_cancel = 0 AND s.do_fail_type = 0) AS is_signup,
  512. ( SELECT COUNT( DISTINCT user_id ) FROM cygx_activity_signup AS s WHERE s.activity_id = art.activity_id AND s.is_cancel = 0 AND s.do_fail_type = 0) AS signup_num ,
  513. ( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment,
  514. ( SELECT COUNT( 1 ) FROM cygx_activity_meeting_reminder AS m WHERE m.activity_id = art.activity_id AND m.is_cancel = 0 AND m.user_id = ? ) AS is_cancel_meeting_reminder,
  515. 1 AS source_type
  516. FROM cygx_activity AS art
  517. INNER JOIN cygx_my_schedule as my ON my.activity_id = art.activity_id
  518. INNER JOIN cygx_activity_type as t ON t.activity_type_id = art.activity_type_id
  519. WHERE 1=1 AND my.user_id = ? `
  520. if condition != "" {
  521. sql += condition
  522. }
  523. sql += ` ORDER BY art.active_state ASC,art.activity_time ASC LIMIT ?,?`
  524. _, err = o.Raw(sql, pars, uid, uid, uid, uid, startSize, pageSize).QueryRows(&items)
  525. return
  526. }
  527. // 我的日程列表 活动以及专项调研一起
  528. func GetScheduleAndSpecilList(condition string, pars []interface{}, conditionSpecil string, parsSpecil []interface{}, startSize, pageSize int) (items []*ActivityDetail, err error) {
  529. o := orm.NewOrm()
  530. sql := `SELECT
  531. art.activity_id,
  532. art.activity_time_text,
  533. art.activity_name,
  534. art.chart_permission_id,
  535. art.active_state,
  536. t.activity_type,
  537. art.chart_permission_name,
  538. art.distinguished_guest,
  539. art.expert,
  540. art.speaker,
  541. "" AS trip_img_link,
  542. "" AS activity_time_end,
  543. art.yidong_activity_id,
  544. art.is_can_appointment_minutes,
  545. art.activity_type_id,
  546. art.limit_people_num,
  547. art.is_limit_people,
  548. 1 AS source_type,
  549. art.activity_time,
  550. 0 AS days,
  551. art.city AS city,
  552. art.is_external_label,
  553. art.is_yidong_conduct,
  554. art.is_can_outbound_call,
  555. art.is_research_points,
  556. art.cancel_deadline,
  557. art.host
  558. FROM
  559. cygx_activity AS art
  560. INNER JOIN cygx_my_schedule AS my ON my.activity_id = art.activity_id
  561. INNER JOIN cygx_activity_type AS t ON t.activity_type_id = art.activity_type_id
  562. WHERE
  563. 1 = 1 `
  564. if condition != `` {
  565. sql += condition
  566. }
  567. sql += ` UNION ALL
  568. SELECT
  569. art.activity_id,
  570. art.activity_time_text_by_day AS activity_time_text,
  571. art.research_theme AS activity_name,
  572. art.chart_permission_id,
  573. "",
  574. art.special_type AS activity_type,
  575. art.chart_permission_name,
  576. "",
  577. "",
  578. "",
  579. art.trip_img_link_fix AS trip_img_link,
  580. art.activity_time_end,
  581. "",
  582. "",
  583. "",
  584. "",
  585. "",
  586. 2 AS source_type,
  587. art.activity_time,
  588. art.days,
  589. art.city,
  590. "",
  591. "",
  592. "",
  593. "",
  594. "",
  595. art.host
  596. FROM
  597. cygx_activity_special AS art
  598. INNER JOIN cygx_activity_special_trip AS my ON my.activity_id = art.activity_id
  599. WHERE
  600. 1 = 1`
  601. if conditionSpecil != "" {
  602. sql += conditionSpecil
  603. }
  604. sql += ` ORDER BY activity_time DESC LIMIT ?,?`
  605. _, err = o.Raw(sql, pars, parsSpecil, startSize, pageSize).QueryRows(&items)
  606. return
  607. }
  608. // 列表
  609. func GetActivityListByCondition(condition string, pars []interface{}) (items []*CygxActivity, err error) {
  610. o := orm.NewOrm()
  611. sql := `SELECT * FROM cygx_activity WHERE 1 =1 `
  612. if condition != "" {
  613. sql += condition
  614. }
  615. _, err = o.Raw(sql, pars).QueryRows(&items)
  616. return
  617. }