Erp.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 crmeb\services\erp;
  12. use crmeb\basic\BaseManager;
  13. use crmeb\services\erp\storage\Jushuitan;
  14. use think\Container;
  15. use think\facade\Config;
  16. /**
  17. * Class Erp
  18. * @package crmeb\services\erp
  19. * @mixin Jushuitan
  20. */
  21. class Erp extends BaseManager
  22. {
  23. /**
  24. * 空间名
  25. * @var string
  26. */
  27. protected $namespace = '\\crmeb\\services\\erp\\storage\\';
  28. protected $type = [
  29. 'nothing',
  30. 'jushuitan',
  31. ];
  32. /**
  33. * 默认驱动
  34. * @return mixed
  35. */
  36. protected function getDefaultDriver()
  37. {
  38. $this->config = [
  39. 'app_key' => sys_config('jst_appkey'),
  40. 'secret' => sys_config('jst_appsecret'),
  41. 'login_account' => sys_config('jst_login_account'),
  42. 'login_password' => sys_config('jst_login_password'),
  43. ];
  44. return $this->type[sys_config('erp_type')];
  45. }
  46. /**
  47. * 获取类的实例
  48. * @param $class
  49. * @return mixed|void
  50. */
  51. protected function invokeClass($class)
  52. {
  53. if (!class_exists($class)) {
  54. throw new \RuntimeException('class not exists: ' . $class);
  55. }
  56. $this->getConfigFile();
  57. if (!$this->config) {
  58. $this->config = Config::get($this->configFile . '.stores.' . $this->name, []);
  59. }
  60. $handleAccessToken = new AccessToken($this->name, $this->configFile, $this->config);
  61. $handle = Container::getInstance()->invokeClass($class, [$this->name, $handleAccessToken, $this->configFile]);
  62. $this->config = [];
  63. return $handle;
  64. }
  65. }