activity.go 37 KB

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