engineering/app/adminapi/lists/bid/BidDocumentExaminationDetailLists.php
2024-01-30 14:03:55 +08:00

145 lines
5.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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\bid;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsExcelInterface;
use app\common\model\bid\BidDocumentExamination;
use app\common\model\bid\BidDocumentExaminationDetail;
use app\common\lists\ListsSearchInterface;
use app\common\model\custom\Custom;
use app\common\model\material\Material;
use app\common\model\project\Project;
/**
* 标书审查-报价明细列表
* Class BidDocumentExaminationDetailLists
* @package app\adminapi\listsbid
*/
class BidDocumentExaminationDetailLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/12/02 09:59
*/
public function setSearch(): array
{
return [
'=' => ['bid_document_examination_id'],
];
}
/**
* @notes 获取标书审查-报价明细列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/12/02 09:59
*/
public function lists(): array
{
$params = $this->request->get(['bid_document_examination_code','product_name']);
$where = [];
if(isset($params['bid_document_examination_code']) && $params['bid_document_examination_code'] != ''){
$bid_document_examination_ids = BidDocumentExamination::where('code','like','%'.$params['bid_document_examination_code'].'%')->column('id');
$where[] = ['bid_document_examination_id','in',$bid_document_examination_ids];
}
if(isset($params['product_name']) && $params['product_name'] != ''){
$product_ids = Material::where('name','like','%'.$params['product_name'].'%')->column('id');
$where[] = ['product_id','in',$product_ids];
}
return BidDocumentExaminationDetail::where($this->searchWhere)->where($where)
->field('id,bid_document_examination_id,product_id,num,points,cost_price,cost_amount,sale_price,sale_amount')
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function($item){
$bid_document_examination = BidDocumentExamination::field('project_id,code')->where('id',$item['bid_document_examination_id'])->findOrEmpty();
$project = Project::field('name,project_code,custom_id')->where('id',$bid_document_examination['project_id'])->findOrEmpty();
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
$product = Material::field('name,specs,unit')->where('id',$item['product_id'])->findOrEmpty();
$item['bid_document_examination_code'] = $bid_document_examination['code'];
$item['project_name'] = $project['name'];
$item['project_code'] = $project['project_code'];
$item['custom_name'] = $custom['name'];
$item['product_name'] = $product['name'];
$item['product_specs'] = $product['specs'];
$item['product_unit'] = $product['unit'];
})
->toArray();
}
/**
* @notes 获取标书审查-报价明细数量
* @return int
* @author likeadmin
* @date 2023/12/02 09:59
*/
public function count(): int
{
$params = $this->request->get(['bid_document_examination_code','product_name']);
$where = [];
if(isset($params['bid_document_examination_code']) && $params['bid_document_examination_code'] != ''){
$bid_document_examination_ids = BidDocumentExamination::where('code','like','%'.$params['bid_document_examination_code'].'%')->column('id');
$where[] = ['bid_document_examination_id','in',$bid_document_examination_ids];
}
if(isset($params['product_name']) && $params['product_name'] != ''){
$product_ids = Material::where('name','like','%'.$params['product_name'].'%')->column('id');
$where[] = ['product_id','in',$product_ids];
}
return BidDocumentExaminationDetail::where($this->searchWhere)->where($where)->count();
}
public function setFileName(): string
{
return '报价明细列表';
}
/**
* @notes 导出字段
* @return string[]
* @author 段誉
* @date 2022/11/24 16:17
*/
public function setExcelFields(): array
{
return [
'id' => 'id',
'bid_document_examination_code' => '标书审查编号',
'custom_name' => '客户名称',
'project_name' => '项目名称',
'project_code' => '项目编码',
'product_name' => '产品名称',
'product_specs' => '型号规格',
'product_unit' => '单位',
'num' => '数量',
'cost_price' => '成本单价',
'cost_amount' => '金额',
'points' => '点数',
'sale_price' => '报价单价',
'sale_amount' => '报价金额',
];
}
}