This commit is contained in:
2026-04-22 20:03:10 +08:00
parent 4047f87e8c
commit 7473fdcc03
65 changed files with 13311 additions and 10192 deletions
+4 -1
View File
@@ -138,6 +138,8 @@ CREATE TABLE `rooms` (
`cover_image` VARCHAR(500) DEFAULT '' COMMENT '封面图',
`price` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT 0.00 COMMENT '基础价格/晚',
`status` ENUM('on_sale','off_sale') NOT NULL DEFAULT 'on_sale' COMMENT '状态',
`audit_status` ENUM('pending','approved','rejected') NOT NULL DEFAULT 'pending' COMMENT '审核状态',
`audit_reject_reason` VARCHAR(500) DEFAULT NULL COMMENT '审核拒绝原因',
`rating` DECIMAL(2,1) UNSIGNED DEFAULT 5.0 COMMENT '评分',
`review_count` INT UNSIGNED DEFAULT 0 COMMENT '评价数',
`description` TEXT COMMENT '房源描述',
@@ -148,7 +150,8 @@ CREATE TABLE `rooms` (
KEY `idx_merchant_id` (`merchant_id`),
KEY `idx_type` (`type`),
KEY `idx_status_price` (`status`,`price`),
KEY `idx_rating` (`rating`)
KEY `idx_rating` (`rating`),
KEY `idx_audit_status` (`audit_status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='房型/房源表';
-- ============================================================
+4 -4
View File
@@ -5,13 +5,13 @@ USE `rent_platform`;
-- 平台管理员账号 (密码: admin123)
INSERT INTO `admins` (`username`, `password`, `name`, `phone`, `role`, `status`) VALUES
('admin', '$2b$10$N9qo8uLOickgx2ZMRZoMy.Mrq7Y5g0kOPIl7vJfzOTfJ7qKqOqOAa', '超级管理员', '13800000000', 'super_admin', 'active'),
('operator', '$2b$10$N9qo8uLOickgx2ZMRZoMy.Mrq7Y5g0kOPIl7vJfzOTfJ7qKqOqOAa', '运营人员', '13800000001', 'operator', 'active');
('admin', '$2b$10$CSNiniLMqNxguD4jkpOPYO5Exer2QyhwbGRwqLEKUJRmfI694WRd6', '超级管理员', '13800000000', 'super_admin', 'active'),
('operator', '$2b$10$CSNiniLMqNxguD4jkpOPYO5Exer2QyhwbGRwqLEKUJRmfI694WRd6', '运营人员', '13800000001', 'operator', 'active');
-- 商家账号 (密码: seller123)
INSERT INTO `sellers` (`phone`, `password`, `contact_name`, `email`, `status`) VALUES
('13900000001', '$2b$10$N9qo8uLOickgx2ZMRZoMy.Mrq7Y5g0kOPIl7vJfzOTfJ7qKqOqOAa', '张经理', 'zhang@example.com', 'active'),
('13900000002', '$2b$10$N9qo8uLOickgx2ZMRZoMy.Mrq7Y5g0kOPIl7vJfzOTfJ7qKqOqOAa', '李老板', 'li@example.com', 'active');
('13900000001', '$2b$10$CSNiniLMqNxguD4jkpOPYO5Exer2QyhwbGRwqLEKUJRmfI694WRd6', '张经理', 'zhang@example.com', 'active'),
('13900000002', '$2b$10$CSNiniLMqNxguD4jkpOPYO5Exer2QyhwbGRwqLEKUJRmfI694WRd6', '李老板', 'li@example.com', 'active');
-- 商家店铺信息
INSERT INTO `merchants` (`seller_id`, `shop_name`, `phone`, `city`, `address`, `business_license`, `status`, `rating`) VALUES
+21 -8
View File
@@ -16,7 +16,7 @@
| user_oauth | 第三方账号绑定 | user_id, provider, openid |
| sellers | 商家账户表 | id, phone, password, contact_name, status |
| merchants | 商家表 | seller_id, shop_name, status, rating |
| rooms | 房源表 | merchant_id, name, type, price, status |
| rooms | 房源表 | merchant_id, name, type, price, status, audit_status |
| room_calendar | 房量房价日历 | room_id, date, price, stock, status |
| room_calendar_logs | 房态变更日志 | room_id, operator_id, change_type |
| orders | 订单表 | order_no, user_id, merchant_id, room_id, status |
@@ -92,6 +92,11 @@ orders (1) ──── (1) settlements
- `on_sale` - 在售
- `off_sale` - 已下架
### 房源审核状态 (rooms.audit_status)
- `pending` - 待审核
- `approved` - 已通过
- `rejected` - 已拒绝
### 房源类型 (rooms.type)
- `hotel` - 酒店
- `homestay` - 民宿
@@ -112,6 +117,7 @@ idx_merchants_status (status)
idx_merchants_city (city)
idx_rooms_merchant_id (merchant_id)
idx_rooms_status_price (status, price)
idx_rooms_audit_status (audit_status)
idx_orders_user_id (user_id)
idx_orders_merchant_id (merchant_id)
idx_orders_status (status)
@@ -131,6 +137,20 @@ ORDER BY r.rating DESC
LIMIT 10;
```
### 获取房源日历
```sql
SELECT * FROM room_calendar
WHERE room_id = ? AND date BETWEEN ? AND ?
ORDER BY date;
```
### 批量更新房量房价
```sql
INSERT INTO room_calendar (room_id, date, price, stock, status)
VALUES (?, ?, ?, ?, ?)
ON DUPLICATE KEY UPDATE price = VALUES(price), stock = VALUES(stock), status = VALUES(status);
```
### 获取用户订单
```sql
SELECT o.*, r.name as room_name, m.shop_name
@@ -141,13 +161,6 @@ WHERE o.user_id = ?
ORDER BY o.created_at DESC;
```
### 获取房源日历
```sql
SELECT * FROM room_calendar
WHERE room_id = ? AND date BETWEEN ? AND ?
ORDER BY date;
```
### 更新房量(预订成功)
```sql
UPDATE room_calendar