Merge pull request 'update contract' (#125) from zhangwei into dev
Reviewed-on: #125
This commit is contained in:
commit
413a86fa55
@ -16,8 +16,13 @@ namespace app\adminapi\lists\contract;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\bid\BidBuyBiddingDocument;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\model\finance\FinanceReturnedRecord;
|
||||
use app\common\model\project\Project;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
@ -38,7 +43,8 @@ class ContractLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['c.org_id', 'c.dept_id', 'c.customer_id', 'c.contract_name', 'c.contract_type', 'c.contract_code'],
|
||||
'=' => ['contract_type', 'contract_code'],
|
||||
'%like%' => ['contract_code']
|
||||
];
|
||||
}
|
||||
|
||||
@ -54,23 +60,39 @@ class ContractLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return Db::name('Contract')->alias('c')
|
||||
->where($this->searchWhere)
|
||||
->whereNull('c.delete_time')
|
||||
->leftJoin('bid_buy_bidding_document bbbd','bbbd.id = c.buy_bidding_document_id')
|
||||
->leftJoin('orgs o','o.id = c.org_id')
|
||||
->leftJoin('dept d','d.id = c.dept_id')
|
||||
->leftJoin('project p','p.id = bbbd.project_id')
|
||||
->leftJoin('custom ct','ct.id = c.customer_id')
|
||||
->field('c.*, d.name as dept_name, o.name as org_name, bbbd.project_id, p.name as project_name, p.project_code, ct.name as customer_name')
|
||||
$params = $this->request->get(['project_name','business_director_name','custom_id']);
|
||||
$where = [];
|
||||
if(isset($params['project_name']) && $params['project_name'] != ''){
|
||||
$project_ids = Project::where('name','like','%'.$params['project_name'].'%')->column('id');
|
||||
$where[] = ['project_id','in',$project_ids];
|
||||
}
|
||||
if(isset($params['business_director_name']) && $params['business_director_name'] != ''){
|
||||
$business_director_ids = Admin::where('name','like','%'.$params['business_director_name'].'%')->column('id');
|
||||
$where[] = ['business_director','in',$business_director_ids];
|
||||
}
|
||||
if(isset($params['custom_id']) && $params['custom_id'] != ''){
|
||||
$project_ids = Admin::where('custom_id','=',$params['custom_id'])->column('id');
|
||||
$where[] = ['project_id','in',$project_ids];
|
||||
}
|
||||
return Contract::where($this->searchWhere)->where($where)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['c.id' => 'desc'])
|
||||
->select()->each(function($item, $key){
|
||||
//关联数据后续添加
|
||||
$item['approve_no'] = '付款单号';
|
||||
$item['approve_step'] = '流程步骤';
|
||||
$item['approve_settle_status'] = 1;
|
||||
return $item;
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function($data){
|
||||
$project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||||
$buy_bidding_document = BidBuyBiddingDocument::field('bid_document_no')->where('id',$data['buy_bidding_document_id'])->findOrEmpty();
|
||||
$business_director = Admin::field('name')->where('id',$data['business_director'])->findOrEmpty();
|
||||
$data['custom_name'] = $custom['name'];
|
||||
$data['bid_document_no'] = $buy_bidding_document['bid_document_no'];
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['contract_type_text'] = $data->contract_type_text;
|
||||
$data['contract_pricing_method_text'] = $data->contract_pricing_method_text;
|
||||
$data['contract_status_text'] = $data->contract_status_text;
|
||||
$data['contract_pricing_method_text'] = $data->contract_pricing_method_text;
|
||||
$data['business_director_name'] = $business_director['name'];
|
||||
$data['returned_amount'] = FinanceReturnedRecord::where('contract_id',$data['id'])->sum('amount');
|
||||
return $data;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
@ -84,12 +106,21 @@ class ContractLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Db::name('Contract')->alias('c')
|
||||
->where($this->searchWhere)
|
||||
->whereNull('c.delete_time')
|
||||
->leftJoin('bid_buy_bidding_document bbbd','c.id = c.buy_bidding_document_id')
|
||||
->leftJoin('project p','p.id = bbbd.project_id')
|
||||
->leftJoin('custom ct','ct.id = c.customer_id')->count();
|
||||
$params = $this->request->get(['project_name','business_director_name','custom_id']);
|
||||
$where = [];
|
||||
if(isset($params['project_name']) && $params['project_name'] != ''){
|
||||
$project_ids = Project::where('name','like','%'.$params['project_name'].'%')->column('id');
|
||||
$where[] = ['project_id','in',$project_ids];
|
||||
}
|
||||
if(isset($params['business_director_name']) && $params['business_director_name'] != ''){
|
||||
$business_director_ids = Admin::where('name','like','%'.$params['business_director_name'].'%')->column('id');
|
||||
$where[] = ['business_director','in',$business_director_ids];
|
||||
}
|
||||
if(isset($params['custom_id']) && $params['custom_id'] != ''){
|
||||
$project_ids = Admin::where('custom_id','=',$params['custom_id'])->column('id');
|
||||
$where[] = ['project_id','in',$project_ids];
|
||||
}
|
||||
return Contract::field('id')->where($this->searchWhere)->where($where)->count();
|
||||
}
|
||||
|
||||
}
|
@ -15,8 +15,12 @@
|
||||
namespace app\adminapi\logic\contract;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\bid\BidBuyBiddingDocument;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\finance\FinanceReturnedMoney;
|
||||
use app\common\model\finance\FinanceReturnedRecord;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\custom\Custom;
|
||||
use think\facade\Db;
|
||||
@ -40,41 +44,58 @@ class ContractLogic extends BaseLogic
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
$buy_bidding_document = BidBuyBiddingDocument::field('project_id')->where('id',$params['buy_bidding_document_id'])->findOrEmpty();
|
||||
$returned_money = json_decode($params['returned_money'],true);
|
||||
Db::startTrans();
|
||||
try {
|
||||
Contract::create([
|
||||
'org_id' => $params['org_id'] ?? 0,
|
||||
'dept_id' => $params['dept_id'] ?? 0,
|
||||
'customer_id' => $params['customer_id'] ?? 0,
|
||||
'approve_id' => $params['approve_id'] ?? 0,
|
||||
'buy_bidding_document_id' => $params['buy_bidding_document_id'] ?? 0,
|
||||
'contract_name' => $params['contract_name'] ?? '',
|
||||
'contract_code' => $params['contract_code'] ?? '',
|
||||
'contract_type' => $params['contract_type'] ?? 0,
|
||||
'contract_pricing_method' => $params['contract_pricing_method'] ?? 0,
|
||||
'party_a' => $params['party_a'] ?? '',
|
||||
'party_a_contact_address' => $params['party_a_contact_address'] ?? '',
|
||||
'party_a_diretor' => $params['party_a_diretor'] ?? '',
|
||||
'party_a_phone' => $params['party_a_phone'] ?? '',
|
||||
'party_a_mobile' => $params['party_a_mobile'] ?? '',
|
||||
'party_a_email' => $params['party_a_email'] ?? '',
|
||||
'party_b' => $params['party_b'] ?? '',
|
||||
'party_b_contact_address' => $params['party_b_contact_address'] ?? '',
|
||||
'party_b_diretor' => $params['party_b_diretor'] ?? '',
|
||||
'party_b_phone' => $params['party_b_phone'] ?? '',
|
||||
'party_b_mobile' => $params['party_b_mobile'] ?? '',
|
||||
'party_b_email' => $params['party_b_email'] ?? '',
|
||||
'amount' => $params['amount'] ?? 0,
|
||||
'amount_daxie' => $params['amount_daxie'] ?? '',
|
||||
'business_director' => $params['business_director'] ?? 0,
|
||||
'contract_status' => $params['contract_status'] ?? 0,
|
||||
'expire' => $params['expire'] ?? '',
|
||||
'contract_date' => $params['contract_date'] ?? '',
|
||||
'main_content' => $params['main_content'] ?? '',
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => $params['annex'] ?? '',
|
||||
$contractRes = Contract::create([
|
||||
"org_id" => $params['org_id'],
|
||||
"dept_id" =>$params['dept_id'],
|
||||
"project_id" => $buy_bidding_document['project_id'],
|
||||
"buy_bidding_document_id" => $params['buy_bidding_document_id'],
|
||||
"contract_name" =>$params['contract_name'],
|
||||
'contract_code' => data_unique_code('PHT'),
|
||||
"contract_type" => $params['contract_type'],
|
||||
"contract_pricing_method" => $params['contract_pricing_method'],
|
||||
"party_a" => $params['party_a'],
|
||||
"party_a_contact_address" => $params['party_a_contact_address'] ?? '',
|
||||
"party_a_diretor" => $params['party_a_diretor'] ?? '',
|
||||
"party_a_phone" => $params['party_a_phone'] ?? '',
|
||||
"party_a_mobile" => $params['party_a_mobile'] ?? '',
|
||||
"party_a_email" => $params['party_a_email'] ?? '',
|
||||
"party_b" => $params['party_b'],
|
||||
"party_b_contact_address" => $params['party_b_contact_address'] ?? '',
|
||||
"party_b_diretor" => $params['party_b_diretor'] ?? '',
|
||||
"party_b_phone" => $params['party_b_phone'] ?? '',
|
||||
"party_b_mobile" => $params['party_b_mobile'] ?? '',
|
||||
"party_b_email" => $params['party_b_email'] ?? '',
|
||||
"amount" => $params['amount'],
|
||||
"business_director" => $params['business_director'],
|
||||
"contract_status" => $params['contract_status'],
|
||||
"expire" => strtotime($params['expire']),
|
||||
"contract_date" => strtotime($params['contract_date']),
|
||||
"main_content" => $params['main_content'] ?? '',
|
||||
"remark" => $params['remark'] ?? '',
|
||||
"annex" => !empty($params['annex']) ? $params['annex'] : null,
|
||||
]);
|
||||
|
||||
foreach ($returned_money as $item)
|
||||
{
|
||||
FinanceReturnedMoney::create([
|
||||
'project_id' => $buy_bidding_document['project_id'],
|
||||
'contract_id' => $contractRes->id,
|
||||
'return_date' => strtotime($item['return_date']),
|
||||
'period' => $item['period'],
|
||||
'amount' => $item['amount'],
|
||||
'return_status' => 2,
|
||||
'return_duty_id' => 0,
|
||||
'remark' => $item['remark'] ?? '',
|
||||
'annex' => null,
|
||||
]);
|
||||
}
|
||||
Project::where('id',$buy_bidding_document['project_id'])->update([
|
||||
'status' => 3,
|
||||
'update_time' => time(),
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -94,41 +115,38 @@ class ContractLogic extends BaseLogic
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
$buy_bidding_document = BidBuyBiddingDocument::field('project_id')->where('id',$params['buy_bidding_document_id'])->findOrEmpty();
|
||||
Db::startTrans();
|
||||
try {
|
||||
Contract::where('approve_id', $params['approve_id'])->update([
|
||||
'org_id' => $params['org_id'] ?? 0,
|
||||
'dept_id' => $params['dept_id'] ?? 0,
|
||||
'customer_id' => $params['customer_id'] ?? 0,
|
||||
'approve_id' => $params['approve_id'] ?? 0,
|
||||
'buy_bidding_document_id' => $params['buy_bidding_document_id'] ?? 0,
|
||||
'contract_name' => $params['contract_name'] ?? '',
|
||||
'contract_code' => $params['contract_code'] ?? '',
|
||||
'contract_type' => $params['contract_type'] ?? 0,
|
||||
'contract_pricing_method' => $params['contract_pricing_method'] ?? 0,
|
||||
'party_a' => $params['party_a'] ?? '',
|
||||
'party_a_contact_address' => $params['party_a_contact_address'] ?? '',
|
||||
'party_a_diretor' => $params['party_a_diretor'] ?? '',
|
||||
'party_a_phone' => $params['party_a_phone'] ?? '',
|
||||
'party_a_mobile' => $params['party_a_mobile'] ?? '',
|
||||
'party_a_email' => $params['party_a_email'] ?? '',
|
||||
'party_b' => $params['party_b'] ?? '',
|
||||
'party_b_contact_address' => $params['party_b_contact_address'] ?? '',
|
||||
'party_b_diretor' => $params['party_b_diretor'] ?? '',
|
||||
'party_b_phone' => $params['party_b_phone'] ?? '',
|
||||
'party_b_mobile' => $params['party_b_mobile'] ?? '',
|
||||
'party_b_email' => $params['party_b_email'] ?? '',
|
||||
'amount' => $params['amount'] ?? 0,
|
||||
'amount_daxie' => $params['amount_daxie'] ?? '',
|
||||
'business_director' => $params['business_director'] ?? 0,
|
||||
'contract_status' => $params['contract_status'] ?? 0,
|
||||
'expire' => $params['expire'] ?? '',
|
||||
'contract_date' => $params['contract_date'] ?? '',
|
||||
'main_content' => $params['main_content'] ?? '',
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => $params['annex'] ?? '',
|
||||
"org_id" => $params['org_id'],
|
||||
"dept_id" =>$params['dept_id'],
|
||||
"project_id" => $buy_bidding_document['project_id'],
|
||||
"buy_bidding_document_id" => $params['buy_bidding_document_id'],
|
||||
"contract_name" =>$params['contract_name'],
|
||||
"contract_type" => $params['contract_type'],
|
||||
"contract_pricing_method" => $params['contract_pricing_method'],
|
||||
"party_a" => $params['party_a'],
|
||||
"party_a_contact_address" => $params['party_a_contact_address'] ?? '',
|
||||
"party_a_diretor" => $params['party_a_diretor'] ?? '',
|
||||
"party_a_phone" => $params['party_a_phone'] ?? '',
|
||||
"party_a_mobile" => $params['party_a_mobile'] ?? '',
|
||||
"party_a_email" => $params['party_a_email'] ?? '',
|
||||
"party_b" => $params['party_b'],
|
||||
"party_b_contact_address" => $params['party_b_contact_address'] ?? '',
|
||||
"party_b_diretor" => $params['party_b_diretor'] ?? '',
|
||||
"party_b_phone" => $params['party_b_phone'] ?? '',
|
||||
"party_b_mobile" => $params['party_b_mobile'] ?? '',
|
||||
"party_b_email" => $params['party_b_email'] ?? '',
|
||||
"amount" => $params['amount'],
|
||||
"business_director" => $params['business_director'],
|
||||
"contract_status" => $params['contract_status'],
|
||||
"expire" => strtotime($params['expire']),
|
||||
"contract_date" => strtotime($params['contract_date']),
|
||||
"main_content" => $params['main_content'] ?? '',
|
||||
"remark" => $params['remark'] ?? '',
|
||||
"annex" => !empty($params['annex']) ? $params['annex'] : null,
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
@ -161,19 +179,21 @@ class ContractLogic extends BaseLogic
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$contract = Contract::findOrEmpty($params['id']);
|
||||
$contract->document;
|
||||
$contract->project = null;
|
||||
$contract->custom = null;
|
||||
if (!empty($contract->document->project_id)) {
|
||||
$contract->project = Project::findOrEmpty($contract->document->project_id);
|
||||
}
|
||||
if (!empty($contract->project->custom_id)) {
|
||||
$contract->custom = Custom::findOrEmpty($contract->project->custom_id);
|
||||
}
|
||||
$contract->org;
|
||||
$contract->dept;
|
||||
$contract->annex = json_decode($contract->annex, true);
|
||||
return $contract->toArray();
|
||||
$data = Contract::findOrEmpty($params['id']);
|
||||
$project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||||
$buy_bidding_document = BidBuyBiddingDocument::field('bid_document_no')->where('id',$data['buy_bidding_document_id'])->findOrEmpty();
|
||||
$business_director = Admin::field('name')->where('id',$data['business_director'])->findOrEmpty();
|
||||
$data['custom_name'] = $custom['name'];
|
||||
$data['bid_document_no'] = $buy_bidding_document['bid_document_no'];
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['contract_type_text'] = $data->contract_type_text;
|
||||
$data['contract_pricing_method_text'] = $data->contract_pricing_method_text;
|
||||
$data['contract_status_text'] = $data->contract_status_text;
|
||||
$data['contract_pricing_method_text'] = $data->contract_pricing_method_text;
|
||||
$data['business_director_name'] = $business_director['name'];
|
||||
$data['returned_amount'] = FinanceReturnedRecord::where('contract_id',$data['id'])->sum('amount');
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -15,6 +15,13 @@
|
||||
namespace app\adminapi\validate\contract;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\bid\BidBuyBiddingDocument;
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
@ -32,11 +39,24 @@ class ContractValidate extends BaseValidate
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'approve_id' => 'require',
|
||||
'customer_id' => 'require',
|
||||
'buy_bidding_document_id' => 'require',
|
||||
'org_id' => 'require|checkOrg',
|
||||
'dept_id' => 'require|checkDept',
|
||||
'custom_id' => 'require|checkCustom',
|
||||
'buy_bidding_document_id' => 'require|checkBuyBiddingDocument',
|
||||
'contract_name' => 'require',
|
||||
'contract_code' => 'require',
|
||||
'contract_type' => 'require|checkContractType',
|
||||
'contract_pricing_method' => 'require|checkContractPricingMethod',
|
||||
'party_a' => 'require',
|
||||
'party_a_mobile' => 'mobile',
|
||||
'party_b' => 'require',
|
||||
'party_b_mobile' => 'mobile',
|
||||
'amount' => 'require|float|gt:0',
|
||||
'business_director' => 'require|checkBusinessDirector',
|
||||
'contract_status' => 'require|checkContractStatus',
|
||||
'expire' => 'require|dateFormat:Y-m-d',
|
||||
'contract_date' => 'require|dateFormat:Y-m-d',
|
||||
'annex' => 'checkAnnex',
|
||||
'returned_money' => 'require|checkReturnedMoney'
|
||||
];
|
||||
|
||||
|
||||
@ -44,8 +64,29 @@ class ContractValidate extends BaseValidate
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'approve_id' => 'approve_id',
|
||||
protected $message = [
|
||||
'id.require' => '缺少必要参数',
|
||||
'org_id.require' => '请选择组织',
|
||||
'dept_id.require' => '请选择部门',
|
||||
'custom_id.require' => '请选择客户',
|
||||
'buy_bidding_document_id.require' => '请选择标书编号',
|
||||
'contract_name.require' => '请填写合同名称',
|
||||
'contract_type.require' => '请选择合同类型',
|
||||
'contract_pricing_method.require' => '请选择合同计价方式',
|
||||
'party_a.require' => '请填写甲方名称',
|
||||
'party_a_mobile.mobile' => '甲方手机号码格式错误',
|
||||
'party_b.require' => '请填写乙方名称',
|
||||
'party_b_mobile.mobile' => '乙方手机号码格式错误',
|
||||
'amount.require' => '请填写合同金额',
|
||||
'amount.float' => '合同金额值必须是数字',
|
||||
'amount.gt' => '写合同金额值必须大于0',
|
||||
'business_director.require' => '请选择业务负责人',
|
||||
'contract_status.require' => '请选择合同状态',
|
||||
'expire.require' => '请选择合同有效期',
|
||||
'expire.dateFormat' => '合同有效期数据格式错误',
|
||||
'contract_date.require' => '请选择签约日期',
|
||||
'contract_date.dateFormat' => '签约日期数据格式错误',
|
||||
'returned_money.require' => '回款计划信息不能为空',
|
||||
];
|
||||
|
||||
|
||||
@ -68,9 +109,7 @@ class ContractValidate extends BaseValidate
|
||||
* @date 2023/12/02 17:19
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'approve_id', 'customer_id', 'buy_bidding_document_id', 'contract_name', 'contract_code']);
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
@ -95,5 +134,125 @@ class ContractValidate extends BaseValidate
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkOrg($value): bool|string
|
||||
{
|
||||
$org = Orgs::where('id',$value)->findOrEmpty();
|
||||
if($org->isEmpty()){
|
||||
return '组织不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkDept($value,$rule,$data): bool|string
|
||||
{
|
||||
$dept = Dept::where('id',$value)->findOrEmpty();
|
||||
if($dept->isEmpty()){
|
||||
return '部门不存在';
|
||||
}
|
||||
if($dept['org_id'] != $data['org_id']){
|
||||
return '部门无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkCustom($value): bool|string
|
||||
{
|
||||
$custom = Custom::where('id',$value)->findOrEmpty();
|
||||
if($custom->isEmpty()){
|
||||
return '客户信息不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkBuyBiddingDocument($value,$rule,$data): bool|string
|
||||
{
|
||||
$buy_bidding_document = BidBuyBiddingDocument::where('id',$value)->findOrEmpty();
|
||||
if($buy_bidding_document->isEmpty()){
|
||||
return '标书信息不存在';
|
||||
}
|
||||
$project = Project::where('id',$buy_bidding_document['project_id'])->findOrEmpty();
|
||||
if($data['custom_id'] != $project['custom_id']){
|
||||
return '标书信息无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkContractType($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value','contract_type')->column('value');
|
||||
if(!in_array($value,$dict)){
|
||||
return '合同类型无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkContractPricingMethod($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value','contract_pricing_method')->column('value');
|
||||
if(!in_array($value,$dict)){
|
||||
return '合同计价方式无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkContractStatus($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value','contract_status')->column('value');
|
||||
if(!in_array($value,$dict)){
|
||||
return '合同状态无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkBusinessDirector($value): bool|string
|
||||
{
|
||||
$user = Admin::where('id',$value)->findOrEmpty();
|
||||
if($user->isEmpty()){
|
||||
return '业务负责人信息不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkAnnex($value): bool|string
|
||||
{
|
||||
if(!empty($value) && $value != ''){
|
||||
$annex = json_decode($value,true);
|
||||
if(empty($annex) || !is_array($annex)){
|
||||
return '附件格式错误';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkReturnedMoney($value): bool|string
|
||||
{
|
||||
$detail = json_decode($value,true);
|
||||
if(empty($detail) || !is_array($detail)){
|
||||
return '审回款计划数据格式错误';
|
||||
}
|
||||
foreach($detail as $v) {
|
||||
if(empty($v['period'])){
|
||||
return '请选择期次';
|
||||
}else{
|
||||
$dict = DictData::where('type_value','pay_period')->column('value');
|
||||
if(!in_array($v['period'],$dict)){
|
||||
return '期次无效';
|
||||
}
|
||||
}
|
||||
if(empty($v['return_date'])){
|
||||
return '请选择计划回款日期';
|
||||
}
|
||||
|
||||
if(empty($v['amount'])){
|
||||
return '金额不能为空';
|
||||
}else{
|
||||
if(!is_numeric($v['amount']) || $v['amount'] <= 0){
|
||||
return '金额必须是大于0的数字';
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -30,26 +30,6 @@ class Contract extends BaseModel
|
||||
use SoftDelete;
|
||||
protected $name = 'contract';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function custom()
|
||||
{
|
||||
return $this->belongsTo(\app\common\model\custom\Custom::class, 'customer_id');
|
||||
}
|
||||
|
||||
public function document()
|
||||
{
|
||||
return $this->belongsTo(\app\common\model\bid\BidBuyBiddingDocument::class, 'buy_bidding_document_id');
|
||||
}
|
||||
|
||||
public function org()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\dept\Orgs::class, 'id', 'org_id');
|
||||
}
|
||||
|
||||
public function dept()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\dept\Dept::class, 'id', 'dept_id');
|
||||
}
|
||||
|
||||
public function getContractTypeTextAttr($value,$data): string
|
||||
{
|
||||
@ -63,6 +43,21 @@ class Contract extends BaseModel
|
||||
return $dictData[$data['contract_status']];
|
||||
}
|
||||
|
||||
public function getContractPricingMethodTextAttr($value,$data){
|
||||
$dictData = DictData::where('type_value','contract_pricing_method')->column('name','value');
|
||||
return $dictData[$data['contract_pricing_method']];
|
||||
}
|
||||
|
||||
public function getExpireAttr($value): string
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d',$value) : '';
|
||||
}
|
||||
|
||||
public function getContractDateAttr($value): string
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d',$value) : '';
|
||||
}
|
||||
|
||||
public function getAnnexAttr($value){
|
||||
return !empty($value) ? json_decode($value,true) : null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user