From 4bb44bfca433420759a7431f42e5801f43744140 Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Thu, 11 Apr 2024 17:36:55 +0800 Subject: [PATCH] update --- .../MarketingBidEvaluationController.php | 141 +++++++++++ ...MarketingBusinessOpportunityController.php | 134 ++++++++++ .../marketing/MarketingBidEvaluationLists.php | 121 +++++++++ .../MarketingBusinessOpportunityLists.php | 109 +++++++++ .../marketing/MarketingBidEvaluationLogic.php | 215 ++++++++++++++++ .../MarketingBusinessOpportunityLogic.php | 198 +++++++++++++++ .../MarketingBidEvaluationValidate.php | 196 +++++++++++++++ .../MarketingBusinessOpportunityValidate.php | 230 ++++++++++++++++++ .../marketing/MarketingBidEvaluation.php | 68 ++++++ .../MarketingBusinessOpportunity.php | 75 ++++++ 10 files changed, 1487 insertions(+) create mode 100644 app/adminapi/controller/marketing/MarketingBidEvaluationController.php create mode 100644 app/adminapi/controller/marketing/MarketingBusinessOpportunityController.php create mode 100644 app/adminapi/lists/marketing/MarketingBidEvaluationLists.php create mode 100644 app/adminapi/lists/marketing/MarketingBusinessOpportunityLists.php create mode 100644 app/adminapi/logic/marketing/MarketingBidEvaluationLogic.php create mode 100644 app/adminapi/logic/marketing/MarketingBusinessOpportunityLogic.php create mode 100644 app/adminapi/validate/marketing/MarketingBidEvaluationValidate.php create mode 100644 app/adminapi/validate/marketing/MarketingBusinessOpportunityValidate.php create mode 100644 app/common/model/marketing/MarketingBidEvaluation.php create mode 100644 app/common/model/marketing/MarketingBusinessOpportunity.php diff --git a/app/adminapi/controller/marketing/MarketingBidEvaluationController.php b/app/adminapi/controller/marketing/MarketingBidEvaluationController.php new file mode 100644 index 000000000..54b8d54fc --- /dev/null +++ b/app/adminapi/controller/marketing/MarketingBidEvaluationController.php @@ -0,0 +1,141 @@ +dataLists(new MarketingBidEvaluationLists()); + } + + + /** + * @notes 添加市场经营--投标管理--投标评审 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/11 15:42 + */ + public function add() + { + $params = (new MarketingBidEvaluationValidate())->post()->goCheck('add'); + $result = MarketingBidEvaluationLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(MarketingBidEvaluationLogic::getError()); + } + + /** + * @notes 市场经营--投标管理--投标评审-报名 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/11 15:42 + */ + public function reg() + { + $params = (new MarketingBidEvaluationValidate())->post()->goCheck('reg'); + $result = MarketingBidEvaluationLogic::reg($params); + if (true === $result) { + return $this->success('报名成功', [], 1, 1); + } + return $this->fail(MarketingBidEvaluationLogic::getError()); + } + + /** + * @notes 编辑市场经营--投标管理--投标评审 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/11 15:42 + */ + public function edit() + { + $params = (new MarketingBidEvaluationValidate())->post()->goCheck('edit'); + $result = MarketingBidEvaluationLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(MarketingBidEvaluationLogic::getError()); + } + + /** + * @notes 删除市场经营--投标管理--投标评审 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/11 15:42 + */ + public function delete() + { + $params = (new MarketingBidEvaluationValidate())->post()->goCheck('delete'); + MarketingBidEvaluationLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取市场经营--投标管理--投标评审详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/11 15:42 + */ + public function detail() + { + $params = (new MarketingBidEvaluationValidate())->goCheck('detail'); + $result = MarketingBidEvaluationLogic::detail($params); + return $this->data($result); + } + + //获取审批流程列表 + public function flows(): \think\response\Json + { + $flow_type = FlowType::where('type', 1)->where('name', 'TBPS')->findOrEmpty(); + $data = Flow::field('id,name')->where('flow_cate', $flow_type['id'])->where('status', 2)->select(); + return $this->success('请求成功', $data->toArray()); + } + + //添加审批 + public function approve(): \think\response\Json + { + $params = (new MarketingBidEvaluationValidate())->post()->goCheck('approve'); + $result = MarketingBidEvaluationLogic::approve($params, $this->adminId); + if (true === $result) { + return $this->success('提交审核信息成功', [], 1, 1); + } + return $this->fail(MarketingBidEvaluationLogic::getError()); + } + } \ No newline at end of file diff --git a/app/adminapi/controller/marketing/MarketingBusinessOpportunityController.php b/app/adminapi/controller/marketing/MarketingBusinessOpportunityController.php new file mode 100644 index 000000000..c640a9151 --- /dev/null +++ b/app/adminapi/controller/marketing/MarketingBusinessOpportunityController.php @@ -0,0 +1,134 @@ +dataLists(new MarketingBusinessOpportunityLists()); + } + + + /** + * @notes 添加市场经营--投标管理--业务机会 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public function add() + { + $params = (new MarketingBusinessOpportunityValidate())->post()->goCheck('add'); + $result = MarketingBusinessOpportunityLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(MarketingBusinessOpportunityLogic::getError()); + } + + + /** + * @notes 编辑市场经营--投标管理--业务机会 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public function edit() + { + $params = (new MarketingBusinessOpportunityValidate())->post()->goCheck('edit'); + $result = MarketingBusinessOpportunityLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(MarketingBusinessOpportunityLogic::getError()); + } + + + /** + * @notes 删除市场经营--投标管理--业务机会 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public function delete() + { + $params = (new MarketingBusinessOpportunityValidate())->post()->goCheck('delete'); + MarketingBusinessOpportunityLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + public function datas(): \think\response\Json + { + return $this->data(MarketingBusinessOpportunityLogic::datas()); + } + + + /** + * @notes 获取市场经营--投标管理--业务机会详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public function detail() + { + $params = (new MarketingBusinessOpportunityValidate())->goCheck('detail'); + $result = MarketingBusinessOpportunityLogic::detail($params); + return $this->data($result); + } + + //获取审批流程列表 + public function flows(): \think\response\Json + { + $flow_type = FlowType::where('type', 1)->where('name', 'ywjh')->findOrEmpty(); + $data = Flow::field('id,name')->where('flow_cate', $flow_type['id'])->where('status', 2)->select(); + return $this->success('请求成功', $data->toArray()); + } + + //添加审批 + public function approve(): \think\response\Json + { + $params = (new MarketingBusinessOpportunityValidate())->post()->goCheck('approve'); + $result = MarketingBusinessOpportunityLogic::approve($params, $this->adminId); + if (true === $result) { + return $this->success('提交审核信息成功', [], 1, 1); + } + return $this->fail(MarketingBusinessOpportunityLogic::getError()); + } + + + } \ No newline at end of file diff --git a/app/adminapi/lists/marketing/MarketingBidEvaluationLists.php b/app/adminapi/lists/marketing/MarketingBidEvaluationLists.php new file mode 100644 index 000000000..3d2bbb391 --- /dev/null +++ b/app/adminapi/lists/marketing/MarketingBidEvaluationLists.php @@ -0,0 +1,121 @@ + ['business_opportunity_id', 'bid_type', 'bid_nature'], + '%like%' => ['bid_code'], + ]; + } + + + /** + * @notes 获取市场经营--投标管理--投标评审列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/04/11 15:42 + */ + public function lists(): array + { + return MarketingBidEvaluation::withoutField('create_time,update_time,delete_time')->where($this->searchWhere) + ->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(); + $construct_company = MarketingCustom::field('name')->where('id', $data['construct_company'])->findOrEmpty(); + $admin = Admin::where('id', 'in', [$data['head'], $data['leader']])->column('name', 'id'); + $dept = Dept::field('name')->where('id', $data['dept'])->findOrEmpty(); + $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'] = $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; + if (empty($data['reg_date'])) { + $data['reg_status'] = 0; + $data['reg_status_text'] = '未报名'; + } else { + $data['reg_status'] = 1; + $data['reg_status_text'] = '已报名'; + } + if (!empty($data['approve_id'])) { + $approve = FlowApprove::field('check_status')->where('content_id', $data['id'])->where('content_model', 'app\common\model\marketing\MarketingBidEvaluation')->findOrEmpty(); + $data['approve_status'] = $approve['check_status']; + $data['approve_status_text'] = match ($approve['check_status']) { + 0 => '待审核', + 1 => '审核中', + 2 => '审核通过', + 3 => '审核不通过', + 4 => '撤销审核', + }; + } else { + $data['approve_status'] = 0; + $data['approve_status_text'] = '待审核'; + } + }) + ->toArray(); + } + + + /** + * @notes 获取市场经营--投标管理--投标评审数量 + * @return int + * @author likeadmin + * @date 2024/04/11 15:42 + */ + public function count(): int + { + return MarketingBidEvaluation::where($this->searchWhere)->count(); + } + + } \ No newline at end of file diff --git a/app/adminapi/lists/marketing/MarketingBusinessOpportunityLists.php b/app/adminapi/lists/marketing/MarketingBusinessOpportunityLists.php new file mode 100644 index 000000000..3eafc7f2a --- /dev/null +++ b/app/adminapi/lists/marketing/MarketingBusinessOpportunityLists.php @@ -0,0 +1,109 @@ + ['construct_company', 'business_nature', 'industry_nature', 'info_sources', 'fund_sources', 'const_area', 'status'], + '%like%' => ['project_name', 'project_code'], + ]; + } + + + /** + * @notes 获取市场经营--投标管理--业务机会列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public function lists(): array + { + return MarketingBusinessOpportunity::withoutField('create_time,update_time,delete_time')->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function ($data) { + $construct_company = MarketingCustom::field('name')->where('id', $data['construct_company'])->findOrEmpty(); + $admin = Admin::where('id', 'in', [$data['head'], $data['leader']])->column('name', 'id'); + $dept = Dept::field('name')->where('id', $data['dept'])->findOrEmpty(); + $data['construct_company_name'] = $construct_company?->name; + $data['business_nature_text'] = $data->business_nature_text; + $data['industry_nature_text'] = $data->industry_nature_text; + $data['info_sources_text'] = $data->info_sources_text; + $data['fund_sources_text'] = $data->fund_sources_text; + $data['const_area_text'] = $data->const_area_text; + $data['status_text'] = $data->status_text; + $data['dept_name'] = $dept?->name; + $data['head_name'] = $admin[$data['head']] ?? ''; + $data['leader_name'] = $admin[$data['leader']] ?? ''; + if (!empty($data['approve_id'])) { + $approve = FlowApprove::field('check_status')->where('content_id', $data['id'])->where('content_model', 'app\common\model\marketing\MarketingBusinessOpportunity')->findOrEmpty(); + $data['approve_status'] = $approve['check_status']; + $data['approve_status_text'] = match ($approve['check_status']) { + 0 => '待审核', + 1 => '审核中', + 2 => '审核通过', + 3 => '审核不通过', + 4 => '撤销审核', + }; + } else { + $data['approve_status'] = 0; + $data['approve_status_text'] = '待审核'; + } + }) + ->toArray(); + } + + + /** + * @notes 获取市场经营--投标管理--业务机会数量 + * @return int + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public function count(): int + { + return MarketingBusinessOpportunity::where($this->searchWhere)->count(); + } + + } \ No newline at end of file diff --git a/app/adminapi/logic/marketing/MarketingBidEvaluationLogic.php b/app/adminapi/logic/marketing/MarketingBidEvaluationLogic.php new file mode 100644 index 000000000..835267052 --- /dev/null +++ b/app/adminapi/logic/marketing/MarketingBidEvaluationLogic.php @@ -0,0 +1,215 @@ + $params['business_opportunity_id'], + 'bid_type' => $params['bid_type'] ?? 0, + 'bid_nature' => $params['bid_nature'] ?? 0, + 'bid_code' => $params['bid_code'], + 'bid_margin' => $params['bid_margin'] ?? 0, + 'bid_amount' => $params['bid_amount'] ?? 0, + 'quotation_amount' => $params['quotation_amount'] ?? 0, + 'end_date' => !empty($params['end_date']) ? strtotime($params['end_date']) : 0, + 'bid_date' => !empty($params['bid_date']) ? strtotime($params['bid_date']) : 0, + 'service_duration' => $params['service_duration'] ?? '', + 'bid_address' => $params['bid_address'] ?? '', + 'bid_agency' => $params['bid_agency'] ?? '', + 'bid_agency_address' => $params['bid_agency_address'] ?? '', + 'bid_agency_contacts' => $params['bid_agency_contacts'] ?? '', + 'bid_agency_telephone' => $params['bid_agency_telephone'] ?? '', + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + ]); + MarketingBusinessOpportunity::where('id', $params['business_opportunity_id'])->update(['status' => 1]); + 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/11 15:42 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + MarketingBidEvaluation::where('id', $params['id'])->update([ + 'business_opportunity_id' => $params['business_opportunity_id'], + 'bid_type' => $params['bid_type'] ?? 0, + 'bid_nature' => $params['bid_nature'] ?? 0, + 'bid_code' => $params['bid_code'], + 'bid_margin' => $params['bid_margin'] ?? 0, + 'bid_amount' => $params['bid_amount'] ?? 0, + 'quotation_amount' => $params['quotation_amount'] ?? 0, + 'end_date' => !empty($params['end_date']) ? strtotime($params['end_date']) : 0, + 'bid_date' => !empty($params['bid_date']) ? strtotime($params['bid_date']) : 0, + 'service_duration' => $params['service_duration'] ?? '', + 'bid_address' => $params['bid_address'] ?? '', + 'bid_agency' => $params['bid_agency'] ?? '', + 'bid_agency_address' => $params['bid_agency_address'] ?? '', + 'bid_agency_contacts' => $params['bid_agency_contacts'] ?? '', + 'bid_agency_telephone' => $params['bid_agency_telephone'] ?? '', + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + ]); + 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/11 15:42 + */ + public static function reg(array $params): bool + { + Db::startTrans(); + try { + MarketingBidEvaluation::where('id', $params['id'])->update([ + 'reg_date' => !empty($params['reg_date']) ? strtotime($params['reg_date']) : 0, + 'review_status' => $params['review_status'] ?? 0, + 'reg_result' => $params['reg_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/11 15:42 + */ + public static function delete(array $params): bool + { + return MarketingBidEvaluation::destroy($params['id']); + } + + + /** + * @notes 获取市场经营--投标管理--投标评审详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/04/11 15:42 + */ + 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['business_opportunity'] = $business_opportunity->toArray(); + $construct_company = MarketingCustom::field('name')->where('id', $data['construct_company'])->findOrEmpty(); + $admin = Admin::where('id', 'in', [$data['head'], $data['leader']])->column('name', 'id'); + $dept = Dept::field('name')->where('id', $data['dept'])->findOrEmpty(); + $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'] = $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; + return $data->toArray(); + } + + public static function approve($params, $admin_id): bool + { + $data = MarketingBidEvaluation::where('id', $params['id'])->findOrEmpty(); + $approve_data = FlowApprove::where('id', $data['approve_id'])->findOrEmpty(); + if (!empty($data['approve_id']) && $approve_data['check_status'] != 3) { + self::setError('当前内容存在审核信息,请勿重复提交'); + return false; + } + Db::startTrans(); + try { + $res = addApprove( + '投标评审', + $params['id'], + 'app\common\model\marketing\MarketingBidEvaluation', + $params['path'], + $params['flow_id'], + $admin_id + ); + if ($res) { + MarketingBidEvaluation::where('id', $params['id'])->update([ + 'approve_id' => $res, + ]); + } + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + } \ No newline at end of file diff --git a/app/adminapi/logic/marketing/MarketingBusinessOpportunityLogic.php b/app/adminapi/logic/marketing/MarketingBusinessOpportunityLogic.php new file mode 100644 index 000000000..a3cb950b3 --- /dev/null +++ b/app/adminapi/logic/marketing/MarketingBusinessOpportunityLogic.php @@ -0,0 +1,198 @@ + $params['project_name'], + 'project_code' => data_unique_code('YWJH'), + 'bid_date' => !empty($params['bid_date']) ? strtotime($params['bid_date']) : 0, + 'construct_company' => $params['construct_company'], + 'management_company' => $params['management_company'], + 'business_nature' => $params['business_nature'] ?? 0, + 'industry_nature' => $params['industry_nature'] ?? 0, + 'info_sources' => $params['info_sources'] ?? 0, + 'fund_sources' => $params['fund_sources'] ?? 0, + 'const_area' => $params['const_area'] ?? 0, + 'project_address' => $params['project_address'] ?? '', + 'total_investment' => $params['total_investment'] ?? 0, + 'jianan_investment' => $params['jianan_investment'] ?? 0, + 'project_overview' => $params['project_overview'] ?? '', + 'remark' => $params['remark'] ?? '', + 'head' => $params['head'] ?? 0, + 'dept' => $params['dept'] ?? 0, + 'leader' => $params['leader'] ?? 0, + 'contacts' => $params['contacts'] ?? '', + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + ]); + 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/11 14:27 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + MarketingBusinessOpportunity::where('id', $params['id'])->update([ + 'project_name' => $params['project_name'], + 'bid_date' => !empty($params['bid_date']) ? strtotime($params['bid_date']) : 0, + 'construct_company' => $params['construct_company'], + 'management_company' => $params['management_company'], + 'business_nature' => $params['business_nature'] ?? 0, + 'industry_nature' => $params['industry_nature'] ?? 0, + 'info_sources' => $params['info_sources'] ?? 0, + 'fund_sources' => $params['fund_sources'] ?? 0, + 'const_area' => $params['const_area'] ?? 0, + 'project_address' => $params['project_address'] ?? '', + 'total_investment' => $params['total_investment'] ?? 0, + 'jianan_investment' => $params['jianan_investment'] ?? 0, + 'project_overview' => $params['project_overview'] ?? '', + 'remark' => $params['remark'] ?? '', + 'head' => $params['head'] ?? 0, + 'dept' => $params['dept'] ?? 0, + 'leader' => $params['leader'] ?? 0, + 'contacts' => $params['contacts'] ?? '', + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + ]); + 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/11 14:27 + */ + public static function delete(array $params): bool + { + return MarketingBusinessOpportunity::destroy($params['id']); + } + + + /** + * @notes 获取市场经营--投标管理--业务机会详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public static function detail($params): array + { + $data = MarketingBusinessOpportunity::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']); + $construct_company = MarketingCustom::field('name')->where('id', $data['construct_company'])->findOrEmpty(); + $admin = Admin::where('id', 'in', [$data['head'], $data['leader']])->column('name', 'id'); + $dept = Dept::field('name')->where('id', $data['dept'])->findOrEmpty(); + $data['construct_company_name'] = $construct_company?->name; + $data['business_nature_text'] = $data->business_nature_text; + $data['industry_nature_text'] = $data->industry_nature_text; + $data['info_sources_text'] = $data->info_sources_text; + $data['fund_sources_text'] = $data->fund_sources_text; + $data['const_area_text'] = $data->const_area_text; + $data['status_text'] = $data->status_text; + $data['dept_name'] = $dept?->name; + $data['head_name'] = $admin[$data['head']] ?? ''; + $data['leader_name'] = $admin[$data['leader']] ?? ''; + return $data->toArray(); + } + + public static function datas(): array + { + return MarketingBusinessOpportunity::field(['id', 'project_name'])->order(['id' => 'desc'])->select()->each(function ($data) { + $data['projectinfo'] = 'ID:' . $data['id'] . ' / 名称:' . $data['project_name']; + })->toArray(); + } + + public static function approve($params, $admin_id): bool + { + $data = MarketingBusinessOpportunity::where('id', $params['id'])->findOrEmpty(); + $approve_data = FlowApprove::where('id', $data['approve_id'])->findOrEmpty(); + if (!empty($data['approve_id']) && $approve_data['check_status'] != 3) { + self::setError('当前内容存在审核信息,请勿重复提交'); + return false; + } + Db::startTrans(); + try { + $res = addApprove( + '业务机会', + $params['id'], + 'app\common\model\marketing\MarketingBusinessOpportunity', + $params['path'], + $params['flow_id'], + $admin_id + ); + if ($res) { + MarketingBusinessOpportunity::where('id', $params['id'])->update([ + 'approve_id' => $res, + ]); + } + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + } \ No newline at end of file diff --git a/app/adminapi/validate/marketing/MarketingBidEvaluationValidate.php b/app/adminapi/validate/marketing/MarketingBidEvaluationValidate.php new file mode 100644 index 000000000..6c028715a --- /dev/null +++ b/app/adminapi/validate/marketing/MarketingBidEvaluationValidate.php @@ -0,0 +1,196 @@ + 'require|checkData', + 'business_opportunity_id' => 'require|checkBusinessOpportunity', + 'bid_type' => 'checkBidType', + 'bid_nature' => 'checkBidNature', + 'bid_code' => 'require', + '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', + 'annex' => 'checkAnnex', + 'flow_id' => 'require|checkFlow', + 'path' => 'require', + 'reg_date' => 'require|dateFormat:y-m-d', + 'review_status' => 'require|in:0,1', + 'reg_result' => 'require|in:0,1', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'business_opportunity_id' => '业务机会id', + 'bid_type' => '招标方式', + 'bid__nature' => '投标性质', + 'bid_code' => '投标项目编号', + 'bid_margin' => '投标保证金', + 'bid_amount' => '报名和标书费', + 'quotation_amount' => '报价范围', + 'end_date' => '报名截止日期', + 'bid_date' => '投标日期', + 'service_duration' => '服务工期', + 'bid_address' => '投标地点', + 'bid_agency' => '招标代理单位', + 'bid_agency_address' => '联系地址', + 'bid_agency_contacts' => '联系人', + 'bid_agency_telephone' => '联系方式', + 'flow_id' => '审批流id', + 'path' => '路径', + 'reg_date' => '报名时间', + 'review_status' => '资审情况', + 'reg_result' => '报名结果', + ]; + + + /** + * @notes 添加场景 + * @return MarketingBidEvaluationValidate + * @author likeadmin + * @date 2024/04/11 15:42 + */ + public function sceneAdd() + { + return $this->remove('id', true) + ->remove('flow_id', true) + ->remove('path', true) + ->remove('reg_date', true) + ->remove('review_status', true)->remove('reg_result', true); + } + + + /** + * @notes 编辑场景 + * @return MarketingBidEvaluationValidate + * @author likeadmin + * @date 2024/04/11 15:42 + */ + public function sceneEdit() + { + return $this->remove('flow_id', true)->remove('path', true)->remove('reg_date', true) + ->remove('review_status', true)->remove('reg_result', true); + } + + + /** + * @notes 删除场景 + * @return MarketingBidEvaluationValidate + * @author likeadmin + * @date 2024/04/11 15:42 + */ + public function sceneDelete() + { + return $this->only(['id'])->remove('id', 'checkData'); + } + + + /** + * @notes 详情场景 + * @return MarketingBidEvaluationValidate + * @author likeadmin + * @date 2024/04/11 15:42 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + + /** + * @notes 审批场景 + * @return MarketingBidEvaluationValidate + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public function sceneApprove() + { + return $this->only(['id', 'flow_id', 'path']); + } + + /** + * @notes 报名场景 + * @return MarketingBidEvaluationValidate + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public function sceneReg() + { + return $this->only(['id', 'reg_date', 'review_status', 'reg_result']); + } + + + public function checkData($value): bool|string + { + $data = MarketingBidEvaluation::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '数据不存在' : true; + } + + + public function checkBusinessOpportunity($value): bool|string + { + $data = MarketingBusinessOpportunity::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '关联业务机会数据不存在' : true; + } + + + public function checkBidType($value): bool|string + { + if (empty($value)) return true; + $dict = DictData::where('type_value', 'bidding_method')->column('value'); + if (!in_array($value, $dict)) { + return '招标方式数据值无效'; + } + return true; + } + + + public function checkBidNature($value): bool|string + { + if (empty($value)) return true; + $dict = DictData::where('type_value', 'bid_nature')->column('value'); + if (!in_array($value, $dict)) { + return '投标性质数据值无效'; + } + return true; + } + + } \ No newline at end of file diff --git a/app/adminapi/validate/marketing/MarketingBusinessOpportunityValidate.php b/app/adminapi/validate/marketing/MarketingBusinessOpportunityValidate.php new file mode 100644 index 000000000..1a284b6bd --- /dev/null +++ b/app/adminapi/validate/marketing/MarketingBusinessOpportunityValidate.php @@ -0,0 +1,230 @@ + 'require|checkData', + 'project_name' => 'require', + 'bid_date' => 'require|dateFormat:Y-m-d', + 'construct_company' => 'require|checkConstructCompany', + 'management_company' => 'require', + 'business_nature' => 'checkBusinessNature', + 'industry_nature' => 'checkIndustryNature', + 'info_sources' => 'checkInfoSources', + 'fund_sources' => 'checkFundSources', + 'const_area' => 'checkConstArea', + 'total_investment' => 'float|egt:0', + 'jianan_investment' => 'float|egt:0', + 'head' => 'checkHead', + 'dept' => 'checkDept', + 'leader' => 'checkLeader', + 'annex' => 'checkAnnex', + 'flow_id' => 'require|checkFlow', + 'path' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'project_name' => '项目名称', + 'project_code' => '项目编号', + 'bid_date' => '预计招标日期', + 'construct_company' => '建设单位', + 'management_company' => '建设管理单位', + 'business_nature' => '业务性质', + 'industry_nature' => '行业性质', + 'info_sources' => '消息来源', + 'fund_sources' => '资金来源', + 'const_area' => '建设区域', + 'project_address' => '项目地点', + 'total_investment' => '工程总投资', + 'jianan_investment' => '建安投资额', + 'project_overview' => '工程概况', + 'remark' => '备注', + 'head' => '负责人', + 'dept' => '负责部门', + 'leader' => '分管领导', + 'contacts' => '联系人信息', + 'flow_id' => '审批流id', + 'path' => '路径', + ]; + + + /** + * @notes 添加场景 + * @return MarketingBusinessOpportunityValidate + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public function sceneAdd() + { + return $this->remove('id', true)->remove('flow_id', true)->remove('path', true); + } + + + /** + * @notes 编辑场景 + * @return MarketingBusinessOpportunityValidate + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public function sceneEdit() + { + return $this->remove('flow_id', true)->remove('path', true); + } + + + /** + * @notes 删除场景 + * @return MarketingBusinessOpportunityValidate + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public function sceneDelete() + { + return $this->only(['id'])->remove('id', 'checkData'); + } + + + /** + * @notes 详情场景 + * @return MarketingBusinessOpportunityValidate + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + /** + * @notes 审批场景 + * @return MarketingBusinessOpportunityValidate + * @author likeadmin + * @date 2024/04/11 14:27 + */ + public function sceneApprove() + { + return $this->only(['id', 'flow_id', 'path']); + } + + public function checkData($value): bool|string + { + $data = MarketingBusinessOpportunity::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '数据不存在' : true; + } + + public function checkConstructCompany($value): bool|string + { + $data = MarketingCustom::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '建设单位数据不存在' : true; + } + + public function checkBusinessNature($value): bool|string + { + if (empty($value)) return true; + $dict = DictData::where('type_value', 'cost_consultation_business_nature')->column('value'); + if (!in_array($value, $dict)) { + return '业务性质数据值无效'; + } + return true; + } + + public function checkIndustryNature($value): bool|string + { + if (empty($value)) return true; + $dict = DictData::where('type_value', 'cost_consultation_industry_nature')->column('value'); + if (!in_array($value, $dict)) { + return '行业性质数据值无效'; + } + return true; + } + + public function checkInfoSources($value): bool|string + { + if (empty($value)) return true; + $dict = DictData::where('type_value', 'info_sources')->column('value'); + if (!in_array($value, $dict)) { + return '消息来源数据值无效'; + } + return true; + } + + public function checkFundSources($value): bool|string + { + if (empty($value)) return true; + $dict = DictData::where('type_value', 'cost_consultation_fund_sources')->column('value'); + if (!in_array($value, $dict)) { + return '资金来源数据值无效'; + } + return true; + } + + public function checkConstArea($value): bool|string + { + if (empty($value)) return true; + $dict = DictData::where('type_value', 'cost_consultation_const_area')->column('value'); + if (!in_array($value, $dict)) { + return '建设区域数据值无效'; + } + return true; + } + + public function checkHead($value): bool|string + { + if (empty($value)) return true; + $data = Admin::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '负责人数据不存在' : true; + } + + public function checkDept($value): bool|string + { + if (empty($value)) return true; + $data = Dept::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '负责部门数据不存在' : true; + } + + public function checkLeader($value): bool|string + { + if (empty($value)) return true; + $data = Admin::where('id', $value)->findOrEmpty(); + return $data->isEmpty() ? '分管领导数据不存在' : true; + } + } \ No newline at end of file diff --git a/app/common/model/marketing/MarketingBidEvaluation.php b/app/common/model/marketing/MarketingBidEvaluation.php new file mode 100644 index 000000000..0bc9a5c21 --- /dev/null +++ b/app/common/model/marketing/MarketingBidEvaluation.php @@ -0,0 +1,68 @@ +column('name', 'value'); + return !empty($data['bid_type']) ? $dict[$data['bid_type']] : ''; + } + + public function getBidNatureTextAttr($value, $data) + { + $dict = DictData::where('type_value', 'bid_nature')->column('name', 'value'); + return !empty($data['bid_nature']) ? $dict[$data['bid_nature']] : ''; + } + + public function getEndDateAttr($value): string + { + return !empty($value) ? date('Y-m-d', $value) : ''; + } + + public function getBidDateAttr($value): string + { + return !empty($value) ? date('Y-m-d', $value) : ''; + } + + public function getReviewStatusTextAttr($value, $data): string + { + $arr = [0 => '通过', 1 => '不通过']; + return $arr[$data['review_status']]; + } + + public function getRegResultTextAttr($value, $data): string + { + $arr = [0 => '通过', 1 => '不通过']; + return $arr[$data['reg_result']]; + } + } \ No newline at end of file diff --git a/app/common/model/marketing/MarketingBusinessOpportunity.php b/app/common/model/marketing/MarketingBusinessOpportunity.php new file mode 100644 index 000000000..7d43803ea --- /dev/null +++ b/app/common/model/marketing/MarketingBusinessOpportunity.php @@ -0,0 +1,75 @@ +column('name', 'value'); + return !empty($data['business_nature']) ? $dict[$data['business_nature']] : ''; + } + + public function getIndustryNatureTextAttr($value, $data) + { + $dict = DictData::where('type_value', 'cost_consultation_industry_nature')->column('name', 'value'); + return !empty($data['industry_nature']) ? $dict[$data['industry_nature']] : ''; + } + + public function getInfoSourcesTextAttr($value, $data) + { + $dict = DictData::where('type_value', 'info_sources')->column('name', 'value'); + return !empty($data['info_sources']) ? $dict[$data['info_sources']] : ''; + } + + public function getFundSourcesTextAttr($value, $data) + { + $dict = DictData::where('type_value', 'cost_consultation_fund_sources')->column('name', 'value'); + return !empty($data['fund_sources']) ? $dict[$data['fund_sources']] : ''; + } + + public function getConstAreaTextAttr($value, $data) + { + $dict = DictData::where('type_value', 'cost_consultation_const_area')->column('name', 'value'); + return !empty($data['const_area']) ? $dict[$data['const_area']] : ''; + } + + public function getStatusTextAttr($value, $data): string + { + $arr = [0 => '未启动投标', 1 => '参与投标']; + return $arr[$data['status']]; + } + + public function getBidDateAttr($value): string + { + return !empty($value) ? date('Y-m-d', $value) : ''; + } + } \ No newline at end of file