Commit 41245090 by mushishixian

初始化供应商搜索标签数据和接入修改流程

parent 53d7cb5c
......@@ -52,17 +52,17 @@ class DataService
$cooperation_agreement = array_get($files, 'cooperation_agreement');
$other_attachment = array_get($files, 'other_attachment');
$attachment = [
'business_license' => $business_license?[$business_license]:'',
'billing_information' => $billing_information?[$billing_information]:'',
'registration_certificate' => $registration_certificate?[$registration_certificate]:'',
'incorporation_certificate' => $incorporation_certificate?[$incorporation_certificate]:'',
'certification_notice' => $certification_notice?[$certification_notice]:'',
'supplier_survey' => $supplier_survey?[$supplier_survey]:'',
'proxy_certificate' => $proxy_certificate?[$proxy_certificate]:'',
'quality_assurance_agreement' => $quality_assurance_agreement?[$quality_assurance_agreement]:'',
'confidentiality_agreement' => $confidentiality_agreement?[$confidentiality_agreement]:'',
'cooperation_agreement' => $cooperation_agreement?[$cooperation_agreement]:'',
'other_attachment' => $other_attachment?[$other_attachment]:'',
'business_license' => $business_license ? [$business_license] : '',
'billing_information' => $billing_information ? [$billing_information] : '',
'registration_certificate' => $registration_certificate ? [$registration_certificate] : '',
'incorporation_certificate' => $incorporation_certificate ? [$incorporation_certificate] : '',
'certification_notice' => $certification_notice ? [$certification_notice] : '',
'supplier_survey' => $supplier_survey ? [$supplier_survey] : '',
'proxy_certificate' => $proxy_certificate ? [$proxy_certificate] : '',
'quality_assurance_agreement' => $quality_assurance_agreement ? [$quality_assurance_agreement] : '',
'confidentiality_agreement' => $confidentiality_agreement ? [$confidentiality_agreement] : '',
'cooperation_agreement' => $cooperation_agreement ? [$cooperation_agreement] : '',
'other_attachment' => $other_attachment ? [$other_attachment] : '',
'create_time' => time(),
'update_time' => time(),
'supplier_id' => $supplierId,
......@@ -170,6 +170,32 @@ class DataService
print_r($standardBrandIds);
}
}
//初始化供应商对应的搜索标签到redis
public function initSupplierSearchTags()
{
//初始化所有正式服务器的标签情况到redis
$supplierModel = new SupplierChannelModel();
$suppliers = $supplierModel->where('is_type', 0)->get()->toArray();
$redis = new RedisModel();
foreach ($suppliers as $supplier) {
//1精选,2原厂直供,3认证,4猎芯自营,100无标签
$tagFlags = [];
//先去判断供应商性质是否为原厂,如果是的话,写入标签2
if ($supplier['supplier_group'] == 4) {
$tagFlags[] = 2;
}
if ($supplier['has_certification'] == 1) {
$tagFlags[] = 3;
}
$redis->hset('supplier_search_tags', $supplier['supplier_code'], json_encode([
'supplier_code' => $supplier['supplier_code'],
'tags' => $tagFlags,
]));
}
}
}
......@@ -158,6 +158,8 @@ class SupplierService
$attachmentService->saveAttachment($supplierId, $attachment);
//重新生成外部显示的编码
$this->generateSupplierSn($supplierId, $channel['supplier_group']);
//保存和搜索相关的标签情况
$this->saveSupplierSearchTags($supplierId);
return true;
});
......@@ -429,4 +431,26 @@ class SupplierService
]);
}
}
//保存标签情况(搜索相关,不是系统标签和自定义标签)
//供应商性质为原厂(4)的话,写入标签2;已认证的话,写入标签3
public function saveSupplierSearchTags($supplierId)
{
$supplierModel = new SupplierChannelModel();
$supplier = $supplierModel->where('supplier_id', $supplierId)->first()->toArray();
$tagFlags = [];
//先去判断供应商性质是否为原厂,如果是的话,写入标签2
if ($supplier['supplier_group'] == 4) {
$tagFlags[] = 2;
}
if ($supplier['has_certification'] == 1) {
$tagFlags[] = 3;
}
$redis = new RedisModel();
$redis->hset('supplier_search_tags', $supplier['supplier_code'], json_encode([
'supplier_code' => $supplier['supplier_code'],
'tags' => $tagFlags,
]));
}
}
\ No newline at end of file
......@@ -45,5 +45,6 @@ Route::group(['middleware' => ['web'], 'namespace' => 'Api'], function () {
Route::match(['get', 'post'], '/test', function () {
$service = new \App\Http\Services\DataService();
// $service->initSystemTag();
$service->transferFileData();
// $service->transferFileData();
$service->initSupplierSearchTags();
});
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