提交 95b370a8 编写于 作者: 李光春's avatar 李光春

- 增加订单侠开放平台接口

上级 ca10776e
## v6.0.122 / 2020-11-28
- 增加订单侠开放平台接口
## v6.0.121 / 2020-11-12
- 修复缴费平台接口
......
......@@ -25,7 +25,7 @@ use DtApp\ThinkLibrary\service\SystemService;
/**
* 定义当前版本
*/
const VERSION = '6.0.121';
const VERSION = '6.0.122';
if (!function_exists('get_ip_info')) {
/**
......
<?php
namespace DtApp\ThinkLibrary\service\dingdanxia;
use DtApp\ThinkLibrary\exception\DtaException;
use DtApp\ThinkLibrary\Service;
use DtApp\ThinkLibrary\service\curl\HttpService;
use think\exception\HttpException;
/**
* 订单侠开放平台
* Class DingDanXiaService
* @package DtApp\ThinkLibrary\service\dingdanxia
*/
class DingDanXiaService extends Service
{
/**
* 接口秘钥
* @var string
*/
private $app_key;
/**
* API接口
* @var string
*/
private $method;
/**
* 需要发送的的参数
* @var
*/
private $param;
/**
* 响应内容
* @var
*/
private $output;
/**
* 接口秘钥,请登录后台获取
* @param string $appKey
* @return $this
*/
public function appKey(string $appKey): self
{
$this->app_key = $appKey;
return $this;
}
/**
* 自定义接口
* @param string $method
* @return $this
*/
public function setMethod($method = ''): self
{
$this->method = $method;
return $this;
}
/**
* 请求参数
* @param array $param
* @return $this
*/
public function param(array $param): self
{
$this->param = $param;
return $this;
}
/**
* 获取配置信息
* @return $this
*/
private function getConfig(): self
{
$this->app_key = config('dtapp.dingdanxia.app_key');
return $this;
}
/**
* 返回Array
* @return array|mixed
* @throws DtaException
*/
public function toArray()
{
//首先检测是否支持curl
if (!extension_loaded("curl")) {
throw new HttpException(404, '请开启curl模块!');
}
if (empty($this->app_key)) {
$this->getConfig();
}
if (empty($this->method)) {
throw new DtaException('请检查接口');
}
$this->output = HttpService::instance()
->url($this->method)
->data($this->param)
->post()
->toArray();
return $this->output;
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册