OfficialAccountSettingLogic.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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\wechat;
  20. use app\common\logic\BaseLogic;
  21. use app\common\service\ConfigService;
  22. use app\common\service\FileService;
  23. /**
  24. * 微信公众号设置逻辑层
  25. * Class OfficialAccountSettingLogic
  26. * @package app\adminapi\logic\wechat
  27. */
  28. class OfficialAccountSettingLogic extends BaseLogic
  29. {
  30. /**
  31. * @notes 获取微信公众号设置
  32. * @return array
  33. * @author Tab
  34. * @date 2021/7/28 17:20
  35. */
  36. public static function getConfig()
  37. {
  38. $domainName = $_SERVER['SERVER_NAME'];
  39. $qrCode = ConfigService::get('official_account', 'qr_code', '');
  40. $qrCode = empty($qrCode) ? $qrCode : FileService::getFileUrl($qrCode);
  41. $config = [
  42. 'name' => ConfigService::get('official_account', 'name', ''),
  43. 'original_id' => ConfigService::get('official_account', 'original_id', ''),
  44. 'qr_code' => $qrCode,
  45. 'app_id' => ConfigService::get('official_account', 'app_id', ''),
  46. 'app_secret' => ConfigService::get('official_account', 'app_secret', ''),
  47. // url()方法返回Url实例,通过与空字符串连接触发该实例的__toString()方法以得到路由地址
  48. 'url' => url('adminapi/wechat.official_account_reply/index', [],'',true).'',
  49. 'token' => ConfigService::get('official_account', 'token'),
  50. 'encoding_aes_key' => ConfigService::get('official_account', 'encoding_aes_key', ''),
  51. 'encryption_type' => ConfigService::get('official_account', 'encryption_type'),
  52. 'business_domain' => $domainName,
  53. 'js_secure_domain' => $domainName,
  54. 'web_auth_domain' => $domainName,
  55. ];
  56. return $config;
  57. }
  58. /**
  59. * @notes 微信公众号设置
  60. * @param $params
  61. * @author Tab
  62. * @date 2021/7/28 17:56
  63. */
  64. public static function setConfig($params)
  65. {
  66. $qrCode = isset($params['qr_code']) ? FileService::setFileUrl($params['qr_code']) : '';
  67. ConfigService::set('official_account','name', $params['name'] ?? '');
  68. ConfigService::set('official_account','original_id', $params['original_id'] ?? '');
  69. ConfigService::set('official_account','qr_code', $qrCode);
  70. ConfigService::set('official_account','app_id',$params['app_id']);
  71. ConfigService::set('official_account','app_secret',$params['app_secret']);
  72. ConfigService::set('official_account','token',$params['token'] ?? '');
  73. ConfigService::set('official_account','encoding_aes_key',$params['encoding_aes_key'] ?? '');
  74. ConfigService::set('official_account','encryption_type',$params['encryption_type']);
  75. }
  76. }