user_remind.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package cygx
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hz_crm_api/models"
  6. "hongze/hz_crm_api/models/cygx"
  7. "hongze/hz_crm_api/services/alarm_msg"
  8. "hongze/hz_crm_api/utils"
  9. )
  10. // 根据用户ID获取那些用户设置了互动提醒
  11. func GetCygxUserRemindListMap(userIds []int) (mapResp map[int]bool) {
  12. lenArr := len(userIds)
  13. if lenArr == 0 {
  14. return
  15. }
  16. var err error
  17. defer func() {
  18. if err != nil {
  19. fmt.Println(err)
  20. go alarm_msg.SendAlarmMsg("根据用户ID获取那些用户设置了互动提醒,信息失败,GetCygxUserRemindListMap Err:"+err.Error(), 3)
  21. }
  22. }()
  23. var condition string
  24. var pars []interface{}
  25. condition = ` AND user_id IN (` + utils.GetOrmInReplace(lenArr) + `)`
  26. pars = append(pars, userIds)
  27. //获取分类名称
  28. userRemindList, e := cygx.GetCygxUserRemindList(condition, pars, 0, 0)
  29. if e != nil {
  30. err = errors.New("GetCygxUserRemindList, Err: " + e.Error())
  31. return
  32. }
  33. mapResp = make(map[int]bool, 0)
  34. for _, v := range userRemindList {
  35. mapResp[v.UserId] = true
  36. }
  37. return
  38. }
  39. // 获取某一个公司下所有OpenId (查研观向主体)
  40. func GetUserOpenidByComapnyIdRai(comppanyId int) (openIdArr []string) {
  41. var err error
  42. defer func() {
  43. if err != nil {
  44. fmt.Println(err)
  45. go alarm_msg.SendAlarmMsg(fmt.Sprint("获取某一个公司下所有用户的手机号 失败 comppanyId", comppanyId, "err", err.Error()), 2)
  46. }
  47. }()
  48. listUser, e := models.GetWxUserListCompanyId(comppanyId)
  49. if e != nil {
  50. err = errors.New("GetWxUserListCompanyId" + e.Error())
  51. return
  52. }
  53. var mobileArr []string
  54. openIdArr = make([]string, 0)
  55. for _, v := range listUser {
  56. mobileArr = append(mobileArr, v.Mobile)
  57. }
  58. openIdListJmcj, e := cygx.GetUserRecordListByMobileArr(mobileArr)
  59. if e != nil {
  60. err = errors.New("GetUserRecordListByMobileArr" + e.Error())
  61. return
  62. }
  63. for _, v := range openIdListJmcj {
  64. openIdArr = append(openIdArr, v.OpenId)
  65. }
  66. return
  67. }