crm.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package mcndao
  2. import (
  3. "go-common/app/interface/main/mcn/model/mcnmodel"
  4. "go-common/library/log"
  5. )
  6. //GetActiveTid get tid from crm database
  7. func (d *Dao) GetActiveTid(mids []int64) (res map[int64]int64, err error) {
  8. var infoList []*mcnmodel.UpBaseInfo
  9. err = d.mcndb.Select("mid, active_tid").Where("mid in (?) and business_type=1", mids).Find(&infoList).Error
  10. if err != nil {
  11. log.Error("fail to get active_tid from crm, err=%s", err)
  12. return
  13. }
  14. res = make(map[int64]int64, len(infoList))
  15. for _, v := range infoList {
  16. res[v.Mid] = v.ActiveTid
  17. }
  18. return
  19. }
  20. //GetUpBaseInfo get up base info from crm database
  21. func (d *Dao) GetUpBaseInfo(fields string, mids []int64) (res map[int64]*mcnmodel.UpBaseInfo, err error) {
  22. var infoList []*mcnmodel.UpBaseInfo
  23. err = d.mcndb.Select(fields).Where("mid in (?) and business_type=1", mids).Find(&infoList).Error
  24. if err != nil {
  25. log.Error("fail to get active_tid from crm, err=%s", err)
  26. return
  27. }
  28. res = make(map[int64]*mcnmodel.UpBaseInfo, len(infoList))
  29. for _, v := range infoList {
  30. res[v.Mid] = v
  31. }
  32. return
  33. }