$params['project_id'], 'bid_decision_id' => $params['bid_decision_id'], 'bid_document_no' => data_unique_code('购买标书'), 'invite_tenders_company_name' => $params['invite_tenders_company_name'], 'bid_company_name' => $params['bid_company_name'], 'buyer' => $params['buyer'] ?? 0, 'amount' => $params['amount'] ?? 0, 'buy_date' => !empty($params['buy_date']) ? strtotime($params['buy_date']) : 0, ]); 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:22 */ public static function edit(array $params): bool { Db::startTrans(); try { BidBuyBiddingDocument::where('id', $params['id'])->update([ 'project_id' => $params['project_id'], 'bid_decision_id' => $params['bid_decision_id'], 'invite_tenders_company_name' => $params['invite_tenders_company_name'], 'bid_company_name' => $params['bid_company_name'], 'buyer' => $params['buyer'] ?? 0, 'amount' => $params['amount'] ?? 0, 'buy_date' => !empty($params['buy_date']) ? strtotime($params['buy_date']) : 0, '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:22 */ public static function delete(array $params): bool { return BidBuyBiddingDocument::destroy($params['id']); } /** * @notes 获取购买标书详情 * @param $params * @return array * @author likeadmin * @date 2023/11/27 18:22 */ 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']); $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(); $admin = Admin::field('name')->where('id',$data['buyer'])->findOrEmpty(); $data['project_name'] = $project['name']; $data['project_code'] = $project['project_code']; $data['custom_name'] = $custom['name']; $data['bid_decision_code'] = $bid_decision['code']; $data['bidding_time'] = $bid_decision['bidding_time']; $data['bidding_project_fund_source'] = $bid_decision->bidding_project_fund_source_text; $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['buyer'] = $admin['name']; return $data->toArray(); } }