This commit is contained in:
weiz 2024-01-19 11:10:36 +08:00
parent 1da8d86ec3
commit 4d580cab2a
9 changed files with 608 additions and 415 deletions

View File

@ -1,77 +1,128 @@
<?php <?php
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版 // | likeadmin快速开发前后端分离管理后台PHP版
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力 // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo // | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin // | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin // | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn // | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权 // | likeadmin团队 版权所有 拥有最终解释权
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | author: likeadminTeam // | author: likeadminTeam
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\adminapi\lists\project; namespace app\adminapi\lists\project;
use app\adminapi\lists\BaseAdminDataLists; use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\project\ProjectTravelReimbursementDetail; use app\common\model\project\Project;
use app\common\lists\ListsSearchInterface; use app\common\model\project\ProjectCostTempSet;
use app\common\model\project\ProjectTravelReimbursement;
use app\common\model\project\ProjectTravelReimbursementDetail;
/** use app\common\lists\ListsSearchInterface;
* 报销明细列表 use app\common\model\project\ProjectTripApply;
* Class ProjectTravelReimbursementDetailLists
* @package app\adminapi\listsproject
*/ /**
class ProjectTravelReimbursementDetailLists extends BaseAdminDataLists implements ListsSearchInterface * 报销明细列表
{ * Class ProjectTravelReimbursementDetailLists
* @package app\adminapi\listsproject
*/
/** class ProjectTravelReimbursementDetailLists extends BaseAdminDataLists implements ListsSearchInterface
* @notes 设置搜索条件 {
* @return \string[][]
* @author likeadmin
* @date 2024/01/18 13:57 /**
*/ * @notes 设置搜索条件
public function setSearch(): array * @return \string[][]
{ * @author likeadmin
return [ * @date 2024/01/18 13:57
'=' => ['travel_reimbursement_id'], */
]; public function setSearch(): array
} {
return [
'=' => ['travel_reimbursement_id'],
/** ];
* @notes 获取报销明细列表 }
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException /**
* @throws \think\db\exception\ModelNotFoundException * @notes 获取报销明细列表
* @author likeadmin * @return array
* @date 2024/01/18 13:57 * @throws \think\db\exception\DataNotFoundException
*/ * @throws \think\db\exception\DbException
public function lists(): array * @throws \think\db\exception\ModelNotFoundException
{ * @author likeadmin
return ProjectTravelReimbursementDetail::where($this->searchWhere) * @date 2024/01/18 13:57
->field(['id', 'travel_reimbursement_id', 'project_cost_temp_id', 'traffic_fee', 'stay_fee', 'restaurant_fee', 'subsidy_fee', 'other_fee', 'remark']) */
->limit($this->limitOffset, $this->limitLength) public function lists(): array
->order(['id' => 'desc']) {
->select() $params = $this->request->get(['trip_reimbursement_code','project_code','trip_apply_code']);
->toArray(); $where = [];
} if(isset($params['trip_reimbursement_code']) && $params['trip_reimbursement_code']){
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_reimbursement_code','like','%'.$params['trip_reimbursement_code'].'%')->column('id');
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
/** }
* @notes 获取报销明细数量 if(isset($params['project_code']) && $params['project_code']){
* @return int $project_ids = Project::where('project_code','like','%'.$params['project_code'].'%')->column('id');
* @author likeadmin $travel_reimbursement_ids = ProjectTravelReimbursement::where('project_id','in',$project_ids)->column('id');
* @date 2024/01/18 13:57 $where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
*/ }
public function count(): int if(isset($params['trip_apply_code']) && $params['trip_apply_code']){
{ $trip_apply_ids = ProjectTripApply::where('trip_apply_code','like','%'.$params['trip_apply_code'].'%')->column('id');
return ProjectTravelReimbursementDetail::where($this->searchWhere)->count(); $travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_apply_id','in',$trip_apply_ids)->column('id');
} $where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
}
return ProjectTravelReimbursementDetail::where($this->searchWhere)->where($where)
->field('id,travel_reimbursement_id,project_cost_temp_id,traffic_fee,stay_fee,restaurant_fee,subsidy_fee,other_fee,total_amount,remark')
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
$travel_reimbursement = ProjectTravelReimbursement::field('trip_reimbursement_code,trip_apply_id,project_id,apply_user,apply_date')->where('id',$data['travel_reimbursement_id'])->findOrEmpty();
$project_cost_temp = ProjectCostTempSet::field('first_level_subject,second_level_subject,third_level_subject')->where('id',$data['project_cost_temp_id'])->findOrEmpty();
$trip_apply = ProjectTripApply::field('trip_apply_code')->where('id',$travel_reimbursement['trip_apply_id'])->findOrEmpty();
$project = Project::field('name,project_code')->where('id',$travel_reimbursement['project_id'])->findOrEmpty();
$data['trip_apply_code'] = $trip_apply['trip_apply_code'];
$data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code'];
$data['trip_reimbursement_code'] = $travel_reimbursement['trip_reimbursement_code'];
$data['apply_user'] = $travel_reimbursement['apply_user'];
$data['apply_date'] = $travel_reimbursement['apply_date'];
$data['first_level_subject'] = $project_cost_temp['first_level_subject'];
$data['second_level_subject'] = $project_cost_temp['second_level_subject'];
$data['third_level_subject'] = $project_cost_temp['third_level_subject'];
return $data;
})
->toArray();
}
/**
* @notes 获取报销明细数量
* @return int
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function count(): int
{
$params = $this->request->get(['trip_reimbursement_code','project_code','trip_apply_code']);
$where = [];
if(isset($params['trip_reimbursement_code']) && $params['trip_reimbursement_code']){
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_reimbursement_code','like','%'.$params['trip_reimbursement_code'].'%')->column('id');
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
}
if(isset($params['project_code']) && $params['project_code']){
$project_ids = Project::where('project_code','like','%'.$params['project_code'].'%')->column('id');
$travel_reimbursement_ids = ProjectTravelReimbursement::where('project_id','in',$project_ids)->column('id');
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
}
if(isset($params['trip_apply_code']) && $params['trip_apply_code']){
$trip_apply_ids = ProjectTripApply::where('trip_apply_code','like','%'.$params['trip_apply_code'].'%')->column('id');
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_apply_id','in',$trip_apply_ids)->column('id');
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
}
return ProjectTravelReimbursementDetail::where($this->searchWhere)->where($where)->count();
}
} }

View File

@ -1,77 +1,127 @@
<?php <?php
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版 // | likeadmin快速开发前后端分离管理后台PHP版
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力 // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo // | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin // | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin // | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn // | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权 // | likeadmin团队 版权所有 拥有最终解释权
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | author: likeadminTeam // | author: likeadminTeam
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\adminapi\lists\project; namespace app\adminapi\lists\project;
use app\adminapi\lists\BaseAdminDataLists; use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\project\ProjectTravelReimbursementInvoiceDetail; use app\common\model\project\Project;
use app\common\lists\ListsSearchInterface; use app\common\model\project\ProjectTravelReimbursement;
use app\common\model\project\ProjectTravelReimbursementInvoiceDetail;
use app\common\lists\ListsSearchInterface;
/** use app\common\model\project\ProjectTripApply;
* 发票明细列表
* Class ProjectTravelReimbursementInvoiceDetailLists
* @package app\adminapi\listsproject /**
*/ * 发票明细列表
class ProjectTravelReimbursementInvoiceDetailLists extends BaseAdminDataLists implements ListsSearchInterface * Class ProjectTravelReimbursementInvoiceDetailLists
{ * @package app\adminapi\listsproject
*/
class ProjectTravelReimbursementInvoiceDetailLists extends BaseAdminDataLists implements ListsSearchInterface
/** {
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin /**
* @date 2024/01/18 13:57 * @notes 设置搜索条件
*/ * @return \string[][]
public function setSearch(): array * @author likeadmin
{ * @date 2024/01/18 13:57
return [ */
'=' => ['travel_reimbursement_id', 'invoice_type', 'invoice_sn', 'invoice_form'], public function setSearch(): array
]; {
} return [
'=' => ['travel_reimbursement_id', 'invoice_type', 'invoice_form'],
'%like%' => ['invoice_sn']
/** ];
* @notes 获取发票明细列表 }
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException /**
* @throws \think\db\exception\ModelNotFoundException * @notes 获取发票明细列表
* @author likeadmin * @return array
* @date 2024/01/18 13:57 * @throws \think\db\exception\DataNotFoundException
*/ * @throws \think\db\exception\DbException
public function lists(): array * @throws \think\db\exception\ModelNotFoundException
{ * @author likeadmin
return ProjectTravelReimbursementInvoiceDetail::where($this->searchWhere) * @date 2024/01/18 13:57
->field(['id', 'travel_reimbursement_id', 'invoice_type', 'invoice_sn', 'tax_rate', 'invoice_form', 'invoice_amount', 'tax_amount', 'annex', 'remark']) */
->limit($this->limitOffset, $this->limitLength) public function lists(): array
->order(['id' => 'desc']) {
->select() $params = $this->request->get(['trip_reimbursement_code','project_code','trip_apply_code']);
->toArray(); $where = [];
} if(isset($params['trip_reimbursement_code']) && $params['trip_reimbursement_code']){
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_reimbursement_code','like','%'.$params['trip_reimbursement_code'].'%')->column('id');
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
/** }
* @notes 获取发票明细数量 if(isset($params['project_code']) && $params['project_code']){
* @return int $project_ids = Project::where('project_code','like','%'.$params['project_code'].'%')->column('id');
* @author likeadmin $travel_reimbursement_ids = ProjectTravelReimbursement::where('project_id','in',$project_ids)->column('id');
* @date 2024/01/18 13:57 $where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
*/ }
public function count(): int if(isset($params['trip_apply_code']) && $params['trip_apply_code']){
{ $trip_apply_ids = ProjectTripApply::where('trip_apply_code','like','%'.$params['trip_apply_code'].'%')->column('id');
return ProjectTravelReimbursementInvoiceDetail::where($this->searchWhere)->count(); $travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_apply_id','in',$trip_apply_ids)->column('id');
} $where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
}
return ProjectTravelReimbursementInvoiceDetail::where($this->searchWhere)->where($where)
->field(['id', 'travel_reimbursement_id', 'invoice_type', 'invoice_sn', 'tax_rate', 'invoice_form', 'invoice_amount', 'tax_amount', 'remark'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($data){
$travel_reimbursement = ProjectTravelReimbursement::field('trip_reimbursement_code,trip_apply_id,project_id,apply_user,apply_date')->where('id',$data['travel_reimbursement_id'])->findOrEmpty();
$trip_apply = ProjectTripApply::field('trip_apply_code')->where('id',$travel_reimbursement['trip_apply_id'])->findOrEmpty();
$project = Project::field('name,project_code')->where('id',$travel_reimbursement['project_id'])->findOrEmpty();
$data['trip_apply_code'] = $trip_apply['trip_apply_code'];
$data['project_name'] = $project['name'];
$data['project_code'] = $project['project_code'];
$data['trip_reimbursement_code'] = $travel_reimbursement['trip_reimbursement_code'];
$data['apply_user'] = $travel_reimbursement['apply_user'];
$data['apply_date'] = $travel_reimbursement['apply_date'];
$data['invoice_type'] = $data->invoice_type_text;
$data['tax_rate'] = $data->tax_rate_text;
$data['invoice_form'] = $data->invoice_form_text;
return $data;
})
->toArray();
}
/**
* @notes 获取发票明细数量
* @return int
* @author likeadmin
* @date 2024/01/18 13:57
*/
public function count(): int
{
$params = $this->request->get(['trip_reimbursement_code','project_code','trip_apply_code']);
$where = [];
if(isset($params['trip_reimbursement_code']) && $params['trip_reimbursement_code']){
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_reimbursement_code','like','%'.$params['trip_reimbursement_code'].'%')->column('id');
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
}
if(isset($params['project_code']) && $params['project_code']){
$project_ids = Project::where('project_code','like','%'.$params['project_code'].'%')->column('id');
$travel_reimbursement_ids = ProjectTravelReimbursement::where('project_id','in',$project_ids)->column('id');
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
}
if(isset($params['trip_apply_code']) && $params['trip_apply_code']){
$trip_apply_ids = ProjectTripApply::where('trip_apply_code','like','%'.$params['trip_apply_code'].'%')->column('id');
$travel_reimbursement_ids = ProjectTravelReimbursement::where('trip_apply_id','in',$trip_apply_ids)->column('id');
$where[] = ['travel_reimbursement_id','in',$travel_reimbursement_ids];
}
return ProjectTravelReimbursementInvoiceDetail::where($this->searchWhere)->where($where)->count();
}
} }

View File

@ -22,6 +22,7 @@ use app\common\model\project\ProjectLoanApply;
use app\common\model\project\ProjectManagerAppointment; use app\common\model\project\ProjectManagerAppointment;
use app\common\model\project\ProjectTravelReimbursement; use app\common\model\project\ProjectTravelReimbursement;
use app\common\lists\ListsSearchInterface; use app\common\lists\ListsSearchInterface;
use app\common\model\project\ProjectTravelReimbursementDetail;
use app\common\model\project\ProjectTripApply; use app\common\model\project\ProjectTripApply;
@ -60,7 +61,7 @@ class ProjectTravelReimbursementLists extends BaseAdminDataLists implements List
*/ */
public function lists(): array public function lists(): array
{ {
$field = 'id,trip_apply_id,project_id,trip_reimbursement_code,reimbursement_type,loan_apply_id,reimbursement_amount,actual_reimbursement_amount,offset_loan_amount,apply_user,apply_date,remark'; $field = 'id,trip_apply_id,project_id,trip_reimbursement_code,reimbursement_type,loan_apply_id,offset_loan_amount,apply_user,apply_date,remark';
return ProjectTravelReimbursement::where($this->searchWhere) return ProjectTravelReimbursement::where($this->searchWhere)
->field($field) ->field($field)
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
@ -83,6 +84,8 @@ class ProjectTravelReimbursementLists extends BaseAdminDataLists implements List
$data['loan_amount'] = !$loan_apply->isEmpty() ? $loan_apply['loan_amount'] : '---'; $data['loan_amount'] = !$loan_apply->isEmpty() ? $loan_apply['loan_amount'] : '---';
$data['reimbursement_type'] = $data->reimbursement_type_text; $data['reimbursement_type'] = $data->reimbursement_type_text;
unset($data['trip_apply_id'],$data['loan_apply_id']); unset($data['trip_apply_id'],$data['loan_apply_id']);
$data['total_amount'] = ProjectTravelReimbursementDetail::where('travel_reimbursement_id',$data['id'])->sum('total_amount');
$data['pay_amount'] = $data['total_amount'] - $data['offset_loan_amount'];
return $data; return $data;
}) })
->toArray(); ->toArray();

