['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(); } }