activity.go 33 KB

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