194 lines
5.5 KiB
PHP
194 lines
5.5 KiB
PHP
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | 开源版本可自由商用,可去除界面版权logo
|
||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||
// | 访问官网:https://www.likeadmin.cn
|
||
// | likeadmin团队 版权所有 拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeadminTeam
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\adminapi\validate\bid;
|
||
|
||
|
||
use app\common\model\bid\BidBuyBiddingDocument;
|
||
use app\common\model\bid\BidDocumentExamination;
|
||
use app\common\model\bid\BidDocumentExaminationDetail;
|
||
use app\common\model\dict\DictData;
|
||
use app\common\model\material\Material;
|
||
use app\common\validate\BaseValidate;
|
||
|
||
|
||
/**
|
||
* 标书审查验证器
|
||
* Class BidDocumentExaminationValidate
|
||
* @package app\adminapi\validate\bid
|
||
*/
|
||
class BidDocumentExaminationValidate extends BaseValidate
|
||
{
|
||
|
||
/**
|
||
* 设置校验规则
|
||
* @var string[]
|
||
*/
|
||
protected $rule = [
|
||
'id' => 'require|checkData',
|
||
'buy_bidding_document_id' => 'require|checkBuyBiddingDocument',
|
||
'technical_review_annex' => 'checkAnnex',
|
||
'business_contract_deviation_annex' => 'checkAnnex',
|
||
'tax_rate' => 'checkTaxRate',
|
||
'pay_type' => 'checkPayType',
|
||
'quotation_detail' => 'checkQuotationDetail',
|
||
'flow_id' => 'require|checkFlow',
|
||
'path' => 'require',
|
||
];
|
||
|
||
protected $message = [
|
||
'id.require' => '缺少必要参数',
|
||
'buy_bidding_document_id.require' => '请选择标书编号',
|
||
];
|
||
|
||
|
||
/**
|
||
* @notes 添加场景
|
||
* @return BidDocumentExaminationValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/02 09:52
|
||
*/
|
||
public function sceneAdd()
|
||
{
|
||
return $this->remove('id', true)->remove('flow_id', true)->remove('path', true);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑场景
|
||
* @return BidDocumentExaminationValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/02 09:52
|
||
*/
|
||
public function sceneEdit()
|
||
{
|
||
return $this->remove('flow_id', true)->remove('path', true);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 删除场景
|
||
* @return BidDocumentExaminationValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/02 09:52
|
||
*/
|
||
public function sceneDelete()
|
||
{
|
||
return $this->only(['id'])->remove('id', 'checkData');
|
||
}
|
||
|
||
public function sceneApprove()
|
||
{
|
||
return $this->only(['id', 'flow_id', 'path']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 详情场景
|
||
* @return BidDocumentExaminationValidate
|
||
* @author likeadmin
|
||
* @date 2023/12/02 09:52
|
||
*/
|
||
public function sceneDetail()
|
||
{
|
||
return $this->only(['id']);
|
||
}
|
||
|
||
public function checkData($value): bool|string
|
||
{
|
||
$data = BidDocumentExamination::where('id', $value)->findOrEmpty();
|
||
if ($data->isEmpty()) {
|
||
return '数据不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkBuyBiddingDocument($value): bool|string
|
||
{
|
||
$data = BidBuyBiddingDocument::where('id', $value)->findOrEmpty();
|
||
if ($data->isEmpty()) {
|
||
return '标书信息不存在';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkTaxRate($value): bool|string
|
||
{
|
||
$dictDate = DictData::where('type_value', 'tax_rate')->column('value');
|
||
if (!in_array($value, $dictDate)) {
|
||
return '税率无效';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkPayType($value): bool|string
|
||
{
|
||
$dictDate = DictData::where('type_value', 'pay_type')->column('value');
|
||
if (!in_array($value, $dictDate)) {
|
||
return '付款方式无效';
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public function checkQuotationDetail($value): bool|string
|
||
{
|
||
if (!empty($value) && !is_array($value)) {
|
||
return '审查明细数据格式错误';
|
||
}
|
||
foreach ($value as $k => $v) {
|
||
if (!empty($v['id'])) {
|
||
$quotation_detail = BidDocumentExaminationDetail::where('id', $v['id'])->findOrEmpty();
|
||
if ($quotation_detail->isEmpty()) return '审查明细列表第' . ($k + 1) . '行审查明细数据不存在';
|
||
}
|
||
if (empty($v['product_id'])) {
|
||
return '请选择产品';
|
||
} else {
|
||
$product = Material::where('id', $v['product_id'])->findOrEmpty();
|
||
if ($product->isEmpty()) {
|
||
return '产品信息不存在';
|
||
}
|
||
}
|
||
if (empty($v['num'])) {
|
||
return '审查明细列表第' . ($k + 1) . '数量不能为空';
|
||
} else {
|
||
if (!is_numeric($v['num']) || $v['num'] < 0) {
|
||
return '审查明细列表第' . ($k + 1) . '数量必须是大于0的数字';
|
||
}
|
||
}
|
||
if (empty($v['cost_price'])) {
|
||
return '审查明细列表第' . ($k + 1) . '成本单价不能为空';
|
||
} else {
|
||
if (!is_numeric($v['cost_price']) || $v['cost_price'] < 0) {
|
||
return '审查明细列表第' . ($k + 1) . '成本单价必须是大于0的数字';
|
||
}
|
||
}
|
||
if (empty($v['sale_price'])) {
|
||
return '审查明细列表第' . ($k + 1) . '报价单价不能为空';
|
||
} else {
|
||
if (!is_numeric($v['sale_price']) || $v['sale_price'] < 0) {
|
||
return '审查明细列表第' . ($k + 1) . '报价单价必须是大于0的数字';
|
||
}
|
||
}
|
||
if (empty($v['points'])) {
|
||
return '审查明细列表第' . ($k + 1) . '点数不能为空';
|
||
} else {
|
||
if (!is_numeric($v['points']) || $v['points'] < 0) {
|
||
return '审查明细列表第' . ($k + 1) . '点数必须是大于0的数字';
|
||
}
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
} |