common.php 894 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. use thans\jwt\facade\JWTAuth;
  3. // 应用公共文件
  4. function getXzqdm(){
  5. $payload = JWTAuth::auth();
  6. return $payload['xzqdm']->getValue();
  7. }
  8. function getUserId(){
  9. $payload = JWTAuth::auth();
  10. return $payload['id']->getValue();
  11. }
  12. function getQydm(){
  13. $payload = JWTAuth::auth();
  14. return $payload['qydm']->getValue();
  15. }
  16. /**
  17. * @return false|string
  18. * 获取行政区代码,并去除结尾的0
  19. */
  20. function getXzqdmSub(){
  21. $payload = JWTAuth::auth();
  22. $xzqdm = $payload['xzqdm']->getValue();
  23. $province = substr($xzqdm,3);
  24. $city = substr($xzqdm,4);
  25. $country = substr($xzqdm,6);
  26. if($province === "000000"){
  27. $code = substr($xzqdm,0,2);
  28. }else if ($city === "00000"){
  29. $code = substr($xzqdm,0,4);
  30. }else if ($country === "000"){
  31. $code = substr($xzqdm,0,6);
  32. }else{
  33. $code = $xzqdm ;
  34. }
  35. return $code;
  36. }