activity.go 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299
  1. package models
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hongze_cygx/utils"
  7. "strings"
  8. "time"
  9. )
  10. // 活动详情
  11. type CygxActivity struct {
  12. ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
  13. ActivityTypeId int `description:"活动类型id"`
  14. ActivityTypeName string `description:"活动类型名称"`
  15. ChartPermissionId int `description:"行业id"`
  16. ChartPermissionName string `description:"行业名称"`
  17. ChartPermissionNames string `description:"行业名称辅助字段,区分研选子分类"`
  18. Body string `description:"内容"`
  19. CreateTime 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. YidongActivityUrl string `description:"易董活动跳转地址"`
  61. YidongActivityEndTime string `description:"易董活动截止时间"`
  62. ActivityJoinType string `description:"活动入会类型01报名审核后可入会 02预约即可入会 03仅定向邀请人员可入会"`
  63. YidongSignUpEnd string `description:"易董活动截止时间"` // 报名结束时间,适应于报名审核后可入会,为空表示不限制报名时间
  64. YidongSignUpStart string `description:"易董活动截止时间"` // 报名开始时间,适应于报名审核后可入会,为空表示不限制报名时间
  65. IsExternalLabel int `description:"是否为外部资源 1是,0否"`
  66. YidongActivityIdByCygx string `description:"通过查研观向建会易董返回的活动ID"`
  67. JmcjRoadshowTitle string `description:"进门财经的活动标题"`
  68. JmcjActivityId string `description:"进门财经的活动ID"`
  69. }
  70. type ActivityCheck struct {
  71. CheckPermission bool `description:"权限是否通过校验"`
  72. HasPermission int `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请"`
  73. PopupMsg string `description:"权限弹窗信息"`
  74. CancelPopupMsg string `description:"取消报名时间弹窗信息"`
  75. SellerMobile string `description:"销售电话"`
  76. SellerName string `description:"销售姓名"`
  77. Mobile string `description:"手机号"`
  78. IsResearch bool `description:"是否属于研选"`
  79. IsResearchSpecial bool `description:"是否属于特殊的研选"`
  80. CheckTime bool `description:"时间是否通过校验"`
  81. CheckEmail bool `description:"邮箱是否通过校验"`
  82. CheckPoints bool `description:"扣点是否通过校验"`
  83. CompanyPoints string `description:"公司剩余点数"`
  84. ActivityPoints string `description:"本场活动要扣除的点数"`
  85. }
  86. type Activity struct {
  87. ActivityTypeId int `description:"活动类型id"`
  88. ActivityTypeName string `description:"活动名称"`
  89. TemplateP string `description:"活动模板,带P标签"`
  90. Template string `description:"活动模板"`
  91. ShowType string `description:"人数限制类型,1不展示限制,2可选限制,3强制限制"`
  92. }
  93. type ActivityIdRep struct {
  94. ActivityId int `description:"活动id"`
  95. PlaySeconds int `description:"播放时长"`
  96. }
  97. type ActivitySingnupRep struct {
  98. ActivityId int `description:"活动id"`
  99. SignupType int `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
  100. }
  101. type ActivityCcustomerType struct {
  102. CustomerTypeId int `description:"活动类型id"`
  103. CustomerName string `description:"活动名称"`
  104. PermissionValue string `description:"用户权限对应的值"`
  105. }
  106. type ActivityCcustomerTypeList struct {
  107. List []*ActivityCcustomerType
  108. }
  109. // 列表
  110. func GetActivityCcustomerTypeList() (items []*ActivityCcustomerType, err error) {
  111. o := orm.NewOrm()
  112. sql := `SELECT * FROM cygx_customer_type ORDER BY sort DESC`
  113. _, err = o.Raw(sql).QueryRows(&items)
  114. return
  115. }
  116. // 活动添加、修改入参
  117. type ActivityRep struct {
  118. ActivityTypeId int `description:"活动类型id"`
  119. ChartPermissionId int `description:"行业id"`
  120. Body string `description:"内容"`
  121. LimitPeopleNum int `description:"限制的人数数量"`
  122. CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
  123. ActivityId int `description:"活动ID 等于0新增活动,大于0修改活动"`
  124. DoType int `description:"操作类型 0,保存 、1,发布"`
  125. }
  126. type ActivityArticleResp struct {
  127. ReportLink string `description:"报告链接"`
  128. ArticleId int `description:"报告id(报告链接跳转使用)"`
  129. Title string `description:"报告id(报告链接跳转使用)"`
  130. }
  131. // 活动详情
  132. type ActivityDetail struct {
  133. ActivityId int `orm:"column(activity_id);pk";description:"活动ID "`
  134. ActivityTypeId int `description:"活动类型id"`
  135. PublishStatus int `description:"发布状态,0未发布,1已发布"`
  136. ActivityTypeName string `description:"活动类型名称"`
  137. ChartPermissionId int `description:"行业id"`
  138. ChartPermissionName string `description:"行业名称"`
  139. ChartPermissionNames string `description:"行业名称辅助字段,区分研选子分类"`
  140. Body string `description:"内容"`
  141. CreateTime string `description:"创建时间"`
  142. IsLimitPeople int `description:"是否限制人数 1是,0否"`
  143. LimitPeopleNum int `description:"限制的人数数量"`
  144. LastUpdatedTime string `description:"更新时间"`
  145. ActivityTime string `description:"活动时间"`
  146. ActivityTimeText string `description:"活动时间带文字"`
  147. DistinguishedGuest string `description:"嘉宾"`
  148. Host string `description:"主持人"`
  149. Speaker string `description:"主讲人"`
  150. MainlandTell string `description:"大陆拨入号"`
  151. HongKongTell string `description:"香港拨入号"`
  152. TaiwanTell string `description:"台湾拨入号"`
  153. AmericaTell string `description:"美国拨入号"`
  154. ParticipationCode string `description:"参会密码"`
  155. Theme string `description:"主题"`
  156. Expert string `description:"专家"`
  157. ActivityName string `description:"活动名称"`
  158. OnlineParticipation string `description:"网络参会"`
  159. ReportLink string `description:"报告链接"`
  160. City string `description:"城市"`
  161. Address string `description:"活动地址"`
  162. Highlights string `description:"活动亮点"`
  163. Remarks string `description:"备注"`
  164. ShowType string `description:"人数限制类型,1不展示限制,2可选限制,3强制限制"`
  165. IsSignup int `description:"是否已报名 1是 ,0 否"`
  166. IsAppointment int `description:"是否已预约纪要 1是 ,0 否"`
  167. SignupNum int `description:"已报名人数"`
  168. SignupType int `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
  169. ActiveState string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
  170. IsCancelMeetingReminder int `description:"是否取消会议提醒 1展示取消会议提醒 ,0展示会议提醒"`
  171. ArticleId int `description:"报告id(报告链接跳转使用)"`
  172. CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
  173. IsShowSustainable bool `description:"是否展示限免标签"`
  174. Description string `description:"研选内容说明"`
  175. IsResearch bool `description:"是否属于研选"`
  176. LinkParticipants string `description:"链接参会"`
  177. AppAttendance string `description:"App参会"`
  178. ConferencePassword string `description:"会议密码"`
  179. Scale string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
  180. IsShowAppointment bool `description:"是否展示预约纪要"`
  181. IsHideAppointment int `description:"是否隐藏预约纪要按钮 1是,0 否"`
  182. IsCClassMeeting bool `description:"是否是c类电话会"`
  183. ArticleList []*ActivityArticleResp // 下面是列表添加的部分结构体
  184. IsBrackets int `description:"是否有方括号 1是 ,0 否"`
  185. Label string `description:"主题标签"`
  186. ImgUrl string `description:"图片链接"`
  187. ImgUrlText string `description:"图片链接文字"`
  188. ActivityType int `description:"活动线上线下类型 1线上,0 线下"`
  189. JmcjRoadshowTitle string `description:"进门财经手动匹配的活动名称"`
  190. Listndustrial []*IndustrialManagementRep `description:"活动关联的产业信息"`
  191. IsShowOutboundCall bool `description:"是否展示预约外呼"`
  192. IsShowMeetingReminder bool `description:"是否展示会议提醒"`
  193. IsShowHelpSsk bool `description:"是否展示帮我带问"`
  194. IsShowSignup bool `description:"是否展示我要报名"`
  195. IsShowDetails bool `description:"是否展示查看详情按钮"`
  196. TemporaryLabel string `description:"临时标签"`
  197. IsCanAppointmentMinutes int `description:"是否可预约纪要 1是 ,0 否 默认0 "`
  198. YidongActivityId string `description:"易董活动ID"`
  199. YidongActivityUrl string `description:"易董活动跳转地址"`
  200. AudioLink bool `description:"是否展示回放按钮"`
  201. VoiceList *CygxActivityVoiceReq `description:"音频数据"`
  202. AdminId int `description:"管理员、销售ID "`
  203. IsMakerShow int `description:"是否仅决策人可见 0,否 、1,是"`
  204. VisibleRange int `description:"可见范围 1,仅本组可见 、2,全部客户可见"`
  205. VideoDetail *CygxActivityVideoListResp `description:"视频数据"`
  206. FileType int `description:"类型: 1-音频; 2-视频"`
  207. SourceType int `description:"活动来源。 1:活动 、2:专项产业调研"`
  208. TripImgLink string `description:"专项产业调研行程链接"`
  209. ActivityTimeEnd string `description:"专项产业调研活动预期结束时间"`
  210. IsCollect bool `description:"是否收藏"`
  211. IsShowFollowButton bool `description:"是否展示关注取关按钮"`
  212. IsFollowButton bool `description:"是否关注"`
  213. IsYidongConduct bool `description:"是否属于易董办会 1:是 、0:否"`
  214. IsCanOutboundCall int `description:"是否提供外呼 1:是 、0:否"`
  215. TencentConferenceNumber string `description:"腾讯会议号"`
  216. YidongActivityIdByCygx string `description:"通过查研观向建会易董返回的活动ID"`
  217. IsShowSigninButton bool `description:"是否展示签到码按钮"`
  218. IsShowSignUpDetail bool `description:"是否展示报名详情按钮"`
  219. SigninImg string `description:"签到码图片"`
  220. IsNeedEmail int `description:"是否需要提供邮箱 1是,0否"`
  221. SiginupDeadline string `description:"报名截止时间"`
  222. IsExternalLabel bool `description:"是否为外部资源"`
  223. IsResearchPoints bool `description:"是否为研选扣点"`
  224. CancelDeadline string `description:"取消报名截止时间"`
  225. ImgUrlBgYx string `description:"研选背景图片"`
  226. }
  227. type ListArticleActivity struct {
  228. Title string `description:"文章标题"`
  229. ArtleId int `description:"产业id"`
  230. }
  231. type CygxActivityResp struct {
  232. HaqveJurisdiction bool `description:"是否有权限"`
  233. OperationMode string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`
  234. HasPermission int `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请,5:有IFCC、无权益"`
  235. PopupMsg string `description:"权限弹窗信息"`
  236. MsgType string `description:"Type : 类型 , Industry : 行业"`
  237. SellerMobile string `description:"销售电话"`
  238. SellerName string `description:"销售姓名"`
  239. IsResearch bool `description:"是否属于研选"`
  240. IsResearchSpecial bool `description:"是否属于特殊的研选"`
  241. Detail *ActivityDetail
  242. }
  243. // 通过纪要ID获取活动详情
  244. func GetAddActivityInfoById(ActivityId int) (item *ActivityDetail, err error) {
  245. o := orm.NewOrm()
  246. sql := `SELECT * FROM cygx_activity WHERE activity_id=? AND publish_status = 1 `
  247. err = o.Raw(sql, ActivityId).QueryRow(&item)
  248. return
  249. }
  250. // 通过纪要ID获取活动详情
  251. func GetAddActivityInfoByActivityId(ActivityId int) (item *ActivityDetail, err error) {
  252. o := orm.NewOrm()
  253. sql := `SELECT * FROM cygx_activity WHERE activity_id=? `
  254. err = o.Raw(sql, ActivityId).QueryRow(&item)
  255. return
  256. }
  257. // 通过活动名称获取活动详情
  258. func GetAddActivityInfoByTitle(title, startDate, endDate string) (item *ActivityDetail, err error) {
  259. o := orm.NewOrm()
  260. sql := `SELECT * FROM cygx_activity WHERE activity_time > '` + startDate + `' AND activity_time < '` + endDate + `' AND (activity_name_task LIKE '%` + title + `%' OR jmcj_roadshow_title LIKE '%` + title + `%') AND activity_id NOT IN (1328) LIMIT 1 `
  261. err = o.Raw(sql).QueryRow(&item)
  262. return
  263. }
  264. // 通过纪要ID获取活动详情
  265. func GetAddActivityInfoByIdShow(uid, ActivityId int) (item *ActivityDetail, err error) {
  266. o := orm.NewOrm()
  267. 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,
  268. ( 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,
  269. ( 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,
  270. ( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = a.activity_id AND ap.user_id = ? ) AS is_appointment
  271. FROM cygx_activity AS a WHERE activity_id=? AND publish_status = 1 `
  272. err = o.Raw(sql, uid, uid, uid, ActivityId).QueryRow(&item)
  273. return
  274. }
  275. // 活动列表
  276. type CygxActivityList struct {
  277. ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
  278. ActivityTypeId int `description:"活动类型id"`
  279. ActivityName string `description:"活动名称"`
  280. ActivityTypeName string `description:"活动类型名称"`
  281. Speaker string `description:"主讲人"`
  282. SignupType int `description:"报名方式,1预约外呼,2我要报名"`
  283. ChartPermissionId int `description:"行业id"`
  284. ChartPermissionName string `description:"行业名称"`
  285. IsLimitPeople int `description:"是否限制人数 1是,0否"`
  286. LimitPeopleNum int `description:"限制的人数数量"`
  287. ActivityTime string `description:"活动时间"`
  288. ActivityTimeText string `description:"活动时间带文字"`
  289. City string `description:"城市"`
  290. Address string `description:"活动地址"`
  291. DistinguishedGuest string `description:"嘉宾"`
  292. Expert string `description:"专家"`
  293. IsSignup int `description:"是否已报名 1是 ,0 否"`
  294. IsAppointment int `description:"是否已预约纪要 1是 ,0 否"`
  295. IsShowAppointment bool `description:"是否展示预约纪要"`
  296. SignupNum int `description:"已报名人数"`
  297. ActiveState string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
  298. IsCancelMeetingReminder int `description:"是否取消会议提醒 1展示取消会议提醒 ,0展示会议提醒"`
  299. IsBrackets int `description:"是否有方括号 1是 ,0 否"`
  300. Label string `description:"主题标签"`
  301. IsShowSustainable bool `description:"是否展示限免标签"`
  302. ImgUrl string `description:"图片链接"`
  303. ImgUrlText string `description:"图片链接文字"`
  304. ActivityType int `description:"活动线上线下类型 1线上,0 线下"`
  305. IsHideAppointment int `description:"是否隐藏预约纪要按钮 1是,0 否"`
  306. JmcjRoadshowTitle string `description:"进门财经手动匹配的活动名称"`
  307. IsCClassMeeting bool `description:"是否是c类电话会"`
  308. }
  309. type GetCygxActivityListRep struct {
  310. Paging *paging.PagingItem `description:"分页数据"`
  311. List []*ActivityDetail
  312. Label string `description:"主题"`
  313. ImgUrl string `description:"图片路径"`
  314. IsResearch bool `description:"是否属于研选"`
  315. IsJump bool `description:"是否跳转"`
  316. IndustrialManagementId int `description:"产业ID"`
  317. IndustryNewLabel bool `description:"产业是否新标签"`
  318. IsShowResearchPoints bool `description:"是否展示研选扣点搜索"`
  319. }
  320. // 列表
  321. func GetActivityListAll(condition string, pars []interface{}, uid, startSize, pageSize, playBack int) (items []*ActivityDetail, err error) {
  322. var sqlJiontable string
  323. if playBack == 1 {
  324. //sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  325. }
  326. o := orm.NewOrm()
  327. sql := `SELECT art.* ,t.activity_type,t.img_url_text,c.image_url as img_url,
  328. ( 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,
  329. ( 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,
  330. ( 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,
  331. ( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment
  332. FROM cygx_activity as art
  333. INNER JOIN cygx_activity_type as t ON t.activity_type_id = art.activity_type_id
  334. INNER JOIN chart_permission AS c ON c.chart_permission_id = art.chart_permission_id ` + sqlJiontable + ` WHERE 1= 1 `
  335. if condition != "" {
  336. sql += condition
  337. }
  338. sql += ` LIMIT ?,?`
  339. _, err = o.Raw(sql, pars, uid, uid, uid, startSize, pageSize).QueryRows(&items)
  340. return
  341. }
  342. // 列表
  343. func GetActivityListByDateTime(startDate, endDate, activityIds, activityIdsLongTime string) (items []*CygxActivityList, err error) {
  344. o := orm.NewOrm()
  345. sql := `SELECT * FROM cygx_activity WHERE activity_time > '` + startDate + `' AND activity_time < '` + endDate + `' `
  346. activityIds = strings.TrimRight(activityIds, ",")
  347. if activityIds != "" {
  348. sql += ` AND activity_id NOT IN (` + activityIds + `,1328 ) `
  349. }
  350. sql += ` OR activity_id IN (` + activityIdsLongTime + `)`
  351. _, err = o.Raw(sql).QueryRows(&items)
  352. return
  353. }
  354. // 获取我的日程数量
  355. func GetSpecialScheduleCount(uid int) (count int, err error) {
  356. o := orm.NewOrm()
  357. sqlCount := `
  358. SELECT COUNT( 1 ) AS count FROM
  359. cygx_activity_special AS art
  360. INNER JOIN cygx_activity_special_trip AS my ON my.activity_id = art.activity_id
  361. WHERE
  362. 1 = 1 AND my.user_id = ? AND my.is_cancel = 0`
  363. err = o.Raw(sqlCount, uid).QueryRow(&count)
  364. return
  365. }
  366. // 获取数量
  367. func GetActivityCount(condition string, playBack int, pars []interface{}, filter int) (count int, err error) {
  368. var sqlJiontable string
  369. if playBack == 1 {
  370. //sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  371. }
  372. if filter == 1 {
  373. sqlJiontable = ` INNER JOIN cygx_activity_video AS av ON av.activity_id = art.activity_id `
  374. } else if filter == 2 {
  375. sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  376. }
  377. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_activity as art ` + sqlJiontable + ` WHERE 1= 1 `
  378. if condition != "" {
  379. sqlCount += condition
  380. }
  381. o := orm.NewOrm()
  382. err = o.Raw(sqlCount, pars).QueryRow(&count)
  383. return
  384. }
  385. // 获取我的日程数量
  386. func GetScheduleCount(condition string, uid int) (count int, err error) {
  387. o := orm.NewOrm()
  388. sqlCount := `SELECT COUNT( 1 ) AS count
  389. FROM cygx_my_schedule AS m
  390. INNER JOIN cygx_activity AS art ON art.activity_id = m.activity_id
  391. WHERE
  392. user_id = ?`
  393. if condition != "" {
  394. sqlCount += condition
  395. }
  396. err = o.Raw(sqlCount, uid).QueryRow(&count)
  397. return
  398. }
  399. // 我的日程列表
  400. func GetScheduleList(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*ActivityDetail, err error) {
  401. o := orm.NewOrm()
  402. sql := `SELECT art.*,t.activity_type,t.img_url_text,c.image_url as img_url,
  403. ( 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,
  404. ( 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 ,
  405. ( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment,
  406. ( 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
  407. FROM cygx_activity AS art
  408. INNER JOIN cygx_my_schedule as my ON my.activity_id = art.activity_id
  409. INNER JOIN cygx_activity_type as t ON t.activity_type_id = art.activity_type_id
  410. INNER JOIN chart_permission AS c ON c.chart_permission_id = art.chart_permission_id
  411. WHERE 1=1 AND my.user_id = ? `
  412. if condition != "" {
  413. sql += condition
  414. }
  415. sql += ` ORDER BY art.active_state ASC,art.activity_time ASC LIMIT ?,?`
  416. _, err = o.Raw(sql, pars, uid, uid, uid, uid, startSize, pageSize).QueryRows(&items)
  417. return
  418. }
  419. // 我的日程列表 活动以及专项调研一起
  420. func GetScheduleAndSpecilList(condition string, pars []interface{}, conditionSpecil string, parsSpecil []interface{}, startSize, pageSize int) (items []*ActivityDetail, err error) {
  421. o := orm.NewOrm()
  422. sql := `SELECT
  423. art.activity_id,
  424. art.activity_time_text,
  425. art.activity_name,
  426. art.chart_permission_id,
  427. art.active_state,
  428. t.activity_type,
  429. art.chart_permission_name,
  430. art.distinguished_guest,
  431. art.expert,
  432. art.speaker,
  433. "" AS trip_img_link,
  434. "" AS activity_time_end,
  435. art.yidong_activity_id,
  436. art.is_can_appointment_minutes,
  437. art.activity_type_id,
  438. art.limit_people_num,
  439. art.is_limit_people,
  440. 1 AS source_type,
  441. art.activity_time,
  442. art.city,
  443. art.is_external_label,
  444. art.siginup_deadline,
  445. art.is_research_points,
  446. art.cancel_deadline
  447. FROM
  448. cygx_activity AS art
  449. INNER JOIN cygx_my_schedule AS my ON my.activity_id = art.activity_id
  450. INNER JOIN cygx_activity_type AS t ON t.activity_type_id = art.activity_type_id
  451. INNER JOIN chart_permission AS c ON c.chart_permission_id = art.chart_permission_id
  452. WHERE
  453. 1 = 1 `
  454. if condition != `` {
  455. sql += condition
  456. }
  457. sql += ` UNION ALL
  458. SELECT
  459. art.activity_id,
  460. art.activity_time_text_by_day AS activity_time_text,
  461. art.research_theme AS activity_name,
  462. art.chart_permission_id,
  463. "",
  464. art.special_type AS activity_type,
  465. art.chart_permission_name,
  466. "",
  467. "",
  468. "",
  469. art.trip_img_link_fix AS trip_img_link,
  470. art.activity_time_end,
  471. "",
  472. "",
  473. "",
  474. "",
  475. "",
  476. 2 AS source_type,
  477. art.activity_time,
  478. "",
  479. "",
  480. "",
  481. "",
  482. ""
  483. FROM
  484. cygx_activity_special AS art
  485. INNER JOIN cygx_activity_special_trip AS my ON my.activity_id = art.activity_id
  486. WHERE
  487. 1 = 1`
  488. if conditionSpecil != "" {
  489. sql += conditionSpecil
  490. }
  491. sql += ` ORDER BY activity_time DESC LIMIT ?,?`
  492. _, err = o.Raw(sql, pars, parsSpecil, startSize, pageSize).QueryRows(&items)
  493. return
  494. }
  495. // 获取数量
  496. func GetActivityCountById(activityId int) (count int, err error) {
  497. o := orm.NewOrm()
  498. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity WHERE activity_id = ?`
  499. err = o.Raw(sqlCount, activityId).QueryRow(&count)
  500. return
  501. }
  502. // 删除数据
  503. func DeleteActivity(activityId int) (err error) {
  504. o := orm.NewOrm()
  505. sql := ` DELETE FROM cygx_activity WHERE activity_id = ?`
  506. _, err = o.Raw(sql, activityId).Exec()
  507. return
  508. }
  509. // 修改活动状态至进行中
  510. func UpdateActivitySattusToHaveInHand() (err error) {
  511. defer func() {
  512. if err != nil {
  513. fmt.Println(err)
  514. go utils.SendAlarmMsg("修改活动状态至进行中失败"+err.Error(), 2)
  515. go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "修改活动状态至进行中失败 ErrMsg:"+err.Error(), utils.EmailSendToUsers)
  516. }
  517. }()
  518. o := orm.NewOrm()
  519. resultTime_30 := time.Now().Add(-time.Minute * 60).Format("2006-01-02 15:04:05") // 线上活动也改成60分钟之后结束了 2023.5.8
  520. resultTime_60 := time.Now().Add(-time.Minute * 60).Format("2006-01-02 15:04:05")
  521. var sqlOr string
  522. var condition string
  523. condition += ` AND activity_time < NOW()`
  524. sqlOr = condition
  525. condition += ` AND (activity_type_id IN ( 1, 2, 3, 7 ) AND activity_time > ` + "'" + resultTime_30 + "'" + ")"
  526. condition += ` OR(activity_type_id IN ( 4, 5, 6 ) AND activity_time > ` + "'" + resultTime_60 + "'" + sqlOr + ")"
  527. msql := " UPDATE cygx_activity SET active_state = 2 WHERE 1 = 1 " + condition
  528. _, err = o.Raw(msql).Exec()
  529. return
  530. }
  531. // 修改活动状态至已结束
  532. func UpdateActivitySattusToComplete() (err error) {
  533. defer func() {
  534. if err != nil {
  535. fmt.Println(err)
  536. go utils.SendAlarmMsg("修改活动状态至已结束"+err.Error(), 2)
  537. go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "修改活动状态至已结束 ErrMsg:"+err.Error(), utils.EmailSendToUsers)
  538. }
  539. }()
  540. o := orm.NewOrm()
  541. resultTime_30 := time.Now().Add(-time.Minute * 60).Format("2006-01-02 15:04:05") // 线上活动也改成60分钟之后结束了 2023.5.8
  542. resultTime_60 := time.Now().Add(-time.Minute * 60).Format("2006-01-02 15:04:05")
  543. //var sqlOr string
  544. var condition string
  545. //condition += ` AND activity_time < NOW()`
  546. //sqlOr = condition
  547. condition += ` AND (activity_type_id IN ( 1, 2, 3, 7 ) AND activity_time < ` + "'" + resultTime_30 + "'" + ")"
  548. condition += ` OR(activity_type_id IN ( 4, 5, 6 ) AND activity_time < ` + "'" + resultTime_60 + "'" + ")"
  549. msql := " UPDATE cygx_activity SET active_state = 3 WHERE 1 = 1 " + condition
  550. _, err = o.Raw(msql).Exec()
  551. return
  552. }
  553. // 活动详情
  554. type WxMsgCygxActivityList struct {
  555. Id int `description:"报名ID"`
  556. UserId int `description:"用户ID"`
  557. ActivityId int `description:"活动ID 等于0新增活动,大于0修改活动"`
  558. ActivityTypeId int `description:"活动类型id"`
  559. ActivityName string `description:"活动名称"`
  560. ActivityTypeName string `description:"活动类型名称"`
  561. Speaker string `description:"主讲人"`
  562. SignupType int `description:"报名方式,1预约外呼,2我要报名"`
  563. ChartPermissionId int `description:"行业id"`
  564. ChartPermissionName string `description:"行业名称"`
  565. IsLimitPeople int `description:"是否限制人数 1是,0否"`
  566. LimitPeopleNum int `description:"限制的人数数量"`
  567. ActivityTime string `description:"活动时间"`
  568. ActivityTimeText string `description:"活动时间带文字"`
  569. City string `description:"城市"`
  570. Address string `description:"活动地址"`
  571. DistinguishedGuest string `description:"嘉宾"`
  572. Expert string `description:"专家"`
  573. IsSignup int `description:"是否已报名 1是 ,0 否"`
  574. SignupNum int `description:"已报名人数"`
  575. ActiveState string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
  576. IsCancelMeetingReminder int `description:"是否取消会议提醒 1展示取消会议提醒 ,0展示会议提醒"`
  577. IsBrackets int `description:"是否有方括号 1是 ,0 否"`
  578. OpenId string `description:"OenId"`
  579. FailType int `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
  580. }
  581. // 列表 3o分钟
  582. func GetActivitySendMsgListAll(endDate string) (items []*WxMsgCygxActivityList, err error) {
  583. o := orm.NewOrm()
  584. sql := `SELECT
  585. s.id,
  586. s.user_id,
  587. s.fail_type,
  588. cr.open_id,
  589. a.*
  590. FROM
  591. cygx_activity AS a
  592. INNER JOIN cygx_activity_signup AS s ON s.activity_id = a.activity_id
  593. INNER JOIN user_record AS c ON c.bind_account = s.mobile
  594. INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
  595. WHERE
  596. 1 = 1
  597. AND s.is_send_wx_msg = 0
  598. AND s.do_fail_type = 0
  599. AND a.publish_status = 1
  600. AND c.create_platform = 4
  601. AND a.activity_time <= ? AND a.activity_time >= NOW()
  602. AND s.is_cancel = 0
  603. AND( a.activity_type_id IN (4,5,6) OR (a.activity_type_id = 3 AND a.is_limit_people = 1 )) GROUP BY s.id`
  604. _, err = o.Raw(sql, endDate).QueryRows(&items)
  605. return
  606. }
  607. // 列表 15分钟提醒
  608. func GetActivitySendMsgListAllMeeting(endDate string) (items []*WxMsgCygxActivityList, err error) {
  609. o := orm.NewOrm()
  610. sql := `SELECT
  611. m.id,
  612. cr.open_id,
  613. a.*
  614. FROM
  615. cygx_activity AS a
  616. INNER JOIN cygx_activity_meeting_reminder AS m ON m.activity_id = a.activity_id
  617. INNER JOIN user_record AS c ON c.bind_account = m.mobile
  618. INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
  619. WHERE
  620. 1 = 1
  621. AND m.is_send_wx_msg = 0
  622. AND a.publish_status = 1
  623. AND a.activity_time <= ? AND a.activity_time >= NOW()
  624. AND m.is_cancel = 0
  625. AND c.create_platform = 4
  626. AND (
  627. a.activity_type_id IN ( 1, 2 )
  628. OR ( a.activity_type_id = 3 AND a.is_limit_people = 0 ))
  629. GROUP BY m.id`
  630. _, err = o.Raw(sql, endDate).QueryRows(&items)
  631. return
  632. }
  633. // 修改是否推送消息状态
  634. func UPdateSendedMsgStatus(signupIds string) (err error) {
  635. sql := ` UPDATE cygx_activity_signup SET is_send_wx_msg= 1 WHERE id IN(` + signupIds + `)`
  636. o := orm.NewOrm()
  637. _, err = o.Raw(sql).Exec()
  638. return
  639. }
  640. // 修改是否推送消息状态
  641. func UPdateSendedYiDongSignUp(activityId int) (err error) {
  642. sql := ` UPDATE cygx_activity SET is_yidong_sign_up= 1 WHERE activity_id = ? `
  643. o := orm.NewOrm()
  644. _, err = o.Raw(sql, activityId).Exec()
  645. return
  646. }
  647. // 修改是否推送消息状态
  648. func UPdateSendedMsgMeetingStatus(signupIds string) (err error) {
  649. sql := ` UPDATE cygx_activity_meeting_reminder SET is_send_wx_msg= 1 WHERE id IN(` + signupIds + `)`
  650. o := orm.NewOrm()
  651. _, err = o.Raw(sql).Exec()
  652. return
  653. }
  654. // 获取满足推送的活动ID数量
  655. func GetCountActivityIdToSendFile(endDate string) (count int, err error) {
  656. o := orm.NewOrm()
  657. sql := `SELECT
  658. COUNT(1) count
  659. FROM
  660. cygx_activity AS a
  661. INNER JOIN cygx_activity_signup AS s ON s.activity_id = a.activity_id
  662. WHERE
  663. 1 = 1
  664. AND s.signup_type = 1
  665. AND s.fail_type = 0
  666. AND a.is_send_file_toemail = 0
  667. AND a.activity_time <= ? AND a.activity_time >= NOW() GROUP BY a.activity_id `
  668. err = o.Raw(sql, endDate).QueryRow(&count)
  669. return
  670. }
  671. // 获取满足推送的活动ID
  672. func GetActivityIdToSendFile(endDate string) (items []*ActivityIdRep, err error) {
  673. o := orm.NewOrm()
  674. sql := `SELECT
  675. *
  676. FROM
  677. cygx_activity AS a
  678. INNER JOIN cygx_activity_signup AS s ON s.activity_id = a.activity_id
  679. INNER JOIN cygx_activity_type AS t ON a.activity_type_id = t.activity_type_id
  680. WHERE
  681. 1 = 1
  682. AND s.signup_type = 1
  683. AND a.yidong_activity_id = ''
  684. AND t.activity_type = 1
  685. AND s.fail_type = 0
  686. AND a.is_send_file_toemail = 0
  687. AND a.activity_time <= ? AND a.activity_time >= NOW() GROUP BY a.activity_id `
  688. _, err = o.Raw(sql, endDate).QueryRows(&items)
  689. return
  690. }
  691. type SignupExportRep struct {
  692. Mobile string `description:"手机号"`
  693. CompanyName string `description:"公司名称"`
  694. RealName string `description:"姓名"`
  695. CountryCode string `description:"区号"`
  696. OutboundMobile string `description:"外呼手机号"`
  697. SellerName string `description:"销售姓名"`
  698. }
  699. type ActivityMsgExportRep struct {
  700. AskId int `description:"活动带问ID"`
  701. UserId int `description:"用户ID"`
  702. RealName string `description:"姓名"`
  703. CompanyName string `description:"公司名称"`
  704. CompanyId int `description:"公司ID"`
  705. Content string `description:"内容"`
  706. CreateTime string `description:"提交时间"`
  707. }
  708. func GetSignupExport(activityId int) (item []*SignupExportRep, err error) {
  709. o := orm.NewOrm()
  710. sql := ` SELECT s.outbound_mobile,
  711. s.country_code,
  712. a.is_limit_people,
  713. u.real_name,
  714. ( SELECT p.seller_name FROM company_product AS p WHERE p.company_id = u.company_id AND p.product_id = 2 ) AS seller_name,
  715. ( SELECT c.company_name FROM company AS c WHERE c.company_id = u.company_id ) AS company_name
  716. FROM
  717. cygx_activity_signup AS s
  718. LEFT JOIN wx_user AS u ON u.user_id = s.user_id
  719. LEFT JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  720. LEFT JOIN company_product AS p ON p.company_id = u.company_id
  721. WHERE a.activity_id = ? AND s.do_fail_type = 0 AND s.signup_type = 1 GROUP BY s.id `
  722. _, err = o.Raw(sql, activityId).QueryRows(&item)
  723. return
  724. }
  725. // 修改文件是否推送状态
  726. func UPdateActivityIdToSendFile(activityId int) (err error) {
  727. sql := ` UPDATE cygx_activity SET is_send_file_toemail= 1 WHERE activity_id = ?`
  728. o := orm.NewOrm()
  729. _, err = o.Raw(sql, activityId).Exec()
  730. return
  731. }
  732. // 活动详情
  733. type CygxActivityLabelList struct {
  734. KeyWord string `orm:"column(label)";description:"主题"`
  735. Timesort string `description:"最大时间"`
  736. Mintimesort string `description:"最小时间"`
  737. ImgUrlBg string `description:"背景图片"`
  738. ActivityId int `description:"活动ID "`
  739. IsShowSubjectName int `description:"小程序内是否展示标的名称 1是 ,0否 默认0 "`
  740. Resource int `description:"位置 ,1:活动 ,2:专项产业调研"`
  741. TemporaryLabel string `description:"临时标签"`
  742. IsNew bool `description:"是否为新:活动存在关联的的产业所关联的报告均在3个月内/无报告则标记新"`
  743. YidongActivityId int `description:"易董活动ID"`
  744. IsExternalLabel bool `description:"是否为外部资源"`
  745. IsResearchPoints bool `description:"是否为研选扣点"`
  746. TripStatus int `description:"行程进行状态 1:预报名,2:确定行程"`
  747. City string `description:"城市"`
  748. Days int `description:"天数"`
  749. ActivityTypeId int `description:"活动类型id"`
  750. }
  751. // 主题列表
  752. func GetActivityLabelListAll(condition, sortTime string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityLabelList, err error) {
  753. o := orm.NewOrm()
  754. sql := `SELECT activity_id,activity_type_id, label,temporary_label,is_show_subject_name, MAX( art.activity_time ) AS timesort, MIn( art.activity_time ) AS mintimesort , yidong_activity_id,city,is_external_label,is_research_points
  755. FROM cygx_activity as art WHERE 1= 1 `
  756. if condition != "" {
  757. sql += condition
  758. }
  759. sql += ` GROUP BY art.activity_id ORDER BY ` + sortTime + ` ,art.activity_id DESC LIMIT ?,? `
  760. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  761. return
  762. }
  763. // 主题列表
  764. func GetActivityLabelListCity() (items []*CygxActivity, err error) {
  765. o := orm.NewOrm()
  766. sql := `SELECT
  767. activity_id,
  768. activity_type_id,
  769. activity_time,
  770. label,
  771. temporary_label,
  772. is_show_subject_name,
  773. yidong_activity_id,
  774. city
  775. FROM
  776. cygx_activity AS art
  777. WHERE
  778. 1 = 1
  779. AND art.active_state IN ( 1, 2 )
  780. AND city != ''
  781. ORDER BY
  782. activity_time ASC `
  783. _, err = o.Raw(sql).QueryRows(&items)
  784. return
  785. }
  786. type GetCygxActivityLabelListRep struct {
  787. Label string `description:"主题"`
  788. ImgUrl string `description:"图片路径"`
  789. List []*CygxActivityLabelList
  790. }
  791. // 获取研选系列专家电话会,会前1小时,满足推送的活动ID数量
  792. func GetCountActivityResearchToSendFile(condition, endDate string) (count int, err error) {
  793. o := orm.NewOrm()
  794. sql := `SELECT
  795. COUNT(1) count
  796. FROM
  797. cygx_activity AS a
  798. INNER JOIN cygx_activity_help_ask AS k ON k.activity_id = a.activity_id
  799. WHERE
  800. 1 = 1 ` + condition + `
  801. AND a.is_send_ask_msg = 0
  802. AND a.activity_time <= ?
  803. AND a.activity_time >= NOW()`
  804. err = o.Raw(sql, endDate).QueryRow(&count)
  805. return
  806. }
  807. // 获取研选系列专家电话会,会前1小时,满足推送的活动ID
  808. func GetActivityResearchToSendFile(condition, endDate string) (items []*ActivityIdRep, err error) {
  809. o := orm.NewOrm()
  810. sql := `SELECT
  811. *
  812. FROM
  813. cygx_activity AS a
  814. INNER JOIN cygx_activity_help_ask AS k ON k.activity_id = a.activity_id
  815. WHERE
  816. 1 = 1 ` + condition + `
  817. AND a.is_send_ask_msg = 0
  818. AND a.activity_time <= ?
  819. AND a.activity_time >= NOW()
  820. GROUP BY
  821. a.activity_id `
  822. _, err = o.Raw(sql, endDate).QueryRows(&items)
  823. return
  824. }
  825. func GetActivityMsgExport(activityId int) (item []*ActivityMsgExportRep, err error) {
  826. o := orm.NewOrm()
  827. sql := `SELECT
  828. k.*,
  829. u.real_name
  830. FROM
  831. cygx_activity_help_ask AS k
  832. LEFT JOIN wx_user AS u ON u.user_id = k.user_id
  833. WHERE
  834. k.activity_id = ?
  835. GROUP BY
  836. k.ask_id`
  837. _, err = o.Raw(sql, activityId).QueryRows(&item)
  838. return
  839. }
  840. // 修改文件带问消息是否推送状态
  841. func UPdateActivityMsgToSendFile(activityId int) (err error) {
  842. sql := ` UPDATE cygx_activity SET is_send_ask_msg= 1 WHERE activity_id = ?`
  843. o := orm.NewOrm()
  844. _, err = o.Raw(sql, activityId).Exec()
  845. return
  846. }
  847. type AskEmailRep struct {
  848. Name string `description:"姓名"`
  849. Email string `description:"邮箱"`
  850. Mobile string `description:"手机号"`
  851. }
  852. func GetAskEmail() (item []*AskEmailRep, err error) {
  853. o := orm.NewOrm()
  854. sql := `SELECT * FROM cygx_activity_ask_email`
  855. _, err = o.Raw(sql).QueryRows(&item)
  856. return
  857. }
  858. // 主题列表
  859. func GetActivityLabelSpecialListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityLabelList, err error) {
  860. o := orm.NewOrm()
  861. sql := `SELECT label,activity_id,is_show_subject_name,days
  862. FROM cygx_activity_special as art WHERE 1= 1 `
  863. if condition != "" {
  864. sql += condition
  865. }
  866. sql += ` LIMIT ?,? `
  867. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  868. return
  869. }
  870. type GetCygxActivitySpecialDetailListResp struct {
  871. IsFollow bool `description:"是否关注新调研通知"`
  872. IsBindingMobile bool `description:"是否绑定了手机号"`
  873. Paging *paging.PagingItem `description:"分页数据"`
  874. List []*CygxActivitySpecialDetail
  875. }
  876. type CygxActivitySpecialResp struct {
  877. HaqveJurisdiction bool `description:"是否有权限"`
  878. OperationMode string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`
  879. HasPermission int `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请,5:有IFCC、无权益"`
  880. PopupMsg string `description:"权限弹窗信息"`
  881. MsgType string `description:"Type : 类型 , Industry : 行业"`
  882. SellerMobile string `description:"销售电话"`
  883. SellerName string `description:"销售姓名"`
  884. IsFollow bool `description:"是否关注新调研通知"`
  885. Detail *CygxActivitySpecialDetail
  886. }
  887. // 获取专项调研活动列表
  888. func GetCygxActivitySpecialDetailList(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*CygxActivitySpecialDetail, err error) {
  889. o := orm.NewOrm()
  890. sql := ` SELECT
  891. art.*,
  892. c.image_url AS img_url,
  893. (
  894. SELECT
  895. COUNT( 1 )
  896. FROM
  897. cygx_activity_special_signup AS s
  898. WHERE
  899. s.activity_id = art.activity_id
  900. AND s.user_id = ?
  901. ) AS is_signup
  902. FROM
  903. cygx_activity_special AS art
  904. INNER JOIN chart_permission AS c ON c.chart_permission_id = art.chart_permission_id
  905. WHERE
  906. 1 = 1 `
  907. if condition != "" {
  908. sql += condition
  909. }
  910. sql += ` LIMIT ?,? `
  911. _, err = o.Raw(sql, uid, pars, startSize, pageSize).QueryRows(&items)
  912. return
  913. }
  914. // 通过活动ID获取活动详情
  915. func GetCygxActivitySpecialDetailById(uid, ActivityId int) (item *CygxActivitySpecialDetail, err error) {
  916. o := orm.NewOrm()
  917. sql := `SELECT *,( SELECT COUNT( 1 ) FROM cygx_activity_special_signup AS s WHERE s.activity_id = a.activity_id AND s.user_id = ? ) AS is_signup
  918. FROM
  919. cygx_activity_special AS a
  920. WHERE
  921. activity_id = ?
  922. AND publish_status = 1 AND is_offline = 0 `
  923. err = o.Raw(sql, uid, ActivityId).QueryRow(&item)
  924. return
  925. }
  926. // 通过活动ID获取活动详情
  927. func GetCygxActivitySpecialDetail(ActivityId int) (item *CygxActivitySpecialDetail, err error) {
  928. o := orm.NewOrm()
  929. sql := `SELECT * FROM cygx_activity_special WHERE activity_id=? AND publish_status = 1 `
  930. err = o.Raw(sql, ActivityId).QueryRow(&item)
  931. return
  932. }
  933. func UpdateCygxActivityName(activityId int, Name string) (err error) {
  934. o := orm.NewOrm()
  935. sql := `UPDATE cygx_activity SET activity_name_task = ? WHERE activity_id=? `
  936. _, err = o.Raw(sql, Name, activityId).Exec()
  937. return
  938. }
  939. // 获取已发布但是为开始活动的权限
  940. func GetActivityWeekPermission() (permission string, err error) {
  941. o := orm.NewOrm()
  942. sql := ` SELECT
  943. GROUP_CONCAT( DISTINCT chart_permission_name SEPARATOR ',' ) AS permission
  944. FROM
  945. cygx_activity
  946. WHERE
  947. active_state = 1`
  948. err = o.Raw(sql).QueryRow(&permission)
  949. return
  950. }
  951. // 列表
  952. func GetIndustrialActivityGroupManagementList(activityId int) (items []*IndustrialManagementRep, err error) {
  953. o := orm.NewOrm()
  954. sql := `SELECT
  955. p.permission_name,
  956. p.chart_permission_id,
  957. m.industrial_management_id,
  958. m.industry_name
  959. FROM
  960. cygx_industrial_activity_group_management AS am
  961. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = am.industrial_management_id
  962. INNER JOIN chart_permission AS p ON p.chart_permission_id = m.chart_permission_id
  963. WHERE
  964. am.activity_id = ? AND am.source = 1`
  965. _, err = o.Raw(sql, activityId).QueryRows(&items)
  966. return
  967. }
  968. // GetActivityListByYiDong 获取易董同步过来的活动列表
  969. func GetActivityListByYiDong() (items []*CygxActivity, err error) {
  970. o := orm.NewOrm()
  971. sql := ` SELECT * FROM cygx_activity WHERE yidong_activity_id != '' `
  972. _, err = o.Raw(sql).QueryRows(&items)
  973. return
  974. }
  975. // GetActivityListByYiDong 获取易董同步过来的活动列表
  976. func GetActivityListByYiDongByCygx() (items []*CygxActivity, err error) {
  977. o := orm.NewOrm()
  978. sql := ` SELECT * FROM cygx_activity WHERE yidong_activity_id_by_cygx != '' `
  979. _, err = o.Raw(sql).QueryRows(&items)
  980. return
  981. }
  982. // AddCygxActivity 添加活动
  983. func AddCygxActivity(item *CygxActivity) (lastId int64, err error) {
  984. o := orm.NewOrm()
  985. lastId, err = o.Insert(item)
  986. return
  987. }
  988. // 列表
  989. func GetActivityListByYidong(condition string) (items []*ActivityDetail, err error) {
  990. o := orm.NewOrm()
  991. sql := `SELECT * FROM cygx_activity WHERE 1 = 1
  992. AND ( yidong_activity_id != '' OR yidong_activity_id_by_cygx != '' ) AND publish_status = 1 `
  993. if condition != "" {
  994. sql += condition
  995. }
  996. _, err = o.Raw(sql).QueryRows(&items)
  997. return
  998. }
  999. // 列表
  1000. func GetActivityListByCondition(condition string, pars []interface{}) (items []*CygxActivity, err error) {
  1001. o := orm.NewOrm()
  1002. sql := `SELECT * FROM cygx_activity WHERE 1 =1 `
  1003. if condition != "" {
  1004. sql += condition
  1005. }
  1006. _, err = o.Raw(sql, pars).QueryRows(&items)
  1007. return
  1008. }
  1009. // UpdateCygxActivitySubmitMeetingByActivityId ,修改活动提交到会状态
  1010. func UpdateCygxActivitySubmitMeetingByActivityId(activityId int) (err error) {
  1011. o := orm.NewOrm()
  1012. sql := `UPDATE cygx_activity SET is_submit_meeting = 1 WHERE activity_id = ? `
  1013. _, err = o.Raw(sql, activityId).Exec()
  1014. return
  1015. }
  1016. // UpdateCygxActivitySubmitMeetingByYidong ,跟易董返回的用户状态修改活动以提交到会状态
  1017. func UpdateCygxActivitySubmitMeetingByYidong(yidongActivityId string) (err error) {
  1018. o := orm.NewOrm()
  1019. sql := `UPDATE cygx_activity SET is_submit_meeting = 1 WHERE yidong_activity_id=? OR yidong_activity_id_by_cygx = ? `
  1020. _, err = o.Raw(sql, yidongActivityId, yidongActivityId).Exec()
  1021. return
  1022. }
  1023. // UpdateActivityshowSubject 根据易董推过来的匹配信息,判断临时标签是否展示
  1024. func UpdateActivityshowSubject(activityId int) (err error) {
  1025. sql := ` UPDATE cygx_activity SET is_show_subject_name= 1 , temporary_label = '' WHERE activity_id = ?`
  1026. o := orm.NewOrm()
  1027. _, err = o.Raw(sql, activityId).Exec()
  1028. return
  1029. }
  1030. // GetActivitySpecialSearcheList 活动与专项调研的搜索
  1031. func GetActivitySpecialSearcheList(condition string, pars []interface{}, conditionSpecil string, parsSpecil []interface{}, startSize, pageSize int) (items []*ActivityDetail, total int, err error) {
  1032. o := orm.NewOrm()
  1033. sql := `SELECT
  1034. art.activity_id,
  1035. art.activity_time_text,
  1036. art.activity_name,
  1037. art.chart_permission_id,
  1038. art.active_state,
  1039. t.activity_type,
  1040. t.img_url_text,
  1041. art.chart_permission_name,
  1042. art.distinguished_guest,
  1043. art.expert,
  1044. art.speaker,
  1045. "" AS trip_img_link,
  1046. "" AS activity_time_end,
  1047. art.yidong_activity_id,
  1048. art.is_can_appointment_minutes,
  1049. art.activity_type_id,
  1050. art.limit_people_num,
  1051. art.is_limit_people,
  1052. art.city,
  1053. 1 AS source_type,
  1054. art.is_yidong_conduct,
  1055. art.activity_time,
  1056. art.is_external_label,
  1057. art.siginup_deadline,
  1058. art.is_research_points,
  1059. art.cancel_deadline
  1060. FROM
  1061. cygx_activity AS art
  1062. INNER JOIN cygx_activity_type AS t ON t.activity_type_id = art.activity_type_id
  1063. WHERE
  1064. 1 = 1 `
  1065. if condition != `` {
  1066. sql += condition
  1067. }
  1068. sql += ` UNION ALL
  1069. SELECT
  1070. art.activity_id,
  1071. art.activity_time_text_by_day AS activity_time_text,
  1072. art.research_theme AS activity_name,
  1073. art.chart_permission_id,
  1074. "",
  1075. art.special_type AS activity_type,
  1076. "",
  1077. art.chart_permission_name,
  1078. "",
  1079. "",
  1080. "",
  1081. art.trip_img_link_fix AS trip_img_link,
  1082. art.activity_time_end,
  1083. "",
  1084. "",
  1085. "",
  1086. "",
  1087. "",
  1088. "",
  1089. 2 AS source_type,
  1090. "",
  1091. art.activity_time,
  1092. "",
  1093. "",
  1094. "",
  1095. ""
  1096. FROM
  1097. cygx_activity_special AS art
  1098. WHERE
  1099. 1 = 1 `
  1100. if conditionSpecil != "" {
  1101. sql += conditionSpecil
  1102. }
  1103. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  1104. err = o.Raw(totalSql, pars, parsSpecil).QueryRow(&total)
  1105. if err != nil {
  1106. return
  1107. }
  1108. sql += ` ORDER BY activity_time DESC LIMIT ?,?`
  1109. _, err = o.Raw(sql, pars, parsSpecil, startSize, pageSize).QueryRows(&items)
  1110. return
  1111. }
  1112. // 列表
  1113. func GetActivityListNew(condition string, pars []interface{}, uid, startSize, pageSize, playBack, filter int, typeName string) (items []*ActivityDetail, err error) {
  1114. var sqlJiontable string
  1115. if playBack == 1 {
  1116. //sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  1117. }
  1118. if filter == 1 {
  1119. sqlJiontable = ` INNER JOIN cygx_activity_video AS av ON av.activity_id = art.activity_id `
  1120. } else if filter == 2 {
  1121. sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  1122. }
  1123. o := orm.NewOrm()
  1124. sql := `SELECT art.* ,t.activity_type,t.img_url_text,c.image_url as img_url,t.img_url_bg_yx,
  1125. ( 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,
  1126. ( 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,
  1127. ( 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,
  1128. ( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment
  1129. FROM cygx_activity as art
  1130. INNER JOIN cygx_activity_type as t ON t.activity_type_id = art.activity_type_id
  1131. INNER JOIN chart_permission AS c ON c.chart_permission_id = art.chart_permission_id ` + sqlJiontable + ` WHERE 1= 1 `
  1132. if condition != "" {
  1133. sql += condition
  1134. }
  1135. sql += ` LIMIT ?,?`
  1136. if typeName != "" {
  1137. typeSlice := strings.Split(typeName, ",")
  1138. tempCondition := ""
  1139. for _, s := range typeSlice {
  1140. if s == "1" {
  1141. tempCondition += "'专家电话会',"
  1142. } else if s == "2" {
  1143. tempCondition += "'分析师电话会',"
  1144. } else if s == "1,2" {
  1145. tempCondition += "'专家电话会','分析师电话会',"
  1146. }
  1147. }
  1148. tempCondition = strings.TrimRight(tempCondition, ",")
  1149. sql = `SELECT * FROM(` + sql + `) AS t WHERE t.activity_type_name IN (` + tempCondition + `)`
  1150. }
  1151. _, err = o.Raw(sql, uid, uid, uid, pars, startSize, pageSize).QueryRows(&items)
  1152. return
  1153. }
  1154. // 列表
  1155. func GetActivityListHomeNew(condition string, startSize, pageSize int) (items []*ActivityDetail, err error) {
  1156. o := orm.NewOrm()
  1157. sql := `SELECT activity_id
  1158. FROM cygx_activity as art
  1159. INNER JOIN cygx_activity_type as t ON t.activity_type_id = art.activity_type_id
  1160. INNER JOIN chart_permission AS c ON c.chart_permission_id = art.chart_permission_id WHERE 1= 1 `
  1161. if condition != "" {
  1162. sql += condition
  1163. }
  1164. sql += ` LIMIT ?,?`
  1165. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
  1166. return
  1167. }
  1168. // 主题列表
  1169. func GetActivityLabelListAllNoLimit(condition, sortTime string, pars []interface{}, conditionSpecial string) (items []*CygxActivityLabelList, err error) {
  1170. o := orm.NewOrm()
  1171. sql := `SELECT activity_id, label,temporary_label,is_show_subject_name, art.activity_time, 1 AS resource, yidong_activity_id
  1172. FROM cygx_activity as art WHERE 1= 1 `
  1173. if condition != "" {
  1174. sql += condition
  1175. }
  1176. sql += ` UNION ALL `
  1177. sql += ` SELECT
  1178. art.activity_id,
  1179. art.label,
  1180. art.temporary_label,
  1181. is_show_subject_name,
  1182. art.activity_time,
  1183. 2 AS resource,
  1184. '' AS yidong_activity_id
  1185. FROM
  1186. cygx_activity_special AS art WHERE 1= 1 ` + conditionSpecial
  1187. sql += ` GROUP BY label,resource ORDER BY ` + sortTime + ` , activity_id DESC `
  1188. _, err = o.Raw(sql, pars).QueryRows(&items)
  1189. return
  1190. }
  1191. // 列表
  1192. func GetCygxActivityList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivity, err error) {
  1193. o := orm.NewOrm()
  1194. sql := `SELECT * FROM cygx_activity as art WHERE 1= 1 `
  1195. if condition != "" {
  1196. sql += condition
  1197. }
  1198. sql += ` LIMIT ?,? `
  1199. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  1200. return
  1201. }
  1202. // 批量修改弘则活动与进门财经的一个活动关联
  1203. func UpdateJmcjActivityIdGroup(items map[int]string) (err error) {
  1204. o := orm.NewOrm()
  1205. p, err := o.Raw("UPDATE cygx_activity SET jmcj_activity_id = ? WHERE activity_id = ? AND jmcj_activity_id= '' ").Prepare()
  1206. if err != nil {
  1207. return
  1208. }
  1209. defer func() {
  1210. _ = p.Close() // 别忘记关闭 statement
  1211. }()
  1212. for k, v := range items {
  1213. _, err = p.Exec(v, k)
  1214. if err != nil {
  1215. return
  1216. }
  1217. }
  1218. return
  1219. }