$data['employee_id'], 'unionid' => $data['unionid'], 'openid' => $data['openid'], 'type' => isset($data['type']) ? $data['type'] : '3', 'insert_time' => time(), ]; $EmployeeOpenid_id = $this->insertGetId($insert_data); return $EmployeeOpenid_id; } /** * 写入数据 * @author 唐远望 * @version 1.0 * @date 2025-12-04 * @param $data * @return bool */ public function addEmployeeOpenid($data) { DB::beginTransaction(); try { $insert_data = [ 'employee_id' => $data['employee_id'], 'unionid' => $data['unionid'], 'openid' => $data['openid'], 'type' => isset($data['type']) ? $data['type'] : '3', 'insert_time' => time(), ]; $EmployeeOpenid_id = $this->insertGetId($insert_data); DB::commit(); return $EmployeeOpenid_id; // 成功处理... } catch (\Exception $e) { DB::rollBack(); // 错误处理... return false; } } /** * 编辑内容 * @author 唐远望 * @version 1.0 * @date 2025-12-04 * @param $data * @return bool */ public function editEmployeeOpenid_content($where, $data) { $EmployeeOpenid = $this->where($where)->first(); if (!$EmployeeOpenid) { return false; } $EmployeeOpenid->employee_id = $data['employee_id']; $EmployeeOpenid->unionid = $data['unionid']; $EmployeeOpenid->openid = $data['openid']; $EmployeeOpenid->type = isset($data['type']) ? $data['type'] : '3'; $EmployeeOpenid->update_time = time(); $EmployeeOpenid->save(); return true; } /** * 更新数据 * @author 唐远望 * @version 1.0 * @date 2025-12-04 * @param $data * @return bool */ public function updateEmployeeOpenid($EmployeeOpenid, $data) { DB::beginTransaction(); try { $EmployeeOpenid->employee_id = $data['employee_id']; $EmployeeOpenid->unionid = $data['unionid']; $EmployeeOpenid->openid = $data['openid']; $EmployeeOpenid->type = isset($data['type']) ? $data['type'] : '3'; $EmployeeOpenid->update_time = time(); $EmployeeOpenid->save(); DB::commit(); return true; // 成功处理... } catch (\Exception $e) { DB::rollBack(); print_r($e->getMessage()); exit; // 错误处理... return false; } } /** * 删除数据 * @author 唐远望 * @version 1.0 * @date 2025-12-04 * @param $id * @return bool */ public function deleteEmployeeOpenid($where) { $EmployeeOpenid = $this->where($where)->first(); if (!$EmployeeOpenid) { return false; } $EmployeeOpenid->delete(); return true; } }