|
@@ -0,0 +1,168 @@
|
|
|
+package models
|
|
|
+
|
|
|
+import (
|
|
|
+ "fmt"
|
|
|
+ "rdluck_tools/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:"职位"`
|
|
|
+}
|
|
|
+
|
|
|
+//添加会议提醒信息
|
|
|
+func AddCygxActivityAttendanceDetail(item *CygxActivityAttendanceDetail) (lastId int64, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ o.Begin()
|
|
|
+ defer func() {
|
|
|
+ fmt.Println(err)
|
|
|
+ if err == nil {
|
|
|
+ o.Commit()
|
|
|
+ } else {
|
|
|
+ o.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(endDate string) (list []*RoadshowData, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ o.Using("comein_data")
|
|
|
+ sql := `SELECT * FROM roadshow_data WHERE roadshow_title LIKE '%化学发光自身免疫产品&流水线市场情况%'`
|
|
|
+
|
|
|
+ _, err = o.Raw(sql).QueryRows(&list)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+type WxUserOutboundMobile struct {
|
|
|
+ CompanyId int `description:"公司ID"`
|
|
|
+ OutboundMobile string `description:"外呼手机号"`
|
|
|
+}
|
|
|
+
|
|
|
+func GetWxUserOutboundMobile(mobileStr string) (item []*WxUserOutboundMobile, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := `SELECT * FROM wx_user WHERE mobile IN (` + mobileStr + `)`
|
|
|
+ _, err = o.Raw(sql).QueryRows(&item)
|
|
|
+ return
|
|
|
+}
|