Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_supplier
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a0e1ef8d
authored
Jun 29, 2022
by
杨树贤
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
天眼查校验提前
parent
0a76ff65
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
50 deletions
app/Http/Services/SupplierService.php
app/Http/Validators/SupplierValidator.php
app/Http/Services/SupplierService.php
View file @
a0e1ef8d
...
...
@@ -161,7 +161,6 @@ class SupplierService
//添加附件
SupplierAttachmentService
::
addAttachmentFromAddPage
(
$supplierId
,
$attachmentData
);
}
//添加银行信息,也是有填一个表单域也要新增,排除receipt_type字段,因为这个肯定有的
if
(
!
checkArrayAllValueNull
(
$receiptData
,
[
'receipt_type'
]))
{
$receiptData
[
'supplier_id'
]
=
$supplierId
;
...
...
app/Http/Validators/SupplierValidator.php
View file @
a0e1ef8d
...
...
@@ -19,6 +19,19 @@ class SupplierValidator
{
//整理下请求数据
$validateData
=
$this
->
transformRequestData
(
$validateData
);
//这个要优先判断
if
(
!
checkPerm
(
'IgnoreCompanyCheck'
))
{
$regionType
=
$validateData
[
'region'
]
==
2
?
1
:
2
;
//还要校验提交上来的公司是否有合法信息
$companyInfo
=
(
new
CompanyService
())
->
getCompanyInfo
(
$validateData
[
'supplier_name'
],
$validateData
[
'tax_number'
],
$regionType
);
if
(
empty
(
$companyInfo
))
{
return
'公司未进行工商注册,请修改后重新提交'
;
}
}
//这个supplierId是用来判断是新增还是修改的
$supplierId
=
array_get
(
$validateData
,
'supplier_id'
);
//如果是修改直接提交,不是点申请审核的,只需要校验供应商名称和采购员是否完整即可
...
...
@@ -101,68 +114,73 @@ class SupplierValidator
* 供应商类型为代理商的,需要上传代理证才能成为正式供应商,没有上传代理证的只能为临时供应商。
* 非国内的供应商,商业登记证不能为空
**/
//只有在提交供应商是正式的时候,才会去校验附件
//校验附件这块,新增和修改判断的逻辑不一样
if
(
empty
(
$supplierId
))
{
$attachmentFields
=
array_unique
(
$validateData
[
'field_name'
]
);
$attachmentFields
=
array_unique
(
array_get
(
$validateData
,
'field_name'
,
[])
);
}
else
{
$attachmentFields
=
SupplierAttachmentsModel
::
where
(
'supplier_id'
,
$supplierId
)
->
get
()
->
pluck
(
'field_name'
)
->
toArray
();
}
if
(
!
$attachmentFields
)
{
$errorMessageList
[]
=
'请上传附件'
;
}
$attachmentFields
=
array_unique
(
$attachmentFields
);
//fixed.php FileNameMapping 可以知道所有对应关系
if
(
!
in_array
(
'business_license'
,
$attachmentFields
))
{
$errorMessageList
[]
=
'营业执照必须上传'
;
}
if
(
!
in_array
(
'billing_information'
,
$attachmentFields
)
&&
$validateData
[
'currency'
]
==
1
)
{
$errorMessageList
[]
=
'如果选择币种为人民币,开票资料必须上传'
;
}
}
else
{
$attachmentFields
=
array_unique
(
$attachmentFields
);
//fixed.php FileNameMapping 可以知道所有对应关系
if
(
!
in_array
(
'business_license'
,
$attachmentFields
))
{
$errorMessageList
[]
=
'营业执照必须上传'
;
}
if
(
$validateData
[
'supplier_type'
]
==
SupplierChannelModel
::
SUPPLIER_TYPE_OFFICIAL
&&
!
in_array
(
$validateData
[
'supplier_group'
],
[
SupplierChannelModel
::
SUPPLIER_TYPE_OFFICIAL
,
SupplierChannelModel
::
SUPPLIER_GROUP_PROXY
]))
{
if
(
!
in_array
(
'quality_assurance_agreement'
,
$attachmentFields
))
{
$errorMessageList
[]
=
'供应商为正式供应商,品质保证协议必须上传 (代理商跟原厂类型除外) '
;
if
(
!
in_array
(
'billing_information'
,
$attachmentFields
)
&&
$validateData
[
'currency'
]
==
1
)
{
$errorMessageList
[]
=
'如果选择币种为人民币,开票资料必须上传'
;
}
}
if
(
$validateData
[
'supplier_type'
]
==
SupplierChannelModel
::
SUPPLIER_TYPE_OFFICIAL
&&
$validateData
[
'supplier_group'
]
==
1
)
{
if
(
!
in_array
(
'proxy_certificate'
,
$attachmentFields
))
{
$errorMessageList
[]
=
'供应商为正式供应商,供应商性质为代理商,代理证必须上传'
;
if
(
$validateData
[
'supplier_type'
]
==
SupplierChannelModel
::
SUPPLIER_TYPE_OFFICIAL
&&
!
in_array
(
$validateData
[
'supplier_group'
],
[
SupplierChannelModel
::
SUPPLIER_TYPE_OFFICIAL
,
SupplierChannelModel
::
SUPPLIER_GROUP_PROXY
]))
{
if
(
!
in_array
(
'quality_assurance_agreement'
,
$attachmentFields
))
{
$errorMessageList
[]
=
'供应商为正式供应商,品质保证协议必须上传 (代理商跟原厂类型除外) '
;
}
}
}
//如果选择有法人身份证,那么附件上传必须要要有法人身份证
if
(
$validateData
[
'has_legal_ID_card'
]
==
1
)
{
if
(
!
in_array
(
'legal_ID_card'
,
$attachmentFields
))
{
$errorMessageList
[]
=
'请上传法人身份证'
;
if
(
$validateData
[
'supplier_type'
]
==
SupplierChannelModel
::
SUPPLIER_TYPE_OFFICIAL
&&
$validateData
[
'supplier_group'
]
==
1
)
{
if
(
!
in_array
(
'proxy_certificate'
,
$attachmentFields
)
)
{
$errorMessageList
[]
=
'供应商为正式供应商,供应商性质为代理商,代理证必须上传'
;
}
}
}
if
(
!
$supplierId
)
{
//附件信息校验
foreach
(
$validateData
[
'validity_type'
]
as
$key
=>
$type
)
{
//最后一个跳过,因为是模板里的数据
if
(
$key
==
(
count
(
$validateData
[
'validity_type'
])
-
1
))
{
continue
;
//如果选择有法人身份证,那么附件上传必须要要有法人身份证
if
(
$validateData
[
'has_legal_ID_card'
]
==
1
)
{
if
(
!
in_array
(
'legal_ID_card'
,
$attachmentFields
))
{
$errorMessageList
[]
=
'请上传法人身份证'
;
}
if
(
$type
==
2
&&
!
$validateData
[
'validity_period'
][
$key
])
{
$errorMessageList
[]
=
'附件有效期为自定义的时候,必须选择时间区间'
;
break
;
}
if
(
!
$supplierId
)
{
//附件信息校验
foreach
(
$validateData
[
'validity_type'
]
as
$key
=>
$type
)
{
//最后一个跳过,因为是模板里的数据
if
(
$key
==
(
count
(
$validateData
[
'validity_type'
])
-
1
))
{
continue
;
}
if
(
$type
==
2
&&
!
$validateData
[
'validity_period'
][
$key
])
{
$errorMessageList
[]
=
'附件有效期为自定义的时候,必须选择时间区间'
;
break
;
}
}
}
}
if
(
$validateData
[
'region'
]
!=
2
)
{
if
(
!
in_array
(
'registration_certificate'
,
$attachmentFields
))
{
$errorMessageList
[]
=
'海外供应商必须上传商业登记证/PI'
;
if
(
$validateData
[
'region'
]
!=
2
)
{
if
(
!
in_array
(
'registration_certificate'
,
$attachmentFields
))
{
$errorMessageList
[]
=
'海外供应商必须上传商业登记证/PI'
;
}
}
}
//银行信息校验
$receiptValidator
=
new
ReceiptValidator
();
if
(
empty
(
$supplierId
))
{
...
...
@@ -262,16 +280,7 @@ class SupplierValidator
$errorMessageList
[]
=
"存在和你相关的联系人没有完善,请先去完善相关联系人"
;
}
}
if
(
!
checkPerm
(
'IgnoreCompanyCheck'
))
{
$regionType
=
$validateData
[
'region'
]
==
2
?
1
:
2
;
//还要校验提交上来的公司是否有合法信息
$companyInfo
=
(
new
CompanyService
())
->
getCompanyInfo
(
$validateData
[
'supplier_name'
],
$validateData
[
'tax_number'
],
$regionType
);
if
(
empty
(
$companyInfo
))
{
$errorMessageList
[]
=
'公司未进行工商注册,请修改后重新提交'
;
}
}
return
implode
(
'|'
,
$errorMessageList
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment