164 lines
6.2 KiB
PHP
164 lines
6.2 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\custom\Custom;
|
||
use app\common\model\project\Project;
|
||
use app\common\logic\BaseLogic;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* Project逻辑
|
||
* Class ProjectLogic
|
||
* @package app\adminapi\logic\project
|
||
*/
|
||
class ProjectLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/11/12 14:30
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
Project::create([
|
||
'custom_id' => $params['custom_id'],
|
||
'name' => $params['name'],
|
||
'project_type' => $params['project_type'],
|
||
'project_code' => project_code(),
|
||
'project_content' => $params['project_content'],
|
||
'project_estimation' => $params['project_estimation'],
|
||
'project_address' => $params['project_address'],
|
||
'estimated_construction' => $params['estimated_construction'],
|
||
'bidding_time' => strtotime($params['bidding_time']),
|
||
'bidding_method' => $params['bidding_method'],
|
||
'contacts' => $params['contacts'],
|
||
'position' => $params['position'],
|
||
'telephone' => $params['telephone'],
|
||
'department' => $params['department'],
|
||
'person' => $params['person'],
|
||
'relationship' => $params['relationship'],
|
||
'discovery_time' => strtotime($params['discovery_time']),
|
||
'information_sources' => $params['information_sources'],
|
||
'competitor' => $params['competitor'],
|
||
'construction_funds_sources' => $params['construction_funds_sources'],
|
||
'construction_payment_method' => $params['construction_payment_method'],
|
||
'construction_financial_status' => $params['construction_financial_status'],
|
||
'construction_recognition' => $params['construction_recognition'],
|
||
'my_construction_recognition' => $params['my_construction_recognition'],
|
||
'strategic_significance' => $params['strategic_significance'],
|
||
'industry' => $params['industry'],
|
||
'unit_nature' => $params['unit_nature'],
|
||
'annex' => $params['annex'],
|
||
'status' => 0
|
||
]);
|
||
|
||
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/12 14:30
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
Project::where('id', $params['id'])->update([
|
||
'custom_id' => $params['custom_id'],
|
||
'name' => $params['name'],
|
||
'project_type' => $params['project_type'],
|
||
'project_content' => $params['project_content'],
|
||
'project_estimation' => $params['project_estimation'],
|
||
'project_address' => $params['project_address'],
|
||
'estimated_construction' => $params['estimated_construction'],
|
||
'bidding_time' => strtotime($params['bidding_time']),
|
||
'bidding_method' => $params['bidding_method'],
|
||
'contacts' => $params['contacts'],
|
||
'position' => $params['position'],
|
||
'telephone' => $params['telephone'],
|
||
'department' => $params['department'],
|
||
'person' => $params['person'],
|
||
'relationship' => $params['relationship'],
|
||
'discovery_time' => strtotime($params['discovery_time']),
|
||
'information_sources' => $params['information_sources'],
|
||
'competitor' => $params['competitor'],
|
||
'construction_funds_sources' => $params['construction_funds_sources'],
|
||
'construction_payment_method' => $params['construction_payment_method'],
|
||
'construction_financial_status' => $params['construction_financial_status'],
|
||
'construction_recognition' => $params['construction_recognition'],
|
||
'my_construction_recognition' => $params['my_construction_recognition'],
|
||
'strategic_significance' => $params['strategic_significance'],
|
||
'industry' => $params['industry'],
|
||
'unit_nature' => $params['unit_nature'],
|
||
'annex' => $params['annex'],
|
||
]);
|
||
|
||
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/12 14:30
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return Project::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/11/12 14:30
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = Project::findOrEmpty($params['id'])->toArray();
|
||
$custom = Custom::field('name')->where('id',$data['custom_id'])->findOrEmpty();
|
||
$data['custom_name'] = $custom->isEmpty() ? '' : $custom['name'];
|
||
return $data;
|
||
}
|
||
} |