-- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- 主机： localhost
-- 生成日期： 2026-01-25 20:00:28
-- 服务器版本： 5.7.44-log
-- PHP 版本： 7.4.33

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- 数据库： `invoice_system`
--

-- --------------------------------------------------------

--
-- 表的结构 `customer`
--

CREATE TABLE `customer` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL COMMENT '客户名称',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `contact` varchar(50) DEFAULT NULL COMMENT '联系人',
  `phone` varchar(20) DEFAULT NULL COMMENT '联系电话',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态（1=启用，0=禁用）'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客户列表';

--
-- 转存表中的数据 `customer`
--

INSERT INTO `customer` (`id`, `name`, `create_time`, `contact`, `phone`, `status`) VALUES
(1, '河南省中医院', '2026-01-25 09:07:01', NULL, NULL, 1);

-- --------------------------------------------------------

--
-- 表的结构 `invoice`
--

CREATE TABLE `invoice` (
  `id` int(11) NOT NULL,
  `invoice_no` varchar(50) NOT NULL,
  `invoice_date` date NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `supplier_id` int(11) NOT NULL,
  `customer_id` int(11) NOT NULL,
  `remark` text,
  `attach_path` varchar(255) DEFAULT NULL,
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `create_user_id` int(11) NOT NULL COMMENT '创建人ID（关联user表id）'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- 转存表中的数据 `invoice`
--

INSERT INTO `invoice` (`id`, `invoice_no`, `invoice_date`, `amount`, `supplier_id`, `customer_id`, `remark`, `attach_path`, `create_time`, `create_user_id`) VALUES
(2, '26412000000224572816', '2026-01-21', '9480.00', 4, 1, '2打印机1电脑', 'invoice_6975c1f940471.pdf', '2026-01-25 15:10:49', 0),
(5, '26412000000224222956', '2026-01-21', '9370.00', 5, 1, '运动医学科2电脑1打印机', 'invoice_6975ce5494cdb.pdf', '2026-01-25 16:03:32', 0),
(6, '26412000000253175071', '2026-01-23', '24040.00', 5, 1, '五龙口放疗科经费', 'invoice_6975ce7971f6a.pdf', '2026-01-25 16:04:09', 0),
(7, '26412000000253694251', '2026-01-23', '146620.00', 5, 1, '五龙口自筹', 'invoice_6975ce9ee9f03.pdf', '2026-01-25 16:04:46', 0),
(8, '26412000000253740631', '2026-01-23', '16380.00', 5, 1, '五龙口肿瘤三区经费', 'invoice_6975cec379edb.pdf', '2026-01-25 16:05:23', 0),
(9, '26412000000253745461', '2026-01-23', '3780.00', 5, 1, '内科三区三台打印机经费', 'invoice_6975cf052fb2f.pdf', '2026-01-25 16:06:29', 0),
(10, '26412000000253853986', '2026-01-23', '16380.00', 5, 1, '五龙口肿瘤一区', 'invoice_6975cf21a77d1.pdf', '2026-01-25 16:06:57', 0),
(11, '26412000000254177971', '2026-01-23', '3780.00', 5, 1, '肿瘤二区', 'invoice_6975cf3fae87d.pdf', '2026-01-25 16:07:27', 0),
(12, '26412000000254487256', '2026-01-23', '4830.00', 5, 1, 'icu四台打印机', 'invoice_6975cf664dc32.pdf', '2026-01-25 16:08:06', 0),
(13, '26412000000257673631', '2026-01-23', '50610.00', 5, 1, '本部自筹电脑打印机', 'invoice_6975cf93b4049.pdf', '2026-01-25 16:08:51', 0),
(14, '26412000000257687176', '2026-01-23', '6140.00', 5, 1, '老年病科1电脑2打印机', 'invoice_6975cfba099b4.pdf', '2026-01-25 16:09:30', 0),
(15, '26412000000258135901', '2026-01-23', '4200.00', 5, 1, '脑病三区1电脑', 'invoice_6975cfe8ec07d.pdf', '2026-01-25 16:10:16', 0),
(16, '26412000000260568601', '2026-01-23', '12600.00', 5, 1, '发热门诊3电脑经费', 'invoice_6975d023dc07c.pdf', '2026-01-25 16:11:15', 0),
(17, '26412000000162612601', '2026-01-15', '6300.00', 6, 1, '感控科经费', 'invoice_6975f8e038bb1.pdf', '2026-01-25 19:05:04', 2),
(18, '26412000000160772491', '2026-01-15', '800.00', 6, 1, '明亮用', 'invoice_6975f91fa4d2d.pdf', '2026-01-25 19:06:07', 2);

-- --------------------------------------------------------

--
-- 表的结构 `invoice_info`
--

CREATE TABLE `invoice_info` (
  `id` int(10) UNSIGNED NOT NULL COMMENT '主键ID',
  `invoice_no` varchar(50) NOT NULL COMMENT '发票号码',
  `amount` decimal(10,2) NOT NULL COMMENT '发票金额',
  `invoice_date` date NOT NULL COMMENT '开票日期',
  `supplier` varchar(100) DEFAULT NULL COMMENT '开票方（手工补充）',
  `purchaser` varchar(100) DEFAULT NULL COMMENT '购方名称（手工补充）',
  `remark` varchar(500) DEFAULT '' COMMENT '备注',
  `handler_id` int(11) NOT NULL DEFAULT '0' COMMENT '经手人ID',
  `handler_name` varchar(50) NOT NULL DEFAULT '' COMMENT '经手人姓名',
  `status` enum('已收票','流转中','已结账') DEFAULT '已收票' COMMENT '发票状态',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '录入时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `attach_path` varchar(255) DEFAULT NULL COMMENT '发票附件路径'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='发票信息表';

-- --------------------------------------------------------

--
-- 表的结构 `supplier`
--

CREATE TABLE `supplier` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL COMMENT '供应商名称',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
  `contact` varchar(50) DEFAULT NULL COMMENT '联系人',
  `phone` varchar(20) DEFAULT NULL COMMENT '联系电话',
  `status` tinyint(1) DEFAULT '1' COMMENT '状态（1=启用，0=禁用）'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='供应商列表';

--
-- 转存表中的数据 `supplier`
--

INSERT INTO `supplier` (`id`, `name`, `create_time`, `contact`, `phone`, `status`) VALUES
(4, '河南广智中源信息技术有限公司', '2026-01-25 15:09:41', '马先生', '', 1),
(5, '河南坤元电子科技有限公司', '2026-01-25 15:18:39', '', '', 1),
(6, '郑州分时电子科技有限公司', '2026-01-25 15:19:01', '', '', 1),
(7, '苏星电子', '2026-01-25 19:03:40', '', '', 1),
(8, '河南联通', '2026-01-25 19:03:47', '', '', 1);

-- --------------------------------------------------------

--
-- 表的结构 `sys_user`
--

CREATE TABLE `sys_user` (
  `id` int(11) NOT NULL COMMENT '用户ID',
  `username` varchar(50) NOT NULL COMMENT '登录账号',
  `password` varchar(100) NOT NULL COMMENT '密码（md5加密）',
  `realname` varchar(50) NOT NULL COMMENT '真实姓名',
  `role` varchar(20) NOT NULL DEFAULT 'operator' COMMENT '角色：admin/operator',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态：1启用 0禁用',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统用户表';

--
-- 转存表中的数据 `sys_user`
--

INSERT INTO `sys_user` (`id`, `username`, `password`, `realname`, `role`, `status`, `create_time`) VALUES
(1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', '系统管理员', 'admin', 1, '2026-01-25 10:09:37'),
(2, 'lml', 'e10adc3949ba59abbe56e057f20f883e', '李明亮', 'admin', 1, '2026-01-25 10:33:10');

-- --------------------------------------------------------

--
-- 表的结构 `user`
--

CREATE TABLE `user` (
  `id` int(11) NOT NULL COMMENT '用户ID',
  `username` varchar(50) NOT NULL COMMENT '登录用户名',
  `password` varchar(32) NOT NULL COMMENT '登录密码（MD5加密）',
  `realname` varchar(50) NOT NULL COMMENT '真实姓名',
  `phone` varchar(20) DEFAULT '' COMMENT '联系电话',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '账号状态：1-启用 0-禁用',
  `role` tinyint(1) NOT NULL DEFAULT '2' COMMENT '角色：1-管理员 2-普通用户',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='系统用户表';

--
-- 转存表中的数据 `user`
--

INSERT INTO `user` (`id`, `username`, `password`, `realname`, `phone`, `status`, `role`, `create_time`) VALUES
(1, 'admin', 'e10adc3949ba59abbe56e057f20f883e', '系统管理员', '', 1, 1, '2026-01-25 18:19:57'),
(2, 'lml', 'e10adc3949ba59abbe56e057f20f883e', '李明亮', '', 1, 1, '2026-01-25 18:23:54');

--
-- 转储表的索引
--

--
-- 表的索引 `customer`
--
ALTER TABLE `customer`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `name` (`name`),
  ADD KEY `idx_name` (`name`);

--
-- 表的索引 `invoice`
--
ALTER TABLE `invoice`
  ADD PRIMARY KEY (`id`),
  ADD KEY `supplier_id` (`supplier_id`),
  ADD KEY `customer_id` (`customer_id`);

--
-- 表的索引 `invoice_info`
--
ALTER TABLE `invoice_info`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `idx_invoice_no` (`invoice_no`),
  ADD KEY `idx_invoice_date` (`invoice_date`),
  ADD KEY `idx_supplier` (`supplier`),
  ADD KEY `idx_purchaser` (`purchaser`),
  ADD KEY `idx_status` (`status`);

--
-- 表的索引 `supplier`
--
ALTER TABLE `supplier`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `name` (`name`),
  ADD KEY `idx_name` (`name`);

--
-- 表的索引 `sys_user`
--
ALTER TABLE `sys_user`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `idx_username` (`username`);

--
-- 表的索引 `user`
--
ALTER TABLE `user`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`);

--
-- 在导出的表使用AUTO_INCREMENT
--

--
-- 使用表AUTO_INCREMENT `customer`
--
ALTER TABLE `customer`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- 使用表AUTO_INCREMENT `invoice`
--
ALTER TABLE `invoice`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;

--
-- 使用表AUTO_INCREMENT `invoice_info`
--
ALTER TABLE `invoice_info`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键ID', AUTO_INCREMENT=6;

--
-- 使用表AUTO_INCREMENT `supplier`
--
ALTER TABLE `supplier`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;

--
-- 使用表AUTO_INCREMENT `sys_user`
--
ALTER TABLE `sys_user`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID', AUTO_INCREMENT=3;

--
-- 使用表AUTO_INCREMENT `user`
--
ALTER TABLE `user`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID', AUTO_INCREMENT=4;

--
-- 限制导出的表
--

--
-- 限制表 `invoice`
--
ALTER TABLE `invoice`
  ADD CONSTRAINT `invoice_ibfk_1` FOREIGN KEY (`supplier_id`) REFERENCES `supplier` (`id`),
  ADD CONSTRAINT `invoice_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`);
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
