diff --git a/app/adminapi/controller/marketing/MarketingBidEvaluationController.php b/app/adminapi/controller/marketing/MarketingBidEvaluationController.php index 1a57fd0a0..68a34c0a2 100644 --- a/app/adminapi/controller/marketing/MarketingBidEvaluationController.php +++ b/app/adminapi/controller/marketing/MarketingBidEvaluationController.php @@ -126,7 +126,7 @@ //获取审批流程列表 public function flows(): \think\response\Json { - $flow_type = FlowType::where('type', 1)->where('name', 'TBPS')->findOrEmpty(); + $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()); } diff --git a/app/adminapi/lists/marketing/MarketingBidEvaluationLists.php b/app/adminapi/lists/marketing/MarketingBidEvaluationLists.php index 2840ae63f..ec585e725 100644 --- a/app/adminapi/lists/marketing/MarketingBidEvaluationLists.php +++ b/app/adminapi/lists/marketing/MarketingBidEvaluationLists.php @@ -22,7 +22,6 @@ use app\common\model\marketing\MarketingBidEvaluation; use app\common\model\marketing\MarketingBusinessOpportunity; use app\common\model\marketing\MarketingCustom; - use app\common\model\oa\FlowApprove; /** @@ -43,7 +42,7 @@ public function setSearch(): array { return [ - '=' => ['business_opportunity_id', 'bid_type', 'bid_nature'], + '=' => ['business_opportunity_id', 'bid_type', 'bid_nature', 'approve_check_status'], '%like%' => ['bid_code'], ]; } @@ -60,7 +59,13 @@ */ public function lists(): array { - return MarketingBidEvaluation::withoutField('create_time,update_time,delete_time')->where($this->searchWhere) + $params = $this->request->get(); + $where = []; + if (isset($params['construct_company']) && $params['construct_company'] != '') { + $business_opportunity_ids = MarketingBusinessOpportunity::where('construct_company', $params['construct_company'])->column('id'); + $where[] = ['business_opportunity_id', 'in', $business_opportunity_ids]; + } + return MarketingBidEvaluation::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)->where($where) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($data) { @@ -81,6 +86,7 @@ $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; if (empty($data['reg_date'])) { $data['reg_status'] = 0; $data['reg_status_text'] = '未报名'; @@ -93,20 +99,6 @@ $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(); } @@ -120,7 +112,13 @@ */ public function count(): int { - return MarketingBidEvaluation::where($this->searchWhere)->count(); + $params = $this->request->get(); + $where = []; + if (isset($params['construct_company']) && $params['construct_company'] != '') { + $business_opportunity_ids = MarketingBusinessOpportunity::where('construct_company', $params['construct_company'])->column('id'); + $where[] = ['business_opportunity_id', 'in', $business_opportunity_ids]; + } + return MarketingBidEvaluation::where($this->searchWhere)->where($where)->count(); } } \ No newline at end of file diff --git a/app/adminapi/lists/marketing/MarketingBidInfoLists.php b/app/adminapi/lists/marketing/MarketingBidInfoLists.php index d517f3510..19b2eb5cb 100644 --- a/app/adminapi/lists/marketing/MarketingBidInfoLists.php +++ b/app/adminapi/lists/marketing/MarketingBidInfoLists.php @@ -43,7 +43,7 @@ public function setSearch(): array { return [ - '=' => ['bid_evaluation_id', 'general_manager', 'bid_head'], + '=' => ['bid_evaluation_id', 'general_manager', 'bid_head', 'bid_status'], ]; } @@ -59,7 +59,18 @@ */ public function lists(): array { - return MarketingBidInfo::withoutField('create_time,update_time,delete_time')->where($this->searchWhere) + $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'); + $where[] = ['bid_evaluation_id', 'in', $bid_evaluation_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'); + $where[] = ['bid_evaluation_id', 'in', $bid_evaluation_ids]; + } + return MarketingBidInfo::withoutField('create_time,update_time,delete_time')->where($this->searchWhere)->where($where) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($data) { @@ -105,7 +116,18 @@ */ public function count(): int { - return MarketingBidInfo::where($this->searchWhere)->count(); + $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'); + $where[] = ['bid_evaluation_id', 'in', $bid_evaluation_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'); + $where[] = ['bid_evaluation_id', 'in', $bid_evaluation_ids]; + } + return MarketingBidInfo::where($this->searchWhere)->where($where)->count(); } } \ No newline at end of file diff --git a/app/adminapi/lists/marketing/MarketingBusinessOpportunityLists.php b/app/adminapi/lists/marketing/MarketingBusinessOpportunityLists.php index 3eafc7f2a..457653da3 100644 --- a/app/adminapi/lists/marketing/MarketingBusinessOpportunityLists.php +++ b/app/adminapi/lists/marketing/MarketingBusinessOpportunityLists.php @@ -21,7 +21,6 @@ use app\common\model\dept\Dept; use app\common\model\marketing\MarketingBusinessOpportunity; use app\common\model\marketing\MarketingCustom; - use app\common\model\oa\FlowApprove; /** @@ -42,7 +41,7 @@ public function setSearch(): array { return [ - '=' => ['construct_company', 'business_nature', 'industry_nature', 'info_sources', 'fund_sources', 'const_area', 'status'], + '=' => ['construct_company', 'business_nature', 'industry_nature', 'info_sources', 'fund_sources', 'const_area', 'status', 'approve_check_status'], '%like%' => ['project_name', 'project_code'], ]; } @@ -73,23 +72,10 @@ $data['fund_sources_text'] = $data->fund_sources_text; $data['const_area_text'] = $data->const_area_text; $data['status_text'] = $data->status_text; + $data['approve_check_status_text'] = $data->approve_check_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(); } diff --git a/app/adminapi/logic/bid/BidBiddingDecisionLogic.php b/app/adminapi/logic/bid/BidBiddingDecisionLogic.php index b5aa06ce0..947834d77 100644 --- a/app/adminapi/logic/bid/BidBiddingDecisionLogic.php +++ b/app/adminapi/logic/bid/BidBiddingDecisionLogic.php @@ -11,181 +11,180 @@ // +---------------------------------------------------------------------- // | author: likeadminTeam // +---------------------------------------------------------------------- - -namespace app\adminapi\logic\bid; - - -use app\common\model\bid\BidBiddingDecision; -use app\common\model\bid\BidBuyBiddingDocument; -use app\common\model\custom\Custom; -use app\common\logic\BaseLogic; -use app\common\model\oa\FlowApprove; -use app\common\model\project\Project; -use think\facade\Db; - - -/** - * 投标决策逻辑 - * Class BidBiddingDecisionLogic - * @package app\adminapi\logic\bid - */ -class BidBiddingDecisionLogic extends BaseLogic -{ - - - /** - * @notes 添加投标决策 - * @param array $params - * @return bool - * @author likeadmin - * @date 2023/11/27 18:14 - */ - public static function add(array $params): bool - { - Db::startTrans(); - try { - BidBiddingDecision::create([ - 'code' => data_unique_code('投标决策'), - 'project_id' => $params['project_id'], - 'project_estimation' => $params['project_estimation'], - 'bidding_project_fund_source' => $params['bidding_project_fund_source'] ?? 0, - 'bidding_time' => !empty($params['bidding_time']) ? strtotime($params['bidding_time']) : 0, - 'bid_type' => $params['bid_type'] ?? 0, - 'competitor' => $params['competitor'] ?? '', - 'is_margin' => $params['is_margin'] ?? 0, - 'margin_amount' => $params['margin_amount'] ?? 0, - 'bid_opening_date' => !empty($params['bid_opening_date']) ? strtotime($params['bid_opening_date']) : 0, - 'margin_amount_return_date' => !empty($params['margin_amount_return_date']) ? strtotime($params['margin_amount_return_date']) : 0, - 'is_internal_resources' => $params['is_internal_resources'] ?? 0, - 'project_assurance' => $params['project_assurance'] ?? 0, - 'bid_project_overview' => $params['bid_project_overview'] ?? '', - 'project_desc' => $params['project_desc'] ?? '', - 'annex' => $params['annex'] ? json_encode($params['annex']) : null, - ]); - Project::where('id',$params['project_id'])->update([ - 'status' => 2, - 'update_time' => time(), - ]); - Db::commit(); - return true; - } catch (\Exception $e) { - Db::rollback(); - self::setError($e->getMessage()); - return false; - } - } - - - /** - * @notes 编辑投标决策 - * @param array $params - * @return bool - * @author likeadmin - * @date 2023/11/27 18:14 - */ - public static function edit(array $params): bool - { - Db::startTrans(); - try { - BidBiddingDecision::where('id', $params['id'])->update([ - 'project_id' => $params['project_id'], - 'project_estimation' => $params['project_estimation'], - 'bidding_project_fund_source' => $params['bidding_project_fund_source'] ?? 0, - 'bidding_time' => !empty($params['bidding_time']) ? strtotime($params['bidding_time']) : 0, - 'bid_type' => $params['bid_type'] ?? 0, - 'competitor' => $params['competitor'] ?? '', - 'is_margin' => $params['is_margin'] ?? 0, - 'margin_amount' => $params['margin_amount'] ?? 0, - 'bid_opening_date' => !empty($params['bid_opening_date']) ? strtotime($params['bid_opening_date']) : 0, - 'margin_amount_return_date' => !empty($params['margin_amount_return_date']) ? strtotime($params['margin_amount_return_date']) : 0, - 'is_internal_resources' => $params['is_internal_resources'] ?? 0, - 'project_assurance' => $params['project_assurance'] ?? 0, - 'bid_project_overview' => $params['bid_project_overview'] ?? '', - 'project_desc' => $params['project_desc'] ?? '', - 'annex' => $params['annex'] ? json_encode($params['annex']) : null, - 'update_time' => time(), - ]); - Db::commit(); - return true; - } catch (\Exception $e) { - Db::rollback(); - self::setError($e->getMessage()); - return false; - } - } - - - /** - * @notes 删除投标决策 - * @param array $params - * @return bool - * @author likeadmin - * @date 2023/11/27 18:14 - */ - public static function delete(array $params): bool - { - $data = BidBuyBiddingDocument::where('bid_decision_id','in',$params['id'])->findOrEmpty(); - if(!$data->isEmpty()){ - self::setError('此数据关联了购买标书信息,需删除购买标书信息'); - return false; - } - return BidBiddingDecision::destroy($params['id']); - } - - - /** - * @notes 获取投标决策详情 - * @param $params - * @return array - * @author likeadmin - * @date 2023/11/27 18:14 - */ - public static function detail($params): array - { - $data = BidBiddingDecision::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']); - $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']; - $data['bidding_project_fund_source_text'] = $data->bidding_project_fund_source_text; - $data['bid_type_text'] = $data->bid_type_text; - $data['is_margin_text'] = $data->is_margin_text; - $data['is_internal_resources_text'] = $data->is_internal_resources_text; - $data['project_assurance_text'] = $data->project_assurance_text; - $approve_data = FlowApprove::where('id',$data['approve_id'])->findOrEmpty(); - $data['approve_check_status'] = $approve_data['check_status']; - return $data->toArray(); - } - public static function approve($params,$admin_id): bool{ - $data = BidBiddingDecision::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\bid\BidBiddingDecision', - $params['path'], - $params['flow_id'], - $admin_id - ); - if($res){ - BidBiddingDecision::where('id',$params['id'])->update([ - 'approve_id' => $res, + namespace app\adminapi\logic\bid; + + + use app\common\logic\BaseLogic; + use app\common\model\bid\BidBiddingDecision; + use app\common\model\bid\BidBuyBiddingDocument; + use app\common\model\custom\Custom; + use app\common\model\oa\FlowApprove; + use app\common\model\project\Project; + use think\facade\Db; + + + /** + * 投标决策逻辑 + * Class BidBiddingDecisionLogic + * @package app\adminapi\logic\bid + */ + class BidBiddingDecisionLogic extends BaseLogic + { + + + /** + * @notes 添加投标决策 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/27 18:14 + */ + public static function add(array $params): bool + { + Db::startTrans(); + try { + BidBiddingDecision::create([ + 'code' => data_unique_code('投标决策'), + 'project_id' => $params['project_id'], + 'project_estimation' => $params['project_estimation'], + 'bidding_project_fund_source' => $params['bidding_project_fund_source'] ?? 0, + 'bidding_time' => !empty($params['bidding_time']) ? strtotime($params['bidding_time']) : 0, + 'bid_type' => $params['bid_type'] ?? 0, + 'competitor' => $params['competitor'] ?? '', + 'is_margin' => $params['is_margin'] ?? 0, + 'margin_amount' => $params['margin_amount'] ?? 0, + 'bid_opening_date' => !empty($params['bid_opening_date']) ? strtotime($params['bid_opening_date']) : 0, + 'margin_amount_return_date' => !empty($params['margin_amount_return_date']) ? strtotime($params['margin_amount_return_date']) : 0, + 'is_internal_resources' => $params['is_internal_resources'] ?? 0, + 'project_assurance' => $params['project_assurance'] ?? 0, + 'bid_project_overview' => $params['bid_project_overview'] ?? '', + 'project_desc' => $params['project_desc'] ?? '', + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, ]); + Project::where('id', $params['project_id'])->update([ + 'status' => 2, + 'update_time' => time(), + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; } - Db::commit(); - return true; - } catch (\Exception $e) { - Db::rollback(); - self::setError($e->getMessage()); - return false; } - } -} \ No newline at end of file + + + /** + * @notes 编辑投标决策 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/27 18:14 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + BidBiddingDecision::where('id', $params['id'])->update([ + 'project_id' => $params['project_id'], + 'project_estimation' => $params['project_estimation'], + 'bidding_project_fund_source' => $params['bidding_project_fund_source'] ?? 0, + 'bidding_time' => !empty($params['bidding_time']) ? strtotime($params['bidding_time']) : 0, + 'bid_type' => $params['bid_type'] ?? 0, + 'competitor' => $params['competitor'] ?? '', + 'is_margin' => $params['is_margin'] ?? 0, + 'margin_amount' => $params['margin_amount'] ?? 0, + 'bid_opening_date' => !empty($params['bid_opening_date']) ? strtotime($params['bid_opening_date']) : 0, + 'margin_amount_return_date' => !empty($params['margin_amount_return_date']) ? strtotime($params['margin_amount_return_date']) : 0, + 'is_internal_resources' => $params['is_internal_resources'] ?? 0, + 'project_assurance' => $params['project_assurance'] ?? 0, + 'bid_project_overview' => $params['bid_project_overview'] ?? '', + 'project_desc' => $params['project_desc'] ?? '', + 'annex' => $params['annex'] ? json_encode($params['annex']) : null, + 'update_time' => time(), + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除投标决策 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/27 18:14 + */ + public static function delete(array $params): bool + { + $data = BidBuyBiddingDocument::where('bid_decision_id', 'in', $params['id'])->findOrEmpty(); + if (!$data->isEmpty()) { + self::setError('此数据关联了购买标书信息,需删除购买标书信息'); + return false; + } + return BidBiddingDecision::destroy($params['id']); + } + + + /** + * @notes 获取投标决策详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/11/27 18:14 + */ + public static function detail($params): array + { + $data = BidBiddingDecision::withoutField('create_time,update_time,delete_time')->findOrEmpty($params['id']); + $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']; + $data['bidding_project_fund_source_text'] = $data->bidding_project_fund_source_text; + $data['bid_type_text'] = $data->bid_type_text; + $data['is_margin_text'] = $data->is_margin_text; + $data['is_internal_resources_text'] = $data->is_internal_resources_text; + $data['project_assurance_text'] = $data->project_assurance_text; + return $data->toArray(); + } + + public static function approve($params, $admin_id): bool + { + $data = BidBiddingDecision::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\bid\BidBiddingDecision', + $params['path'], + $params['flow_id'], + $admin_id + ); + if ($res) { + BidBiddingDecision::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/MarketingBidEvaluationLogic.php b/app/adminapi/logic/marketing/MarketingBidEvaluationLogic.php index 17fd575db..cca921beb 100644 --- a/app/adminapi/logic/marketing/MarketingBidEvaluationLogic.php +++ b/app/adminapi/logic/marketing/MarketingBidEvaluationLogic.php @@ -184,6 +184,7 @@ $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; return $data->toArray(); } diff --git a/app/adminapi/logic/marketing/MarketingBusinessOpportunityLogic.php b/app/adminapi/logic/marketing/MarketingBusinessOpportunityLogic.php index bf0e4134a..213b6fa91 100644 --- a/app/adminapi/logic/marketing/MarketingBusinessOpportunityLogic.php +++ b/app/adminapi/logic/marketing/MarketingBusinessOpportunityLogic.php @@ -157,6 +157,7 @@ $data['fund_sources_text'] = $data->fund_sources_text; $data['const_area_text'] = $data->const_area_text; $data['status_text'] = $data->status_text; + $data['approve_check_status_text'] = $data->approve_check_status_text; $data['dept_name'] = $dept?->name; $data['head_name'] = $admin[$data['head']] ?? ''; $data['leader_name'] = $admin[$data['leader']] ?? ''; @@ -174,7 +175,7 @@ { $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) { + if ((!empty($data['approve_id']) && $approve_data['check_status'] != 3) || (!empty($data['approve_id']) && $approve_data['check_status'] != 4)) { self::setError('当前内容存在审核信息,请勿重复提交'); return false; } diff --git a/app/adminapi/logic/oa/FlowApproveLogic.php b/app/adminapi/logic/oa/FlowApproveLogic.php index 43ecd65f3..492472b3f 100644 --- a/app/adminapi/logic/oa/FlowApproveLogic.php +++ b/app/adminapi/logic/oa/FlowApproveLogic.php @@ -1,267 +1,275 @@ findOrEmpty($params['id']); - if($data->isEmpty()) return []; - //获取创建人信息 - $create_user = Admin::field('name')->where('id',$data['create_user'])->findOrEmpty(); - //获取审批流程信息 - $flow = Flow::field('name,copy_uids')->where('id',$data['flow_id'])-> findOrEmpty(); - //获取抄送人信息 - $copy = Admin::where('id','in',$flow['copy_uids'])->column('name'); - //当前审核人 - $current_check_user = ''; - $current_check_user_ids = ''; - //获取审核步骤 - $step = FlowStep::field('flow_step,flow_user,is_active')->where('approve_id',$data['id'])->order('sort asc')->select()->each(function($item)use($create_user,&$current_check_user,&$current_check_user_ids){ - $item['flow_step_text'] = $item->flow_step_text; - if($item['flow_step'] == 0){ - $item['flow_step_text'] = $create_user['name'].'创建'; - $item['flow_user_name'] = ''; - }else{ - $item['flow_step_text'] = $item->flow_step_text; - $flow_user = Admin::where('id','in',$item['flow_user'])->column('name'); - $item['flow_user_name'] = implode(',',$flow_user); - } - if($item['is_active'] == 1){ - $current_check_user = $item['flow_user_name']; - $current_check_user_ids = explode(',',$item['flow_user']); - } - })->toArray(); - //获取审批记录 - $record = FlowRecord::field('title,content,check_time,status')->where('approve_id',$data['id'])->select()->each(function($item){ - $item['status_text'] = $item->status_text; - })->toArray(); - $data['flow_name'] = $flow['name']; - $data['check_status_text'] = $data->check_status_text; - $data['current_check_user'] = $current_check_user; - $data['current_check_user_ids'] = $current_check_user_ids; - $data['create_user_name'] = $create_user['name']; - $data['copy_user'] = implode(',',$copy); - $data['step'] = $step; - $data['record'] = $record; - unset($data['flow_id']); - return $data->toArray(); - } - //撤销申请 - public static function revoke(array $params,$admin_id): bool + namespace app\adminapi\logic\oa; + + use app\common\logic\BaseLogic; + use app\common\model\auth\Admin; + use app\common\model\oa\Flow; + use app\common\model\oa\FlowApprove; + use app\common\model\oa\FlowRecord; + use app\common\model\oa\FlowStep; + use think\facade\Db; + + + /** + * 日常审批逻辑 + * Class FlowApproveLogic + * @package app\adminapi\logic\oa + */ + class FlowApproveLogic extends BaseLogic { - $approve_data = FlowApprove::where('id',$params['id'])->findOrEmpty(); - if($approve_data->isEmpty()){ - self::setError('审批信息不存在'); - return false; - } - if($approve_data['check_status'] != 0){ - self::setError('审批信息状态不是待审核状态,不可撤回'); - return false; - } - if($approve_data['create_user'] != $admin_id){ - self::setError('当前登录用户不是该审批信息的创建用户'); - return false; - } - $createUser = Admin::field('name')->where('id',$approve_data['create_user'])->findOrEmpty(); - Db::startTrans(); - try { - $revoke_time = time(); - FlowApprove::where('id',$params['id'])->update([ - 'check_status' => 4, - 'update_time' => $revoke_time, - ]); - //添加审批数据记录 - FlowRecord::create([ - 'approve_id' => $params['id'], - 'step_id' => 0, - 'check_user_id' => 0, - 'check_time' => $revoke_time, - 'status' => 3, - 'title' => $createUser['name'].'撤销了此申请', - 'content' => $params['revoke_reason'], - 'is_invalid' => 0 - ]); - $approve_data['content_model']::where('id',$approve_data['content_id'])->update([ - 'approve_id' => 0 - ]); - Db::commit(); - return true; - } catch (\Exception $e) { - Db::rollback(); - self::setError($e->getMessage()); - return false; - } - } - - //审核申请 - public static function check($params,$admin_id): bool{ - $str = $params['check_status'] == 1 ? '通过' : '拒绝'; - $check_user = Admin::field('name')->where('id',$admin_id)->findOrEmpty(); - $approve_data = FlowApprove::where('id',$params['id'])->findOrEmpty(); - if($approve_data->isEmpty()){ - self::setError('当前审批信息不存在'); - return false; - } - if($approve_data['check_status'] == 2 || $approve_data['check_status'] == 3){ - self::setError('当前审批信息已审核'); - return false; - } - if($approve_data['check_status'] == 4){ - self::setError('当前审批信息已撤销'); - return false; - } - //获取当前审批信息的审批步骤 - $current_step = FlowStep::where('approve_id',$params['id'])->where('is_active',1)->findOrEmpty(); - //获取下一步步骤 - $next_step = FlowStep::where('approve_id',$params['id'])->where('sort',$current_step['sort']+1)->findOrEmpty(); - $current_check_user = explode(',',$current_step['flow_user']); - //获取当前审批信息的步骤总数 - $step_count = FlowStep::where('approve_id',$params['id'])->count(); - if(!in_array($admin_id,$current_check_user)){ - self::setError('当前登录用户不是此审批信息的审核人'); - return false; - } - //判断当前用户是否审核过该条记录 - $check_record = FlowRecord::where('approve_id',$params['id'])->where('step_id',$current_step['id'])->where('check_user_id',$admin_id)->where('is_invalid',0)->findOrEmpty(); - if(!$check_record->isEmpty()){ - self::setError('你已经审核过该条信息,无需重复审核'); - return false; - } - //审批时间 - $check_time = time(); - //获取审批流程信息 - $flow_data = Flow::where('id',$approve_data['flow_id'])->findOrEmpty(); - Db::startTrans(); - try { - if($flow_data['check_type'] == 1){ - //判断当前审批步骤类型 - switch($current_step['flow_step']){ - case 1://当前部门负责人审批 - if($next_step->isEmpty()){ - FlowApprove::where('id',$params['id'])->update([ - 'check_status' => $params['check_status'] == 1 ? 2 : 3, - 'update_time' => $check_time, - ]); - }else{ - FlowApprove::where('id',$params['id'])->update([ - 'check_status' => $params['check_status'] == 1 ? 1 : 3, - 'update_time' => $check_time, - ]); - //设置下一步 - if($params['check_status'] == 1){ - FlowStep::where('id',$current_step['id'])->update(['is_active'=>0]); - FlowStep::where('id',$next_step['id'])->update(['is_active'=>1]); - } - } - break; - case 2: //指定人或签 - //判断当前审核状态 - if($params['check_status'] == 1){ - $approve_check_status = $next_step->isEmpty() ? 2 : 1; - if(!$next_step->isEmpty()){ - FlowStep::where('id',$current_step['id'])->update(['is_active'=>0]); - FlowStep::where('id',$next_step['id'])->update(['is_active'=>1]); - } - }else{ - //获取当前记录的审核记录数 - $check_record_count = FlowRecord::where('approve_id',$params['id'])->where('step_id',$current_step['id'])->where('is_invalid',0)->where('status','<>',0)->count(); - //判断当前记录除当前用户外,是否都审批了 - if(count($current_check_user)-1 == $check_record_count){ - $approve_check_status = 3; - if(!$next_step->isEmpty()){ - FlowStep::where('id',$current_step['id'])->update(['is_active'=>0]); - FlowStep::where('id',$next_step['id'])->update(['is_active'=>1]); - } - }else{ - $approve_check_status = 1; - } - } - FlowApprove::where('id',$params['id'])->update([ - 'check_status' => $approve_check_status, - 'update_time' => $check_time, - ]); - break; - case 3: //指定人会签 - if($params['check_status'] == 2){ - $approve_check_status = 3; - }else{ - //获取当前记录的审核记录数 - $check_record_count = FlowRecord::where('approve_id',$params['id'])->where('step_id',$current_step['id'])->where('is_invalid',0)->where('status','<>',0)->count(); - //判断当前记录除当前用户外,是否都审批了, - if(count($current_check_user)-1 == $check_record_count){ - $approve_check_status = 2; - if(!$next_step->isEmpty()){ - FlowStep::where('id',$current_step['id'])->update(['is_active'=>0]); - FlowStep::where('id',$next_step['id'])->update(['is_active'=>1]); - } - }else{ - $approve_check_status = 1; - } - } - FlowApprove::where('id',$params['id'])->update([ - 'check_status' => $approve_check_status, - 'update_time' => $check_time, - ]); - break; + /** + * @notes 获取日常审批详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/02/01 11:26 + */ + public static function detail($params): array + { + $data = FlowApprove::field('id,title,flow_id,content_id,create_user,check_status')->findOrEmpty($params['id']); + if ($data->isEmpty()) return []; + //获取创建人信息 + $create_user = Admin::field('name')->where('id', $data['create_user'])->findOrEmpty(); + //获取审批流程信息 + $flow = Flow::field('name,copy_uids')->where('id', $data['flow_id'])->findOrEmpty(); + //获取抄送人信息 + $copy = Admin::where('id', 'in', $flow['copy_uids'])->column('name'); + //当前审核人 + $current_check_user = ''; + $current_check_user_ids = ''; + //获取审核步骤 + $step = FlowStep::field('flow_step,flow_user,is_active')->where('approve_id', $data['id'])->order('sort asc')->select()->each(function ($item) use ($create_user, &$current_check_user, &$current_check_user_ids) { + $item['flow_step_text'] = $item->flow_step_text; + if ($item['flow_step'] == 0) { + $item['flow_step_text'] = $create_user['name'] . '创建'; + $item['flow_user_name'] = ''; + } else { + $item['flow_step_text'] = $item->flow_step_text; + $flow_user = Admin::where('id', 'in', $item['flow_user'])->column('name'); + $item['flow_user_name'] = implode(',', $flow_user); } - }else{ - if($next_step->isEmpty()){ - FlowApprove::where('id',$params['id'])->update([ - 'check_status' => $params['check_status'] == 1 ? 2 : 3, - 'update_time' => $check_time, - ]); - }else{ - FlowApprove::where('id',$params['id'])->update([ - 'check_status' => $params['check_status'] == 1 ? 1 : 3, - 'update_time' => $check_time, - ]); - //设置下一步 - if($params['check_status'] == 1){ - FlowStep::where('id',$current_step['id'])->update(['is_active'=>0]); - FlowStep::where('id',$next_step['id'])->update(['is_active'=>1]); + if ($item['is_active'] == 1) { + $current_check_user = $item['flow_user_name']; + $current_check_user_ids = explode(',', $item['flow_user']); + } + })->toArray(); + //获取审批记录 + $record = FlowRecord::field('title,content,check_time,status')->where('approve_id', $data['id'])->select()->each(function ($item) { + $item['status_text'] = $item->status_text; + })->toArray(); + $data['flow_name'] = $flow['name']; + $data['check_status_text'] = $data->check_status_text; + $data['current_check_user'] = $current_check_user; + $data['current_check_user_ids'] = $current_check_user_ids; + $data['create_user_name'] = $create_user['name']; + $data['copy_user'] = implode(',', $copy); + $data['step'] = $step; + $data['record'] = $record; + unset($data['flow_id']); + return $data->toArray(); + } + + //撤销申请 + public static function revoke(array $params, $admin_id): bool + { + $approve_data = FlowApprove::where('id', $params['id'])->findOrEmpty(); + if ($approve_data->isEmpty()) { + self::setError('审批信息不存在'); + return false; + } + if ($approve_data['check_status'] != 0) { + self::setError('审批信息状态不是待审核状态,不可撤回'); + return false; + } + if ($approve_data['create_user'] != $admin_id) { + self::setError('当前登录用户不是该审批信息的创建用户'); + return false; + } + $createUser = Admin::field('name')->where('id', $approve_data['create_user'])->findOrEmpty(); + Db::startTrans(); + try { + $revoke_time = time(); + FlowApprove::where('id', $params['id'])->update([ + 'check_status' => 4, + 'update_time' => $revoke_time, + ]); + //添加审批数据记录 + FlowRecord::create([ + 'approve_id' => $params['id'], + 'step_id' => 0, + 'check_user_id' => 0, + 'check_time' => $revoke_time, + 'status' => 3, + 'title' => $createUser['name'] . '撤销了此申请', + 'content' => $params['revoke_reason'], + 'is_invalid' => 0 + ]); + $approve_data['content_model']::where('id', $approve_data['content_id'])->update([ + 'approve_check_status' => 4, + ]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + //审核申请 + public static function check($params, $admin_id): bool + { + $str = $params['check_status'] == 1 ? '通过' : '拒绝'; + $check_user = Admin::field('name')->where('id', $admin_id)->findOrEmpty(); + $approve_data = FlowApprove::where('id', $params['id'])->findOrEmpty(); + $approve_status = 0; + if ($approve_data->isEmpty()) { + self::setError('当前审批信息不存在'); + return false; + } + if ($approve_data['check_status'] == 2 || $approve_data['check_status'] == 3) { + self::setError('当前审批信息已审核'); + return false; + } + if ($approve_data['check_status'] == 4) { + self::setError('当前审批信息已撤销'); + return false; + } + //获取当前审批信息的审批步骤 + $current_step = FlowStep::where('approve_id', $params['id'])->where('is_active', 1)->findOrEmpty(); + //获取下一步步骤 + $next_step = FlowStep::where('approve_id', $params['id'])->where('sort', $current_step['sort'] + 1)->findOrEmpty(); + $current_check_user = explode(',', $current_step['flow_user']); + if (!in_array($admin_id, $current_check_user)) { + self::setError('当前登录用户不是此审批信息的审核人'); + return false; + } + //判断当前用户是否审核过该条记录 + $check_record = FlowRecord::where('approve_id', $params['id'])->where('step_id', $current_step['id'])->where('check_user_id', $admin_id)->where('is_invalid', 0)->findOrEmpty(); + if (!$check_record->isEmpty()) { + self::setError('你已经审核过该条信息,无需重复审核'); + return false; + } + //审批时间 + $check_time = time(); + //获取审批流程信息 + $flow_data = Flow::where('id', $approve_data['flow_id'])->findOrEmpty(); + Db::startTrans(); + try { + if ($flow_data['check_type'] == 1) { + //判断当前审批步骤类型 + switch ($current_step['flow_step']) { + case 1://当前部门负责人审批 + if ($next_step->isEmpty()) { + FlowApprove::where('id', $params['id'])->update([ + 'check_status' => $params['check_status'] == 1 ? 2 : 3, + 'update_time' => $check_time, + ]); + $approve_status = $params['check_status'] == 1 ? 2 : 3; + } else { + FlowApprove::where('id', $params['id'])->update([ + 'check_status' => $params['check_status'] == 1 ? 1 : 3, + 'update_time' => $check_time, + ]); + //设置下一步 + if ($params['check_status'] == 1) { + FlowStep::where('id', $current_step['id'])->update(['is_active' => 0]); + FlowStep::where('id', $next_step['id'])->update(['is_active' => 1]); + } + $approve_status = $params['check_status'] == 1 ? 1 : 3; + } + break; + case 2: //指定人或签 + //判断当前审核状态 + if ($params['check_status'] == 1) { + $approve_check_status = $next_step->isEmpty() ? 2 : 1; + if (!$next_step->isEmpty()) { + FlowStep::where('id', $current_step['id'])->update(['is_active' => 0]); + FlowStep::where('id', $next_step['id'])->update(['is_active' => 1]); + } + } else { + //获取当前记录的审核记录数 + $check_record_count = FlowRecord::where('approve_id', $params['id'])->where('step_id', $current_step['id'])->where('is_invalid', 0)->where('status', '<>', 0)->count(); + //判断当前记录除当前用户外,是否都审批了 + if (count($current_check_user) - 1 == $check_record_count) { + $approve_check_status = 3; + if (!$next_step->isEmpty()) { + FlowStep::where('id', $current_step['id'])->update(['is_active' => 0]); + FlowStep::where('id', $next_step['id'])->update(['is_active' => 1]); + } + } else { + $approve_check_status = 1; + } + } + FlowApprove::where('id', $params['id'])->update([ + 'check_status' => $approve_check_status, + 'update_time' => $check_time, + ]); + $approve_status = $approve_check_status; + break; + case 3: //指定人会签 + if ($params['check_status'] == 2) { + $approve_check_status = 3; + } else { + //获取当前记录的审核记录数 + $check_record_count = FlowRecord::where('approve_id', $params['id'])->where('step_id', $current_step['id'])->where('is_invalid', 0)->where('status', '<>', 0)->count(); + //判断当前记录除当前用户外,是否都审批了, + if (count($current_check_user) - 1 == $check_record_count) { + $approve_check_status = 2; + if (!$next_step->isEmpty()) { + FlowStep::where('id', $current_step['id'])->update(['is_active' => 0]); + FlowStep::where('id', $next_step['id'])->update(['is_active' => 1]); + } + } else { + $approve_check_status = 1; + } + } + FlowApprove::where('id', $params['id'])->update([ + 'check_status' => $approve_check_status, + 'update_time' => $check_time, + ]); + $approve_status = $approve_check_status; + break; + } + } else { + if ($next_step->isEmpty()) { + FlowApprove::where('id', $params['id'])->update([ + 'check_status' => $params['check_status'] == 1 ? 2 : 3, + 'update_time' => $check_time, + ]); + $approve_status = $params['check_status'] == 1 ? 2 : 3; + } else { + FlowApprove::where('id', $params['id'])->update([ + 'check_status' => $params['check_status'] == 1 ? 1 : 3, + 'update_time' => $check_time, + ]); + $approve_status = $params['check_status'] == 1 ? 1 : 3; + //设置下一步 + if ($params['check_status'] == 1) { + FlowStep::where('id', $current_step['id'])->update(['is_active' => 0]); + FlowStep::where('id', $next_step['id'])->update(['is_active' => 1]); + } } } + //添加审批数据记录 + FlowRecord::create([ + 'approve_id' => $params['id'], + 'step_id' => $current_step['id'], + 'check_user_id' => $admin_id, + 'check_time' => $check_time, + 'status' => $params['check_status'], + 'title' => $check_user['name'] . $str . '了此申请', + 'content' => $params['check_reason'], + 'is_invalid' => 0 + ]); + $approve_data['content_model']::where('id', $approve_data['content_id'])->update(['approve_check_status' => $approve_status]); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; } - //添加审批数据记录 - FlowRecord::create([ - 'approve_id' => $params['id'], - 'step_id' => $current_step['id'], - 'check_user_id' => $admin_id, - 'check_time' => $check_time, - 'status' => $params['check_status'], - 'title' => $check_user['name'].$str.'了此申请', - 'content' => $params['check_reason'], - 'is_invalid' => 0 - ]); - Db::commit(); - return true; - } catch (\Exception $e) { - Db::rollback(); - self::setError($e->getMessage()); - return false; } - } -} \ No newline at end of file + } \ No newline at end of file diff --git a/app/common/model/marketing/MarketingBidEvaluation.php b/app/common/model/marketing/MarketingBidEvaluation.php index 0bc9a5c21..2bba59a20 100644 --- a/app/common/model/marketing/MarketingBidEvaluation.php +++ b/app/common/model/marketing/MarketingBidEvaluation.php @@ -44,6 +44,12 @@ return !empty($data['bid_nature']) ? $dict[$data['bid_nature']] : ''; } + public function getApproveCheckStatusTextAttr($value, $data) + { + $dict = DictData::where('type_value', 'check_status')->column('name', 'value'); + return !empty($data['approve_check_status']) ? $dict[$data['approve_check_status']] : ''; + } + public function getEndDateAttr($value): string { return !empty($value) ? date('Y-m-d', $value) : ''; diff --git a/app/common/model/marketing/MarketingBusinessOpportunity.php b/app/common/model/marketing/MarketingBusinessOpportunity.php index 1625880bf..076eb795a 100644 --- a/app/common/model/marketing/MarketingBusinessOpportunity.php +++ b/app/common/model/marketing/MarketingBusinessOpportunity.php @@ -62,6 +62,12 @@ return !empty($data['const_area']) ? $dict[$data['const_area']] : ''; } + public function getApproveCheckStatusTextAttr($value, $data) + { + $dict = DictData::where('type_value', 'check_status')->column('name', 'value'); + return !empty($data['approve_check_status']) ? $dict[$data['approve_check_status']] : ''; + } + public function getStatusTextAttr($value, $data): string { $arr = [0 => '未启动投标', 1 => '参与投标', 2 => '未开标'];