cygx_activity_special_meeting_detail.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. package cygx
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. type CygxActivitySpecialMeetingDetail struct {
  8. Id int `orm:"column(id);pk"`
  9. UserId int `description:"用户id"`
  10. ActivityId int `description:"活动ID"`
  11. CreateTime time.Time `description:"创建时间"`
  12. Mobile string `description:"手机号"`
  13. Email string `description:"邮箱号"`
  14. CompanyId int `description:"公司ID"`
  15. CompanyName string `description:"公司名称"`
  16. IsMeeting int `description:"是否到会 1.是 ,0否"`
  17. IsAirborne int `description:"是否属于空降 1.是 ,0否"`
  18. }
  19. type CygxActivitySpecialMeetingDetailResp struct {
  20. Id int `description:"id"`
  21. UserId int `description:"用户id"`
  22. ActivityId int `description:"活动ID"`
  23. CreateTime string `description:"创建时间"`
  24. RealName string `description:"姓名"`
  25. Email string `description:"邮箱号"`
  26. CompanyId int `description:"公司ID"`
  27. CompanyName string `description:"公司名称"`
  28. IsMeeting int `description:"到会类型 1.是 ,0否 ,2空降"`
  29. IsAirborne int `description:"是否属于空降 1.是 ,0否"`
  30. Operation bool `description:"操作按钮,true,到会,false 未到会"`
  31. }
  32. type SpecialMeetingDetailRespList struct {
  33. List []*CygxActivitySpecialMeetingDetailResp
  34. }
  35. type MeetingSpeciaDoRep struct {
  36. UserIds string `description:"用户ID,多个ID用 , 隔开"`
  37. ActivityId int `description:"活动ID"`
  38. }
  39. //列表
  40. func GetCygxActivitySpecialMeetingDetailListByActivity(activityId int) (items []*CygxActivitySpecialMeetingDetailResp, err error) {
  41. o := orm.NewOrm()
  42. sql := `SELECT s.* , u.real_name
  43. FROM cygx_activity_special_meeting_detail as s
  44. INNER JOIN wx_user as u ON u.user_id = s.user_id WHERE 1 =1 AND s.activity_id =? `
  45. _, err = o.Raw(sql, activityId).QueryRows(&items)
  46. return
  47. }
  48. //到会操作
  49. func MeetingDopecialMeet(meetingUids, noMeetingUids string, ActivityId int, items []*CygxActivitySpecialMeetingDetail) (err error) {
  50. o := orm.NewOrm()
  51. to, err := o.Begin()
  52. if err != nil {
  53. return
  54. }
  55. defer func() {
  56. if err != nil {
  57. fmt.Println(err)
  58. _ = to.Rollback()
  59. } else {
  60. _ = to.Commit()
  61. }
  62. }()
  63. fmt.Println("ActivityId", ActivityId)
  64. //修改报名表的参会记录
  65. sql := `UPDATE cygx_activity_special_trip SET is_meeting = 0 WHERE activity_id =? `
  66. _, err = to.Raw(sql, ActivityId).Exec()
  67. if err != nil {
  68. return
  69. }
  70. sql = `UPDATE cygx_activity_special_trip SET is_meeting = 1 WHERE activity_id =? AND is_cancel = 0 AND user_id IN (` + meetingUids + `)`
  71. _, err = to.Raw(sql, ActivityId).Exec()
  72. if err != nil {
  73. return
  74. }
  75. sql = `UPDATE cygx_activity_special SET is_submit_meeting = 1 WHERE activity_id = ? `
  76. _, err = to.Raw(sql, ActivityId).Exec()
  77. if err != nil {
  78. return
  79. }
  80. //删除老的记录并插入新的记录
  81. sql = `DELETE FROM cygx_activity_special_meeting_detail WHERE activity_id = ? `
  82. _, err = to.Raw(sql, ActivityId).Exec()
  83. if err != nil {
  84. return
  85. }
  86. for _, v := range items {
  87. _, err = to.Insert(v)
  88. if err != nil {
  89. return
  90. }
  91. }
  92. if len(noMeetingUids) > 0 {
  93. sql = `UPDATE cygx_activity_special_meeting_detail SET is_meeting = 0 WHERE activity_id =? AND user_id IN (` + noMeetingUids + `)`
  94. _, err = to.Raw(sql, ActivityId).Exec()
  95. if err != nil {
  96. return
  97. }
  98. }
  99. //添加记录表的到会信息
  100. sql = `UPDATE cygx_activity_special_meeting_detail SET is_meeting = 1 WHERE activity_id =? AND user_id IN (` + meetingUids + `)`
  101. _, err = to.Raw(sql, ActivityId).Exec()
  102. if err != nil {
  103. return
  104. }
  105. return
  106. }
  107. //列表
  108. func GetCygxActivitySpecialMeetingDetailList(condition string, pars []interface{}) (items []*CygxActivitySpecialMeetingDetail, err error) {
  109. o := orm.NewOrm()
  110. sql := `SELECT s.*
  111. FROM cygx_activity_special_meeting_detail as s WHERE 1 =1 ` + condition
  112. _, err = o.Raw(sql, pars).QueryRows(&items)
  113. return
  114. }
  115. func GetCygxActivitySpecialMeetingDetailListByActivityId(activityId int) (item []*CygxActivitySpecialMeetingDetail, err error) {
  116. o := orm.NewOrm()
  117. sql := `SELECT *
  118. FROM
  119. cygx_activity_special_trip
  120. WHERE activity_id = ? AND is_cancel = 0 `
  121. _, err = o.Raw(sql, activityId).QueryRows(&item)
  122. return
  123. }