admin.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. package services
  2. import (
  3. "errors"
  4. "hongze/hongze_mfyx/models"
  5. "hongze/hongze_mfyx/models/company"
  6. "hongze/hongze_mfyx/utils"
  7. )
  8. func GetAdminMobileMap() (mapItem map[string]string, err error) {
  9. adminList, e := models.GetRaiAdmin()
  10. if e != nil {
  11. err = e
  12. return
  13. }
  14. mapMobile := make(map[string]string)
  15. for _, v := range adminList {
  16. mapMobile[v.Mobile] = v.Mobile
  17. }
  18. mapItem = mapMobile
  19. return
  20. }
  21. func GetActivityCcustomerTypeList() (mapItem map[int]string, err error) {
  22. list, e := models.GetActivityCcustomerTypeList()
  23. if e != nil {
  24. err = e
  25. return
  26. }
  27. mapUserType := make(map[int]string)
  28. for _, v := range list {
  29. mapUserType[v.CustomerTypeId] = v.PermissionValue
  30. }
  31. mapUserType[0] = "0"
  32. mapItem = mapUserType
  33. return
  34. }
  35. // GetRaiAdminMobileMap 获取权益内部人员手机号
  36. func GetRaiAdminMobileMap() (mapItem map[string]string) {
  37. var err error
  38. defer func() {
  39. if err != nil {
  40. go utils.SendAlarmMsg("获取权益内部人员手机号失败 ErrMsg:"+err.Error(), 2)
  41. }
  42. }()
  43. adminList, e := models.GetRaiAdmin()
  44. if e != nil {
  45. err = e
  46. return
  47. }
  48. mapMobile := make(map[string]string)
  49. for _, v := range adminList {
  50. mapMobile[v.Mobile] = v.Mobile
  51. }
  52. mapItem = mapMobile
  53. return
  54. }
  55. // 根据手机号判断是否属于权益
  56. func GetBelongingRai(mobile string) (isBelong bool) {
  57. mapItem := GetRaiAdminMobileMap()
  58. if mapItem[mobile] != "" {
  59. isBelong = true
  60. }
  61. return
  62. }
  63. // GetAdminCheckUserMobileMap 获取对应销售所能查看的用户手机号
  64. func GetAdminCheckUserMobileMap(user *models.WxUserItem) (mapItem map[string]string, err error) {
  65. admin, e := models.GetSysAdminByMobile(user.Mobile)
  66. if e != nil {
  67. err = e
  68. return
  69. }
  70. userList, e := models.GetSellerUserMobile(admin.AdminId)
  71. if e != nil {
  72. err = e
  73. return
  74. }
  75. mapMobile := make(map[string]string)
  76. for _, v := range userList {
  77. mapMobile[v.Mobile] = v.Mobile
  78. }
  79. mapItem = mapMobile
  80. return
  81. }
  82. // 根据公司ID获取权益销售、共享销售手机号
  83. func GetCompanySellerAndShareMobileByRai(companyId int) (mobiles []string, err error) {
  84. productDetail, e := company.GetCompanyProductDetailByCompanyId(companyId, 2)
  85. if e != nil {
  86. err = errors.New("GetCompanyProductDetailByCompanyId, Err: " + e.Error())
  87. return
  88. }
  89. var adminIds []int
  90. adminIds = append(adminIds, productDetail.SellerId)
  91. if productDetail.ShareSellerId > 0 {
  92. adminIds = append(adminIds, productDetail.ShareSellerId)
  93. }
  94. listAdmin, e := models.GetAdminByAdminIds(adminIds)
  95. if e != nil {
  96. err = errors.New("GetAdminByAdminIds, Err: " + e.Error())
  97. return
  98. }
  99. mobiles = make([]string, 0)
  100. for _, v := range listAdmin {
  101. if v.Mobile != "" {
  102. mobiles = append(mobiles, v.Mobile)
  103. }
  104. }
  105. return
  106. }