activity.go 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. package cygx
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hz_crm_api/utils"
  7. "time"
  8. )
  9. type Activity struct {
  10. ActivityTypeId int `description:"活动类型id"`
  11. ActivityTypeName string `description:"活动名称"`
  12. TemplateP string `description:"活动模板,带P标签"`
  13. Template string `description:"活动模板"`
  14. ShowType string `description:"人数限制类型,1不展示限制,2可选限制,3强制限制"`
  15. }
  16. type ActivityIdRep struct {
  17. ActivityId int `description:"活动id"`
  18. }
  19. type ActivityList struct {
  20. List []*ActivityType
  21. }
  22. // 列表
  23. func GetActivityList() (items []*ActivityType, err error) {
  24. o := orm.NewOrm()
  25. sql := `SELECT * FROM cygx_activity_type ORDER BY sort DESC`
  26. _, err = o.Raw(sql).QueryRows(&items)
  27. return
  28. }
  29. type ActivityCcustomerType struct {
  30. CustomerTypeId int `description:"活动类型id"`
  31. CustomerName string `description:"活动名称"`
  32. PermissionValue string `description:"不同客户身份所对应的权限值"`
  33. Explain string `description:"说明"`
  34. ExplainSpecial string `description:"专项产业调研说明"`
  35. }
  36. type ActivityCcustomerTypeList struct {
  37. List []*ActivityCcustomerType
  38. }
  39. // 列表
  40. func GetActivityCcustomerTypeList(condition string) (items []*ActivityCcustomerType, err error) {
  41. o := orm.NewOrm()
  42. sql := `SELECT * FROM cygx_customer_type WHERE 1= 1 `
  43. if condition != "" {
  44. sql += condition
  45. }
  46. sql += ` ORDER BY sort DESC `
  47. _, err = o.Raw(sql).QueryRows(&items)
  48. return
  49. }
  50. // 活动添加、修改入参
  51. type ActivityRep struct {
  52. ActivityTypeId int `description:"活动类型id"`
  53. PermissionName string `description:"行业名称"`
  54. Body string `description:"内容"`
  55. LimitPeopleNum int `description:"限制的人数数量"`
  56. CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开 1、永续客户; 2、大套餐客户; 3、行业套餐客户; 4、专家套餐客户; 5、试用客户;6、冻结客户;7、流失客户 "`
  57. ActivityId int `description:"活动ID 等于0新增活动,大于0修改活动"`
  58. DoType int `description:"操作类型 0,保存 、1,发布"`
  59. IsMakerShow int `description:"是否仅决策人可见 0,否 、1,是"`
  60. VisibleRange int `description:"可见范围 1,仅本组可见 、2,全部客户可见"`
  61. IsYidongConduct int `description:"是否属于易董办会 1:是 、0:否"`
  62. IsCanOutboundCall int `description:"是否提供外呼 1:是 、0:否"`
  63. LabelType int `description:"标签类型 ,1单主题标签 ,2多主题标签"`
  64. IndustrialManagementIdS string `description:"产业ID,多个用 , 隔开"`
  65. IndustrialSubjectIdS string `description:"标的ID,多个用,隔开"`
  66. Scale string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
  67. IsExternalLabel int `description:"是否为外部资源 1是,0否"`
  68. IsBClass int `description:"是否为B类电话会 1是,0否"`
  69. IsNeedEmail int `description:"是否需要提供邮箱 1是,0否"`
  70. SiginupDeadline string `description:"报名截止时间"`
  71. IsResearchPoints int `description:"是否为研选扣点 1是,0否"`
  72. IsResearch bool `description:"是否为研选"`
  73. IsShowHz int `description:"是否同时在弘则展示 1是,0否"`
  74. PointsSet *CygxActivityPointsSetRsq `description:"研选扣点明细"`
  75. IsAllCustomerType int `description:"是否全选活动可见类型 0无 1全选"`
  76. List []*ActivityGroupIndustrialRep
  77. VoiceList []*CygxActivityVoiceReq
  78. VideoDetail *CygxActivityVideoReq
  79. }
  80. // 活动添加、修改入参
  81. type ActivityGroupIndustrialRep struct {
  82. IndustrialManagementIdS string `description:"产业ID,多个用 , 隔开"`
  83. IndustrialSubjectIdS string `description:"标的ID,多个用,隔开"`
  84. IsShowSubjectName int `description:"小程序内是否展示标的名称 1是 ,0 否 默认0 "`
  85. TemporaryLabel string `description:"临时标签"`
  86. IsCanAppointmentMinutes int `description:"是否可预约纪要 1是 ,0 否 默认0 "`
  87. }
  88. // 活动详情
  89. type ActivityDetail struct {
  90. ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
  91. ActivityTypeId int `description:"活动类型id"`
  92. ActivityTypeName string `description:"活动类型名称"`
  93. ChartPermissionId int `description:"行业id"`
  94. ChartPermissionName string `description:"行业名称"`
  95. Body string `description:"内容"`
  96. CreateTime string `description:"创建时间"`
  97. IsLimitPeople int `description:"是否限制人数 1是,0否"`
  98. LimitPeopleNum string `description:"限制的人数数量"`
  99. CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
  100. PublishStatus int `description:"发布状态 1已发布,0未发布"`
  101. LastUpdatedTime string `description:"更新时间"`
  102. ActivityTime string `description:"活动时间"`
  103. ActivityTimeText string `description:"活动时间带文字"`
  104. DistinguishedGuest string `description:"嘉宾"`
  105. Host string `description:"主持人"`
  106. MainlandTell string `description:"大陆拨入号"`
  107. HongKongTell string `description:"香港拨入号"`
  108. TaiwanTell string `description:"台湾拨入号"`
  109. AmericaTell string `description:"美国拨入号"`
  110. ParticipationCode string `description:"参会密码"`
  111. Theme string `description:"主题"`
  112. Expert string `description:"专家"`
  113. ActivityName string `description:"活动名称"`
  114. OnlineParticipation string `description:"网络参会"`
  115. ReportLink string `description:"报告链接"`
  116. City string `description:"城市"`
  117. Address string `description:"活动地址"`
  118. Highlights string `description:"活动亮点"`
  119. Remarks string `description:"备注"`
  120. ShowType string `description:"人数限制类型,1不展示限制,2可选限制,3强制限制"`
  121. Speaker string `description:"主讲人"`
  122. ActiveState int `description:"活动进行状态 未开始:1、进行中2、已结束3"`
  123. IsSubmitMeeting int `description:"是否提交过到会情况,1是,0否"`
  124. TemporaryLabel string `description:"临时标签"`
  125. IsMakerShow int `description:"是否仅决策人可见 0,否 、1,是"`
  126. VisibleRange int `description:"可见范围 1,仅本组可见 、2,全部客户可见"`
  127. Scale string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
  128. IsShowSubjectName int `description:"小程序内是否展示标的名称 1是 ,0 否 默认0 "`
  129. AdminId int `description:"销售/管理员ID"`
  130. AdminName string `description:"销售/管理员姓名"`
  131. IsHideAppointment int `description:"是否隐藏预约纪要按钮 1是,0 否"`
  132. PermissionType int `description:"1主观,2客观"`
  133. Label string `description:"标签"`
  134. ListIndustrial []*IndustrialActivityGroupManagementRep
  135. ListSubject []*SubjectActivityGroupManagementRep
  136. IsCanAppointmentMinutes int `description:"是否可预约纪要 1是 ,0 否 默认0 "`
  137. YidongActivityId string `description:"易董的活动ID"`
  138. YidongActivityEndTime string `description:"易董活动截止时间"`
  139. VoiceList []*CygxActivityVoiceReq
  140. VideoDetail *CygxActivityVideo
  141. ActivityJoinType string `description:"活动入会类型01报名审核后可入会 02预约即可入会 03仅定向邀请人员可入会"`
  142. YidongSignUpEnd string `description:"易董活动截止时间"` // 报名结束时间,适应于报名审核后可入会,为空表示不限制报名时间
  143. YidongSignUpStart string `description:"易董活动截止时间"` // 报名开始时间,适应于报名审核后可入会,为空表示不限制报名时间
  144. PublishDate string `description:"发布时间"`
  145. IsYidongConduct int `description:"是否属于易董办会 1:是 、0:否"`
  146. IsCanOutboundCall int `description:"是否提供外呼 1:是 、0:否"`
  147. YidongActivityIdByCygx string `description:"通过查研观向建会易董返回的活动ID"`
  148. TencentConferenceNumber string `description:"腾讯会议号"`
  149. IsExternalLabel int `description:"是否为外部资源 1是,0否"`
  150. SigninImg string `description:"签到码图片"`
  151. IsResearchPoints int `description:"是否为研选扣点 1是,0否"`
  152. IsBClass int `description:"是否为B类电话会 1是,0否"`
  153. IsNeedEmail int `description:"是否需要提供邮箱 1是,0否"`
  154. SiginupDeadline string `description:"报名截止时间"`
  155. PointsSet *CygxActivityPointsSetRsq `description:"研选扣点明细"`
  156. IsShowHz int `description:"是否同时在弘则展示 1是,0否"`
  157. ChartPermissionNameDeputy string `description:"副行业名称"`
  158. }
  159. type ActivityDetailRep struct {
  160. Detail *ActivityDetail
  161. ListIndustrial []*IndustrialActivityGroupManagementRep
  162. ListSubject []*SubjectActivityGroupManagementRep
  163. }
  164. // 活动详情
  165. type CygxActivity struct {
  166. ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
  167. ActivityTypeId int `description:"活动类型id"`
  168. ActivityTypeName string `description:"活动类型名称"`
  169. ChartPermissionId int `description:"行业id"`
  170. ChartPermissionName string `description:"行业名称"`
  171. ChartPermissionNames string `description:"行业名称辅助字段,区分研选子分类"`
  172. Body string `description:"内容"`
  173. CreateTime time.Time `description:"创建时间"`
  174. PublishDate time.Time `description:"发布时间"`
  175. IsLimitPeople int `description:"是否限制人数 1是,0否"`
  176. LimitPeopleNum int `description:"限制的人数数量"`
  177. CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
  178. PublishStatus int `description:"发布状态 1已发布,0未发布"`
  179. LastUpdatedTime time.Time `description:"更新时间"`
  180. ActivityTime string `description:"活动时间"`
  181. ActivityTimeText string `description:"活动时间带文字"`
  182. DistinguishedGuest string `description:"嘉宾"`
  183. Host string `description:"主持人"`
  184. MainlandTell string `description:"大陆拨入号"`
  185. HongKongTell string `description:"香港拨入号"`
  186. TaiwanTell string `description:"台湾拨入号"`
  187. AmericaTell string `description:"美国拨入号"`
  188. ParticipationCode string `description:"参会密码"`
  189. Theme string `description:"主题"`
  190. Expert string `description:"专家"`
  191. ActivityName string `description:"活动名称"`
  192. ActivityNameTask string `description:"活动名称定时任务同步的时候使用"`
  193. OnlineParticipation string `description:"网络参会"`
  194. ReportLink string `description:"报告链接"`
  195. City string `description:"城市"`
  196. Address string `description:"活动地址"`
  197. Highlights string `description:"活动亮点"`
  198. Remarks string `description:"备注"`
  199. Speaker string `description:"主讲人"`
  200. ArticleId int `description:"关联报告id"`
  201. Label string `description:"标签"`
  202. LinkParticipants string `description:"链接参会"`
  203. AppAttendance string `description:"App参会"`
  204. ConferencePassword string `description:"会议密码"`
  205. TemporaryLabel string `description:"临时标签"`
  206. IsMakerShow int `description:"是否仅决策人可见 0,否 、1,是"`
  207. VisibleRange int `description:"可见范围 1,仅本组可见 、2,全部客户可见"`
  208. Scale string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
  209. IsShowSubjectName int `description:"小程序内是否展示标的名称 1是 ,0 否 默认0 "`
  210. IsHideAppointment int `description:"是否隐藏预约纪要按钮 1是 ,0 否 默认0 "`
  211. AdminId int `description:"销售/管理员ID"`
  212. AdminName string `description:"销售/管理员姓名"`
  213. IsCanAppointmentMinutes int `description:"是否可预约纪要 1是 ,0 否 默认0 "`
  214. IsYidongConduct int `description:"是否属于易董办会 1:是 、0:否"`
  215. IsCanOutboundCall int `description:"是否提供外呼 1:是 、0:否"`
  216. IsCancel int `description:"是否取消,1是,0否"`
  217. TencentConferenceNumber string `description:"腾讯会议号"`
  218. IsExternalLabel int `description:"是否为外部资源 1是,0否"`
  219. IsBClass int `description:"是否为B类电话会 1是,0否"`
  220. IsNeedEmail int `description:"是否需要提供邮箱 1是,0否"`
  221. SiginupDeadline string `description:"报名截止时间"`
  222. IsResearchPoints int `description:"是否为研选扣点 1是,0否"`
  223. IsAllCustomerType int `description:"是否全选活动可见类型 0无 1全选"`
  224. IsShowHz int `description:"是否同时在弘则展示 1是,0否"`
  225. ChartPermissionIdDeputy int `description:"行业id"`
  226. ChartPermissionNameDeputy string `description:"行业名称"`
  227. CancelDeadline string `description:"取消报名截止时间"`
  228. }
  229. type CygxActivityEditDetail struct {
  230. ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
  231. ActivityTypeId int `description:"活动类型id"`
  232. ChartPermissionId int `description:"行业id"`
  233. Body string `description:"内容"`
  234. LimitPeopleNum int `description:"限制的人数数量"`
  235. CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
  236. }
  237. // 添加活动
  238. func AddActivity(items []*CygxActivity, industrialActivityItems [][]*CygxIndustrialActivityGroupManagement, subjectActivityItems [][]*CygxIndustrialActivityGroupSubject, itemPointsSet *CygxActivityPointsSet) (newId int64, activityIdArr []int, err error) {
  239. o := orm.NewOrm()
  240. to, err := o.Begin()
  241. if err != nil {
  242. return
  243. }
  244. defer func() {
  245. if err != nil {
  246. _ = to.Rollback()
  247. } else {
  248. _ = to.Commit()
  249. }
  250. }()
  251. for k, v := range items {
  252. fmt.Println(v.ActivityName + "____标题")
  253. newId, err = to.Insert(v)
  254. activityIdArr = append(activityIdArr, int(newId))
  255. if err != nil {
  256. return
  257. }
  258. //添加关联的产业
  259. if len(industrialActivityItems) > 0 {
  260. for k1, v1 := range industrialActivityItems {
  261. if len(v1) > 0 && k == k1 {
  262. for _, v2 := range v1 {
  263. v2.ActivityId = int(newId)
  264. _, err = to.Insert(v2)
  265. if err != nil {
  266. return
  267. }
  268. }
  269. }
  270. }
  271. }
  272. //添加关联的标的
  273. if len(subjectActivityItems) > 0 {
  274. for k1, v1 := range subjectActivityItems {
  275. if len(v1) > 0 && k == k1 {
  276. for _, v2 := range v1 {
  277. v2.ActivityId = int(newId)
  278. _, err = to.Insert(v2)
  279. if err != nil {
  280. return
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287. {
  288. //添加研选扣点内容
  289. if itemPointsSet.PointsObject != "" {
  290. itemPointsSet.ActivityId = int(newId)
  291. _, err = to.Insert(itemPointsSet)
  292. if err != nil {
  293. return
  294. }
  295. }
  296. }
  297. //newId, err = to.Insert(item)
  298. return
  299. }
  300. // 通过纪要ID获取活动详情
  301. func GetAddActivityInfoById(ActivityId int) (item *ActivityDetail, err error) {
  302. o := orm.NewOrm()
  303. sql := `SELECT
  304. a.*,t.permission_type
  305. FROM
  306. cygx_activity as a
  307. INNER JOIN cygx_activity_type as t on t.activity_type_id = a.activity_type_id
  308. WHERE
  309. activity_id =?`
  310. err = o.Raw(sql, ActivityId).QueryRow(&item)
  311. return
  312. }
  313. // 修改
  314. func EditActivity(item *CygxActivity, oldPublishStatus int, industrialActivityItems [][]*CygxIndustrialActivityGroupManagement, subjectActivityItems [][]*CygxIndustrialActivityGroupSubject, itemVoice *CygxActivityVoice, itemVideo *CygxActivityVideo, itemPointsSet *CygxActivityPointsSet) (voiceId, videoId int64, err error) {
  315. o := orm.NewOrm()
  316. to, err := o.Begin()
  317. if err != nil {
  318. return
  319. }
  320. defer func() {
  321. if err != nil {
  322. fmt.Println(err)
  323. _ = to.Rollback()
  324. } else {
  325. _ = to.Commit()
  326. }
  327. }()
  328. activityId := item.ActivityId
  329. //修改活动信息
  330. updateParams := make(map[string]interface{})
  331. updateParams["ActivityTypeId"] = item.ActivityTypeId
  332. updateParams["ActivityTypeName"] = item.ActivityTypeName
  333. updateParams["ChartPermissionId"] = item.ChartPermissionId
  334. updateParams["ChartPermissionName"] = item.ChartPermissionName
  335. updateParams["ChartPermissionNames"] = item.ChartPermissionNames
  336. updateParams["Body"] = item.Body
  337. updateParams["IsLimitPeople"] = item.IsLimitPeople
  338. updateParams["LimitPeopleNum"] = item.LimitPeopleNum
  339. updateParams["CustomerTypeIds"] = item.CustomerTypeIds
  340. updateParams["PublishStatus"] = item.PublishStatus
  341. updateParams["LastUpdatedTime"] = item.LastUpdatedTime
  342. updateParams["ActivityTime"] = item.ActivityTime
  343. updateParams["ActivityTimeText"] = item.ActivityTimeText
  344. updateParams["DistinguishedGuest"] = item.DistinguishedGuest
  345. updateParams["Host"] = item.Host
  346. updateParams["MainlandTell"] = item.MainlandTell
  347. updateParams["HongKongTell"] = item.HongKongTell
  348. updateParams["TaiwanTell"] = item.TaiwanTell
  349. updateParams["AmericaTell"] = item.AmericaTell
  350. updateParams["ParticipationCode"] = item.ParticipationCode
  351. updateParams["Theme"] = item.Theme
  352. updateParams["Expert"] = item.Expert
  353. updateParams["ActivityName"] = item.ActivityName
  354. updateParams["OnlineParticipation"] = item.OnlineParticipation
  355. updateParams["ReportLink"] = item.ReportLink
  356. updateParams["City"] = item.City
  357. updateParams["Address"] = item.Address
  358. updateParams["Highlights"] = item.Highlights
  359. updateParams["Remarks"] = item.Remarks
  360. updateParams["ArticleId"] = item.ArticleId
  361. updateParams["TemporaryLabel"] = item.TemporaryLabel
  362. updateParams["Speaker"] = item.Speaker
  363. updateParams["LinkParticipants"] = item.LinkParticipants
  364. updateParams["AppAttendance"] = item.AppAttendance
  365. updateParams["ConferencePassword"] = item.ConferencePassword
  366. updateParams["Label"] = item.Label
  367. updateParams["Scale"] = item.Scale
  368. updateParams["IsShowSubjectName"] = item.IsShowSubjectName
  369. updateParams["ActivityNameTask"] = item.ActivityNameTask
  370. updateParams["AdminId"] = item.AdminId
  371. updateParams["AdminName"] = item.AdminName
  372. updateParams["IsHideAppointment"] = item.IsHideAppointment
  373. updateParams["IsMakerShow"] = item.IsMakerShow
  374. updateParams["VisibleRange"] = item.VisibleRange
  375. updateParams["IsCanAppointmentMinutes"] = item.IsCanAppointmentMinutes
  376. updateParams["PublishDate"] = item.PublishDate
  377. updateParams["IsYidongConduct"] = item.IsYidongConduct
  378. updateParams["IsCanOutboundCall"] = item.IsCanOutboundCall
  379. updateParams["TencentConferenceNumber"] = item.TencentConferenceNumber
  380. updateParams["IsExternalLabel"] = item.IsExternalLabel
  381. updateParams["IsCancel"] = item.IsCancel
  382. updateParams["IsBClass"] = item.IsBClass
  383. updateParams["IsNeedEmail"] = item.IsNeedEmail
  384. updateParams["SiginupDeadline"] = item.SiginupDeadline
  385. updateParams["IsResearchPoints"] = item.IsResearchPoints
  386. updateParams["IsAllCustomerType"] = item.IsAllCustomerType
  387. if item.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
  388. updateParams["IsShowHz"] = item.IsShowHz //研选的才做修改
  389. }
  390. updateParams["ChartPermissionNameDeputy"] = item.ChartPermissionNameDeputy
  391. updateParams["ChartPermissionIdDeputy"] = item.ChartPermissionIdDeputy
  392. updateParams["CancelDeadline"] = item.CancelDeadline
  393. //修改活动信息
  394. ptrStructOrTableName := "cygx_activity"
  395. whereParam := map[string]interface{}{"activity_id": item.ActivityId}
  396. qs := to.QueryTable(ptrStructOrTableName)
  397. for expr, exprV := range whereParam {
  398. qs = qs.Filter(expr, exprV)
  399. }
  400. _, err = qs.Update(updateParams)
  401. //删除活动关联的产业
  402. sql := ` DELETE FROM cygx_industrial_activity_group_management WHERE activity_id = ? AND source =1 `
  403. _, err = to.Raw(sql, activityId).Exec()
  404. if err != nil {
  405. return
  406. }
  407. //删除活动关联的标的
  408. sql = ` DELETE FROM cygx_industrial_activity_group_subject WHERE activity_id = ? AND source =1`
  409. _, err = to.Raw(sql, activityId).Exec()
  410. if err != nil {
  411. return
  412. }
  413. //添加关联的产业
  414. if len(industrialActivityItems) > 0 {
  415. for _, v1 := range industrialActivityItems {
  416. if len(v1) > 0 {
  417. for _, v2 := range v1 {
  418. _, err = to.Insert(v2)
  419. if err != nil {
  420. return
  421. }
  422. }
  423. }
  424. }
  425. }
  426. //添加关联的标的
  427. if len(subjectActivityItems) > 0 {
  428. for _, v1 := range subjectActivityItems {
  429. if len(v1) > 0 {
  430. for _, v2 := range v1 {
  431. _, err = to.Insert(v2)
  432. if err != nil {
  433. return
  434. }
  435. }
  436. }
  437. }
  438. }
  439. //音频处理
  440. //删除旧的音频
  441. sql = "DELETE FROM cygx_activity_voice WHERE activity_id=?"
  442. _, err = to.Raw(sql, activityId).Exec()
  443. //插入新的音频
  444. //if len(itemVoiceList) > 0 {
  445. // voiceId, err := to.InsertMulti(len(itemVoiceList), itemVoiceList)
  446. // if err != nil {
  447. // return
  448. // }
  449. //}
  450. if itemVoice != nil {
  451. if itemVoice.VoiceUrl != "" {
  452. voiceId, err = to.Insert(itemVoice)
  453. if err != nil {
  454. return
  455. }
  456. }
  457. }
  458. //视频处理
  459. //删除旧的视频
  460. sql = "DELETE FROM cygx_activity_video WHERE activity_id=?"
  461. _, err = to.Raw(sql, activityId).Exec()
  462. //插入新的音频
  463. if itemVideo != nil {
  464. if itemVideo.VideoUrl != "" {
  465. videoId, err = to.Insert(itemVideo)
  466. if err != nil {
  467. return
  468. }
  469. }
  470. }
  471. {
  472. //处理研选扣点子表
  473. if itemPointsSet.PointsObject == "" {
  474. sql := ` DELETE FROM cygx_activity_points_set WHERE activity_id = ?`
  475. _, err = to.Raw(sql, activityId).Exec()
  476. if err != nil {
  477. return
  478. }
  479. } else {
  480. var countpoints int
  481. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_activity_points_set WHERE activity_id=? `
  482. err = to.Raw(sqlCount, activityId).QueryRow(&countpoints)
  483. if err != nil {
  484. return
  485. }
  486. itemPointsSet.ActivityId = activityId
  487. if countpoints == 0 {
  488. _, err = to.Insert(itemPointsSet)
  489. if err != nil {
  490. return
  491. }
  492. } else {
  493. updateParams := make(map[string]interface{})
  494. updateParams["PointsObject"] = itemPointsSet.PointsObject
  495. updateParams["CompanyId"] = itemPointsSet.CompanyId
  496. updateParams["CompanyName"] = itemPointsSet.CompanyName
  497. updateParams["UserPointsNum"] = itemPointsSet.UserPointsNum
  498. updateParams["PointsType"] = itemPointsSet.PointsType
  499. updateParams["CompanyPointsNum"] = itemPointsSet.CompanyPointsNum
  500. updateParams["ModifyTime"] = itemPointsSet.ModifyTime
  501. updateParams["CancelDeadlineType"] = itemPointsSet.CancelDeadlineType
  502. //修改活动信息
  503. ptrStructOrTableName = "cygx_activity_points_set"
  504. whereParam := map[string]interface{}{"activity_id": itemPointsSet.ActivityId}
  505. qs := to.QueryTable(ptrStructOrTableName)
  506. for expr, exprV := range whereParam {
  507. qs = qs.Filter(expr, exprV)
  508. }
  509. _, err = qs.Update(updateParams)
  510. if err != nil {
  511. return
  512. }
  513. }
  514. }
  515. }
  516. return
  517. }
  518. // 修改
  519. func EditActivityStatus(activityId int) (err error) {
  520. o := orm.NewOrm()
  521. to, err := o.Begin()
  522. if err != nil {
  523. return
  524. }
  525. defer func() {
  526. if err != nil {
  527. _ = to.Rollback()
  528. } else {
  529. _ = to.Commit()
  530. }
  531. }()
  532. sql := `UPDATE cygx_activity SET active_state=1, is_send_file_toemail=0 ,is_send_ask_msg = 0 WHERE activity_id=?`
  533. _, err = to.Raw(sql, activityId).Exec()
  534. if err != nil {
  535. return
  536. }
  537. sql = `UPDATE cygx_activity_signup SET is_send_wx_msg=0 WHERE activity_id=?`
  538. _, err = to.Raw(sql, activityId).Exec()
  539. if err != nil {
  540. return
  541. }
  542. sql = `UPDATE cygx_activity_meeting_reminder SET is_send_wx_msg=0 WHERE activity_id=?`
  543. _, err = to.Raw(sql, activityId).Exec()
  544. return
  545. }
  546. // 活动详情
  547. type CygxActivityList struct {
  548. ActivityId int `orm:"column(activity_id);pk";description:"活动ID 等于0新增活动,大于0修改活动"`
  549. ActivityTypeId int `description:"活动类型id"`
  550. ActivityName string `description:"活动名称"`
  551. ActivityTypeName string `description:"活动类型名称"`
  552. ActiveState int `description:"活动进行状态 未开始:1、进行中2、已结束3"`
  553. ChartPermissionId int `description:"行业id"`
  554. ChartPermissionName string `description:"行业名称"`
  555. ChartPermissionNames string `description:"行业名称辅助字段,区分研选子分类"`
  556. Body string `description:"内容"`
  557. IsLimitPeople int `description:"是否限制人数 1是,0否"`
  558. LimitPeopleNum int `description:"限制的人数数量"`
  559. CustomerTypeIds string `description:"活动可见的客户类型,多个ID用 , 隔开"`
  560. PublishStatus int `description:"发布状态 1已发布,0未发布"`
  561. LastUpdatedTime string `description:"更新时间"`
  562. ActivityTime string `description:"活动时间"`
  563. ActivityTimeText string `description:"活动时间带文字"`
  564. Label string `description:"标签"`
  565. YidongActivityId string `description:"易董的活动ID"`
  566. TemporaryLabel string `description:"临时标签"`
  567. IsCancel int `description:"是否取消,1是,0否"`
  568. IsUpload bool `description:"是否上传"`
  569. IsYidongConduct int `description:"是否属于易董办会 1:是 、0:否"`
  570. IsShowSigninButton bool `description:"是否展示签到码按钮"`
  571. SigninImg string `description:"签到码图片"`
  572. ChartPermissionNameDeputy string `description:"副行业名称"`
  573. }
  574. type GetCygxActivityListRep struct {
  575. Paging *paging.PagingItem `description:"分页数据"`
  576. List []*CygxActivityList
  577. }
  578. // 列表
  579. func GetActivityListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityList, err error) {
  580. o := orm.NewOrm()
  581. sql := `SELECT * FROM cygx_activity as art WHERE 1= 1 `
  582. if condition != "" {
  583. sql += condition
  584. }
  585. sql += ` LIMIT ?,?`
  586. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  587. return
  588. }
  589. // 获取数量
  590. func GetActivityCount(condition string, pars []interface{}) (count int, err error) {
  591. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_activity as art WHERE 1= 1 `
  592. if condition != "" {
  593. sqlCount += condition
  594. }
  595. o := orm.NewOrm()
  596. err = o.Raw(sqlCount, pars).QueryRow(&count)
  597. return
  598. }
  599. // 获取数量
  600. func GetActivityCountById(activityId int) (count int, err error) {
  601. o := orm.NewOrm()
  602. sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity WHERE activity_id = ?`
  603. err = o.Raw(sqlCount, activityId).QueryRow(&count)
  604. return
  605. }
  606. // 修改发布状态
  607. func ActivityPublishAndCancel(item *CygxActivity) (err error) {
  608. o := orm.NewOrm()
  609. to, err := o.Begin()
  610. if err != nil {
  611. return
  612. }
  613. defer func() {
  614. if err != nil {
  615. fmt.Println(err)
  616. _ = to.Rollback()
  617. } else {
  618. _ = to.Commit()
  619. }
  620. }()
  621. activityId := item.ActivityId
  622. sql := `UPDATE cygx_activity SET publish_status=? , last_updated_time= ? ,admin_id =?,admin_name =? ,publish_date=?,is_cancel=? WHERE activity_id=? `
  623. _, err = to.Raw(sql, item.PublishStatus, time.Now(), item.AdminId, item.AdminName, item.PublishDate, item.IsCancel, activityId).Exec()
  624. if err != nil {
  625. return
  626. }
  627. //if item.PublishStatus == 0 {
  628. // //删除报名信息
  629. // sql = ` DELETE FROM cygx_activity_signup WHERE activity_id = ?`
  630. // _, err = to.Raw(sql, activityId).Exec()
  631. // if err != nil {
  632. // return
  633. // }
  634. // //删除会议提醒信息
  635. // sql = ` DELETE FROM cygx_activity_meeting_reminder WHERE activity_id = ?`
  636. // _, err = to.Raw(sql, activityId).Exec()
  637. // if err != nil {
  638. // return
  639. // }
  640. // //删除我的日程信息
  641. // sql = ` DELETE FROM cygx_my_schedule WHERE activity_id = ?`
  642. // _, err = to.Raw(sql, activityId).Exec()
  643. // if err != nil {
  644. // return
  645. // }
  646. //}
  647. return
  648. }
  649. // 删除数据
  650. func DeleteActivity(activityId int) (err error) {
  651. o := orm.NewOrm()
  652. sql := ` DELETE FROM cygx_activity WHERE activity_id = ?`
  653. _, err = o.Raw(sql, activityId).Exec()
  654. return
  655. }
  656. // 更新手动匹配的活动匹配关键词,建立匹配关系
  657. func UpdateActivityRoadshowTitle(activityId int, roadshowTitle, roadshowId string) (err error) {
  658. o := orm.NewOrm()
  659. sql := ` UPDATE cygx_activity SET jmcj_roadshow_title=?,jmcj_activity_id=? WHERE activity_id=?`
  660. _, err = o.Raw(sql, roadshowTitle, roadshowId, activityId).Exec()
  661. return
  662. }
  663. // 列表
  664. func GetArticleListByCategoryId(categoryIds, industrialSubjectIdS string) (items []*CygxArticle, err error) {
  665. o := orm.NewOrm()
  666. sql := `SELECT
  667. *
  668. FROM
  669. cygx_article AS a
  670. INNER JOIN cygx_industrial_article_group_subject AS s ON s.article_id = a.article_id
  671. WHERE
  672. a.category_id IN (` + categoryIds + ` )
  673. AND a.publish_status = 1
  674. AND DATE_SUB( CURDATE(), INTERVAL 14 DAY ) <= date( a.publish_date )
  675. AND s.industrial_subject_id IN ( ` + industrialSubjectIdS + ` )
  676. GROUP BY
  677. a.article_id
  678. ORDER BY
  679. a.publish_date DESC`
  680. _, err = o.Raw(sql).QueryRows(&items)
  681. return
  682. }
  683. // 通过产业名称获取关联的ID
  684. func GetactivityIdsByLabel(name string) (activityIds string, err error) {
  685. sql := ` SELECT
  686. GROUP_CONCAT( DISTINCT s.activity_id SEPARATOR ',' ) AS activityIds
  687. FROM
  688. cygx_activity AS s
  689. WHERE
  690. label LIKE '%` + name + `%' `
  691. o := orm.NewOrm()
  692. err = o.Raw(sql).QueryRow(&activityIds)
  693. return
  694. }
  695. // 根据易董的建会信息,修改腾讯参会信息
  696. func UpdateCygxActivityTencentConferenceNumber(item *ActivityDetail) (err error) {
  697. sql := `UPDATE cygx_activity SET tencent_conference_number=?,yidong_activity_id_by_cygx=?, body = ? WHERE activity_id=? `
  698. o := orm.NewOrm()
  699. _, err = o.Raw(sql, item.TencentConferenceNumber, item.YidongActivityIdByCygx, item.Body, item.ActivityId).Exec()
  700. return
  701. }
  702. // 添加场所码
  703. func UpdateCygxActivitySigninImg(signinImg string, activityId int) (err error) {
  704. sql := `UPDATE cygx_activity SET signin_img=? WHERE activity_id=? `
  705. o := orm.NewOrm()
  706. _, err = o.Raw(sql, signinImg, activityId).Exec()
  707. return
  708. }
  709. type AliyunOcrTextActivityResp struct {
  710. TitmeYMD string `description:"时间年月日"`
  711. TitmeHM string `description:"时间时分"`
  712. Company string `description:"公司名称"`
  713. }
  714. type AliyunOcrTextActivityListResp struct {
  715. List []*AliyunOcrTextActivityResp
  716. }