174 lines
7.3 KiB
PHP
174 lines
7.3 KiB
PHP
<?php
|
|
namespace app\adminapi\logic\cost_project;
|
|
|
|
use app\common\model\cost_project\CostApprovedProject;
|
|
use app\common\logic\BaseLogic;
|
|
use think\facade\Db;
|
|
|
|
|
|
/**
|
|
* 待立项造价项目逻辑
|
|
* Class CostApprovedProjectLogic
|
|
* @package app\adminapi\logic\cost_project
|
|
*/
|
|
class CostApprovedProjectLogic extends BaseLogic
|
|
{
|
|
|
|
/**
|
|
* @notes 添加待立项造价项目
|
|
* @param array $params
|
|
* @return bool
|
|
* @author likeadmin
|
|
* @date 2024/02/20 14:16
|
|
*/
|
|
public static function add(array $params): bool
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
CostApprovedProject::create([
|
|
'contract_name' => $params['contract_name'],
|
|
'contract_num' => date('Ymd',time()).'-'.mt_rand(100000, 999999),
|
|
'part_a' => $params['part_a'],
|
|
'part_a_contract' => $params['part_a_contract'] ?? '',
|
|
'part_a_address' => $params['part_a_address'] ?? '',
|
|
'part_b' => $params['part_b'],
|
|
'part_b_signatory' => $params['part_b_signatory'] ?? '',
|
|
'business_nature' => $params['business_nature'] ?? 0,
|
|
'industry_nature' => $params['industry_nature'] ?? 0,
|
|
'fund_sources' => $params['fund_sources'] ?? 0,
|
|
'const_area' => $params['const_area'] ?? 0,
|
|
'project_money' => $params['project_money'] ?? 0,
|
|
'project_scale' => $params['project_scale'] ?? '',
|
|
'money' => $params['money'],
|
|
'rate' => $params['rate'] ?? 0,
|
|
'contract_service' => $params['contract_service'] ?? '',
|
|
'start_date' => !empty($params['start_date']) ? strtotime($params['start_date']) : 0,
|
|
'end_date' => !empty($params['end_date']) ? strtotime($params['end_date']) : 0,
|
|
'performance' => $params['performance'] ?? 0,
|
|
'due_time' => !empty($params['due_time']) ? strtotime($params['due_time']) : 0,
|
|
'payment' => $params['payment'] ?? '',
|
|
'content' => $params['content'] ?? '',
|
|
'founder' => $params['founder'] ?? '',
|
|
'create_date' => !empty($params['create_date']) ? strtotime($params['create_date']) : 0,
|
|
'dept' => $params['dept'],
|
|
'signing_person' => $params['signing_person'] ?? '',
|
|
'regulators' => $params['regulators'],
|
|
'project_director' => $params['project_director'] ?? '',
|
|
'way' => $params['way'] ?? 0,
|
|
'seal_name' => $params['seal_name'] ?? 0,
|
|
'limit' => $params['limit'] ?? 0,
|
|
'limit_num' => $params['limit_num'] ?? 0,
|
|
'file_type' => $params['file_type'] ?? 0,
|
|
'seal_num' => $params['seal_num'] ?? 0,
|
|
'sealer' => $params['sealer'] ?? '',
|
|
'plance_seal' => $params['plance_seal'] ?? 0,
|
|
'send_date' => !empty($params['send_date']) ? strtotime($params['send_date']) : 0,
|
|
'number' => $params['number'] ?? '',
|
|
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
|
]);
|
|
Db::commit();
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
Db::rollback();
|
|
self::setError($e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 编辑待立项造价项目
|
|
* @param array $params
|
|
* @return bool
|
|
* @author likeadmin
|
|
* @date 2024/02/20 14:16
|
|
*/
|
|
public static function edit(array $params): bool
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
CostApprovedProject::where('id', $params['id'])->update([
|
|
'contract_name' => $params['contract_name'],
|
|
'part_a' => $params['part_a'],
|
|
'part_a_contract' => $params['part_a_contract'] ?? '',
|
|
'part_a_address' => $params['part_a_address'] ?? '',
|
|
'part_b' => $params['part_b'],
|
|
'part_b_signatory' => $params['part_b_signatory'] ?? '',
|
|
'business_nature' => $params['business_nature'] ?? 0,
|
|
'industry_nature' => $params['industry_nature'] ?? 0,
|
|
'fund_sources' => $params['fund_sources'] ?? 0,
|
|
'const_area' => $params['const_area'] ?? 0,
|
|
'project_money' => $params['project_money'] ?? 0,
|
|
'project_scale' => $params['project_scale'] ?? '',
|
|
'money' => $params['money'],
|
|
'rate' => $params['rate'] ?? 0,
|
|
'contract_service' => $params['contract_service'] ?? '',
|
|
'start_date' => !empty($params['start_date']) ? strtotime($params['start_date']) : 0,
|
|
'end_date' => !empty($params['end_date']) ? strtotime($params['end_date']) : 0,
|
|
'performance' => $params['performance'] ?? 0,
|
|
'due_time' => !empty($params['due_time']) ? strtotime($params['due_time']) : 0,
|
|
'payment' => $params['payment'] ?? '',
|
|
'content' => $params['content'] ?? '',
|
|
'founder' => $params['founder'] ?? '',
|
|
'create_date' => !empty($params['create_date']) ? strtotime($params['create_date']) : 0,
|
|
'dept' => $params['dept'],
|
|
'signing_person' => $params['signing_person'] ?? '',
|
|
'regulators' => $params['regulators'],
|
|
'project_director' => $params['project_director'] ?? '',
|
|
'way' => $params['way'] ?? 0,
|
|
'seal_name' => $params['seal_name'] ?? 0,
|
|
'limit' => $params['limit'] ?? 0,
|
|
'limit_num' => $params['limit_num'] ?? 0,
|
|
'file_type' => $params['file_type'] ?? 0,
|
|
'seal_num' => $params['seal_num'] ?? 0,
|
|
'sealer' => $params['sealer'] ?? '',
|
|
'plance_seal' => $params['plance_seal'] ?? 0,
|
|
'send_date' => !empty($params['send_date']) ? strtotime($params['send_date']) : 0,
|
|
'number' => $params['number'] ?? '',
|
|
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
|
'update_time' => time(),
|
|
]);
|
|
Db::commit();
|
|
return true;
|
|
} catch (\Exception $e) {
|
|
Db::rollback();
|
|
self::setError($e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 删除待立项造价项目
|
|
* @param array $params
|
|
* @return bool
|
|
* @author likeadmin
|
|
* @date 2024/02/20 14:16
|
|
*/
|
|
public static function delete(array $params): bool
|
|
{
|
|
return CostApprovedProject::destroy($params['id']);
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取待立项造价项目详情
|
|
* @param $params
|
|
* @return array
|
|
* @author likeadmin
|
|
* @date 2024/02/20 14:16
|
|
*/
|
|
public static function detail($params): array
|
|
{
|
|
$data = CostApprovedProject::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
|
|
$data['business_nature_text'] = $data->business_nature_text;
|
|
$data['industry_nature_text'] = $data->industry_nature_text;
|
|
$data['fund_sources_text'] = $data->fund_sources_text;
|
|
$data['const_area_text'] = $data->const_area_text;
|
|
$data['way_text'] = $data->way_text;
|
|
$data['seal_name_text'] = $data->seal_name_text;
|
|
$data['file_type_text'] = $data->file_type_text;
|
|
$data['plance_seal_text'] = $data->plance_seal_text;
|
|
return $data->toArray();
|
|
}
|
|
} |