Commit d98013c6 by 杨树贤

回传接口crm

parent 5a8ae8cd
Showing with 32 additions and 36 deletions
...@@ -5,7 +5,6 @@ namespace App\Http\Services; ...@@ -5,7 +5,6 @@ namespace App\Http\Services;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use App\Model\RedisModel; use App\Model\RedisModel;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use Illuminate\Support\Facades\DB;
class CrmService class CrmService
{ {
...@@ -46,7 +45,7 @@ class CrmService ...@@ -46,7 +45,7 @@ class CrmService
} }
/** /**
* 回传CRM供应商转化确认结果 * 回传CRM供应商转化确认结果(队列推送)
* @param string $supplierName 供应商名称 * @param string $supplierName 供应商名称
* @param string $approverName 审批人姓名 * @param string $approverName 审批人姓名
* @param string $approveResult 审批结果:completed(通过)/purchase_rejected(采购驳回) * @param string $approveResult 审批结果:completed(通过)/purchase_rejected(采购驳回)
...@@ -56,55 +55,52 @@ class CrmService ...@@ -56,55 +55,52 @@ class CrmService
public static function confirmCrmSupplier($supplierName, $approverName, $approveResult, $remark = '') public static function confirmCrmSupplier($supplierName, $approverName, $approveResult, $remark = '')
{ {
try { try {
$url = env('CRM_URL') . '/open/customer/confirmSupplierApproval'; $data = [
$client = new Client(); 'customer_name' => $supplierName,
$response = $client->post($url, [ 'approver' => $approverName,
'form_params' => [ 'approve_result' => $approveResult,
'customer_name' => $supplierName, 'remark' => $remark,
'approver' => $approverName, ];
'approve_result' => $approveResult, (new QueueDeliveryService())->setQueueName('lie_queue_crm')->push(
'remark' => $remark, QueueDeliveryService::PUSH_TYPE_QUEUE,
] '/sync/synSuppAuditResultToCrm',
]); $data,
$result = json_decode($response->getBody()->getContents(), true); (string)$supplierName
if (isset($result['code']) && $result['code'] == 0) { );
return true; \Illuminate\Support\Facades\Log::info('[CRM回传]回传审批结果已推送到队列', ['supplier_name' => $supplierName, 'approve_result' => $approveResult]);
} return true;
\Illuminate\Support\Facades\Log::warning('[CRM回传]回传审批结果失败', ['response' => $result, 'supplier_name' => $supplierName]);
return false;
} catch (\Exception $e) { } catch (\Exception $e) {
\Illuminate\Support\Facades\Log::error('[CRM回传]回传审批结果异常: ' . $e->getMessage(), ['supplier_name' => $supplierName]); \Illuminate\Support\Facades\Log::error('[CRM回传]回传审批结果推送队列异常: ' . $e->getMessage(), ['supplier_name' => $supplierName]);
return false; return false;
} }
} }
/** /**
* 同步供应商状态变更到CRM系统 * 同步供应商状态变更到CRM系统(队列推送)
* @param string $supplierName 供应商名称 * @param string $supplierName 供应商名称
* @param string $supplierStatus CRM供应商状态:rejected/passed/blacklist/disable_trade * @param string $supplierStatus CRM供应商状态:rejected/passed/blacklist/disable_trade
* @param string $remark 备注 * @param string $remark 备注
* @param string $supplierName 供应商名称(作为searchKey)
* @return bool * @return bool
*/ */
public static function syncSupplierStatus($supplierName, $supplierStatus, $remark = '') public static function syncSupplierStatus($supplierName, $supplierStatus, $remark = '')
{ {
try { try {
$url = env('CRM_URL') . '/open/customer/syncSupplierStatus'; $data = [
$client = new Client(); 'customer_name' => $supplierName,
$response = $client->post($url, [ 'supplier_status' => $supplierStatus,
'form_params' => [ 'remark' => $remark,
'customer_name' => $supplierName, ];
'supplier_status' => $supplierStatus, (new QueueDeliveryService())->setQueueName('lie_queue_crm')->push(
'remark' => $remark, QueueDeliveryService::PUSH_TYPE_QUEUE,
] '/sync/synSuppAuditResultToCrm',
]); $data,
$result = json_decode($response->getBody()->getContents(), true); (string)$supplierName
if (isset($result['code']) && $result['code'] == 0) { );
return true; \Illuminate\Support\Facades\Log::info('[CRM回传]同步供应商状态已推送到队列', ['supplier_name' => $supplierName, 'status' => $supplierStatus]);
} return true;
\Illuminate\Support\Facades\Log::warning('[CRM回传]同步供应商状态失败', ['response' => $result, 'supplier_name' => $supplierName]);
return false;
} catch (\Exception $e) { } catch (\Exception $e) {
\Illuminate\Support\Facades\Log::error('[CRM回传]同步供应商状态异常: ' . $e->getMessage(), ['supplier_name' => $supplierName]); \Illuminate\Support\Facades\Log::error('[CRM回传]同步供应商状态推送队列异常: ' . $e->getMessage(), ['supplier_name' => $supplierName]);
return false; return false;
} }
} }
......
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