115 lines
5.5 KiB
PHP
115 lines
5.5 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\contract;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\model\contract\ProcurementContract;
|
||
use app\common\model\contract\ProcurementContractDetail;
|
||
use app\common\lists\ListsSearchInterface;
|
||
use app\common\model\material\Material;
|
||
use app\common\model\material\MaterialClassify;
|
||
use app\common\model\material\MaterialPurchaseRequest;
|
||
use app\common\model\material\MaterialPurchaseRequestDetail;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\project\ProjectMaterialBudgetDetail;
|
||
use app\common\model\supplier\Supplier;
|
||
|
||
|
||
/**
|
||
* 采购明细列表
|
||
* Class ProcurementContractDetailLists
|
||
* @package app\adminapi\listscontract
|
||
*/
|
||
class ProcurementContractDetailLists extends BaseAdminDataLists implements ListsSearchInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2023/12/04 22:30
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['contract_id'],
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取采购明细列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2023/12/04 22:30
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
return ProcurementContractDetail::where($this->searchWhere)
|
||
->field('id,material_purchase_request_detail_id,contract_id,num,price,tax_rate,amount_excluding_tax,amount_including_tax')
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function($data){
|
||
$contract = ProcurementContract::field('contract_no,project_id,supplier_id,contract_type')->where('id',$data['contract_id'])->findOrEmpty();
|
||
$project = Project::field('name,project_code')->where('id',$contract['project_id'])->findOrEmpty();
|
||
$supplier = Supplier::field('supplier_code,supplier_name')->where('id',$contract['supplier_id'])->findOrEmpty();
|
||
$material_purchase_request_detail = MaterialPurchaseRequestDetail::field('material_purchase_request_id,project_material_budget_detail_id')->where('id',$data['material_purchase_request_detail_id'])->findOrEmpty();
|
||
$material_purchase_request = MaterialPurchaseRequest::field('material_purchase_request_code')->where('id',$material_purchase_request_detail['material_purchase_request_id'])->findOrEmpty();
|
||
$project_material_budget_detail = ProjectMaterialBudgetDetail::field('material_id')->where('id',$material_purchase_request_detail['project_material_budget_detail_id'])->findOrEmpty();
|
||
$material = Material::field('first_level,second_level,three_level,name,code,specs,brand,parameter_description,unit')->where('id',$project_material_budget_detail['material_id'])->findOrEmpty();
|
||
$material_classify = MaterialClassify::where('id','in',[$material['first_level'],$material['second_level'],$material['three_level']])->column('name','id');
|
||
$data['project_code'] = $project['project_code'];
|
||
$data['project_name'] = $project['name'];
|
||
$data['supplier_code'] = $supplier['supplier_code'];
|
||
$data['supplier_name'] = $supplier['supplier_name'];
|
||
$data['contract_no'] = $contract['contract_no'];
|
||
$data['contract_type'] = $contract->contract_type_text;
|
||
$data['material_purchase_request_code'] = $material_purchase_request['material_purchase_request_code'];
|
||
$data['material_first_level'] = !empty($material_classify[$material['first_level']]) ? $material_classify[$material['first_level']] : '';
|
||
$data['material_second_level'] = !empty($material_classify[$material['second_level']]) ? $material_classify[$material['second_level']] : '';
|
||
$data['material_three_level'] = !empty($material_classify[$material['three_level']]) ? $material_classify[$material['three_level']] : '';
|
||
$data['material_name'] = $material['name'];
|
||
$data['material_code'] = $material['code'];
|
||
$data['material_specs'] = $material['specs'];
|
||
$data['material_brand'] = $material['brand'];
|
||
$data['material_parameter_description'] = $material['parameter_description'];
|
||
$data['material_unit'] = $material['unit'];
|
||
//已入库数量
|
||
$data['has_storage_num'] = 0;
|
||
//未入库数量
|
||
$data['not_storage_num'] = $data['num'] - $data['has_storage_num'];
|
||
return $data;
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取采购明细数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2023/12/04 22:30
|
||
*/
|
||
public function count(): int
|
||
{
|
||
return ProcurementContractDetail::where($this->searchWhere)->count();
|
||
}
|
||
|
||
} |