CommonService.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Author: luzheng.liu
  4. * Time: 2020/12/5 00:49
  5. */
  6. namespace app\common\service;
  7. use app\index\model\SettingModel;
  8. class CommonService {
  9. static $setData;
  10. public static function getSetData() {
  11. if (empty(self::$setData)){
  12. $data = (new SettingModel())::where(['id' => 1])->find();
  13. self::$setData = $data;
  14. return $data;
  15. }
  16. return self::$setData;
  17. }
  18. public static function getChannelId(): int {
  19. self::getSetData();
  20. return self::$setData['channel_id'];
  21. }
  22. public static function getAuthKey(): string {
  23. self::getSetData();
  24. return self::$setData['channel_auth_code'];
  25. }
  26. public static function getAuthUrl() {
  27. $baseUrl = self::getBaeUrl();
  28. return $baseUrl.'?redirecturi='.self::getRedirectUrl();
  29. }
  30. public static function getBaeUrl() {
  31. $data = self::getSetData();
  32. return "http://{$data['domain']}/api/wechat/focusarea/{$data['site_id']}/{$data['unique_key']}";
  33. }
  34. public static function getRedirectUrl() {
  35. return self::getSetData()['redirct_url'];
  36. }
  37. }