system.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package services
  2. import (
  3. "eta/eta_mobile/models/company"
  4. "eta/eta_mobile/models/system"
  5. )
  6. // CheckAdminIsSameBigGroup 判断是否两个系统用户是否同一个大组内
  7. func CheckAdminIsSameBigGroup(adminInfo1, adminInfo2 *system.Admin) (isSame bool, err error) {
  8. // 如果销售和创建人是同一个小组
  9. if adminInfo1.GroupId == adminInfo2.GroupId {
  10. isSame = true
  11. return
  12. }
  13. var admin1BigGroupId, admin2BigGroupId int
  14. //获取第一个系统用户的大组id
  15. {
  16. //获取该账号的大组id
  17. pid, tmpErr := company.GetParentIdFromGroup(adminInfo1.GroupId)
  18. if tmpErr != nil {
  19. err = tmpErr
  20. return
  21. }
  22. if pid != nil && *pid > 0 {
  23. //该账号放在了三级分组下
  24. admin1BigGroupId = *pid
  25. } else {
  26. //该账号放在了二级分组下
  27. admin1BigGroupId = adminInfo1.GroupId
  28. }
  29. }
  30. //获取第二个系统用户的大组id
  31. {
  32. //获取该账号的大组id
  33. pid, tmpErr := company.GetParentIdFromGroup(adminInfo2.GroupId)
  34. if tmpErr != nil {
  35. err = tmpErr
  36. return
  37. }
  38. if pid != nil && *pid > 0 {
  39. //该账号放在了三级分组下
  40. admin2BigGroupId = *pid
  41. } else {
  42. //该账号放在了二级分组下
  43. admin2BigGroupId = adminInfo2.GroupId
  44. }
  45. }
  46. if admin1BigGroupId == admin2BigGroupId {
  47. isSame = true
  48. return
  49. }
  50. return
  51. }