activity_special_meeting_detail.go 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. RealName string `description:"真实姓名"`
  19. }
  20. type CygxActivitySpecialMeetingDetailResp struct {
  21. Id int `description:"id"`
  22. UserId int `description:"用户id"`
  23. ActivityId int `description:"活动ID"`
  24. CreateTime string `description:"创建时间"`
  25. RealName string `description:"姓名"`
  26. Email string `description:"邮箱号"`
  27. CompanyId int `description:"公司ID"`
  28. CompanyName string `description:"公司名称"`
  29. IsMeeting int `description:"到会类型 1.是 ,0否 ,2空降"`
  30. IsAirborne int `description:"是否属于空降 1.是 ,0否"`
  31. Operation bool `description:"操作按钮,true,到会,false 未到会"`
  32. }
  33. type SpecialMeetingDetailRespList struct {
  34. List []*CygxActivitySpecialMeetingDetailResp
  35. }
  36. type MeetingSpeciaDoRep struct {
  37. UserIds string `description:"用户ID,多个ID用 , 隔开"`
  38. ActivityId int `description:"活动ID"`
  39. }
  40. // 列表
  41. func GetCygxActivitySpecialMeetingDetailListByActivity(activityId int) (items []*CygxActivitySpecialMeetingDetailResp, err error) {
  42. o := orm.NewOrmUsingDB("hz_cygx")
  43. sql := `SELECT s.*
  44. FROM cygx_activity_special_meeting_detail as s
  45. WHERE 1 =1 AND s.activity_id =? `
  46. _, err = o.Raw(sql, activityId).QueryRows(&items)
  47. return
  48. }
  49. // 到会操作
  50. func MeetingDopecialMeet(meetingUids, noMeetingUids string, ActivityId int, items []*CygxActivitySpecialMeetingDetail, itemsBill []*CygxActivitySpecialTripBill) (err error) {
  51. o := orm.NewOrmUsingDB("hz_cygx")
  52. to, err := o.Begin()
  53. if err != nil {
  54. return
  55. }
  56. defer func() {
  57. if err != nil {
  58. fmt.Println(err)
  59. _ = to.Rollback()
  60. } else {
  61. _ = to.Commit()
  62. }
  63. }()
  64. fmt.Println("ActivityId", ActivityId)
  65. //修改报名表的参会记录
  66. sql := `UPDATE cygx_activity_special_trip SET is_meeting = 0 WHERE activity_id =? `
  67. _, err = to.Raw(sql, ActivityId).Exec()
  68. if err != nil {
  69. return
  70. }
  71. sql = `UPDATE cygx_activity_special_trip SET is_meeting = 1 WHERE activity_id =? AND is_cancel = 0 AND user_id IN (` + meetingUids + `)`
  72. _, err = to.Raw(sql, ActivityId).Exec()
  73. if err != nil {
  74. return
  75. }
  76. sql = `UPDATE cygx_activity_special SET is_submit_meeting = 1 WHERE activity_id = ? `
  77. _, err = to.Raw(sql, ActivityId).Exec()
  78. if err != nil {
  79. return
  80. }
  81. //删除老的记录并插入新的记录
  82. sql = `DELETE FROM cygx_activity_special_meeting_detail WHERE activity_id = ? `
  83. _, err = to.Raw(sql, ActivityId).Exec()
  84. if err != nil {
  85. return
  86. }
  87. for _, v := range items {
  88. _, err = to.Insert(v)
  89. if err != nil {
  90. return
  91. }
  92. }
  93. if len(noMeetingUids) > 0 {
  94. sql = `UPDATE cygx_activity_special_meeting_detail SET is_meeting = 0 WHERE activity_id =? AND user_id IN (` + noMeetingUids + `)`
  95. _, err = to.Raw(sql, ActivityId).Exec()
  96. if err != nil {
  97. return
  98. }
  99. }
  100. //添加记录表的到会信息
  101. sql = `UPDATE cygx_activity_special_meeting_detail SET is_meeting = 1 WHERE activity_id =? AND user_id IN (` + meetingUids + `)`
  102. _, err = to.Raw(sql, ActivityId).Exec()
  103. if err != nil {
  104. return
  105. }
  106. //添加到会扣点流水记录
  107. if len(itemsBill) > 0 {
  108. for _, v := range itemsBill {
  109. _, err = to.Insert(v)
  110. if err != nil {
  111. return
  112. }
  113. }
  114. }
  115. return
  116. }
  117. // 列表
  118. func GetCygxActivitySpecialMeetingDetailList(condition string, pars []interface{}) (items []*CygxActivitySpecialMeetingDetail, err error) {
  119. o := orm.NewOrmUsingDB("hz_cygx")
  120. sql := `SELECT s.*
  121. FROM cygx_activity_special_meeting_detail as s WHERE 1 =1 ` + condition
  122. _, err = o.Raw(sql, pars).QueryRows(&items)
  123. return
  124. }
  125. func GetCygxActivitySpecialMeetingDetailListByActivityId(activityId int) (item []*CygxActivitySpecialMeetingDetail, err error) {
  126. o := orm.NewOrmUsingDB("hz_cygx")
  127. sql := `SELECT *
  128. FROM
  129. cygx_activity_special_trip
  130. WHERE activity_id = ? AND is_cancel = 0 `
  131. _, err = o.Raw(sql, activityId).QueryRows(&item)
  132. return
  133. }
  134. // 列表
  135. func UpdateCygxActivitySpecialMeetingDetailRealName(realName, mobile string) (err error) {
  136. o := orm.NewOrmUsingDB("hz_cygx")
  137. //添加记录表的到会信息
  138. sql := `UPDATE cygx_activity_special_meeting_detail SET real_name = ? WHERE mobile = ? `
  139. _, err = o.Raw(sql, realName, mobile).Exec()
  140. return
  141. }
  142. // 添加
  143. func AddCygxActivitySpecialMeetingDetail(item *CygxActivitySpecialMeetingDetail) (err error) {
  144. o := orm.NewOrmUsingDB("hz_cygx")
  145. _, err = o.Insert(item)
  146. return
  147. }