rentease-backend-new/routes/billing.js

71 lines
2.8 KiB
JavaScript
Raw Permalink Normal View History

2026-04-20 06:43:09 +00:00
const express = require('express');
const router = express.Router();
const billingController = require('../controllers/billingController');
const { authMiddleware } = require('../middleware/auth');
const { superAdminMiddleware } = require('../middleware/tenant');
// 套餐管理路由
// 获取所有套餐 - 需要认证
router.get('/plans', authMiddleware, billingController.getAllPlans);
// 创建套餐 - 仅超级管理员
router.post('/plans', authMiddleware, superAdminMiddleware, billingController.createPlan);
// 更新套餐 - 仅超级管理员
router.put('/plans/:id', authMiddleware, superAdminMiddleware, billingController.updatePlan);
// 删除套餐 - 仅超级管理员
router.delete('/plans/:id', authMiddleware, superAdminMiddleware, billingController.deletePlan);
// 设置默认套餐 - 仅超级管理员
router.put('/plans/:id/default', authMiddleware, superAdminMiddleware, billingController.setDefaultPlan);
// 价格配置路由
// 获取价格配置 - 需要认证
router.get('/pricing', authMiddleware, billingController.getPricingConfig);
// 更新价格配置 - 仅超级管理员
router.put('/pricing', authMiddleware, superAdminMiddleware, billingController.updatePricingConfig);
// 订单管理路由
// 获取订单列表 - 需要认证(超级管理员可查看所有)
router.get('/orders', authMiddleware, billingController.getOrders);
// 创建续费订单 - 需要认证
router.post('/orders', authMiddleware, billingController.createOrder);
// 计算续费价格(含超额费用)- 需要认证
router.post('/calculate-price', authMiddleware, billingController.calculatePrice);
// 获取订单详情 - 需要认证
router.get('/orders/:id', authMiddleware, billingController.getOrderDetail);
// 取消订单 - 需要认证
router.put('/orders/:id/cancel', authMiddleware, billingController.cancelOrder);
// 支付订单 - 需要认证
router.post('/orders/:id/pay', authMiddleware, billingController.payOrder);
// 支付记录路由
// 获取支付记录 - 需要认证(超级管理员可查看所有)
router.get('/payments', authMiddleware, billingController.getPayments);
// 计费信息路由
// 获取当前租户计费信息 - 需要认证
router.get('/info', authMiddleware, billingController.getBillingInfo);
// 获取资源使用情况 - 需要认证
router.get('/usage', authMiddleware, billingController.getUsageStats);
// 获取计费统计 - 仅超级管理员
router.get('/stats', authMiddleware, superAdminMiddleware, billingController.getBillingStats);
// 支付设置路由
// 获取支付设置 - 需要认证
router.get('/payment-settings', authMiddleware, billingController.getPaymentSettings);
// 更新支付设置 - 仅超级管理员
router.put('/payment-settings', authMiddleware, superAdminMiddleware, billingController.updatePaymentSettings);
module.exports = router;