activity.go 58 KB

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