123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660 |
- package services
- import (
- "context"
- "errors"
- "fmt"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/utils"
- "strconv"
- "strings"
- "time"
- )
- //func init() {
- // fmt.Println(strings.Contains("渠道新声第583期运动服饰渠道调研更新反馈", "运动服饰渠道调研更新反馈"))
- // fmt.Println(len("反馈"))
- // GroupingActivityToJmcj()
- // GetActivityMeetingByJmcj()
- //}
- // GroupingActivityToJmcj 建立与进门财经的活动关联
- func GroupingActivityToJmcj(cont context.Context) (err error) {
- //func GroupingActivityToJmcj() (err error) {
- defer func() {
- if err != nil {
- fmt.Println(err)
- go utils.SendAlarmMsg("建立与进门财经的活动关联失败"+err.Error(), 2)
- }
- }()
- dateTime := time.Now().AddDate(0, 0, -7).Format(utils.FormatDate)
- dateNow := time.Now().AddDate(0, 0, 0).Format(utils.FormatDate)
- startDate := dateTime + " 00:00:00"
- endDate := dateNow + " 23:59:59"
- var condition string
- var pars []interface{}
- condition = " AND roadshow_begin_time BETWEEN ? AND ? "
- //condition += " AND roadshow_id = 95871 "
- pars = append(pars, startDate, endDate)
- condition += ` GROUP BY roadshow_id `
- listJmcj, e := models.GetJmcjRoadshowDataList(condition, pars)
- if e != nil {
- err = errors.New("GetJmcjRoadshowDataList, Err: " + e.Error())
- return
- }
- textLen := 15
- pars = make([]interface{}, 0)
- //进门财经的不匹配的易董办会的
- condition = " AND activity_time BETWEEN ? AND ? AND publish_status = 1 AND jmcj_activity_id = '' AND yidong_activity_id_by_cygx = '' AND yidong_activity_id = '' "
- //condition += " AND activity_id = 1339 "
- pars = append(pars, startDate, endDate)
- listHz, e := models.GetActivityListByCondition(condition, pars)
- if e != nil {
- err = errors.New("GetActivityListByCondition, Err: " + e.Error())
- return
- }
- mapGroupActivityid := make(map[int]string)
- //通过进门财经匹配弘则
- for _, vJmcj := range listJmcj {
- var roadshowTitle, roadshowTitle1, roadshowTitle2, roadshowTitle3, roadshowTitle4 string
- roadshowTitle = vJmcj.RoadshowTitle
- roadshowTitle = strings.Replace(roadshowTitle, " ", "", -1)
- roadshowBeginTime := utils.TimeRemoveHms2(vJmcj.RoadshowBeginTime)
- nameSlice1 := strings.Split(roadshowTitle, "|")
- nameSlice2 := strings.Split(roadshowTitle, ":")
- nameSlice3 := strings.Split(roadshowTitle, "】")
- nameSlice4 := strings.Split(roadshowTitle, "-")
- if len(nameSlice1) >= 1 {
- roadshowTitle1 = nameSlice1[len(nameSlice1)-1]
- }
- if len(nameSlice2) >= 1 {
- roadshowTitle2 = nameSlice2[len(nameSlice2)-1]
- }
- if len(nameSlice3) >= 1 {
- roadshowTitle3 = nameSlice3[len(nameSlice3)-1]
- }
- if len(nameSlice4) >= 1 {
- roadshowTitle4 = nameSlice4[len(nameSlice4)-1]
- }
- if roadshowTitle == "" {
- continue
- }
- //fmt.Println(roadshowTitle1)
- //fmt.Println(roadshowTitle2)
- //fmt.Println(roadshowTitle3)
- //fmt.Println(roadshowTitle4)
- for _, vHz := range listHz {
- //如果同一时间标题匹配就建立匹配关系
- if roadshowBeginTime == utils.TimeRemoveHms2(vHz.ActivityTime) {
- if strings.Contains(vHz.ActivityNameTask, roadshowTitle) || strings.Contains(vHz.JmcjRoadshowTitle, roadshowTitle) {
- mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
- break
- }
- //去掉空格标识,完全等于时候的匹配
- if strings.Replace(vHz.ActivityName, " ", "", -1) == strings.Replace(vJmcj.RoadshowTitle, " ", "", -1) {
- mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
- break
- }
- if len(roadshowTitle1) > textLen {
- if strings.Contains(vHz.ActivityNameTask, roadshowTitle1) || strings.Contains(vHz.JmcjRoadshowTitle, roadshowTitle1) {
- mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
- break
- }
- }
- if len(roadshowTitle2) > textLen {
- if strings.Contains(vHz.ActivityNameTask, roadshowTitle2) || strings.Contains(vHz.JmcjRoadshowTitle, roadshowTitle2) {
- mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
- break
- }
- }
- if len(roadshowTitle3) > textLen {
- if strings.Contains(vHz.ActivityNameTask, roadshowTitle3) || strings.Contains(vHz.JmcjRoadshowTitle, roadshowTitle3) {
- mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
- break
- }
- }
- if len(roadshowTitle4) > textLen {
- if strings.Contains(vHz.ActivityNameTask, roadshowTitle4) || strings.Contains(vHz.JmcjRoadshowTitle, roadshowTitle4) {
- mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
- break
- }
- }
- }
- }
- }
- //通过弘则匹配进门财经
- for _, vHz := range listHz {
- if mapGroupActivityid[vHz.ActivityId] != "" {
- continue
- }
- var roadshowTitle string
- roadshowTitle = vHz.ActivityName
- nameSlice := strings.Split(roadshowTitle, "】")
- if len(nameSlice) >= 1 {
- roadshowTitle = nameSlice[len(nameSlice)-1]
- if len(roadshowTitle) > textLen {
- vHz.ActivityTime = utils.TimeRemoveHms2(vHz.ActivityTime)
- for _, vJmcj := range listJmcj {
- //如果同一时间标题匹配就建立匹配关系
- if vHz.ActivityTime == utils.TimeRemoveHms2(vJmcj.RoadshowBeginTime) {
- if strings.Contains(vJmcj.RoadshowTitle, roadshowTitle) {
- mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
- break
- }
- if strings.Contains(vJmcj.RoadshowTitle, vHz.JmcjRoadshowTitle) && vHz.JmcjRoadshowTitle != "" {
- mapGroupActivityid[vHz.ActivityId] = vJmcj.RoadshowId
- break
- }
- }
- }
- }
- }
- }
- if len(mapGroupActivityid) > 0 {
- e = models.UpdateJmcjActivityIdGroup(mapGroupActivityid)
- if e != nil {
- err = errors.New("UpdateJmcjActivityIdGroup, Err: " + e.Error())
- }
- }
- return
- }
- // GetActivityMeetingByJmcj 同步进门财经到会信息,并处理爽约记录
- func GetActivityMeetingByJmcj(cont context.Context) (err error) {
- defer func() {
- if err != nil {
- fmt.Println(err)
- go utils.SendAlarmMsg("获取进门财经的到会信息失败,Err"+err.Error(), 2)
- }
- }()
- //获取需要一直同步的活动信息
- configCode := "jin_meng_activity_id"
- detail, e := models.GetConfigByCode(configCode)
- if e != nil {
- err = errors.New("GetConfigByCode, Err: " + e.Error())
- return
- }
- mapActivityIdlLongTime := make(map[string]string)
- sliceValue := strings.Split(detail.ConfigValue, ",")
- for _, v := range sliceValue {
- mapActivityIdlLongTime[v] = v
- }
- dateTime := time.Now().AddDate(0, 0, -14).Format(utils.FormatDate)
- dateNow := time.Now().AddDate(0, 0, 0).Format(utils.FormatDate)
- startDate := dateTime + " 00:00:00"
- endDate := dateNow + " 23:59:59"
- var condition string
- var pars []interface{}
- //获取弘则要同步到会信息的活动
- condition = ` AND activity_time BETWEEN ? AND ? AND publish_status = 1 AND jmcj_activity_id != '' AND yidong_activity_id_by_cygx = '' AND yidong_activity_id = '' OR ( activity_id IN (` + detail.ConfigValue + `) AND publish_status = 1 AND jmcj_activity_id != '' ) `
- pars = append(pars, startDate, endDate)
- listHz, e := models.GetActivityListByCondition(condition, pars)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetActivityListByCondition, Err: " + e.Error())
- return
- }
- var jmcjActivityIds []string
- var activityIds []int
- mapGroupActivityid := make(map[string]int)
- mapGroupActivityTime := make(map[string]string)
- for _, v := range listHz {
- jmcjActivityIds = append(jmcjActivityIds, v.JmcjActivityId)
- activityIds = append(activityIds, v.ActivityId)
- mapGroupActivityid[v.JmcjActivityId] = v.ActivityId
- mapGroupActivityTime[v.JmcjActivityId] = v.ActivityTime
- }
- //return
- lenjmcjActivityIds := len(jmcjActivityIds)
- if lenjmcjActivityIds == 0 {
- return
- }
- //获取进门财经对应的路演ID的到会列表
- pars = make([]interface{}, 0)
- condition = ` AND roadshow_id IN (` + utils.GetOrmInReplace(lenjmcjActivityIds) + `)`
- pars = append(pars, jmcjActivityIds)
- listJmcj, e := models.GetJmcjRoadshowDataList(condition, pars)
- if e != nil {
- err = errors.New("GetJmcjRoadshowDataList, Err: " + e.Error())
- return
- }
- //获取已经写入到会信息的参会人员
- lenactivityIds := len(activityIds)
- pars = make([]interface{}, 0)
- condition = ` AND activity_id IN (` + utils.GetOrmInReplace(lenactivityIds) + `)`
- pars = append(pars, activityIds)
- attendanceDetailList, e := models.GetActivityAttendanceDetailListCondition(condition, pars)
- if e != nil {
- err = errors.New("GetActivityAttendanceDetailListCondition, Err: " + e.Error())
- return
- }
- mapAttendanceDetail := make(map[string]int)
- for _, v := range attendanceDetailList {
- mapAttendanceDetail[fmt.Sprint("ActivityId:", v.ActivityId, "Mobile:", v.Mobile)] = v.ActivityId
- }
- var mobiles []string
- var mobileMap = make(map[string]string)
- //var isPlayback bool // 是否包含回放
- var isPlaybackMap = make(map[int]bool) // 是否包含回放map
- var activityIdsLongTime string //包含回放的活动ID
- needAddAttendanc := make([]*models.CygxActivityAttendanceDetail, 0)
- for _, v := range listJmcj {
- if v.UserPhone == "" {
- continue
- }
- if mapGroupActivityid[v.RoadshowId] == 0 {
- continue
- }
- //如果数据已经存在了那么就不做数据更新
- if mapAttendanceDetail[fmt.Sprint("ActivityId:", mapGroupActivityid[v.RoadshowId], "Mobile:", v.UserPhone)] > 0 {
- continue
- }
- item := new(models.CygxActivityAttendanceDetail)
- item.ActivityId = mapGroupActivityid[v.RoadshowId]
- item.RealName = v.UserName
- item.Mobile = v.UserPhone
- item.CompanyName = v.Company
- item.FirstMeetingTime = v.FirstWatchTime
- item.LastMeetingTime = v.LastWatchTime
- item.IsMeetingStr = 1
- 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 = "回放"
- if !isPlaybackMap[item.ActivityId] && mapActivityIdlLongTime[strconv.Itoa(item.ActivityId)] == "" {
- activityIdsLongTime += strconv.Itoa(item.ActivityId) + ","
- }
- isPlaybackMap[item.ActivityId] = true
- }
- item.Position = v.Occupation
- item.UseridEntity = v.UseridEntity
- item.ActivityTime = mapGroupActivityTime[v.RoadshowId]
- item.CrmCompanyMapStatusId = v.CrmCompanyMapStatusId
- item.CreateTime = time.Now()
- needAddAttendanc = append(needAddAttendanc, item)
- if mobileMap[v.UserPhone] == "" {
- mobiles = append(mobiles, v.UserPhone)
- mobileMap[v.UserPhone] = v.UserPhone
- }
- }
- if len(needAddAttendanc) == 0 {
- return
- }
- //根据手机号获取这些用户的信息
- listUser, e := models.GetWxUserOutboundMobiles(mobiles)
- if e != nil {
- err = errors.New("GetWxUserOutboundMobiles, Err: " + e.Error())
- return
- }
- mapUser := make(map[string]*models.WxUserOutboundMobile)
- for _, v := range listUser {
- mapUser[v.Mobile] = v
- mapUser[v.OutboundMobile] = v
- }
- var updateActivityIds []int // 需要更新的活动ID
- var updateActivityIdsMap = make(map[int]bool) // 需要更新的活动ID
- for k, v := range needAddAttendanc {
- if needAddAttendanc[k].CompanyId == 0 && mapUser[v.Mobile] != nil {
- needAddAttendanc[k].CompanyId = mapUser[v.Mobile].CompanyId
- needAddAttendanc[k].SellerName = mapUser[v.Mobile].SellerName
- needAddAttendanc[k].CompanyName = mapUser[v.Mobile].CompanyName
- needAddAttendanc[k].IsMeetingStr = 1
- }
- if !updateActivityIdsMap[v.ActivityId] {
- updateActivityIds = append(updateActivityIds, v.ActivityId)
- updateActivityIdsMap[v.ActivityId] = true
- }
- attendanceDetailList = append(attendanceDetailList, v)
- }
- if len(updateActivityIds) == 0 {
- return
- }
- // 更新需要长时间同步到会信息的活动
- if activityIdsLongTime != "" {
- activityIdsLongTime = strings.TrimRight(activityIdsLongTime, ",")
- activityIdsLongTime = detail.ConfigValue + "," + activityIdsLongTime
- e = models.UpdateConfigByCode(activityIdsLongTime, configCode)
- if e != nil {
- err = errors.New("UpdateConfigByCode, Err: " + e.Error())
- return
- }
- }
- //return
- {
- //参会记录
- e = models.AddAttendancDetailNew(needAddAttendanc, updateActivityIds)
- if e != nil {
- err = errors.New("AddAttendancDetailNew, Err: " + e.Error())
- return err
- }
- }
- {
- //标记到会信息
- e = models.UpdateCygxActivitySignupIsMeeting(needAddAttendanc)
- if e != nil {
- err = errors.New("UpdateCygxActivitySignupIsMeeting, Err: " + e.Error())
- return err
- }
- }
- {
- //处理是否限制报名
- AddCygxActivityRestrictSignupByAdminNew(updateActivityIds)
- }
- {
- //通过进门财经添加用户参数信息
- AddctivitySignupDetailByJmcjNew(needAddAttendanc, updateActivityIds)
- }
- {
- //添加报名日志 (对个人以及机构互动数量进行排序下载使用)
- CygxActivityMeetSort(needAddAttendanc, updateActivityIds)
- }
- return
- }
- // 查研观向处理活动用户限制报名
- func AddCygxActivityRestrictSignupByAdminNew(activityIds []int) (err error) {
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go utils.SendAlarmMsg("查研观向处理活动用户限制报名失败,AddCygxActivityRestrictSignupByAdminNew,Err:"+err.Error()+"activityIds"+fmt.Sprint(activityIds), 3)
- }
- }()
- var condition string
- var pars []interface{}
- lenactivityIds := len(activityIds)
- if lenactivityIds == 0 {
- return
- }
- condition = ` AND is_meeting = 1 AND activity_id IN (` + utils.GetOrmInReplace(lenactivityIds) + `)`
- pars = append(pars, activityIds)
- //获取到会了的人员
- meetingList, e := models.GetActivitySignupList(condition, pars)
- if e != nil {
- err = errors.New("GetActivitySignupList" + e.Error())
- return
- }
- var userIdArr []int
- if len(meetingList) > 0 {
- for _, v := range meetingList {
- userIdArr = append(userIdArr, v.UserId)
- }
- lenuserIdArr := len(userIdArr)
- var condition string
- var pars []interface{}
- condition = ` AND user_id IN (` + utils.GetOrmInReplace(lenuserIdArr) + `)`
- pars = append(pars, userIdArr)
- restrictSignupList, e := models.GetCygxActivityRestrictSignupList(condition, pars, 0, 9999)
- if e != nil {
- err = errors.New("GetCygxActivityRestrictSignupList" + e.Error())
- return
- }
- //获取这些用户是否被加入到限制报名了
- maptotalRestrict := make(map[int]bool)
- for _, v := range restrictSignupList {
- maptotalRestrict[v.UserId] = true
- }
- pars = make([]interface{}, 0)
- condition = ` AND a.is_limit_people = 1 AND v.is_meeting = 0 AND v.do_fail_type = 0 AND v.user_id IN (` + utils.GetOrmInReplace(lenuserIdArr) + `) AND a.activity_id IN (` + utils.GetOrmInReplace(lenactivityIds) + `)`
- pars = append(pars, userIdArr, activityIds)
- listSignup, e := models.GetActivitySignupInnerActivityList(condition, pars)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetActivitySignupInnerActivityList" + e.Error())
- return
- }
- mapNomeet := make(map[int]int)
- if len(listSignup) > 0 {
- for _, v := range listSignup {
- mapNomeet[v.UserId]++
- }
- }
- var userIdDelArr []int
- for _, v := range meetingList {
- //如果加入了爽约限制但是爽约次数少于3条就删除爽约记录
- if maptotalRestrict[v.UserId] && mapNomeet[v.UserId] < 3 {
- userIdDelArr = append(userIdDelArr, v.UserId)
- }
- }
- //if len(userIdDelArr) > 0 {
- // e = models.DeleteCygxActivityRestrictSignupByUserIds(userIdDelArr)
- // if e != nil {
- // err = errors.New("DeleteCygxActivityRestrictSignupByUserIds" + e.Error())
- // return
- // }
- //}
- }
- //获取未到会的人员
- pars = make([]interface{}, 0)
- condition = ` AND v.is_meeting = 0 AND v.do_fail_type = 0 AND v.activity_id IN (` + utils.GetOrmInReplace(lenactivityIds) + `)`
- pars = append(pars, activityIds)
- nomeetingListlist, e := models.GetActivitySignupInnerActivityList(condition, pars)
- if e != nil {
- err = errors.New("GetActivitySignupNomeetingCountList" + e.Error())
- return
- }
- var userIdSiginArr []int
- var items []*models.CygxActivitySignupBreak
- for _, v := range nomeetingListlist {
- userIdSiginArr = append(userIdSiginArr, v.UserId)
- //添加爽约记录
- item := new(models.CygxActivitySignupBreak)
- item.UserId = v.UserId
- item.ActivityId = v.ActivityId
- item.CreateTime = time.Now()
- item.Mobile = v.Mobile
- item.Email = v.Email
- item.CompanyId = v.CompanyId
- item.CompanyName = v.CompanyName
- item.RealName = v.RealName
- item.SellerName = v.SellerName
- items = append(items, item)
- }
- lenuserIdSiginArr := len(userIdSiginArr)
- if lenuserIdSiginArr == 0 {
- return
- }
- var itemsRestrict []*models.CygxActivityRestrictSignup
- maptotalRestrict := make(map[int]bool)
- //var condition string
- pars = make([]interface{}, 0)
- condition = ""
- restrictSignupList, e := models.GetCygxActivityRestrictSignupList(condition, pars, 0, 9999)
- if e != nil {
- err = errors.New("GetCygxActivityRestrictSignupList" + e.Error())
- return
- }
- //获取这些用户是否被加入到限制报名了
- for _, v := range restrictSignupList {
- maptotalRestrict[v.UserId] = true
- }
- pars = make([]interface{}, 0)
- condition = ` AND a.is_limit_people = 1 AND v.is_meeting = 0 AND v.do_fail_type = 0 AND user_id IN (` + utils.GetOrmInReplace(lenuserIdSiginArr) + `)`
- pars = append(pars, userIdSiginArr)
- listSignup, e := models.GetActivitySignupInnerActivityList(condition, pars)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("GetActivitySignupInnerActivityList" + e.Error())
- return
- }
- mapNomeet := make(map[int]int)
- if len(listSignup) > 0 {
- for _, v := range listSignup {
- mapNomeet[v.UserId]++
- }
- }
- for _, v := range meetingList {
- //如果加入了爽约限制但是爽约次数少于3条就删除爽约记录
- if !maptotalRestrict[v.UserId] && mapNomeet[v.UserId] >= 3 {
- itemRestrict := new(models.CygxActivityRestrictSignup)
- itemRestrict.UserId = v.UserId
- itemRestrict.CreateTime = time.Now()
- itemRestrict.Mobile = v.Mobile
- itemRestrict.Email = v.Email
- itemRestrict.CompanyId = v.CompanyId
- itemRestrict.CompanyName = v.CompanyName
- itemRestrict.IsRestrict = 1
- itemsRestrict = append(itemsRestrict, itemRestrict)
- maptotalRestrict[v.UserId] = true
- }
- }
- e = models.DeleteCygxActivitySignupBreakByIds(activityIds)
- if e != nil {
- err = errors.New("DeleteCygxActivitySignupBreakById" + e.Error())
- return
- }
- //添加爽约记录
- if len(items) > 0 {
- _, e = models.AddCygxActivitySignupBreakList(items)
- if e != nil {
- err = errors.New("AddCygxActivitySignupBreakList, Err: " + e.Error())
- return
- }
- }
- //添加报名限制
- if len(itemsRestrict) > 0 {
- _, e = models.AddCygxActivityRestrictSignupList(itemsRestrict)
- if e != nil {
- err = errors.New("AddCygxActivityRestrictSignupList, Err: " + e.Error())
- return
- }
- }
- return
- }
- // 对个人以及机构互动数量进行排序下载使用
- func CygxActivityMeetSort(list []*models.CygxActivityAttendanceDetail, activityIds []int) (err error) {
- defer func() {
- if err != nil {
- fmt.Println("err:", err)
- go utils.SendAlarmMsg("查研观向处理活动用户限制报名失败,AddCygxActivityRestrictSignupByAdminNew,Err:"+err.Error()+"activityIds"+fmt.Sprint(activityIds), 3)
- }
- }()
- var items []*models.CygxActivityMeetDetailLog
- var condition string
- var pars []interface{}
- lenactivityIds := len(activityIds)
- if lenactivityIds == 0 {
- return
- }
- //获取已经写入到会信息的参会人员
- pars = make([]interface{}, 0)
- condition = ` AND activity_id IN (` + utils.GetOrmInReplace(lenactivityIds) + `)`
- pars = append(pars, activityIds)
- activityMeetDetailLogList, e := models.GetCygxActivityMeetDetailLogList(condition, pars)
- if e != nil {
- err = errors.New("GetCygxActivityMeetDetailLogList, Err: " + e.Error())
- return
- }
- mapActivityMeetDetailL := make(map[string]int)
- for _, v := range activityMeetDetailLogList {
- mapActivityMeetDetailL[fmt.Sprint("ActivityId:", v.ActivityId, "Mobile:", v.Mobile)] = v.ActivityId
- }
- var companyIds []int
- var companyIdsMap = make(map[int]bool)
- var mobiles []string
- var mobilesMap = make(map[string]bool)
- for _, v := range list {
- if mapActivityMeetDetailL[fmt.Sprint("ActivityId:", v.ActivityId, "Mobile:", v.Mobile)] > 0 {
- continue
- }
- item := new(models.CygxActivityMeetDetailLog)
- item.ActivityId = v.ActivityId
- item.Mobile = v.Mobile
- item.CompanyName = v.CompanyName
- item.CompanyId = v.CompanyId
- item.ActivityTime = v.ActivityTime
- item.CreateTime = v.CreateTime
- if !companyIdsMap[v.CompanyId] {
- companyIds = append(companyIds, v.CompanyId)
- }
- if !mobilesMap[v.Mobile] {
- mobiles = append(mobiles, v.Mobile)
- }
- items = append(items, item)
- }
- //插入
- e = models.AddCygxActivityMeetDetailLogMulti(items)
- if e != nil {
- err = errors.New("AddCygxActivityMeetDetailLogMulti, Err: " + e.Error())
- return
- }
- {
- //批量修改个人参会数量
- listMobileCount, e := models.GetActivityMeetDetailLogCountMobile(mobiles)
- if e != nil {
- err = errors.New("GetActivityMeetDetailLogCountCompany, Err: " + e.Error())
- return
- }
- if len(listMobileCount) > 0 {
- e = models.UpdateCygxActivityMeetDetailLogMobileNumMulti(listMobileCount)
- if e != nil {
- err = errors.New("UpdateCygxActivityMeetDetailLogMobileNumMulti, Err: " + e.Error())
- return
- }
- }
- }
- {
- //批量修改机构参会数量
- listCompanyCount, e := models.GetActivityMeetDetailLogCountCompany(companyIds)
- if e != nil {
- err = errors.New("GetActivityMeetDetailLogCountCompany, Err: " + e.Error())
- return
- }
- if len(listCompanyCount) > 0 {
- e = models.UpdateCygxActivityMeetDetailLogCompanyNumMulti(listCompanyCount)
- if e != nil {
- err = errors.New("UpdateCygxActivityMeetDetailLogCompanyNumMulti, Err: " + e.Error())
- return
- }
- }
- }
- return
- }
|