Commit c71eac70 by 杨树贤

搜索供应商接口完善

parent 12a34922
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use App\Http\Services\SupplierService;
use Illuminate\Http\Request;
//提供外部系统的接口
class ExternalApiController extends Controller
{
public function searchSupplier(Request $request)
{
$map = $request->only(['supplier_name','channel_uid']);
if (empty($map['supplier_name'])) {
$this->response(-1, '搜索的供应商名称不能为空');
}
$suppliers = SupplierService::searchSupplier($map);
$this->externalResponse(0, 'ok', $suppliers['data'], $suppliers['total']);
}
}
......@@ -498,14 +498,4 @@ class SupplierApiController extends Controller
$this->response(0, '申请审核成功');
}
//搜索供应商
public function searchSupplier($request)
{
$map = $request->only(['supplier_name']);
if (empty($map['supplier_name'])) {
$this->response(-1, '搜索的供应商名称不能为空');
}
$suppliers = SupplierService::searchSupplier($map);
$this->response(0, 'ok', $suppliers['data'],$suppliers['total']);
}
}
......@@ -54,4 +54,26 @@ class Controller extends BaseController
exit();
}
}
//提供给第三方接口json返回方法
public function externalResponse($errCode = 0, $errMsg = '成功', $data = '', $count = 0)
{
if (is_array($errCode)) {
echo json_encode([
'code' => $errCode[0],
'msg' => $errCode[1],
'data' => !empty($errCode[2]) ? $errCode[2] : '',
'count' => $count,
]);
exit();
} else {
echo json_encode([
'code' => $errCode,
'msg' => $errMsg,
'data' => $data,
'count' => $count,
]);
exit();
}
}
}
......@@ -24,7 +24,7 @@ class Kernel extends HttpKernel
*/
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\CheckLogin::class,
// \App\Http\Middleware\CheckLogin::class,
// \App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
// \Illuminate\Session\Middleware\StartSession::class,
......@@ -38,6 +38,7 @@ class Kernel extends HttpKernel
],
'api' => [
\App\Http\Middleware\CheckLogin::class,
'throttle:60,1',
],
];
......
......@@ -460,7 +460,8 @@ class SupplierService
'supplier_id',
'supplier_code',
'supplier_name',
'pay_type'
'pay_type',
'channel_uid'
]);
$query = $filter->listFilter($params, $query);
$suppliers = $query->paginate($limit);
......
......@@ -42,13 +42,12 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
Route::match(['get', 'post'], '/api/supplier_tag/{key}', 'SupplierTagApiController@Entrance');
Route::match(['get', 'post'], '/api/supplier_share_apply/{key}', 'SupplierShareApplyApiController@Entrance');
});
//提供给其它系统使用的接口
Route::group(['middleware' => [],'namespace' => 'Api'], function () {
Route::get('/api/external/searchSupplier','ExternalApiController@searchSupplier');
});
Route::match(['get', 'post'], '/test', function () {
$service = new \App\Http\Services\DataService();
// $service->pushSupplierSKu();
// $service->makeSupplierSystemTag();
// $service->importSupplier();
// $service->transferFileData();
$service->TransferPayTypeDataToNewTable();
// $service->changeSupplierIsTypeByCheckChannelUidOrPurchaseUid();
// $service->replaceStandardBrandId();
});
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