|
@@ -0,0 +1,190 @@
|
|
|
+package services
|
|
|
+
|
|
|
+import (
|
|
|
+ "context"
|
|
|
+ "fmt"
|
|
|
+ "hongze/hongze_cygx/models"
|
|
|
+ "hongze/hongze_cygx/utils"
|
|
|
+)
|
|
|
+
|
|
|
+//AddctivitySignupDetail 获取当天已结束的活动的报名信息。添加到到会详情
|
|
|
+func AddctivitySignupDetail(cont context.Context) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go utils.SendAlarmMsg(" 获取当天已结束的活动的报名信息。添加到到会详情失败, ErrMsg:"+err.Error(), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ actList, err := models.GetActivitySattusToComplete()
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if len(actList) == 0 {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ activityIds := make([]int, 0)
|
|
|
+ for _, v := range actList {
|
|
|
+ activityIds = append(activityIds, v.ActivityId)
|
|
|
+ }
|
|
|
+ actLen := len(activityIds)
|
|
|
+
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ if actLen > 0 {
|
|
|
+ //condition += ` AND activity_id IN (` + utils.GetOrmInReplace(actLen) + `)`
|
|
|
+ //pars = append(pars, activityIds)
|
|
|
+ } else {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ condition = ""
|
|
|
+ //获取当天已经结束了 活动的报名人数
|
|
|
+ signUpList, err := models.GetSignupDetailBySignup(condition, pars)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ signUpDetailList, err := models.GetSignupDetailList(condition, pars)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ mapsignUpDetai := make(map[string]string)
|
|
|
+ if len(signUpDetailList) > 0 {
|
|
|
+ for _, v := range signUpDetailList {
|
|
|
+ mapsignUpDetai[fmt.Sprint("ActivityId", v.ActivityId, "Mobile", v.Mobile)] = v.Mobile
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var items []*models.CygxActivitySignupDetail
|
|
|
+ if len(signUpList) > 0 {
|
|
|
+ for _, v := range signUpList {
|
|
|
+ if _, ok := mapsignUpDetai[fmt.Sprint("ActivityId", v.ActivityId, "Mobile", v.Mobile)]; !ok {
|
|
|
+ item := new(models.CygxActivitySignupDetail)
|
|
|
+ item.UserId = v.UserId
|
|
|
+ item.RealName = v.RealName
|
|
|
+ item.SellerName = v.SellerName
|
|
|
+ item.ActivityId = v.ActivityId
|
|
|
+ item.CreateTime = v.CreateTime
|
|
|
+ item.Mobile = v.Mobile
|
|
|
+ item.Email = v.Email
|
|
|
+ item.CompanyId = v.CompanyId
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
+ item.SignupType = v.SignupType
|
|
|
+ item.FailType = v.FailType
|
|
|
+ item.DoFailType = v.DoFailType
|
|
|
+ items = append(items, item)
|
|
|
+ if len(items)%2000 == 0 {
|
|
|
+ err = models.AddCygxActivitySignupDetail(items)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ items = make([]*models.CygxActivitySignupDetail, 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if len(items) > 0 {
|
|
|
+ err = models.AddCygxActivitySignupDetail(items)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
+//AddctivitySignupDetailByJmcj 通过进门财经添加用户参数信息
|
|
|
+func AddctivitySignupDetailByJmcj(itemsDetail []*models.CygxActivityAttendanceDetail, activityId int) (err error) {
|
|
|
+ fmt.Println()
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ go utils.SendAlarmMsg("通过进门财经添加用户参数信息失败 ErrMsg:"+err.Error(), 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ fmt.Println("活动ID", activityId)
|
|
|
+ activityIds := make([]int, 0)
|
|
|
+ activityIds = append(activityIds, activityId)
|
|
|
+ actLen := len(activityIds)
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ if actLen > 0 {
|
|
|
+ condition += ` AND activity_id IN (` + utils.GetOrmInReplace(actLen) + `)`
|
|
|
+ pars = append(pars, activityIds)
|
|
|
+ }
|
|
|
+
|
|
|
+ signUpDetailList, err := models.GetSignupDetailList(condition, pars)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+
|
|
|
+ mapsignUpDetai := make(map[string]string)
|
|
|
+ if len(signUpDetailList) > 0 {
|
|
|
+ for _, v := range signUpDetailList {
|
|
|
+ mapsignUpDetai[fmt.Sprint("ActivityId", v.ActivityId, "Mobile", v.Mobile)] = v.Mobile
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var itemsAdd []*models.CygxActivitySignupDetail
|
|
|
+ var itemsUpdate []*models.CygxActivitySignupDetail
|
|
|
+
|
|
|
+ for _, v := range itemsDetail {
|
|
|
+ var item = new(models.CygxActivitySignupDetail)
|
|
|
+ item.ActivityId = v.ActivityId
|
|
|
+ item.RealName = v.RealName
|
|
|
+ item.Mobile = v.Mobile
|
|
|
+ item.CompanyName = v.CompanyName
|
|
|
+ item.CompanyId = v.CompanyId
|
|
|
+ item.SellerName = v.SellerName
|
|
|
+ item.FirstMeetingTime = v.FirstMeetingTime
|
|
|
+ item.LastMeetingTime = v.LastMeetingTime
|
|
|
+ item.Duration = v.Duration
|
|
|
+ item.MeetingTypeStr = v.MeetingTypeStr
|
|
|
+ item.MeetingAuthentication = v.MeetingAuthentication
|
|
|
+ item.MeetingStatusStr = v.MeetingStatusStr
|
|
|
+ item.CreateTime = v.CreateTime
|
|
|
+ item.Position = v.Position
|
|
|
+ item.IsMeeting = 1
|
|
|
+ item.UseridEntity = v.UseridEntity
|
|
|
+ item.ActivityTime = v.ActivityTime
|
|
|
+ item.CrmCompanyMapStatusId = v.CrmCompanyMapStatusId
|
|
|
+ //fmt.Println(item)
|
|
|
+ //return err
|
|
|
+ if _, ok := mapsignUpDetai[fmt.Sprint("ActivityId", v.ActivityId, "Mobile", v.Mobile)]; !ok {
|
|
|
+ itemsAdd = append(itemsAdd, item)
|
|
|
+ } else {
|
|
|
+ itemsUpdate = append(itemsUpdate, item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(itemsAdd) > 0 {
|
|
|
+ err = models.AddCygxActivitySignupDetail(itemsAdd)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(itemsAdd) > 0 {
|
|
|
+ err = models.UpdateActivitySignupDetailMulti(itemsUpdate)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return err
|
|
|
+}
|
|
|
+
|
|
|
+func GetCygxActivityAttendanceDetail() {
|
|
|
+ listAll, err := models.GetActivityAttendanceDetailListAll()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ }
|
|
|
+ mapDetal := make(map[int][]*models.CygxActivityAttendanceDetail)
|
|
|
+
|
|
|
+ for _, v := range listAll {
|
|
|
+ mapDetal[v.ActivityId] = append(mapDetal[v.ActivityId], v)
|
|
|
+ }
|
|
|
+
|
|
|
+ for k, v := range mapDetal {
|
|
|
+ AddctivitySignupDetailByJmcj(v, k)
|
|
|
+ }
|
|
|
+ //fmt.Println(mapDetal)
|
|
|
+}
|