From 8fcd8586fbb588b24fd9f5ecddbc092a64f55b8e Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Mon, 19 Feb 2024 15:22:01 +0800 Subject: [PATCH] update --- .../bid/BidBuyBiddingDocumentController.php | 21 +++++++++++ .../logic/bid/BidBuyBiddingDocumentLogic.php | 36 ++++++++++++++++++- .../bid/BidBuyBiddingDocumentValidate.php | 25 +++++++++++-- 3 files changed, 78 insertions(+), 4 deletions(-) diff --git a/app/adminapi/controller/bid/BidBuyBiddingDocumentController.php b/app/adminapi/controller/bid/BidBuyBiddingDocumentController.php index ecfa4404d..b75c0288b 100644 --- a/app/adminapi/controller/bid/BidBuyBiddingDocumentController.php +++ b/app/adminapi/controller/bid/BidBuyBiddingDocumentController.php @@ -20,6 +20,8 @@ use app\adminapi\controller\BaseAdminController; use app\adminapi\lists\bid\BidBuyBiddingDocumentLists; use app\adminapi\logic\bid\BidBuyBiddingDocumentLogic; use app\adminapi\validate\bid\BidBuyBiddingDocumentValidate; +use app\common\model\oa\Flow; +use app\common\model\oa\FlowType; /** @@ -72,6 +74,25 @@ class BidBuyBiddingDocumentController extends BaseAdminController $result = BidBuyBiddingDocumentLogic::detail($params); return $this->data($result); } + + //获取审批流程列表 + public function flows(): \think\response\Json + { + $flow_type = FlowType::where('type',1)->where('name','gmbs')->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 BidBuyBiddingDocumentValidate())->post()->goCheck('approve'); + $result = BidBuyBiddingDocumentLogic::approve($params,$this->adminId); + if (true === $result) { + return $this->success('提交审核信息成功', [], 1, 1); + } + return $this->fail(BidBuyBiddingDocumentLogic::getError()); + } } \ No newline at end of file diff --git a/app/adminapi/logic/bid/BidBuyBiddingDocumentLogic.php b/app/adminapi/logic/bid/BidBuyBiddingDocumentLogic.php index 9ad087ff6..c21800a29 100644 --- a/app/adminapi/logic/bid/BidBuyBiddingDocumentLogic.php +++ b/app/adminapi/logic/bid/BidBuyBiddingDocumentLogic.php @@ -20,6 +20,7 @@ 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; @@ -117,7 +118,7 @@ class BidBuyBiddingDocumentLogic extends BaseLogic */ public static function detail($params): array { - $data = BidBuyBiddingDocument::field('id,project_id,bid_decision_id,bid_document_no,invite_tenders_company_name,bid_company_name,buyer,amount,buy_date')->findOrEmpty($params['id']); + $data = BidBuyBiddingDocument::field('id,project_id,bid_decision_id,bid_document_no,invite_tenders_company_name,bid_company_name,buyer,amount,buy_date,approve_id')->findOrEmpty($params['id']); $project = Project::field('custom_id,name,project_code')->where('id',$data['project_id'])->findOrEmpty(); $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty(); $bid_decision = BidBiddingDecision::field('code,bidding_project_fund_source,bidding_time,bid_type,is_margin,margin_amount,bid_opening_date,margin_amount_return_date,bid_project_overview,project_desc,annex')->where('id',$data['bid_decision_id'])->findOrEmpty(); @@ -137,6 +138,39 @@ class BidBuyBiddingDocumentLogic extends BaseLogic $data['project_desc'] = $bid_decision['project_desc']; $data['annex'] = $bid_decision['annex']; $data['buyer'] = $admin['name']; + $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 = BidBuyBiddingDocument::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\BidBuyBiddingDocument', + $params['path'], + $params['flow_id'], + $admin_id + ); + if($res){ + BidBuyBiddingDocument::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/bid/BidBuyBiddingDocumentValidate.php b/app/adminapi/validate/bid/BidBuyBiddingDocumentValidate.php index 11578e97b..d48d4d204 100644 --- a/app/adminapi/validate/bid/BidBuyBiddingDocumentValidate.php +++ b/app/adminapi/validate/bid/BidBuyBiddingDocumentValidate.php @@ -17,6 +17,7 @@ namespace app\adminapi\validate\bid; use app\common\model\auth\Admin; use app\common\model\bid\BidBiddingDecision; +use app\common\model\bid\BidBuyBiddingDocument; use app\common\model\project\Project; use app\common\validate\BaseValidate; @@ -34,7 +35,7 @@ class BidBuyBiddingDocumentValidate extends BaseValidate * @var string[] */ protected $rule = [ - 'id' => 'require', + 'id' => 'require|checkData', 'project_id' => 'require|checkProject', 'bid_decision_id' => 'require|checkBidDecision', 'bid_document_no' => 'require', @@ -44,6 +45,8 @@ class BidBuyBiddingDocumentValidate extends BaseValidate 'amount' => 'float|egt:0', 'project_fund_source' => 'checkProjectFundSource', 'buy_date' => 'dateFormat:Y-m-d', + 'flow_id' => 'require|checkFlow', + 'path' => 'require', ]; protected $message = [ @@ -67,7 +70,7 @@ class BidBuyBiddingDocumentValidate extends BaseValidate */ public function sceneAdd() { - return $this->remove('id', true); + return $this->remove('id', true)->remove('flow_id',true)->remove('path',true); } @@ -78,7 +81,9 @@ class BidBuyBiddingDocumentValidate extends BaseValidate * @date 2023/11/27 18:22 */ public function sceneEdit() - {} + { + return $this->remove('flow_id',true)->remove('path',true); + } /** @@ -104,6 +109,20 @@ class BidBuyBiddingDocumentValidate extends BaseValidate return $this->only(['id']); } + public function sceneApprove() + { + return $this->only(['id','flow_id','path']); + } + + public function checkData($value): bool|string + { + $data = BidBuyBiddingDocument::where('id',$value)->findOrEmpty(); + if($data->isEmpty()){ + return '数据不存在'; + } + return true; + } + public function checkProject($value): bool|string { $project = Project::where('id',$value)->findOrEmpty();