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
1c8052b5
authored
Mar 18, 2021
by
hcy001
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1
parent
c799ad7a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
0 deletions
app/Http/Controllers/HdController.php
app/Model/SearchModel.php
app/Http/Controllers/HdController.php
View file @
1c8052b5
...
...
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use
App\Http\Requests
;
use
App\Http\Controllers\Controller
;
use
App\Model\QuoteModel
;
use
App\Model\SearchModel
;
use
Dompdf\Dompdf
;
use
Request
;
use
Barryvdh\DomPDF\PDF
;
...
...
@@ -20,8 +21,17 @@ class HdController extends Controller
echo
json_encode
([
'errcode'
=>
$errcode
,
'errmsg'
=>
$errmsg
,
'data'
=>
$data
]);
exit
();
}
//添加参数
private
function
cf
(){
$param
=
[
[
"spu_name"
=>
"RCP0603W110RGS3"
,
"brand_name"
=>
"vishay"
]
];
$res
=
(
new
SearchModel
())
->
getClassName
(
\GuzzleHttp\json_encode
(
$param
));
print_r
(
$res
);
return
;
$t
=
'{"0":{"inquiry_id":"1","inquiry_sn":"A161398670712345","inquiry_items_id":"1","currency":2,"goods_id":"353535","goods_name":"LM358","brand_id":"0","brand_name":"TI","supplier_id":7,"supplier_name":"digikey","quote_number":"25","status":1,"create_uid":0,"create_name":"digikey","price_origin":2.9,"raw_goods_sn":"1597-1134-ND","raw_goods_packing":"Bulk","raw_brand_name":"Seeed Technology Co., Ltd"}}'
;
$res
=
(
new
QuoteModel
())
->
addBatch
(
$t
);
}
...
...
app/Model/SearchModel.php
0 → 100644
View file @
1c8052b5
<?php
namespace
App\Model
;
use
App\Model\OpLogModel
;
use
League\Flysystem\Exception
;
use
Request
;
use
DB
;
/*
对接搜索接口
*/
class
SearchModel
{
private
$SERVICE_URL
;
public
function
__construct
()
{
$this
->
SERVICE_URL
=
"http://so12.ichunt.com/"
;
}
/*
* 批量获取spu+品牌分类信息
*@param json $data eg: [{"spu_name":"RCP0603W110RGS3","brand_name":"vishay"}]
*
* 调用例子:
* $param = [
["spu_name"=>"RCP0603W110RGS3","brand_name"=>"vishay"]
];
$res = (new SearchModel())->getClassName(json_encode($param));
print_r($res);
*
*
* 返回:
* {"code":0,"msg":"查询成功","data":{"RCP0603W110RGS3#VISHAY":{"class_id2":13803,"class_id2_name":"片式电阻器 - 表面贴装"}}}
*
*/
public
function
getClassName
(
$data
){
$param
=
[
"data"
=>
$data
];
$result
=
curl
(
$this
->
SERVICE_URL
.
"search/spu/getClassName"
,
http_build_query
(
$param
),
true
,
false
,
''
);
if
(
@
$_REQUEST
[
"flag"
]
==
100
){
print_r
(
$this
->
SERVICE_URL
.
"search/spu/getClassName"
);
print_r
(
"<br/>"
);
print_r
(
$param
);
print_r
(
"<br/>"
);
print_r
(
$result
);
}
$res
=
json_decode
(
$result
,
true
);
if
(
!
$res
){
return
false
;
}
if
(
$res
[
'code'
]
>
0
){
return
false
;
}
return
$res
[
'data'
];
}
}
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