Commit 745bb649 by 杨树贤

fix

parent e3788801
...@@ -14,12 +14,10 @@ class BaseSyncController extends Controller ...@@ -14,12 +14,10 @@ class BaseSyncController extends Controller
{ {
public function syncResponse($code = 0, $msg = '成功', $data = '', $count = 0) public function syncResponse($code = 0, $msg = '成功', $data = '', $count = 0)
{ {
header('Content-Type: application/json'); return response()->json([
echo json_encode([
'code' => $code, 'code' => $code,
'msg' => $msg, 'msg' => $msg,
'data' => $data, 'data' => $data,
]); ]);
exit();
} }
} }
...@@ -52,11 +52,11 @@ class SupplierSyncController extends BaseSyncController ...@@ -52,11 +52,11 @@ class SupplierSyncController extends BaseSyncController
if ($validator->fails()) { if ($validator->fails()) {
$error = $validator->errors()->first(); $error = $validator->errors()->first();
Log::warning($error); Log::warning($error);
$this->syncResponse(-1, $error); return $this->syncResponse(-1, $error);
} }
$result = (new SyncSupplierService())->syncSupplierToUnitedResult($resultData); $result = (new SyncSupplierService())->syncSupplierToUnitedResult($resultData);
$this->syncResponse(0, '同步一体化信息成功'); return $this->syncResponse(0, '同步一体化信息成功');
} }
public function receiveEntityResult(Request $request) public function receiveEntityResult(Request $request)
...@@ -69,11 +69,11 @@ class SupplierSyncController extends BaseSyncController ...@@ -69,11 +69,11 @@ class SupplierSyncController extends BaseSyncController
$resultData['result'] = (int)$resultData['result_map']["1"]; $resultData['result'] = (int)$resultData['result_map']["1"];
} }
if ($resultData['result'] !== 0 && empty($resultData)) { if ($resultData['result'] !== 0 && empty($resultData)) {
$this->syncResponse(-1, '没有获取到正确的类型'); return $this->syncResponse(-1, '没有获取到正确的类型');
} }
if (!in_array($resultData['result'], [0, 1, -1, -2, -3])) { if (!in_array($resultData['result'], [0, 1, -1, -2, -3])) {
$this->syncResponse(-1, '非法公司分类'); return $this->syncResponse(-1, '非法公司分类');
} }
...@@ -86,7 +86,7 @@ class SupplierSyncController extends BaseSyncController ...@@ -86,7 +86,7 @@ class SupplierSyncController extends BaseSyncController
//判断联系方式的表单验证 //判断联系方式的表单验证
if ($validator->fails()) { if ($validator->fails()) {
$error = $validator->errors()->first(); $error = $validator->errors()->first();
$this->syncResponse(-1, $error); return $this->syncResponse(-1, $error);
} }
//这里还要去判断是是拉黑 //这里还要去判断是是拉黑
...@@ -97,10 +97,10 @@ class SupplierSyncController extends BaseSyncController ...@@ -97,10 +97,10 @@ class SupplierSyncController extends BaseSyncController
$data['update_time'] = time(); $data['update_time'] = time();
SupplierChannelModel::where('supplier_name', $resultData['company_name']) SupplierChannelModel::where('supplier_name', $resultData['company_name'])
->update($data); ->update($data);
$this->syncResponse(0, '获取审核结果广播成功'); return $this->syncResponse(0, '获取审核结果广播成功');
} }
(new SyncSupplierService())->receiveEntityResult($resultData); (new SyncSupplierService())->receiveEntityResult($resultData);
$this->syncResponse(0, '获取审核结果广播成功'); return $this->syncResponse(0, '获取审核结果广播成功');
} }
//获取供应商需要审核的数量 //获取供应商需要审核的数量
...@@ -176,7 +176,7 @@ class SupplierSyncController extends BaseSyncController ...@@ -176,7 +176,7 @@ class SupplierSyncController extends BaseSyncController
if ($validator->fails()) { if ($validator->fails()) {
$error = $validator->errors()->first(); $error = $validator->errors()->first();
Log::warning('[CRM同步]参数校验失败: ' . $error, $data); Log::warning('[CRM同步]参数校验失败: ' . $error, $data);
$this->syncResponse(-1, $error); return $this->syncResponse(-1, $error);
} }
$customerName = trim($data['customer_name']); $customerName = trim($data['customer_name']);
...@@ -186,7 +186,7 @@ class SupplierSyncController extends BaseSyncController ...@@ -186,7 +186,7 @@ class SupplierSyncController extends BaseSyncController
// 如果状态为待确认或CRM转移供应商不通过,说明CRM重新同步了,改回待确认状态并更新信息 // 如果状态为待确认或CRM转移供应商不通过,说明CRM重新同步了,改回待确认状态并更新信息
if (!in_array($existingSupplier['status'], [SupplierChannelModel::STATUS_CONFIRM, SupplierChannelModel::STATUS_CRM_REJECTED])) { if (!in_array($existingSupplier['status'], [SupplierChannelModel::STATUS_CONFIRM, SupplierChannelModel::STATUS_CRM_REJECTED])) {
Log::info('[CRM同步]供应商已存在且为正式供应商,跳过: ' . $customerName); Log::info('[CRM同步]供应商已存在且为正式供应商,跳过: ' . $customerName);
$this->syncResponse(-1, '供应商已存在,跳过'); return $this->syncResponse(-1, '供应商已存在,跳过');
} }
// 如果状态为CRM转移供应商不通过,说明CRM重新同步了,改回待确认状态并更新信息 // 如果状态为CRM转移供应商不通过,说明CRM重新同步了,改回待确认状态并更新信息
if ( if (
...@@ -206,11 +206,11 @@ class SupplierSyncController extends BaseSyncController ...@@ -206,11 +206,11 @@ class SupplierSyncController extends BaseSyncController
$auditService = new SupplierAuditService(); $auditService = new SupplierAuditService();
$auditService->addApproveForCustomerConvert($existingSupplier['supplier_id'], $data['apply_uid'], '客户转化供应商审核'); $auditService->addApproveForCustomerConvert($existingSupplier['supplier_id'], $data['apply_uid'], '客户转化供应商审核');
}); });
$this->syncResponse(0, 'CRM重新同步,状态已恢复为待确认并更新信息,已重新发起审核', ['supplier_id' => $existingSupplier['supplier_id']]); return $this->syncResponse(0, 'CRM重新同步,状态已恢复为待确认并更新信息,已重新发起审核', ['supplier_id' => $existingSupplier['supplier_id']]);
LogService::AddLog($existingSupplier['supplier_id'], LogModel::UPDATE_OPERATE, 'CRM重新同步', 'CRM重新同步,状态已恢复为待确认并更新信息,已重新发起审核'); LogService::AddLog($existingSupplier['supplier_id'], LogModel::UPDATE_OPERATE, 'CRM重新同步', 'CRM重新同步,状态已恢复为待确认并更新信息,已重新发起审核');
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error('[CRM同步]恢复待确认状态并更新失败: ' . $e->getMessage(), ['data' => $data]); Log::error('[CRM同步]恢复待确认状态并更新失败: ' . $e->getMessage(), ['data' => $data]);
$this->syncResponse(-1, '恢复状态并更新失败: ' . $e->getMessage()); return $this->syncResponse(-1, '恢复状态并更新失败: ' . $e->getMessage());
} }
} }
...@@ -221,16 +221,16 @@ class SupplierSyncController extends BaseSyncController ...@@ -221,16 +221,16 @@ class SupplierSyncController extends BaseSyncController
) { ) {
try { try {
$this->updateCrmSupplier($existingSupplier, $data); $this->updateCrmSupplier($existingSupplier, $data);
$this->syncResponse(0, 'CRM再次提交更新成功', ['supplier_id' => $existingSupplier['supplier_id']]); return $this->syncResponse(0, 'CRM再次提交更新成功', ['supplier_id' => $existingSupplier['supplier_id']]);
LogService::AddLog($existingSupplier['supplier_id'], LogModel::UPDATE_OPERATE, 'CRM再次提交', 'CRM再次提交更新成功'); LogService::AddLog($existingSupplier['supplier_id'], LogModel::UPDATE_OPERATE, 'CRM再次提交', 'CRM再次提交更新成功');
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error('[CRM同步]再次提交更新失败: ' . $e->getMessage(), ['data' => $data]); Log::error('[CRM同步]再次提交更新失败: ' . $e->getMessage(), ['data' => $data]);
$this->syncResponse(-1, '更新失败: ' . $e->getTraceAsString()); return $this->syncResponse(-1, '更新失败: ' . $e->getTraceAsString());
} }
} }
Log::info('[CRM同步]供应商已存在且不满足再次提交条件,跳过: ' . $customerName); Log::info('[CRM同步]供应商已存在且不满足再次提交条件,跳过: ' . $customerName);
$this->syncResponse(0, '供应商已存在,跳过'); return $this->syncResponse(0, '供应商已存在,跳过');
} }
try { try {
...@@ -381,10 +381,10 @@ class SupplierSyncController extends BaseSyncController ...@@ -381,10 +381,10 @@ class SupplierSyncController extends BaseSyncController
Log::info('[CRM同步]供应商创建成功', ['supplier_id' => $supplierId, 'supplier_name' => $customerName]); Log::info('[CRM同步]供应商创建成功', ['supplier_id' => $supplierId, 'supplier_name' => $customerName]);
$this->syncResponse(0, '同步成功', ['supplier_id' => $supplierId]); return $this->syncResponse(0, '同步成功', ['supplier_id' => $supplierId]);
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error('[CRM同步]创建供应商失败: ' . $e->getMessage(), ['data' => $data]); Log::error('[CRM同步]创建供应商失败: ' . $e->getMessage(), ['data' => $data]);
$this->syncResponse(-1, '创建供应商失败: ' . $e->getMessage()); return $this->syncResponse(-1, '创建供应商失败: ' . $e->getMessage());
} }
} }
...@@ -500,7 +500,7 @@ class SupplierSyncController extends BaseSyncController ...@@ -500,7 +500,7 @@ class SupplierSyncController extends BaseSyncController
if ($validator->fails()) { if ($validator->fails()) {
$error = $validator->errors()->first(); $error = $validator->errors()->first();
Log::warning('[CRM转让同步]参数校验失败: ' . $error, $data); Log::warning('[CRM转让同步]参数校验失败: ' . $error, $data);
$this->syncResponse(-1, $error); return $this->syncResponse(-1, $error);
} }
$customerName = trim($data['customer_name']); $customerName = trim($data['customer_name']);
...@@ -511,7 +511,7 @@ class SupplierSyncController extends BaseSyncController ...@@ -511,7 +511,7 @@ class SupplierSyncController extends BaseSyncController
if (empty($supplier)) { if (empty($supplier)) {
Log::warning('[CRM转让同步]供应商不存在或非CRM来源: ' . $customerName); Log::warning('[CRM转让同步]供应商不存在或非CRM来源: ' . $customerName);
$this->syncResponse(-1, '供应商不存在或非CRM来源'); return $this->syncResponse(-1, '供应商不存在或非CRM来源');
} }
$supplierId = $supplier['supplier_id']; $supplierId = $supplier['supplier_id'];
...@@ -537,10 +537,10 @@ class SupplierSyncController extends BaseSyncController ...@@ -537,10 +537,10 @@ class SupplierSyncController extends BaseSyncController
'transfer_saler' => $data['transfer_saler'], 'transfer_saler' => $data['transfer_saler'],
]); ]);
$this->syncResponse(0, '同步成功'); return $this->syncResponse(0, '同步成功');
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error('[CRM转让同步]更新失败: ' . $e->getMessage(), ['data' => $data]); Log::error('[CRM转让同步]更新失败: ' . $e->getMessage(), ['data' => $data]);
$this->syncResponse(-1, '更新失败: ' . $e->getMessage()); return $this->syncResponse(-1, '更新失败: ' . $e->getMessage());
} }
} }
} }
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