- 优化报错

v6 v6.0.31
Chaim 4 years ago
parent 0dcd1d0443
commit 2768fd79cb

@ -86,6 +86,10 @@ return [
'dingtalk' => [
'access_token' => ''
],
// 企业微信
'qyweixin' => [
'key' => ''
],
// 微信
'wechat' => [
// 通知微信

@ -19,6 +19,7 @@ namespace DtApp\ThinkLibrary\exception;
use DtApp\ThinkLibrary\service\curl\HttpService;
use DtApp\ThinkLibrary\service\DingTalkService;
use DtApp\ThinkLibrary\service\Ip\QqWryService;
use DtApp\ThinkLibrary\service\wechat\QyService;
use think\exception\Handle;
use think\exception\HttpException;
use think\exception\ValidateException;
@ -39,7 +40,7 @@ class ThinkException extends Handle
* @param Throwable $e
* @return Response
* @throws AliException
* @throws CurlException|IpException
* @throws CurlException|IpException|NoticeException
*/
public function render($request, Throwable $e): Response
{
@ -61,6 +62,7 @@ class ThinkException extends Handle
* @throws AliException
* @throws CurlException
* @throws IpException
* @throws NoticeException
*/
private function show($msg)
{
@ -72,12 +74,18 @@ class ThinkException extends Handle
->accessToken($access_token)
->text($msg);
}
if (!empty($nt) && $nt == 'wechat') {
if (!empty($nt) && $nt == 'qyweixin') {
$key = config('dtapp.exception.qyweixin.key', '');
if (!empty($key)) return QyService::instance()
->key($key)
->text($msg);
}
if (!empty($nt) && $nt === 'wechat') {
$openid = config('dtapp.exception.wechat.openid', '');
$ip = config('dtapp.exception.wechat.ip', '未配置');
$seip = get_ip();
$ipinfo = QqWryService::instance()->getLocation($seip);
if (isset($ipinfo['location_all'])) $ipinfo['location_all'] = '';
if (!isset($ipinfo['location_all'])) $ipinfo['location_all'] = '';
if (!empty($openid)) return HttpService::instance()
->url("https://api.dtapp.net/v1/wechatmp/tmplmsgWebError/openid/{$openid}")
->post()

@ -0,0 +1,61 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service;
use DtApp\ThinkLibrary\exception\CurlException;
use DtApp\ThinkLibrary\Service;
use DtApp\ThinkLibrary\service\curl\HttpService;
/**
* 倍洽
* Class BeAryChatService
* @package DtApp\ThinkLibrary\service
*/
class BeAryChatService extends Service
{
/**
* 发送文本消息
* @param string $webhook
* @param string $content 消息内容
* @return bool 发送结果
* @throws CurlException
*/
public function text(string $webhook, string $content)
{
return $this->sendMsg($webhook, [
'text' => $content
]);
}
/**
* 组装发送消息
* @param string $webhook
* @param array $data 消息内容数组
* @return bool 发送结果
* @throws CurlException
*/
private function sendMsg(string $webhook, array $data)
{
$result = HttpService::instance()
->url($webhook)
->data($data)
->toArray();
if ($result['code'] !== 0) return true;
return false;
}
}

@ -1,24 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service\Notice;
use DtApp\ThinkLibrary\Service;
class BeAryChatService extends Service
{
}

@ -1,24 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service\Notice;
use DtApp\ThinkLibrary\Service;
class SendCloudService extends Service
{
}

@ -1,24 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service\Notice;
use DtApp\ThinkLibrary\Service;
class WorkKileService extends Service
{
}

@ -0,0 +1,62 @@
<?php
// +----------------------------------------------------------------------
// | ThinkLibrary 6.0 for ThinkPhP 6.0
// +----------------------------------------------------------------------
// | 版权所有 2017~2020 [ https://www.dtapp.net ]
// +----------------------------------------------------------------------
// | 官方网站: https://gitee.com/liguangchun/ThinkLibrary
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 仓库地址 https://gitee.com/liguangchun/ThinkLibrary
// | github 仓库地址 https://github.com/GC0202/ThinkLibrary
// | Packagist 地址 https://packagist.org/packages/liguangchun/think-library
// +----------------------------------------------------------------------
namespace DtApp\ThinkLibrary\service;
use DtApp\ThinkLibrary\exception\CurlException;
use DtApp\ThinkLibrary\Service;
use DtApp\ThinkLibrary\service\curl\HttpService;
/**
* WorkTile
* Class WorkKileService
* @package DtApp\ThinkLibrary\service
*/
class WorkKileService extends Service
{
/**
* 发送文本消息
* @param string $webhook
* @param string $user 发送对象
* @param string $content 消息内容
* @return bool 发送结果
* @throws CurlException
*/
public function text(string $webhook, string $user, string $content)
{
return $this->sendMsg($webhook, [
'user' => $user,
'text' => $content
]);
}
/**
* 组装发送消息
* @param string $webhook
* @param array $data 消息内容数组
* @return bool 发送结果
* @throws CurlException
*/
private function sendMsg(string $webhook, array $data)
{
$result = HttpService::instance()
->url($webhook)
->data($data)
->toArray();
if ($result['code'] == 200) return true;
return false;
}
}
Loading…
Cancel
Save