123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- package models
- import (
- "fmt"
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CygxActivityAttendanceDetail struct {
- AttendanceId int `orm:"column(attendance_id);pk;"description:"主键ID"`
- ActivityId int `description:"活动ID"`
- RealName string `description:"姓名"`
- Mobile string `description:"手机号"`
- CompanyName string `description:"公司名称"`
- CompanyId int `description:"公司id 不在数据库的用户为0"`
- SellerName string `description:"销售姓名"`
- FirstMeetingTime string `description:"首次入会时间"`
- LastMeetingTime string `description:"最后退出时间"`
- Duration string `description:"参会时长"`
- MeetingTypeStr string `description:"参会方式"`
- MeetingAuthentication string `description:"参会权鉴"`
- MeetingStatusStr string `description:"参会状态"`
- CreateTime time.Time `description:"创建时间"`
- Position string `description:"职位"`
- IsMeetingStr int `description:"是否到会,1到会,0未到会"`
- }
- //添加会议提醒信息
- func AddCygxActivityAttendanceDetail(item *CygxActivityAttendanceDetail) (lastId int64, err error) {
- o := orm.NewOrm()
- tx, err := o.Begin()
- //o.Begin()
- //defer func() {
- // fmt.Println(err)
- // if err == nil {
- // o.C
- // } else {
- // o.Rollback()
- // }
- //}()
- defer func() {
- fmt.Println(err)
- if err == nil {
- tx.Commit()
- } else {
- tx.Rollback()
- }
- }()
- var count int
- var countMySchedule int
- sql := `SELECT COUNT(1) AS count FROM cygx_my_schedule WHERE user_id=? AND activity_id=? `
- err = o.Raw(sql, item, item.ActivityId).QueryRow(&countMySchedule)
- if err != nil {
- return
- }
- if countMySchedule == 0 {
- itemMy := new(CygxMySchedule)
- itemMy.ActivityId = item.ActivityId
- itemMy.CreateTime = time.Now()
- itemMy.Mobile = item.Mobile
- itemMy.CompanyId = item.CompanyId
- itemMy.CompanyName = item.CompanyName
- lastId, err = o.Insert(itemMy)
- if err != nil {
- return
- }
- }
- sql = `SELECT COUNT(1) AS count FROM cygx_activity_meeting_reminder WHERE user_id=? AND activity_id=? `
- err = o.Raw(sql, item, item.ActivityId).QueryRow(&count)
- if err != nil {
- return
- }
- if count > 0 {
- sql := `UPDATE cygx_activity_meeting_reminder SET is_cancel = 0 WHERE user_id=? AND activity_id=? `
- _, err = o.Raw(sql, item, item.ActivityId).Exec()
- } else {
- lastId, err = o.Insert(item)
- }
- itemLog := new(CygxActivityMeetingReminderLog)
- //itemLog.UserId = item.UserId
- itemLog.ActivityId = item.ActivityId
- itemLog.CreateTime = time.Now()
- itemLog.Mobile = item.Mobile
- //itemLog.Email = item.Email
- itemLog.CompanyId = item.CompanyId
- itemLog.CompanyName = item.CompanyName
- itemLog.Type = 1
- lastId, err = o.Insert(itemLog)
- return
- }
- type RoadshowData struct {
- Id int `orm:"column(id);pk;"description:"主键ID"`
- Company string `description:"公司名称"`
- UserName string `description:"用户名"`
- UserPhone string `description:"手机号"`
- UserinfoUource string `description:"用户来源"`
- AuthInfo string `description:"用户参会鉴权"`
- GuestUsername string `description:"嘉宾名称, 多个用,隔开"`
- FirstWatchTime string `description:"首次观看时间"`
- LastWatchTime string `description:"最后观看时间"`
- RoadshowId string `description:"路演ID"`
- RoadshowTitle string `description:"路演标题"`
- RoadshowBeginTime time.Time `description:"路演开始时间"`
- RoadshowEndTime time.Time `description:"路演结束时间"`
- JoinTime int `description:"参与时长"`
- JoinType int `description:"参与方式, 1网络, 2电话"`
- DataType int `description:"数据类型: 1直播, 2回放"`
- Occupation string `description:"职位"`
- }
- func AddAttendancDetail(items []*CygxActivityAttendanceDetail, activityId int, mobileStr string) (err error) {
- o := orm.NewOrm()
- //o.Begin()
- //defer func() {
- // fmt.Println(err)
- // if err == nil {
- // o.Commit()
- // } else {
- // o.Rollback()
- // }
- //}()
- //修改活动是否上传到会信息字段
- sql := `UPDATE cygx_activity SET is_submit_meeting=1 WHERE activity_id=? `
- _, err = o.Raw(sql, activityId).Exec()
- if err != nil {
- return
- }
- //修改单个报名信息是否到会
- sql = `UPDATE cygx_activity_signup SET is_meeting=0 WHERE activity_id=? `
- _, err = o.Raw(sql, activityId).Exec()
- if err != nil {
- return
- }
- sql = `UPDATE cygx_activity_signup SET is_meeting=1 WHERE activity_id=? AND outbound_mobile IN (` + mobileStr + `)`
- _, err = o.Raw(sql, activityId).Exec()
- if err != nil {
- return
- }
- //二次上传时删除原有数据
- sql = ` DELETE FROM cygx_activity_attendance_detail WHERE activity_id = ?`
- _, err = o.Raw(sql, activityId).Exec()
- if err != nil {
- return
- }
- //插入提交信息
- for _, v := range items {
- _, err = o.Insert(v)
- if err != nil {
- return
- }
- }
- return
- }
- //获取用户报名数量
- func GetRoadshowDataList(title, findStartDate, findEndDate string) (list []*RoadshowData, err error) {
- //o := orm.NewOrm()
- o := orm.NewOrmUsingDB("comein_data")
- //o.Using("comein_data")
- sql := `SELECT * FROM roadshow_data WHERE roadshow_title LIKE '%` + title + `%' AND roadshow_begin_time >= '` + findStartDate + `' AND roadshow_begin_time <= '` + findEndDate + `'`
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- type WxUserOutboundMobile struct {
- RealName string `description:"姓名"`
- Mobile string `description:"手机号"`
- OutboundMobile string `description:"外呼手机号"`
- CompanyId int `description:"公司ID"`
- CompanyName string `description:"公司名称"`
- SellerName string `description:"所属销售"`
- }
- func GetWxUserOutboundMobile(mobileStr string) (item []*WxUserOutboundMobile, err error) {
- o := orm.NewOrm()
- sql := `SELECT u.real_name,u.mobile,u.outbound_mobile,u.company_id,p.company_name ,GROUP_CONCAT( DISTINCT p.seller_name SEPARATOR '/' ) AS seller_name
- FROM wx_user as u
- INNER JOIN company_product AS p ON p.company_id = u.company_id
- WHERE outbound_mobile IN (` + mobileStr + `) GROUP BY u.user_id`
- _, err = o.Raw(sql).QueryRows(&item)
- return
- }
|