100 lines
4.0 KiB
PHP
100 lines
4.0 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\quotation;
|
||
|
||
|
||
use app\adminapi\lists\BaseAdminDataLists;
|
||
use app\common\model\custom\Custom;
|
||
use app\common\model\material\Material;
|
||
use app\common\model\material\MaterialClassify;
|
||
use app\common\model\quotation\Quotation;
|
||
use app\common\model\quotation\QuotationDetail;
|
||
use app\common\lists\ListsSearchInterface;
|
||
|
||
|
||
/**
|
||
* 报价明细列表
|
||
* Class QuotationDetailLists
|
||
* @package app\adminapi\listsquotation
|
||
*/
|
||
class QuotationDetailLists extends BaseAdminDataLists implements ListsSearchInterface
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 设置搜索条件
|
||
* @return \string[][]
|
||
* @author likeadmin
|
||
* @date 2023/11/27 17:59
|
||
*/
|
||
public function setSearch(): array
|
||
{
|
||
return [
|
||
'=' => ['quotation_id'],
|
||
];
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取报价明细列表
|
||
* @return array
|
||
* @throws \think\db\exception\DataNotFoundException
|
||
* @throws \think\db\exception\DbException
|
||
* @throws \think\db\exception\ModelNotFoundException
|
||
* @author likeadmin
|
||
* @date 2023/11/27 17:59
|
||
*/
|
||
public function lists(): array
|
||
{
|
||
return QuotationDetail::where($this->searchWhere)
|
||
->field(['id', 'quotation_id', 'product_id', 'num', 'tax_rate', 'tax_inclusive_price', 'tax_inclusive_amount', 'tax_exclusive_amount', 'remark', 'create_time'])
|
||
->limit($this->limitOffset, $this->limitLength)
|
||
->order(['id' => 'desc'])
|
||
->select()->each(function($item){
|
||
$quotation = Quotation::field('custom_id,code,quotation_date,create_user')->where('id',$item['quotation_id'])->findOrEmpty();
|
||
$custom = Custom::field('name')->where('id',$quotation['custom_id'])->findOrEmpty();
|
||
$material = Material::field('first_level,second_level,three_level,name,code,specs,brand,parameter_description,unit')->where('id',$item['product_id'])->findOrEmpty();
|
||
$classify = MaterialClassify::where('id','in',[$material['first_level'],$material['second_level'],$material['three_level']])->column('name','id');
|
||
$item['quotation_code'] = $quotation['code'];
|
||
$item['quotation_date'] = $quotation['quotation_date'];
|
||
$item['quotation_create_user'] = $quotation['create_user'];
|
||
$item['custom_name'] = $custom['name'];
|
||
$item['product_first_level_name'] = $classify[$material['first_level']];
|
||
$item['product_second_level_name'] = !empty($classify[$material['second_level']]) ? $classify[$material['second_level']] : '';
|
||
$item['product_three_level_name'] = !empty($classify[$material['three_level']]) ? $classify[$material['three_level']] : '';
|
||
$item['product_name'] = $material['name'];
|
||
$item['product_code'] = $material['code'];
|
||
$item['product_specs'] = $material['specs'];
|
||
$item['product_brand'] = $material['brand'];
|
||
$item['product_parameter_description'] = $material['parameter_description'];
|
||
$item['product_unit'] = $material['unit'];
|
||
$item['tax_rate'] = $item->tax_rate_text.'%';
|
||
})
|
||
->toArray();
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取报价明细数量
|
||
* @return int
|
||
* @author likeadmin
|
||
* @date 2023/11/27 17:59
|
||
*/
|
||
public function count(): int
|
||
{
|
||
return QuotationDetail::where($this->searchWhere)->count();
|
||
}
|
||
|
||
} |