123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- // +----------------------------------------------------------------------
- // | Niucloud-admin 企业快速开发的saas管理平台
- // +----------------------------------------------------------------------
- // | 官方网址:https://www.niucloud.com
- // +----------------------------------------------------------------------
- // | niucloud团队 版权所有 开源版本可自由商用
- // +----------------------------------------------------------------------
- // | Author: Niucloud Team
- // +----------------------------------------------------------------------
- namespace app\service\admin\wechat;
- use app\model\sys\SysConfig;
- use app\service\core\sys\CoreConfigService;
- use app\service\core\wechat\CoreWechatApiService;
- use core\base\BaseAdminService;
- use core\exception\WechatException;
- use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
- use GuzzleHttp\Exception\GuzzleException;
- use think\Model;
- /**
- * 微信菜单
- * Class WechatConfigService
- * @package app\service\core\wechat
- */
- class WechatMenuService extends BaseAdminService
- {
- /**
- * 获取微信菜单
- * @return array|mixed
- */
- public function getInfo(){
- $core_config_service = new CoreConfigService();
- return $core_config_service->getConfig($this->request->defaultSiteId(), 'WECHAT_MENU')['value'] ?? [];
- }
- /**
- * 更新微信菜单
- * @param array $data
- * @return SysConfig|bool|Model
- * @throws GuzzleException
- * @throws InvalidConfigException
- */
- public function edit(array $data){
- $core_wechat_api_service = new CoreWechatApiService();
- $menu_result = $core_wechat_api_service->menuCreate($this->site_id, $data);
- if(!empty($menu_result['errcode']) && $menu_result['errcode'] != 0)
- throw new WechatException($menu_result['errmsg']);
- //先尝试改变微信接口菜单
- $core_config_service = new CoreConfigService();
- return $core_config_service->setConfig($this->request->defaultSiteId(), 'WECHAT_MENU', $data);
- }
- }
|