Commit 48b6e14c by hcy001

1

parent 51527441
...@@ -101,11 +101,11 @@ class ApiController extends Controller ...@@ -101,11 +101,11 @@ class ApiController extends Controller
//搜索品牌 //搜索品牌
private function ApiBrandList($input, $id){ 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){ 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){ private function ApiUserList($input, $id){
......
...@@ -61,9 +61,18 @@ class CommonModel extends Model ...@@ -61,9 +61,18 @@ class CommonModel extends Model
$dbspu = DB::connection("spu"); $dbspu = DB::connection("spu");
if ($types == 1) { #模糊搜索 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"); $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) ; echo json_encode($brandInfo,JSON_UNESCAPED_UNICODE) ;
exit(); 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"); $brandInfo = $dbspu->select("select brand_id as brand_id,brand_name as name from lie_brand where brand_name = '".$k."' limit 1");
if (!$brandInfo){ if (!$brandInfo){
return false; return false;
...@@ -111,13 +120,13 @@ class CommonModel extends Model ...@@ -111,13 +120,13 @@ class CommonModel extends Model
} }
//模糊搜索sku型号 //模糊搜索sku型号
public function SkuList($k) public function SkuList($k,$types = 1)
{ {
$url = "http://so12.ichunt.com/search/spu/think?spu_name=".$k; $url = "http://so12.ichunt.com/search/spu/think?spu_name=".$k;
$res = post_curl($url,[]); $res = post_curl($url,[]);
$resArr = \GuzzleHttp\json_decode($res,true); $resArr = \GuzzleHttp\json_decode($res,true);
$temp = []; $temp = [];
if (count($resArr["data"]) == 0){ if (count($resArr["data"]) == 0 && $types == 1){ #返回没查到的数据
array_push($temp,["value"=>"","name"=>$k]); array_push($temp,["value"=>"","name"=>$k]);
}else{ }else{
foreach ($resArr["data"] as $k=>$v){ foreach ($resArr["data"] as $k=>$v){
......
...@@ -534,9 +534,9 @@ class InquiryItemsModel extends Model ...@@ -534,9 +534,9 @@ class InquiryItemsModel extends Model
} }
break; break;
case "brand_name": #验证品牌 case "brand_name": #验证品牌
$brand_id = $CommonModel->BrandList($val,2); $brand_id = $CommonModel->BrandList($val,3);
if ($brand_id === false){ if ($brand_id === false){
$err[] = $str_msg."系统不存在此品牌"; $brand_id = 0;
} }
$b2["brand_id"] = $brand_id; $b2["brand_id"] = $brand_id;
break; break;
......
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