151 lines
5.5 KiB
PHP
151 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\logic\project;
|
||
|
||
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\custom\Custom;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\project\ProjectFollowUp;
|
||
use app\common\logic\BaseLogic;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* ProjectFollowUp逻辑
|
||
* Class ProjectFollowUpLogic
|
||
* @package app\adminapi\logic\project
|
||
*/
|
||
class ProjectFollowUpLogic extends BaseLogic
|
||
{
|
||
|
||
/**
|
||
* @notes 添加
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/11/14 10:49
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
ProjectFollowUp::create([
|
||
'project_id' => $params['project_id'],
|
||
'executor' => $params['executor'],
|
||
'contacts' => $params['contacts'],
|
||
'contact_information' => $params['contact_information'],
|
||
'project_role' => $params['project_role'],
|
||
'position' => $params['position'],
|
||
'follow_date' => strtotime($params['follow_date']),
|
||
'follow_type' => $params['follow_type'],
|
||
'theme' => $params['theme'],
|
||
'action_description' => $params['action_description'],
|
||
'project_assurance' => $params['project_assurance'],
|
||
'follow_status' => $params['follow_status'],
|
||
'follow_stage' => $params['follow_stage'],
|
||
'notes' => $params['notes'],
|
||
'next_follow_up_date' => strtotime($params['next_follow_up_date']),
|
||
'file' => $params['file']
|
||
]);
|
||
Db::commit();
|
||
return true;
|
||
} catch (\Exception $e) {
|
||
Db::rollback();
|
||
self::setError($e->getMessage());
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 编辑
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/11/14 10:49
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
ProjectFollowUp::where('id', $params['id'])->update([
|
||
'project_id' => $params['project_id'],
|
||
'executor' => $params['executor'],
|
||
'contacts' => $params['contacts'],
|
||
'contact_information' => $params['contact_information'],
|
||
'project_role' => $params['project_role'],
|
||
'position' => $params['position'],
|
||
'follow_date' => strtotime($params['follow_date']),
|
||
'follow_type' => $params['follow_type'],
|
||
'theme' => $params['theme'],
|
||
'action_description' => $params['action_description'],
|
||
'project_assurance' => $params['project_assurance'],
|
||
'follow_status' => $params['follow_status'],
|
||
'follow_stage' => $params['follow_stage'],
|
||
'notes' => $params['notes'],
|
||
'next_follow_up_date' => strtotime($params['next_follow_up_date']),
|
||
'file' => $params['file']
|
||
]);
|
||
Db::commit();
|
||
return true;
|
||
} catch (\Exception $e) {
|
||
Db::rollback();
|
||
self::setError($e->getMessage());
|
||
return false;
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 删除
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/11/14 10:49
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return ProjectFollowUp::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/11/14 10:49
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = ProjectFollowUp::findOrEmpty($params['id']);
|
||
$data['follow_type_text'] = $data->follow_type_text;
|
||
$data['project_assurance_text'] = $data->project_assurance_text;
|
||
$data['follow_status_text'] = $data->follow_status_text;
|
||
$data['follow_stage_text'] = $data->follow_stage_text;
|
||
$data['follow_date'] = !empty($data['follow_date']) ? date('Y-m-d',$data['follow_date']) : '';
|
||
$data['next_follow_up_date'] = !empty($data['next_follow_up_date']) ? date('Y-m-d',$data['next_follow_up_date']) : '';
|
||
$project = Project::field('id,custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||
$executor = Admin::field('name')->where('id',$data['executor'])->findOrEmpty();
|
||
$data['executor'] = $executor['name'];
|
||
$data['project_name'] = $project['name'];
|
||
$data['project_code'] = $project['project_code'];
|
||
$data['custom_name'] = $custom['name'];
|
||
unset($data['delete_time']);
|
||
return $data->toArray();
|
||
}
|
||
} |