207 lines
7.0 KiB
PHP
207 lines
7.0 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\cost_project;
|
||
|
||
|
||
use app\common\model\cost_project\CostProject;
|
||
use app\common\logic\BaseLogic;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 造价项目台账逻辑
|
||
* Class CostProjectLogic
|
||
* @package app\adminapi\logic\cost_project
|
||
*/
|
||
class CostProjectLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加造价项目台账
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2024/02/21 09:23
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
CostProject::create([
|
||
'project_num' => $params['project_num'],
|
||
'project_name' => $params['project_name'],
|
||
'contract_id' => $params['contract_id'],
|
||
'types' => $params['types'],
|
||
'industry' => $params['industry'],
|
||
'province' => $params['province'],
|
||
'city' => $params['city'],
|
||
'address' => $params['address'],
|
||
'starting' => $params['starting'],
|
||
'endtime' => $params['endtime'],
|
||
'jhgq' => $params['jhgq'],
|
||
'org_id' => $params['org_id'],
|
||
'depar' => $params['depar'],
|
||
'principal' => $params['principal'],
|
||
'person' => $params['person'],
|
||
'invest' => $params['invest'],
|
||
'budget' => $params['budget'],
|
||
'cost' => $params['cost'],
|
||
'approval' => $params['approval'],
|
||
'aunit' => $params['aunit'],
|
||
'Acontact' => $params['Acontact'],
|
||
'acontactnum' => $params['acontactnum'],
|
||
'date' => $params['date'],
|
||
'generalize' => $params['generalize'],
|
||
'note' => $params['note'],
|
||
'remark' => $params['remark'],
|
||
'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 2024/02/21 09:23
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
CostProject::where('id', $params['id'])->update([
|
||
'project_num' => $params['project_num'],
|
||
'project_name' => $params['project_name'],
|
||
'contract_id' => $params['contract_id'],
|
||
'types' => $params['types'],
|
||
'industry' => $params['industry'],
|
||
'province' => $params['province'],
|
||
'city' => $params['city'],
|
||
'address' => $params['address'],
|
||
'starting' => $params['starting'],
|
||
'endtime' => $params['endtime'],
|
||
'jhgq' => $params['jhgq'],
|
||
'org_id' => $params['org_id'],
|
||
'depar' => $params['depar'],
|
||
'principal' => $params['principal'],
|
||
'person' => $params['person'],
|
||
'invest' => $params['invest'],
|
||
'budget' => $params['budget'],
|
||
'cost' => $params['cost'],
|
||
'approval' => $params['approval'],
|
||
'aunit' => $params['aunit'],
|
||
'Acontact' => $params['Acontact'],
|
||
'acontactnum' => $params['acontactnum'],
|
||
'date' => $params['date'],
|
||
'generalize' => $params['generalize'],
|
||
'note' => $params['note'],
|
||
'remark' => $params['remark'],
|
||
'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 2024/02/21 09:23
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return CostProject::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取造价项目台账详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2024/02/21 09:23
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
return CostProject::with(['contract'])->findOrEmpty($params['id'])->toArray();
|
||
}
|
||
|
||
public static function datas($name)
|
||
{
|
||
$datas = CostProject::where(function ($query) use ($name) {
|
||
if ($name) {
|
||
$query->where('project_name', 'like', '%' . $name . '%');
|
||
}
|
||
})
|
||
->field(['id', 'project_num', 'project_name'])
|
||
->order(['id' => 'desc'])
|
||
->select()
|
||
->toArray();
|
||
foreach ($datas as &$item) {
|
||
$item['projectinfo'] = 'ID:' . $item['id'] . ' / 名称:' . $item['project_name'];
|
||
}
|
||
return $datas;
|
||
}
|
||
|
||
public static function createProject($data)
|
||
{
|
||
return CostProject::create([
|
||
'project_num' => generate_sn('cost_project'),
|
||
'project_name' => $data['project_name'],
|
||
'contract_id' => $data['contract_id'],
|
||
'types' => $data['types'],
|
||
'industry' => $data['industry'],
|
||
'province' => $data['province'],
|
||
'city' => $data['city'],
|
||
'address' => $data['address'],
|
||
'starting' => $data['starting'],
|
||
'endtime' => $data['endtime'],
|
||
'jhgq' => $data['jhgq'],
|
||
'depar' => $data['depar'],
|
||
'principal' => $data['principal'],
|
||
'person' => $data['person'],
|
||
'invest' => $data['invest'],
|
||
'budget' => $data['budget'],
|
||
'cost' => $data['cost'],
|
||
'approval' => $data['approval'],
|
||
'aunit' => $data['aunit'],
|
||
'Acontact' => $data['Acontact'],
|
||
'acontactnum' => $data['acontactnum'],
|
||
'date' => $data['date'],
|
||
'generalize' => $data['generalize'],
|
||
'note' => $data['note'],
|
||
'remark' => $data['remark'],
|
||
'annex' => $data['annex']
|
||
]);
|
||
}
|
||
} |