activity.go 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424
  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. SourceType int `description:"活动来源。 1:活动 、2:专项产业调研"`
  215. TripImgLink string `description:"专项产业调研行程链接"`
  216. ActivityTimeEnd string `description:"专项产业调研活动预期结束时间"`
  217. IsCollect bool `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. CancelDeadline string `description:"取消报名截止时间"`
  232. ImgUrlBgYx 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 GetAddActivityDetailByActivityId(ActivityId int) (item *ActivityDetail, err error) {
  274. o := orm.NewOrm()
  275. sql := `SELECT a.*,t.activity_type, FROM cygx_activity AS a
  276. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id WHERE activity_id=? `
  277. err = o.Raw(sql, ActivityId).QueryRow(&item)
  278. return
  279. }
  280. // 通过活动名称获取活动详情
  281. func GetAddActivityInfoByTitle(title, startDate, endDate string) (item *ActivityDetail, err error) {
  282. o := orm.NewOrm()
  283. 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 `
  284. err = o.Raw(sql).QueryRow(&item)
  285. return
  286. }
  287. // 通过纪要ID获取活动详情
  288. func GetAddActivityInfoByIdShow(uid, ActivityId int) (item *ActivityDetail, err error) {
  289. o := orm.NewOrm()
  290. 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,
  291. ( 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,
  292. ( 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,
  293. ( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = a.activity_id AND ap.user_id = ? ) AS is_appointment
  294. FROM cygx_activity AS a
  295. INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
  296. WHERE a.activity_id=? AND a.publish_status = 1 `
  297. err = o.Raw(sql, uid, uid, uid, ActivityId).QueryRow(&item)
  298. return
  299. }
  300. // 活动列表
  301. type CygxActivityList struct {
  302. ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
  303. ActivityTypeId int `description:"活动类型id"`
  304. ActivityName string `description:"活动名称"`
  305. ActivityTypeName string `description:"活动类型名称"`
  306. Speaker string `description:"主讲人"`
  307. SignupType int `description:"报名方式,1预约外呼,2我要报名"`
  308. ChartPermissionId int `description:"行业id"`
  309. ChartPermissionName string `description:"行业名称"`
  310. IsLimitPeople int `description:"是否限制人数 1是,0否"`
  311. LimitPeopleNum int `description:"限制的人数数量"`
  312. ActivityTime string `description:"活动时间"`
  313. ActivityTimeText string `description:"活动时间带文字"`
  314. City string `description:"城市"`
  315. Address string `description:"活动地址"`
  316. DistinguishedGuest string `description:"嘉宾"`
  317. Expert string `description:"专家"`
  318. IsSignup int `description:"是否已报名 1是 ,0 否"`
  319. IsAppointment int `description:"是否已预约纪要 1是 ,0 否"`
  320. IsShowAppointment bool `description:"是否展示预约纪要"`
  321. SignupNum int `description:"已报名人数"`
  322. ActiveState string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
  323. IsCancelMeetingReminder int `description:"是否取消会议提醒 1展示取消会议提醒 ,0展示会议提醒"`
  324. IsBrackets int `description:"是否有方括号 1是 ,0 否"`
  325. Label string `description:"主题标签"`
  326. IsShowSustainable bool `description:"是否展示限免标签"`
  327. ImgUrl string `description:"图片链接"`
  328. ImgUrlText string `description:"图片链接文字"`
  329. ActivityType int `description:"活动线上线下类型 1线上,0 线下"`
  330. IsHideAppointment int `description:"是否隐藏预约纪要按钮 1是,0 否"`
  331. JmcjRoadshowTitle string `description:"进门财经手动匹配的活动名称"`
  332. IsCClassMeeting bool `description:"是否是c类电话会"`
  333. }
  334. type GetCygxActivityListRep struct {
  335. Paging *paging.PagingItem `description:"分页数据"`
  336. List []*ActivityDetail
  337. Label string `description:"主题"`
  338. ImgUrl string `description:"图片路径"`
  339. IsResearch bool `description:"是否属于研选"`
  340. IsJump bool `description:"是否跳转"`
  341. IndustrialManagementId int `description:"产业ID"`
  342. IndustryNewLabel bool `description:"产业是否新标签"`
  343. IsShowResearchPoints bool `description:"是否展示研选扣点搜索"`
  344. }
  345. // 列表
  346. func GetActivityListAll(condition string, pars []interface{}, uid, startSize, pageSize, playBack int) (items []*ActivityDetail, err error) {
  347. var sqlJiontable string
  348. if playBack == 1 {
  349. //sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  350. }
  351. o := orm.NewOrm()
  352. sql := `SELECT art.* ,t.activity_type,t.img_url_text,
  353. ( 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,
  354. ( 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,
  355. ( 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,
  356. ( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment
  357. FROM cygx_activity as art
  358. INNER JOIN cygx_activity_type as t ON t.activity_type_id = art.activity_type_id` + sqlJiontable + ` WHERE 1= 1 `
  359. if condition != "" {
  360. sql += condition
  361. }
  362. sql += ` LIMIT ?,?`
  363. _, err = o.Raw(sql, pars, uid, uid, uid, startSize, pageSize).QueryRows(&items)
  364. return
  365. }
  366. // 列表
  367. func GetActivityListByDateTime(startDate, endDate, activityIds, activityIdsLongTime string) (items []*CygxActivityList, err error) {
  368. o := orm.NewOrm()
  369. sql := `SELECT * FROM cygx_activity WHERE activity_time > '` + startDate + `' AND activity_time < '` + endDate + `' `
  370. activityIds = strings.TrimRight(activityIds, ",")
  371. if activityIds != "" {
  372. sql += ` AND activity_id NOT IN (` + activityIds + `,1328 ) `
  373. }
  374. sql += ` OR activity_id IN (` + activityIdsLongTime + `)`
  375. _, err = o.Raw(sql).QueryRows(&items)
  376. return
  377. }
  378. // 获取我的日程数量
  379. func GetSpecialScheduleCount(uid int) (count int, err error) {
  380. o := orm.NewOrm()
  381. sqlCount := `
  382. SELECT COUNT( 1 ) AS count FROM
  383. cygx_activity_special AS art
  384. INNER JOIN cygx_activity_special_trip AS my ON my.activity_id = art.activity_id
  385. WHERE
  386. 1 = 1 AND my.user_id = ? AND my.is_cancel = 0`
  387. err = o.Raw(sqlCount, uid).QueryRow(&count)
  388. return
  389. }
  390. // 获取数量
  391. func GetActivityCount(condition string, playBack int, pars []interface{}, filter int) (count int, err error) {
  392. var sqlJiontable string
  393. if playBack == 1 {
  394. //sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  395. }
  396. if filter == 1 {
  397. sqlJiontable = ` INNER JOIN cygx_activity_video AS av ON av.activity_id = art.activity_id `
  398. } else if filter == 2 {
  399. sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  400. }
  401. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_activity as art ` + sqlJiontable + ` WHERE 1= 1 `
  402. if condition != "" {
  403. sqlCount += condition
  404. }
  405. o := orm.NewOrm()
  406. err = o.Raw(sqlCount, pars).QueryRow(&count)
  407. return
  408. }
  409. // 获取我的日程数量
  410. func GetScheduleCount(condition string, uid int) (count int, err error) {
  411. o := orm.NewOrm()
  412. sqlCount := `SELECT COUNT( 1 ) AS count
  413. FROM cygx_my_schedule AS m
  414. INNER JOIN cygx_activity AS art ON art.activity_id = m.activity_id
  415. WHERE
  416. user_id = ?`
  417. if condition != "" {
  418. sqlCount += condition
  419. }
  420. err = o.Raw(sqlCount, uid).QueryRow(&count)
  421. return
  422. }
  423. // 我的日程列表
  424. func GetScheduleList(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*ActivityDetail, err error) {
  425. o := orm.NewOrm()
  426. sql := `SELECT art.*,t.activity_type,t.img_url_text,
  427. ( 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,
  428. ( 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 ,
  429. ( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment,
  430. ( 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
  431. FROM cygx_activity AS art
  432. INNER JOIN cygx_my_schedule as my ON my.activity_id = art.activity_id
  433. INNER JOIN cygx_activity_type as t ON t.activity_type_id = art.activity_type_id
  434. WHERE 1=1 AND my.user_id = ? `
  435. if condition != "" {
  436. sql += condition
  437. }
  438. sql += ` ORDER BY art.active_state ASC,art.activity_time ASC LIMIT ?,?`
  439. _, err = o.Raw(sql, pars, uid, uid, uid, uid, startSize, pageSize).QueryRows(&items)
  440. return
  441. }
  442. // 我的日程列表 活动以及专项调研一起
  443. func GetScheduleAndSpecilList(condition string, pars []interface{}, conditionSpecil string, parsSpecil []interface{}, startSize, pageSize int) (items []*ActivityDetail, err error) {
  444. o := orm.NewOrm()
  445. sql := `SELECT
  446. art.activity_id,
  447. art.activity_time_text,
  448. art.activity_name,
  449. art.chart_permission_id,
  450. art.active_state,
  451. t.activity_type,
  452. art.chart_permission_name,
  453. art.distinguished_guest,
  454. art.expert,
  455. art.speaker,
  456. "" AS trip_img_link,
  457. "" AS activity_time_end,
  458. art.yidong_activity_id,
  459. art.is_can_appointment_minutes,
  460. art.activity_type_id,
  461. art.limit_people_num,
  462. art.is_limit_people,
  463. 1 AS source_type,
  464. art.activity_time,
  465. art.city,
  466. art.is_external_label,
  467. art.siginup_deadline,
  468. art.is_research_points,
  469. art.is_zoom,
  470. art.cancel_deadline
  471. FROM
  472. cygx_activity AS art
  473. INNER JOIN cygx_my_schedule AS my ON my.activity_id = art.activity_id
  474. INNER JOIN cygx_activity_type AS t ON t.activity_type_id = art.activity_type_id
  475. WHERE
  476. 1 = 1 `
  477. if condition != `` {
  478. sql += condition
  479. }
  480. sql += ` UNION ALL
  481. SELECT
  482. art.activity_id,
  483. art.activity_time_text_by_day AS activity_time_text,
  484. art.research_theme AS activity_name,
  485. art.chart_permission_id,
  486. "",
  487. art.special_type AS activity_type,
  488. art.chart_permission_name,
  489. "",
  490. "",
  491. "",
  492. art.trip_img_link_fix AS trip_img_link,
  493. art.activity_time_end,
  494. "",
  495. "",
  496. "",
  497. "",
  498. "",
  499. 2 AS source_type,
  500. art.activity_time,
  501. "",
  502. "",
  503. "",
  504. "",
  505. "",
  506. ""
  507. FROM
  508. cygx_activity_special AS art
  509. INNER JOIN cygx_activity_special_trip AS my ON my.activity_id = art.activity_id
  510. WHERE
  511. 1 = 1`
  512. if conditionSpecil != "" {
  513. sql += conditionSpecil
  514. }
  515. sql += ` ORDER BY activity_time DESC LIMIT ?,?`
  516. _, err = o.Raw(sql, pars, parsSpecil, startSize, pageSize).QueryRows(&items)
  517. return
  518. }
  519. // 获取数量
  520. func GetActivityCountById(activityId int) (count int, err error) {
  521. o := orm.NewOrm()
  522. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity WHERE activity_id = ?`
  523. err = o.Raw(sqlCount, activityId).QueryRow(&count)
  524. return
  525. }
  526. // 删除数据
  527. func DeleteActivity(activityId int) (err error) {
  528. o := orm.NewOrm()
  529. sql := ` DELETE FROM cygx_activity WHERE activity_id = ?`
  530. _, err = o.Raw(sql, activityId).Exec()
  531. return
  532. }
  533. // 修改活动状态至进行中
  534. func UpdateActivitySattusToHaveInHand() (err error) {
  535. defer func() {
  536. if err != nil {
  537. fmt.Println(err)
  538. go utils.SendAlarmMsg("修改活动状态至进行中失败"+err.Error(), 2)
  539. go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "修改活动状态至进行中失败 ErrMsg:"+err.Error(), utils.EmailSendToUsers)
  540. }
  541. }()
  542. o := orm.NewOrm()
  543. resultTime_30 := time.Now().Add(-time.Minute * 60).Format("2006-01-02 15:04:05") // 线上活动也改成60分钟之后结束了 2023.5.8
  544. resultTime_60 := time.Now().Add(-time.Minute * 60).Format("2006-01-02 15:04:05")
  545. var sqlOr string
  546. var condition string
  547. condition += ` AND activity_time < NOW()`
  548. sqlOr = condition
  549. condition += ` AND (activity_type_id IN ( 1, 2, 3, 7 ) AND activity_time > ` + "'" + resultTime_30 + "'" + ")"
  550. condition += ` OR(activity_type_id IN ( 4, 5, 6, 8 ) AND activity_time > ` + "'" + resultTime_60 + "'" + sqlOr + ")"
  551. msql := " UPDATE cygx_activity SET active_state = 2, top_time = 0 WHERE 1 = 1 " + condition
  552. _, err = o.Raw(msql).Exec()
  553. return
  554. }
  555. // 修改活动状态至已结束
  556. func UpdateActivitySattusToComplete() (err error) {
  557. defer func() {
  558. if err != nil {
  559. fmt.Println(err)
  560. go utils.SendAlarmMsg("修改活动状态至已结束"+err.Error(), 2)
  561. go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "修改活动状态至已结束 ErrMsg:"+err.Error(), utils.EmailSendToUsers)
  562. }
  563. }()
  564. o := orm.NewOrm()
  565. resultTime_30 := time.Now().Add(-time.Minute * 60).Format("2006-01-02 15:04:05") // 线上活动也改成60分钟之后结束了 2023.5.8
  566. resultTime_60 := time.Now().Add(-time.Minute * 60).Format("2006-01-02 15:04:05")
  567. //var sqlOr string
  568. var condition string
  569. //condition += ` AND activity_time < NOW()`
  570. //sqlOr = condition
  571. condition += ` AND (activity_type_id IN ( 1, 2, 3, 7 ) AND activity_time < ` + "'" + resultTime_30 + "'" + ")"
  572. condition += ` OR(activity_type_id IN ( 4, 5, 6 ,8 ) AND activity_time < ` + "'" + resultTime_60 + "'" + ")"
  573. msql := " UPDATE cygx_activity SET active_state = 3 WHERE 1 = 1 " + condition
  574. _, err = o.Raw(msql).Exec()
  575. return
  576. }
  577. // 活动详情
  578. type WxMsgCygxActivityList struct {
  579. Id int `description:"报名ID"`
  580. UserId int `description:"用户ID"`
  581. ActivityId int `description:"活动ID 等于0新增活动,大于0修改活动"`
  582. ActivityTypeId int `description:"活动类型id"`
  583. ActivityName string `description:"活动名称"`
  584. ActivityTypeName string `description:"活动类型名称"`
  585. Speaker string `description:"主讲人"`
  586. SignupType int `description:"报名方式,1预约外呼,2我要报名"`
  587. ChartPermissionId int `description:"行业id"`
  588. ChartPermissionName string `description:"行业名称"`
  589. IsLimitPeople int `description:"是否限制人数 1是,0否"`
  590. LimitPeopleNum int `description:"限制的人数数量"`
  591. ActivityTime string `description:"活动时间"`
  592. ActivityTimeText string `description:"活动时间带文字"`
  593. City string `description:"城市"`
  594. Address string `description:"活动地址"`
  595. DistinguishedGuest string `description:"嘉宾"`
  596. Expert string `description:"专家"`
  597. IsSignup int `description:"是否已报名 1是 ,0 否"`
  598. SignupNum int `description:"已报名人数"`
  599. ActiveState string `description:"活动进行状态 未开始:1、进行中2、已结束3"`
  600. IsCancelMeetingReminder int `description:"是否取消会议提醒 1展示取消会议提醒 ,0展示会议提醒"`
  601. IsBrackets int `description:"是否有方括号 1是 ,0 否"`
  602. OpenId string `description:"OenId"`
  603. FailType int `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
  604. }
  605. // 列表 3o分钟
  606. func GetActivitySendMsgListAll(endDate string) (items []*WxMsgCygxActivityList, err error) {
  607. o := orm.NewOrm()
  608. sql := `SELECT
  609. s.id,
  610. s.user_id,
  611. s.fail_type,
  612. cr.open_id,
  613. a.*
  614. FROM
  615. cygx_activity AS a
  616. INNER JOIN cygx_activity_signup AS s ON s.activity_id = a.activity_id
  617. INNER JOIN cygx_user_record AS cr ON cr.cygx_bind_account = s.mobile
  618. WHERE
  619. 1 = 1
  620. AND s.is_send_wx_msg = 0
  621. AND s.do_fail_type = 0
  622. AND a.publish_status = 1
  623. AND a.activity_time <= ? AND a.activity_time >= NOW()
  624. AND s.is_cancel = 0
  625. 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`
  626. _, err = o.Raw(sql, endDate).QueryRows(&items)
  627. return
  628. }
  629. // 买方研选会前一小时需要推送的Openid
  630. func GetActivitySendMsgListAllMfyx(endDate string) (items []*WxMsgCygxActivityList, err error) {
  631. o := orm.NewOrm()
  632. sql := `SELECT
  633. s.id,
  634. s.user_id,
  635. s.fail_type,
  636. cr.open_id,
  637. a.activity_name,
  638. a.activity_id,
  639. a.activity_time
  640. FROM
  641. cygx_activity AS a
  642. INNER JOIN cygx_activity_signup AS s ON s.activity_id = a.activity_id
  643. INNER JOIN cygx_mfyx_gzh_user_record AS cr ON cr.cygx_bind_account = s.mobile
  644. WHERE
  645. 1 = 1
  646. AND s.is_send_wx_msg = 0
  647. AND s.do_fail_type = 0
  648. AND a.publish_status = 1
  649. AND a.chart_permission_id = 31
  650. AND a.activity_time = ? AND a.activity_time >= NOW()
  651. AND s.is_cancel = 0
  652. AND a.activity_type_id IN (5,8) GROUP BY s.id`
  653. _, err = o.Raw(sql, endDate).QueryRows(&items)
  654. return
  655. }
  656. // 列表 15分钟提醒
  657. func GetActivitySendMsgListAllMeeting(endDate string) (items []*WxMsgCygxActivityList, err error) {
  658. o := orm.NewOrm()
  659. sql := `SELECT
  660. m.id,
  661. cr.open_id,
  662. a.*
  663. FROM
  664. cygx_activity AS a
  665. INNER JOIN cygx_activity_meeting_reminder AS m ON m.activity_id = a.activity_id
  666. INNER JOIN user_record AS c ON c.bind_account = m.mobile
  667. INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
  668. WHERE
  669. 1 = 1
  670. AND m.is_send_wx_msg = 0
  671. AND a.publish_status = 1
  672. AND a.activity_time <= ? AND a.activity_time >= NOW()
  673. AND m.is_cancel = 0
  674. AND c.create_platform = 4
  675. AND (
  676. a.activity_type_id IN ( 1, 2 )
  677. OR ( a.activity_type_id = 3 AND a.is_limit_people = 0 ))
  678. GROUP BY m.id`
  679. _, err = o.Raw(sql, endDate).QueryRows(&items)
  680. return
  681. }
  682. // 修改是否推送消息状态
  683. func UPdateSendedMsgStatus(signupIds string) (err error) {
  684. sql := ` UPDATE cygx_activity_signup SET is_send_wx_msg= 1 WHERE id IN(` + signupIds + `)`
  685. o := orm.NewOrm()
  686. _, err = o.Raw(sql).Exec()
  687. return
  688. }
  689. // 修改是否推送消息状态
  690. func UPdateSendedYiDongSignUp(activityId int) (err error) {
  691. sql := ` UPDATE cygx_activity SET is_yidong_sign_up= 1 WHERE activity_id = ? `
  692. o := orm.NewOrm()
  693. _, err = o.Raw(sql, activityId).Exec()
  694. return
  695. }
  696. // 修改是否推送消息状态
  697. func UPdateSendedMsgMeetingStatus(signupIds string) (err error) {
  698. sql := ` UPDATE cygx_activity_meeting_reminder SET is_send_wx_msg= 1 WHERE id IN(` + signupIds + `)`
  699. o := orm.NewOrm()
  700. _, err = o.Raw(sql).Exec()
  701. return
  702. }
  703. // 获取满足推送的活动ID数量
  704. func GetCountActivityIdToSendFile(endDate string) (count int, err error) {
  705. o := orm.NewOrm()
  706. sql := `SELECT
  707. COUNT(1) count
  708. FROM
  709. cygx_activity AS a
  710. INNER JOIN cygx_activity_signup AS s ON s.activity_id = a.activity_id
  711. WHERE
  712. 1 = 1
  713. AND s.signup_type = 1
  714. AND s.fail_type = 0
  715. AND a.is_send_file_toemail = 0
  716. AND a.activity_time <= ? AND a.activity_time >= NOW() GROUP BY a.activity_id `
  717. err = o.Raw(sql, endDate).QueryRow(&count)
  718. return
  719. }
  720. // 获取满足推送的活动ID
  721. func GetActivityIdToSendFile(endDate string) (items []*ActivityIdRep, err error) {
  722. o := orm.NewOrm()
  723. sql := `SELECT
  724. *
  725. FROM
  726. cygx_activity AS a
  727. INNER JOIN cygx_activity_signup AS s ON s.activity_id = a.activity_id
  728. INNER JOIN cygx_activity_type AS t ON a.activity_type_id = t.activity_type_id
  729. WHERE
  730. 1 = 1
  731. AND s.signup_type = 1
  732. AND a.yidong_activity_id = ''
  733. AND t.activity_type = 1
  734. AND s.fail_type = 0
  735. AND a.is_send_file_toemail = 0
  736. AND a.publish_status = 1
  737. AND a.activity_time <= ? AND a.activity_time >= NOW() GROUP BY a.activity_id `
  738. _, err = o.Raw(sql, endDate).QueryRows(&items)
  739. return
  740. }
  741. type SignupExportRep struct {
  742. Mobile string `description:"手机号"`
  743. CompanyName string `description:"公司名称"`
  744. CompanyId int `description:"公司Id"`
  745. RealName string `description:"姓名"`
  746. CountryCode string `description:"区号"`
  747. OutboundMobile string `description:"外呼手机号"`
  748. SellerName string `description:"销售姓名"`
  749. }
  750. type ActivityMsgExportRep struct {
  751. AskId int `description:"活动带问ID"`
  752. UserId int `description:"用户ID"`
  753. RealName string `description:"姓名"`
  754. CompanyName string `description:"公司名称"`
  755. CompanyId int `description:"公司ID"`
  756. Content string `description:"内容"`
  757. CreateTime string `description:"提交时间"`
  758. }
  759. func GetSignupExport(activityId int) (item []*SignupExportRep, err error) {
  760. o := orm.NewOrm()
  761. sql := `SELECT
  762. s.outbound_mobile,
  763. s.country_code,
  764. a.is_limit_people,
  765. s.real_name,
  766. s.seller_name,
  767. s.company_id,
  768. s.company_name
  769. FROM
  770. cygx_activity_signup AS s
  771. JOIN cygx_activity AS a ON a.activity_id = s.activity_id
  772. WHERE a.activity_id = ? AND s.do_fail_type = 0 AND s.signup_type = 1 GROUP BY s.id `
  773. _, err = o.Raw(sql, activityId).QueryRows(&item)
  774. return
  775. }
  776. // 修改文件是否推送状态
  777. func UPdateActivityIdToSendFile(activityId int) (err error) {
  778. sql := ` UPDATE cygx_activity SET is_send_file_toemail= 1 WHERE activity_id = ?`
  779. o := orm.NewOrm()
  780. _, err = o.Raw(sql, activityId).Exec()
  781. return
  782. }
  783. // 活动详情
  784. type CygxActivityLabelList struct {
  785. KeyWord string `orm:"column(label)";description:"主题"`
  786. Timesort string `description:"最大时间"`
  787. Mintimesort string `description:"最小时间"`
  788. ImgUrlBg string `description:"背景图片"`
  789. ActivityId int `description:"活动ID "`
  790. IsShowSubjectName int `description:"小程序内是否展示标的名称 1是 ,0否 默认0 "`
  791. Resource int `description:"位置 ,1:活动 ,2:专项产业调研"`
  792. TemporaryLabel string `description:"临时标签"`
  793. IsNew bool `description:"是否为新:活动存在关联的的产业所关联的报告均在3个月内/无报告则标记新"`
  794. YidongActivityId string `description:"易董活动ID"`
  795. IsExternalLabel bool `description:"是否为外部资源"`
  796. IsResearchPoints bool `description:"是否为研选扣点"`
  797. TripStatus int `description:"行程进行状态 1:预报名,2:确定行程"`
  798. City string `description:"城市"`
  799. Days int `description:"天数"`
  800. ActivityTypeId int `description:"活动类型id"`
  801. IsResearch bool `description:"是否属于研选"`
  802. ChartPermissionId int `description:"行业id"`
  803. }
  804. // 主题列表
  805. func GetActivityLabelListAll(condition, sortTime string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityLabelList, err error) {
  806. o := orm.NewOrm()
  807. 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
  808. FROM cygx_activity as art WHERE 1= 1 `
  809. if condition != "" {
  810. sql += condition
  811. }
  812. sql += ` GROUP BY art.activity_id ORDER BY ` + sortTime + ` ,art.activity_id DESC LIMIT ?,? `
  813. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  814. return
  815. }
  816. // 主题列表
  817. func GetActivityLabelListCity() (items []*CygxActivity, err error) {
  818. o := orm.NewOrm()
  819. sql := `SELECT
  820. activity_id,
  821. activity_type_id,
  822. activity_time,
  823. label,
  824. temporary_label,
  825. is_show_subject_name,
  826. yidong_activity_id,
  827. city
  828. FROM
  829. cygx_activity AS art
  830. WHERE
  831. 1 = 1
  832. AND art.active_state IN ( 1, 2 )
  833. AND city != ''
  834. ORDER BY
  835. activity_time ASC `
  836. _, err = o.Raw(sql).QueryRows(&items)
  837. return
  838. }
  839. type GetCygxActivityLabelListRep struct {
  840. Label string `description:"主题"`
  841. ImgUrl string `description:"图片路径"`
  842. List []*CygxActivityLabelList
  843. }
  844. // 获取研选系列专家电话会,会前1小时,满足推送的活动ID数量
  845. func GetCountActivityResearchToSendFile(condition, endDate string) (count int, err error) {
  846. o := orm.NewOrm()
  847. sql := `SELECT
  848. COUNT(1) count
  849. FROM
  850. cygx_activity AS a
  851. INNER JOIN cygx_activity_help_ask AS k ON k.activity_id = a.activity_id
  852. WHERE
  853. 1 = 1 ` + condition + `
  854. AND a.is_send_ask_msg = 0
  855. AND a.activity_time <= ?
  856. AND a.activity_time >= NOW()`
  857. err = o.Raw(sql, endDate).QueryRow(&count)
  858. return
  859. }
  860. // 获取研选系列专家电话会,会前1小时,满足推送的活动ID
  861. func GetActivityResearchToSendFile(condition, endDate string) (items []*ActivityIdRep, err error) {
  862. o := orm.NewOrm()
  863. sql := `SELECT
  864. *
  865. FROM
  866. cygx_activity AS a
  867. INNER JOIN cygx_activity_help_ask AS k ON k.activity_id = a.activity_id
  868. WHERE
  869. 1 = 1 ` + condition + `
  870. AND a.is_send_ask_msg = 0
  871. AND a.activity_time <= ?
  872. AND a.activity_time >= NOW()
  873. GROUP BY
  874. a.activity_id `
  875. _, err = o.Raw(sql, endDate).QueryRows(&items)
  876. return
  877. }
  878. func GetActivityMsgExport(activityId int) (item []*ActivityMsgExportRep, err error) {
  879. o := orm.NewOrm()
  880. sql := `SELECT
  881. k.*
  882. FROM
  883. cygx_activity_help_ask AS k
  884. WHERE
  885. k.activity_id = ?
  886. GROUP BY
  887. k.ask_id`
  888. _, err = o.Raw(sql, activityId).QueryRows(&item)
  889. return
  890. }
  891. // 修改文件带问消息是否推送状态
  892. func UPdateActivityMsgToSendFile(activityId int) (err error) {
  893. sql := ` UPDATE cygx_activity SET is_send_ask_msg= 1 WHERE activity_id = ?`
  894. o := orm.NewOrm()
  895. _, err = o.Raw(sql, activityId).Exec()
  896. return
  897. }
  898. type AskEmailRep struct {
  899. Name string `description:"姓名"`
  900. Email string `description:"邮箱"`
  901. Mobile string `description:"手机号"`
  902. ChartPermissionName string `description:"行业名称"`
  903. }
  904. func GetAskEmail() (item []*AskEmailRep, err error) {
  905. o := orm.NewOrm()
  906. sql := `SELECT * FROM cygx_activity_ask_email`
  907. _, err = o.Raw(sql).QueryRows(&item)
  908. return
  909. }
  910. // 主题列表
  911. func GetActivityLabelSpecialListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityLabelList, err error) {
  912. o := orm.NewOrm()
  913. sql := `SELECT label,activity_id,is_show_subject_name,days
  914. FROM cygx_activity_special as art WHERE 1= 1 `
  915. if condition != "" {
  916. sql += condition
  917. }
  918. sql += ` LIMIT ?,? `
  919. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  920. return
  921. }
  922. type GetCygxActivitySpecialDetailListResp struct {
  923. IsFollow bool `description:"是否关注新调研通知"`
  924. IsBindingMobile bool `description:"是否绑定了手机号"`
  925. Paging *paging.PagingItem `description:"分页数据"`
  926. List []*CygxActivitySpecialDetail
  927. }
  928. type CygxActivitySpecialResp struct {
  929. HaqveJurisdiction bool `description:"是否有权限"`
  930. OperationMode string `description:"操作方式 Apply:立即申请、Call:拨号 为空则为有权限"`
  931. HasPermission int `description:"操作方式,1:有该行业权限,正常展示,2:无该行业权限,3:潜在客户,未提交过申请,4:潜在客户,已提交过申请,5:有IFCC、无权益"`
  932. PopupMsg string `description:"权限弹窗信息"`
  933. MsgType string `description:"Type : 类型 , Industry : 行业"`
  934. SellerMobile string `description:"销售电话"`
  935. SellerName string `description:"销售姓名"`
  936. IsFollow bool `description:"是否关注新调研通知"`
  937. Detail *CygxActivitySpecialDetail
  938. }
  939. // 获取专项调研活动列表
  940. func GetCygxActivitySpecialDetailList(condition string, pars []interface{}, uid, startSize, pageSize int) (items []*CygxActivitySpecialDetail, err error) {
  941. o := orm.NewOrm()
  942. sql := ` SELECT
  943. art.*,
  944. (
  945. SELECT
  946. COUNT( 1 )
  947. FROM
  948. cygx_activity_special_signup AS s
  949. WHERE
  950. s.activity_id = art.activity_id
  951. AND s.user_id = ?
  952. ) AS is_signup
  953. FROM
  954. cygx_activity_special AS art
  955. WHERE
  956. 1 = 1 `
  957. if condition != "" {
  958. sql += condition
  959. }
  960. sql += ` LIMIT ?,? `
  961. _, err = o.Raw(sql, uid, pars, startSize, pageSize).QueryRows(&items)
  962. return
  963. }
  964. // 通过活动ID获取活动详情
  965. func GetCygxActivitySpecialDetailById(uid, ActivityId int) (item *CygxActivitySpecialDetail, err error) {
  966. o := orm.NewOrm()
  967. 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
  968. FROM
  969. cygx_activity_special AS a
  970. WHERE
  971. activity_id = ?
  972. AND publish_status = 1 AND is_offline = 0 `
  973. err = o.Raw(sql, uid, ActivityId).QueryRow(&item)
  974. return
  975. }
  976. // 通过活动ID获取活动详情
  977. func GetCygxActivitySpecialDetail(ActivityId int) (item *CygxActivitySpecialDetail, err error) {
  978. o := orm.NewOrm()
  979. sql := `SELECT * FROM cygx_activity_special WHERE activity_id=? AND publish_status = 1 `
  980. err = o.Raw(sql, ActivityId).QueryRow(&item)
  981. return
  982. }
  983. func UpdateCygxActivityName(activityId int, Name string) (err error) {
  984. o := orm.NewOrm()
  985. sql := `UPDATE cygx_activity SET activity_name_task = ? WHERE activity_id=? `
  986. _, err = o.Raw(sql, Name, activityId).Exec()
  987. return
  988. }
  989. // 获取已发布但是为开始活动的权限
  990. func GetActivityWeekPermission() (permission string, err error) {
  991. o := orm.NewOrm()
  992. sql := ` SELECT
  993. GROUP_CONCAT( DISTINCT chart_permission_name SEPARATOR ',' ) AS permission
  994. FROM
  995. cygx_activity
  996. WHERE
  997. active_state = 1`
  998. err = o.Raw(sql).QueryRow(&permission)
  999. return
  1000. }
  1001. // 列表
  1002. func GetIndustrialActivityGroupManagementList(activityId int) (items []*IndustrialManagementRep, err error) {
  1003. o := orm.NewOrm()
  1004. sql := `SELECT
  1005. m.chart_permission_id,
  1006. m.industrial_management_id,
  1007. m.industry_name
  1008. FROM
  1009. cygx_industrial_activity_group_management AS am
  1010. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = am.industrial_management_id
  1011. WHERE
  1012. am.activity_id = ? AND am.source = 1`
  1013. _, err = o.Raw(sql, activityId).QueryRows(&items)
  1014. return
  1015. }
  1016. // GetActivityListByYiDong 获取易董同步过来的活动列表
  1017. func GetActivityListByYiDong() (items []*CygxActivity, err error) {
  1018. o := orm.NewOrm()
  1019. sql := ` SELECT * FROM cygx_activity WHERE yidong_activity_id != '' `
  1020. _, err = o.Raw(sql).QueryRows(&items)
  1021. return
  1022. }
  1023. // GetActivityListByYiDong 获取易董同步过来的活动列表
  1024. func GetActivityListByYiDongByCygx() (items []*CygxActivity, err error) {
  1025. o := orm.NewOrm()
  1026. sql := ` SELECT * FROM cygx_activity WHERE yidong_activity_id_by_cygx != '' `
  1027. _, err = o.Raw(sql).QueryRows(&items)
  1028. return
  1029. }
  1030. // AddCygxActivity 添加活动
  1031. func AddCygxActivity(item *CygxActivity) (lastId int64, err error) {
  1032. o := orm.NewOrm()
  1033. lastId, err = o.Insert(item)
  1034. return
  1035. }
  1036. // 列表
  1037. func GetActivityListByYidong(condition string) (items []*ActivityDetail, err error) {
  1038. o := orm.NewOrm()
  1039. sql := `SELECT * FROM cygx_activity WHERE 1 = 1
  1040. AND ( yidong_activity_id != '' OR yidong_activity_id_by_cygx != '' ) AND publish_status = 1 `
  1041. if condition != "" {
  1042. sql += condition
  1043. }
  1044. _, err = o.Raw(sql).QueryRows(&items)
  1045. return
  1046. }
  1047. // 列表
  1048. func GetActivityListByCondition(condition string, pars []interface{}) (items []*CygxActivity, err error) {
  1049. o := orm.NewOrm()
  1050. sql := `SELECT * FROM cygx_activity WHERE 1 =1 `
  1051. if condition != "" {
  1052. sql += condition
  1053. }
  1054. _, err = o.Raw(sql, pars).QueryRows(&items)
  1055. return
  1056. }
  1057. // UpdateCygxActivitySubmitMeetingByActivityId ,修改活动提交到会状态
  1058. func UpdateCygxActivitySubmitMeetingByActivityId(activityId int) (err error) {
  1059. o := orm.NewOrm()
  1060. sql := `UPDATE cygx_activity SET is_submit_meeting = 1 WHERE activity_id = ? `
  1061. _, err = o.Raw(sql, activityId).Exec()
  1062. return
  1063. }
  1064. // UpdateCygxActivitySubmitMeetingByYidong ,跟易董返回的用户状态修改活动以提交到会状态
  1065. func UpdateCygxActivitySubmitMeetingByYidong(yidongActivityId string) (err error) {
  1066. o := orm.NewOrm()
  1067. sql := `UPDATE cygx_activity SET is_submit_meeting = 1 WHERE yidong_activity_id=? OR yidong_activity_id_by_cygx = ? `
  1068. _, err = o.Raw(sql, yidongActivityId, yidongActivityId).Exec()
  1069. return
  1070. }
  1071. // UpdateActivityshowSubject 根据易董推过来的匹配信息,判断临时标签是否展示
  1072. func UpdateActivityshowSubject(activityId int) (err error) {
  1073. sql := ` UPDATE cygx_activity SET is_show_subject_name= 1 , temporary_label = '' WHERE activity_id = ?`
  1074. o := orm.NewOrm()
  1075. _, err = o.Raw(sql, activityId).Exec()
  1076. return
  1077. }
  1078. // GetActivitySpecialSearcheList 活动与专项调研的搜索
  1079. func GetActivitySpecialSearcheList(condition string, pars []interface{}, conditionSpecil string, parsSpecil []interface{}, startSize, pageSize int) (items []*ActivityDetail, total int, err error) {
  1080. o := orm.NewOrm()
  1081. sql := `SELECT
  1082. art.activity_id,
  1083. art.activity_time_text,
  1084. art.activity_name,
  1085. art.chart_permission_id,
  1086. art.active_state,
  1087. t.activity_type,
  1088. t.img_url_text,
  1089. art.chart_permission_name,
  1090. art.distinguished_guest,
  1091. art.expert,
  1092. art.speaker,
  1093. "" AS trip_img_link,
  1094. "" AS activity_time_end,
  1095. art.yidong_activity_id,
  1096. art.is_can_appointment_minutes,
  1097. art.activity_type_id,
  1098. art.limit_people_num,
  1099. art.is_limit_people,
  1100. art.city,
  1101. 1 AS source_type,
  1102. art.is_yidong_conduct,
  1103. art.activity_time,
  1104. art.is_external_label,
  1105. art.siginup_deadline,
  1106. art.is_research_points,
  1107. art.cancel_deadline
  1108. FROM
  1109. cygx_activity AS art
  1110. INNER JOIN cygx_activity_type AS t ON t.activity_type_id = art.activity_type_id
  1111. WHERE
  1112. 1 = 1 `
  1113. if condition != `` {
  1114. sql += condition
  1115. }
  1116. sql += ` UNION ALL
  1117. SELECT
  1118. art.activity_id,
  1119. art.activity_time_text_by_day AS activity_time_text,
  1120. art.research_theme AS activity_name,
  1121. art.chart_permission_id,
  1122. "",
  1123. art.special_type AS activity_type,
  1124. "",
  1125. art.chart_permission_name,
  1126. "",
  1127. "",
  1128. "",
  1129. art.trip_img_link_fix AS trip_img_link,
  1130. art.activity_time_end,
  1131. "",
  1132. "",
  1133. "",
  1134. "",
  1135. "",
  1136. "",
  1137. 2 AS source_type,
  1138. "",
  1139. art.activity_time,
  1140. "",
  1141. "",
  1142. "",
  1143. ""
  1144. FROM
  1145. cygx_activity_special AS art
  1146. WHERE
  1147. 1 = 1 `
  1148. if conditionSpecil != "" {
  1149. sql += conditionSpecil
  1150. }
  1151. totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
  1152. err = o.Raw(totalSql, pars, parsSpecil).QueryRow(&total)
  1153. if err != nil {
  1154. return
  1155. }
  1156. sql += ` ORDER BY activity_time DESC LIMIT ?,?`
  1157. _, err = o.Raw(sql, pars, parsSpecil, startSize, pageSize).QueryRows(&items)
  1158. return
  1159. }
  1160. // 列表
  1161. func GetActivityListNew(condition string, pars []interface{}, uid, startSize, pageSize, playBack, filter int, typeName string) (items []*ActivityDetail, err error) {
  1162. var sqlJiontable string
  1163. if playBack == 1 {
  1164. //sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  1165. }
  1166. if filter == 1 {
  1167. sqlJiontable = ` INNER JOIN cygx_activity_video AS av ON av.activity_id = art.activity_id `
  1168. } else if filter == 2 {
  1169. sqlJiontable = ` INNER JOIN cygx_activity_voice AS ac ON ac.activity_id = art.activity_id `
  1170. }
  1171. o := orm.NewOrm()
  1172. sql := `SELECT art.* ,t.activity_type,t.img_url_text,t.img_url_bg_yx,
  1173. ( 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,
  1174. ( 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,
  1175. ( 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,
  1176. ( SELECT COUNT( 1 ) FROM cygx_activity_appointment AS ap WHERE ap.activity_id = art.activity_id AND ap.user_id = ? ) AS is_appointment
  1177. FROM cygx_activity as art
  1178. INNER JOIN cygx_activity_type as t ON t.activity_type_id = art.activity_type_id ` + sqlJiontable + ` WHERE 1= 1 `
  1179. if condition != "" {
  1180. sql += condition
  1181. }
  1182. sql += ` LIMIT ?,?`
  1183. if typeName != "" {
  1184. typeSlice := strings.Split(typeName, ",")
  1185. tempCondition := ""
  1186. for _, s := range typeSlice {
  1187. if s == "1" {
  1188. tempCondition += "'专家电话会',"
  1189. } else if s == "2" {
  1190. tempCondition += "'分析师电话会',"
  1191. } else if s == "1,2" {
  1192. tempCondition += "'专家电话会','分析师电话会',"
  1193. }
  1194. }
  1195. tempCondition = strings.TrimRight(tempCondition, ",")
  1196. sql = `SELECT * FROM(` + sql + `) AS t WHERE t.activity_type_name IN (` + tempCondition + `)`
  1197. }
  1198. _, err = o.Raw(sql, uid, uid, uid, pars, startSize, pageSize).QueryRows(&items)
  1199. return
  1200. }
  1201. // 列表
  1202. func GetActivityListHomeNew(condition string, startSize, pageSize int) (items []*ActivityDetail, err error) {
  1203. o := orm.NewOrm()
  1204. sql := `SELECT activity_id
  1205. FROM cygx_activity as art
  1206. INNER JOIN cygx_activity_type as t ON t.activity_type_id = art.activity_type_id WHERE 1= 1 `
  1207. if condition != "" {
  1208. sql += condition
  1209. }
  1210. sql += ` LIMIT ?,?`
  1211. _, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
  1212. return
  1213. }
  1214. // 主题列表
  1215. func GetActivityLabelListAllNoLimit(condition, sortTime string, pars []interface{}, conditionSpecial string) (items []*CygxActivityLabelList, err error) {
  1216. o := orm.NewOrm()
  1217. sql := `SELECT activity_id, label,temporary_label,is_show_subject_name, art.activity_time, 1 AS resource, yidong_activity_id
  1218. FROM cygx_activity as art WHERE 1= 1 `
  1219. if condition != "" {
  1220. sql += condition
  1221. }
  1222. sql += ` UNION ALL `
  1223. sql += ` SELECT
  1224. art.activity_id,
  1225. art.label,
  1226. art.temporary_label,
  1227. is_show_subject_name,
  1228. art.activity_time,
  1229. 2 AS resource,
  1230. '' AS yidong_activity_id
  1231. FROM
  1232. cygx_activity_special AS art WHERE 1= 1 ` + conditionSpecial
  1233. sql += ` GROUP BY label,resource ORDER BY ` + sortTime + ` , activity_id DESC `
  1234. _, err = o.Raw(sql, pars).QueryRows(&items)
  1235. return
  1236. }
  1237. // 列表
  1238. func GetCygxActivityList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivity, err error) {
  1239. o := orm.NewOrm()
  1240. sql := `SELECT * FROM cygx_activity as art WHERE 1= 1 `
  1241. if condition != "" {
  1242. sql += condition
  1243. }
  1244. sql += ` LIMIT ?,? `
  1245. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  1246. return
  1247. }
  1248. // 批量修改弘则活动与进门财经的一个活动关联
  1249. func UpdateJmcjActivityIdGroup(items map[int]string) (err error) {
  1250. o := orm.NewOrm()
  1251. p, err := o.Raw("UPDATE cygx_activity SET jmcj_activity_id = ? WHERE activity_id = ? AND jmcj_activity_id= '' ").Prepare()
  1252. if err != nil {
  1253. return
  1254. }
  1255. defer func() {
  1256. _ = p.Close() // 别忘记关闭 statement
  1257. }()
  1258. for k, v := range items {
  1259. _, err = p.Exec(v, k)
  1260. if err != nil {
  1261. return
  1262. }
  1263. }
  1264. return
  1265. }
  1266. // UpdateActivityVmpRobotMeetingId 建立活动跟上海那边机器人助手参会信息的关联
  1267. func UpdateActivityVmpRobotMeetingId(vmpRobotMeetingId, activityId int) (err error) {
  1268. sql := ` UPDATE cygx_activity SET vmp_robot_meeting_id = ? WHERE activity_id = ?`
  1269. o := orm.NewOrm()
  1270. _, err = o.Raw(sql, vmpRobotMeetingId, activityId).Exec()
  1271. return
  1272. }
  1273. func GetYxActivitySendMsgListAll(endDate string) (items []*WxMsgCygxActivityList, err error) {
  1274. o := orm.NewOrm()
  1275. sql := `SELECT
  1276. s.id,
  1277. s.user_id,
  1278. s.fail_type,
  1279. cr.open_id,
  1280. a.*
  1281. FROM
  1282. cygx_activity AS a
  1283. INNER JOIN cygx_activity_signup AS s ON s.activity_id = a.activity_id
  1284. INNER JOIN cygx_user_record AS cr ON cr.cygx_bind_account = s.mobile
  1285. WHERE
  1286. 1 = 1
  1287. AND s.is_send_wx_msg = 0
  1288. AND s.do_fail_type = 0
  1289. AND a.publish_status = 1
  1290. AND a.chart_permission_id = 31
  1291. AND a.activity_time <= ? AND a.activity_time >= NOW()
  1292. AND s.is_cancel = 0
  1293. GROUP BY s.id`
  1294. _, err = o.Raw(sql, endDate).QueryRows(&items)
  1295. return
  1296. }
  1297. // 获取买方研选这边的openid
  1298. func GetMfyxActivitySendMsgListAll(endDate string) (items []*WxMsgCygxActivityList, err error) {
  1299. o := orm.NewOrm()
  1300. sql := `SELECT
  1301. s.id,
  1302. s.user_id,
  1303. s.fail_type,
  1304. cr.open_id,
  1305. a.*
  1306. FROM
  1307. cygx_activity AS a
  1308. INNER JOIN cygx_activity_signup AS s ON s.activity_id = a.activity_id
  1309. INNER JOIN cygx_mfyx_gzh_user_record AS cr ON cr.cygx_bind_account = s.mobile
  1310. WHERE
  1311. 1 = 1
  1312. AND s.is_send_wx_msg = 0
  1313. AND s.do_fail_type = 0
  1314. AND a.publish_status = 1
  1315. AND a.chart_permission_id = 31
  1316. AND a.activity_time <= ? AND a.activity_time >= NOW()
  1317. AND s.is_cancel = 0
  1318. GROUP BY s.id`
  1319. _, err = o.Raw(sql, endDate).QueryRows(&items)
  1320. return
  1321. }
  1322. // UpdateCygxActivityyidongActivityId ,建立与易董的活动关联
  1323. func UpdateCygxActivityyidongActivityId(yidongActivityId, activityTime, yidongTitle string) (err error) {
  1324. yidongTitle = "%" + yidongTitle + "%"
  1325. o := orm.NewOrm()
  1326. 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 ? `
  1327. _, err = o.Raw(sql, yidongActivityId, activityTime, yidongTitle).Exec()
  1328. return
  1329. }
  1330. // 获取所有未开始、进行中的活动ID
  1331. func GetActivityIdListNoEnd() (items []*CygxActivity, err error) {
  1332. o := orm.NewOrm()
  1333. sql := `SELECT activity_id FROM cygx_activity WHERE active_state IN (1,2) `
  1334. _, err = o.Raw(sql).QueryRows(&items)
  1335. return
  1336. }