package cygx

import (
	"errors"
	"hongze/hz_crm_api/models"
	"hongze/hz_crm_api/models/cygx"
	"strconv"
	"strings"
)

// 校验该用户是否有报名权限
func CheckaddSpecialSignuUserPower(wxuser *models.WxUser, activityInfo *cygx.ActivitySpecialDetail) (havePower bool) {
	companyId := wxuser.CompanyId
	companyPermission, _ := cygx.GetCompanyPermission(companyId)
	if companyPermission == "" {
		return
	}
	userType, _ := GetSpecialUserType(wxuser)
	if strings.Contains(activityInfo.CustomerTypeIds, strconv.Itoa(userType)) && strings.Contains(companyPermission, activityInfo.ChartPermissionName) {
		havePower = true
	}
	return
}

func GetSpecialTripUserMap(activityId int) (mapUserId map[int]int, err error) {
	list, e := cygx.GetCygxActivitySpecialTripListByActivityId(activityId)
	if e != nil {
		err = errors.New("GetCygxActivitySpecialTripListByActivityId, Err: " + e.Error())
		return
	}
	mapUid := make(map[int]int)
	for _, v := range list {
		mapUid[v.UserId] = v.UserId
	}
	mapUserId = mapUid
	return
}
