where('id',$params['buy_bidding_document_id'])->findOrEmpty(); Db::startTrans(); try { $bidDocumentExamination = BidDocumentExamination::create([ 'code' => data_unique_code('标书审查'), 'project_id' => $buy_bidding_document['project_id'], 'buy_bidding_document_id' => $params['buy_bidding_document_id'], 'technical_protocol_deviation' => $params['technical_protocol_deviation'] ?? '', 'protocol_deviation_handling_plan' => $params['protocol_deviation_handling_plan'] ?? '', 'technical_review_annex' => !empty($params['technical_review_annex']) ? $params['technical_review_annex'] : null, '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' => !empty($params['business_contract_deviation_annex']) ? $params['business_contract_deviation_annex'] : null, ]); if(!empty($params['quotation_detail'])){ $quotation_detail = $params['quotation_detail']; foreach ($quotation_detail as $item) { BidDocumentExaminationDetail::create([ 'bid_document_examination_id' => $bidDocumentExamination->id, 'product_id' => $item['product_id'], 'num' => $item['num'], 'points' => $item['points'] ?? 0, 'cost_price' => $item['cost_price'], 'sale_price' => $item['sale_price'], 'cost_amount' => $item['cost_price'] * $item['num'], 'sale_amount' => $item['sale_price'] * $item['num'], 'add_user' => $admin_id, 'update_user' => $admin_id ]); } } Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 获取标书审查详情 * @param $params * @return array * @author likeadmin * @date 2023/12/02 09:52 */ public static function detail($params): array { $field = 'id,code,project_id,buy_bidding_document_id,technical_protocol_deviation,protocol_deviation_handling_plan,technical_review_annex,tax_rate,pay_type,pay_rate,business_contract_deviation,business_contract_deviation_handling_plan,business_contract_deviation_annex'; $data = BidDocumentExamination::field($field)->findOrEmpty($params['id']); $project = Project::field('custom_id,name')->where('id',$data['project_id'])->findOrEmpty(); $custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty(); $bid_buy_doc = BidBuyBiddingDocument::field('bid_decision_id,bid_document_no,buyer,invite_tenders_company_name,bid_company_name,amount,buy_date')->where('id',$data['buy_bidding_document_id'])->findOrEmpty(); $buyer = Admin::field('name')->where('id',$bid_buy_doc['buyer'])->findOrEmpty(); $bid_decision = BidBiddingDecision::field('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',$bid_buy_doc['bid_decision_id'])->findOrEmpty(); $data['project_name'] = $project['name']; $data['custom_name'] = $custom['name']; $data['bid_document_no'] = $bid_buy_doc['bid_document_no']; $data['buyer'] = $buyer['name']; $data['invite_tenders_company_name'] = $bid_buy_doc['invite_tenders_company_name']; $data['bid_company_name'] = $bid_buy_doc['bid_company_name']; $data['bid_document_amount'] = $bid_buy_doc['amount']; $data['bidding_project_fund_source'] = $bid_decision->bidding_project_fund_source_text; $data['bidding_time'] = $bid_decision['bidding_time']; $data['buy_date'] = $bid_buy_doc['buy_date']; $data['bid_type'] = $bid_decision->bid_type_text; $data['is_margin'] = $bid_decision->is_margin_text; $data['margin_amount'] = $bid_decision['margin_amount']; $data['bid_opening_date'] = $bid_decision['bid_opening_date']; $data['margin_amount_return_date'] = $bid_decision['margin_amount_return_date']; $data['bid_project_overview'] = $bid_decision['bid_project_overview']; $data['project_desc'] = $bid_decision['project_desc']; $data['annex'] = $bid_decision['annex']; $data['total_amount'] = BidDocumentExaminationDetail::where('bid_document_examination_id',$data['id'])->sum('sale_amount'); return $data->toArray(); } }