Commit 80ceab50 by mushishixian

联系人完善判断

parent 5017175f
Showing with 24 additions and 4 deletions
......@@ -67,19 +67,21 @@ class SupplierValidator
return $validator->errors()->first();
}
$supplierId = $request->get('supplier_id');
//检验名称是否已经存在数据库
$supplierModel = new SupplierChannelModel();
$contactModel = new SupplierContactModel();
$companyNameCount = 0;
if (empty($request->get('supplier_id'))) {
if (empty($supplierId)) {
$count = $supplierModel->where('supplier_name', $request->get('supplier_name'))->count();
$companyNameCount = $supplierModel->where('register_company_name',
$request->get('register_company_name'))->where('register_company_name', '!=', '')->count();
} else {
$count = $supplierModel->where('supplier_name', $request->get('supplier_name'))
->where('supplier_id', '!=', $request->get('supplier_id'))->count();
->where('supplier_id', '!=', $supplierId)->count();
//至少要有一个联系方式
$contactModel = new SupplierContactModel();
$contactCount = $contactModel->where('supplier_id', $request->get('supplier_id'))->count();
$contactCount = $contactModel->where('supplier_id', $supplierId)->count();
if (!$contactCount) {
return "供应商至少要有一个联系人,请补全";
}
......@@ -90,6 +92,24 @@ class SupplierValidator
if ($companyNameCount) {
return "该注册公司名已经存在,请核验后再提交";
}
if (!empty($supplierId)) {
//还要去判断当前提交人是否存在与其关联的联系人没有完善
$codeId = $request->user->codeId;
$notCompleteContacts = $contactModel->where('supplier_id', $supplierId)->where('can_check_uids', $codeId)
->where(function ($q) {
$q->where('supplier_consignee', '')
->orWhere('supplier_position', '')
->orWhere('supplier_email', '')
->orWhere('supplier_mobile', '')
->orWhere('supplier_telephone', '');
})->get();
$notCompleteContacts = !empty($notCompleteContacts) ? $notCompleteContacts->toArray() : [];
if ($notCompleteContacts) {
return "存在和你相关的联系人没有完善,请先去完善相关联系人";
}
}
}
private function messages()
......
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