Factory.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\common\library\wechat;
  10. use xzncit\Factory as WechatFactory;
  11. use app\common\models\Setting as SettingModel;
  12. class Factory {
  13. /**
  14. * init wechat
  15. * @param array $config
  16. * @return \xzncit\wechat\Wechat
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\DbException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. */
  21. public static function wechat(array $config = []){
  22. if(empty($config)){
  23. $config = SettingModel::getArrayData("wechat");
  24. }
  25. return WechatFactory::Wechat([
  26. "token" => trim($config["token"]),
  27. "appid" => trim($config["appid"]),
  28. "appsecret" => trim($config["appsecret"]),
  29. "enaeskey" => trim($config["enaes_key"])
  30. ]);
  31. }
  32. }