activity.go 34 KB

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