activity.go 59 KB

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