浏览代码

进门财经数据同步

xingzai 3 年之前
父节点
当前提交
2143cebfbc
共有 7 个文件被更改,包括 417 次插入103 次删除
  1. 1 1
      models/activity.go
  2. 12 4
      models/activity_attendance_detail.go
  3. 93 24
      models/activity_meet_detail_log.go
  4. 134 0
      models/activity_signup.go
  5. 4 3
      models/db.go
  6. 156 69
      services/activity.go
  7. 17 2
      utils/common.go

+ 1 - 1
models/activity.go

@@ -186,7 +186,7 @@ func GetActivityListAll(condition string, pars []interface{}, uid, startSize, pa
 //列表
 func GetActivityListByDateTime(startDate, endDate string) (items []*CygxActivityList, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_activity WHERE activity_time > '` + startDate + `' AND activity_time < '` + endDate + `' AND is_submit_meeting = 0 `
+	sql := `SELECT * FROM cygx_activity WHERE activity_time > '` + startDate + `' AND activity_time < '` + endDate + `' `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }

+ 12 - 4
models/activity_attendance_detail.go

@@ -22,6 +22,7 @@ type CygxActivityAttendanceDetail struct {
 	MeetingStatusStr      string    `description:"参会状态"`
 	CreateTime            time.Time `description:"创建时间"`
 	Position              string    `description:"职位"`
+	IsMeetingStr          int       `description:"是否到会,1到会,0未到会"`
 }
 
 //添加会议提醒信息
@@ -146,23 +147,30 @@ func AddAttendancDetail(items []*CygxActivityAttendanceDetail, activityId int, m
 
 //获取用户报名数量
 
-func GetRoadshowDataList(endDate string) (list []*RoadshowData, err error) {
+func GetRoadshowDataList(title, findStartDate, findEndDate string) (list []*RoadshowData, err error) {
 	o := orm.NewOrm()
 	o.Using("comein_data")
-	sql := `SELECT * FROM roadshow_data WHERE roadshow_title LIKE '%化学发光自身免疫产品&流水线市场情况%'`
+	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 {
-	CompanyId      int    `description:"公司ID"`
+	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 *  FROM wx_user WHERE mobile IN (` + mobileStr + `)`
+	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
 }

+ 93 - 24
models/activity_meet_detail_log.go

@@ -1,7 +1,9 @@
 package models
 
 import (
+	"fmt"
 	"rdluck_tools/orm"
+	"strings"
 	"time"
 )
 
@@ -16,30 +18,37 @@ type CygxActivityMeetDetailLog struct {
 	CreateTime   time.Time `description:"创建时间"`
 }
 
-func GetOfflineMeetingDetailList() (item []*CygxActivityMeetDetailLog, err error) {
+func GetOfflineMeetingDetailListCompanyIdStr(companyIdStr string) (item []*CygxActivityMeetDetailLog, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_activity_offline_meeting_detail WHERE is_meeting = 1`
+	sql := `SELECT * FROM cygx_activity_offline_meeting_detail WHERE company_id IN (` + companyIdStr + `)`
 	_, err = o.Raw(sql).QueryRows(&item)
 	return
 }
 
-//添加优化建议
+func GetOfflineMeetingDetailListCompanyName(companyName string) (item []*CygxActivityMeetDetailLog, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_meet_detail_log WHERE company_name IN (` + companyName + `)`
+	_, err = o.Raw(sql).QueryRows(&item)
+	return
+}
+
+//添加
 func AddCygxActivityMeetDetailLog(item *CygxActivityMeetDetailLog) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
 	return
 }
 
-func GetActivityMeetDetailLog() (item []*CygxActivityMeetDetailLog, err error) {
+func GetActivityMeetDetailLog(mobileStr string) (item []*CygxActivityMeetDetailLog, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM  cygx_activity_meet_detail_log WHERE company_name !='' GROUP BY company_name `
+	sql := `SELECT * FROM  cygx_activity_meet_detail_log WHERE mobile IN (` + mobileStr + `)`
 	_, err = o.Raw(sql).QueryRows(&item)
 	return
 }
 
 func GetActivityMeetDetailLogByMobile() (item []*CygxActivityMeetDetailLog, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM  cygx_activity_meet_detail_log WHERE mobile !=''  GROUP BY mobile `
+	sql := `SELECT * FROM  cygx_activity_meet_detail_log WHERE mobile !='' GROUP BY mobile `
 	_, err = o.Raw(sql).QueryRows(&item)
 	return
 }
@@ -57,7 +66,7 @@ func GetActivityMeetDetailLogCount(condition string) (count int, err error) {
 
 //修改公司参会数量
 func UpdateActivityMeetDetailLog(companyName string, num int) (err error) {
-	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 = ?`
 	o := orm.NewOrm()
 	_, err = o.Raw(sql, num, companyName).Exec()
 	return
@@ -71,23 +80,83 @@ func UpdateActivityMeetDetailLogByUser(mobile string, num int) (err error) {
 	return
 }
 
-func DeleteActivityMeetDetailLogByUser(item *CygxActivityMeetDetailLog) (err error) {
-	o := orm.NewOrm()
-	sql := ` DELETE FROM cygx_activity_meet_detail_log WHERE mobile=? AND  activity_id = ? AND attendance_id != ? AND company_id =?`
-	_, err = o.Raw(sql, item.Mobile, item.ActivityId, item.AttendanceId, item.CompanyId).Exec()
-	return
-}
-
-func ListActivityMeetDetailLogByUser() (items []*CygxActivityList, err error) {
+//添加线上到会记录
+func AddCygxActivityMeetDetailLogOnline(list []*CygxActivityAttendanceDetail, activityId int) (err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT
-	* 
-FROM
-	cygx_activity 
-WHERE
-	activity_type_id IN ( 4,
-	5,
-	6)`
-	_, err = o.Raw(sql).QueryRows(&items)
+	o.Begin()
+	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 = ?`
+	_, err = o.Raw(sql, activityId).Exec()
+	if err != nil {
+		return
+	}
+	//插入新的数据
+	for _, v := range list {
+		item := new(CygxActivityMeetDetailLog)
+		item.ActivityId = v.ActivityId
+		item.Mobile = v.Mobile
+		item.CompanyName = v.CompanyName
+		item.CompanyId = v.CompanyId
+		item.CreateTime = v.CreateTime
+		CompanyName += "'" + v.CompanyName + "',"
+		MobileStr += v.Mobile + ","
+		items = append(items, item)
+	}
+	CompanyName = strings.TrimRight(CompanyName, ",")
+	MobileStr = strings.TrimRight(MobileStr, ",")
+	for _, v := range items {
+		_, err = o.Insert(v)
+		if err != nil {
+			return
+		}
+	}
+	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 {
+			return
+		}
+	}
 	return
 }

+ 134 - 0
models/activity_signup.go

@@ -397,3 +397,137 @@ func GetActivityCountByIdWithUid(activityId, Uid int) (count int, err error) {
 	err = o.Raw(sqlCount, activityId, Uid).QueryRow(&count)
 	return
 }
+
+//获取用户报名数量
+func GetActivitySignupNomeetingCount(activityId int) (count int, err error) {
+	sqlCount := `SELECT
+	COUNT( 1 ) count 
+FROM
+	cygx_activity_signup AS s
+	INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id 
+WHERE
+	1 = 1 
+	AND a.is_limit_people > 0 
+	AND s.is_meeting = 0 
+	AND a.is_submit_meeting = 1
+	AND a.activity_id = ?`
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, activityId).QueryRow(&count)
+	return
+}
+
+func GetUserMeetingMobile(activityId int) (items []*CygxActivitySignup, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *
+FROM
+	cygx_activity_signup AS s 
+WHERE
+	s.is_meeting = 1 
+	AND s.activity_id = ?`
+	_, err = o.Raw(sql, activityId).QueryRows(&items)
+	return
+}
+
+//获取用户是否被限制报名
+func GetRestrictSignupCountByUid(uid int) (count int, err error) {
+	sqlCount := `SELECT COUNT( 1 ) count FROM cygx_activity_restrict_signup  WHERE user_id = ?`
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid).QueryRow(&count)
+	return
+}
+
+//获取用户爽约次数
+func GetActivitySignupNomeetingCountByUid(uid int) (count int, err error) {
+	sqlCount := `SELECT
+	COUNT( 1 ) count 
+FROM
+	cygx_activity_signup AS s
+	INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id 
+WHERE
+	1 = 1 
+	AND a.is_limit_people > 0 
+	AND s.is_meeting = 0 
+	AND a.is_submit_meeting = 1
+	AND s.do_fail_type = 0
+	AND s.user_id = ?`
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, uid).QueryRow(&count)
+	return
+}
+
+//删除
+func DeleteCygxActivityRestrictSignup(uid int) (err error) {
+	o := orm.NewOrm()
+	sql := ` DELETE FROM cygx_activity_restrict_signup  WHERE user_id=?`
+	_, err = o.Raw(sql, uid).Exec()
+	return
+}
+
+type CygxActivitySignupList struct {
+	Id          int    `orm:"column(id);pk"`
+	UserId      int    `description:"用户id"`
+	ActivityId  int    `description:"活动ID"`
+	CompanyName string `description:"公司名称"`
+	RealName    string `description:"姓名"`
+	CreateTime  string `description:"创建时间"`
+	IsMeeting   int    `description:"是否到会 ,1是, 0否"`
+	Operation   bool   `description:"操作按钮,true,到会,false 未到会"`
+	Channel     int    `description:"报名渠道,0 空降、 1小程序报名"`
+}
+
+//获取用户报名列表
+func GetActivitySignupNomeetingCountList(activityId int) (items []*CygxActivitySignupList, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	s.user_id
+FROM
+	cygx_activity_signup AS s
+	INNER JOIN cygx_activity AS a ON a.activity_id = s.activity_id 
+WHERE
+	1 = 1 
+	AND a.is_limit_people > 0 
+	AND s.is_meeting = 0 
+	AND a.is_submit_meeting = 1
+	AND a.activity_id = ?`
+	_, err = o.Raw(sql, activityId).QueryRows(&items)
+	return
+}
+
+type UserAndCompanyName struct {
+	UserId              int `orm:"column(user_id);pk"`
+	Mobile              string
+	Email               string
+	CompanyId           int
+	CompanyName         string `description:"公司名称"`
+	CountryCode         string `description:"手机国家区号"`
+	OutboundMobile      string `description:"外呼手机号"`
+	OutboundCountryCode string `description:"外呼手机号区号"`
+}
+
+func GetUserAndCompanyNameList(uid int) (item *UserAndCompanyName, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT u.*,c.company_name 
+			FROM wx_user AS u
+	INNER JOIN company AS c ON c.company_id = u.company_id
+	WHERE user_id =?`
+	err = o.Raw(sql, uid).QueryRow(&item)
+	return
+}
+
+type CygxActivityRestrictSignup struct {
+	Id          int       `orm:"column(id);pk"`
+	UserId      int       `description:"用户id,多个用,隔开"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱号"`
+	CompanyId   int       `description:"公司ID"`
+	CompanyName string    `description:"公司名称"`
+	IsRestrict  int       `description:"是否限制报名,1是,0否"`
+}
+
+//添加
+func AddCygxActivityRestrictSignup(item *CygxActivityRestrictSignup) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}

