Commit 47ff92ec by 杨树贤

回写接口

parent ff3e58b8
<?php
namespace App\Http\Controllers\Sync;
use App\Http\Controllers\Controller;
use App\Http\Services\SupplierService;
use App\Http\Services\SyncSupplierService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
//提供外部系统的接口
class BaseSyncController extends Controller
{
public function syncResponse($code = 0, $msg = '成功', $data = '', $count = 0)
{
echo json_encode([
'code' => $code,
'msg' => $msg,
'data' => $data,
]);
exit();
}
}
<?php
namespace App\Http\Controllers\Api;
namespace App\Http\Controllers\Sync;
use App\Http\Controllers\Controller;
use App\Http\Services\SupplierService;
use App\Http\Services\SyncSupplierService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
//提供外部系统的接口
class SupplierSyncController extends Controller
class SupplierSyncController extends BaseSyncController
{
public function syncUniteResult(Request $request)
{
$resultData = $request->only([
'group_code',
'source_sn',
'company_name',
'init_nature',
'company_nature',
]);
$resultData = $request->only([
'group_code',
'source_sn',
'company_name',
'init_nature',
'company_nature',
]);
$rules = [
"group_code" => "required",
"source_sn" => "required",
"company_name" => "required",
"init_nature" => 'required',
"company_nature" => "required",
];
$validator = Validator::make($rules, $rules);
//判断联系方式的表单验证
if ($validator->fails()) {
$error = $validator->errors()->first();
$this->syncResponse(-1, $error);
}
$result = (new SyncSupplierService())->syncSupplierToUnitedResult($resultData);
$this->syncResponse(0, '同步一体化信息成功');
}
}
......@@ -151,12 +151,11 @@ class SyncSupplierService
$groupCode = array_get($syncResult, 'group_code');
$sourceSn = array_get($syncResult, 'source_sn');
$supplierId = $sourceSn;
SupplierChannelModel::where('supplier_id',$supplierId)
return SupplierChannelModel::where('supplier_id', $supplierId)
->update([
'sync_united_status' => SupplierChannelModel::SYNC_UNITED_STATUS_OK,
'group_code' => $groupCode,
'company_nature' => $syncResult['company_nature'],
]);
}
}
\ No newline at end of file
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