201 lines
7.3 KiB
PHP
201 lines
7.3 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\consult_catalog;
|
||
|
||
|
||
use app\common\model\consult_build\ConsultAccept;
|
||
use app\common\model\consult_build\ConsultSceneExecute;
|
||
use app\common\model\consult_build\ConsultSceneOrg;
|
||
use app\common\model\consult_build\ConsultScenePrepare;
|
||
use app\common\model\consult_catalog\ConsultDirectory;
|
||
use app\common\model\consult_catalog\ConsultSubdirectory;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\consult_strategy\ConsultContract;
|
||
use app\common\model\consult_strategy\ConsultCost;
|
||
use app\common\model\consult_strategy\ConsultDeclare;
|
||
use app\common\model\consult_strategy\ConsultDesign;
|
||
use app\common\model\consult_strategy\ConsultProcure;
|
||
use app\common\model\consult_target\ConsultControl;
|
||
use app\common\model\consult_target\ConsultDecision;
|
||
use app\common\model\consult_target\ConsultDemand;
|
||
use app\common\model\consult_target\ConsultReceive;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 项目咨询--全过程咨询子目录逻辑
|
||
* Class ConsultSubdirectoryLogic
|
||
* @package app\adminapi\logic\consult_catalog
|
||
*/
|
||
class ConsultSubdirectoryLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加项目咨询--全过程咨询子目录
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2024/03/11 13:58
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
ConsultSubdirectory::create([
|
||
'directory_id' => $params['directory_id'],
|
||
'name' => $params['name']
|
||
]);
|
||
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/03/11 13:58
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
ConsultSubdirectory::where('id', $params['id'])->update([
|
||
'directory_id' => $params['directory_id'],
|
||
'name' => $params['name']
|
||
]);
|
||
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/03/11 13:58
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
//决策管理信息
|
||
$decision = ConsultDecision::where('subdirectory_id','in',$params['id'])->findOrEmpty();
|
||
if($decision->isEmpty()){
|
||
self::setError('此数据关联了决策管理信息,需删除决策管理信息');
|
||
return false;
|
||
}
|
||
//需求研究及管理
|
||
$demand = ConsultDemand::where('subdirectory_id','in',$params['id'])->findOrEmpty();
|
||
if($demand->isEmpty()){
|
||
self::setError('此数据关联了需求研究管理信息,需删除需求研究管理信息');
|
||
return false;
|
||
}
|
||
//总控管理
|
||
$control = ConsultControl::where('subdirectory_id','in',$params['id'])->findOrEmpty();
|
||
if($control->isEmpty()){
|
||
self::setError('此数据关联了总控管理信息,需删除总控管理信息');
|
||
return false;
|
||
}
|
||
//接收管理
|
||
$receive = ConsultReceive::where('subdirectory_id','in',$params['id'])->findOrEmpty();
|
||
if($receive->isEmpty()){
|
||
self::setError('此数据关联了接收管理信息,需删除接收管理信息');
|
||
return false;
|
||
}
|
||
//报建管理
|
||
$declare = ConsultDeclare::where('subdirectory_id','in',$params['id'])->findOrEmpty();
|
||
if($declare->isEmpty()){
|
||
self::setError('此数据关联了报建管理信息,需删除报建管理信息');
|
||
return false;
|
||
}
|
||
//招采管理
|
||
$procure = ConsultProcure::where('subdirectory_id','in',$params['id'])->findOrEmpty();
|
||
if($procure->isEmpty()){
|
||
self::setError('此数据关联了招采管理信息,需删除招采管理信息');
|
||
return false;
|
||
}
|
||
//合同管理
|
||
$contract = ConsultContract::where('subdirectory_id','in',$params['id'])->findOrEmpty();
|
||
if($contract->isEmpty()){
|
||
self::setError('此数据关联了合同管理信息,需删除合同管理信息');
|
||
return false;
|
||
}
|
||
//造价管理
|
||
$cost = ConsultCost::where('subdirectory_id','in',$params['id'])->findOrEmpty();
|
||
if($cost->isEmpty()){
|
||
self::setError('此数据关联了造价管理信息,需删除造价管理信息');
|
||
return false;
|
||
}
|
||
//设计管理
|
||
$design = ConsultDesign::where('subdirectory_id','in',$params['id'])->findOrEmpty();
|
||
if($design->isEmpty()){
|
||
self::setError('此数据关联了设计管理信息,需删除设计管理信息');
|
||
return false;
|
||
}
|
||
//现场准备
|
||
$scene_prepare = ConsultScenePrepare::where('subdirectory_id','in',$params['id'])->findOrEmpty();
|
||
if($scene_prepare->isEmpty()){
|
||
self::setError('此数据关联了现场准备信息,需删除现场准备信息');
|
||
return false;
|
||
}
|
||
//现场组织建设
|
||
$scene_org = ConsultSceneOrg::where('subdirectory_id','in',$params['id'])->findOrEmpty();
|
||
if($scene_org->isEmpty()){
|
||
self::setError('此数据关联了现场组织建设信息,需删除现场组织建设信息');
|
||
return false;
|
||
}
|
||
//现场实施管理
|
||
$scene_execute = ConsultSceneExecute::where('subdirectory_id','in',$params['id'])->findOrEmpty();
|
||
if($scene_execute->isEmpty()){
|
||
self::setError('此数据关联了现场实施管理信息,需删除现场实施管理信息');
|
||
return false;
|
||
}
|
||
//验收管理
|
||
$accept = ConsultAccept::where('subdirectory_id','in',$params['id'])->findOrEmpty();
|
||
if($accept->isEmpty()){
|
||
self::setError('此数据关联了验收管理信息,需删除验收管理信息');
|
||
return false;
|
||
}
|
||
return ConsultSubdirectory::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取项目咨询--全过程咨询子目录详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2024/03/11 13:58
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = ConsultSubdirectory::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
|
||
$directory = ConsultDirectory::field('name')->where('id',$data['directory_id'])->findOrEmpty();
|
||
$data['directory_name'] = $directory['name'];
|
||
return $data->toArray();
|
||
}
|
||
} |