feat:增加微信支付功能

This commit is contained in:
lik
2026-11-05 16:31:51 +08:00
parent 770f7ebb1d
commit 23b9de16a6
12 changed files with 2126 additions and 13 deletions
+13
View File
@@ -1,5 +1,6 @@
import Router from "koa-router";
import { HandlerEscortRecord } from "../handler/escort_record.js";
import { HandlerPayment } from "../handler/payment.js";
import { HandlerHealthProfile } from "../handler/health_profile.js";
import { HandlerResource } from "../handler/resource.js";
import { HandlerEmployee } from "../handler/employee.js";
@@ -75,6 +76,7 @@ function registerRoutes(app) {
const router = new Router({ prefix: '/health' });
const handlerEscortRecord = new HandlerEscortRecord();
const handlerPayment = new HandlerPayment();
const handlerHealthProfile = new HandlerHealthProfile();
const handlerResource = new HandlerResource();
const handlerEmployee = new HandlerEmployee();
@@ -82,11 +84,22 @@ function registerRoutes(app) {
const handlerTrainingApplication = new HandlerTrainingApplication();
const handlerHospital = new HandlerHospital();
// 微信支付回调:微信服务器直调,无鉴权,靠验签保安全;
// 必须注册在 /escort-record/:id 之前,避免被通用路由抢占
router.post("/pay/notify", handlerPayment.paymentNotify.bind(handlerPayment));
router.post("/pay/refund-notify", handlerPayment.refundNotify.bind(handlerPayment));
// 敏感数据路由需要登录后访问
router.get("/escort-record/my", requireAuth, handlerEscortRecord.getMyRecords.bind(handlerEscortRecord));
router.get("/escort-record/attendant", requireAuth, handlerEscortRecord.getAttendantRecords.bind(handlerEscortRecord));
// 全量查询属管理端能力,必须管理员
router.get("/escort-record", requireAuth, requireAdmin, handlerEscortRecord.getRecords.bind(handlerEscortRecord));
// 支付相关:发起支付 / 查单确认 / 管理端退款查单兜底
router.post("/escort-record/:id/pay", requireAuth, createLimit, handlerPayment.createPayment.bind(handlerPayment));
router.get("/escort-record/:id/pay/status", requireAuth, handlerPayment.queryPayment.bind(handlerPayment));
router.post("/escort-record/:id/refund/query", requireAuth, requireAdmin, handlerPayment.queryRefundResult.bind(handlerPayment));
router.get("/escort-record/:id", requireAuth, handlerEscortRecord.getRecordById.bind(handlerEscortRecord));
router.post("/escort-record", requireAuth, createLimit, handlerEscortRecord.createRecord.bind(handlerEscortRecord));
router.put("/escort-record/:id", requireAuth, updateLimit, handlerEscortRecord.updateRecord.bind(handlerEscortRecord));