+ 4 - 3
models/db.go

@@ -35,8 +35,8 @@ func init() {
 	orm.SetMaxIdleConns("comein_data", 50)
 	orm.SetMaxOpenConns("comein_data", 100)
 
-	comein_dataDb, _ := orm.GetDB("comein_data")
-	comein_dataDb.SetConnMaxLifetime(10 * time.Minute)
+	comein_datadb, _ := orm.GetDB("comein_data")
+	comein_datadb.SetConnMaxLifetime(10 * time.Minute)
 	//
 	//orm.RegisterDataBase("comein_data", "mysql", utils.MYSQL_URL_COMEIN_DATA)
 	//orm.SetMaxIdleConns("comein_data", 50)
@@ -76,12 +76,13 @@ func init() {
 		new(CygxArticleAsk),
 		new(CygxPageHistoryRecord),
 		new(CygxReportHistoryRecord),
-		new(CygxActivityMeetDetailLog),
 		new(CygxArticleAuthor),
 		new(CygxUserRecord),
 		new(CygxReportIndustrialSeaarchHistory),
 		new(CygxArticleHistoryRecordNewpv),
 		new(CygxActivitySearchHistory),
 		new(CygxActivityAttendanceDetail),
+		new(CygxActivityRestrictSignup),
+		new(CygxActivityMeetDetailLog),
 	)
 }

