130 lines
4.3 KiB
PHP
130 lines
4.3 KiB
PHP
<?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;
|
||
|
||
|
||
use app\common\lists\ListsExcelInterface;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\cost_project\CostProject;
|
||
use app\common\model\marketing\MarketingContract;
|
||
use app\common\model\ProjectCommission;
|
||
use app\common\model\ProjectCommissionDetail;
|
||
use app\common\model\zjzx_finance\ZjzxRefund;
|
||
|
||
|
||
/**
|
||
* ProjectCommission列表
|
||
* Class ProjectCommissionLists
|
||
* @package app\adminapi\lists
|
||
*/
|
||
class ProjectCommissionLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2024/02/23 09:37
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['project_id'],
|
||
'%like%' => ['num']
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2024/02/23 09:37
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
return ProjectCommission::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function ($data) {
|
||
$project = CostProject::field('project_name,project_num,contract_id,industry,principal')->where('id', $data['project_id'])->findOrEmpty();
|
||
$contract = MarketingContract::field('contract_name')->where('id', $project['contract_id'])->findOrEmpty();
|
||
$admin = Admin::field('name')->where('id', $project['principal'])->findOrEmpty();
|
||
$djr = Admin::field('name')->where('id', $data['djr'])->findOrEmpty();
|
||
$data['djr_name'] = $djr?->name;
|
||
$data['project_name'] = $project['project_name'];
|
||
$data['project_num'] = $project['project_num'];
|
||
$data['contract_name'] = $contract['contract_name'];
|
||
$data['industry_nature'] = $project->industry_text;
|
||
$data['principal_name'] = $admin?->name;
|
||
//到账金额
|
||
$data['total_refund_amount'] = ZjzxRefund::where('project_id', $data['project_id'])->sum('amount');
|
||
//已支付总额
|
||
$data['total_pay_amount'] = ProjectCommission::where('project_id', $data['project_id'])->sum('bczfze');
|
||
//应提成总金额
|
||
$data['total_commission_amount'] = $data['total_refund_amount'] * ($data['rate'] / 100);
|
||
$data['children'] = ProjectCommissionDetail::field('id,engineer,task_name,task_type,professional_type,zj_amount,sk_amount,tc_rate,tc_amount,pay_amount,other_fee')->where('project_commission_id', $data['id'])->select()->toArray();
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2024/02/23 09:37
|
||
*/
|
||
public function count(): int
|
||
{
|
||
return ProjectCommission::where($this->searchWhere)->count();
|
||
}
|
||
|
||
public function setFileName(): string
|
||
{
|
||
return '项目提成';
|
||
}
|
||
|
||
/**
|
||
* @notes 导出字段
|
||
* @return string[]
|
||
* @author 段誉
|
||
* @date 2022/11/24 16:17
|
||
*/
|
||
public function setExcelFields(): array
|
||
{
|
||
return [
|
||
'id' => 'id',
|
||
'num' => '单据编号',
|
||
'project_id' => '项目id',
|
||
'affcontract' => '关联合同',
|
||
'industry' => '行业',
|
||
'hk' => '项目回款总额',
|
||
'rate' => '提成比例(%)',
|
||
'ticheng' => '应提成总金额',
|
||
'paid_amount' => '已支付总额',
|
||
'bczfze' => '本次支付总额',
|
||
'djr' => '登记人',
|
||
'apptime' => '登记日期',
|
||
'remark' => '备注',
|
||
];
|
||
}
|
||
|
||
} |