123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- package services
- import (
- "errors"
- "hongze/hongze_mfyx/models"
- "hongze/hongze_mfyx/models/company"
- "hongze/hongze_mfyx/utils"
- )
- func GetAdminMobileMap() (mapItem map[string]string, err error) {
- adminList, e := models.GetRaiAdmin()
- if e != nil {
- err = e
- return
- }
- mapMobile := make(map[string]string)
- for _, v := range adminList {
- mapMobile[v.Mobile] = v.Mobile
- }
- mapItem = mapMobile
- return
- }
- func GetActivityCcustomerTypeList() (mapItem map[int]string, err error) {
- list, e := models.GetActivityCcustomerTypeList()
- if e != nil {
- err = e
- return
- }
- mapUserType := make(map[int]string)
- for _, v := range list {
- mapUserType[v.CustomerTypeId] = v.PermissionValue
- }
- mapUserType[0] = "0"
- mapItem = mapUserType
- return
- }
- // GetRaiAdminMobileMap 获取权益内部人员手机号
- func GetRaiAdminMobileMap() (mapItem map[string]string) {
- var err error
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("获取权益内部人员手机号失败 ErrMsg:"+err.Error(), 2)
- }
- }()
- adminList, e := models.GetRaiAdmin()
- if e != nil {
- err = e
- return
- }
- mapMobile := make(map[string]string)
- for _, v := range adminList {
- mapMobile[v.Mobile] = v.Mobile
- }
- mapItem = mapMobile
- return
- }
- // 根据手机号判断是否属于权益
- func GetBelongingRai(mobile string) (isBelong bool) {
- mapItem := GetRaiAdminMobileMap()
- if mapItem[mobile] != "" {
- isBelong = true
- }
- return
- }
- // GetAdminCheckUserMobileMap 获取对应销售所能查看的用户手机号
- func GetAdminCheckUserMobileMap(user *models.WxUserItem) (mapItem map[string]string, err error) {
- admin, e := models.GetSysAdminByMobile(user.Mobile)
- if e != nil {
- err = e
- return
- }
- userList, e := models.GetSellerUserMobile(admin.AdminId)
- if e != nil {
- err = e
- return
- }
- mapMobile := make(map[string]string)
- for _, v := range userList {
- mapMobile[v.Mobile] = v.Mobile
- }
- mapItem = mapMobile
- return
- }
- // 根据公司ID获取权益销售、共享销售手机号
- func GetCompanySellerAndShareMobileByRai(companyId int) (mobiles []string, err error) {
- productDetail, e := company.GetCompanyProductDetailByCompanyId(companyId, 2)
- if e != nil {
- err = errors.New("GetCompanyProductDetailByCompanyId, Err: " + e.Error())
- return
- }
- var adminIds []int
- adminIds = append(adminIds, productDetail.SellerId)
- if productDetail.ShareSellerId > 0 {
- adminIds = append(adminIds, productDetail.ShareSellerId)
- }
- listAdmin, e := models.GetAdminByAdminIds(adminIds)
- if e != nil {
- err = errors.New("GetAdminByAdminIds, Err: " + e.Error())
- return
- }
- mobiles = make([]string, 0)
- for _, v := range listAdmin {
- if v.Mobile != "" {
- mobiles = append(mobiles, v.Mobile)
- }
- }
- return
- }
|