Browse Source

fix:进门财经

Roc 2 years ago
parent
commit
c0843de226
2 changed files with 179 additions and 0 deletions
  1. 102 0
      models/yb/comein_event.go
  2. 77 0
      models/yb/comein_event_user.go

+ 102 - 0
models/yb/comein_event.go

@@ -0,0 +1,102 @@
+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
+		}
+
+	}
+}

+ 77 - 0
models/yb/comein_event_user.go

@@ -0,0 +1,77 @@
+package yb
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+// ComeinEventUser 进门会议用户表
+type ComeinEventUser struct {
+	ComeinUserId     int       `orm:"column(comein_user_id);pk" description:"自增id"`
+	ComeinEventId    int       `orm:"column(comein_event_id)" description:"活动与进门会议的关系id"`
+	ComeinDataId     int       `orm:"column(comein_data_id)" description:"进门会议的数据id,用作数据去重"`
+	UserId           int       `description:"用户id"`
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	Name             string    `description:"姓名"`
+	FirstWatchTime   time.Time `description:"首次入会时间"`
+	LastWatchTime    time.Time `description:"最后退出会议时间"`
+	JoinTime         int       `description:"会议参与时长"`
+	AuthInfo         string    `description:"用户参与鉴权"`
+	JoinType         int       `description:"参与方式 1:网络 2:电话"`
+	DataType         int       `description:"数据类型,1:直播 2:回放"`
+	RegisterTime     time.Time `description:"用户注册时间"`
+	ViewTotal        int       `description:"报告累计阅读次数"`
+	LastViewTime     time.Time `description:"报告最近一次阅读时间"`
+	CompanyId        int       `description:"客户id"`
+	ProductId        int       `description:"产品id"`
+	CompanyName      string    `description:"客户名称"`
+	Occupation       string    `description:"职位"`
+	Status           string    `description:"客户产品状态"`
+	SellerId         int       `description:"所属销售id"`
+	SellerName       string    `description:"所属销售名称"`
+	CompanyViewTotal int       `description:"客户总计阅读次数"`
+	CompanyRoadTotal int       `description:"客户路演次数"`
+	CreateTime       time.Time `description:"记录创建时间"`
+}
+
+// TableName 表名变更
+func (comeinEventUserInfo *ComeinEventUser) TableName() string {
+	return "comein_event_user"
+}
+
+// AddComeinEventUser 新增进门会议用户
+func AddComeinEventUser(comeinEventUserInfo *ComeinEventUser) (err error) {
+	o := orm.NewOrm()
+	id, err := o.Insert(comeinEventUserInfo)
+	if err != nil {
+		return
+	}
+	comeinEventUserInfo.ComeinUserId = int(id)
+	return
+}
+
+// GetQsUserList 获取到会用户列表数据
+func GetComeinUserList(condition string, pars []interface{}, startSize, pageSize int) (total int, list []*ComeinEventUser, err error) {
+	o := orm.NewOrm()
+	sql := "select * from comein_event_user a where 1=1 "
+	sql += condition
+	sql += ` order by a.comein_user_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
+}
+
+// GetComeinEventUserByComeinDataId 根据进门会议的数据id获取记录
+func GetComeinEventUserByComeinDataId(comeinId int) (item *ComeinEventUser, err error) {
+	o := orm.NewOrm()
+	sql := "select * from comein_event_user where comein_data_id=? "
+	err = o.Raw(sql, comeinId).QueryRow(&item)
+	return
+}