comein_event.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package yb
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // ComeinEvent 全时会议表
  7. type ComeinEvent struct {
  8. ComeinEventId int `orm:"column(comein_event_id);pk" description:"自增id"`
  9. RoadshowId int `description:"路演ID"`
  10. ConferenceId string `description:"电话会议ID"`
  11. Title string `description:"活动标题"`
  12. StartTime time.Time `description:"路演开始时间"`
  13. EndTime time.Time `description:"路演结束时间"`
  14. People int `description:"实际入会人数"`
  15. CreateTime time.Time `description:"创建时间"`
  16. }
  17. // TableName 表名变更
  18. func (comeinEventInfo *ComeinEvent) TableName() string {
  19. return "comein_event"
  20. }
  21. // GetComeinEventByRoadshowId 根据进门会议的路演id获取进门会议(已同步)
  22. func GetComeinEventByRoadshowId(comeinId int) (item *ComeinEvent, err error) {
  23. o := orm.NewOrm()
  24. sql := "select * from comein_event where roadshow_id=? "
  25. err = o.Raw(sql, comeinId).QueryRow(&item)
  26. return
  27. }
  28. // Update 更新进门会议
  29. func (comeinEventInfo *ComeinEvent) Update(cols []string) (err error) {
  30. o := orm.NewOrm()
  31. _, err = o.Update(comeinEventInfo, cols...)
  32. return
  33. }
  34. // AddComeinEvent 新增进门会议
  35. func AddComeinEvent(comeinEvent *ComeinEvent) (err error) {
  36. o := orm.NewOrm()
  37. id, err := o.Insert(comeinEvent)
  38. if err != nil {
  39. return
  40. }
  41. comeinEvent.ComeinEventId = int(id)
  42. return
  43. }
  44. // GetComeinList 获取进门列表数据
  45. func GetComeinList(condition string, pars []interface{}, startSize, pageSize int) (total int, list []*ComeinEvent, err error) {
  46. o := orm.NewOrm()
  47. sql := "select a.* from comein_event a " +
  48. " where 1=1 "
  49. sql += condition
  50. sql += ` order by a.start_time DESC,comein_event_id desc `
  51. totalSql := `select count(1) total from (` + sql + `) z `
  52. err = o.Raw(totalSql, pars).QueryRow(&total)
  53. if err != nil {
  54. return
  55. }
  56. sql += ` LIMIT ?,? `
  57. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
  58. return
  59. }
  60. // AddComeinEventAndUser 添加进门活动和用户
  61. func AddComeinEventAndUser(comeinEventInfo *ComeinEvent, userList []*ComeinEventUser) {
  62. o := orm.NewOrm()
  63. to, err := o.Begin()
  64. if err != nil {
  65. return
  66. }
  67. defer func() {
  68. if err != nil {
  69. _ = to.Rollback()
  70. } else {
  71. _ = to.Commit()
  72. }
  73. }()
  74. id, err := to.Insert(comeinEventInfo)
  75. if err != nil {
  76. return
  77. }
  78. comeinEventInfo.ComeinEventId = int(id)
  79. // 联系人入库
  80. if len(userList) > 0 {
  81. for _, v := range userList {
  82. v.ComeinEventId = comeinEventInfo.ComeinEventId
  83. }
  84. _, tmpErr := to.InsertMulti(len(userList), userList)
  85. if tmpErr != nil {
  86. err = tmpErr
  87. return
  88. }
  89. }
  90. }
  91. type ComeinResponse struct {
  92. Code string `json:"code"`
  93. Data string `json:"data"`
  94. ErrorCode string `json:"errorcode"`
  95. ErrorDesc string `json:"errordesc"`
  96. Msg string `json:"msg"`
  97. TipType string `json:"tipType"`
  98. }
  99. type Whitelist struct {
  100. Guid string `json:"guid"`
  101. Phone string `json:"phone"`
  102. Email string `json:"email"`
  103. Areacode string `json:"areacode"`
  104. }
  105. type SyncWhitelist struct {
  106. Opt int `json:"opt"`
  107. Timestamp string `json:"timestamp"`
  108. AppID string `json:"appId"`
  109. Signature string `json:"signature"`
  110. Whitelist []Whitelist `json:"whitelist"`
  111. }
  112. type GetWhitelist struct {
  113. Ts string `json:"ts"`
  114. AppID string `json:"appId"`
  115. Signature string `json:"signature"`
  116. }