WechatConfig.php 781 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace app\common\model;
  3. class WechatConfig extends Base
  4. {
  5. /**
  6. * 获取微信号配置
  7. * @param $key
  8. * @return array|false
  9. * @throws \think\db\exception\DataNotFoundException
  10. * @throws \think\db\exception\DbException
  11. * @throws \think\db\exception\ModelNotFoundException
  12. */
  13. public static function getEasyWechatConfig($key)
  14. {
  15. $where = [];
  16. $where[] = ["app_id|app_code", "=", $key];
  17. $wechatConfig = self::where($where)->find();
  18. if (!$wechatConfig) {
  19. return false;
  20. }
  21. $config = [
  22. 'app_id' => $wechatConfig->app_id,
  23. 'secret' => $wechatConfig->secret,
  24. 'sign_key'=>$wechatConfig->sign_key,
  25. ];
  26. return $config;
  27. }
  28. }