新增
This commit is contained in:
parent
387b787f8d
commit
74e9697ba4
@ -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\FinancialFeeApplicationLists;
|
||||
use app\adminapi\logic\financial\FinancialFeeApplicationLogic;
|
||||
use app\adminapi\validate\financial\FinancialFeeApplicationValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--费用申请控制器
|
||||
* Class FinancialFeeApplicationController
|
||||
* @package app\adminapi\controller\financial
|
||||
*/
|
||||
class FinancialFeeApplicationController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--费用申请列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new FinancialFeeApplicationLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加财务管理--费用申请
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new FinancialFeeApplicationValidate())->post()->goCheck('add');
|
||||
$result = FinancialFeeApplicationLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialFeeApplicationLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑财务管理--费用申请
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new FinancialFeeApplicationValidate())->post()->goCheck('edit');
|
||||
$result = FinancialFeeApplicationLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialFeeApplicationLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除财务管理--费用申请
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new FinancialFeeApplicationValidate())->post()->goCheck('delete');
|
||||
$result = FinancialFeeApplicationLogic::delete($params);
|
||||
if (true === $result) {
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialFeeApplicationLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--费用申请详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new FinancialFeeApplicationValidate())->goCheck('detail');
|
||||
$result = FinancialFeeApplicationLogic::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\FinancialFeeApplicationDetailLists;
|
||||
use app\adminapi\logic\financial\FinancialFeeApplicationDetailLogic;
|
||||
use app\adminapi\validate\financial\FinancialFeeApplicationDetailValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--费用申请--申请明细控制器
|
||||
* Class FinancialFeeApplicationDetailController
|
||||
* @package app\adminapi\controller\financial
|
||||
*/
|
||||
class FinancialFeeApplicationDetailController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--费用申请--申请明细列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new FinancialFeeApplicationDetailLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加财务管理--费用申请--申请明细
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new FinancialFeeApplicationDetailValidate())->post()->goCheck('add');
|
||||
$result = FinancialFeeApplicationDetailLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialFeeApplicationDetailLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑财务管理--费用申请--申请明细
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new FinancialFeeApplicationDetailValidate())->post()->goCheck('edit');
|
||||
$result = FinancialFeeApplicationDetailLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(FinancialFeeApplicationDetailLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除财务管理--费用申请--申请明细
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new FinancialFeeApplicationDetailValidate())->post()->goCheck('delete');
|
||||
FinancialFeeApplicationDetailLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--费用申请--申请明细详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new FinancialFeeApplicationDetailValidate())->goCheck('detail');
|
||||
$result = FinancialFeeApplicationDetailLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
<?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\FinancialFeeApplicationDetail;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--费用申请--申请明细列表
|
||||
* Class FinancialFeeApplicationDetailLists
|
||||
* @package app\adminapi\listsfinancial
|
||||
*/
|
||||
class FinancialFeeApplicationDetailLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['fee_application_id', 'subject_category'],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--费用申请--申请明细列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return FinancialFeeApplicationDetail::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)
|
||||
->field(['id', 'fee_application_id', 'subject_category', 'bill_num', 'amount', 'remark'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($data) {
|
||||
$data['subject_category_text'] = $data->subject_category_text;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--费用申请--申请明细数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return FinancialFeeApplicationDetail::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
<?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\FinancialFeeApplication;
|
||||
use app\common\model\financial\FinancialFeeApplicationDetail;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--费用申请列表
|
||||
* Class FinancialFeeApplicationLists
|
||||
* @package app\adminapi\listsfinancial
|
||||
*/
|
||||
class FinancialFeeApplicationLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'%like%' => ['theme', 'code', 'create_user'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--费用申请列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$where = [];
|
||||
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 FinancialFeeApplication::withoutField('update_time,delete_time')->where($this->searchWhere)->where($where)
|
||||
->field(['id', 'theme', 'code', 'days', 'remark', 'create_user', 'create_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($data) {
|
||||
$data['total_bill_num'] = FinancialFeeApplicationDetail::where('fee_application_id', $data['id'])->sum('bill_num');
|
||||
$data['total_amount'] = FinancialFeeApplicationDetail::where('fee_application_id', $data['id'])->sum('amount');
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--费用申请数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$where = [];
|
||||
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 FinancialFeeApplication::where($this->searchWhere)->where($where)->count();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
<?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\FinancialFeeApplicationDetail;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--费用申请--申请明细逻辑
|
||||
* Class FinancialFeeApplicationDetailLogic
|
||||
* @package app\adminapi\logic\financial
|
||||
*/
|
||||
class FinancialFeeApplicationDetailLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加财务管理--费用申请--申请明细
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
FinancialFeeApplicationDetail::create([
|
||||
'fee_application_id' => $params['fee_application_id'],
|
||||
'subject_category' => $params['subject_category'],
|
||||
'bill_num' => $params['bill_num'],
|
||||
'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/27 14:53
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
FinancialFeeApplicationDetail::where('id', $params['id'])->update([
|
||||
'fee_application_id' => $params['fee_application_id'],
|
||||
'subject_category' => $params['subject_category'],
|
||||
'bill_num' => $params['bill_num'],
|
||||
'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/27 14:53
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return FinancialFeeApplicationDetail::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--费用申请--申请明细详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = FinancialFeeApplicationDetail::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$data['subject_category_text'] = $data->subject_category_text;
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
156
app/adminapi/logic/financial/FinancialFeeApplicationLogic.php
Normal file
156
app/adminapi/logic/financial/FinancialFeeApplicationLogic.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\logic\financial;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\financial\FinancialFeeApplication;
|
||||
use app\common\model\financial\FinancialFeeApplicationDetail;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--费用申请逻辑
|
||||
* Class FinancialFeeApplicationLogic
|
||||
* @package app\adminapi\logic\financial
|
||||
*/
|
||||
class FinancialFeeApplicationLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加财务管理--费用申请
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$res = FinancialFeeApplication::create([
|
||||
'theme' => $params['theme'],
|
||||
'code' => data_unique_code('FYSQ'),
|
||||
'days' => $params['days'],
|
||||
'remark' => $params['remark'],
|
||||
'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) {
|
||||
FinancialFeeApplicationDetail::create([
|
||||
'fee_application_id' => $res->id,
|
||||
'subject_category' => $v['subject_category'],
|
||||
'bill_num' => $v['bill_num'],
|
||||
'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/27 14:53
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
FinancialFeeApplication::where('id', $params['id'])->update([
|
||||
'theme' => $params['theme'],
|
||||
'days' => $params['days'],
|
||||
'remark' => $params['remark'],
|
||||
'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'])) {
|
||||
FinancialFeeApplicationDetail::where('id', $v['id'])->update([
|
||||
'fee_application_id' => $params['id'],
|
||||
'subject_category' => $v['subject_category'],
|
||||
'bill_num' => $v['bill_num'],
|
||||
'amount' => $v['amount'],
|
||||
'remark' => $v['remark'],
|
||||
'update_time' => time(),
|
||||
]);
|
||||
} else {
|
||||
FinancialFeeApplicationDetail::create([
|
||||
'fee_application_id' => $params['id'],
|
||||
'subject_category' => $v['subject_category'],
|
||||
'bill_num' => $v['bill_num'],
|
||||
'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/27 14:53
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
$detail = FinancialFeeApplicationDetail::where('fee_application_id', 'in', $params['id'])->findOrEmpty();
|
||||
if (!$detail->isEmpty()) {
|
||||
self::setError('此数据关联了申请明细信息,需删除申请明细信息');
|
||||
return false;
|
||||
}
|
||||
return FinancialFeeApplication::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取财务管理--费用申请详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = FinancialFeeApplication::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
|
||||
$data['total_bill_num'] = FinancialFeeApplicationDetail::where('fee_application_id', $data['id'])->sum('bill_num');
|
||||
$data['total_amount'] = FinancialFeeApplicationDetail::where('fee_application_id', $data['id'])->sum('amount');
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
<?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\dict\DictData;
|
||||
use app\common\model\financial\FinancialFeeApplication;
|
||||
use app\common\model\financial\FinancialFeeApplicationDetail;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--费用申请--申请明细验证器
|
||||
* Class FinancialFeeApplicationDetailValidate
|
||||
* @package app\adminapi\validate\financial
|
||||
*/
|
||||
class FinancialFeeApplicationDetailValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'fee_application_id' => 'require|checkFeeApplication',
|
||||
'subject_category' => 'require|checkSubjectCategory',
|
||||
'bill_num' => 'require|integer|egt:0',
|
||||
'amount' => 'require|float|egt:0',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'fee_application_id' => '费用申请id',
|
||||
'subject_category' => '科目类别',
|
||||
'bill_num' => '票据张数',
|
||||
'amount' => '申请金额',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return FinancialFeeApplicationDetailValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['fee_application_id', 'subject_category', 'bill_num', 'amount']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return FinancialFeeApplicationDetailValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'fee_application_id', 'subject_category', 'bill_num', 'amount']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return FinancialFeeApplicationDetailValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])->remove('id', 'checkData');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return FinancialFeeApplicationDetailValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = FinancialFeeApplicationDetail::where('id', $value)->findOrEmpty();
|
||||
return $data->isEmpty() ? '数据不存在' : true;
|
||||
}
|
||||
|
||||
public function checkFeeApplication($value): bool|string
|
||||
{
|
||||
$data = FinancialFeeApplication::where('id', $value)->findOrEmpty();
|
||||
return $data->isEmpty() ? '费用申请信息不存在' : true;
|
||||
}
|
||||
|
||||
public function checkSubjectCategory($value): bool|string
|
||||
{
|
||||
$dict = DictData::where('type_value', 'subject_category')->column('value');
|
||||
return !in_array($value, $dict) ? '科目类别数据值无效' : true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
<?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\dict\DictData;
|
||||
use app\common\model\financial\FinancialFeeApplication;
|
||||
use app\common\model\financial\FinancialFeeApplicationDetail;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 财务管理--费用申请验证器
|
||||
* Class FinancialFeeApplicationValidate
|
||||
* @package app\adminapi\validate\financial
|
||||
*/
|
||||
class FinancialFeeApplicationValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require|checkData',
|
||||
'theme' => 'require',
|
||||
'days' => 'require|float|egt:0',
|
||||
'create_user' => 'require',
|
||||
'create_time' => 'require|dateFormat:Y-m-d H:i:s',
|
||||
'detail' => 'checkDetail'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'theme' => '单据主题',
|
||||
'days' => '借款天数',
|
||||
'create_user' => '申请人',
|
||||
'create_time' => '申请日期',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return FinancialFeeApplicationValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['theme', 'days', 'create_user', 'create_time']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return FinancialFeeApplicationValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id', 'theme', 'days', 'create_user', 'create_time']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return FinancialFeeApplicationValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id'])->remove('id', 'checkData');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return FinancialFeeApplicationValidate
|
||||
* @author likeadmin
|
||||
* @date 2024/03/27 14:53
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkData($value): bool|string
|
||||
{
|
||||
$data = FinancialFeeApplication::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 = FinancialFeeApplicationDetail::where('id', $v['id'])->findOrEmpty();
|
||||
if ($data->isEmpty()) {
|
||||
return '第' . ($k + 1) . '行申请明细信息不存在';
|
||||
}
|
||||
}
|
||||
if (empty($v['subject_category'])) {
|
||||
return '第' . ($k + 1) . '行科目类别为空';
|
||||
} else {
|
||||
$dict = DictData::where('type_value', 'subject_category')->column('value');
|
||||
if (!in_array($v['subject_category'], $dict)) return '第' . ($k + 1) . '行科目类别数据值无效';
|
||||
}
|
||||
if (empty($v['bill_num'])) {
|
||||
return '第' . ($k + 1) . '行票据张数为空';
|
||||
} else {
|
||||
if (!is_numeric($v['bill_num']) || $v['bill_num'] < 0) return '第' . ($k + 1) . '行票据张数必须是大于零的数字';
|
||||
}
|
||||
if (empty($v['amount'])) {
|
||||
return '第' . ($k + 1) . '行申请金额为空';
|
||||
} else {
|
||||
if (!is_numeric($v['amount']) || $v['amount'] < 0) return '第' . ($k + 1) . '行申请金额必须是大于零的数字';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
34
app/common/model/financial/FinancialFeeApplication.php
Normal file
34
app/common/model/financial/FinancialFeeApplication.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 FinancialFeeApplication
|
||||
* @package app\common\model\financial
|
||||
*/
|
||||
class FinancialFeeApplication extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'financial_fee_application';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
}
|
40
app/common/model/financial/FinancialFeeApplicationDetail.php
Normal file
40
app/common/model/financial/FinancialFeeApplicationDetail.php
Normal file
@ -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 FinancialFeeApplicationDetail
|
||||
* @package app\common\model\financial
|
||||
*/
|
||||
class FinancialFeeApplicationDetail extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
|
||||
protected $name = 'financial_fee_application_detail';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getSubjectCategoryTextAttr($value, $data)
|
||||
{
|
||||
$dict = DictData::where('type_value', 'subject_category')->column('name', 'value');
|
||||
return !empty($data['subject_category']) ? $dict[$data['subject_category']] : '';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user