新增
This commit is contained in:
parent
18013bf4b8
commit
173954b0f6
@ -107,5 +107,8 @@
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
public function datas()
|
||||
{
|
||||
return $this->data(FinancialBudgetDocLogic::datas());
|
||||
}
|
||||
}
|
@ -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\FinancialDepartmentIncomeSettlementLists;
|
||||
use app\adminapi\logic\financial\FinancialDepartmentIncomeSettlementLogic;
|
||||
use app\adminapi\validate\financial\FinancialDepartmentIncomeSettlementValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--部门收入结算控制器
|
||||
* Class FinancialDepartmentIncomeSettlementController
|
||||
* @package app\adminapi\controller\financial
|
||||
*/
|
||||
class FinancialDepartmentIncomeSettlementController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--部门收入结算列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new FinancialDepartmentIncomeSettlementLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加财务管理--部门收入结算
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new FinancialDepartmentIncomeSettlementValidate())->post()->goCheck('add');
|
||||
$result = FinancialDepartmentIncomeSettlementLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialDepartmentIncomeSettlementLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑财务管理--部门收入结算
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new FinancialDepartmentIncomeSettlementValidate())->post()->goCheck('edit');
|
||||
$result = FinancialDepartmentIncomeSettlementLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialDepartmentIncomeSettlementLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除财务管理--部门收入结算
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new FinancialDepartmentIncomeSettlementValidate())->post()->goCheck('delete');
|
||||
$result = FinancialDepartmentIncomeSettlementLogic::delete($params);
|
||||
if (true === $result) {
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialDepartmentIncomeSettlementLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--部门收入结算详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new FinancialDepartmentIncomeSettlementValidate())->goCheck('detail');
|
||||
$result = FinancialDepartmentIncomeSettlementLogic::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\FinancialDepartmentIncomeSettlementDetailLists;
|
||||
use app\adminapi\logic\financial\FinancialDepartmentIncomeSettlementDetailLogic;
|
||||
use app\adminapi\validate\financial\FinancialDepartmentIncomeSettlementDetailValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--部门收入结算--结算明细控制器
|
||||
* Class FinancialDepartmentIncomeSettlementDetailController
|
||||
* @package app\adminapi\controller\financial
|
||||
*/
|
||||
class FinancialDepartmentIncomeSettlementDetailController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--部门收入结算--结算明细列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new FinancialDepartmentIncomeSettlementDetailLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加财务管理--部门收入结算--结算明细
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new FinancialDepartmentIncomeSettlementDetailValidate())->post()->goCheck('add');
|
||||
$result = FinancialDepartmentIncomeSettlementDetailLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialDepartmentIncomeSettlementDetailLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑财务管理--部门收入结算--结算明细
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new FinancialDepartmentIncomeSettlementDetailValidate())->post()->goCheck('edit');
|
||||
$result = FinancialDepartmentIncomeSettlementDetailLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialDepartmentIncomeSettlementDetailLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除财务管理--部门收入结算--结算明细
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new FinancialDepartmentIncomeSettlementDetailValidate())->post()->goCheck('delete');
|
||||
FinancialDepartmentIncomeSettlementDetailLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--部门收入结算--结算明细详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new FinancialDepartmentIncomeSettlementDetailValidate())->goCheck('detail');
|
||||
$result = FinancialDepartmentIncomeSettlementDetailLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
<?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\dept\Dept;
|
||||
use app\common\model\financial\FinancialDepartmentIncomeSettlementDetail;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--部门收入结算--结算明细列表
|
||||
* Class FinancialDepartmentIncomeSettlementDetailLists
|
||||
* @package app\adminapi\listsfinancial
|
||||
*/
|
||||
class FinancialDepartmentIncomeSettlementDetailLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['department_income_settlement_id', 'dept_id', 'type'],
|
||||
'%like%' => ['settlement_code'],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--部门收入结算--结算明细列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return FinancialDepartmentIncomeSettlementDetail::where($this->searchWhere)
|
||||
->field(['id', 'department_income_settlement_id', 'dept_id', 'type', 'amount', 'settlement_amount', 'settlement_code'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($data) {
|
||||
$dept = Dept::field('name')->where('id', $data['dept_id'])->findOrEmpty();
|
||||
$data['dept_name'] = $dept['name'];
|
||||
$data['type_text'] = $data->type_text;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--部门收入结算--结算明细数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return FinancialDepartmentIncomeSettlementDetail::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -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\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\FinancialDepartmentIncomeSettlement;
|
||||
use app\common\model\financial\FinancialDepartmentIncomeSettlementDetail;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--部门收入结算列表
|
||||
* Class FinancialDepartmentIncomeSettlementLists
|
||||
* @package app\adminapi\listsfinancial
|
||||
*/
|
||||
class FinancialDepartmentIncomeSettlementLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['budget_doc_id'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--部门收入结算列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$where = [];
|
||||
if (!empty($params['contract_id'])) {
|
||||
$budget_doc_ids = FinancialBudgetDoc::where('contract_id', $params['contract_id'])->column('id');
|
||||
$where[] = ['budget_doc_id', 'in', $budget_doc_ids];
|
||||
}
|
||||
if (!empty($params['create_time'])) {
|
||||
$date = explode(',', $params['create_time']);
|
||||
$where[] = ['create_time', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]];
|
||||
}
|
||||
return FinancialDepartmentIncomeSettlement::where($this->searchWhere)->where($where)
|
||||
->field(['id', 'budget_doc_id', 'create_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($data) {
|
||||
$budget_doc = FinancialBudgetDoc::field('contract_id,code,name,issue_date')->where('id', $data['budget_doc_id'])->findOrEmpty();
|
||||
$contract = CostApprovedProject::field('contract_name,money')->where('id', $budget_doc['contract_id'])->findOrEmpty();
|
||||
$data['budget_doc_code'] = $budget_doc['code'];
|
||||
$data['budget_doc_name'] = $budget_doc['name'];
|
||||
$data['contract_name'] = $contract['contract_name'];
|
||||
$data['contract_money'] = $contract['money'];
|
||||
$data['issue_date'] = $budget_doc['issue_date'];
|
||||
$data['amount'] = FinancialDepartmentIncomeSettlementDetail::where('department_income_settlement_id', $data['id'])->sum('amount');
|
||||
$data['settlement_amount'] = FinancialDepartmentIncomeSettlementDetail::where('department_income_settlement_id', $data['id'])->sum('settlement_amount');
|
||||
unset($data['budget_doc_id']);
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--部门收入结算数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$where = [];
|
||||
if (!empty($params['contract_id'])) {
|
||||
$budget_doc_ids = FinancialBudgetDoc::where('contract_id', $params['contract_id'])->column('id');
|
||||
$where[] = ['budget_doc_id', 'in', $budget_doc_ids];
|
||||
}
|
||||
if (!empty($params['create_time'])) {
|
||||
$date = explode(',', $params['create_time']);
|
||||
$where[] = ['create_time', 'between', [strtotime($date[0] . ' 00:00:00'), strtotime($date[1] . ' 23:59:59')]];
|
||||
}
|
||||
return FinancialDepartmentIncomeSettlement::where($this->searchWhere)->where($where)->count();
|
||||
}
|
||||
|
||||
}
|
@ -163,4 +163,11 @@
|
||||
$data['contract_type_text'] = $contract->contract_type_text;
|
||||
return $data->toArray();
|
||||
}
|
||||
|
||||
public static function datas()
|
||||
{
|
||||
return FinancialBudgetDoc::field(['id', 'name'])->order(['id' => 'desc'])->select()->each(function ($data) {
|
||||
$data['projectinfo'] = 'ID:' . $data['id'] . ' / 名称:' . $data['name'];
|
||||
})->toArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
<?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\dept\Dept;
|
||||
use app\common\model\financial\FinancialDepartmentIncomeSettlementDetail;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--部门收入结算--结算明细逻辑
|
||||
* Class FinancialDepartmentIncomeSettlementDetailLogic
|
||||
* @package app\adminapi\logic\financial
|
||||
*/
|
||||
class FinancialDepartmentIncomeSettlementDetailLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加财务管理--部门收入结算--结算明细
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
FinancialDepartmentIncomeSettlementDetail::create([
|
||||
'department_income_settlement_id' => $params['department_income_settlement_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'type' => $params['type'],
|
||||
'amount' => $params['amount'],
|
||||
'settlement_amount' => $params['settlement_amount'],
|
||||
'settlement_code' => $params['settlement_code'],
|
||||
'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/27 09:46
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
FinancialDepartmentIncomeSettlementDetail::where('id', $params['id'])->update([
|
||||
'department_income_settlement_id' => $params['department_income_settlement_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'type' => $params['type'],
|
||||
'amount' => $params['amount'],
|
||||
'settlement_amount' => $params['settlement_amount'],
|
||||
'settlement_code' => $params['settlement_code'],
|
||||
'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/27 09:46
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return FinancialDepartmentIncomeSettlementDetail::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--部门收入结算--结算明细详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = FinancialDepartmentIncomeSettlementDetail::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$dept = Dept::field('name')->where('id', $data['dept_id'])->findOrEmpty();
|
||||
$data['dept_name'] = $dept['name'];
|
||||
$data['type_text'] = $data->type_text;
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
<?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\FinancialDepartmentIncomeSettlement;
|
||||
use app\common\model\financial\FinancialDepartmentIncomeSettlementDetail;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--部门收入结算逻辑
|
||||
* Class FinancialDepartmentIncomeSettlementLogic
|
||||
* @package app\adminapi\logic\financial
|
||||
*/
|
||||
class FinancialDepartmentIncomeSettlementLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加财务管理--部门收入结算
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$res = FinancialDepartmentIncomeSettlement::create([
|
||||
'budget_doc_id' => $params['budget_doc_id'],
|
||||
'desc' => $params['desc'],
|
||||
'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) {
|
||||
FinancialDepartmentIncomeSettlementDetail::create([
|
||||
'department_income_settlement_id' => $res->id,
|
||||
'dept_id' => $v['dept_id'],
|
||||
'type' => $v['type'],
|
||||
'amount' => $v['amount'],
|
||||
'settlement_amount' => $v['settlement_amount'],
|
||||
'settlement_code' => $v['settlement_code'],
|
||||
'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/27 09:46
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
FinancialDepartmentIncomeSettlement::where('id', $params['id'])->update([
|
||||
'budget_doc_id' => $params['budget_doc_id'],
|
||||
'desc' => $params['desc'],
|
||||
'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'])) {
|
||||
FinancialDepartmentIncomeSettlementDetail::where('id', $v['id'])->update([
|
||||
'department_income_settlement_id' => $params['id'],
|
||||
'dept_id' => $v['dept_id'],
|
||||
'type' => $v['type'],
|
||||
'amount' => $v['amount'],
|
||||
'settlement_amount' => $v['settlement_amount'],
|
||||
'settlement_code' => $v['settlement_code'],
|
||||
'remark' => $v['remark'],
|
||||
'update_time' => time(),
|
||||
]);
|
||||
} else {
|
||||
FinancialDepartmentIncomeSettlementDetail::create([
|
||||
'department_income_settlement_id' => $params['id'],
|
||||
'dept_id' => $v['dept_id'],
|
||||
'type' => $v['type'],
|
||||
'amount' => $v['amount'],
|
||||
'settlement_amount' => $v['settlement_amount'],
|
||||
'settlement_code' => $v['settlement_code'],
|
||||
'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/27 09:46
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
$detail = FinancialDepartmentIncomeSettlementDetail::where('department_income_settlement_id', 'in', $params['id'])->findOrEmpty();
|
||||
if (!$detail->isEmpty()) {
|
||||
self::setError('此数据关联了结算明细信息,需删除结算明细信息');
|
||||
return false;
|
||||
}
|
||||
return FinancialDepartmentIncomeSettlement::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--部门收入结算详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = FinancialDepartmentIncomeSettlement::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$budget_doc = FinancialBudgetDoc::field('contract_id,code,name,issue_date')->where('id', $data['budget_doc_id'])->findOrEmpty();
|
||||
$contract = CostApprovedProject::field('contract_name,part_a,create_date,money,contract_type')->where('id', $budget_doc['contract_id'])->findOrEmpty();
|
||||
$data['code'] = $budget_doc['code'];
|
||||
$data['name'] = $budget_doc['name'];
|
||||
$data['issue_date'] = $budget_doc['issue_date'];
|
||||
$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\FinancialDepartmentIncomeSettlement;
|
||||
use app\common\model\financial\FinancialDepartmentIncomeSettlementDetail;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--部门收入结算--结算明细验证器
|
||||
* Class FinancialDepartmentIncomeSettlementDetailValidate
|
||||
* @package app\adminapi\validate\financial
|
||||
*/
|
||||
class FinancialDepartmentIncomeSettlementDetailValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'department_income_settlement_id' => 'require|checkDepartmentIncomeSettlement',
|
||||
'dept_id' => 'require|checkDept',
|
||||
'type' => 'require|checkType',
|
||||
'amount' => 'require|float|gt:0',
|
||||
'settlement_amount' => 'require|float|gt:0',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'department_income_settlement_id' => '部门收入结算id',
|
||||
'dept_id' => '部门',
|
||||
'type' => '预算分成方式',
|
||||
'amount' => '预算分成金额',
|
||||
'settlement_amount' => '结算金额',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return FinancialDepartmentIncomeSettlementDetailValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['department_income_settlement_id', 'dept_id', 'type', 'amount', 'settlement_amount']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return FinancialDepartmentIncomeSettlementDetailValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'department_income_settlement_id', 'dept_id', 'type', 'amount', 'settlement_amount']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return FinancialDepartmentIncomeSettlementDetailValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])->remove('id', 'checkData');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return FinancialDepartmentIncomeSettlementDetailValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = FinancialDepartmentIncomeSettlementDetail::where('id', $value)->findOrEmpty();
|
||||
return $data->isEmpty() ? '数据不存在' : true;
|
||||
}
|
||||
|
||||
public function checkDepartmentIncomeSettlement($value): bool|string
|
||||
{
|
||||
$data = FinancialDepartmentIncomeSettlement::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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,155 @@
|
||||
<?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\FinancialDepartmentIncomeSettlement;
|
||||
use app\common\model\financial\FinancialDepartmentIncomeSettlementDetail;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--部门收入结算验证器
|
||||
* Class FinancialDepartmentIncomeSettlementValidate
|
||||
* @package app\adminapi\validate\financial
|
||||
*/
|
||||
class FinancialDepartmentIncomeSettlementValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'budget_doc_id' => 'require|checkBudgetDoc',
|
||||
'create_user' => 'require',
|
||||
'create_time' => 'require|dateFormat:Y-m-d H:i:s',
|
||||
'detail' => 'checkDetail'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'budget_doc_id' => '预算书id',
|
||||
'create_user' => '结算人',
|
||||
'create_time' => '结算日期',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return FinancialDepartmentIncomeSettlementValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['budget_doc_id', 'desc', 'create_user', 'create_time']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return FinancialDepartmentIncomeSettlementValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'budget_doc_id', 'desc', 'create_user', 'create_time']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return FinancialDepartmentIncomeSettlementValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])->remove('id', 'checkData');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return FinancialDepartmentIncomeSettlementValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 09:46
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = FinancialDepartmentIncomeSettlement::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 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 = FinancialDepartmentIncomeSettlementDetail::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) . '行预算分成金额必须是大于零的数字';
|
||||
}
|
||||
if (empty($v['settlement_amount'])) {
|
||||
return '第' . ($k + 1) . '行结算金额为空';
|
||||
} else {
|
||||
if (!is_numeric($v['settlement_amount']) || $v['settlement_amount'] < 0) return '第' . ($k + 1) . '行结算金额必须是大于零的数字';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -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 FinancialDepartmentIncomeSettlement
|
||||
* @package app\common\model\financial
|
||||
*/
|
||||
class FinancialDepartmentIncomeSettlement extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'financial_department_income_settlement';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<?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 app\common\model\dict\DictData;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--部门收入结算--结算明细模型
|
||||
* Class FinancialDepartmentIncomeSettlementDetail
|
||||
* @package app\common\model\financial
|
||||
*/
|
||||
class FinancialDepartmentIncomeSettlementDetail extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
|
||||
protected $name = 'financial_department_income_settlement_detail';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getTypeTextAttr($value, $data)
|
||||
{
|
||||
$dict = DictData::where('type_value', 'budget_share_method')->column('name', 'value');
|
||||
return !empty($data['type']) ? $dict[$data['type']] : '';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user