Role.php 1022 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace common\util;
  3. use common\models\BaseUser;
  4. use common\models\LwtCompanyInfoBase;
  5. class Role
  6. {
  7. /**
  8. * 判断是否是客户
  9. * @param BaseUser $userInfo
  10. * @return bool
  11. */
  12. public static function isCommonUser(BaseUser $userInfo)
  13. {
  14. $result = false;
  15. if ($userInfo->category == 1) {
  16. $result = true;
  17. }
  18. return $result;
  19. }
  20. public static function getCommonUserCompanyScanId(BaseUser $userInfo)
  21. {
  22. $LwtCompanyInfo = LwtCompanyInfoBase::findOne(["company_name" => $userInfo->company]);
  23. if ($LwtCompanyInfo) {
  24. $scan_id = $LwtCompanyInfo->scan_id;
  25. } else {
  26. $scan_id = $userInfo->login_name;
  27. }
  28. return $scan_id;
  29. }
  30. public static function ifCommonUserAddScanId(BaseUser $userInfo)
  31. {
  32. $addParams = [];
  33. if (self::isCommonUser($userInfo)) {
  34. $addParams["scan_id"] = $userInfo->CompanyScanId;
  35. }
  36. return $addParams;
  37. }
  38. }