新增项目预算书模块
This commit is contained in:
parent
6124008402
commit
d81fb074ea
@ -0,0 +1,111 @@
|
||||
<?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\controller\financial;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\financial\FinancialBudgetDocLists;
|
||||
use app\adminapi\logic\financial\FinancialBudgetDocLogic;
|
||||
use app\adminapi\validate\financial\FinancialBudgetDocValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--项目预算书控制器
|
||||
* Class FinancialBudgetDocController
|
||||
* @package app\adminapi\controller\financial
|
||||
*/
|
||||
class FinancialBudgetDocController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--项目预算书列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new FinancialBudgetDocLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加财务管理--项目预算书
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new FinancialBudgetDocValidate())->post()->goCheck('add');
|
||||
$result = FinancialBudgetDocLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialBudgetDocLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑财务管理--项目预算书
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new FinancialBudgetDocValidate())->post()->goCheck('edit');
|
||||
$result = FinancialBudgetDocLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialBudgetDocLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除财务管理--项目预算书
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new FinancialBudgetDocValidate())->post()->goCheck('delete');
|
||||
$result = FinancialBudgetDocLogic::delete($params);
|
||||
if (true === $result) {
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialBudgetDocLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--项目预算书详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new FinancialBudgetDocValidate())->goCheck('detail');
|
||||
$result = FinancialBudgetDocLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
<?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\controller\financial;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\financial\FinancialBudgetDocDetailLists;
|
||||
use app\adminapi\logic\financial\FinancialBudgetDocDetailLogic;
|
||||
use app\adminapi\validate\financial\FinancialBudgetDocDetailValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--项目预算书--预算明细控制器
|
||||
* Class FinancialBudgetDocDetailController
|
||||
* @package app\adminapi\controller\financial
|
||||
*/
|
||||
class FinancialBudgetDocDetailController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--项目预算书--预算明细列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new FinancialBudgetDocDetailLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加财务管理--项目预算书--预算明细
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new FinancialBudgetDocDetailValidate())->post()->goCheck('add');
|
||||
$result = FinancialBudgetDocDetailLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialBudgetDocDetailLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑财务管理--项目预算书--预算明细
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new FinancialBudgetDocDetailValidate())->post()->goCheck('edit');
|
||||
$result = FinancialBudgetDocDetailLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialBudgetDocDetailLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除财务管理--项目预算书--预算明细
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new FinancialBudgetDocDetailValidate())->post()->goCheck('delete');
|
||||
FinancialBudgetDocDetailLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--项目预算书--预算明细详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new FinancialBudgetDocDetailValidate())->goCheck('detail');
|
||||
$result = FinancialBudgetDocDetailLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
<?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\lists\financial;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\financial\FinancialBudgetDocDetail;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--项目预算书--预算明细列表
|
||||
* Class FinancialBudgetDocDetailLists
|
||||
* @package app\adminapi\listsfinancial
|
||||
*/
|
||||
class FinancialBudgetDocDetailLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['budget_doc_id', 'dept_id', 'type'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--项目预算书--预算明细列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return FinancialBudgetDocDetail::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)
|
||||
->field(['id', 'budget_doc_id', 'dept_id', 'type', 'amount', 'remark'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--项目预算书--预算明细数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return FinancialBudgetDocDetail::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
85
app/adminapi/lists/financial/FinancialBudgetDocLists.php
Normal file
85
app/adminapi/lists/financial/FinancialBudgetDocLists.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?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\lists\financial;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\cost_project\CostApprovedProject;
|
||||
use app\common\model\financial\FinancialBudgetDoc;
|
||||
use app\common\model\financial\FinancialBudgetDocDetail;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--项目预算书列表
|
||||
* Class FinancialBudgetDocLists
|
||||
* @package app\adminapi\listsfinancial
|
||||
*/
|
||||
class FinancialBudgetDocLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['contract_id'],
|
||||
'%like%' => ['code', 'name'],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--项目预算书列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return FinancialBudgetDoc::where($this->searchWhere)
|
||||
->field(['id', 'contract_id', 'code', 'name', 'issue_date'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($data) {
|
||||
$contract = CostApprovedProject::field('contract_name')->where('id', $data['contract_id'])->findOrEmpty();
|
||||
$data['contract_name'] = $contract['contract_name'];
|
||||
$data['total_amount'] = FinancialBudgetDocDetail::where('budget_doc_id', $data['id'])->sum('amount');
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--项目预算书数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return FinancialBudgetDoc::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
113
app/adminapi/logic/financial/FinancialBudgetDocDetailLogic.php
Normal file
113
app/adminapi/logic/financial/FinancialBudgetDocDetailLogic.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?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\financial;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\financial\FinancialBudgetDocDetail;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--项目预算书--预算明细逻辑
|
||||
* Class FinancialBudgetDocDetailLogic
|
||||
* @package app\adminapi\logic\financial
|
||||
*/
|
||||
class FinancialBudgetDocDetailLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加财务管理--项目预算书--预算明细
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
FinancialBudgetDocDetail::create([
|
||||
'budget_doc_id' => $params['budget_doc_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'type' => $params['type'],
|
||||
'amount' => $params['amount'],
|
||||
'remark' => $params['remark'],
|
||||
]);
|
||||
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/26 13:54
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
FinancialBudgetDocDetail::where('id', $params['id'])->update([
|
||||
'budget_doc_id' => $params['budget_doc_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'type' => $params['type'],
|
||||
'amount' => $params['amount'],
|
||||
'remark' => $params['remark'],
|
||||
'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/03/26 13:54
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return FinancialBudgetDocDetail::withoutField('create_time,update_time,delete_time')->destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--项目预算书--预算明细详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return FinancialBudgetDocDetail::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
}
|
166
app/adminapi/logic/financial/FinancialBudgetDocLogic.php
Normal file
166
app/adminapi/logic/financial/FinancialBudgetDocLogic.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?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\financial;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\cost_project\CostApprovedProject;
|
||||
use app\common\model\financial\FinancialBudgetDoc;
|
||||
use app\common\model\financial\FinancialBudgetDocDetail;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--项目预算书逻辑
|
||||
* Class FinancialBudgetDocLogic
|
||||
* @package app\adminapi\logic\financial
|
||||
*/
|
||||
class FinancialBudgetDocLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加财务管理--项目预算书
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$res = FinancialBudgetDoc::create([
|
||||
'contract_id' => $params['contract_id'],
|
||||
'code' => date('YSS'),
|
||||
'name' => $params['name'],
|
||||
'issue_date' => !empty($params['issue_date']) ? strtotime($params['issue_date']) : 0,
|
||||
'remark' => $params['remark'],
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
'create_user' => $params['create_user'],
|
||||
'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : time(),
|
||||
]);
|
||||
if (!empty($params['detail'])) {
|
||||
foreach ($params['detail'] as $v) {
|
||||
FinancialBudgetDocDetail::create([
|
||||
'budget_doc_id' => $res->id,
|
||||
'dept_id' => $v['dept_id'],
|
||||
'type' => $v['type'],
|
||||
'amount' => $v['amount'],
|
||||
'remark' => $v['remark'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
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/26 13:54
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
FinancialBudgetDoc::where('id', $params['id'])->update([
|
||||
'contract_id' => $params['contract_id'],
|
||||
'name' => $params['name'],
|
||||
'issue_date' => !empty($params['issue_date']) ? strtotime($params['issue_date']) : 0,
|
||||
'remark' => $params['remark'],
|
||||
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
|
||||
'create_user' => $params['create_user'],
|
||||
'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : time(),
|
||||
'update_time' => time()
|
||||
]);
|
||||
if (!empty($params['detail'])) {
|
||||
foreach ($params['detail'] as $v) {
|
||||
if (!empty($v['id'])) {
|
||||
FinancialBudgetDocDetail::where('id', $v['id'])->update([
|
||||
'budget_doc_id' => $params['id'],
|
||||
'dept_id' => $v['dept_id'],
|
||||
'type' => $v['type'],
|
||||
'amount' => $v['amount'],
|
||||
'remark' => $v['remark'],
|
||||
'update_time' => time(),
|
||||
]);
|
||||
} else {
|
||||
FinancialBudgetDocDetail::create([
|
||||
'budget_doc_id' => $params['id'],
|
||||
'dept_id' => $v['dept_id'],
|
||||
'type' => $v['type'],
|
||||
'amount' => $v['amount'],
|
||||
'remark' => $v['remark'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
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/26 13:54
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
$detail = FinancialBudgetDocDetail::where('budget_doc_id', 'in', $params['id'])->findOrEmpty();
|
||||
if (!$detail->isEmpty()) {
|
||||
self::setError('此数据关联了预算明细信息,需删除预算明细信息');
|
||||
return false;
|
||||
}
|
||||
return FinancialBudgetDoc::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--项目预算书详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = FinancialBudgetDoc::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$contract = CostApprovedProject::field('contract_name,part_a,create_date,money,contract_type')->where('id', $data['contract_id'])->findOrEmpty();
|
||||
$data['contract_name'] = $contract['contract_name'];
|
||||
$data['part_a'] = $contract['part_a'];
|
||||
$data['create_date'] = $contract['create_date'];
|
||||
$data['money'] = $contract['money'];
|
||||
$data['contract_type'] = $contract['contract_type'];
|
||||
$data['contract_type_text'] = $contract->contract_type_text;
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
<?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\validate\financial;
|
||||
|
||||
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\financial\FinancialBudgetDoc;
|
||||
use app\common\model\financial\FinancialBudgetDocDetail;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--项目预算书--预算明细验证器
|
||||
* Class FinancialBudgetDocDetailValidate
|
||||
* @package app\adminapi\validate\financial
|
||||
*/
|
||||
class FinancialBudgetDocDetailValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'budget_doc_id' => 'require|checkBudgetDoc',
|
||||
'dept_id' => 'require|checkDept',
|
||||
'type' => 'require|checkType',
|
||||
'amount' => 'require|float|gt:0',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'budget_doc_id' => '预算书id',
|
||||
'dept_id' => '部门',
|
||||
'type' => '预算分成方式',
|
||||
'amount' => '预算分成金额',
|
||||
'remark' => '备注',
|
||||
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return FinancialBudgetDocDetailValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['budget_doc_id', 'dept_id', 'type', 'amount', 'remark']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return FinancialBudgetDocDetailValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'budget_doc_id', 'dept_id', 'type', 'amount', 'remark']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return FinancialBudgetDocDetailValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])->remove('id', 'checkData');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return FinancialBudgetDocDetailValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = FinancialBudgetDocDetail::where('id', $value)->findOrEmpty();
|
||||
return $data->isEmpty() ? '数据不存在' : true;
|
||||
}
|
||||
|
||||
public function checkBudgetDoc($value): bool|string
|
||||
{
|
||||
$data = FinancialBudgetDoc::where('id', $value)->findOrEmpty();
|
||||
return $data->isEmpty() ? '项目预算书信息不存在' : true;
|
||||
}
|
||||
|
||||
public function checkDept($value): bool|string
|
||||
{
|
||||
$data = Dept::where('id', $value)->findOrEmpty();
|
||||
return $data->isEmpty() ? '部门信息不存在' : true;
|
||||
}
|
||||
|
||||
public function checkType($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value', 'budget_share_method')->column('value');
|
||||
return !in_array($value, $dict) ? '预算分成方式数据值无效' : true;
|
||||
}
|
||||
|
||||
}
|
156
app/adminapi/validate/financial/FinancialBudgetDocValidate.php
Normal file
156
app/adminapi/validate/financial/FinancialBudgetDocValidate.php
Normal file
@ -0,0 +1,156 @@
|
||||
<?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\validate\financial;
|
||||
|
||||
|
||||
use app\common\model\cost_project\CostApprovedProject;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\financial\FinancialBudgetDoc;
|
||||
use app\common\model\financial\FinancialBudgetDocDetail;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--项目预算书验证器
|
||||
* Class FinancialBudgetDocValidate
|
||||
* @package app\adminapi\validate\financial
|
||||
*/
|
||||
class FinancialBudgetDocValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'contract_id' => 'require|checkContract',
|
||||
'name' => 'require',
|
||||
'issue_date' => 'require|dateFormat:Y-m-d',
|
||||
'create_user' => 'require',
|
||||
'create_time' => 'require|dateFormat:Y-m-d H:i:s',
|
||||
'annex' => 'checkAnnex',
|
||||
'detail' => 'checkDetail'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'contract_id' => '合同id',
|
||||
'name' => '预算书名称',
|
||||
'issue_date' => '下达日期',
|
||||
'remark' => '备注',
|
||||
'create_user' => '创建人',
|
||||
'create_time' => '创建时间'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return FinancialBudgetDocValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['contract_id', 'name', 'issue_date', 'remark', 'create_user', 'create_time', 'annex']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return FinancialBudgetDocValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'contract_id', 'name', 'issue_date', 'remark', 'create_user', 'create_time', 'annex']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return FinancialBudgetDocValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])->remove('id', 'checkData');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return FinancialBudgetDocValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/26 13:54
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = FinancialBudgetDoc::where('id', $value)->findOrEmpty();
|
||||
return $data->isEmpty() ? '数据不存在' : true;
|
||||
}
|
||||
|
||||
public function checkContract($value): bool|string
|
||||
{
|
||||
$data = CostApprovedProject::where('id', $value)->findOrEmpty();
|
||||
return $data->isEmpty() ? '合同信息不存在' : true;
|
||||
}
|
||||
|
||||
public function checkDetail($value): bool|string
|
||||
{
|
||||
if (empty($value) || $value == '') return true;
|
||||
if (!is_array($value)) return '预算明细数据格式错误';
|
||||
foreach ($value as $k => $v) {
|
||||
if (isset($v['id']) && !empty($v['id'])) {
|
||||
$data = FinancialBudgetDocDetail::where('id', $v['id'])->findOrEmpty();
|
||||
if ($data->isEmpty()) {
|
||||
return '第' . ($k + 1) . '行预算明细信息不存在';
|
||||
}
|
||||
}
|
||||
if (empty($v['dept_id'])) {
|
||||
return '第' . ($k + 1) . '行部门为空';
|
||||
} else {
|
||||
$dept = Dept::where('id', $v['dept_id'])->findOrEmpty();
|
||||
if ($dept->isEmpty()) return '第' . ($k + 1) . '行部门信息不存在';
|
||||
}
|
||||
if (empty($v['type'])) {
|
||||
return '第' . ($k + 1) . '行预算分成方式为空';
|
||||
} else {
|
||||
$dict = DictData::where('type_value', 'budget_share_method')->column('value');
|
||||
if (!in_array($v['type'], $dict)) return '第' . ($k + 1) . '行预算分成方式数据值无效';
|
||||
}
|
||||
if (empty($v['amount'])) {
|
||||
return '第' . ($k + 1) . '行预算分成金额为空';
|
||||
} else {
|
||||
if (!is_numeric($v['amount']) || $v['amount'] < 0) return '第' . ($k + 1) . '行预算分成金额必须是大于零的数字';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
38
app/common/model/financial/FinancialBudgetDoc.php
Normal file
38
app/common/model/financial/FinancialBudgetDoc.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?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\common\model\financial;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--项目预算书模型
|
||||
* Class FinancialBudgetDoc
|
||||
* @package app\common\model\financial
|
||||
*/
|
||||
class FinancialBudgetDoc extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
|
||||
protected $name = 'financial_budget_doc';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getIssueDateAttr($value): string
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d', $value) : '';
|
||||
}
|
||||
}
|
34
app/common/model/financial/FinancialBudgetDocDetail.php
Normal file
34
app/common/model/financial/FinancialBudgetDocDetail.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?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\common\model\financial;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--项目预算书--预算明细模型
|
||||
* Class FinancialBudgetDocDetail
|
||||
* @package app\common\model\financial
|
||||
*/
|
||||
class FinancialBudgetDocDetail extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'financial_budget_doc_detail';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user