113 lines
4.7 KiB
PHP
113 lines
4.7 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\bid;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
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
|
||
{
|
||
|
||
|
||
/**
|
||
* @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();
|
||
}
|
||
|
||
} |