['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' => '备注', ]; } }