Skip to content

Commit 95b370a

Browse files
committed
- 增加订单侠开放平台接口
1 parent ca10776 commit 95b370a

File tree

4 files changed

+113
-2
lines changed

4 files changed

+113
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## v6.0.122 / 2020-11-28
2+
- 增加订单侠开放平台接口
3+
14
## v6.0.121 / 2020-11-12
25
- 修复缴费平台接口
36

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"qcloud/cos-sdk-v5": "^2.0",
4141
"qiniu/php-sdk": "^7.2",
4242
"upyun/sdk": "^3.4",
43-
"phpoffice/phpspreadsheet": "1.12.0"
43+
"phpoffice/phpspreadsheet": "^1.14"
4444
},
4545
"require-dev": {
4646
"symfony/var-dumper": "^4.2"

src/common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/**
2626
* 定义当前版本
2727
*/
28-
const VERSION = '6.0.121';
28+
const VERSION = '6.0.122';
2929

3030
if (!function_exists('get_ip_info')) {
3131
/**
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<?php
2+
3+
namespace DtApp\ThinkLibrary\service\dingdanxia;
4+
5+
use DtApp\ThinkLibrary\exception\DtaException;
6+
use DtApp\ThinkLibrary\Service;
7+
use DtApp\ThinkLibrary\service\curl\HttpService;
8+
use think\exception\HttpException;
9+
10+
/**
11+
* 订单侠开放平台
12+
* Class DingDanXiaService
13+
* @package DtApp\ThinkLibrary\service\dingdanxia
14+
*/
15+
class DingDanXiaService extends Service
16+
{
17+
/**
18+
* 接口秘钥
19+
* @var string
20+
*/
21+
private $app_key;
22+
23+
/**
24+
* API接口
25+
* @var string
26+
*/
27+
private $method;
28+
29+
/**
30+
* 需要发送的的参数
31+
* @var
32+
*/
33+
private $param;
34+
35+
/**
36+
* 响应内容
37+
* @var
38+
*/
39+
private $output;
40+
41+
/**
42+
* 接口秘钥,请登录后台获取
43+
* @param string $appKey
44+
* @return $this
45+
*/
46+
public function appKey(string $appKey): self
47+
{
48+
$this->app_key = $appKey;
49+
return $this;
50+
}
51+
52+
/**
53+
* 自定义接口
54+
* @param string $method
55+
* @return $this
56+
*/
57+
public function setMethod($method = ''): self
58+
{
59+
$this->method = $method;
60+
return $this;
61+
}
62+
63+
/**
64+
* 请求参数
65+
* @param array $param
66+
* @return $this
67+
*/
68+
public function param(array $param): self
69+
{
70+
$this->param = $param;
71+
return $this;
72+
}
73+
74+
/**
75+
* 获取配置信息
76+
* @return $this
77+
*/
78+
private function getConfig(): self
79+
{
80+
$this->app_key = config('dtapp.dingdanxia.app_key');
81+
return $this;
82+
}
83+
84+
/**
85+
* 返回Array
86+
* @return array|mixed
87+
* @throws DtaException
88+
*/
89+
public function toArray()
90+
{
91+
//首先检测是否支持curl
92+
if (!extension_loaded("curl")) {
93+
throw new HttpException(404, '请开启curl模块!');
94+
}
95+
if (empty($this->app_key)) {
96+
$this->getConfig();
97+
}
98+
if (empty($this->method)) {
99+
throw new DtaException('请检查接口');
100+
}
101+
$this->output = HttpService::instance()
102+
->url($this->method)
103+
->data($this->param)
104+
->post()
105+
->toArray();
106+
return $this->output;
107+
}
108+
}

0 commit comments

Comments
 (0)