$params['project_id'], 'project_person_id' => $params['project_person_id'], 'insurance_date' => strtotime($params['insurance_date']), 'due_date' => strtotime($params['due_date']), 'type' => $params['type'], 'insurance_no' => $params['insurance_no'], 'insurance' => $params['insurance'], 'insured_amount' => $params['insured_amount'], 'insurance_company' => $params['insurance_company'], 'insurance_detail' => $params['insurance_detail'], 'invoice_no' => $params['invoice_no'], 'handler' => $params['handler'], 'annex' => $params['annex']? json_encode($params['annex']) : '', ]); 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/25 15:58 */ public static function edit(array $params): bool { Db::startTrans(); try { ProjectInsuranceManagement::where('id', $params['id'])->update([ 'project_id' => $params['project_id'], 'project_person_id' => $params['project_person_id'], 'insurance_date' => strtotime($params['insurance_date']), 'due_date' => strtotime($params['due_date']), 'type' => $params['type'], 'insurance_no' => $params['insurance_no'], 'insurance' => $params['insurance'], 'insured_amount' => $params['insured_amount'], 'insurance_company' => $params['insurance_company'], 'insurance_detail' => $params['insurance_detail'], 'invoice_no' => $params['invoice_no'], 'handler' => $params['handler'], 'annex' => $params['annex']? json_encode($params['annex']) : '', ]); 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/25 15:58 */ public static function delete(array $params): bool { return ProjectInsuranceManagement::destroy($params['id']); } /** * @notes 获取保险管理详情 * @param $params * @return array * @author likeadmin * @date 2023/12/25 15:58 */ public static function detail($params): array { $data = ProjectInsuranceManagement::findOrEmpty($params['id'])->toArray(); $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); $person = ProjectPersonnel::field('name,idcard')->where('id',$data['project_person_id'])->findOrEmpty(); $data['project_name'] = $project['name']; $data['project_code'] = $project['project_code']; $data['person_name'] = $person['name']; $data['person_idcard'] = $person['idcard']; return $data; } }