package cygx

import (
	"errors"
	"fmt"
	"hongze/hz_crm_api/models/cygx"
	"hongze/hz_crm_api/services/alarm_msg"
	"hongze/hz_crm_api/utils"
)

// GetCygxUserBusinessCardMap 获取手机号对应的邀请人
func GetCygxUserBusinessCardMap(mobileArr []string) (mapResp map[string]string) {
	lenArr := len(mobileArr)
	if lenArr == 0 {
		return
	}
	var err error
	defer func() {
		if err != nil {
			fmt.Println(err)
			go alarm_msg.SendAlarmMsg("获取手机号对应的邀请人，信息失败，GetCygxUserBusinessCardMap Err："+err.Error(), 3)
		}
	}()
	var condition string
	var pars []interface{}

	condition = ` AND  mobile IN (` + utils.GetOrmInReplace(lenArr) + `)`
	pars = append(pars, mobileArr)
	list, e := cygx.GetCygxUserBusinessCardList(condition, pars, 0, lenArr)
	if e != nil && e.Error() != utils.ErrNoRow() {
		err = errors.New("GetArticlList, Err: " + e.Error())
		return
	}
	mapResp = make(map[string]string, 0)
	for _, v := range list {
		mapResp[v.Mobile] = v.InviteName
	}
	return
}
