ConfigLogic.php 5.0 KB

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