update
This commit is contained in:
parent
55d4fe7d21
commit
66eaf507fe
@ -12,26 +12,26 @@
|
|||||||
// | author: likeadminTeam
|
// | author: likeadminTeam
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace app\adminapi\validate\contract;
|
namespace app\adminapi\validate\contract;
|
||||||
|
|
||||||
|
|
||||||
use app\common\model\contract\ProcurementContract;
|
use app\common\model\contract\ProcurementContract;
|
||||||
use app\common\model\contract\ProcurementContractDetail;
|
use app\common\model\contract\ProcurementContractDetail;
|
||||||
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\material\MaterialPurchaseRequestDetail;
|
use app\common\model\material\MaterialPurchaseRequestDetail;
|
||||||
use app\common\model\project\Project;
|
use app\common\model\project\Project;
|
||||||
use app\common\model\supplier\Supplier;
|
use app\common\model\supplier\Supplier;
|
||||||
use app\common\validate\BaseValidate;
|
use app\common\validate\BaseValidate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 采购合同验证器
|
* 采购合同验证器
|
||||||
* Class ProcurementContractValidate
|
* Class ProcurementContractValidate
|
||||||
* @package app\adminapi\validate\contract
|
* @package app\adminapi\validate\contract
|
||||||
*/
|
*/
|
||||||
class ProcurementContractValidate extends BaseValidate
|
class ProcurementContractValidate extends BaseValidate
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置校验规则
|
* 设置校验规则
|
||||||
@ -85,7 +85,7 @@ class ProcurementContractValidate 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class ProcurementContractValidate 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ class ProcurementContractValidate extends BaseValidate
|
|||||||
*/
|
*/
|
||||||
public function sceneDelete()
|
public function sceneDelete()
|
||||||
{
|
{
|
||||||
return $this->only(['id'])->remove('id','checkData');
|
return $this->only(['id'])->remove('id', 'checkData');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -126,13 +126,13 @@ class ProcurementContractValidate 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 = ProcurementContract::where('id',$value)->findOrEmpty();
|
$data = ProcurementContract::where('id', $value)->findOrEmpty();
|
||||||
if($data->isEmpty()){
|
if ($data->isEmpty()) {
|
||||||
return '数据不存在';
|
return '数据不存在';
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -140,8 +140,8 @@ class ProcurementContractValidate 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;
|
||||||
@ -149,8 +149,8 @@ class ProcurementContractValidate 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;
|
||||||
@ -158,8 +158,8 @@ class ProcurementContractValidate extends BaseValidate
|
|||||||
|
|
||||||
public function checkContractType($value): bool|string
|
public function checkContractType($value): bool|string
|
||||||
{
|
{
|
||||||
$dict = DictData::where('type_value','procurement_contract_type')->column('value');
|
$dict = DictData::where('type_value', 'procurement_contract_type')->column('value');
|
||||||
if(!in_array($value,$dict)){
|
if (!in_array($value, $dict)) {
|
||||||
return '合同类型无效';
|
return '合同类型无效';
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -167,8 +167,8 @@ class ProcurementContractValidate 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;
|
||||||
@ -176,8 +176,8 @@ class ProcurementContractValidate 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;
|
||||||
@ -185,43 +185,47 @@ class ProcurementContractValidate extends BaseValidate
|
|||||||
|
|
||||||
public function checkProcurementContractDetail($value): bool|string
|
public function checkProcurementContractDetail($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'] != ''){
|
$material_purchase_request_detail = MaterialPurchaseRequestDetail::where('id', $v['material_purchase_request_detail_id'])->findOrEmpty();
|
||||||
$data_detail = ProcurementContractDetail::where('id',$v['id'])->findOrEmpty();
|
if (isset($v['id']) && $v['id'] != '') {
|
||||||
if($data_detail->isEmpty()){
|
$data_detail = ProcurementContractDetail::where('id', $v['id'])->findOrEmpty();
|
||||||
|
if ($data_detail->isEmpty()) {
|
||||||
return '采购合同明细信息不存在';
|
return '采购合同明细信息不存在';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(empty($v['material_purchase_request_detail_id'])){
|
if (empty($v['material_purchase_request_detail_id'])) {
|
||||||
return '请选择采购申请明细信息';
|
return '请选择采购申请明细信息';
|
||||||
}else{
|
} else {
|
||||||
$material_purchase_request_detail = MaterialPurchaseRequestDetail::where('id',$v['material_purchase_request_detail_id'])->findOrEmpty();
|
|
||||||
if($material_purchase_request_detail->isEmpty()){
|
if ($material_purchase_request_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 ($v['num'] > $material_purchase_request_detail['num']) {
|
||||||
|
return '数量不能大于申请数量';
|
||||||
}
|
}
|
||||||
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 '税率无效';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,35 +235,35 @@ class ProcurementContractValidate 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