123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- package yb
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // ComeinEvent 全时会议表
- type ComeinEvent struct {
- ComeinEventId int `orm:"column(comein_event_id);pk" description:"自增id"`
- RoadshowId int `description:"路演ID"`
- ConferenceId string `description:"电话会议ID"`
- Title string `description:"活动标题"`
- StartTime time.Time `description:"路演开始时间"`
- EndTime time.Time `description:"路演结束时间"`
- People int `description:"实际入会人数"`
- CreateTime time.Time `description:"创建时间"`
- }
- // TableName 表名变更
- func (comeinEventInfo *ComeinEvent) TableName() string {
- return "comein_event"
- }
- // GetComeinEventByRoadshowId 根据进门会议的路演id获取进门会议(已同步)
- func GetComeinEventByRoadshowId(comeinId int) (item *ComeinEvent, err error) {
- o := orm.NewOrm()
- sql := "select * from comein_event where roadshow_id=? "
- err = o.Raw(sql, comeinId).QueryRow(&item)
- return
- }
- // Update 更新进门会议
- func (comeinEventInfo *ComeinEvent) Update(cols []string) (err error) {
- o := orm.NewOrm()
- _, err = o.Update(comeinEventInfo, cols...)
- return
- }
- // AddComeinEvent 新增进门会议
- func AddComeinEvent(comeinEvent *ComeinEvent) (err error) {
- o := orm.NewOrm()
- id, err := o.Insert(comeinEvent)
- if err != nil {
- return
- }
- comeinEvent.ComeinEventId = int(id)
- return
- }
- // GetComeinList 获取进门列表数据
- func GetComeinList(condition string, pars []interface{}, startSize, pageSize int) (total int, list []*ComeinEvent, err error) {
- o := orm.NewOrm()
- sql := "select a.* from comein_event a " +
- " where 1=1 "
- sql += condition
- sql += ` order by a.start_time DESC,comein_event_id desc `
- totalSql := `select count(1) total from (` + sql + `) z `
- err = o.Raw(totalSql, pars).QueryRow(&total)
- if err != nil {
- return
- }
- sql += ` LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
- return
- }
- // AddComeinEventAndUser 添加进门活动和用户
- func AddComeinEventAndUser(comeinEventInfo *ComeinEvent, userList []*ComeinEventUser) {
- o := orm.NewOrm()
- to, err := o.Begin()
- if err != nil {
- return
- }
- defer func() {
- if err != nil {
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- id, err := to.Insert(comeinEventInfo)
- if err != nil {
- return
- }
- comeinEventInfo.ComeinEventId = int(id)
- // 联系人入库
- if len(userList) > 0 {
- for _, v := range userList {
- v.ComeinEventId = comeinEventInfo.ComeinEventId
- }
- _, tmpErr := to.InsertMulti(len(userList), userList)
- if tmpErr != nil {
- err = tmpErr
- return
- }
- }
- }
- type ComeinResponse struct {
- Code string `json:"code"`
- Data string `json:"data"`
- ErrorCode string `json:"errorcode"`
- ErrorDesc string `json:"errordesc"`
- Msg string `json:"msg"`
- TipType string `json:"tipType"`
- }
- type Whitelist struct {
- Guid string `json:"guid"`
- Phone string `json:"phone"`
- Email string `json:"email"`
- Areacode string `json:"areacode"`
- }
- type SyncWhitelist struct {
- Opt int `json:"opt"`
- Timestamp string `json:"timestamp"`
- AppID string `json:"appId"`
- Signature string `json:"signature"`
- Whitelist []Whitelist `json:"whitelist"`
- }
- type GetWhitelist struct {
- Ts string `json:"ts"`
- AppID string `json:"appId"`
- Signature string `json:"signature"`
- }
|