Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
数据应用
ThinkLibrary
提交
515a7692
T
ThinkLibrary
项目概览
数据应用
/
ThinkLibrary
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
代码片段
项目成员
Pages
T
ThinkLibrary
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
515a7692
编写于
12月 03, 2020
作者:
李光春
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- 增加卡券网服务
上级
fe399c48
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
166 addition
and
1 deletion
+166
-1
CHANGELOG.md
CHANGELOG.md
+3
-0
src/common.php
src/common.php
+1
-1
src/service/KaShAngWl.php
src/service/KaShAngWl.php
+162
-0
未找到文件。
CHANGELOG.md
浏览文件 @
515a7692
## v6.0.131 / 2020-12-03
-
增加卡券网服务
## v6.0.130 / 2020-11-26
-
优化服务
...
...
src/common.php
浏览文件 @
515a7692
...
...
@@ -25,7 +25,7 @@ use DtApp\ThinkLibrary\service\SystemService;
/**
* 定义当前版本
*/
const
VERSION
=
'6.0.13
0
'
;
const
VERSION
=
'6.0.13
1
'
;
if
(
!
function_exists
(
'get_ip_info'
))
{
/**
...
...
src/service/KaShAngWl.php
0 → 100644
浏览文件 @
515a7692
<?php
namespace
DtApp\ThinkLibrary\service
;
use
DtApp\ThinkLibrary\Service
;
use
DtApp\ThinkLibrary\service\curl\HttpService
;
use
think\App
;
use
think\exception\HttpException
;
/**
* 卡商网
* http://www.kashangwl.com/
* Class KaShAngWl
* @package DtApp\ThinkLibrary\service
*/
class
KaShAngWl
extends
Service
{
/**
* 接口地址
* @var string
*/
private
$api_url
=
'http://www.kashangwl.com/api'
;
/**
* 商家编号、商家密钥
* @var
*/
private
$customer_id
,
$customer_key
;
/**
* 设置商家编号
* @param string $customer_id
* @return $this
*/
public
function
setCustomerId
(
string
$customer_id
):
self
{
$this
->
customer_id
=
$customer_id
;
return
$this
;
}
/**
* 设置商家密钥
* @param string $customer_key
* @return $this
*/
public
function
setCustomerKey
(
string
$customer_key
):
self
{
$this
->
customer_key
=
$customer_key
;
return
$this
;
}
/**
* 待请求的链接
* @var string
*/
private
$method
=
''
;
/**
* 设置接口
* @param $method
* @return KaShAngWl
*/
public
function
setMethod
(
$method
):
self
{
$this
->
method
=
"
{
$this
->
api_url
}
/
$method
"
;
return
$this
;
}
/**
* 需要发送的的参数
* @var
*/
private
$param
;
/**
* 入参
* @param $param
* @return KaShAngWl
*/
public
function
param
(
$param
):
self
{
$this
->
param
=
$param
;
return
$this
;
}
/**
* 响应内容
* @var
*/
private
$output
;
/**
* 时间戳
* @var int
*/
private
$time
;
public
function
__construct
(
App
$app
)
{
$this
->
time
=
time
();
parent
::
__construct
(
$app
);
}
/**
* @return array|mixed
*/
public
function
toArray
()
{
//首先检测是否支持curl
if
(
!
extension_loaded
(
"curl"
))
{
throw
new
HttpException
(
404
,
'请开启curl模块!'
);
}
$this
->
http
();
// 正常
if
(
is_array
(
$this
->
output
))
{
return
$this
->
output
;
}
if
(
is_object
(
$this
->
output
))
{
$this
->
output
=
json_encode
(
$this
->
output
,
JSON_UNESCAPED_UNICODE
);
}
$this
->
output
=
json_decode
(
$this
->
output
,
true
);
return
$this
->
output
;
}
/**
* 网络请求
*/
private
function
http
():
void
{
//生成签名
$sign
=
$this
->
createSign
();
//组织参数
$this
->
param
[
'customer_id'
]
=
$this
->
customer_id
;
$this
->
param
[
'timestamp'
]
=
$this
->
time
;
$this
->
param
[
'sign'
]
=
$sign
;
$result
=
HttpService
::
instance
()
->
url
(
$this
->
method
)
->
data
(
$this
->
param
)
->
post
()
->
toArray
();
$this
->
output
=
$result
;
}
/**
* 签名
* @return string
*/
private
function
createSign
():
string
{
$sign
=
$this
->
customer_key
;
$this
->
param
[
'customer_id'
]
=
$this
->
customer_id
;
$this
->
param
[
'timestamp'
]
=
$this
->
time
;
ksort
(
$this
->
param
);
foreach
(
$this
->
param
as
$key
=>
$val
)
{
if
(
$key
!==
''
&&
$val
!==
''
)
{
$sign
.
=
$key
.
$val
;
}
}
$sign
=
strtolower
(
md5
(
$sign
));
return
$sign
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录