View File

@ -15,6 +15,8 @@
namespace app\adminapi\logic\project; namespace app\adminapi\logic\project;
use app\common\model\project\ProjectCostTempSet;
use app\common\model\project\ProjectTravelReimbursement;
use app\common\model\project\ProjectTravelReimbursementDetail; use app\common\model\project\ProjectTravelReimbursementDetail;
use app\common\logic\BaseLogic; use app\common\logic\BaseLogic;
use think\facade\Db; use think\facade\Db;
@ -43,14 +45,14 @@ class ProjectTravelReimbursementDetailLogic extends BaseLogic
ProjectTravelReimbursementDetail::create([ ProjectTravelReimbursementDetail::create([
'travel_reimbursement_id' => $params['travel_reimbursement_id'], 'travel_reimbursement_id' => $params['travel_reimbursement_id'],
'project_cost_temp_id' => $params['project_cost_temp_id'], 'project_cost_temp_id' => $params['project_cost_temp_id'],
'traffic_fee' => $params['traffic_fee'], 'traffic_fee' => $params['traffic_fee'] ?? 0,
'stay_fee' => $params['stay_fee'], 'stay_fee' => $params['stay_fee'] ?? 0,
'restaurant_fee' => $params['restaurant_fee'], 'restaurant_fee' => $params['restaurant_fee'] ?? 0,
'subsidy_fee' => $params['subsidy_fee'], 'subsidy_fee' => $params['subsidy_fee'] ?? 0,
'other_fee' => $params['other_fee'], 'other_fee' => $params['other_fee'] ?? 0,
'remark' => $params['remark'], 'total_amount' => $params['traffic_fee'] + $params['stay_fee'] + $params['restaurant_fee'] + $params['subsidy_fee'] + $params['other_fee'],
'remark' => $params['remark'] ?? '',
]); ]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -73,16 +75,17 @@ class ProjectTravelReimbursementDetailLogic extends BaseLogic
Db::startTrans(); Db::startTrans();
try { try {
ProjectTravelReimbursementDetail::where('id', $params['id'])->update([ ProjectTravelReimbursementDetail::where('id', $params['id'])->update([
'travel_reimbursement_id' => $params['travel_reimbursement_id'], 'travel_reimbursement_id' => $params['travel_reimbursement_id'],
'project_cost_temp_id' => $params['project_cost_temp_id'], 'project_cost_temp_id' => $params['project_cost_temp_id'],
'traffic_fee' => $params['traffic_fee'], 'traffic_fee' => $params['traffic_fee'] ?? 0,
'stay_fee' => $params['stay_fee'], 'stay_fee' => $params['stay_fee'] ?? 0,
'restaurant_fee' => $params['restaurant_fee'], 'restaurant_fee' => $params['restaurant_fee'] ?? 0,
'subsidy_fee' => $params['subsidy_fee'], 'subsidy_fee' => $params['subsidy_fee'] ?? 0,
'other_fee' => $params['other_fee'], 'other_fee' => $params['other_fee'] ?? 0,
'remark' => $params['remark'], 'total_amount' => $params['traffic_fee'] + $params['stay_fee'] + $params['restaurant_fee'] + $params['subsidy_fee'] + $params['other_fee'],
'remark' => $params['remark'] ?? '',
'update_time' => time(),
]); ]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -115,6 +118,13 @@ class ProjectTravelReimbursementDetailLogic extends BaseLogic
*/ */
public static function detail($params): array public static function detail($params): array
{ {
return ProjectTravelReimbursementDetail::findOrEmpty($params['id'])->toArray(); $data = ProjectTravelReimbursementDetail::field('id,travel_reimbursement_id,project_cost_temp_id,traffic_fee,stay_fee,restaurant_fee,subsidy_fee,other_fee,total_amount,remark')->findOrEmpty($params['id']);
$travel_reimbursement = ProjectTravelReimbursement::field('trip_reimbursement_code')->where('id',$data['travel_reimbursement_id'])->findOrEmpty();
$project_cost_temp = ProjectCostTempSet::field('first_level_subject,second_level_subject,third_level_subject')->where('id',$data['project_cost_temp_id'])->findOrEmpty();
$data['trip_reimbursement_code'] = $travel_reimbursement['trip_reimbursement_code'];
$data['first_level_subject'] = $project_cost_temp['first_level_subject'];
$data['second_level_subject'] = $project_cost_temp['second_level_subject'];
$data['third_level_subject'] = $project_cost_temp['third_level_subject'];
return $data->toArray();
} }
} }

View File

@ -15,6 +15,8 @@
namespace app\adminapi\logic\project; namespace app\adminapi\logic\project;
use app\common\model\dict\DictData;
use app\common\model\project\ProjectTravelReimbursement;
use app\common\model\project\ProjectTravelReimbursementInvoiceDetail; use app\common\model\project\ProjectTravelReimbursementInvoiceDetail;
use app\common\logic\BaseLogic; use app\common\logic\BaseLogic;
use think\facade\Db; use think\facade\Db;
@ -38,6 +40,8 @@ class ProjectTravelReimbursementInvoiceDetailLogic extends BaseLogic
*/ */
public static function add(array $params): bool public static function add(array $params): bool
{ {
//获取税率
$tax_rate = DictData::where('type_value','tax_rate')->column('name','value');
Db::startTrans(); Db::startTrans();
try { try {
ProjectTravelReimbursementInvoiceDetail::create([ ProjectTravelReimbursementInvoiceDetail::create([
@ -47,11 +51,10 @@ class ProjectTravelReimbursementInvoiceDetailLogic extends BaseLogic
'tax_rate' => $params['tax_rate'], 'tax_rate' => $params['tax_rate'],
'invoice_form' => $params['invoice_form'], 'invoice_form' => $params['invoice_form'],
'invoice_amount' => $params['invoice_amount'], 'invoice_amount' => $params['invoice_amount'],
'tax_amount' => $params['tax_amount'], 'tax_amount' => $tax_rate[$params['tax_rate']] / 100 * $params['invoice_amount'],
'annex' => $params['annex'], 'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'remark' => $params['remark'], 'remark' => $params['remark'] ?? '',
]); ]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -71,20 +74,22 @@ class ProjectTravelReimbursementInvoiceDetailLogic extends BaseLogic
*/ */
public static function edit(array $params): bool public static function edit(array $params): bool
{ {
//获取税率
$tax_rate = DictData::where('type_value','tax_rate')->column('name','value');
Db::startTrans(); Db::startTrans();
try { try {
ProjectTravelReimbursementInvoiceDetail::where('id', $params['id'])->update([ ProjectTravelReimbursementInvoiceDetail::where('id', $params['id'])->update([
'travel_reimbursement_id' => $params['travel_reimbursement_id'], 'travel_reimbursement_id' => $params['travel_reimbursement_id'],
'invoice_type' => $params['invoice_type'], 'invoice_type' => $params['invoice_type'],
'invoice_sn' => $params['invoice_sn'], 'invoice_sn' => $params['invoice_sn'],
'tax_rate' => $params['tax_rate'], 'tax_rate' => $params['tax_rate'],
'invoice_form' => $params['invoice_form'], 'invoice_form' => $params['invoice_form'],
'invoice_amount' => $params['invoice_amount'], 'invoice_amount' => $params['invoice_amount'],
'tax_amount' => $params['tax_amount'], 'tax_amount' => $tax_rate[$params['tax_rate']] / 100 * $params['invoice_amount'],
'annex' => $params['annex'], 'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'remark' => $params['remark'], 'remark' => $params['remark'] ?? '',
'update_time' => time(),
]); ]);
Db::commit(); Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
@ -117,6 +122,12 @@ class ProjectTravelReimbursementInvoiceDetailLogic extends BaseLogic
*/ */
public static function detail($params): array public static function detail($params): array
{ {
return ProjectTravelReimbursementInvoiceDetail::findOrEmpty($params['id'])->toArray(); $data = ProjectTravelReimbursementInvoiceDetail::field('id,travel_reimbursement_id,invoice_type,invoice_sn,tax_rate,invoice_form,invoice_amount,tax_amount,annex,remark')->findOrEmpty($params['id']);
$travel_reimbursement = ProjectTravelReimbursement::field('trip_reimbursement_code')->where('id',$data['travel_reimbursement_id'])->findOrEmpty();
$data['trip_reimbursement_code'] = $travel_reimbursement['trip_reimbursement_code'];
$data['invoice_type_text'] = $data->invoice_type_text;
$data['tax_rate_text'] = $data->tax_rate_text;
$data['invoice_form_text'] = $data->invoice_form_text;
return $data->toArray();
} }
} }

View File

@ -48,11 +48,6 @@ class ProjectTravelReimbursementLogic extends BaseLogic
public static function add(array $params): bool public static function add(array $params): bool
{ {
$trip_apply = ProjectTripApply::field('project_id')->where('id',$params['trip_apply_id'])->findOrEmpty(); $trip_apply = ProjectTripApply::field('project_id')->where('id',$params['trip_apply_id'])->findOrEmpty();
//初始报销金额 = 所有报销明细中的交通、住宿、餐饮、补助、其他金额之和
$reimbursement_amount = 0;
foreach($params['reimbursement_detail'] as $v){
$reimbursement_amount += ($v['traffic_fee'] + $v['stay_fee'] + $v['restaurant_fee'] + $v['subsidy_fee'] + $v['other_fee']);
}
//获取税率 //获取税率
$tax_rate = DictData::where('type_value','tax_rate')->column('name','value'); $tax_rate = DictData::where('type_value','tax_rate')->column('name','value');
Db::startTrans(); Db::startTrans();
@ -63,8 +58,6 @@ class ProjectTravelReimbursementLogic extends BaseLogic
'project_id' => $trip_apply['project_id'], 'project_id' => $trip_apply['project_id'],
'reimbursement_type' => $params['reimbursement_type'], 'reimbursement_type' => $params['reimbursement_type'],
'loan_apply_id' => $params['loan_apply_id'] ?? 0, 'loan_apply_id' => $params['loan_apply_id'] ?? 0,
'reimbursement_amount' => $reimbursement_amount,//初始报销金额
'actual_reimbursement_amount' => $reimbursement_amount - $params['offset_loan_amount'],//实际报销金额
'offset_loan_amount' => $params['offset_loan_amount'] ?? 0,//冲抵借款金额 'offset_loan_amount' => $params['offset_loan_amount'] ?? 0,//冲抵借款金额
'apply_user' => $params['apply_user'], 'apply_user' => $params['apply_user'],
'apply_date' => strtotime($params['apply_date']), 'apply_date' => strtotime($params['apply_date']),
@ -121,11 +114,6 @@ class ProjectTravelReimbursementLogic extends BaseLogic
public static function edit(array $params): bool public static function edit(array $params): bool
{ {
$trip_apply = ProjectTripApply::field('project_id')->where('id',$params['trip_apply_id'])->findOrEmpty(); $trip_apply = ProjectTripApply::field('project_id')->where('id',$params['trip_apply_id'])->findOrEmpty();
//初始报销金额 = 所有报销明细中的交通、住宿、餐饮、补助、其他金额之和
$reimbursement_amount = 0;
foreach($params['reimbursement_detail'] as $v){
$reimbursement_amount += ($v['traffic_fee'] + $v['stay_fee'] + $v['restaurant_fee'] + $v['subsidy_fee'] + $v['other_fee']);
}
//获取税率 //获取税率
$tax_rate = DictData::where('type_value','tax_rate')->column('name','value'); $tax_rate = DictData::where('type_value','tax_rate')->column('name','value');
Db::startTrans(); Db::startTrans();
@ -135,8 +123,6 @@ class ProjectTravelReimbursementLogic extends BaseLogic
'project_id' => $trip_apply['project_id'], 'project_id' => $trip_apply['project_id'],
'reimbursement_type' => $params['reimbursement_type'], 'reimbursement_type' => $params['reimbursement_type'],
'loan_apply_id' => $params['loan_apply_id'] ?? 0, 'loan_apply_id' => $params['loan_apply_id'] ?? 0,
'reimbursement_amount' => $reimbursement_amount,//初始报销金额
'actual_reimbursement_amount' => $reimbursement_amount - $params['offset_loan_amount'],//实际报销金额
'offset_loan_amount' => $params['offset_loan_amount'] ?? 0,//冲抵借款金额 'offset_loan_amount' => $params['offset_loan_amount'] ?? 0,//冲抵借款金额
'apply_user' => $params['apply_user'], 'apply_user' => $params['apply_user'],
'apply_date' => strtotime($params['apply_date']), 'apply_date' => strtotime($params['apply_date']),
@ -236,7 +222,7 @@ class ProjectTravelReimbursementLogic extends BaseLogic
*/ */
public static function detail($params): array public static function detail($params): array
{ {
$field = 'id,trip_apply_id,project_id,trip_reimbursement_code,reimbursement_type,loan_apply_id,reimbursement_amount,actual_reimbursement_amount,offset_loan_amount,apply_user,apply_date,payee_name,payee_bank,payee_account,remark,annex,bank_account_id'; $field = 'id,trip_apply_id,project_id,trip_reimbursement_code,reimbursement_type,loan_apply_id,offset_loan_amount,apply_user,apply_date,payee_name,payee_bank,payee_account,remark,annex,bank_account_id';
$data = ProjectTravelReimbursement::field($field) $data = ProjectTravelReimbursement::field($field)
->findOrEmpty($params['id']); ->findOrEmpty($params['id']);
$trip_apply = ProjectTripApply::field('trip_apply_code')->where('id',$data['trip_apply_id'])->findOrEmpty(); $trip_apply = ProjectTripApply::field('trip_apply_code')->where('id',$data['trip_apply_id'])->findOrEmpty();
@ -255,6 +241,8 @@ class ProjectTravelReimbursementLogic extends BaseLogic
$data['loan_apply_code'] = !$loan_apply->isEmpty() ? $loan_apply['loan_apply_code'] : '---'; $data['loan_apply_code'] = !$loan_apply->isEmpty() ? $loan_apply['loan_apply_code'] : '---';
$data['loan_amount'] = !$loan_apply->isEmpty() ? $loan_apply['loan_amount'] : '---'; $data['loan_amount'] = !$loan_apply->isEmpty() ? $loan_apply['loan_amount'] : '---';
$data['reimbursement_type_text'] = $data->reimbursement_type_text; $data['reimbursement_type_text'] = $data->reimbursement_type_text;
$data['total_amount'] = ProjectTravelReimbursementDetail::where('travel_reimbursement_id',$data['id'])->sum('total_amount');
$data['pay_amount'] = $data['total_amount'] - $data['offset_loan_amount'];
$data['bank_account'] = BankAccount::field('account_sn,deposit_bank,account_name,account')->where('id',$data['bank_account_id'])->findOrEmpty(); $data['bank_account'] = BankAccount::field('account_sn,deposit_bank,account_name,account')->where('id',$data['bank_account_id'])->findOrEmpty();
return $data->toArray(); return $data->toArray();
} }

View File

@ -1,108 +1,126 @@
<?php <?php
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版 // | likeadmin快速开发前后端分离管理后台PHP版
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力 // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo // | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin // | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin // | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn // | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权 // | likeadmin团队 版权所有 拥有最终解释权
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | author: likeadminTeam // | author: likeadminTeam
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\adminapi\validate\project; namespace app\adminapi\validate\project;
use app\common\validate\BaseValidate; use app\common\model\project\ProjectCostTempSet;
use app\common\model\project\ProjectTravelReimbursement;
use app\common\validate\BaseValidate;
/**
* 报销明细验证器
* Class ProjectTravelReimbursementDetailValidate /**
* @package app\adminapi\validate\project * 报销明细验证器
*/ * Class ProjectTravelReimbursementDetailValidate
class ProjectTravelReimbursementDetailValidate extends BaseValidate * @package app\adminapi\validate\project
{ */
class ProjectTravelReimbursementDetailValidate extends BaseValidate
/** {
* 设置校验规则
* @var string[] /**
*/ * 设置校验规则
protected $rule = [ * @var string[]
'id' => 'require', */
'travel_reimbursement_id' => 'require', protected $rule = [
'project_cost_temp_id' => 'require', 'id' => 'require',
'traffic_fee' => 'require', 'travel_reimbursement_id' => 'require|checkTravelReimbursement',
'stay_fee' => 'require', 'project_cost_temp_id' => 'require|checkProjectCostTemp',
'restaurant_fee' => 'require', 'traffic_fee' => 'require|float|egt:0',
'subsidy_fee' => 'require', 'stay_fee' => 'require|float|egt:0',
'other_fee' => 'require', 'restaurant_fee' => 'require|float|egt:0',
]; 'subsidy_fee' => 'require|float|egt:0',
'other_fee' => 'require|float|egt:0',
];
/**
* 参数描述
* @var string[] /**
*/ * 参数描述
protected $field = [ * @var string[]
'id' => 'id', */
'travel_reimbursement_id' => '差旅报销单id', protected $field = [
'project_cost_temp_id' => '项目费用模板id', 'id' => 'id',
'traffic_fee' => '交通', 'travel_reimbursement_id' => '差旅报销单id',
'stay_fee' => '住宿', 'project_cost_temp_id' => '项目费用模板id',
'restaurant_fee' => '餐饮', 'traffic_fee' => '交通费用',
'subsidy_fee' => '补助', 'stay_fee' => '住宿费用',
'other_fee' => '其它', 'restaurant_fee' => '餐饮费用',
]; 'subsidy_fee' => '补助费用',
'other_fee' => '其它费用',
];
/**
* @notes 添加场景
* @return ProjectTravelReimbursementDetailValidate /**
* @author likeadmin * @notes 添加场景
* @date 2024/01/18 13:57 * @return ProjectTravelReimbursementDetailValidate
*/ * @author likeadmin
public function sceneAdd() * @date 2024/01/18 13:57
{ */
return $this->only(['travel_reimbursement_id','project_cost_temp_id','traffic_fee','stay_fee','restaurant_fee','subsidy_fee','other_fee']); public function sceneAdd()
} {
return $this->remove('id',true);
}
/**
* @notes 编辑场景
* @return ProjectTravelReimbursementDetailValidate /**
* @author likeadmin * @notes 编辑场景
* @date 2024/01/18 13:57 * @return ProjectTravelReimbursementDetailValidate
*/ * @author likeadmin
public function sceneEdit() * @date 2024/01/18 13:57
{ */
return $this->only(['id','travel_reimbursement_id','project_cost_temp_id','traffic_fee','stay_fee','restaurant_fee','subsidy_fee','other_fee']); public function sceneEdit()
} {}
/** /**
* @notes 删除场景 * @notes 删除场景
* @return ProjectTravelReimbursementDetailValidate * @return ProjectTravelReimbursementDetailValidate
* @author likeadmin * @author likeadmin
* @date 2024/01/18 13:57 * @date 2024/01/18 13:57
*/ */
public function sceneDelete() public function sceneDelete()
{ {
return $this->only(['id']); return $this->only(['id']);
} }
/** /**
* @notes 详情场景 * @notes 详情场景
* @return ProjectTravelReimbursementDetailValidate * @return ProjectTravelReimbursementDetailValidate
* @author likeadmin * @author likeadmin
* @date 2024/01/18 13:57 * @date 2024/01/18 13:57
*/ */
public function sceneDetail() public function sceneDetail()
{ {
return $this->only(['id']); return $this->only(['id']);
} }
public function checkTravelReimbursement($value): bool|string
{
$data = ProjectTravelReimbursement::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '差旅报销申请信息不存在';
}
return true;
}
public function checkProjectCostTemp($value): bool|string
{
$data = ProjectCostTempSet::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '项目费用模板信息不存在';
}
return true;
}
} }

View File

@ -1,108 +1,152 @@
<?php <?php
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版 // | likeadmin快速开发前后端分离管理后台PHP版
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力 // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo // | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin // | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin // | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn // | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权 // | likeadmin团队 版权所有 拥有最终解释权
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | author: likeadminTeam // | author: likeadminTeam
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\adminapi\validate\project; namespace app\adminapi\validate\project;
use app\common\validate\BaseValidate; use app\common\model\dict\DictData;
use app\common\model\project\ProjectTravelReimbursement;
use app\common\validate\BaseValidate;
/**
* 发票明细验证器
* Class ProjectTravelReimbursementInvoiceDetailValidate /**
* @package app\adminapi\validate\project * 发票明细验证器
*/ * Class ProjectTravelReimbursementInvoiceDetailValidate
class ProjectTravelReimbursementInvoiceDetailValidate extends BaseValidate * @package app\adminapi\validate\project
{ */
class ProjectTravelReimbursementInvoiceDetailValidate extends BaseValidate
/** {
* 设置校验规则
* @var string[] /**
*/ * 设置校验规则
protected $rule = [ * @var string[]
'id' => 'require', */
'travel_reimbursement_id' => 'require', protected $rule = [
'invoice_type' => 'require', 'id' => 'require',
'invoice_sn' => 'require', 'travel_reimbursement_id' => 'require|checkTravelReimbursement',
'tax_rate' => 'require', 'invoice_type' => 'require|checkInvoiceType',
'invoice_form' => 'require', 'invoice_sn' => 'require',
'invoice_amount' => 'require', 'tax_rate' => 'require|checkTaxRate',
'tax_amount' => 'require', 'invoice_form' => 'require|checkInvoiceForm',
]; 'invoice_amount' => 'require|float|gt:0',
'annex' => 'checkAnnex',
];
/**
* 参数描述
* @var string[] /**
*/ * 参数描述
protected $field = [ * @var string[]
'id' => 'id', */
'travel_reimbursement_id' => '差旅报销id', protected $field = [
'invoice_type' => '发票类型', 'id' => 'id',
'invoice_sn' => '发票号', 'travel_reimbursement_id' => '差旅报销id',
'tax_rate' => '发票税率', 'invoice_type' => '发票类型',
'invoice_form' => '发票形式', 'invoice_sn' => '发票号',
'invoice_amount' => '发票金额', 'tax_rate' => '发票税率',
'tax_amount' => '发票税额', 'invoice_form' => '发票形式',
]; 'invoice_amount' => '发票金额',
];
/**
* @notes 添加场景 /**
* @return ProjectTravelReimbursementInvoiceDetailValidate * @notes 添加场景
* @author likeadmin * @return ProjectTravelReimbursementInvoiceDetailValidate
* @date 2024/01/18 13:57 * @author likeadmin
*/ * @date 2024/01/18 13:57
public function sceneAdd() */
{ public function sceneAdd()
return $this->only(['travel_reimbursement_id','invoice_type','invoice_sn','tax_rate','invoice_form','invoice_amount','tax_amount']); {
} return $this->remove('id',true);
}
/**
* @notes 编辑场景 /**
* @return ProjectTravelReimbursementInvoiceDetailValidate * @notes 编辑场景
* @author likeadmin * @return ProjectTravelReimbursementInvoiceDetailValidate
* @date 2024/01/18 13:57 * @author likeadmin
*/ * @date 2024/01/18 13:57
public function sceneEdit() */
{ public function sceneEdit()
return $this->only(['id','travel_reimbursement_id','invoice_type','invoice_sn','tax_rate','invoice_form','invoice_amount','tax_amount']); {}
}
/**
/** * @notes 删除场景
* @notes 删除场景 * @return ProjectTravelReimbursementInvoiceDetailValidate
* @return ProjectTravelReimbursementInvoiceDetailValidate * @author likeadmin
* @author likeadmin * @date 2024/01/18 13:57
* @date 2024/01/18 13:57 */
*/ public function sceneDelete()
public function sceneDelete() {
{ return $this->only(['id']);
return $this->only(['id']); }
}
/**
/** * @notes 详情场景
* @notes 详情场景 * @return ProjectTravelReimbursementInvoiceDetailValidate
* @return ProjectTravelReimbursementInvoiceDetailValidate * @author likeadmin
* @author likeadmin * @date 2024/01/18 13:57
* @date 2024/01/18 13:57 */
*/ public function sceneDetail()
public function sceneDetail() {
{ return $this->only(['id']);
return $this->only(['id']); }
}
public function checkTravelReimbursement($value): bool|string
{
$data = ProjectTravelReimbursement::where('id',$value)->findOrEmpty();
if($data->isEmpty()){
return '差旅报销申请信息不存在';
}
return true;
}
public function checkInvoiceType($value): bool|string
{
$dict = DictData::where('type_value','invoice_type')->column('value');
if(!in_array($value,$dict)){
return '发票类型数据值无效';
}
return true;
}
public function checkTaxRate($value): bool|string
{
$dict = DictData::where('type_value','tax_rate')->column('value');
if(!in_array($value,$dict)){
return '发票税率数据值无效';
}
return true;
}
public function checkInvoiceForm($value){
$dict = DictData::where('type_value','invoice_form')->column('value');
if(!in_array($value,$dict)){
return '发票形式数据值无效';
}
return true;
}
public function checkAnnex($value): bool|string
{
if(!empty($value) && $value != ''){
if(!is_array($value)){
return '附件格式错误';
}
}
return true;
}
} }

View File

@ -16,6 +16,7 @@ namespace app\common\model\project;
use app\common\model\BaseModel; use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete; use think\model\concern\SoftDelete;
@ -30,5 +31,22 @@ class ProjectTravelReimbursementInvoiceDetail extends BaseModel
protected $name = 'project_travel_reimbursement_invoice_detail'; protected $name = 'project_travel_reimbursement_invoice_detail';
protected $deleteTime = 'delete_time'; protected $deleteTime = 'delete_time';
public function getAnnexAttr($value){
return !empty($value) ? json_decode($value,true) : '';
}
public function getInvoiceTypeTextAttr($value,$data){
$dict = DictData::where('type_value','invoice_type')->column('name','value');
return !empty($data['invoice_type']) ? $dict[$data['invoice_type']] : '';
}
public function getTaxRateTextAttr($value,$data){
$dict = DictData::where('type_value','tax_rate')->column('name','value');
return !empty($data['tax_rate']) ? $dict[$data['tax_rate']] : '';
}
public function getInvoiceFormTextAttr($value,$data){
$dict = DictData::where('type_value','invoice_form')->column('name','value');
return !empty($data['invoice_form']) ? $dict[$data['invoice_form']] : '';
}
} }