Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
飞鱼0526
ShopXO
提交
51ec7c6e
ShopXO
项目概览
飞鱼0526
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
51ec7c6e
编写于
6月 01, 2019
作者:
G
gongfuxiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
快递鸟插件优化
上级
e9039d59
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
208 addition
and
172 deletion
+208
-172
application/admin/controller/Plugins.php
application/admin/controller/Plugins.php
+14
-4
application/index/controller/Plugins.php
application/index/controller/Plugins.php
+14
-4
application/plugins/expressforkdn/Hook.php
application/plugins/expressforkdn/Hook.php
+1
-164
application/plugins/expressforkdn/index/Index.php
application/plugins/expressforkdn/index/Index.php
+179
-0
未找到文件。
application/admin/controller/Plugins.php
浏览文件 @
51ec7c6e
...
...
@@ -110,16 +110,26 @@ class Plugins extends Common
$plugins
=
'\app\plugins\\'
.
$pluginsname
.
'\admin\\'
.
ucfirst
(
$pluginscontrol
);
if
(
!
class_exists
(
$plugins
))
{
$this
->
assign
(
'msg'
,
ucfirst
(
$pluginscontrol
)
.
' 应用控制器未定义'
);
return
$this
->
fetch
(
'public/tips_error'
);
if
(
IS_AJAX
)
{
return
DataReturn
(
ucfirst
(
$pluginscontrol
)
.
' 应用控制器未定义'
,
-
1
);
}
else
{
$this
->
assign
(
'msg'
,
ucfirst
(
$pluginscontrol
)
.
' 应用控制器未定义'
);
return
$this
->
fetch
(
'public/tips_error'
);
}
}
// 调用方法
$obj
=
new
$plugins
();
if
(
!
method_exists
(
$obj
,
$pluginsaction
))
{
$this
->
assign
(
'msg'
,
ucfirst
(
$pluginsaction
)
.
' 应用方法未定义'
);
return
$this
->
fetch
(
'public/tips_error'
);
if
(
IS_AJAX
)
{
return
DataReturn
(
ucfirst
(
$pluginsaction
)
.
' 应用方法未定义'
,
-
1
);
}
else
{
$this
->
assign
(
'msg'
,
ucfirst
(
$pluginsaction
)
.
' 应用方法未定义'
);
return
$this
->
fetch
(
'public/tips_error'
);
}
}
return
$obj
->
$pluginsaction
(
$params
);
}
...
...
application/index/controller/Plugins.php
浏览文件 @
51ec7c6e
...
...
@@ -104,16 +104,26 @@ class Plugins extends Common
$plugins
=
'\app\plugins\\'
.
$pluginsname
.
'\index\\'
.
ucfirst
(
$pluginscontrol
);
if
(
!
class_exists
(
$plugins
))
{
$this
->
assign
(
'msg'
,
ucfirst
(
$pluginscontrol
)
.
' 应用控制器未定义'
);
return
$this
->
fetch
(
'public/tips_error'
);
if
(
IS_AJAX
)
{
return
DataReturn
(
ucfirst
(
$pluginscontrol
)
.
' 应用控制器未定义'
,
-
1
);
}
else
{
$this
->
assign
(
'msg'
,
ucfirst
(
$pluginscontrol
)
.
' 应用控制器未定义'
);
return
$this
->
fetch
(
'public/tips_error'
);
}
}
// 调用方法
$obj
=
new
$plugins
();
if
(
!
method_exists
(
$obj
,
$pluginsaction
))
{
$this
->
assign
(
'msg'
,
ucfirst
(
$pluginsaction
)
.
' 应用方法未定义'
);
return
$this
->
fetch
(
'public/tips_error'
);
if
(
IS_AJAX
)
{
return
DataReturn
(
ucfirst
(
$pluginsaction
)
.
' 应用方法未定义'
,
-
1
);
}
else
{
$this
->
assign
(
'msg'
,
ucfirst
(
$pluginsaction
)
.
' 应用方法未定义'
);
return
$this
->
fetch
(
'public/tips_error'
);
}
}
return
$obj
->
$pluginsaction
(
$params
);
}
...
...
application/plugins/expressforkdn/Hook.php
浏览文件 @
51ec7c6e
...
...
@@ -85,7 +85,7 @@ class Hook extends Controller
$(".plugins-expressforkdn-submit").on("click", function()
{
$.ajax({
url:"'
.
PluginsHomeUrl
(
'expressforkdn'
,
'
hook
'
,
'getexpinfo'
)
.
'",
url:"'
.
PluginsHomeUrl
(
'expressforkdn'
,
'
index
'
,
'getexpinfo'
)
.
'",
type:"POST",
dataType:"json",
data: {express_id: $(this).data("exp-id"), express_number: $(this).data("exp-num")},
...
...
@@ -150,168 +150,5 @@ class Hook extends Controller
return
DataReturn
(
'处理成功'
,
0
);
}
/**
* 获取物流信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-12
* @desc description
* @param [array] $params [输入参数]
* @return [type] [description]
*/
public
function
getexpinfo
(
$params
=
[])
{
// html
$html
=
''
;
// 请求参数
$p
=
[
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'express_id'
,
'error_msg'
=>
'快递id有误'
,
],
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'express_number'
,
'error_msg'
=>
'快递单号有误'
,
],
];
$ret
=
ParamsChecked
(
$params
,
$p
);
if
(
$ret
!==
true
)
{
return
DataReturn
(
$ret
,
-
1
,
'<p>'
.
$ret
.
'</p>'
);
}
// 获取配置数据
$ret
=
PluginsService
::
PluginsData
(
'expressforkdn'
);
if
(
$ret
[
'code'
]
==
0
)
{
// 是否配置物流代码
if
(
empty
(
$ret
[
'data'
][
'express_ids'
][
$params
[
'express_id'
]]))
{
return
DataReturn
(
'请先再后台配置物流代码'
,
-
1
,
'<p>请先再后台配置物流代码</p>'
);
}
// 获取快递信息
$data
=
$this
->
expresstraces
([
'shipper_code'
=>
$ret
[
'data'
][
'express_ids'
][
$params
[
'express_id'
]],
'logistic_code'
=>
$params
[
'express_number'
],
'config'
=>
$ret
[
'data'
]]);
// 状态列表
$status_arr
=
[
0
=>
'暂无物流信息'
,
1
=>
'快递公司已揽收'
,
2
=>
'快递正在配送途中...'
,
3
=>
'该物流已被签收'
,
4
=>
'该物流问题件,请咨询物流商处理!'
,
];
if
(
!
isset
(
$data
[
'State'
])
||
!
isset
(
$status_arr
[
$data
[
'State'
]]))
{
return
DataReturn
(
'查询失败'
,
-
1
,
'<p>查询失败</p>'
);
}
// 开始处理
$html
.
=
'<p>'
.
$status_arr
[
$data
[
'State'
]]
.
'</p>'
;
$html
.
=
'<ul class="am-list am-list-static">'
;
// 快递信息
if
(
in_array
(
$data
[
'State'
],
[
2
,
3
])
&&
!
empty
(
$data
[
'Traces'
])
&&
is_array
(
$data
[
'Traces'
]))
{
foreach
(
$data
[
'Traces'
]
as
$k
=>
$v
)
{
$html
.
=
'<li class="items">'
.
$v
[
'AcceptTime'
]
.
''
.
$v
[
'AcceptStation'
]
.
'</li>'
;
}
}
return
DataReturn
(
'处理成功'
,
0
,
$html
);
}
else
{
return
DataReturn
(
$ret
[
'msg'
],
-
100
);
}
}
/**
* 获取物流信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-12
* @desc description
* @param [array] $params [输入参数]
* @return [type] [description]
*/
public
function
expresstraces
(
$params
=
[])
{
// 参数
if
(
empty
(
$params
[
'shipper_code'
])
||
empty
(
$params
[
'logistic_code'
])
||
empty
(
$params
[
'config'
]))
{
return
[
'State'
=>
0
,
'Reason'
=>
'请求参数有误'
];
}
// 请求数据
$url
=
'http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx'
;
$request_data
=
json_encode
([
'OrderCode'
=>
''
,
'ShipperCode'
=>
$params
[
'shipper_code'
],
'LogisticCode'
=>
$params
[
'logistic_code'
],
]);
$data
=
array
(
'EBusinessID'
=>
$params
[
'config'
][
'ebid'
],
'RequestType'
=>
'1002'
,
'RequestData'
=>
urlencode
(
$request_data
)
,
'DataType'
=>
'2'
,
);
$data
[
'DataSign'
]
=
$this
->
encrypt
(
$request_data
,
$params
[
'config'
][
'appkey'
]);
return
$this
->
request_post
(
$url
,
$data
);
}
/**
* post提交数据
* @param string $url 请求Url
* @param array $data 提交的数据
* @return url响应返回的html
*/
public
function
request_post
(
$url
,
$data
)
{
$temps
=
array
();
foreach
(
$data
as
$key
=>
$value
)
{
$temps
[]
=
sprintf
(
'%s=%s'
,
$key
,
$value
);
}
$post_data
=
implode
(
'&'
,
$temps
);
$url_info
=
parse_url
(
$url
);
if
(
empty
(
$url_info
[
'port'
]))
{
$url_info
[
'port'
]
=
80
;
}
$httpheader
=
"POST "
.
$url_info
[
'path'
]
.
" HTTP/1.0
\r\n
"
;
$httpheader
.
=
"Host:"
.
$url_info
[
'host'
]
.
"
\r\n
"
;
$httpheader
.
=
"Content-Type:application/x-www-form-urlencoded
\r\n
"
;
$httpheader
.
=
"Content-Length:"
.
strlen
(
$post_data
)
.
"
\r\n
"
;
$httpheader
.
=
"Connection:close
\r\n\r\n
"
;
$httpheader
.
=
$post_data
;
$fd
=
fsockopen
(
$url_info
[
'host'
],
$url_info
[
'port'
]);
fwrite
(
$fd
,
$httpheader
);
$gets
=
""
;
$headerFlag
=
true
;
while
(
!
feof
(
$fd
))
{
if
((
$header
=
@
fgets
(
$fd
))
&&
(
$header
==
"
\r\n
"
||
$header
==
"
\n
"
))
{
break
;
}
}
while
(
!
feof
(
$fd
))
{
$gets
.
=
fread
(
$fd
,
128
);
}
fclose
(
$fd
);
return
json_decode
(
$gets
,
true
);
}
/**
* 电商Sign签名生成
* @param data 内容
* @param appkey Appkey
* @return DataSign签名
*/
public
function
encrypt
(
$data
,
$appkey
)
{
return
urlencode
(
base64_encode
(
md5
(
$data
.
$appkey
)));
}
}
?>
\ No newline at end of file
application/plugins/expressforkdn/index/Index.php
0 → 100644
浏览文件 @
51ec7c6e
<?php
namespace
app\plugins\expressforkdn\index
;
use
think\Controller
;
use
app\service\PluginsService
;
/**
* 快递鸟API接口 - 前端
* @author GuoGuo
* @blog http://gadmin.cojz8.com/
* @version 1.0.0
* @datetime 2016-12-01T21:51:08+0800
*/
class
Index
extends
Controller
{
/**
* 获取物流信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-12
* @desc description
* @param [array] $params [输入参数]
* @return [type] [description]
*/
public
function
getexpinfo
(
$params
=
[])
{
// html
$html
=
''
;
// 请求参数
$p
=
[
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'express_id'
,
'error_msg'
=>
'快递id有误'
,
],
[
'checked_type'
=>
'empty'
,
'key_name'
=>
'express_number'
,
'error_msg'
=>
'快递单号有误'
,
],
];
$ret
=
ParamsChecked
(
$params
,
$p
);
if
(
$ret
!==
true
)
{
return
DataReturn
(
$ret
,
-
1
,
'<p>'
.
$ret
.
'</p>'
);
}
// 获取配置数据
$ret
=
PluginsService
::
PluginsData
(
'expressforkdn'
);
if
(
$ret
[
'code'
]
==
0
)
{
// 是否配置物流代码
if
(
empty
(
$ret
[
'data'
][
'express_ids'
][
$params
[
'express_id'
]]))
{
return
DataReturn
(
'请先再后台配置物流代码'
,
-
1
,
'<p>请先再后台配置物流代码</p>'
);
}
// 获取快递信息
$data
=
$this
->
expresstraces
([
'shipper_code'
=>
$ret
[
'data'
][
'express_ids'
][
$params
[
'express_id'
]],
'logistic_code'
=>
$params
[
'express_number'
],
'config'
=>
$ret
[
'data'
]]);
// 状态列表
$status_arr
=
[
0
=>
'暂无物流信息'
,
1
=>
'快递公司已揽收'
,
2
=>
'快递正在配送途中...'
,
3
=>
'该物流已被签收'
,
4
=>
'该物流问题件,请咨询物流商处理!'
,
];
if
(
!
isset
(
$data
[
'State'
])
||
!
isset
(
$status_arr
[
$data
[
'State'
]]))
{
return
DataReturn
(
'查询失败'
,
-
1
,
'<p>查询失败</p>'
);
}
// 开始处理
$html
.
=
'<p>'
.
$status_arr
[
$data
[
'State'
]]
.
'</p>'
;
$html
.
=
'<ul class="am-list am-list-static">'
;
// 快递信息
if
(
in_array
(
$data
[
'State'
],
[
2
,
3
])
&&
!
empty
(
$data
[
'Traces'
])
&&
is_array
(
$data
[
'Traces'
]))
{
foreach
(
$data
[
'Traces'
]
as
$k
=>
$v
)
{
$html
.
=
'<li class="items">'
.
$v
[
'AcceptTime'
]
.
''
.
$v
[
'AcceptStation'
]
.
'</li>'
;
}
}
return
DataReturn
(
'处理成功'
,
0
,
$html
);
}
else
{
return
DataReturn
(
$ret
[
'msg'
],
-
100
);
}
}
/**
* 获取物流信息
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-12
* @desc description
* @param [array] $params [输入参数]
* @return [type] [description]
*/
public
function
expresstraces
(
$params
=
[])
{
// 参数
if
(
empty
(
$params
[
'shipper_code'
])
||
empty
(
$params
[
'logistic_code'
])
||
empty
(
$params
[
'config'
]))
{
return
[
'State'
=>
0
,
'Reason'
=>
'请求参数有误'
];
}
// 请求数据
$url
=
'http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx'
;
$request_data
=
json_encode
([
'OrderCode'
=>
''
,
'ShipperCode'
=>
$params
[
'shipper_code'
],
'LogisticCode'
=>
$params
[
'logistic_code'
],
]);
$data
=
array
(
'EBusinessID'
=>
$params
[
'config'
][
'ebid'
],
'RequestType'
=>
'1002'
,
'RequestData'
=>
urlencode
(
$request_data
)
,
'DataType'
=>
'2'
,
);
$data
[
'DataSign'
]
=
$this
->
encrypt
(
$request_data
,
$params
[
'config'
][
'appkey'
]);
return
$this
->
request_post
(
$url
,
$data
);
}
/**
* post提交数据
* @param string $url 请求Url
* @param array $data 提交的数据
* @return url响应返回的html
*/
public
function
request_post
(
$url
,
$data
)
{
$temps
=
array
();
foreach
(
$data
as
$key
=>
$value
)
{
$temps
[]
=
sprintf
(
'%s=%s'
,
$key
,
$value
);
}
$post_data
=
implode
(
'&'
,
$temps
);
$url_info
=
parse_url
(
$url
);
if
(
empty
(
$url_info
[
'port'
]))
{
$url_info
[
'port'
]
=
80
;
}
$httpheader
=
"POST "
.
$url_info
[
'path'
]
.
" HTTP/1.0
\r\n
"
;
$httpheader
.
=
"Host:"
.
$url_info
[
'host'
]
.
"
\r\n
"
;
$httpheader
.
=
"Content-Type:application/x-www-form-urlencoded
\r\n
"
;
$httpheader
.
=
"Content-Length:"
.
strlen
(
$post_data
)
.
"
\r\n
"
;
$httpheader
.
=
"Connection:close
\r\n\r\n
"
;
$httpheader
.
=
$post_data
;
$fd
=
fsockopen
(
$url_info
[
'host'
],
$url_info
[
'port'
]);
fwrite
(
$fd
,
$httpheader
);
$gets
=
""
;
$headerFlag
=
true
;
while
(
!
feof
(
$fd
))
{
if
((
$header
=
@
fgets
(
$fd
))
&&
(
$header
==
"
\r\n
"
||
$header
==
"
\n
"
))
{
break
;
}
}
while
(
!
feof
(
$fd
))
{
$gets
.
=
fread
(
$fd
,
128
);
}
fclose
(
$fd
);
return
json_decode
(
$gets
,
true
);
}
/**
* 电商Sign签名生成
* @param data 内容
* @param appkey Appkey
* @return DataSign签名
*/
public
function
encrypt
(
$data
,
$appkey
)
{
return
urlencode
(
base64_encode
(
md5
(
$data
.
$appkey
)));
}
}
?>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录