+ 156 - 69
services/activity.go

@@ -650,84 +650,171 @@ func LabelStr(label string) (labelNew string) {
 }
 
 func ActivityAttendanceDetail() {
-	//var mobileStr string
-	//needAddAttendanc := make([]*models.CygxActivityAttendanceDetail, 0)
+	var mobileStr string
 	fmt.Println("开始同步")
-	dateTime := time.Now().AddDate(0, 0, -1).Format(utils.FormatDate)
-	fmt.Println(dateTime)
+	dateTime := time.Now().AddDate(0, 0, -2).Format(utils.FormatDate)
 	startDate := dateTime + " 00:00:00"
 	endDate := dateTime + " 23:59:59"
-	fmt.Println(startDate)
-	fmt.Println(endDate)
+	//获取需要处理的活动
 	listActivity, err := models.GetActivityListByDateTime(startDate, endDate)
 	if err != nil {
 		fmt.Println("GetTacticsList Err:", err.Error())
 		return
 	}
-	for _, v := range listActivity {
-		fmt.Println(v.ActivityName)
-		fmt.Println(v.ActivityTime)
+	for _, vAct := range listActivity {
+		doTime := utils.TimeRemoveHms2(vAct.ActivityTime)
+		findStartDate := doTime + " 00:00:00"
+		findEndDate := doTime + " 23:59:59"
+		nameSlice := strings.Split(vAct.ActivityName, "】")
+		//fmt.Println(timeSlice[0])
+		var activityName string
+		if len(nameSlice) > 1 {
+			activityName = nameSlice[len(nameSlice)-1]
+			if activityName != "" {
+				list, err := models.GetRoadshowDataList(activityName, findStartDate, findEndDate)
+				if err != nil {
+					fmt.Println("GetTacticsList Err:", err.Error())
+					return
+				}
+				needAddAttendanc := make([]*models.CygxActivityAttendanceDetail, 0)
+				fmt.Println("原来的", vAct.ActivityName)
+				fmt.Println("处理的", activityName)
+				if len(list) > 0 {
+					for _, v := range list {
+						if v.UserPhone != "" {
+							item := new(models.CygxActivityAttendanceDetail)
+							item.ActivityId = vAct.ActivityId
+							item.RealName = v.UserName
+							item.Mobile = v.UserPhone
+							item.CompanyName = v.Company
+							//item.SellerName = sellerName
+							item.FirstMeetingTime = v.FirstWatchTime
+							item.LastMeetingTime = v.LastWatchTime
+							item.Duration = utils.GetAttendanceDetailSeconds(v.JoinTime)
+							if v.JoinType == 1 {
+								item.MeetingTypeStr = "网络"
+							} else {
+								item.MeetingTypeStr = "电话"
+							}
+							item.MeetingAuthentication = v.AuthInfo
+							if v.DataType == 1 {
+								item.MeetingStatusStr = "直播"
+							} else {
+								item.MeetingStatusStr = "回放"
+							}
+							item.Position = v.Occupation
+							item.CreateTime = time.Now()
+							mobileStr += "'" + v.UserPhone + "'" + ","
+							needAddAttendanc = append(needAddAttendanc, item)
+						}
+					}
+					mobileStr = strings.TrimRight(mobileStr, ",")
+					if mobileStr == "" {
+						mobileStr = "1"
+					}
+					listUser, err := models.GetWxUserOutboundMobile(mobileStr)
+					if err != nil {
+						fmt.Println("GetWxUserOutboundMobile Err:", err.Error())
+						return
+					}
+					for k, v := range needAddAttendanc {
+						for _, v2 := range listUser {
+							if v2.OutboundMobile == v.Mobile {
+								needAddAttendanc[k].CompanyId = v2.CompanyId
+								needAddAttendanc[k].SellerName = v2.SellerName
+								needAddAttendanc[k].CompanyName = v2.CompanyName
+								needAddAttendanc[k].IsMeetingStr = 1
+							}
+						}
+					}
+					fmt.Println(mobileStr)
+					err = models.AddAttendancDetail(needAddAttendanc, vAct.ActivityId, mobileStr)
+					if err != nil {
+						fmt.Println("AddAttendancDetail Err:", err.Error())
+						return
+					}
+					go AddCygxActivityRestrictSignupByAdmin(vAct.ActivityId)
+					err = models.AddCygxActivityMeetDetailLogOnline(needAddAttendanc, vAct.ActivityId)
+					fmt.Println(err)
+				}
+			}
+		}
 	}
+	fmt.Println("结束同步")
+}
 
-	//list, err := models.GetRoadshowDataList("")
-	//list, err := models.GetTacticsListAll2()
-	//if err != nil {
-	//	fmt.Println("GetTacticsList Err:", err.Error())
-	//	return
-	//}
-	//mobileMap := make(map[string]string)
+func AddCygxActivityRestrictSignupByAdmin(activityId int) {
+	var msg string
+	total, err := models.GetActivitySignupNomeetingCount(activityId)
+	fmt.Println(total)
+	if err != nil {
+		utils.FileLog.Info("用户限制报名失败,Err:%s,%s", err.Error(), msg)
+		fmt.Println(" Err:", err.Error())
+	}
+	mobileList, _ := models.GetUserMeetingMobile(activityId)
+	if len(mobileList) >= 0 {
+		for _, v := range mobileList {
+			totalRestrict, err := models.GetRestrictSignupCountByUid(v.UserId)
+			if err != nil {
+				fmt.Println(" Err:", err.Error())
+				utils.FileLog.Info("用户限制报名失败,Err:%s,%s", err.Error(), msg)
+			}
+			totalNomeet, err := models.GetActivitySignupNomeetingCountByUid(v.UserId)
+			if err != nil {
+				fmt.Println(" Err:", err.Error())
+				utils.FileLog.Info("用户限制报名失败,Err:%s,%s", err.Error(), msg)
+			}
+			if totalRestrict > 0 && totalNomeet < 3 {
+				err = models.DeleteCygxActivityRestrictSignup(v.UserId)
+				if err != nil {
+					fmt.Println(" Err:", err.Error())
+					utils.FileLog.Info("用户限制报名失败,Err:%s,%s", err.Error(), msg)
+				}
+			}
+		}
+	}
 
-	//activityId := 4
-	//for _, v := range list {
-	//	if v.UserPhone != "" {
-	//		item := new(models.CygxActivityAttendanceDetail)
-	//		item.ActivityId = activityId
-	//		item.RealName = v.UserName
-	//		item.Mobile = v.UserPhone
-	//		item.CompanyName = v.Company
-	//		//item.SellerName = sellerName
-	//		item.FirstMeetingTime = v.FirstWatchTime
-	//		item.LastMeetingTime = v.LastWatchTime
-	//		item.Duration = utils.GetAttendanceDetailSeconds(v.JoinTime)
-	//		if v.JoinType == 1 {
-	//			item.MeetingTypeStr = "网络"
-	//		} else {
-	//			item.MeetingTypeStr = "电话"
-	//		}
-	//		item.MeetingAuthentication = v.AuthInfo
-	//		if v.DataType == 1 {
-	//			item.MeetingStatusStr = "直播"
-	//		} else {
-	//			item.MeetingStatusStr = "回放"
-	//		}
-	//		item.Position = v.Occupation
-	//		item.CreateTime = time.Now()
-	//		mobileStr += "'" + v.UserPhone + "'" + ","
-	//		needAddAttendanc = append(needAddAttendanc, item)
-	//	}
-	//}
-	//mobileStr = strings.TrimRight(mobileStr, ",")
-	//if mobileStr == "" {
-	//	mobileStr = "1"
-	//}
-	//listUser, err := models.GetWxUserOutboundMobile(mobileStr)
-	//if err != nil {
-	//	fmt.Println("GetWxUserOutboundMobile Err:", err.Error())
-	//	return
-	//}
-	//for k, v := range needAddAttendanc {
-	//	for _, v2 := range listUser {
-	//		if v2.OutboundMobile == v.Mobile {
-	//			needAddAttendanc[k].CompanyId = v2.CompanyId
-	//		}
-	//	}
-	//}
-	//
-	//fmt.Println(mobileStr)
-	//err = models.AddAttendancDetail(needAddAttendanc, activityId, mobileStr)
-	//if err != nil {
-	//	fmt.Println("AddAttendancDetail Err:", err.Error())
-	//	return
-	//}
-	fmt.Println("结束同步")
+	if total == 0 {
+		return
+	}
+	list, err := models.GetActivitySignupNomeetingCountList(activityId)
+	fmt.Println(list)
+	if err != nil {
+		utils.FileLog.Info("用户限制报名失败,Err:%s,%s", err.Error(), msg)
+		fmt.Println(" 用户限制报名失败 Err:", err.Error())
+	}
+	for _, v := range list {
+		totalRestrict, err := models.GetRestrictSignupCountByUid(v.UserId)
+		if err != nil {
+			fmt.Println(" Err:", err.Error())
+			utils.FileLog.Info("用户限制报名失败,Err:%s,%s", err.Error(), msg)
+		}
+		totalNomeet, err := models.GetActivitySignupNomeetingCountByUid(v.UserId)
+		if err != nil {
+			fmt.Println(" Err:", err.Error())
+			utils.FileLog.Info("用户限制报名失败,Err:%s,%s", err.Error(), msg)
+		}
+		if totalNomeet >= 3 {
+			if totalRestrict == 0 {
+				infoUser, err := models.GetUserAndCompanyNameList(v.UserId)
+				if err != nil {
+					fmt.Println(" Err:", err.Error())
+				}
+				if infoUser != nil {
+					item := new(models.CygxActivityRestrictSignup)
+					item.UserId = infoUser.UserId
+					item.CreateTime = time.Now()
+					item.Mobile = infoUser.Mobile
+					item.Email = infoUser.Email
+					item.CompanyId = infoUser.CompanyId
+					item.CompanyName = infoUser.CompanyName
+					item.IsRestrict = 1
+					err = models.AddCygxActivityRestrictSignup(item)
+					if err != nil {
+						fmt.Println(" Err:", err.Error())
+					}
+				}
+			}
+		}
+	}
 }

+ 17 - 2
utils/common.go

@@ -586,6 +586,21 @@ func TimeRemoveHms(strTime string) string {
 	return Ymd
 }
 
+//时间格式去掉时分秒
+func TimeRemoveHms2(strTime string) string {
+	var Ymd string
+	var resultTime = StrTimeToTime(strTime)
+	year := resultTime.Year()
+	month := resultTime.Format("01")
+	day1 := resultTime.Day()
+	if day1 < 10 {
+		Ymd = strconv.Itoa(year) + "-" + month + "-0" + strconv.Itoa(day1)
+	} else {
+		Ymd = strconv.Itoa(year) + "-" + month + "-" + strconv.Itoa(day1)
+	}
+	return Ymd
+}
+
 //判断时间是当年的第几周
 func WeekByDate(t time.Time) string {
 	var resultSAtr string
@@ -631,7 +646,7 @@ func Mp3Time(videoPlaySeconds string) string {
 func GetAttendanceDetailSeconds(secondNum int) string {
 	var timeStr string
 	if secondNum <= 60 {
-		if secondNum <= 10 {
+		if secondNum < 10 {
 			timeStr = "0" + strconv.Itoa(secondNum) + "''"
 		} else {
 			timeStr = strconv.Itoa(secondNum) + "''"
@@ -640,7 +655,7 @@ func GetAttendanceDetailSeconds(secondNum int) string {
 		var remainderStr string
 		remainderNum := secondNum % 60
 		minuteNum := secondNum / 60
-		if remainderNum <= 10 {
+		if remainderNum < 10 {
 			remainderStr = "0" + strconv.Itoa(remainderNum) + "''"
 		} else {
 			remainderStr = strconv.Itoa(remainderNum) + "''"