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