ConfigLogic.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\logic;
  20. use app\adminapi\logic\auth\AuthLogic;
  21. use app\common\{cache\AdminAuthCache, model\Role, service\ConfigService, service\FileService};
  22. use think\facade\Config;
  23. /**
  24. * 配置类逻辑层
  25. * Class ConfigLogic
  26. * @package app\adminapi\logic
  27. */
  28. class ConfigLogic
  29. {
  30. /**
  31. * @notes 获取配置
  32. * @return array
  33. * @author cjhao
  34. * @date 2021/8/19 16:28
  35. */
  36. public static function getConfig():array
  37. {
  38. $data = [
  39. 'oss_domain' => FileService::getFileUrl(),
  40. 'copyright' => ConfigService::get('shop', 'copyright', ''),
  41. 'record_number' => ConfigService::get('shop', 'record_number', ''),
  42. 'record_system_link' => ConfigService::get('shop', 'record_system_link', ''),
  43. 'name' => ConfigService::get('shop', 'name'),
  44. 'logo' => FileService::getFileUrl(ConfigService::get('shop', 'logo')),
  45. 'admin_login_image' => FileService::getFileUrl(ConfigService::get('shop', 'admin_login_image')),
  46. 'favicon' => FileService::getFileUrl(ConfigService::get('shop','favicon')),
  47. 'document_status' => ConfigService::get('shop','document_status',1),
  48. 'version' => config('project.version'),
  49. ];
  50. return $data;
  51. }
  52. /**
  53. * @notes 获取菜单权限
  54. * @param array $adminInfo
  55. * @return array
  56. * @throws \think\db\exception\DataNotFoundException
  57. * @throws \think\db\exception\DbException
  58. * @throws \think\db\exception\ModelNotFoundException
  59. * @author cjhao
  60. * @date 2021/8/25 20:33
  61. */
  62. public static function getAuth(array $adminInfo):array
  63. {
  64. $data = [
  65. 'root' => $adminInfo['root'],
  66. 'auth' => [],
  67. ];
  68. if(1 == $adminInfo['root']){
  69. return $data;
  70. }
  71. $adminAuthCache = new AdminAuthCache($adminInfo['admin_id']);
  72. $pageAuth = $adminAuthCache->getAdminPageAuth();
  73. $data['auth'] = $pageAuth;
  74. return $data;
  75. }
  76. /**
  77. * @notes 获取营销中心模块
  78. * @return array
  79. * @author cjhao
  80. * @date 2021/9/11 11:43
  81. */
  82. public static function getMarketingModule():array
  83. {
  84. $configModule = Config::get('module');
  85. return $configModule['marketing'];
  86. }
  87. /**
  88. * @notes 获取应用中心模块
  89. * @return array
  90. * @author cjhao
  91. * @date 2021/9/24 16:55
  92. */
  93. public static function getAppModule():array
  94. {
  95. $configModule = Config::get('module');
  96. return $configModule['apply'];
  97. }
  98. /**
  99. * @notes 正版检测
  100. * @return mixed
  101. * @author ljj
  102. * @date 2023/5/16 11:49 上午
  103. */
  104. public static function checkLegal()
  105. {
  106. $check_domain = config('project.check_domain');
  107. $product_code = config('project.product_code');
  108. $domain = $_SERVER['HTTP_HOST'];
  109. $result = \Requests::get($check_domain.'/api/version/productAuth?code='.$product_code.'&domain='.$domain);
  110. $result = json_decode($result->body,true);
  111. return $result['data'];
  112. }
  113. }