Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
php_frq_api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
48b6e14c
authored
Mar 30, 2021
by
hcy001
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1
parent
51527441
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
7 deletions
app/Http/Controllers/ApiController.php
app/Model/CommonModel.php
app/Model/InquiryItemsModel.php
app/Http/Controllers/ApiController.php
View file @
48b6e14c
...
...
@@ -101,11 +101,11 @@ class ApiController extends Controller
//搜索品牌
private
function
ApiBrandList
(
$input
,
$id
){
(
new
CommonModel
())
->
BrandList
(
$input
[
'k'
]);
(
new
CommonModel
())
->
BrandList
(
$input
[
'k'
]
,
@
$input
[
"types"
]
?
@
$input
[
"types"
]
:
1
);
}
//搜索型号
private
function
ApiSkuList
(
$input
,
$id
){
(
new
CommonModel
())
->
SkuList
(
$input
[
'k'
]);
(
new
CommonModel
())
->
SkuList
(
$input
[
'k'
]
,
@
$input
[
"types"
]
?
@
$input
[
"types"
]
:
1
);
}
//搜索采购
private
function
ApiUserList
(
$input
,
$id
){
...
...
app/Model/CommonModel.php
View file @
48b6e14c
...
...
@@ -61,9 +61,18 @@ class CommonModel extends Model
$dbspu
=
DB
::
connection
(
"spu"
);
if
(
$types
==
1
)
{
#模糊搜索
$brandInfo
=
$dbspu
->
select
(
"select brand_id as value,brand_name as name from lie_brand where brand_name like '%"
.
$k
.
"%' limit 10"
);
if
(
count
(
$brandInfo
)
==
0
){
$brandInfo
=
[[
"value"
=>
"0"
,
"name"
=>
$k
]];
}
echo
json_encode
(
$brandInfo
,
JSON_UNESCAPED_UNICODE
)
;
exit
();
}
else
{
}
if
(
$types
==
2
)
{
#模糊搜索
$brandInfo
=
$dbspu
->
select
(
"select brand_id as value,brand_name as name from lie_brand where brand_name like '%"
.
$k
.
"%' limit 10"
);
echo
json_encode
(
$brandInfo
,
JSON_UNESCAPED_UNICODE
)
;
exit
();
}
if
(
$types
==
3
){
#精确搜索
$brandInfo
=
$dbspu
->
select
(
"select brand_id as brand_id,brand_name as name from lie_brand where brand_name = '"
.
$k
.
"' limit 1"
);
if
(
!
$brandInfo
){
return
false
;
...
...
@@ -111,13 +120,13 @@ class CommonModel extends Model
}
//模糊搜索sku型号
public
function
SkuList
(
$k
)
public
function
SkuList
(
$k
,
$types
=
1
)
{
$url
=
"http://so12.ichunt.com/search/spu/think?spu_name="
.
$k
;
$res
=
post_curl
(
$url
,[]);
$resArr
=
\GuzzleHttp\json_decode
(
$res
,
true
);
$temp
=
[];
if
(
count
(
$resArr
[
"data"
])
==
0
){
if
(
count
(
$resArr
[
"data"
])
==
0
&&
$types
==
1
){
#返回没查到的数据
array_push
(
$temp
,[
"value"
=>
""
,
"name"
=>
$k
]);
}
else
{
foreach
(
$resArr
[
"data"
]
as
$k
=>
$v
){
...
...
app/Model/InquiryItemsModel.php
View file @
48b6e14c
...
...
@@ -534,9 +534,9 @@ class InquiryItemsModel extends Model
}
break
;
case
"brand_name"
:
#验证品牌
$brand_id
=
$CommonModel
->
BrandList
(
$val
,
2
);
$brand_id
=
$CommonModel
->
BrandList
(
$val
,
3
);
if
(
$brand_id
===
false
){
$
err
[]
=
$str_msg
.
"系统不存在此品牌"
;
$
brand_id
=
0
;
}
$b2
[
"brand_id"
]
=
$brand_id
;
break
;
...
...
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