Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
loveisland
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘小敏
loveisland
Commits
0cb1bd7c
Commit
0cb1bd7c
authored
Aug 19, 2026
by
caren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
快递100 智能解析地址接口
parent
cb83b6aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
User.php
addons/shopro/controller/user/User.php
+58
-0
config.php
application/config.php
+4
-0
No files found.
addons/shopro/controller/user/User.php
View file @
0cb1bd7c
...
@@ -13,6 +13,11 @@ use app\admin\model\shopro\ThirdOauth;
...
@@ -13,6 +13,11 @@ use app\admin\model\shopro\ThirdOauth;
use
think\Db
;
use
think\Db
;
use
think\exception\HttpResponseException
;
use
think\exception\HttpResponseException
;
use
fast\Http
;
use
fast\Random
;
use
think\Config
;
use
think\Validate
;
class
User
extends
Common
class
User
extends
Common
{
{
...
@@ -411,4 +416,57 @@ class User extends Common
...
@@ -411,4 +416,57 @@ class User extends Common
$this
->
success
(
'注销成功'
);
$this
->
success
(
'注销成功'
);
}
}
/**
* 智能地址解析
*
* @ApiMethod (POST)
* @ApiParams (name="content", type="string", required=true, description="需要解析的地址文本,如:张三广东省深圳市南山区粤海街道科技南十二路金蝶软件园13088888888")
*/
public
function
addressResolution
()
{
$content
=
$this
->
request
->
post
(
'content'
);
if
(
!
$content
)
{
$this
->
error
(
__
(
'Invalid parameters'
));
}
$key
=
Config
::
get
(
'shopro.kuaidi100_key'
);
$secret
=
Config
::
get
(
'shopro.kuaidi100_secret'
);
if
(
!
$key
||
!
$secret
)
{
$this
->
error
(
'快递100接口配置缺失'
);
}
$param
=
json_encode
([
'content'
=>
$content
]);
$t
=
(
string
)
round
(
microtime
(
true
)
*
1000
);
$sign
=
strtoupper
(
md5
(
$param
.
$t
.
$key
.
$secret
));
$postData
=
http_build_query
([
'key'
=>
$key
,
'sign'
=>
$sign
,
't'
=>
$t
,
'param'
=>
$param
,
]);
$req
=
Http
::
sendRequest
(
'https://api.kuaidi100.com/address/resolution'
,
$postData
,
'POST'
,
[
CURLOPT_HTTPHEADER
=>
[
'Content-Type: application/x-www-form-urlencoded'
,
'Expect:'
],
]);
if
(
!
$req
[
'ret'
])
{
$this
->
error
(
'请求快递100接口失败: '
.
$req
[
'msg'
]);
}
$result
=
json_decode
(
$req
[
'msg'
],
true
);
if
(
!
isset
(
$result
[
'success'
]))
{
$this
->
error
(
'快递100接口返回数据异常'
);
}
if
(
!
$result
[
'success'
])
{
$this
->
error
(
$result
[
'message'
]
??
'地址解析失败'
);
}
$this
->
success
(
$result
[
'message'
]
??
'解析成功'
,
$result
[
'data'
]
??
null
);
}
}
}
application/config.php
View file @
0cb1bd7c
...
@@ -341,6 +341,10 @@ return [
...
@@ -341,6 +341,10 @@ return [
'xhs_app_id'
=>
Env
::
get
(
'xhs.app_id'
,
''
),
'xhs_app_id'
=>
Env
::
get
(
'xhs.app_id'
,
''
),
'xhs_access_token'
=>
Env
::
get
(
'xhs.access_token'
,
''
),
'xhs_access_token'
=>
Env
::
get
(
'xhs.access_token'
,
''
),
// 快递100 地址智能识别
'kuaidi100_key'
=>
Env
::
get
(
'kuaidi100.key'
,
''
),
'kuaidi100_secret'
=>
Env
::
get
(
'kuaidi100.secret'
,
''
),
],
],
];
];
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment