diff --git a/app/adminapi/logic/bid/BidDocumentExaminationLogic.php b/app/adminapi/logic/bid/BidDocumentExaminationLogic.php index 63892d310..63622b888 100644 --- a/app/adminapi/logic/bid/BidDocumentExaminationLogic.php +++ b/app/adminapi/logic/bid/BidDocumentExaminationLogic.php @@ -42,29 +42,36 @@ class BidDocumentExaminationLogic extends BaseLogic Db::startTrans(); try { $bidDocumentExamination = BidDocumentExamination::create([ - 'approve_id' => $params['approve_id'], - 'buy_bidding_document_id' => $params['buy_bidding_document_id'], - 'is_need_deposit' => $params['is_need_deposit'], + 'approve_id' => $params['approve_id'] ?? 0, + 'buy_bidding_document_id' => $params['buy_bidding_document_id'] ?? 0, + 'is_need_deposit' => $params['is_need_deposit'] ?? 0, 'bid_opening_date' => strtotime($params['bid_opening_date']), 'deposit_refund_time' => strtotime($params['deposit_refund_time']), - 'bidding_project_overview' => $params['bidding_project_overview'], - 'project_introduction' => $params['project_introduction'], - 'annex' => $params['annex'], - 'technical_protocol_deviation' => $params['technical_protocol_deviation'], - 'protocol_deviation_handling_plan' => $params['protocol_deviation_handling_plan'], - 'technical_review_annex' => $params['technical_review_annex'], - 'business_review_total_amount' => $params['business_review_total_amount'], - 'tax_rate' => $params['tax_rate'], - 'pay_type' => $params['pay_type'], - 'pay_rate' => $params['pay_rate'], - 'business_contract_deviation' => $params['business_contract_deviation'], - 'business_contract_deviation_handling_plan' => $params['business_contract_deviation_handling_plan'], - 'business_contract_deviation_annex' => $params['business_contract_deviation_annex'] + 'bidding_project_overview' => $params['bidding_project_overview'] ?? '', + 'project_introduction' => $params['project_introduction'] ?? '', + 'annex' => $params['annex'] ?? '', + 'technical_protocol_deviation' => $params['technical_protocol_deviation'] ?? '', + 'protocol_deviation_handling_plan' => $params['protocol_deviation_handling_plan'] ?? '', + 'technical_review_annex' => $params['technical_review_annex'] ?? '', + 'business_review_total_amount' => $params['business_review_total_amount'] ?? 0, + 'tax_rate' => $params['tax_rate'] ?? 0, + 'pay_type' => $params['pay_type'] ?? 0, + 'pay_rate' => $params['pay_rate'] ?? '', + 'business_contract_deviation' => $params['business_contract_deviation'] ?? '', + 'business_contract_deviation_handling_plan' => $params['business_contract_deviation_handling_plan'] ?? '', + 'business_contract_deviation_annex' => $params['business_contract_deviation_annex'] ?? '', ]); - foreach ($params['product'] as $item) + foreach ($params['product'] ?? [] as $item) { BidDocumentExaminationDetail::create([ 'bid_document_examination_id' => $bidDocumentExamination->id, + 'product_id' => $item['product_id'] ?? 0, + 'product_num' => $item['product_num'] ?? 0, + 'cost_unit_price' => $item['cost_unit_price'] ?? 0, + 'amount' => $item['amount'] ?? '', + 'rate' => $item['rate'] ?? '', + 'unit_price' => $item['unit_price'] ?? 0, + 'total_amount' => $item['total_amount'] ?? 0 ]); } Db::commit(); @@ -89,26 +96,39 @@ class BidDocumentExaminationLogic extends BaseLogic Db::startTrans(); try { BidDocumentExamination::where('id', $params['id'])->update([ - 'approve_id' => $params['approve_id'], - 'buy_bidding_document_id' => $params['buy_bidding_document_id'], - 'is_need_deposit' => $params['is_need_deposit'], + 'approve_id' => $params['approve_id'] ?? 0, + 'buy_bidding_document_id' => $params['buy_bidding_document_id'] ?? 0, + 'is_need_deposit' => $params['is_need_deposit'] ?? 0, 'bid_opening_date' => strtotime($params['bid_opening_date']), 'deposit_refund_time' => strtotime($params['deposit_refund_time']), - 'bidding_project_overview' => $params['bidding_project_overview'], - 'project_introduction' => $params['project_introduction'], - 'annex' => $params['annex'], - 'technical_protocol_deviation' => $params['technical_protocol_deviation'], - 'protocol_deviation_handling_plan' => $params['protocol_deviation_handling_plan'], - 'technical_review_annex' => $params['technical_review_annex'], - 'business_review_total_amount' => $params['business_review_total_amount'], - 'tax_rate' => $params['tax_rate'], - 'pay_type' => $params['pay_type'], - 'pay_rate' => $params['pay_rate'], - 'business_contract_deviation' => $params['business_contract_deviation'], - 'business_contract_deviation_handling_plan' => $params['business_contract_deviation_handling_plan'], - 'business_contract_deviation_annex' => $params['business_contract_deviation_annex'] + 'bidding_project_overview' => $params['bidding_project_overview'] ?? '', + 'project_introduction' => $params['project_introduction'] ?? '', + 'annex' => $params['annex'] ?? '', + 'technical_protocol_deviation' => $params['technical_protocol_deviation'] ?? '', + 'protocol_deviation_handling_plan' => $params['protocol_deviation_handling_plan'] ?? '', + 'technical_review_annex' => $params['technical_review_annex'] ?? '', + 'business_review_total_amount' => $params['business_review_total_amount'] ?? 0, + 'tax_rate' => $params['tax_rate'] ?? 0, + 'pay_type' => $params['pay_type'] ?? 0, + 'pay_rate' => $params['pay_rate'] ?? '', + 'business_contract_deviation' => $params['business_contract_deviation'] ?? '', + 'business_contract_deviation_handling_plan' => $params['business_contract_deviation_handling_plan'] ?? '', + 'business_contract_deviation_annex' => $params['business_contract_deviation_annex'] ?? '', ]); - + BidDocumentExaminationDetail::where('bid_document_examination_id', $params['id'])->delete(); + foreach ($params['product'] ?? [] as $item) + { + BidDocumentExaminationDetail::create([ + 'bid_document_examination_id' => $params['id'], + 'product_id' => $item['product_id'] ?? 0, + 'product_num' => $item['product_num'] ?? 0, + 'cost_unit_price' => $item['cost_unit_price'] ?? 0, + 'amount' => $item['amount'] ?? '', + 'rate' => $item['rate'] ?? '', + 'unit_price' => $item['unit_price'] ?? 0, + 'total_amount' => $item['total_amount'] ?? 0 + ]); + } Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/adminapi/validate/bid/BidDocumentExaminationValidate.php b/app/adminapi/validate/bid/BidDocumentExaminationValidate.php index 04949f82d..793d5d3ea 100644 --- a/app/adminapi/validate/bid/BidDocumentExaminationValidate.php +++ b/app/adminapi/validate/bid/BidDocumentExaminationValidate.php @@ -32,6 +32,7 @@ class BidDocumentExaminationValidate extends BaseValidate */ protected $rule = [ 'id' => 'require', + 'buy_bidding_document_id' => 'require', 'product' => 'array|checkProduct', ]; @@ -65,7 +66,7 @@ class BidDocumentExaminationValidate extends BaseValidate */ public function sceneEdit() { - return $this->only(['id', 'product']); + return $this->only(['id', 'buy_bidding_document_id', 'product']); } @@ -94,16 +95,32 @@ class BidDocumentExaminationValidate extends BaseValidate public function checkProduct($value, $rule, $data) { - $firstData = $value[0]; - // if (empty($firstData['product_id'])) { - // return '产品ID不能为空!'; - // } - // if (empty($firstData['product_num'])) { - // return '产品数量不能为空!'; - // } - // if (empty($firstData['tax_rate'])) { - // return '产品税率不能为空!'; - // } + $firstData = $value[0] ?? []; + if (empty($firstData)) { + return true; + } else { + if (empty($firstData['product_id'])) { + return '产品ID不能为空!'; + } + if (empty($firstData['product_num'])) { + return '产品数量不能为空!'; + } + if (empty($firstData['cost_unit_price'])) { + return '成本单价不能为空!'; + } + if (empty($firstData['amount'])) { + return '金额不能为空!'; + } + if (empty($firstData['rate'])) { + return '点数不能为空!'; + } + if (empty($firstData['unit_price'])) { + return '报价单价不能为空!'; + } + if (empty($firstData['total_amount'])) { + return '报价金额不能为空!'; + } + } return true; } diff --git a/app/adminapi/validate/quotation/QuotationValidate.php b/app/adminapi/validate/quotation/QuotationValidate.php index 620b0a1dc..5e5418da3 100644 --- a/app/adminapi/validate/quotation/QuotationValidate.php +++ b/app/adminapi/validate/quotation/QuotationValidate.php @@ -94,7 +94,7 @@ class QuotationValidate extends BaseValidate public function checkProduct($value, $rule, $data) { - $firstData = $value[0]; + $firstData = $value[0] ?? []; if (empty($firstData['product_id'])) { return '产品ID不能为空!'; } diff --git a/app/common/model/bid/BidDocumentExamination.php b/app/common/model/bid/BidDocumentExamination.php index 70597d01c..86c93bba3 100644 --- a/app/common/model/bid/BidDocumentExamination.php +++ b/app/common/model/bid/BidDocumentExamination.php @@ -35,4 +35,14 @@ class BidDocumentExamination extends BaseModel return $this->belongsTo(\app\common\model\bid\BidBuyBiddingDocument::class, 'buy_bidding_document_id'); } + public function getBidOpeningDateAttr($value) + { + return empty($value) ? '' : date('Y-m-d H:i:s', $value); + } + + public function getDepositRefundTimeAttr($value) + { + return empty($value) ? '' : date('Y-m-d H:i:s', $value); + } + } \ No newline at end of file