|
@@ -27,7 +27,11 @@ func GetOfflineMeetingDetailListCompanyIdStr(companyIdStr string) (item []*CygxA
|
|
|
|
|
|
func GetOfflineMeetingDetailListCompanyName(companyName string) (item []*CygxActivityMeetDetailLog, err error) {
|
|
func GetOfflineMeetingDetailListCompanyName(companyName string) (item []*CygxActivityMeetDetailLog, err error) {
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
- sql := `SELECT * FROM cygx_activity_meet_detail_log WHERE company_name IN (` + companyName + `)`
|
|
|
|
|
|
+ sql := `SELECT l.*
|
|
|
|
+ FROM
|
|
|
|
+ cygx_activity_meet_detail_log AS l INNER JOIN company AS c ON c.company_name = l.company_name
|
|
|
|
+ WHERE
|
|
|
|
+ l.company_name IN (` + companyName + `) GROUP BY l.company_name`
|
|
_, err = o.Raw(sql).QueryRows(&item)
|
|
_, err = o.Raw(sql).QueryRows(&item)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -41,7 +45,11 @@ func AddCygxActivityMeetDetailLog(item *CygxActivityMeetDetailLog) (lastId int64
|
|
|
|
|
|
func GetActivityMeetDetailLog(mobileStr string) (item []*CygxActivityMeetDetailLog, err error) {
|
|
func GetActivityMeetDetailLog(mobileStr string) (item []*CygxActivityMeetDetailLog, err error) {
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
- sql := `SELECT * FROM cygx_activity_meet_detail_log WHERE mobile IN (` + mobileStr + `)`
|
|
|
|
|
|
+ sql := `SELECT l.*
|
|
|
|
+ FROM
|
|
|
|
+ cygx_activity_meet_detail_log as l
|
|
|
|
+ INNER JOIN wx_user as u ON u.outbound_mobile = l.mobile
|
|
|
|
+ WHERE l.mobile IN (` + mobileStr + `) GROUP BY l.mobile `
|
|
_, err = o.Raw(sql).QueryRows(&item)
|
|
_, err = o.Raw(sql).QueryRows(&item)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -80,7 +88,7 @@ func UpdateActivityMeetDetailLogByUser(mobile string, num int) (err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
-//添加线上到会记录
|
|
|
|
|
|
+//添加线上到会记录(下载使用)
|
|
func AddCygxActivityMeetDetailLogOnline(list []*CygxActivityAttendanceDetail, activityId int) (err error) {
|
|
func AddCygxActivityMeetDetailLogOnline(list []*CygxActivityAttendanceDetail, activityId int) (err error) {
|
|
o, err := orm.NewOrm().Begin()
|
|
o, err := orm.NewOrm().Begin()
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -117,13 +125,92 @@ func AddCygxActivityMeetDetailLogOnline(list []*CygxActivityAttendanceDetail, ac
|
|
}
|
|
}
|
|
CompanyName = strings.TrimRight(CompanyName, ",")
|
|
CompanyName = strings.TrimRight(CompanyName, ",")
|
|
MobileStr = strings.TrimRight(MobileStr, ",")
|
|
MobileStr = strings.TrimRight(MobileStr, ",")
|
|
- for _, v := range items {
|
|
|
|
- _, err = o.Insert(v)
|
|
|
|
|
|
+ _, err = o.InsertMulti(1, items)
|
|
|
|
+ listCompany, err := GetOfflineMeetingDetailListCompanyName(CompanyName)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //修改公司对应的数量
|
|
|
|
+ var condition string
|
|
|
|
+ for _, v := range listCompany {
|
|
|
|
+ var total int
|
|
|
|
+ condition = ` AND company_name = '` + v.CompanyName + `' `
|
|
|
|
+ total, err = GetActivityMeetDetailLogCount(condition)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ sql := ` UPDATE cygx_activity_meet_detail_log SET company_meet_num= ? WHERE company_name = ?`
|
|
|
|
+ _, err = o.Raw(sql, total, v.CompanyName).Exec()
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ listMobile, err := GetActivityMeetDetailLog(MobileStr)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //修改个人对应的数量
|
|
|
|
+ for _, v := range listMobile {
|
|
|
|
+ var total int
|
|
|
|
+ condition = ` AND mobile = '` + v.Mobile + `' `
|
|
|
|
+ total, err = GetActivityMeetDetailLogCount(condition)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ sql := ` UPDATE cygx_activity_meet_detail_log SET user_meet_num= ? WHERE mobile = ?`
|
|
|
|
+ _, err = o.Raw(sql, total, v.Mobile).Exec()
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+//添加线上到会记录
|
|
|
|
+func AddCygxActivityMeetDetailLogOnlineByList(list []*CygxActivityAttendanceDetail, activityIds string) (err error) {
|
|
|
|
+ o, err := orm.NewOrm().Begin()
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ defer func() {
|
|
|
|
+ fmt.Println(err)
|
|
|
|
+ if err == nil {
|
|
|
|
+ o.Commit()
|
|
|
|
+ } else {
|
|
|
|
+ o.Rollback()
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
+ var CompanyName string
|
|
|
|
+ var MobileStr string
|
|
|
|
+ var items []*CygxActivityMeetDetailLog
|
|
|
|
+ //删除原有数据
|
|
|
|
+ sql := ` DELETE FROM cygx_activity_meet_detail_log WHERE activity_id IN (` + activityIds + `)`
|
|
|
|
+ _, err = o.Raw(sql).Exec()
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //插入新的数据
|
|
|
|
+ for _, v := range list {
|
|
|
|
+ item := new(CygxActivityMeetDetailLog)
|
|
|
|
+ item.ActivityId = v.ActivityId
|
|
|
|
+ item.Mobile = v.Mobile
|
|
|
|
+ fmt.Println(v.CompanyName)
|
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
|
+ item.CompanyId = v.CompanyId
|
|
|
|
+ item.CreateTime = v.CreateTime
|
|
|
|
+ if strings.Index(CompanyName, v.CompanyName) == -1 && v.CompanyName != "" {
|
|
|
|
+ CompanyName += "'" + v.CompanyName + "',"
|
|
|
|
+ }
|
|
|
|
+ if strings.Index(MobileStr, v.Mobile) == -1 && v.Mobile != "" {
|
|
|
|
+ MobileStr += v.Mobile + ","
|
|
|
|
+ }
|
|
|
|
+ items = append(items, item)
|
|
|
|
+ }
|
|
|
|
+ CompanyName = strings.TrimRight(CompanyName, ",")
|
|
|
|
+ MobileStr = strings.TrimRight(MobileStr, ",")
|
|
|
|
+ _, err = o.InsertMulti(1, items)
|
|
listCompany, err := GetOfflineMeetingDetailListCompanyName(CompanyName)
|
|
listCompany, err := GetOfflineMeetingDetailListCompanyName(CompanyName)
|
|
|
|
+ fmt.Println("公司数量", len(listCompany))
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -138,11 +225,13 @@ func AddCygxActivityMeetDetailLogOnline(list []*CygxActivityAttendanceDetail, ac
|
|
}
|
|
}
|
|
sql := ` UPDATE cygx_activity_meet_detail_log SET company_meet_num= ? WHERE company_name = ?`
|
|
sql := ` UPDATE cygx_activity_meet_detail_log SET company_meet_num= ? WHERE company_name = ?`
|
|
_, err = o.Raw(sql, total, v.CompanyName).Exec()
|
|
_, err = o.Raw(sql, total, v.CompanyName).Exec()
|
|
|
|
+ fmt.Println("处理公司", v.CompanyName)
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
listMobile, err := GetActivityMeetDetailLog(MobileStr)
|
|
listMobile, err := GetActivityMeetDetailLog(MobileStr)
|
|
|
|
+ fmt.Println("用户数量", len(listMobile))
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -156,9 +245,11 @@ func AddCygxActivityMeetDetailLogOnline(list []*CygxActivityAttendanceDetail, ac
|
|
}
|
|
}
|
|
sql := ` UPDATE cygx_activity_meet_detail_log SET user_meet_num= ? WHERE mobile = ?`
|
|
sql := ` UPDATE cygx_activity_meet_detail_log SET user_meet_num= ? WHERE mobile = ?`
|
|
_, err = o.Raw(sql, total, v.Mobile).Exec()
|
|
_, err = o.Raw(sql, total, v.Mobile).Exec()
|
|
|
|
+ fmt.Println("处理用户", v.Mobile)
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ fmt.Println("user_end")
|
|
return
|
|
return
|
|
}
|
|
}
|