diff --git a/app/adminapi/lists/cost_project/CostProjectLists.php b/app/adminapi/lists/cost_project/CostProjectLists.php index 37d345e5b..aa24ed37e 100644 --- a/app/adminapi/lists/cost_project/CostProjectLists.php +++ b/app/adminapi/lists/cost_project/CostProjectLists.php @@ -75,13 +75,18 @@ ->order(['id' => 'desc']) ->select() ->each(function ($res) { - $contract = MarketingContract::field('contract_name')->where('id', $res['contract_id'])->findOrEmpty(); + $contract = MarketingContract::field('contract_name,part_a,part_b,signed_amount,create_time')->where('id', $res['contract_id'])->findOrEmpty(); $province = GeoProvince::field('province_name')->where('province_code', $res['province'])->findOrEmpty(); $city = GeoCity::field('city_name')->where('city_code', $res['city'])->findOrEmpty(); $dept = Dept::field('name')->where('id', $res['depar'])->findOrEmpty(); $admin = Admin::field('name')->where('id', $res['principal'])->findOrEmpty(); $custom = MarketingCustom::field('name')->where('id', $res['aunit'])->findOrEmpty(); + $part_a = MarketingCustom::field('name')->where('id', $contract['part_a'])->findOrEmpty(); $res['contract_name'] = $contract?->contract_name; + $res['part_a_name'] = $part_a?->name; + $res['part_b'] = $contract?->part_b; + $res['signed_amount'] = $contract?->signed_amount; + $res['signed_date'] = $contract?->create_time; $res['types_text'] = $res->types_text; $res['industry_text'] = $res->industry_text; $res['province_name'] = $province?->province_name; @@ -101,13 +106,18 @@ ->order(['id' => 'desc']) ->select() ->each(function ($res) { - $contract = MarketingContract::field('contract_name')->where('id', $res['contract_id'])->findOrEmpty(); + $contract = MarketingContract::field('contract_name,part_a,part_b,signed_amount,create_time')->where('id', $res['contract_id'])->findOrEmpty(); $province = GeoProvince::field('province_name')->where('province_code', $res['province'])->findOrEmpty(); $city = GeoCity::field('city_name')->where('city_code', $res['city'])->findOrEmpty(); $dept = Dept::field('name')->where('id', $res['depar'])->findOrEmpty(); $admin = Admin::field('name')->where('id', $res['principal'])->findOrEmpty(); $custom = MarketingCustom::field('name')->where('id', $res['aunit'])->findOrEmpty(); + $part_a = MarketingCustom::field('name')->where('id', $contract['part_a'])->findOrEmpty(); $res['contract_name'] = $contract?->contract_name; + $res['part_a_name'] = $part_a?->name; + $res['part_b'] = $contract?->part_b; + $res['signed_amount'] = $contract?->signed_amount; + $res['signed_date'] = $contract?->create_time; $res['types_text'] = $res->types_text; $res['industry_text'] = $res->industry_text; $res['province_name'] = $province?->province_name; diff --git a/app/adminapi/lists/quotation/QuotationDetailLists.php b/app/adminapi/lists/quotation/QuotationDetailLists.php index c497da596..52cd59ae3 100644 --- a/app/adminapi/lists/quotation/QuotationDetailLists.php +++ b/app/adminapi/lists/quotation/QuotationDetailLists.php @@ -11,128 +11,129 @@ // +---------------------------------------------------------------------- // | author: likeadminTeam // +---------------------------------------------------------------------- - -namespace app\adminapi\lists\quotation; - - -use app\adminapi\lists\BaseAdminDataLists; -use app\common\lists\ListsExcelInterface; -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,ListsExcelInterface -{ - - - /** - * @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'] = !empty($classify[$material['first_level']]) ? $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_text'] = $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(); - } - public function setFileName(): string - { - return '报价单明细列表'; - } + namespace app\adminapi\lists\quotation; + + + use app\adminapi\lists\BaseAdminDataLists; + use app\common\lists\ListsExcelInterface; + use app\common\lists\ListsSearchInterface; + 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; + /** - * @notes 导出字段 - * @return string[] - * @author 段誉 - * @date 2022/11/24 16:17 + * 报价明细列表 + * Class QuotationDetailLists + * @package app\adminapi\listsquotation */ - public function setExcelFields(): array + class QuotationDetailLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface { - return [ - 'id' => 'id', - 'quotation_code' => '报价单号', - 'custom_name' => '客户名称', - 'quotation_create_user' => '制单人', - 'quotation_date' => '报价日期', - 'product_first_level_name' => '产品类别', - 'product_second_level_name' => '产品中类', - 'product_three_level_name' => '产品小类', - 'product_name' => '产品名称', - 'product_code' => '产品编码', - 'product_specs' => '规格型号', - 'product_brand' => '品牌', - 'product_parameter_description' => '参数说明', - 'product_unit' => '单位', - 'num' => '数量', - 'tax_rate' => '税率', - 'tax_inclusive_price' => '含税单价', - 'tax_exclusive_amount' => '不含税金额', - 'tax_inclusive_amount' => '含税金额', - 'remark' => '备注', - ]; - } - -} \ No newline at end of file + + + /** + * @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,inventory')->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'] = !empty($classify[$material['first_level']]) ? $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['inventory'] = $material['inventory']; + $item['tax_rate_text'] = $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(); + } + + public function setFileName(): string + { + return '报价单明细列表'; + } + + /** + * @notes 导出字段 + * @return string[] + * @author 段誉 + * @date 2022/11/24 16:17 + */ + public function setExcelFields(): array + { + return [ + 'id' => 'id', + 'quotation_code' => '报价单号', + 'custom_name' => '客户名称', + 'quotation_create_user' => '制单人', + 'quotation_date' => '报价日期', + 'product_first_level_name' => '产品类别', + 'product_second_level_name' => '产品中类', + 'product_three_level_name' => '产品小类', + 'product_name' => '产品名称', + 'product_code' => '产品编码', + 'product_specs' => '规格型号', + 'product_brand' => '品牌', + 'product_parameter_description' => '参数说明', + 'product_unit' => '单位', + 'num' => '数量', + 'tax_rate' => '税率', + 'tax_inclusive_price' => '含税单价', + 'tax_exclusive_amount' => '不含税金额', + 'tax_inclusive_amount' => '含税金额', + 'remark' => '备注', + ]; + } + + } \ No newline at end of file