137 lines
4.5 KiB
PHP
137 lines
4.5 KiB
PHP
<?php
|
|
|
|
namespace app\adminapi\controller\financial;
|
|
|
|
use app\adminapi\controller\BaseAdminController;
|
|
use app\adminapi\lists\financial\FinancialBudgetDocLists;
|
|
use app\adminapi\logic\financial\FinancialBudgetDocLogic;
|
|
use app\adminapi\validate\financial\FinancialBudgetDocValidate;
|
|
use app\common\model\financial\FinancialBudgetDoc;
|
|
use app\common\model\financial\FinancialDepartmentIncomeSettlement;
|
|
use app\common\model\financial\FinancialDepartmentIncomeSettlementDetail;
|
|
use app\common\model\marketing\MarketingContract;
|
|
|
|
|
|
/**
|
|
* 财务管理--项目预算书控制器
|
|
* Class FinancialBudgetDocController
|
|
* @package app\adminapi\controller\financial
|
|
*/
|
|
class FinancialBudgetDocController extends BaseAdminController
|
|
{
|
|
|
|
/**
|
|
* @notes 获取财务管理--项目预算书列表
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/03/26 13:54
|
|
*/
|
|
public function lists()
|
|
{
|
|
return $this->dataLists(new FinancialBudgetDocLists());
|
|
}
|
|
|
|
/**
|
|
* @notes 添加财务管理--项目预算书
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/03/26 13:54
|
|
*/
|
|
public function add()
|
|
{
|
|
$params = (new FinancialBudgetDocValidate())->post()->goCheck('add');
|
|
$result = FinancialBudgetDocLogic::add($params);
|
|
if (true === $result) {
|
|
return $this->success('添加成功', [], 1, 1);
|
|
}
|
|
return $this->fail(FinancialBudgetDocLogic::getError());
|
|
}
|
|
|
|
/**
|
|
* @notes 编辑财务管理--项目预算书
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/03/26 13:54
|
|
*/
|
|
public function edit()
|
|
{
|
|
$params = (new FinancialBudgetDocValidate())->post()->goCheck('edit');
|
|
$result = FinancialBudgetDocLogic::edit($params);
|
|
if (true === $result) {
|
|
return $this->success('编辑成功', [], 1, 1);
|
|
}
|
|
return $this->fail(FinancialBudgetDocLogic::getError());
|
|
}
|
|
|
|
/**
|
|
* @notes 删除财务管理--项目预算书
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/03/26 13:54
|
|
*/
|
|
public function delete()
|
|
{
|
|
$params = (new FinancialBudgetDocValidate())->post()->goCheck('delete');
|
|
$result = FinancialBudgetDocLogic::delete($params);
|
|
if (true === $result) {
|
|
return $this->success('删除成功', [], 1, 1);
|
|
}
|
|
return $this->fail(FinancialBudgetDocLogic::getError());
|
|
}
|
|
|
|
/**
|
|
* @notes 获取财务管理--项目预算书详情
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/03/26 13:54
|
|
*/
|
|
public function detail()
|
|
{
|
|
$params = (new FinancialBudgetDocValidate())->goCheck('detail');
|
|
$result = FinancialBudgetDocLogic::detail($params);
|
|
return $this->data($result);
|
|
}
|
|
|
|
public function datas()
|
|
{
|
|
return $this->data(FinancialBudgetDocLogic::datas());
|
|
}
|
|
|
|
//部门收入明细
|
|
public function income(): \think\response\Json
|
|
{
|
|
$params = $this->request->get();
|
|
$page_no = !empty($params['page_no']) ? $params['page_no'] : 1;
|
|
$page_size = !empty($params['page_size']) ? $params['page_size'] : 15;
|
|
$where = [];
|
|
if (!empty($params['code'])) {
|
|
$where[] = ['code', 'like', '%' . $params['code'] . '%'];
|
|
}
|
|
if (!empty($params['name'])) {
|
|
$where[] = ['name', 'like', '%' . $params['name'] . '%'];
|
|
}
|
|
if (!empty($params['contract_id'])) {
|
|
$where[] = ['contract_id', '=', $params['contract_id']];
|
|
}
|
|
$lists = FinancialBudgetDoc::field('id,contract_id,code,name')
|
|
->where($where)
|
|
->where($where)
|
|
->page($page_no, $page_size)
|
|
->order('id desc')
|
|
->select()->each(function ($data) {
|
|
$contract = MarketingContract::field('contract_name,signed_amount')->where('id', $data['contract_id'])->findOrEmpty();
|
|
$data['contract_name'] = $contract['contract_name'];
|
|
$data['money'] = $contract['signed_amount'];
|
|
$financial_department_income_settlement_ids = FinancialDepartmentIncomeSettlement::where('budget_doc_id', $data['id'])->column('id');
|
|
//分成金额合计
|
|
$data['amount'] = FinancialDepartmentIncomeSettlementDetail::where('department_income_settlement_id', 'in', $financial_department_income_settlement_ids)->sum('amount');
|
|
//结算金额合计
|
|
$data['settlement_amount'] = FinancialDepartmentIncomeSettlementDetail::where('department_income_settlement_id', 'in', $financial_department_income_settlement_ids)->sum('settlement_amount');
|
|
//未结算金额
|
|
$data['not_settlement_amount'] = bcsub($data['amount'], $data['settlement_amount'], 2);
|
|
})
|
|
->toArray();
|
|
$count = FinancialBudgetDoc::where($where)->count();
|
|
return $this->success('成功', compact('count', 'lists', 'page_no', 'page_size'));
|
|
}
|
|
} |