From cef2a033a6a7befa78bbb3c0f93dd9289136d829 Mon Sep 17 00:00:00 2001 From: weiz Date: Wed, 3 Jan 2024 16:33:09 +0800 Subject: [PATCH 1/2] update --- .../lists/custom/CustomServiceLists.php | 2 +- .../lists/custom/CustomerDemandLists.php | 5 +- .../lists/project/ProjectFollowUpLists.php | 12 +- app/adminapi/lists/project/ProjectLists.php | 33 ++- .../project/ProjectPreSalesMembersLists.php | 6 +- .../logic/custom/CustomerDemandLogic.php | 32 +-- .../logic/project/ProjectFollowUpLogic.php | 66 +++--- app/adminapi/logic/project/ProjectLogic.php | 134 +++++++----- .../project/ProjectPreSalesMembersLogic.php | 11 +- .../custom/CustomerDemandValidate.php | 45 ++-- .../project/ProjectFollowUpValidate.php | 42 ++-- .../validate/project/ProjectValidate.php | 194 ++++++++++++++++-- app/common/model/custom/CustomerDemand.php | 15 +- app/common/model/project/Project.php | 101 +++++++-- app/common/model/project/ProjectFollowUp.php | 10 + 15 files changed, 502 insertions(+), 206 deletions(-) diff --git a/app/adminapi/lists/custom/CustomServiceLists.php b/app/adminapi/lists/custom/CustomServiceLists.php index 50613379d..fc7e63e1b 100644 --- a/app/adminapi/lists/custom/CustomServiceLists.php +++ b/app/adminapi/lists/custom/CustomServiceLists.php @@ -70,7 +70,7 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf $item['classification'] = $item->classification_text; $item['processing_result'] = $item->processing_result_text; $item['urgency'] = $item->urgency_text; - $item['is_solve'] = $item->is_solve_text; + $item['is_solve_text'] = $item->is_solve_text; $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); $custom = Custom::field('name,master_name,master_phone')->where('id',$project['custom_id'])->findOrEmpty(); $contract = Contract::field('contract_code')->where('id',$item['contract_id'])->findOrEmpty(); diff --git a/app/adminapi/lists/custom/CustomerDemandLists.php b/app/adminapi/lists/custom/CustomerDemandLists.php index ea589e36c..4788cbff8 100644 --- a/app/adminapi/lists/custom/CustomerDemandLists.php +++ b/app/adminapi/lists/custom/CustomerDemandLists.php @@ -42,7 +42,7 @@ class CustomerDemandLists extends BaseAdminDataLists implements ListsSearchInter public function setSearch(): array { return [ - '=' => ['importance', 'recording_time'], + '=' => ['project_id','importance', 'recording_time'], '%like%' => ['theme', 'supplier', 'supplier_contacts'] ]; } @@ -75,12 +75,11 @@ class CustomerDemandLists extends BaseAdminDataLists implements ListsSearchInter ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ - $item['importance_text'] = $item->importance_text; - $item['recording_time'] = date('Y-m-d H:i:s',$item['recording_time']); $project = Project::field('name,custom_id')->where('id',$item['project_id'])->findOrEmpty(); $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty(); $item['project_name'] = $project['name']; $item['custom_name'] = $custom['name']; + $item['importance_text'] = $item->importance_text; return $item; }) ->toArray(); diff --git a/app/adminapi/lists/project/ProjectFollowUpLists.php b/app/adminapi/lists/project/ProjectFollowUpLists.php index 1fc0f59bd..2fa4319b4 100644 --- a/app/adminapi/lists/project/ProjectFollowUpLists.php +++ b/app/adminapi/lists/project/ProjectFollowUpLists.php @@ -41,7 +41,7 @@ class ProjectFollowUpLists extends BaseAdminDataLists implements ListsSearchInte public function setSearch(): array { return [ - '=' => ['follow_type', 'project_assurance', 'follow_status', 'follow_stage'], + '=' => ['project_id','follow_type', 'project_assurance', 'follow_status', 'follow_stage'], '%like%' => ['executor','theme','contacts','contact_information'], ]; } @@ -74,16 +74,14 @@ class ProjectFollowUpLists extends BaseAdminDataLists implements ListsSearchInte ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ - $item['follow_type_text'] = $item->follow_type_text; - $item['project_assurance_text'] = $item->project_assurance_text; - $item['follow_status_text'] = $item->follow_status_text; - $item['follow_stage_text'] = $item->follow_stage_text; - $item['follow_date'] = !empty($item['follow_date']) ? date('Y-m-d',$item['follow_date']) : ''; - $item['next_follow_up_date'] = !empty($item['next_follow_up_date']) ? date('Y-m-d',$item['next_follow_up_date']) : ''; $project = Project::field('id,custom_id,name')->where('id',$item['project_id'])->findOrEmpty(); $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty(); $item['project_name'] = $project['name']; $item['custom_name'] = $custom['name']; + $item['follow_type_text'] = $item->follow_type_text; + $item['project_assurance_text'] = $item->project_assurance_text; + $item['follow_status_text'] = $item->follow_status_text; + $item['follow_stage_text'] = $item->follow_stage_text; return $item; }) ->toArray(); diff --git a/app/adminapi/lists/project/ProjectLists.php b/app/adminapi/lists/project/ProjectLists.php index 8ebeaf161..29ef818fe 100644 --- a/app/adminapi/lists/project/ProjectLists.php +++ b/app/adminapi/lists/project/ProjectLists.php @@ -17,6 +17,8 @@ namespace app\adminapi\lists\project; use app\adminapi\lists\BaseAdminDataLists; use app\common\model\custom\Custom; +use app\common\model\dept\Dept; +use app\common\model\dept\Orgs; use app\common\model\project\Project; use app\common\lists\ListsSearchInterface; use app\common\model\project\ProjectTypeSet; @@ -40,7 +42,7 @@ class ProjectLists extends BaseAdminDataLists implements ListsSearchInterface public function setSearch(): array { return [ - '=' => ['custom_id', 'status','project_type','strategic_significance','industry','unit_nature','bidding_method','information_sources'], + '=' => ['custom_id','status','project_type','project_content','strategic_significance','industry','unit_nature','information_sources'], '%like%' => ['project_code','name','project_address','person'] ]; } @@ -64,14 +66,29 @@ class ProjectLists extends BaseAdminDataLists implements ListsSearchInterface $condition[] = ['custom_id','in',$customIds]; } return Project::where($this->searchWhere)->where($condition) - ->field(['id','custom_id','project_code','name','status','contacts','telephone','project_address','project_type','strategic_significance','industry','unit_nature','bidding_method','information_sources','person']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ + $org = Orgs::field('name')->where('id',$item['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$item['dept_id'])->findOrEmpty(); $projectType = ProjectTypeSet::where('id',$item['project_type'])->findOrEmpty(); $custom = Custom::field('name')->where('id',$item['custom_id'])->findOrEmpty(); - $item['custom_name'] = $custom->isEmpty() ? '' : $custom['name']; - $item['project_type_name'] = $projectType->isEmpty() ? '' : $projectType['name']; + $item['org_name'] = $org['name']; + $item['dept_name'] = $dept['name']; + $item['custom_name'] = $custom['name']; + $item['project_type'] = $projectType['name']; + $item['status'] = $item->status_text; + $item['project_content'] = $item->project_content_text; + $item['bidding_method'] = $item->bidding_method_text; + $item['relationship'] = $item->relationship_text; + $item['information_sources'] = $item->information_sources_text; + $item['construction_funds_sources'] = $item->construction_funds_sources_text; + $item['construction_financial_status'] = $item->construction_financial_status_text; + $item['construction_recognition'] = $item->construction_recognition_text; + $item['my_construction_recognition'] = $item->my_construction_recognition_text; + $item['strategic_significance'] = $item->strategic_significance_text; + $item['industry'] = $item->industry_text; + $item['unit_nature'] = $item->unit_nature_text; return $item; }) ->toArray(); @@ -86,7 +103,13 @@ class ProjectLists extends BaseAdminDataLists implements ListsSearchInterface */ public function count(): int { - return Project::where($this->searchWhere)->count(); + $params = $this->request->param(); + $condition = []; + if(isset($params['custom_name']) && $params['custom_name'] != ''){ + $customIds = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id'); + $condition[] = ['custom_id','in',$customIds]; + } + return Project::where($this->searchWhere)->where($condition)->count(); } } \ No newline at end of file diff --git a/app/adminapi/lists/project/ProjectPreSalesMembersLists.php b/app/adminapi/lists/project/ProjectPreSalesMembersLists.php index 91b4d4a1c..7a245ccdb 100644 --- a/app/adminapi/lists/project/ProjectPreSalesMembersLists.php +++ b/app/adminapi/lists/project/ProjectPreSalesMembersLists.php @@ -69,7 +69,7 @@ class ProjectPreSalesMembersLists extends BaseAdminDataLists implements ListsSea $where[] = ['project_id','in',$projectIds]; } return ProjectPreSalesMembers::where($this->searchWhere)->where($where) - ->field(['id,project_id,technician_ids,business_people_ids,cross_departmental_personnel_ids,add_people,create_time']) + ->field(['id,project_id,technician_ids,business_people_ids,cross_departmental_personnel_ids,add_user,create_time']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ @@ -78,13 +78,13 @@ class ProjectPreSalesMembersLists extends BaseAdminDataLists implements ListsSea $technician = Admin::where('id','in',$item['technician_ids'])->column('name'); $business_people = Admin::where('id','in',$item['business_people_ids'])->column('name'); $cross_departmental_personnel = Admin::where('id','in',$item['cross_departmental_personnel_ids'])->column('name'); - $add_people = Admin::field('name')->where('id',$item['add_people'])->findOrEmpty(); + $add_user = Admin::field('name')->where('id',$item['add_user'])->findOrEmpty(); $item['project_name'] = $project['name']; $item['custom_name'] = $custom['name']; $item['technician'] = implode(',',$technician); $item['business_people'] = implode(',',$business_people); $item['cross_departmental_personnel'] = implode(',',$cross_departmental_personnel); - $item['add_people'] = $add_people['name']; + $item['add_user'] = $add_user['name']; unset($item['technician_ids'],$item['business_people_ids'],$item['cross_departmental_personnel_ids']); }) ->toArray(); diff --git a/app/adminapi/logic/custom/CustomerDemandLogic.php b/app/adminapi/logic/custom/CustomerDemandLogic.php index 7514ad2a0..8d333d731 100644 --- a/app/adminapi/logic/custom/CustomerDemandLogic.php +++ b/app/adminapi/logic/custom/CustomerDemandLogic.php @@ -49,12 +49,12 @@ class CustomerDemandLogic extends BaseLogic 'dept_id' => $params['dept_id'], 'project_id' => $params['project_id'], 'theme' => $params['theme'], - 'supplier' => $params['supplier'], - 'supplier_contacts' => $params['supplier_contacts'], + 'supplier' => $params['supplier'] ?? '', + 'supplier_contacts' => $params['supplier_contacts'] ?? '', 'importance' => $params['importance'], 'recording_time' => strtotime($params['recording_time']), - 'demand_content' => $params['demand_content'], - 'annex' => $params['annex'] + 'demand_content' => $params['demand_content'] ?? '', + 'annex' => !empty($params['annex']) ? $params['annex'] : null, ]); Db::commit(); return true; @@ -78,16 +78,17 @@ class CustomerDemandLogic extends BaseLogic Db::startTrans(); try { CustomerDemand::where('id', $params['id'])->update([ - 'org_id' => $params['org_id'], - 'dept_id' => $params['dept_id'], - 'project_id' => $params['project_id'], - 'theme' => $params['theme'], - 'supplier' => $params['supplier'], - 'supplier_contacts' => $params['supplier_contacts'], - 'importance' => $params['importance'], - 'recording_time' => strtotime($params['recording_time']), - 'demand_content' => $params['demand_content'], - 'annex' => $params['annex'] + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'project_id' => $params['project_id'], + 'theme' => $params['theme'], + 'supplier' => $params['supplier'] ?? '', + 'supplier_contacts' => $params['supplier_contacts'] ?? '', + 'importance' => $params['importance'], + 'recording_time' => strtotime($params['recording_time']), + 'demand_content' => $params['demand_content'] ?? '', + 'annex' => !empty($params['annex']) ? $params['annex'] : null, + 'update_time' => time(), ]); Db::commit(); return true; @@ -122,8 +123,6 @@ class CustomerDemandLogic extends BaseLogic public static function detail($params): array { $data = CustomerDemand::field('id,org_id,dept_id,project_id,theme,supplier,supplier_contacts,importance,recording_time,demand_content,annex')->findOrEmpty($params['id']); - $data['importance_text'] = $data->importance_text; - $data['recording_time'] = date('Y-m-d H:i:s',$data['recording_time']); $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); $project = Project::field('name,project_code,custom_id')->where('id',$data['project_id'])->findOrEmpty(); @@ -133,6 +132,7 @@ class CustomerDemandLogic extends BaseLogic $data['project_name'] = $project['name']; $data['project_code'] = $project['project_code']; $data['custom_name'] = $custom['name']; + $data['importance_text'] = $data->importance_text; return $data->toArray(); } } \ No newline at end of file diff --git a/app/adminapi/logic/project/ProjectFollowUpLogic.php b/app/adminapi/logic/project/ProjectFollowUpLogic.php index bcbae7827..fd1cec9ef 100644 --- a/app/adminapi/logic/project/ProjectFollowUpLogic.php +++ b/app/adminapi/logic/project/ProjectFollowUpLogic.php @@ -44,22 +44,26 @@ class ProjectFollowUpLogic extends BaseLogic try { ProjectFollowUp::create([ 'project_id' => $params['project_id'], - 'executor' => $params['executor'], - 'contacts' => $params['contacts'], - 'contact_information' => $params['contact_information'], - 'project_role' => $params['project_role'], - 'position' => $params['position'], + 'executor' => $params['executor'] ?? '', + 'contacts' => $params['contacts'] ?? '', + 'contact_information' => $params['contact_information'] ?? '', + 'project_role' => $params['project_role'] ?? '', + 'position' => $params['position'] ?? '', 'follow_date' => strtotime($params['follow_date']), 'follow_type' => $params['follow_type'], 'theme' => $params['theme'], - 'action_description' => $params['action_description'], + 'action_description' => $params['action_description'] ?? '', 'project_assurance' => $params['project_assurance'], 'follow_status' => $params['follow_status'], 'follow_stage' => $params['follow_stage'], - 'notes' => $params['notes'], - 'next_follow_up_date' => strtotime($params['next_follow_up_date']), - 'file' => $params['file'] + 'notes' => $params['notes'] ?? '', + 'next_follow_up_date' => !empty($params['next_follow_up_date']) ? strtotime($params['next_follow_up_date']) : 0, + 'file' => !empty($params['file']) ? $params['file'] : null, ]); + Project::where('id', $params['project_id'])->update([ + 'status' => 6, + 'update_time' => time() + ]); Db::commit(); return true; } catch (\Exception $e) { @@ -82,22 +86,23 @@ class ProjectFollowUpLogic extends BaseLogic Db::startTrans(); try { ProjectFollowUp::where('id', $params['id'])->update([ - 'project_id' => $params['project_id'], - 'executor' => $params['executor'], - 'contacts' => $params['contacts'], - 'contact_information' => $params['contact_information'], - 'project_role' => $params['project_role'], - 'position' => $params['position'], - 'follow_date' => strtotime($params['follow_date']), - 'follow_type' => $params['follow_type'], - 'theme' => $params['theme'], - 'action_description' => $params['action_description'], - 'project_assurance' => $params['project_assurance'], - 'follow_status' => $params['follow_status'], - 'follow_stage' => $params['follow_stage'], - 'notes' => $params['notes'], - 'next_follow_up_date' => strtotime($params['next_follow_up_date']), - 'file' => $params['file'] + 'project_id' => $params['project_id'], + 'executor' => $params['executor'] ?? '', + 'contacts' => $params['contacts'] ?? '', + 'contact_information' => $params['contact_information'] ?? '', + 'project_role' => $params['project_role'] ?? '', + 'position' => $params['position'] ?? '', + 'follow_date' => strtotime($params['follow_date']), + 'follow_type' => $params['follow_type'], + 'theme' => $params['theme'], + 'action_description' => $params['action_description'] ?? '', + 'project_assurance' => $params['project_assurance'], + 'follow_status' => $params['follow_status'], + 'follow_stage' => $params['follow_stage'], + 'notes' => $params['notes'] ?? '', + 'next_follow_up_date' => !empty($params['next_follow_up_date']) ? strtotime($params['next_follow_up_date']) : 0, + 'file' => !empty($params['file']) ? $params['file'] : null, + 'update_time' => time(), ]); Db::commit(); return true; @@ -132,18 +137,15 @@ class ProjectFollowUpLogic extends BaseLogic public static function detail($params): array { $data = ProjectFollowUp::findOrEmpty($params['id']); - $data['follow_type_text'] = $data->follow_type_text; - $data['project_assurance_text'] = $data->project_assurance_text; - $data['follow_status_text'] = $data->follow_status_text; - $data['follow_stage_text'] = $data->follow_stage_text; - $data['follow_date'] = !empty($data['follow_date']) ? date('Y-m-d',$data['follow_date']) : ''; - $data['next_follow_up_date'] = !empty($data['next_follow_up_date']) ? date('Y-m-d',$data['next_follow_up_date']) : ''; $project = Project::field('id,custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty(); $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty(); $data['project_name'] = $project['name']; $data['project_code'] = $project['project_code']; $data['custom_name'] = $custom['name']; - unset($data['delete_time']); + $data['follow_type_text'] = $data->follow_type_text; + $data['project_assurance_text'] = $data->project_assurance_text; + $data['follow_status_text'] = $data->follow_status_text; + $data['follow_stage_text'] = $data->follow_stage_text; return $data->toArray(); } } \ No newline at end of file diff --git a/app/adminapi/logic/project/ProjectLogic.php b/app/adminapi/logic/project/ProjectLogic.php index a89c19b34..dd2c03b01 100644 --- a/app/adminapi/logic/project/ProjectLogic.php +++ b/app/adminapi/logic/project/ProjectLogic.php @@ -16,6 +16,8 @@ namespace app\adminapi\logic\project; use app\common\model\custom\Custom; +use app\common\model\dept\Dept; +use app\common\model\dept\Orgs; use app\common\model\project\Project; use app\common\logic\BaseLogic; use app\common\model\project\ProjectTypeSet; @@ -43,38 +45,39 @@ class ProjectLogic extends BaseLogic Db::startTrans(); try { Project::create([ + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], 'custom_id' => $params['custom_id'], 'name' => $params['name'], 'project_type' => $params['project_type'], 'project_code' => data_unique_code('P'), - 'project_content' => $params['project_content'], - 'project_estimation' => $params['project_estimation'], - 'project_address' => $params['project_address'], - 'estimated_construction' => $params['estimated_construction'], - 'bidding_time' => strtotime($params['bidding_time']), - 'bidding_method' => $params['bidding_method'], - 'contacts' => $params['contacts'], - 'position' => $params['position'], - 'telephone' => $params['telephone'], - 'department' => $params['department'], - 'person' => $params['person'], - 'relationship' => $params['relationship'], + 'project_content' => $params['project_content'] ?? 0, + 'project_estimation' => $params['project_estimation'] ?? 0, + 'project_address' => $params['project_address'] ?? '', + 'estimated_construction' => $params['estimated_construction'] ?? '', + 'bidding_time' => !empty($params['bidding_time']) ? strtotime($params['bidding_time']) : 0, + 'bidding_method' => $params['bidding_method'] ?? 0, + 'contacts' => $params['contacts'] ?? '', + 'position' => $params['position'] ?? '', + 'telephone' => $params['telephone'] ?? '', + 'department' => $params['department'] ?? '', + 'person' => $params['person'] ?? '', + 'relationship' => $params['relationship'] ?? 0, 'discovery_time' => strtotime($params['discovery_time']), 'information_sources' => $params['information_sources'], - 'competitor' => $params['competitor'], - 'construction_funds_sources' => $params['construction_funds_sources'], - 'construction_payment_method' => $params['construction_payment_method'], - 'construction_financial_status' => $params['construction_financial_status'], - 'construction_recognition' => $params['construction_recognition'], - 'my_construction_recognition' => $params['my_construction_recognition'], - 'strategic_significance' => $params['strategic_significance'], - 'industry' => $params['industry'], - 'unit_nature' => $params['unit_nature'], - 'annex' => $params['annex'], - 'status' => 0, + 'competitor' => $params['competitor'] ?? '', + 'construction_funds_sources' => $params['construction_funds_sources'] ?? 0, + 'construction_payment_method' => $params['construction_payment_method'] ?? '', + 'construction_financial_status' => $params['construction_financial_status'] ?? 0, + 'construction_recognition' => $params['construction_recognition'] ?? 0, + 'my_construction_recognition' => $params['my_construction_recognition'] ?? 0, + 'strategic_significance' => $params['strategic_significance'] ?? 0, + 'industry' => $params['industry'] ?? 0, + 'unit_nature' => $params['unit_nature'] ?? 0, + 'annex' => $params['annex'] ?? null, + 'status' => 1, 'add_user' => $adminId ]); - Db::commit(); return true; } catch (\Exception $e) { @@ -97,35 +100,38 @@ class ProjectLogic extends BaseLogic Db::startTrans(); try { Project::where('id', $params['id'])->update([ - 'custom_id' => $params['custom_id'], + 'org_id' => $params['org_id'], + 'dept_id' => $params['dept_id'], + 'custom_id' => $params['custom_id'], 'name' => $params['name'], - 'project_type' => $params['project_type'], - 'project_content' => $params['project_content'], - 'project_estimation' => $params['project_estimation'], - 'project_address' => $params['project_address'], - 'estimated_construction' => $params['estimated_construction'], - 'bidding_time' => strtotime($params['bidding_time']), - 'bidding_method' => $params['bidding_method'], - 'contacts' => $params['contacts'], - 'position' => $params['position'], - 'telephone' => $params['telephone'], - 'department' => $params['department'], - 'person' => $params['person'], - 'relationship' => $params['relationship'], - 'discovery_time' => strtotime($params['discovery_time']), - 'information_sources' => $params['information_sources'], - 'competitor' => $params['competitor'], - 'construction_funds_sources' => $params['construction_funds_sources'], - 'construction_payment_method' => $params['construction_payment_method'], - 'construction_financial_status' => $params['construction_financial_status'], - 'construction_recognition' => $params['construction_recognition'], - 'my_construction_recognition' => $params['my_construction_recognition'], - 'strategic_significance' => $params['strategic_significance'], - 'industry' => $params['industry'], - 'unit_nature' => $params['unit_nature'], - 'annex' => $params['annex'], + 'project_type' => $params['project_type'], + 'project_code' => data_unique_code('P'), + 'project_content' => $params['project_content'] ?? 0, + 'project_estimation' => $params['project_estimation'] ?? 0, + 'project_address' => $params['project_address'] ?? '', + 'estimated_construction' => $params['estimated_construction'] ?? '', + 'bidding_time' => !empty($params['bidding_time']) ? strtotime($params['bidding_time']) : 0, + 'bidding_method' => $params['bidding_method'] ?? 0, + 'contacts' => $params['contacts'] ?? '', + 'position' => $params['position'] ?? '', + 'telephone' => $params['telephone'] ?? '', + 'department' => $params['department'] ?? '', + 'person' => $params['person'] ?? '', + 'relationship' => $params['relationship'] ?? 0, + 'discovery_time' => strtotime($params['discovery_time']), + 'information_sources' => $params['information_sources'], + 'competitor' => $params['competitor'] ?? '', + 'construction_funds_sources' => $params['construction_funds_sources'] ?? 0, + 'construction_payment_method' => $params['construction_payment_method'] ?? '', + 'construction_financial_status' => $params['construction_financial_status'] ?? 0, + 'construction_recognition' => $params['construction_recognition'] ?? 0, + 'my_construction_recognition' => $params['my_construction_recognition'] ?? 0, + 'strategic_significance' => $params['strategic_significance'] ?? 0, + 'industry' => $params['industry'] ?? 0, + 'unit_nature' => $params['unit_nature'] ?? 0, + 'annex' => $params['annex'] ?? null, + 'update_time' => time(), ]); - Db::commit(); return true; } catch (\Exception $e) { @@ -158,11 +164,27 @@ class ProjectLogic extends BaseLogic */ public static function detail($params): array { - $data = Project::findOrEmpty($params['id'])->toArray(); - $projectType = ProjectTypeSet::where('id',$data['project_type'])->findOrEmpty(); + $data = Project::findOrEmpty($params['id']); + $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); + $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); + $projectType = ProjectTypeSet::field('name')->where('id',$data['project_type'])->findOrEmpty(); $custom = Custom::field('name')->where('id',$data['custom_id'])->findOrEmpty(); - $data['custom_name'] = $custom->isEmpty() ? '' : $custom['name']; - $data['project_type_name'] = $projectType->isEmpty() ? '' : $projectType['name']; - return $data; + $data['org_name'] = $org['name']; + $data['dept_name'] = $dept['name']; + $data['custom_name'] = $custom['name']; + $data['project_type_name'] = $projectType['name']; + $data['status_text'] = $data->status_text; + $data['project_content_text'] = $data->project_content_text; + $data['bidding_method_text'] = $data->bidding_method_text; + $data['relationship_text'] = $data->relationship_text; + $data['information_sources_text'] = $data->information_sources_text; + $data['construction_funds_sources_text'] = $data->construction_funds_sources_text; + $data['construction_financial_status_text'] = $data->construction_financial_status_text; + $data['construction_recognition_text'] = $data->construction_recognition_text; + $data['my_construction_recognition_text'] = $data->my_construction_recognition_text; + $data['strategic_significance_text'] = $data->strategic_significance_text; + $data['industry_text'] = $data->industry_text; + $data['unit_nature_text'] = $data->unit_nature_text; + return $data->toArray(); } } \ No newline at end of file diff --git a/app/adminapi/logic/project/ProjectPreSalesMembersLogic.php b/app/adminapi/logic/project/ProjectPreSalesMembersLogic.php index be1dc6102..57f538680 100644 --- a/app/adminapi/logic/project/ProjectPreSalesMembersLogic.php +++ b/app/adminapi/logic/project/ProjectPreSalesMembersLogic.php @@ -39,7 +39,7 @@ class ProjectPreSalesMembersLogic extends BaseLogic * @author likeadmin * @date 2023/11/14 10:15 */ - public static function add(array $params,$adminId = 0): bool + public static function add(array $params,$admin_id): bool { Db::startTrans(); try { @@ -48,7 +48,7 @@ class ProjectPreSalesMembersLogic extends BaseLogic 'technician_ids' => trim($params['technician_ids'],','), 'business_people_ids' => trim($params['business_people_ids'],','), 'cross_departmental_personnel_ids' => trim($params['cross_departmental_personnel_ids'],','), - 'add_people' => $adminId + 'add_user' => $admin_id ]); Db::commit(); return true; @@ -76,6 +76,7 @@ class ProjectPreSalesMembersLogic extends BaseLogic 'technician_ids' => trim($params['technician_ids'],','), 'business_people_ids' => trim($params['business_people_ids'],','), 'cross_departmental_personnel_ids' => trim($params['cross_departmental_personnel_ids'],','), + 'update_time' => time() ]); Db::commit(); return true; @@ -109,19 +110,19 @@ class ProjectPreSalesMembersLogic extends BaseLogic */ public static function detail($params): array { - $data = ProjectPreSalesMembers::field('id,project_id,technician_ids,business_people_ids,cross_departmental_personnel_ids,add_people,create_time')->findOrEmpty($params['id'])->toArray(); + $data = ProjectPreSalesMembers::field('id,project_id,technician_ids,business_people_ids,cross_departmental_personnel_ids,add_user,create_time')->findOrEmpty($params['id'])->toArray(); $project = Project::field('id,custom_id,name')->where('id',$data['project_id'])->findOrEmpty(); $custom = Custom::field('id,name')->where('id',$project['custom_id'])->findOrEmpty(); $technician = Admin::where('id','in',$data['technician_ids'])->column('name'); $business_people = Admin::where('id','in',$data['business_people_ids'])->column('name'); $cross_departmental_personnel = Admin::where('id','in',$data['cross_departmental_personnel_ids'])->column('name'); - $add_people = Admin::field('name')->where('id',$data['add_people'])->findOrEmpty(); + $add_user = Admin::field('name')->where('id',$data['add_user'])->findOrEmpty(); $data['project_name'] = $project['name']; $data['custom_name'] = $custom['name']; $data['technician'] = implode(',',$technician); $data['business_people'] = implode(',',$business_people); $data['cross_departmental_personnel'] = implode(',',$cross_departmental_personnel); - $data['add_people'] = $add_people['name']; + $data['add_user_name'] = $add_user['name']; return $data; } } \ No newline at end of file diff --git a/app/adminapi/validate/custom/CustomerDemandValidate.php b/app/adminapi/validate/custom/CustomerDemandValidate.php index 6c8cfce91..844e73bc8 100644 --- a/app/adminapi/validate/custom/CustomerDemandValidate.php +++ b/app/adminapi/validate/custom/CustomerDemandValidate.php @@ -17,6 +17,7 @@ namespace app\adminapi\validate\custom; use app\common\model\dept\Dept; use app\common\model\dept\Orgs; +use app\common\model\dict\DictData; use app\common\model\project\Project; use app\common\validate\BaseValidate; @@ -39,8 +40,9 @@ class CustomerDemandValidate extends BaseValidate 'dept_id' => 'require|checkDept', 'project_id' => 'require|checkProject', 'theme' => 'require', - 'importance' => 'integer|in:1,2,3,4', - 'recording_time' => 'date', + 'importance' => 'require|checkImportance', + 'recording_time' => 'require|dateFormat:Y-m-d', + 'annex' => 'checkAnnex' ]; protected $message = [ @@ -49,21 +51,11 @@ class CustomerDemandValidate extends BaseValidate 'dept_id.require' => '请选择部门', 'project_id.require' => '请选择项目', 'theme.require' => '请填写需求主题', - 'importance.integer' => '重要程度数据格式错误', - 'importance.in' => '重要程度数据值错误', - 'recording_time.date' => '记录时间数据格式错误', + 'importance.require' => '请选择重要程度', + 'recording_time.require' => '请选择记录时间', + 'recording_time.dateFormat' => '记录时间数据格式错误', ]; - - /** - * 参数描述 - * @var string[] - */ - protected $field = [ - 'id' => 'id', - ]; - - /** * @notes 添加场景 * @return CustomerDemandValidate @@ -83,8 +75,7 @@ class CustomerDemandValidate extends BaseValidate * @date 2023/11/24 21:18 */ public function sceneEdit() - { - } + {} /** @@ -139,5 +130,25 @@ class CustomerDemandValidate extends BaseValidate } return true; } + + public function checkImportance($value): bool|string + { + $dictData = DictData::where('type_value','importance')->column('value'); + if(!in_array($value,$dictData)){ + return '类型无效'; + } + return true; + } + + public function checkAnnex($value): bool|string + { + if(!empty($value) && $value != ''){ + $annex = json_decode($value,true); + if(empty($annex) || !is_array($annex)){ + return '附件格式错误'; + } + } + return true; + } } \ No newline at end of file diff --git a/app/adminapi/validate/project/ProjectFollowUpValidate.php b/app/adminapi/validate/project/ProjectFollowUpValidate.php index 1c5d6b76b..141488b6f 100644 --- a/app/adminapi/validate/project/ProjectFollowUpValidate.php +++ b/app/adminapi/validate/project/ProjectFollowUpValidate.php @@ -37,12 +37,13 @@ class ProjectFollowUpValidate extends BaseValidate 'id' => 'require', 'project_id' => 'require|checkProject', 'theme' => 'require', - 'follow_date' => 'require|date', + 'follow_date' => 'require|dateFormat:Y-m-d', 'follow_type' => 'require|checkType', 'project_assurance' => 'require|checkAssurance', 'follow_status' => 'require|checkStatus', 'follow_stage' => 'require|checkStage', - 'next_follow_up_date' => 'date|checkDate' + 'next_follow_up_date' => 'date|dateFormat:Y-m-d|checkNextFollowUpDate', + 'file' => 'checkFile', ]; protected $message = [ @@ -50,22 +51,13 @@ class ProjectFollowUpValidate extends BaseValidate 'project_id.require' => '请选择项目', 'theme.require' => '请填写主题', 'follow_date.require' => '请选择日期', - 'follow_date.date' => '日期格式错误', + 'follow_date.dateFormat' => '日期格式错误', 'follow_type.require' => '请选择类型', 'project_assurance.require' => '请选择项目把握度', 'follow_status.require' => '请选择状态', 'follow_stage.require' => '请选择阶段', - 'next_follow_up_date.date' => '下次回访日期格式错误' + 'next_follow_up_date.dateFormat' => '下次回访日期格式错误' ]; - - /** - * 参数描述 - * @var string[] - */ - protected $field = [ - 'id' => 'id', - ]; - /** * @notes 添加场景 @@ -86,9 +78,7 @@ class ProjectFollowUpValidate extends BaseValidate * @date 2023/11/14 10:49 */ public function sceneEdit() - { - - } + {} /** @@ -155,9 +145,23 @@ class ProjectFollowUpValidate extends BaseValidate return true; } - public function checkDate($value,$rule,$data) { - if(strtotime($value) < strtotime($data['follow_date'])){ - return '下次回访日期不能小于项目跟进日期'; + public function checkNextFollowUpDate($value,$rule,$data): bool|string + { + if(!empty($value)){ + if(strtotime($value) < strtotime($data['follow_date'])){ + return '下次回访日期不能小于项目跟进日期'; + } + } + return true; + } + + public function checkFile($value): bool|string + { + if(!empty($value) && $value != ''){ + $annex = json_decode($value,true); + if(empty($annex) || !is_array($annex)){ + return '附件格式错误'; + } } return true; } diff --git a/app/adminapi/validate/project/ProjectValidate.php b/app/adminapi/validate/project/ProjectValidate.php index ec7050c2d..c7b52552c 100644 --- a/app/adminapi/validate/project/ProjectValidate.php +++ b/app/adminapi/validate/project/ProjectValidate.php @@ -15,6 +15,11 @@ namespace app\adminapi\validate\project; +use app\common\model\custom\Custom; +use app\common\model\dept\Dept; +use app\common\model\dept\Orgs; +use app\common\model\dict\DictData; +use app\common\model\project\ProjectTypeSet; use app\common\validate\BaseValidate; @@ -32,35 +37,37 @@ class ProjectValidate extends BaseValidate */ protected $rule = [ 'id' => 'require', - 'custom_id' => 'require|integer', - 'project_type' => 'require|integer', + 'org_id' => 'require|checkOrg', + 'dept_id' => 'require|checkDept', + 'custom_id' => 'require|checkCustom', + 'project_type' => 'require|checkProjectType', 'name' => 'require', - 'discovery_time' => 'require', - 'information_sources' => 'require|integer' + 'project_content' => 'checkProjectContent', + 'bidding_time' => 'dateFormat:Y-m-d', + 'bidding_method' => 'checkBidMethod', + 'relationship' => 'checkRelationship', + 'discovery_time' => 'require|dateFormat:Y-m-d', + 'information_sources' => 'require|checkInfoSource', + 'construction_funds_sources' => 'checkFundSource', + 'construction_financial_status' => 'checkFinancialStatus', + 'construction_recognition' => 'checkConstructionRecognition', + 'my_construction_recognition' => 'checkMyConstructionRecognition', + 'strategic_significance' => 'checkStrategicSignificance', + 'industry' => 'checkIndustry', + 'unit_nature' => 'checkUnitNature', + 'annex' => 'checkAnnex', ]; protected $message = [ - 'id.require' => '缺少数据主键', + 'id.require' => '缺少必要参数', 'custom_id.require' => '请选择客户', - 'custom_id.integer' => '客户数据格式错误', 'project_type.require' => '请选择工程类型', - 'project_type.integer' => '工程类型据格式错误', 'name.require' => '请填写工程名称', 'discovery_time.require' => '请选择发现时间', 'information_sources.require' => '请选择信息来源', - 'information_sources.integer' => '信息来源据格式错误', ]; - /** - * 参数描述 - * @var string[] - */ - protected $field = [ - 'id' => 'id', - ]; - - /** * @notes 添加场景 * @return ProjectValidate @@ -80,9 +87,7 @@ class ProjectValidate extends BaseValidate * @date 2023/11/12 14:30 */ public function sceneEdit() - { - return $this->append(['id']); - } + {} /** @@ -107,5 +112,154 @@ class ProjectValidate extends BaseValidate { return $this->only(['id']); } + + public function checkOrg($value): bool|string + { + $org = Orgs::where('id',$value)->findOrEmpty(); + if($org->isEmpty()){ + return '组织不存在'; + } + return true; + } + + public function checkDept($value,$rule,$data): bool|string + { + $dept = Dept::where('id',$value)->findOrEmpty(); + if($dept->isEmpty()){ + return '部门不存在'; + } + if($dept['org_id'] != $data['org_id']){ + return '部门无效'; + } + return true; + } + + public function checkCustom($value): bool|string + { + $custom = Custom::where('id',$value)->findOrEmpty(); + if($custom->isEmpty()){ + return '客户不存在'; + } + return true; + } + + public function checkProjectType($value): bool|string + { + $project_type = ProjectTypeSet::where('id',$value)->findOrEmpty(); + if($project_type->isEmpty()){ + return '项目类型不存在'; + } + return true; + } + + public function checkProjectContent($value): bool|string + { + $dictData = DictData::where('type_value','project_content')->column('value'); + if(!in_array($value,$dictData)){ + return '项目内容无效'; + } + return true; + } + + public function checkBidMethod($value): bool|string + { + $dictData = DictData::where('type_value','bidding_method')->column('value'); + if(!in_array($value,$dictData)){ + return '招标方式无效'; + } + return true; + } + + public function checkRelationship($value): bool|string + { + $dictData = DictData::where('type_value','relationship')->column('value'); + if(!in_array($value,$dictData)){ + return '关系度无效'; + } + return true; + } + + public function checkInfoSource($value): bool|string + { + $dictData = DictData::where('type_value','information_sources')->column('value'); + if(!in_array($value,$dictData)){ + return '信息来源无效'; + } + return true; + } + + public function checkFundSource($value): bool|string + { + $dictData = DictData::where('type_value','construction_funds_sources')->column('value'); + if(!in_array($value,$dictData)){ + return '项目建设资金来源无效'; + } + return true; + } + + public function checkFinancialStatus($value): bool|string + { + $dictData = DictData::where('type_value','construction_financial_status')->column('value'); + if(!in_array($value,$dictData)){ + return '建设方财务状况无效'; + } + return true; + } + + public function checkConstructionRecognition($value): bool|string + { + $dictData = DictData::where('type_value','construction_recognition')->column('value'); + if(!in_array($value,$dictData)){ + return '建设方对我方认可度无效'; + } + return true; + } + + public function checkMyConstructionRecognition($value): bool|string + { + $dictData = DictData::where('type_value','my_construction_recognition')->column('value'); + if(!in_array($value,$dictData)){ + return '我方对建设方认可度无效'; + } + return true; + } + + public function checkStrategicSignificance($value): bool|string + { + $dictData = DictData::where('type_value','strategic_significance')->column('value'); + if(!in_array($value,$dictData)){ + return '战略意义无效'; + } + return true; + } + + public function checkIndustry($value): bool|string + { + $dictData = DictData::where('type_value','industry')->column('value'); + if(!in_array($value,$dictData)){ + return '所属行业无效'; + } + return true; + } + + public function checkUnitNature($value): bool|string + { + $dictData = DictData::where('type_value','unit_nature')->column('value'); + if(!in_array($value,$dictData)){ + return '单位性质无效'; + } + return true; + } + + public function checkAnnex($value): bool|string + { + if(!empty($value) && $value != ''){ + $annex = json_decode($value,true); + if(empty($annex) || !is_array($annex)){ + return '附件格式错误'; + } + } + return true; + } } \ No newline at end of file diff --git a/app/common/model/custom/CustomerDemand.php b/app/common/model/custom/CustomerDemand.php index 993c37312..a0c1ad3ff 100644 --- a/app/common/model/custom/CustomerDemand.php +++ b/app/common/model/custom/CustomerDemand.php @@ -16,6 +16,7 @@ namespace app\common\model\custom; use app\common\model\BaseModel; +use app\common\model\dict\DictData; use think\model\concern\SoftDelete; @@ -32,7 +33,17 @@ class CustomerDemand extends BaseModel public function getImportanceTextAttr($value,$data): string { - $res = [1=>'非常重要',2=>'重要',3=>'一般',4=>'不重要']; - return $res[$data['importance']]; + $dictData = DictData::where('type_value','importance')->column('name','value'); + return $dictData[$data['importance']]; + } + + public function getRecordingTimeAttr($value): string + { + return empty($value) ? '' : date('Y-m-d', $value); + } + + public function getAnnexAttr($value) + { + return empty($value) ? null : json_decode($value,true); } } \ No newline at end of file diff --git a/app/common/model/project/Project.php b/app/common/model/project/Project.php index 5e08e672b..4f0e979e3 100644 --- a/app/common/model/project/Project.php +++ b/app/common/model/project/Project.php @@ -31,29 +31,90 @@ class Project extends BaseModel protected $name = 'project'; protected $deleteTime = 'delete_time'; - public function getStatusAttr($value) + public function getStatusTextAttr($value,$data) { - $project_status = DictData::field('name,value')->where('type_id',39)->select(); - $status = []; - foreach ($project_status as $v) { - $status[$v['value']] = $v['name']; - } - return $status[$value]; + $dictData = DictData::where('type_value','project_status')->column('name','value'); + return $dictData[$data['status']]; + } + + public function getProjectContentTextAttr($value,$data) + { + $dictData = DictData::where('type_value','project_content')->column('name','value'); + return $dictData[$data['project_content']]; + } + + public function getBiddingMethodTextAttr($value,$data) + { + $dictData = DictData::where('type_value','bidding_method')->column('name','value'); + return $dictData[$data['bidding_method']]; + } + + public function getRelationshipTextAttr($value,$data) + { + $dictData = DictData::where('type_value','relationship')->column('name','value'); + return $dictData[$data['relationship']]; + } + + public function getInformationSourcesTextAttr($value,$data) + { + $dictData = DictData::where('type_value','information_sources')->column('name','value'); + return $dictData[$data['information_sources']]; + } + + public function getConstructionFundsSourcesTextAttr($value,$data) + { + $dictData = DictData::where('type_value','construction_funds_sources')->column('name','value'); + return $dictData[$data['construction_funds_sources']]; + } + + public function getConstructionFinancialStatusTextAttr($value,$data) + { + $dictData = DictData::where('type_value','construction_financial_status')->column('name','value'); + return $dictData[$data['construction_financial_status']]; + } + + public function getConstructionRecognitionTextAttr($value,$data) + { + $dictData = DictData::where('type_value','construction_recognition')->column('name','value'); + return $dictData[$data['construction_recognition']]; + } + + public function getMyConstructionRecognitionTextAttr($value,$data) + { + $dictData = DictData::where('type_value','my_construction_recognition')->column('name','value'); + return $dictData[$data['my_construction_recognition']]; + } + + public function getStrategicSignificanceTextAttr($value,$data) + { + $dictData = DictData::where('type_value','strategic_significance')->column('name','value'); + return $dictData[$data['strategic_significance']]; + } + + public function getIndustryTextAttr($value,$data) + { + $dictData = DictData::where('type_value','industry')->column('name','value'); + return $dictData[$data['industry']]; + } + + public function getUnitNatureTextAttr($value,$data) + { + $dictData = DictData::where('type_value','unit_nature')->column('name','value'); + return $dictData[$data['unit_nature']]; } - public function getBiddingTimeAttr($value) - { - return empty($value) ? '' : date('Y-m-d H:i:s', $value); - } - - public function getDiscoveryTimeAttr($value) - { - return empty($value) ? '' : date('Y-m-d H:i:s', $value); - } - - public function custom() + public function getBiddingTimeAttr($value): string { - return $this->belongsTo(\app\common\model\custom\Custom::class, 'custom_id'); - } + return empty($value) ? '' : date('Y-m-d', $value); + } + public function getDiscoveryTimeAttr($value): string + { + return empty($value) ? '' : date('Y-m-d', $value); + } + + public function getAnnexAttr($value) + { + return empty($value) ? null : json_decode($value,true); + } } \ No newline at end of file diff --git a/app/common/model/project/ProjectFollowUp.php b/app/common/model/project/ProjectFollowUp.php index 2dee0190f..da913c28c 100644 --- a/app/common/model/project/ProjectFollowUp.php +++ b/app/common/model/project/ProjectFollowUp.php @@ -55,6 +55,16 @@ class ProjectFollowUp extends BaseModel return $dictData[$data['follow_stage']]; } + public function getFollowDateAttr($value): string + { + return !empty($value) ? date('Y-m-d',$value) : ''; + } + + public function getNextFollowUpDateAttr($value): string + { + return !empty($value) ? date('Y-m-d',$value) : ''; + } + public function getFileAttr($value) { return !empty($value) ? json_decode($value) : null; From be84d94123e6c77bd0bee81b330a23ce27cc94cb Mon Sep 17 00:00:00 2001 From: weiz Date: Wed, 3 Jan 2024 16:34:15 +0800 Subject: [PATCH 2/2] update --- .../custom/CustomerDemandController.php | 32 ------------------- 1 file changed, 32 deletions(-) diff --git a/app/adminapi/controller/custom/CustomerDemandController.php b/app/adminapi/controller/custom/CustomerDemandController.php index e6020a300..d6fe038e5 100644 --- a/app/adminapi/controller/custom/CustomerDemandController.php +++ b/app/adminapi/controller/custom/CustomerDemandController.php @@ -106,37 +106,5 @@ class CustomerDemandController extends BaseAdminController $result = CustomerDemandLogic::detail($params); return $this->data($result); } - - //根据项目id获取客户需求列表 - public function getListByProjectId(): \think\response\Json - { - $params = $this->request->get(['project_id','page_size','page_no']); - if(empty($params['project_id'])){ - return $this->fail('缺少必要参数'); - } - $pageSize = !empty($params['page_size']) ? $params['page_size'] : 15; - $pageNo = !empty($params['page_size']) ? $params['page_no'] : 1; - $data = CustomerDemand::where('project_id',$params['project_id']) - ->field(['id', 'project_id', 'theme', 'supplier', 'supplier_contacts', 'importance', 'recording_time', 'demand_content', 'annex']) - ->order(['id' => 'desc'])->page($pageNo,$pageSize) - ->select()->each(function($item){ - $item['importance_text'] = $item->importance_text; - $item['recording_time'] = date('Y-m-d H:i:s',$item['recording_time']); - $project = Project::field('name,project_code,custom_id')->where('id',$item['project_id'])->findOrEmpty(); - $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty(); - $item['project_name'] = $project['name']; - $item['project_code'] = $project['project_code']; - $item['custom_name'] = $custom['name']; - return $item; - })->toArray(); - $count = CustomerDemand::field('id')->where('project_id',$params['project_id'])->count(); - $result = [ - 'count' => $count, - 'page_no' => $pageNo, - 'page_size' => $pageSize, - 'lists' => $data - ]; - return $this->success('请求成功',$result); - } } \ No newline at end of file