129 lines
4.9 KiB
PHP
129 lines
4.9 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\logic\supervision_qualification_review;
|
||
|
||
|
||
use app\common\model\supervision_project\SupervisionParticipatingUnits;
|
||
use app\common\model\supervision_project\SupervisionProject;
|
||
use app\common\model\supervision_qualification_review\SupervisionParticipatingUnitsQualifications;
|
||
use app\common\logic\BaseLogic;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 工程监理--参建单位资质逻辑
|
||
* Class SupervisionParticipatingUnitsQualificationsLogic
|
||
* @package app\adminapi\logic\supervision_qualification_review
|
||
*/
|
||
class SupervisionParticipatingUnitsQualificationsLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加工程监理--参建单位资质
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2024/02/26 14:03
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionParticipatingUnitsQualifications::create([
|
||
'project_id' => $params['project_id'],
|
||
'company_id' => $params['company_id'],
|
||
'qualification_name' => $params['qualification_name'],
|
||
'qualification_number' => $params['qualification_number'],
|
||
'get_date' => !empty($params['get_date']) ? strtotime($params['get_date']) : 0,
|
||
'effective_date' => !empty($params['effective_date']) ? strtotime($params['effective_date']) : 0,
|
||
'qualification_status' => $params['qualification_status'],
|
||
'remark' => $params['remark'],
|
||
'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/26 14:03
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
SupervisionParticipatingUnitsQualifications::where('id', $params['id'])->update([
|
||
'project_id' => $params['project_id'],
|
||
'company_id' => $params['company_id'],
|
||
'qualification_name' => $params['qualification_name'],
|
||
'qualification_number' => $params['qualification_number'],
|
||
'get_date' => !empty($params['get_date']) ? strtotime($params['get_date']) : 0,
|
||
'effective_date' => !empty($params['effective_date']) ? strtotime($params['effective_date']) : 0,
|
||
'qualification_status' => $params['qualification_status'],
|
||
'remark' => $params['remark'],
|
||
'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/26 14:03
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return SupervisionParticipatingUnitsQualifications::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取工程监理--参建单位资质详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2024/02/26 14:03
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = SupervisionParticipatingUnitsQualifications::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
|
||
$project = SupervisionProject::field('project_name')->where('id',$data['project_id'])->findOrEmpty();
|
||
$company = SupervisionParticipatingUnits::field('unit_name')->where('id',$data['company_id'])->findOrEmpty();
|
||
$data['project_name'] = $project['project_name'];
|
||
$data['company_name'] = $company['unit_name'];
|
||
$data['qualification_status_text'] = $data->qualification_one_status_text;
|
||
return $data->toArray();
|
||
}
|
||
} |