|
@@ -1571,7 +1571,7 @@ func ActivityAttendanceDetail(cont context.Context) (err error) {
|
|
|
}
|
|
|
|
|
|
// 判断是否加入黑名单
|
|
|
-func AddCygxActivityRestrictSignupByAdmin(activityId int) (err error) {
|
|
|
+func AddCygxActivityRestrictSignupByAdmin111(activityId int) (err error) {
|
|
|
defer func() {
|
|
|
if err != nil {
|
|
|
fmt.Println(err)
|
|
@@ -1679,6 +1679,185 @@ func AddCygxActivityRestrictSignupByAdmin(activityId int) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// 查研观向处理活动用户限制报名
|
|
|
+func AddCygxActivityRestrictSignupByAdmin(activityId int) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("err:", err)
|
|
|
+ go utils.SendAlarmMsg("查研观向处理活动用户限制报名失败,Err:"+err.Error()+"activityId"+strconv.Itoa(activityId), 3)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ activityInfo, e := models.GetAddActivityInfoById(activityId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetAddActivityInfoById" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if activityInfo == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //不限制报名的不做爽约限制处理
|
|
|
+ //if activityInfo.IsLimitPeople > 0 {
|
|
|
+ //total, err := cygx.GetActivitySignupNomeetingCount(activityId)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ mobileList, _ := models.GetUserMeetingMobile(activityId)
|
|
|
+ var userIdArr []int
|
|
|
+ if len(mobileList) > 0 {
|
|
|
+ for _, v := range mobileList {
|
|
|
+ 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) + `)`
|
|
|
+ pars = append(pars, userIdArr)
|
|
|
+ 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 mobileList {
|
|
|
+ //如果加入了爽约限制但是爽约次数少于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
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //if total == 0 {
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //}
|
|
|
+ list, e := models.GetActivitySignupNomeetingCountList(activityId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("GetActivitySignupNomeetingCountList" + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var userIdSiginArr []int
|
|
|
+ var items []*models.CygxActivitySignupBreak
|
|
|
+ for _, v := range list {
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ if len(list) == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ var itemsRestrict []*models.CygxActivityRestrictSignup
|
|
|
+ maptotalRestrict := make(map[int]bool)
|
|
|
+ lenuserIdSiginArr := len(userIdSiginArr)
|
|
|
+ var condition string
|
|
|
+ var pars []interface{}
|
|
|
+ condition = ` AND user_id IN (` + utils.GetOrmInReplace(lenuserIdSiginArr) + `)`
|
|
|
+ pars = append(pars, userIdSiginArr)
|
|
|
+ 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 mobileList {
|
|
|
+ //如果加入了爽约限制但是爽约次数少于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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ err = models.DeleteCygxActivitySignupBreakById(activityId)
|
|
|
+ if err != nil {
|
|
|
+ err = errors.New("DeleteCygxActivitySignupBreakById" + err.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 IsShowAppointment(activityTypeId int, chartPermissionName string) (isShowAppointment bool) {
|
|
|
if activityTypeId == 1 || activityTypeId == 2 || activityTypeId == 3 || activityTypeId == 4 {
|