OfficialAccountSettingLogic.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\logic\channel;
  15. use app\common\logic\BaseLogic;
  16. use app\common\service\ConfigService;
  17. use app\common\service\FileService;
  18. /**
  19. * 公众号设置逻辑
  20. * Class OfficialAccountSettingLogic
  21. * @package app\adminapi\logic\channel
  22. */
  23. class OfficialAccountSettingLogic extends BaseLogic
  24. {
  25. /**
  26. * @notes 获取公众号配置
  27. * @return array
  28. * @author ljj
  29. * @date 2022/2/16 10:08 上午
  30. */
  31. public function getConfig()
  32. {
  33. $domainName = $_SERVER['SERVER_NAME'];
  34. $qrCode = ConfigService::get('oa_setting', 'qr_code', '');
  35. $qrCode = empty($qrCode) ? $qrCode : FileService::getFileUrl($qrCode);
  36. $config = [
  37. 'name' => ConfigService::get('oa_setting', 'name', ''),
  38. 'original_id' => ConfigService::get('oa_setting', 'original_id', ''),
  39. 'qr_code' => $qrCode,
  40. 'app_id' => ConfigService::get('oa_setting', 'app_id', ''),
  41. 'app_secret' => ConfigService::get('oa_setting', 'app_secret', ''),
  42. // url()方法返回Url实例,通过与空字符串连接触发该实例的__toString()方法以得到路由地址
  43. 'url' => url('adminapi/channel.official_account_reply/index', [],'',true).'',
  44. 'token' => ConfigService::get('oa_setting', 'token'),
  45. 'encoding_aes_key' => ConfigService::get('oa_setting', 'encoding_aes_key', ''),
  46. 'encryption_type' => ConfigService::get('oa_setting', 'encryption_type', 1),
  47. 'business_domain' => $domainName,
  48. 'js_secure_domain' => $domainName,
  49. 'web_auth_domain' => $domainName,
  50. ];
  51. return $config;
  52. }
  53. /**
  54. * @notes 设置公众号配置
  55. * @param $params
  56. * @author ljj
  57. * @date 2022/2/16 10:08 上午
  58. */
  59. public function setConfig($params)
  60. {
  61. $qrCode = isset($params['qr_code']) ? FileService::setFileUrl($params['qr_code']) : '';
  62. ConfigService::set('oa_setting','name', $params['name'] ?? '');
  63. ConfigService::set('oa_setting','original_id', $params['original_id'] ?? '');
  64. ConfigService::set('oa_setting','qr_code', $qrCode);
  65. ConfigService::set('oa_setting','app_id',$params['app_id']);
  66. ConfigService::set('oa_setting','app_secret',$params['app_secret']);
  67. ConfigService::set('oa_setting','token',$params['token'] ?? '');
  68. ConfigService::set('oa_setting','encoding_aes_key',$params['encoding_aes_key'] ?? '');
  69. ConfigService::set('oa_setting','encryption_type',$params['encryption_type']);
  70. }
  71. }