ConfigLogic.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. public static function getVedioConfig():array
  53. {
  54. $vedio_setting = ConfigService::get('shop', 'vedio_set', '');
  55. $vedio_setting['file_url'] = FileService::getFileUrl( $vedio_setting['file_url']);
  56. $data = [
  57. 'vedio_setting' =>$vedio_setting
  58. ];
  59. return $data;
  60. }
  61. /**
  62. * @notes 获取菜单权限
  63. * @param array $adminInfo
  64. * @return array
  65. * @throws \think\db\exception\DataNotFoundException
  66. * @throws \think\db\exception\DbException
  67. * @throws \think\db\exception\ModelNotFoundException
  68. * @author cjhao
  69. * @date 2021/8/25 20:33
  70. */
  71. public static function getAuth(array $adminInfo):array
  72. {
  73. $data = [
  74. 'root' => $adminInfo['root'],
  75. 'auth' => [],
  76. ];
  77. if(1 == $adminInfo['root']){
  78. return $data;
  79. }
  80. $adminAuthCache = new AdminAuthCache($adminInfo['admin_id']);
  81. $pageAuth = $adminAuthCache->getAdminPageAuth();
  82. $data['auth'] = $pageAuth;
  83. return $data;
  84. }
  85. /**
  86. * @notes 获取营销中心模块
  87. * @return array
  88. * @author cjhao
  89. * @date 2021/9/11 11:43
  90. */
  91. public static function getMarketingModule():array
  92. {
  93. $configModule = Config::get('module');
  94. return $configModule['marketing'];
  95. }
  96. /**
  97. * @notes 获取应用中心模块
  98. * @return array
  99. * @author cjhao
  100. * @date 2021/9/24 16:55
  101. */
  102. public static function getAppModule():array
  103. {
  104. $configModule = Config::get('module');
  105. return $configModule['apply'];
  106. }
  107. /**
  108. * @notes 正版检测
  109. * @return mixed
  110. * @author ljj
  111. * @date 2023/5/16 11:49 上午
  112. */
  113. public static function checkLegal()
  114. {
  115. $check_domain = config('project.check_domain');
  116. $product_code = config('project.product_code');
  117. $domain = $_SERVER['HTTP_HOST'];
  118. $result = \Requests::get($check_domain.'/api/version/productAuth?code='.$product_code.'&domain='.$domain);
  119. $result = json_decode($result->body,true);
  120. return $result['data'];
  121. }
  122. }