diff --git a/app/adminapi/controller/bid/BidSecurityApplyController.php b/app/adminapi/controller/bid/BidSecurityApplyController.php new file mode 100644 index 000000000..75b1364ee --- /dev/null +++ b/app/adminapi/controller/bid/BidSecurityApplyController.php @@ -0,0 +1,108 @@ +dataLists(new BidSecurityApplyLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/16 10:46 + */ + public function add() + { + $params = (new BidSecurityApplyValidate())->post()->goCheck('add'); + $result = BidSecurityApplyLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(BidSecurityApplyLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/16 10:46 + */ + public function edit() + { + $params = (new BidSecurityApplyValidate())->post()->goCheck('edit'); + $result = BidSecurityApplyLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(BidSecurityApplyLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/16 10:46 + */ + public function delete() + { + $params = (new BidSecurityApplyValidate())->post()->goCheck('delete'); + BidSecurityApplyLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/16 10:46 + */ + public function detail() + { + $params = (new BidSecurityApplyValidate())->goCheck('detail'); + $result = BidSecurityApplyLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/bid/BidSecurityApplyLists.php b/app/adminapi/lists/bid/BidSecurityApplyLists.php new file mode 100644 index 000000000..aafec8645 --- /dev/null +++ b/app/adminapi/lists/bid/BidSecurityApplyLists.php @@ -0,0 +1,91 @@ + ['bsa.bidding_decision_id', 'bsa.applier', 'bsa.pay_type'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/16 10:46 + */ + public function lists(): array + { + return Db::name('BidSecurityApply')->alias('bsa') + ->where($this->searchWhere) + ->leftJoin('bid_bidding_decision bbd','bbd.id = bsa.bidding_decision_id') + ->leftJoin('project p','p.id = bbd.project_id') + ->leftJoin('custom ct','ct.id = p.custom_id') + ->field('bsa.*, bbd.project_id, p.name as project_name, ct.name as customer_name') + ->limit($this->limitOffset, $this->limitLength) + ->order(['bsa.id' => 'desc']) + ->select()->each(function($item, $key){ + //关联数据 供应商后续添加 + $item['approve_no'] = '付款单号'; + $item['approve_step'] = '流程步骤'; + $item['approve_settle_status'] = 1; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/12/16 10:46 + */ + public function count(): int + { + return Db::name('BidSecurityApply')->alias('bsa') + ->where($this->searchWhere) + ->leftJoin('bid_bidding_decision bbd','bbd.id = bsa.bidding_decision_id') + ->leftJoin('project p','p.id = bbd.project_id') + ->leftJoin('custom ct','ct.id = p.custom_id')->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/contract/ContractLists.php b/app/adminapi/lists/contract/ContractLists.php index 62a438659..16d50e9d9 100644 --- a/app/adminapi/lists/contract/ContractLists.php +++ b/app/adminapi/lists/contract/ContractLists.php @@ -38,7 +38,7 @@ class ContractLists extends BaseAdminDataLists implements ListsSearchInterface public function setSearch(): array { return [ - '=' => ['contract_name', 'contract_type', 'contract_code'], + '=' => ['c.contract_name', 'c.contract_type', 'c.contract_code'], ]; } diff --git a/app/adminapi/lists/contract/ProcurementContractLists.php b/app/adminapi/lists/contract/ProcurementContractLists.php index b857d9e9e..0fa727248 100644 --- a/app/adminapi/lists/contract/ProcurementContractLists.php +++ b/app/adminapi/lists/contract/ProcurementContractLists.php @@ -38,14 +38,14 @@ class ProcurementContractLists extends BaseAdminDataLists implements ListsSearch public function setSearch(): array { return [ - '=' => ['supplier_id', 'project_id', 'contract_no'], + '=' => ['pc.supplier_id', 'pc.project_id', 'pc.contract_no'], ]; } public function querySearch(): array { $queryWhere = []; - $queryWhere['contract_cate'] = 1; + $queryWhere['pc.contract_cate'] = 1; if (!empty($this->params['all'])) { unset($queryWhere['contract_cate']); } diff --git a/app/adminapi/lists/contract/SubcontractingContractLists.php b/app/adminapi/lists/contract/SubcontractingContractLists.php index fdf2a8fde..42d6bfa82 100644 --- a/app/adminapi/lists/contract/SubcontractingContractLists.php +++ b/app/adminapi/lists/contract/SubcontractingContractLists.php @@ -40,14 +40,14 @@ class SubcontractingContractLists extends BaseAdminDataLists implements ListsSea public function setSearch(): array { return [ - '=' => ['project_id', 'contract_no', 'contract_name', 'supplier_id', 'contract_type'], + '=' => ['pc.project_id', 'pc.contract_no', 'pc.contract_name', 'pc.supplier_id', 'pc.contract_type'], ]; } public function querySearch(): array { $queryWhere = []; - $queryWhere['contract_cate'] = 2; + $queryWhere['pc.contract_cate'] = 2; if (!empty($this->params['all'])) { unset($queryWhere['contract_cate']); } diff --git a/app/adminapi/logic/bid/BidSecurityApplyLogic.php b/app/adminapi/logic/bid/BidSecurityApplyLogic.php new file mode 100644 index 000000000..379af5767 --- /dev/null +++ b/app/adminapi/logic/bid/BidSecurityApplyLogic.php @@ -0,0 +1,135 @@ + $params['approve_id'] ?? 0, + 'bidding_decision_id' => $params['bidding_decision_id'] ?? 0, + 'applier' => $params['applier'] ?? '', + 'pay_type' => $params['pay_type'] ?? 0, + 'refund_date' => $params['refund_date'] ?? '', + 'remark' => $params['remark'] ?? '', + 'annex' => $params['annex'] ?? '', + 'deposit_bank' => $params['deposit_bank'] ?? '', + 'account_name' => $params['account_name'] ?? '', + 'account' => $params['account'] ?? '', + ]); + + 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/12/16 10:46 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + BidSecurityApply::where('id', $params['id'])->update([ + 'approve_id' => $params['approve_id'] ?? 0, + 'bidding_decision_id' => $params['bidding_decision_id'] ?? 0, + 'applier' => $params['applier'] ?? '', + 'pay_type' => $params['pay_type'] ?? 0, + 'refund_date' => $params['refund_date'] ?? '', + 'remark' => $params['remark'] ?? '', + 'annex' => $params['annex'] ?? '', + 'deposit_bank' => $params['deposit_bank'] ?? '', + 'account_name' => $params['account_name'] ?? '', + 'account' => $params['account'] ?? '', + ]); + + 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/12/16 10:46 + */ + public static function delete(array $params): bool + { + return BidSecurityApply::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/16 10:46 + */ + public static function detail($params): array + { + $bidSecurityApply = BidSecurityApply::findOrEmpty($params['id']); + $bidSecurityApply->project = null; + $bidSecurityApply->custom = null; + if (!empty($bidSecurityApply->decision->project_id)) { + $bidSecurityApply->project = Project::findOrEmpty($bidSecurityApply->decision->project_id); + } + if (!empty($bidSecurityApply->project->custom_id)) { + $bidSecurityApply->custom = Custom::findOrEmpty($bidSecurityApply->project->custom_id); + } + return $bidSecurityApply->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/bid/BidSecurityApplyValidate.php b/app/adminapi/validate/bid/BidSecurityApplyValidate.php new file mode 100644 index 000000000..a70fe78fe --- /dev/null +++ b/app/adminapi/validate/bid/BidSecurityApplyValidate.php @@ -0,0 +1,107 @@ + 'require', + 'approve_id' => 'require', + 'bidding_decision_id' => 'require', + 'applier' => 'require', + 'pay_type' => 'require', + 'deposit_bank' => 'require', + 'account_name' => 'require', + 'account' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'bidding_decision_id' => '投标决策id', + 'applier' => '申请人', + 'pay_type' => '付款方式', + 'deposit_bank' => '开户银行', + 'account_name' => '开户名称', + 'account' => '账号', + ]; + + + /** + * @notes 添加场景 + * @return BidSecurityApplyValidate + * @author likeadmin + * @date 2023/12/16 10:46 + */ + public function sceneAdd() + { + return $this->only(['approve_id','bidding_decision_id','applier','pay_type','deposit_bank','account_name','account']); + } + + + /** + * @notes 编辑场景 + * @return BidSecurityApplyValidate + * @author likeadmin + * @date 2023/12/16 10:46 + */ + public function sceneEdit() + { + return $this->only(['id','approve_id','bidding_decision_id','applier','pay_type','deposit_bank','account_name','account']); + } + + + /** + * @notes 删除场景 + * @return BidSecurityApplyValidate + * @author likeadmin + * @date 2023/12/16 10:46 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return BidSecurityApplyValidate + * @author likeadmin + * @date 2023/12/16 10:46 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/bid/BidSecurityApply.php b/app/common/model/bid/BidSecurityApply.php new file mode 100644 index 000000000..bbc8a7fa4 --- /dev/null +++ b/app/common/model/bid/BidSecurityApply.php @@ -0,0 +1,39 @@ +belongsTo(\app\common\model\bid\BidBiddingDecision::class, 'bidding_decision_id'); + } +} \ No newline at end of file