Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
数据应用
ThinkLibrary
提交
6338e136
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 搜索 >>
提交
6338e136
编写于
5月 20, 2020
作者:
李光春
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- 优化服务返回的结果
上级
4fa69e69
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
66 addition
and
12 deletion
+66
-12
src/facade/Strings.php
src/facade/Strings.php
+1
-0
src/helper/Strings.php
src/helper/Strings.php
+13
-1
src/service/Jd/UnionService.php
src/service/Jd/UnionService.php
+11
-3
src/service/PinDuoDuo/JinBaoService.php
src/service/PinDuoDuo/JinBaoService.php
+23
-5
src/service/TaoBao/TbkService.php
src/service/TaoBao/TbkService.php
+18
-3
未找到文件。
src/facade/Strings.php
浏览文件 @
6338e136
...
...
@@ -33,6 +33,7 @@ use think\facade;
* @method helper exitContain(string $str, $nee = 3, $del = ',') bool 判断字符串是否包含某个字符
* @method helper len(string $str) int 统计字符串长度
* @method helper trimAll(string $str) string 删除空格
* @method helper replace(string $search, string $replace, string $subject) string 替换字符串
*/
class
Strings
extends
Facade
{
...
...
src/helper/Strings.php
浏览文件 @
6338e136
...
...
@@ -160,10 +160,22 @@ class Strings
* @param $str
* @return string|string[]
*/
p
rivate
function
trimAll
(
$str
):
string
p
ublic
function
trimAll
(
$str
):
string
{
$oldchar
=
array
(
" "
,
" "
,
"
\t
"
,
"
\n
"
,
"
\r
"
);
$newchar
=
array
(
""
,
""
,
""
,
""
,
""
);
return
str_replace
(
$oldchar
,
$newchar
,
$str
);
}
/**
* 替换字符串
* @param string $search
* @param string $replace
* @param string $subject
* @return string|string[]
*/
public
function
replace
(
string
$search
,
string
$replace
,
string
$subject
)
{
return
str_replace
(
$search
,
$replace
,
$subject
);
}
}
src/service/Jd/UnionService.php
浏览文件 @
6338e136
...
...
@@ -18,6 +18,7 @@ namespace DtApp\ThinkLibrary\service\Jd;
use
DtApp\ThinkLibrary\exception\CurlException
;
use
DtApp\ThinkLibrary\exception\JdException
;
use
DtApp\ThinkLibrary\facade\Strings
;
use
DtApp\ThinkLibrary\Service
;
/**
...
...
@@ -336,9 +337,16 @@ class UnionService extends Service
$this
->
params
[
'sign_method'
]
=
$this
->
sign_method
;
$this
->
params
[
'param_json'
]
=
json_encode
(
$this
->
param
);
$this
->
http
();
if
(
is_array
(
$this
->
output
))
return
$this
->
output
;
if
(
is_object
(
$this
->
output
))
$this
->
output
=
json_encode
(
$this
->
output
);
return
json_decode
(
$this
->
output
,
true
);
$response
=
Strings
::
replace
(
'.'
,
'_'
,
$this
->
method
)
.
"_response"
;
if
(
isset
(
$this
->
output
[
"
$response
"
][
'result'
]))
{
if
(
is_array
(
$this
->
output
[
"
$response
"
][
'result'
]))
return
$this
->
output
[
"
$response
"
][
'result'
];
if
(
is_object
(
$this
->
output
[
"
$response
"
][
'result'
]))
$this
->
output
=
json_encode
(
$this
->
output
[
"
$response
"
][
'result'
]);
return
json_decode
(
$this
->
output
[
"
$response
"
][
'result'
],
true
);
}
else
{
if
(
is_array
(
$this
->
output
))
return
$this
->
output
;
if
(
is_object
(
$this
->
output
))
$this
->
output
=
json_encode
(
$this
->
output
);
return
json_decode
(
$this
->
output
,
true
);
}
}
/**
...
...
src/service/PinDuoDuo/JinBaoService.php
浏览文件 @
6338e136
...
...
@@ -18,6 +18,7 @@ namespace DtApp\ThinkLibrary\service\PinDuoDuo;
use
DtApp\ThinkLibrary\exception\CurlException
;
use
DtApp\ThinkLibrary\exception\PinDouDouException
;
use
DtApp\ThinkLibrary\facade\Strings
;
use
DtApp\ThinkLibrary\Service
;
/**
...
...
@@ -156,10 +157,9 @@ class JinBaoService extends Service
/**
* 获取商品信息 - 多多进宝商品查询
* https://jinbao.pinduoduo.com/third-party/api-detail?apiName=pdd.ddk.goods.search
* @param array $data
* @return array|mixed
*/
public
function
goodsSearch
(
array
$data
=
[]
)
public
function
goodsSearch
()
{
$this
->
type
=
'pdd.ddk.goods.search'
;
return
$this
;
...
...
@@ -423,9 +423,27 @@ class JinBaoService extends Service
$this
->
param
[
'data_type'
]
=
$this
->
data_type
;
$this
->
param
[
'version'
]
=
$this
->
version
;
$this
->
http
();
if
(
is_array
(
$this
->
output
))
return
$this
->
output
;
if
(
is_object
(
$this
->
output
))
return
$this
->
object2array
(
$this
->
output
);
return
json_decode
(
$this
->
output
,
true
);
if
(
isset
(
$this
->
output
[
'error_response'
]))
{
// 错误
if
(
is_array
(
$this
->
output
))
return
$this
->
output
;
if
(
is_object
(
$this
->
output
))
return
$this
->
object2array
(
$this
->
output
);
return
json_decode
(
$this
->
output
,
true
);
}
else
{
// 正常
$response
=
substr
(
Strings
::
replace
(
'.'
,
'_'
,
$this
->
type
),
8
)
.
"_response"
;
if
(
is_array
(
$this
->
output
))
{
if
(
isset
(
$this
->
output
[
"
$response
"
]))
return
$this
->
output
[
"
$response
"
];
return
$this
->
output
;
}
if
(
is_object
(
$this
->
output
))
{
$this
->
output
=
$this
->
object2array
(
$this
->
output
);
if
(
isset
(
$this
->
output
[
"
$response
"
]))
return
$this
->
output
[
"
$response
"
];
return
$this
->
output
;
}
$this
->
output
=
json_decode
(
$this
->
output
,
true
);
if
(
isset
(
$this
->
output
[
"
$response
"
]))
return
$this
->
output
[
"
$response
"
];
return
$this
->
output
;
}
}
/**
...
...
src/service/TaoBao/TbkService.php
浏览文件 @
6338e136
...
...
@@ -18,6 +18,7 @@ namespace DtApp\ThinkLibrary\service\TaoBao;
use
DtApp\ThinkLibrary\exception\CurlException
;
use
DtApp\ThinkLibrary\exception\TaoBaoException
;
use
DtApp\ThinkLibrary\facade\Strings
;
use
DtApp\ThinkLibrary\Service
;
/**
...
...
@@ -479,9 +480,23 @@ class TbkService extends Service
$this
->
param
[
'sign_method'
]
=
$this
->
sign_method
;
$this
->
param
[
'timestamp'
]
=
date
(
'Y-m-d H:i:s'
);
$this
->
http
();
if
(
is_array
(
$this
->
output
))
return
$this
->
output
;
if
(
is_object
(
$this
->
output
))
$this
->
output
=
json_encode
(
$this
->
output
);
return
json_decode
(
$this
->
output
,
true
);
if
(
isset
(
$this
->
output
[
'error_response'
]))
{
// 错误
if
(
is_array
(
$this
->
output
))
return
$this
->
output
;
if
(
is_object
(
$this
->
output
))
$this
->
output
=
json_encode
(
$this
->
output
);
return
json_decode
(
$this
->
output
,
true
);
}
else
{
// 正常
$response
=
substr
(
Strings
::
replace
(
'.'
,
'_'
,
$this
->
method
),
7
)
.
"_response"
;
if
(
is_array
(
$this
->
output
))
{
if
(
isset
(
$this
->
output
[
"
$response
"
]))
return
$this
->
output
[
"
$response
"
];
return
$this
->
output
;
};
if
(
is_object
(
$this
->
output
))
$this
->
output
=
json_encode
(
$this
->
output
);
$this
->
output
=
json_decode
(
$this
->
output
,
true
);
if
(
isset
(
$this
->
output
[
"
$response
"
]))
return
$this
->
output
[
"
$response
"
];
else
return
$this
->
output
;
}
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录