SystemAuthServices.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\services\system;
  12. use app\services\BaseServices;
  13. use crmeb\exceptions\AdminException;
  14. use crmeb\services\HttpService;
  15. /**
  16. * 商业授权
  17. * Class SystemAuthServices
  18. * @package app\services\system
  19. */
  20. class SystemAuthServices extends BaseServices
  21. {
  22. /**
  23. * 申请授权
  24. * @param array $data
  25. * @return bool
  26. */
  27. public function authApply(array $data, $headerData)
  28. {
  29. $res = HttpService::postRequest('http://authorize.crmeb.net/api/auth_apply', $data, $headerData);
  30. if ($res === false) {
  31. throw new AdminException('申请失败,服务器没有响应!');
  32. }
  33. $res = json_decode($res, true);
  34. if (isset($res['status'])) {
  35. if ($res['status'] == 400) {
  36. throw new AdminException($res['msg'] ?? "申请失败");
  37. } else {
  38. return true;
  39. }
  40. }
  41. }
  42. }