Commit 1c8052b5 by hcy001

1

parent c799ad7a
......@@ -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);
}
......
<?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'];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment