activity_signup_detail.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxActivitySignupDetail struct {
  7. Id int `orm:"column(id);pk"`
  8. ActivityId int `description:"活动ID"`
  9. UserId int `description:"用户ID"`
  10. CreateTime time.Time `description:"创建时间"`
  11. Mobile string `description:"手机号"`
  12. Email string `description:"邮箱"`
  13. CompanyId int `description:"公司id"`
  14. CompanyName string `description:"公司名称"`
  15. FailType int `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
  16. SignupType int `description:"报名方式,1预约外呼,2自主拨入,3我要报名"`
  17. DoFailType int `description:"失败原因,0,未失败,1总人数已满,2单机构超限制,3,爽约次数超限"`
  18. OutboundMobile string `description:"外呼手机号"`
  19. CountryCode string `description:"手机国家区号"`
  20. RealName string `description:"用户实际名称"`
  21. SellerName string `description:"所属销售"`
  22. FirstMeetingTime string `description:"首次入会时间"`
  23. LastMeetingTime string `description:"最后退出时间"`
  24. Duration string `description:"参会时长"`
  25. MeetingTypeStr string `description:"参会方式"`
  26. MeetingAuthentication string `description:"参会权鉴"`
  27. MeetingStatusStr string `description:"参会状态"`
  28. Position string `description:"职位"`
  29. IsMeeting int `description:"是否到会,1到会,0未到会"`
  30. UseridEntity int `description:"参会者身份. 1:主讲人, 2:主持人, 3:嘉宾, 4:普通参会者, 5:联席主讲人, 6:会议助理"`
  31. ActivityTime string `description:"活动时间"`
  32. CrmCompanyMapStatusId int `description:"转换后的对应状态信息:1=正式客户, 2=曾使用客户, 3=其他"`
  33. }
  34. // 获取今天报名的用户信息,存入到参会记录表中
  35. func GetSignupDetailBySignup(condition string, pars []interface{}) (list []*CygxActivitySignupDetail, err error) {
  36. o := orm.NewOrmUsingDB("hz_cygx")
  37. sql := `SELECT * FROM cygx_activity_signup WHERE 1= 1 `
  38. if condition != "" {
  39. sql += condition
  40. }
  41. _, err = o.Raw(sql, pars).QueryRows(&list)
  42. return
  43. }
  44. // 获取参会记录表列表
  45. func GetSignupDetailList(condition string, pars []interface{}) (list []*CygxActivitySignupDetail, err error) {
  46. o := orm.NewOrmUsingDB("hz_cygx")
  47. sql := `SELECT * FROM cygx_activity_signup_detail WHERE 1= 1 `
  48. if condition != "" {
  49. sql += condition
  50. }
  51. _, err = o.Raw(sql, pars).QueryRows(&list)
  52. return
  53. }
  54. // 添加
  55. func AddCygxActivitySignupDetail(items []*CygxActivitySignupDetail) (err error) {
  56. o, err := orm.NewOrmUsingDB("hz_cygx").Begin()
  57. if err != nil {
  58. return
  59. }
  60. defer func() {
  61. if err == nil {
  62. o.Commit()
  63. } else {
  64. o.Rollback()
  65. }
  66. }()
  67. if len(items) > 0 {
  68. //批量添加
  69. _, err = o.InsertMulti(len(items), items)
  70. if err != nil {
  71. return err
  72. }
  73. }
  74. return
  75. }
  76. // UpdateActivitySignupDetailMulti 批量修改用户报名信息且报名的人
  77. func UpdateActivitySignupDetailMulti(items []*CygxActivitySignupDetail) (err error) {
  78. o := orm.NewOrmUsingDB("hz_cygx")
  79. p, err := o.Raw(` UPDATE cygx_activity_signup_detail SET
  80. first_meeting_time = ?,
  81. last_meeting_time = ?,
  82. duration = ?,
  83. meeting_type_str = ?,
  84. meeting_authentication = ?,
  85. meeting_status_str = ?,
  86. position = ?,
  87. is_meeting = ?,
  88. userid_entity = ?,
  89. activity_time = ?,
  90. crm_company_map_status_id = ?
  91. WHERE mobile = ? AND activity_id = ? `).Prepare()
  92. if err != nil {
  93. return
  94. }
  95. defer func() {
  96. _ = p.Close() // 别忘记关闭 statement
  97. }()
  98. for _, v := range items {
  99. _, err = p.Exec(
  100. v.FirstMeetingTime,
  101. v.LastMeetingTime,
  102. v.Duration,
  103. v.MeetingTypeStr,
  104. v.MeetingAuthentication,
  105. v.MeetingStatusStr,
  106. v.Position,
  107. v.IsMeeting,
  108. v.UseridEntity,
  109. v.ActivityTime,
  110. v.CrmCompanyMapStatusId,
  111. v.Mobile, v.ActivityId)
  112. if err != nil {
  113. return
  114. }
  115. }
  116. return
  117. }
  118. // UpdateActivitySignupDetailMultiByYiDong 易董批量修改用户报名信息且报名的人
  119. func UpdateActivitySignupDetailMultiByYiDong(items []*CygxActivitySignupDetail) (err error) {
  120. o := orm.NewOrmUsingDB("hz_cygx")
  121. p, err := o.Raw(` UPDATE cygx_activity_signup_detail SET
  122. first_meeting_time = ?,
  123. last_meeting_time = ?,
  124. meeting_status_str = ?,
  125. position = ?,
  126. real_name = ?,
  127. duration = ?,
  128. is_meeting = ?
  129. WHERE mobile = ? AND activity_id = ? `).Prepare()
  130. if err != nil {
  131. return
  132. }
  133. defer func() {
  134. _ = p.Close() // 别忘记关闭 statement
  135. }()
  136. for _, v := range items {
  137. _, err = p.Exec(
  138. v.FirstMeetingTime,
  139. v.LastMeetingTime,
  140. v.MeetingStatusStr,
  141. v.Position,
  142. v.RealName,
  143. v.Duration,
  144. v.IsMeeting,
  145. v.Mobile, v.ActivityId)
  146. if err != nil {
  147. return
  148. }
  149. }
  150. return
  151. }