2025-02-27 09:55:33 +08:00

118 lines
2.9 KiB
PHP

<?php
namespace app\oa\validate\works\finance;
use app\common\model\works\bgsp\OaFlow;
use app\common\validate\BaseValidate;
class InvoiceValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'code' => 'require',
'open_time' => 'require|dateFormat:Y-m-d',
'cash_type' => 'require|in:1,2,3,4,5,6,7',
'is_cash' => 'require|in:0,1,2',
'amount' => 'require|float',
'type' => 'require|in:1,2',
'invoice_subject' => 'require',
'invoice_type' => 'require|in:1,2,3',
'invoice_title' => 'require',
'invoice_phone' => 'mobile',
'invoice_account' => 'number',
'flow_id' => 'require|checkFlow',
'check_remark' => 'require',
'annex' => 'checkAnnex',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'require',
'code' => '发票号码',
'cash_type' => '付款方式',
'is_cash' => '是否到账',
'amount' => '发票金额',
'type' => '抬头类型',
'invoice_subject' => '发票主体',
'invoice_type' => '发票类型',
'invoice_title' => '开票抬头',
'invoice_phone' => '电话号码',
'invoice_account' => '银行账号',
'flow_id' => '审批流程id',
'check_remark' => '撤销的理由',
'annex' => '附件',
];
/**
* @notes 添加场景
* @return InvoiceValidate
* @author likeadmin
* @date 2024/05/24 14:16
*/
public function sceneAdd()
{
return $this->only(['amount','type','invoice_subject','invoice_type','invoice_title','invoice_phone','invoice_tax','invoice_bank','invoice_account','invoice_banking','invoice_address','remark','annex','flow_id','check_admin_ids','copy_uids']);
}
/**
* @notes 编辑场景
* @return InvoiceValidate
* @author likeadmin
* @date 2024/05/24 14:16
*/
public function sceneEdit()
{
return $this->only(['id','amount','type','invoice_subject','invoice_type','invoice_title','invoice_phone','invoice_tax','invoice_bank','invoice_account','invoice_banking','invoice_address','remark','annex','flow_id','check_admin_ids','copy_uids']);
}
/**
* @notes 删除场景
* @return InvoiceValidate
* @author likeadmin
* @date 2024/05/24 14:16
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return InvoiceValidate
* @author likeadmin
* @date 2024/05/24 14:16
*/
public function sceneDetail()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return InvoiceValidate
* @author likeadmin
* @date 2024/05/24 14:16
*/
public function sceneInvoice()
{
return $this->only(['id','code','open_time','delivery']);
}
public function checkFlow($value): bool|string {
$data = OaFlow::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '审批流程信息不存在';
}
if($data['type'] != 6){
return '当前审批流信息不属于报销审批类型';
}
return true;
}
}