From 74d261bb28738ef037af07eb1066dad7811d840b Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Fri, 12 Apr 2024 14:48:11 +0800 Subject: [PATCH] update --- .../MarketingBidResultController.php | 111 +++++++++ .../MarketingBidResultDetailController.php | 108 +++++++++ .../marketing/MarketingBidEvaluationLists.php | 15 +- .../lists/marketing/MarketingBidInfoLists.php | 6 +- .../MarketingBidResultDetailLists.php | 77 +++++++ .../marketing/MarketingBidResultLists.php | 140 ++++++++++++ .../marketing/MarketingBidEvaluationLogic.php | 13 +- .../logic/marketing/MarketingBidInfoLogic.php | 6 +- .../MarketingBidResultDetailLogic.php | 122 ++++++++++ .../marketing/MarketingBidResultLogic.php | 216 ++++++++++++++++++ .../MarketingBidEvaluationValidate.php | 6 +- .../MarketingBidResultDetailValidate.php | 112 +++++++++ .../marketing/MarketingBidResultValidate.php | 152 ++++++++++++ .../model/marketing/MarketingBidResult.php | 44 ++++ .../marketing/MarketingBidResultDetail.php | 34 +++ .../MarketingBusinessOpportunity.php | 2 +- 16 files changed, 1141 insertions(+), 23 deletions(-) create mode 100644 app/adminapi/controller/marketing/MarketingBidResultController.php create mode 100644 app/adminapi/controller/marketing/MarketingBidResultDetailController.php create mode 100644 app/adminapi/lists/marketing/MarketingBidResultDetailLists.php create mode 100644 app/adminapi/lists/marketing/MarketingBidResultLists.php create mode 100644 app/adminapi/logic/marketing/MarketingBidResultDetailLogic.php create mode 100644 app/adminapi/logic/marketing/MarketingBidResultLogic.php create mode 100644 app/adminapi/validate/marketing/MarketingBidResultDetailValidate.php create mode 100644 app/adminapi/validate/marketing/MarketingBidResultValidate.php create mode 100644 app/common/model/marketing/MarketingBidResult.php create mode 100644 app/common/model/marketing/MarketingBidResultDetail.php diff --git a/app/adminapi/controller/marketing/MarketingBidResultController.php b/app/adminapi/controller/marketing/MarketingBidResultController.php new file mode 100644 index 000000000..c32bd4cb6 --- /dev/null +++ b/app/adminapi/controller/marketing/MarketingBidResultController.php @@ -0,0 +1,111 @@ +dataLists(new MarketingBidResultLists()); + } + + + /** + * @notes 添加市场经营--投标管理--投标结果 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function add() + { + $params = (new MarketingBidResultValidate())->post()->goCheck('add'); + $result = MarketingBidResultLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(MarketingBidResultLogic::getError()); + } + + + /** + * @notes 编辑市场经营--投标管理--投标结果 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function edit() + { + $params = (new MarketingBidResultValidate())->post()->goCheck('edit'); + $result = MarketingBidResultLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(MarketingBidResultLogic::getError()); + } + + + /** + * @notes 删除市场经营--投标管理--投标结果 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function delete() + { + $params = (new MarketingBidResultValidate())->post()->goCheck('delete'); + $result = MarketingBidResultLogic::delete($params); + if (true === $result) { + return $this->success('删除成功', [], 1, 1); + } + return $this->fail(MarketingBidResultLogic::getError()); + } + + + /** + * @notes 获取市场经营--投标管理--投标结果详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function detail() + { + $params = (new MarketingBidResultValidate())->goCheck('detail'); + $result = MarketingBidResultLogic::detail($params); + return $this->data($result); + } + + + } \ No newline at end of file diff --git a/app/adminapi/controller/marketing/MarketingBidResultDetailController.php b/app/adminapi/controller/marketing/MarketingBidResultDetailController.php new file mode 100644 index 000000000..02cf10ca4 --- /dev/null +++ b/app/adminapi/controller/marketing/MarketingBidResultDetailController.php @@ -0,0 +1,108 @@ +dataLists(new MarketingBidResultDetailLists()); + } + + + /** + * @notes 添加市场经营--投标管理--投标结果--参标单位 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function add() + { + $params = (new MarketingBidResultDetailValidate())->post()->goCheck('add'); + $result = MarketingBidResultDetailLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(MarketingBidResultDetailLogic::getError()); + } + + + /** + * @notes 编辑市场经营--投标管理--投标结果--参标单位 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function edit() + { + $params = (new MarketingBidResultDetailValidate())->post()->goCheck('edit'); + $result = MarketingBidResultDetailLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(MarketingBidResultDetailLogic::getError()); + } + + + /** + * @notes 删除市场经营--投标管理--投标结果--参标单位 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function delete() + { + $params = (new MarketingBidResultDetailValidate())->post()->goCheck('delete'); + MarketingBidResultDetailLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取市场经营--投标管理--投标结果--参标单位详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function detail() + { + $params = (new MarketingBidResultDetailValidate())->goCheck('detail'); + $result = MarketingBidResultDetailLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/marketing/MarketingBidEvaluationLists.php b/app/adminapi/lists/marketing/MarketingBidEvaluationLists.php index ec585e725..9addaa718 100644 --- a/app/adminapi/lists/marketing/MarketingBidEvaluationLists.php +++ b/app/adminapi/lists/marketing/MarketingBidEvaluationLists.php @@ -69,8 +69,12 @@ ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($data) { - $business_opportunity = MarketingBusinessOpportunity::withoutField('bid_date,contacts,annex,approve_id,create_time,update_time,delete_time')->where('id', $data['business_opportunity_id'])->findOrEmpty(); - $data['business_opportunity'] = $business_opportunity->toArray(); + $data['bid_type_text'] = $data->bid_type_text; + $data['bid_nature_text'] = $data->bid_nature_text; + $data['approve_check_status_text'] = $data->approve_check_status_text; + //业务机会 + $business_opportunity = MarketingBusinessOpportunity::withoutField('create_time,update_time,delete_time')->where('id', $data['business_opportunity_id'])->findOrEmpty(); + $data['business_opportunity'] = $business_opportunity; $construct_company = MarketingCustom::field('name')->where('id', $business_opportunity['construct_company'])->findOrEmpty(); $admin = Admin::where('id', 'in', [$business_opportunity['head'], $business_opportunity['leader']])->column('name', 'id'); $dept = Dept::field('name')->where('id', $business_opportunity['dept'])->findOrEmpty(); @@ -82,11 +86,8 @@ $data['business_opportunity']['const_area_text'] = $business_opportunity->const_area_text; $data['business_opportunity']['status_text'] = $business_opportunity->status_text; $data['business_opportunity']['dept_name'] = $dept?->name; - $data['business_opportunity']['head_name'] = $admin[$data['head']] ?? ''; - $data['business_opportunity']['leader_name'] = $admin[$data['leader']] ?? ''; - $data['bid_type_text'] = $data->bid_type_text; - $data['bid_nature_text'] = $data->bid_nature_text; - $data['approve_check_status_text'] = $data->approve_check_status_text; + $data['business_opportunity']['head_name'] = $admin[$business_opportunity['head']] ?? ''; + $data['business_opportunity']['leader_name'] = $admin[$business_opportunity['leader']] ?? ''; if (empty($data['reg_date'])) { $data['reg_status'] = 0; $data['reg_status_text'] = '未报名'; diff --git a/app/adminapi/lists/marketing/MarketingBidInfoLists.php b/app/adminapi/lists/marketing/MarketingBidInfoLists.php index 19b2eb5cb..64c43c16b 100644 --- a/app/adminapi/lists/marketing/MarketingBidInfoLists.php +++ b/app/adminapi/lists/marketing/MarketingBidInfoLists.php @@ -75,7 +75,7 @@ ->order(['id' => 'desc']) ->select()->each(function ($data) { //投标审查信息 - $bid_evaluation = MarketingBidEvaluation::withoutField('annex,create_time,update_time,delete_time')->where('id', $data['bid_evaluation_id'])->findOrEmpty(); + $bid_evaluation = MarketingBidEvaluation::withoutField('create_time,update_time,delete_time')->where('id', $data['bid_evaluation_id'])->findOrEmpty(); $data['bid_evaluation'] = $bid_evaluation; $data['bid_evaluation']['bid_type_text'] = $bid_evaluation->bid_type_text; $data['bid_evaluation']['bid_nature_text'] = $bid_evaluation->bid_nature_text; @@ -93,8 +93,8 @@ $data['business_opportunity']['const_area_text'] = $business_opportunity->const_area_text; $data['business_opportunity']['status_text'] = $business_opportunity->status_text; $data['business_opportunity']['dept_name'] = $business_opportunity_dept?->name; - $data['business_opportunity']['head_name'] = $business_opportunity_admin[$data['head']] ?? ''; - $data['business_opportunity']['leader_name'] = $business_opportunity_admin[$data['leader']] ?? ''; + $data['business_opportunity']['head_name'] = $business_opportunity_admin[$business_opportunity['head']] ?? ''; + $data['business_opportunity']['leader_name'] = $business_opportunity_admin[$business_opportunity['leader']] ?? ''; //投标信息 $admin = Admin::where('id', 'in', [$data['general_manager'], $data['bid_head'], $data['technology_head'], $data['business_head'], $data['other_user']])->column('name', 'id'); $data['general_manager_name'] = $admin[$data['general_manager']] ?? ''; diff --git a/app/adminapi/lists/marketing/MarketingBidResultDetailLists.php b/app/adminapi/lists/marketing/MarketingBidResultDetailLists.php new file mode 100644 index 000000000..a063d3e01 --- /dev/null +++ b/app/adminapi/lists/marketing/MarketingBidResultDetailLists.php @@ -0,0 +1,77 @@ + ['bid_result_id'], + ]; + } + + + /** + * @notes 获取市场经营--投标管理--投标结果--参标单位列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function lists(): array + { + return MarketingBidResultDetail::where($this->searchWhere) + ->field(['id', 'bid_result_id', 'company', 'quotation_one', 'quotation_two', 'quotation_three', 'final_rate', 'manager', 'month', 'result']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取市场经营--投标管理--投标结果--参标单位数量 + * @return int + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function count(): int + { + return MarketingBidResultDetail::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/marketing/MarketingBidResultLists.php b/app/adminapi/lists/marketing/MarketingBidResultLists.php new file mode 100644 index 000000000..a12f1ae9c --- /dev/null +++ b/app/adminapi/lists/marketing/MarketingBidResultLists.php @@ -0,0 +1,140 @@ + ['bid_info_id', 'bid_result', 'bid_open_address', 'manager'], + ]; + } + + + /** + * @notes 获取市场经营--投标管理--投标结果列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function lists(): array + { + $params = $this->request->get(); + $where = []; + if (isset($params['business_opportunity_id']) && $params['business_opportunity_id'] != '') { + $bid_evaluation_ids0 = MarketingBidEvaluation::where('business_opportunity_id', $params['business_opportunity_id'])->column('id'); + $bid_info_ids0 = MarketingBidInfo::where('bid_evaluation_id', 'in', $bid_evaluation_ids0)->column('id'); + $where[] = ['bid_info_id', 'in', $bid_info_ids0]; + } + if (isset($params['construct_company']) && $params['construct_company'] != '') { + $business_opportunity_ids = MarketingBusinessOpportunity::where('construct_company', $params['construct_company'])->column('id'); + $bid_evaluation_ids = MarketingBidEvaluation::where('business_opportunity_id', 'in', $business_opportunity_ids)->column('id'); + $bid_info_ids = MarketingBidInfo::where('bid_evaluation_id', 'in', $bid_evaluation_ids)->column('id'); + $where[] = ['bid_info_id', 'in', $bid_info_ids]; + } + return MarketingBidResult::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)->where($where) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function ($data) { + $data['bid_result_text'] = $data->bid_result_text; + //投标信息 + $bid_info = MarketingBidInfo::withoutField('create_time,update_time,delete_time')->where('id', $data['bid_info_id'])->findOrEmpty(); + $data['bid_info'] = $bid_info; + $bid_info_admin = Admin::where('id', 'in', [$bid_info['general_manager'], $bid_info['bid_head'], $bid_info['technology_head'], $bid_info['business_head'], $bid_info['other_user']])->column('name', 'id'); + $data['bid_info']['general_manager_name'] = $bid_info_admin[$bid_info['general_manager']] ?? ''; + $data['bid_info']['bid_head_name'] = $bid_info_admin[$bid_info['bid_head']] ?? ''; + $data['bid_info']['technology_head_name'] = $bid_info_admin[$bid_info['technology_head']] ?? ''; + $data['bid_info']['business_head_name'] = $bid_info_admin[$bid_info['business_head']] ?? ''; + $data['bid_info']['other_user_name'] = $bid_info_admin[$bid_info['other_user']] ?? ''; + //投标审查 + $bid_evaluation = MarketingBidEvaluation::withoutField('create_time,update_time,delete_time')->where('id', $bid_info['bid_evaluation_id'])->findOrEmpty(); + $data['bid_evaluation'] = $bid_evaluation; + $data['bid_evaluation']['bid_type_text'] = $bid_evaluation->bid_type_text; + $data['bid_evaluation']['bid_nature_text'] = $bid_evaluation->bid_nature_text; + //业务机会信息 + $business_opportunity = MarketingBusinessOpportunity::withoutField('bid_date,contacts,annex,approve_id,create_time,update_time,delete_time')->where('id', $bid_evaluation['business_opportunity_id'])->findOrEmpty(); + $construct_company = MarketingCustom::field('name')->where('id', $business_opportunity['construct_company'])->findOrEmpty(); + $business_opportunity_admin = Admin::where('id', 'in', [$business_opportunity['head'], $business_opportunity['leader']])->column('name', 'id'); + $business_opportunity_dept = Dept::field('name')->where('id', $business_opportunity['dept'])->findOrEmpty(); + $data['business_opportunity'] = $business_opportunity; + $data['business_opportunity']['construct_company_name'] = $construct_company?->name; + $data['business_opportunity']['business_nature_text'] = $business_opportunity->business_nature_text; + $data['business_opportunity']['industry_nature_text'] = $business_opportunity->industry_nature_text; + $data['business_opportunity']['info_sources_text'] = $business_opportunity->info_sources_text; + $data['business_opportunity']['fund_sources_text'] = $business_opportunity->fund_sources_text; + $data['business_opportunity']['const_area_text'] = $business_opportunity->const_area_text; + $data['business_opportunity']['status_text'] = $business_opportunity->status_text; + $data['business_opportunity']['dept_name'] = $business_opportunity_dept?->name; + $data['business_opportunity']['head_name'] = $business_opportunity_admin[$business_opportunity['head']] ?? ''; + $data['business_opportunity']['leader_name'] = $business_opportunity_admin[$business_opportunity['leader']] ?? ''; + }) + ->toArray(); + } + + + /** + * @notes 获取市场经营--投标管理--投标结果数量 + * @return int + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function count(): int + { + $params = $this->request->get(); + $where = []; + if (isset($params['business_opportunity_id']) && $params['business_opportunity_id'] != '') { + $bid_evaluation_ids0 = MarketingBidEvaluation::where('business_opportunity_id', $params['business_opportunity_id'])->column('id'); + $bid_info_ids0 = MarketingBidInfo::where('bid_evaluation_id', 'in', $bid_evaluation_ids0)->column('id'); + $where[] = ['bid_info_id', 'in', $bid_info_ids0]; + } + if (isset($params['construct_company']) && $params['construct_company'] != '') { + $business_opportunity_ids = MarketingBusinessOpportunity::where('construct_company', $params['construct_company'])->column('id'); + $bid_evaluation_ids = MarketingBidEvaluation::where('business_opportunity_id', 'in', $business_opportunity_ids)->column('id'); + $bid_info_ids = MarketingBidInfo::where('bid_evaluation_id', 'in', $bid_evaluation_ids)->column('id'); + $where[] = ['bid_info_id', 'in', $bid_info_ids]; + } + return MarketingBidResult::where($this->searchWhere)->where($where)->count(); + } + + } \ No newline at end of file diff --git a/app/adminapi/logic/marketing/MarketingBidEvaluationLogic.php b/app/adminapi/logic/marketing/MarketingBidEvaluationLogic.php index cca921beb..c62cfc7a6 100644 --- a/app/adminapi/logic/marketing/MarketingBidEvaluationLogic.php +++ b/app/adminapi/logic/marketing/MarketingBidEvaluationLogic.php @@ -167,7 +167,11 @@ public static function detail($params): array { $data = MarketingBidEvaluation::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']); - $business_opportunity = MarketingBusinessOpportunity::withoutField('bid_date,contacts,annex,approve_id,create_time,update_time,delete_time')->where('id', $data['business_opportunity_id'])->findOrEmpty(); + $data['bid_type_text'] = $data->bid_type_text; + $data['bid_nature_text'] = $data->bid_nature_text; + $data['approve_check_status_text'] = $data->approve_check_status_text; + //业务机会 + $business_opportunity = MarketingBusinessOpportunity::withoutField('create_time,update_time,delete_time')->where('id', $data['business_opportunity_id'])->findOrEmpty(); $data['business_opportunity'] = $business_opportunity; $construct_company = MarketingCustom::field('name')->where('id', $business_opportunity['construct_company'])->findOrEmpty(); $admin = Admin::where('id', 'in', [$business_opportunity['head'], $business_opportunity['leader']])->column('name', 'id'); @@ -180,11 +184,8 @@ $data['business_opportunity']['const_area_text'] = $business_opportunity->const_area_text; $data['business_opportunity']['status_text'] = $business_opportunity->status_text; $data['business_opportunity']['dept_name'] = $dept?->name; - $data['business_opportunity']['head_name'] = $admin[$data['head']] ?? ''; - $data['business_opportunity']['leader_name'] = $admin[$data['leader']] ?? ''; - $data['bid_type_text'] = $data->bid_type_text; - $data['bid_nature_text'] = $data->bid_nature_text; - $data['approve_check_status_text'] = $data->approve_check_status_text; + $data['business_opportunity']['head_name'] = $admin[$business_opportunity['head']] ?? ''; + $data['business_opportunity']['leader_name'] = $admin[$business_opportunity['leader']] ?? ''; return $data->toArray(); } diff --git a/app/adminapi/logic/marketing/MarketingBidInfoLogic.php b/app/adminapi/logic/marketing/MarketingBidInfoLogic.php index febdb6c51..1e2dd3fc9 100644 --- a/app/adminapi/logic/marketing/MarketingBidInfoLogic.php +++ b/app/adminapi/logic/marketing/MarketingBidInfoLogic.php @@ -135,7 +135,7 @@ { $data = MarketingBidInfo::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']); //投标审查信息 - $bid_evaluation = MarketingBidEvaluation::withoutField('annex,create_time,update_time,delete_time')->where('id', $data['bid_evaluation_id'])->findOrEmpty(); + $bid_evaluation = MarketingBidEvaluation::withoutField('create_time,update_time,delete_time')->where('id', $data['bid_evaluation_id'])->findOrEmpty(); $data['bid_evaluation'] = $bid_evaluation; $data['bid_evaluation']['bid_type_text'] = $bid_evaluation->bid_type_text; $data['bid_evaluation']['bid_nature_text'] = $bid_evaluation->bid_nature_text; @@ -153,8 +153,8 @@ $data['business_opportunity']['const_area_text'] = $business_opportunity->const_area_text; $data['business_opportunity']['status_text'] = $business_opportunity->status_text; $data['business_opportunity']['dept_name'] = $business_opportunity_dept?->name; - $data['business_opportunity']['head_name'] = $business_opportunity_admin[$data['head']] ?? ''; - $data['business_opportunity']['leader_name'] = $business_opportunity_admin[$data['leader']] ?? ''; + $data['business_opportunity']['head_name'] = $business_opportunity_admin[$business_opportunity['head']] ?? ''; + $data['business_opportunity']['leader_name'] = $business_opportunity_admin[$business_opportunity['leader']] ?? ''; //投标信息 $admin = Admin::where('id', 'in', [$data['general_manager'], $data['bid_head'], $data['technology_head'], $data['business_head'], $data['other_user']])->column('name', 'id'); $data['general_manager_name'] = $admin[$data['general_manager']] ?? ''; diff --git a/app/adminapi/logic/marketing/MarketingBidResultDetailLogic.php b/app/adminapi/logic/marketing/MarketingBidResultDetailLogic.php new file mode 100644 index 000000000..be44be74a --- /dev/null +++ b/app/adminapi/logic/marketing/MarketingBidResultDetailLogic.php @@ -0,0 +1,122 @@ + $params['bid_result_id'], + 'company' => $params['company'], + 'quotation_one' => $params['quotation_one'], + 'quotation_two' => $params['quotation_two'], + 'quotation_three' => $params['quotation_three'], + 'final_rate' => $params['final_rate'], + 'manager' => $params['manager'], + 'month' => $params['month'], + 'result' => $params['result'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑市场经营--投标管理--投标结果--参标单位 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + MarketingBidResultDetail::where('id', $params['id'])->update([ + 'bid_result_id' => $params['bid_result_id'], + 'company' => $params['company'], + 'quotation_one' => $params['quotation_one'], + 'quotation_two' => $params['quotation_two'], + 'quotation_three' => $params['quotation_three'], + 'final_rate' => $params['final_rate'], + 'manager' => $params['manager'], + 'month' => $params['month'], + 'result' => $params['result'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除市场经营--投标管理--投标结果--参标单位 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public static function delete(array $params): bool + { + return MarketingBidResultDetail::destroy($params['id']); + } + + + /** + * @notes 获取市场经营--投标管理--投标结果--参标单位详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public static function detail($params): array + { + return MarketingBidResultDetail::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/marketing/MarketingBidResultLogic.php b/app/adminapi/logic/marketing/MarketingBidResultLogic.php new file mode 100644 index 000000000..719d896df --- /dev/null +++ b/app/adminapi/logic/marketing/MarketingBidResultLogic.php @@ -0,0 +1,216 @@ +findOrEmpty(); + $bid_evaluation = MarketingBidEvaluation::where('id', $bid_info['bid_evaluation_id'])->findOrEmpty(); + Db::startTrans(); + try { + $res = MarketingBidResult::create([ + 'bid_info_id' => $params['bid_info_id'], + 'bid_result' => $params['bid_result'], + 'quotation' => $params['quotation'] ?? 0, + 'bid_open_date' => !empty($params['bid_open_date']) ? strtotime($params['bid_open_date']) : 0, + 'bid_open_address' => $params['bid_open_address'] ?? '', + 'our_quotation' => $params['our_quotation'] ?? 0, + 'rate' => $params['rate'] ?? 0, + 'month' => $params['month'] ?? '', + 'manager' => $params['manager'] ?? 0, + 'bid_result analysis' => $params['bid_result analysis'] ?? '', + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + ]); + $status = $params['bid_result'] == 0 ? 3 : 4; + MarketingBusinessOpportunity::where('id', $bid_evaluation['business_opportunity_id'])->update(['status' => $status]); + if (!empty($params['detail'])) { + foreach ($params['detail'] as $v) { + MarketingBidResultDetail::create([ + 'bid_result_id' => $res->id, + 'company' => $v['company'], + 'quotation_one' => $v['quotation_one'] ?? 0, + 'quotation_two' => $v['quotation_two'] ?? 0, + 'quotation_three' => $v['quotation_three'] ?? 0, + 'final_rate' => $v['final_rate'] ?? 0, + 'manager' => $v['manager'] ?? '', + 'month' => $v['month'] ?? '', + 'result' => $v['result'] ?? 0, + ]); + } + } + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑市场经营--投标管理--投标结果 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + MarketingBidResult::where('id', $params['id'])->update([ + 'bid_info_id' => $params['bid_info_id'], + 'bid_result' => $params['bid_result'], + 'quotation' => $params['quotation'] ?? 0, + 'bid_open_date' => !empty($params['bid_open_date']) ? strtotime($params['bid_open_date']) : 0, + 'bid_open_address' => $params['bid_open_address'] ?? '', + 'our_quotation' => $params['our_quotation'] ?? 0, + 'rate' => $params['rate'] ?? 0, + 'month' => $params['month'] ?? '', + 'manager' => $params['manager'] ?? 0, + 'bid_result analysis' => $params['bid_result analysis'] ?? '', + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + ]); + if (!empty($params['detail'])) { + foreach ($params['detail'] as $v) { + if (!empty($v['id'])) { + MarketingBidResultDetail::where('id', $v['id'])->update([ + 'bid_result_id' => $params['id'], + 'company' => $v['company'], + 'quotation_one' => $v['quotation_one'] ?? 0, + 'quotation_two' => $v['quotation_two'] ?? 0, + 'quotation_three' => $v['quotation_three'] ?? 0, + 'final_rate' => $v['final_rate'] ?? 0, + 'manager' => $v['manager'] ?? '', + 'month' => $v['month'] ?? '', + 'result' => $v['result'] ?? 0, + ]); + } else { + MarketingBidResultDetail::create([ + 'bid_result_id' => $params['id'], + 'company' => $v['company'], + 'quotation_one' => $v['quotation_one'] ?? 0, + 'quotation_two' => $v['quotation_two'] ?? 0, + 'quotation_three' => $v['quotation_three'] ?? 0, + 'final_rate' => $v['final_rate'] ?? 0, + 'manager' => $v['manager'] ?? '', + 'month' => $v['month'] ?? '', + 'result' => $v['result'] ?? 0, + ]); + } + } + } + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除市场经营--投标管理--投标结果 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public static function delete(array $params): bool + { + $detail = MarketingBidResultDetail::where('bid_result_id', 'in', $params['id'])->findOrEmpty(); + if (!$detail->isEmpty()) { + self::setError('此数据关联了参标单位信息,需删除参标单位信息'); + return false; + } + return MarketingBidResult::destroy($params['id']); + } + + + /** + * @notes 获取市场经营--投标管理--投标结果详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public static function detail($params): array + { + $data = MarketingBidResult::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']); + $data['bid_result_text'] = $data->bid_result_text; + //投标信息 + $bid_info = MarketingBidInfo::withoutField('create_time,update_time,delete_time')->where('id', $data['bid_info_id'])->findOrEmpty(); + $data['bid_info'] = $bid_info; + $bid_info_admin = Admin::where('id', 'in', [$bid_info['general_manager'], $bid_info['bid_head'], $bid_info['technology_head'], $bid_info['business_head'], $bid_info['other_user']])->column('name', 'id'); + $data['bid_info']['general_manager_name'] = $bid_info_admin[$bid_info['general_manager']] ?? ''; + $data['bid_info']['bid_head_name'] = $bid_info_admin[$bid_info['bid_head']] ?? ''; + $data['bid_info']['technology_head_name'] = $bid_info_admin[$bid_info['technology_head']] ?? ''; + $data['bid_info']['business_head_name'] = $bid_info_admin[$bid_info['business_head']] ?? ''; + $data['bid_info']['other_user_name'] = $bid_info_admin[$bid_info['other_user']] ?? ''; + //投标审查 + $bid_evaluation = MarketingBidEvaluation::withoutField('create_time,update_time,delete_time')->where('id', $bid_info['bid_evaluation_id'])->findOrEmpty(); + $data['bid_evaluation'] = $bid_evaluation; + $data['bid_evaluation']['bid_type_text'] = $bid_evaluation->bid_type_text; + $data['bid_evaluation']['bid_nature_text'] = $bid_evaluation->bid_nature_text; + //业务机会信息 + $business_opportunity = MarketingBusinessOpportunity::withoutField('bid_date,contacts,annex,approve_id,create_time,update_time,delete_time')->where('id', $bid_evaluation['business_opportunity_id'])->findOrEmpty(); + $construct_company = MarketingCustom::field('name')->where('id', $business_opportunity['construct_company'])->findOrEmpty(); + $business_opportunity_admin = Admin::where('id', 'in', [$business_opportunity['head'], $business_opportunity['leader']])->column('name', 'id'); + $business_opportunity_dept = Dept::field('name')->where('id', $business_opportunity['dept'])->findOrEmpty(); + $data['business_opportunity'] = $business_opportunity; + $data['business_opportunity']['construct_company_name'] = $construct_company?->name; + $data['business_opportunity']['business_nature_text'] = $business_opportunity->business_nature_text; + $data['business_opportunity']['industry_nature_text'] = $business_opportunity->industry_nature_text; + $data['business_opportunity']['info_sources_text'] = $business_opportunity->info_sources_text; + $data['business_opportunity']['fund_sources_text'] = $business_opportunity->fund_sources_text; + $data['business_opportunity']['const_area_text'] = $business_opportunity->const_area_text; + $data['business_opportunity']['status_text'] = $business_opportunity->status_text; + $data['business_opportunity']['dept_name'] = $business_opportunity_dept?->name; + $data['business_opportunity']['head_name'] = $business_opportunity_admin[$business_opportunity['head']] ?? ''; + $data['business_opportunity']['leader_name'] = $business_opportunity_admin[$business_opportunity['leader']] ?? ''; + return $data->toArray(); + } + } \ No newline at end of file diff --git a/app/adminapi/validate/marketing/MarketingBidEvaluationValidate.php b/app/adminapi/validate/marketing/MarketingBidEvaluationValidate.php index 6c028715a..0f6a02435 100644 --- a/app/adminapi/validate/marketing/MarketingBidEvaluationValidate.php +++ b/app/adminapi/validate/marketing/MarketingBidEvaluationValidate.php @@ -42,12 +42,12 @@ 'bid_margin' => 'float|egt:0', 'bid_amount' => 'float|egt:0', 'quotation_amount' => 'float|egt:0', - 'end_date' => 'dateFormat:y-m-d', - 'bid_date' => 'require|dateFormat:y-m-d', + 'end_date' => 'dateFormat:Y-m-d', + 'bid_date' => 'require|dateFormat:Y-m-d', 'annex' => 'checkAnnex', 'flow_id' => 'require|checkFlow', 'path' => 'require', - 'reg_date' => 'require|dateFormat:y-m-d', + 'reg_date' => 'require|dateFormat:Y-m-d', 'review_status' => 'require|in:0,1', 'reg_result' => 'require|in:0,1', ]; diff --git a/app/adminapi/validate/marketing/MarketingBidResultDetailValidate.php b/app/adminapi/validate/marketing/MarketingBidResultDetailValidate.php new file mode 100644 index 000000000..ca7fb4658 --- /dev/null +++ b/app/adminapi/validate/marketing/MarketingBidResultDetailValidate.php @@ -0,0 +1,112 @@ + 'require', + 'bid_result_id' => 'require', + 'company' => 'require', + 'quotation_one' => 'require', + 'quotation_two' => 'require', + 'quotation_three' => 'require', + 'final_rate' => 'require', + 'manager' => 'require', + 'month' => 'require', + 'result' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'bid_result_id' => '投标结果id', + 'company' => '投标单位', + 'quotation_one' => '报价1', + 'quotation_two' => '报价2', + 'quotation_three' => '报价3', + 'final_rate' => '最终费率', + 'manager' => '投标总监', + 'month' => '投标人月数', + 'result' => '投标结果 0-中标 1-不中标', + ]; + + + /** + * @notes 添加场景 + * @return MarketingBidResultDetailValidate + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function sceneAdd() + { + return $this->only(['bid_result_id','company','quotation_one','quotation_two','quotation_three','final_rate','manager','month','result']); + } + + + /** + * @notes 编辑场景 + * @return MarketingBidResultDetailValidate + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function sceneEdit() + { + return $this->only(['id','bid_result_id','company','quotation_one','quotation_two','quotation_three','final_rate','manager','month','result']); + } + + + /** + * @notes 删除场景 + * @return MarketingBidResultDetailValidate + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return MarketingBidResultDetailValidate + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/marketing/MarketingBidResultValidate.php b/app/adminapi/validate/marketing/MarketingBidResultValidate.php new file mode 100644 index 000000000..661b7b27c --- /dev/null +++ b/app/adminapi/validate/marketing/MarketingBidResultValidate.php @@ -0,0 +1,152 @@ + 'require|checkData', + 'bid_info_id' => 'require|checkBidInfo', + 'bid_result' => 'require|in:0,1', + 'quotation' => 'requireIf:bid_result,0|float|egt:0', + 'bid_open_date' => 'require|dateFormat:Y-m-d', + 'our_quotation' => 'float|egt:0', + 'rate' => 'float|egt:0', + 'manager' => 'checkManager', + 'bid_result analysis' => 'requireIf:bid_result,0', + 'annex' => 'checkAnnex', + 'detail' => 'checkDetail' + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'bid_info_id' => '投标信息id', + 'bid_result' => '投标结果 0-中标 1-不中标', + 'quotation' => '中标报价', + 'bid_open_date' => '开标日期', + 'bid_open_address' => '开标地点', + 'our_quotation' => '我方报价', + 'rate' => '中标费率', + 'month' => '投标人月数', + 'manager' => '中标总监/经理', + 'bid_result analysis' => '投标结果分析', + ]; + + + /** + * @notes 添加场景 + * @return MarketingBidResultValidate + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return MarketingBidResultValidate + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function sceneEdit() + { + } + + + /** + * @notes 删除场景 + * @return MarketingBidResultValidate + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function sceneDelete() + { + return $this->only(['id'])->remove('id', 'checkData'); + } + + + /** + * @notes 详情场景 + * @return MarketingBidResultValidate + * @author likeadmin + * @date 2024/04/12 13:59 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value): bool|string + { + $data = MarketingBidResult::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '数据不存在' : true; + } + + public function checkBidInfo($value): bool|string + { + $data = MarketingBidInfo::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '投标信息数据不存在' : true; + } + + public function checkManager($value): bool|string + { + $data = Admin::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '中标总监/经理数据不存在' : true; + } + + public function checkDetail($value): bool|string + { + if (!isset($value) || $value == '') return true; + if (!is_array($value)) return '参标单位数据格式错误'; + foreach ($value as $k => $v) { + if (isset($v['id']) && !empty($v['id'])) { + $data = MarketingBidResultDetail::where('id', $v['id'])->findOrEmpty(); + if ($data->isEmpty()) { + return '第' . ($k + 1) . '行参标单位信息不存在'; + } + } + if (empty($v['company'])) { + return '参标单位列表第' . ($k + 1) . '行投标单位为空'; + } + } + return true; + } + } \ No newline at end of file diff --git a/app/common/model/marketing/MarketingBidResult.php b/app/common/model/marketing/MarketingBidResult.php new file mode 100644 index 000000000..7f932589a --- /dev/null +++ b/app/common/model/marketing/MarketingBidResult.php @@ -0,0 +1,44 @@ + '中标', 1 => '不中标']; + return $arr[$data['bid_result']]; + } + + public function getBidOpenDateAttr($value): string + { + return !empty($value) ? date('Y-m-d', $value) : ''; + } + } \ No newline at end of file diff --git a/app/common/model/marketing/MarketingBidResultDetail.php b/app/common/model/marketing/MarketingBidResultDetail.php new file mode 100644 index 000000000..4ac17c783 --- /dev/null +++ b/app/common/model/marketing/MarketingBidResultDetail.php @@ -0,0 +1,34 @@ + '未启动投标', 1 => '参与投标', 2 => '未开标']; + $arr = [0 => '未启动投标', 1 => '参与投标', 2 => '未开标', 3 => '已中标', 4 => '未中标']; return $arr[$data['status']]; }