activity.go 34 KB

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