update
This commit is contained in:
parent
913d9be8b1
commit
59516e0330
@ -12,25 +12,25 @@
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\contract;
|
||||
namespace app\adminapi\validate\contract;
|
||||
|
||||
use app\common\model\contract\SubcontractingContract;
|
||||
use app\common\model\contract\SubcontractingContractDetail;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\finance\FinancePaymentPlan;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectSubpackageBudgetDetail;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\contract\SubcontractingContract;
|
||||
use app\common\model\contract\SubcontractingContractDetail;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\finance\FinancePaymentPlan;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectSubpackageBudgetDetail;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* SubcontractingContract验证器
|
||||
* Class SubcontractingContractValidate
|
||||
* @package app\adminapi\validate\contract
|
||||
*/
|
||||
class SubcontractingContractValidate extends BaseValidate
|
||||
{
|
||||
class SubcontractingContractValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
@ -47,8 +47,8 @@ class SubcontractingContractValidate extends BaseValidate
|
||||
'account_period' => 'require|checkAccountPeriod',
|
||||
'retention_money_rate' => 'require|float|egt:0',
|
||||
'annex' => 'checkAnnex',
|
||||
'subcontracting_contract_detail' => 'require|checkSubcontractingContractDetail',
|
||||
'payment_plan' => 'require|checkPaymentPlan',
|
||||
'subcontracting_contract_detail' => 'checkSubcontractingContractDetail',
|
||||
'payment_plan' => 'checkPaymentPlan',
|
||||
'flow_id' => 'require|checkFlow',
|
||||
'path' => 'require',
|
||||
];
|
||||
@ -79,7 +79,7 @@ class SubcontractingContractValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true)->remove('flow_id',true)->remove('path',true);
|
||||
return $this->remove('id', true)->remove('flow_id', true)->remove('path', true);
|
||||
}
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ class SubcontractingContractValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->remove('flow_id',true)->remove('path',true);
|
||||
return $this->remove('flow_id', true)->remove('path', true);
|
||||
}
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ class SubcontractingContractValidate extends BaseValidate
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])->remove('id','checkData');
|
||||
return $this->only(['id'])->remove('id', 'checkData');
|
||||
}
|
||||
|
||||
|
||||
@ -120,13 +120,13 @@ class SubcontractingContractValidate extends BaseValidate
|
||||
|
||||
public function sceneApprove()
|
||||
{
|
||||
return $this->only(['id','flow_id','path']);
|
||||
return $this->only(['id', 'flow_id', 'path']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = SubcontractingContract::where('id',$value)->findOrEmpty();
|
||||
if($data->isEmpty()){
|
||||
$data = SubcontractingContract::where('id', $value)->findOrEmpty();
|
||||
if ($data->isEmpty()) {
|
||||
return '数据不存在';
|
||||
}
|
||||
return true;
|
||||
@ -134,8 +134,8 @@ class SubcontractingContractValidate extends BaseValidate
|
||||
|
||||
public function checkSupplier($value): bool|string
|
||||
{
|
||||
$supplier = Supplier::where('id',$value)->findOrEmpty();
|
||||
if($supplier->isEmpty()){
|
||||
$supplier = Supplier::where('id', $value)->findOrEmpty();
|
||||
if ($supplier->isEmpty()) {
|
||||
return '供应商信息不存在';
|
||||
}
|
||||
return true;
|
||||
@ -143,8 +143,8 @@ class SubcontractingContractValidate extends BaseValidate
|
||||
|
||||
public function checkProject($value): bool|string
|
||||
{
|
||||
$project = Project::where('id',$value)->findOrEmpty();
|
||||
if($project->isEmpty()){
|
||||
$project = Project::where('id', $value)->findOrEmpty();
|
||||
if ($project->isEmpty()) {
|
||||
return '项目信息不存在';
|
||||
}
|
||||
return true;
|
||||
@ -152,8 +152,8 @@ class SubcontractingContractValidate extends BaseValidate
|
||||
|
||||
public function checkContractType($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value','divide_contract_type')->column('value');
|
||||
if(!in_array($value,$dict)){
|
||||
$dict = DictData::where('type_value', 'divide_contract_type')->column('value');
|
||||
if (!in_array($value, $dict)) {
|
||||
return '合同类型无效';
|
||||
}
|
||||
return true;
|
||||
@ -161,8 +161,8 @@ class SubcontractingContractValidate extends BaseValidate
|
||||
|
||||
public function checkPayType($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value','pay_type')->column('value');
|
||||
if(!in_array($value,$dict)){
|
||||
$dict = DictData::where('type_value', 'pay_type')->column('value');
|
||||
if (!in_array($value, $dict)) {
|
||||
return '付款方式无效';
|
||||
}
|
||||
return true;
|
||||
@ -170,8 +170,8 @@ class SubcontractingContractValidate extends BaseValidate
|
||||
|
||||
public function checkAccountPeriod($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value','account_period')->column('value');
|
||||
if(!in_array($value,$dict)){
|
||||
$dict = DictData::where('type_value', 'account_period')->column('value');
|
||||
if (!in_array($value, $dict)) {
|
||||
return '账期无效';
|
||||
}
|
||||
return true;
|
||||
@ -179,43 +179,43 @@ class SubcontractingContractValidate extends BaseValidate
|
||||
|
||||
public function checkSubcontractingContractDetail($value): bool|string
|
||||
{
|
||||
if(!empty($value) && !is_array($value)){
|
||||
if (!empty($value) && !is_array($value)) {
|
||||
return '分包合同明细数据格式错误';
|
||||
}
|
||||
foreach($value as $v) {
|
||||
if(isset($v['id']) && $v['id'] != ''){
|
||||
$data_detail = SubcontractingContractDetail::where('id',$v['id'])->findOrEmpty();
|
||||
if($data_detail->isEmpty()){
|
||||
foreach ($value as $v) {
|
||||
if (isset($v['id']) && $v['id'] != '') {
|
||||
$data_detail = SubcontractingContractDetail::where('id', $v['id'])->findOrEmpty();
|
||||
if ($data_detail->isEmpty()) {
|
||||
return '分包合同明细信息不存在';
|
||||
}
|
||||
}
|
||||
if(empty($v['subpackage_budget_detail_id'])){
|
||||
if (empty($v['subpackage_budget_detail_id'])) {
|
||||
return '请选择分包预算明细信息';
|
||||
}else{
|
||||
$subcontracting_budget_detail = ProjectSubpackageBudgetDetail::where('id',$v['subpackage_budget_detail_id'])->findOrEmpty();
|
||||
if($subcontracting_budget_detail->isEmpty()){
|
||||
} else {
|
||||
$subcontracting_budget_detail = ProjectSubpackageBudgetDetail::where('id', $v['subpackage_budget_detail_id'])->findOrEmpty();
|
||||
if ($subcontracting_budget_detail->isEmpty()) {
|
||||
return '分包预算明细信息不存在';
|
||||
}
|
||||
}
|
||||
if(empty($v['num'])){
|
||||
if (empty($v['num'])) {
|
||||
return '工作量不能为空';
|
||||
}else{
|
||||
if(!is_numeric($v['num']) || $v['num'] <= 0){
|
||||
} else {
|
||||
if (!is_numeric($v['num']) || $v['num'] <= 0) {
|
||||
return '工作量必须是大于0的数字';
|
||||
}
|
||||
}
|
||||
if(empty($v['price'])){
|
||||
if (empty($v['price'])) {
|
||||
return '含税单价不能为空';
|
||||
}else{
|
||||
if(!is_numeric($v['price']) || $v['price'] <= 0){
|
||||
} else {
|
||||
if (!is_numeric($v['price']) || $v['price'] <= 0) {
|
||||
return '含税单价必须是大于0的数字';
|
||||
}
|
||||
}
|
||||
if(empty($v['tax_rate'])){
|
||||
if (empty($v['tax_rate'])) {
|
||||
return '请选择税率';
|
||||
}else{
|
||||
$dict = DictData::where('type_value','tax_rate')->column('value');
|
||||
if(!in_array($v['tax_rate'],$dict)){
|
||||
} else {
|
||||
$dict = DictData::where('type_value', 'tax_rate')->column('value');
|
||||
if (!in_array($v['tax_rate'], $dict)) {
|
||||
return '税率无效';
|
||||
}
|
||||
}
|
||||
@ -225,35 +225,35 @@ class SubcontractingContractValidate extends BaseValidate
|
||||
|
||||
public function checkPaymentPlan($value): bool|string
|
||||
{
|
||||
if(!empty($value) && !is_array($value)){
|
||||
if (!empty($value) && !is_array($value)) {
|
||||
return '付款计划据格式错误';
|
||||
}
|
||||
foreach($value as $v) {
|
||||
if(isset($v['id']) && $v['id'] != ''){
|
||||
$data_detail = FinancePaymentPlan::where('id',$v['id'])->findOrEmpty();
|
||||
if($data_detail->isEmpty()){
|
||||
foreach ($value as $v) {
|
||||
if (isset($v['id']) && $v['id'] != '') {
|
||||
$data_detail = FinancePaymentPlan::where('id', $v['id'])->findOrEmpty();
|
||||
if ($data_detail->isEmpty()) {
|
||||
return '付款计划信息不存在';
|
||||
}
|
||||
}
|
||||
if(empty($v['period'])){
|
||||
if (empty($v['period'])) {
|
||||
return '请选择期次';
|
||||
}else{
|
||||
$dict = DictData::where('type_value','pay_period')->column('value');
|
||||
if(!in_array($v['period'],$dict)){
|
||||
} else {
|
||||
$dict = DictData::where('type_value', 'pay_period')->column('value');
|
||||
if (!in_array($v['period'], $dict)) {
|
||||
return '期次无效';
|
||||
}
|
||||
}
|
||||
if(empty($v['pay_date'])){
|
||||
if (empty($v['pay_date'])) {
|
||||
return '请选择计划付款日期';
|
||||
}
|
||||
if(empty($v['amount'])){
|
||||
if (empty($v['amount'])) {
|
||||
return '金额不能为空';
|
||||
}else{
|
||||
if(!is_numeric($v['amount']) || $v['amount'] <= 0){
|
||||
} else {
|
||||
if (!is_numeric($v['amount']) || $v['amount'] <= 0) {
|
||||
return '金额必须是大于0的数字';
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user