Files
zhiyin/backend/src/modules/payment/payment-order.schema.ts
T
yuzhiran c161ffbc3c feat: payment refund support + admin payment management
- Add refund()/queryRefund()/downloadPlatformCerts() to WechatPayService
- Add refundId field to PaymentOrder schema
- Fix WeChat Pay callback to auto-download platform certs on verification failure
- Fix syncOrder to handle sprint plan properly
- Add admin refund, refund-query, order-detail endpoints
- Add refund UI (button, modal, query) to admin.vue orders tab
- Fix member.vue MP payment: pass outTradeNo instead of prepayId to pollPayResult
2026-06-18 19:33:10 +08:00

65 lines
1.4 KiB
TypeScript

import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import { Document } from 'mongoose'
export type PaymentOrderDocument = PaymentOrder & Document
@Schema({ timestamps: true })
export class PaymentOrder {
@Prop({ required: true, index: true })
outTradeNo: string
@Prop({ required: true, index: true })
userId: string
@Prop({ default: '' })
userPhone?: string
@Prop({ required: true })
amount: number // 分
@Prop({ required: true })
title: string
@Prop({ default: '' })
description?: string
// pending | success | failed | refunded | partial_refund
@Prop({ default: 'pending' })
status: string
@Prop({ default: 'membership' })
type: string // membership | interview | optimize | download
@Prop({ default: 'growth' })
plan: string // growth | sprint
@Prop({ default: 'native' })
channel: string // native | jsapi
@Prop({ type: Object })
metadata?: Record<string, any>
@Prop()
paidAt?: Date
@Prop()
wxTransactionId?: string
// 退款
@Prop({ default: 0 })
refundAmount?: number
@Prop()
refundedAt?: Date
@Prop()
refundReason?: string
@Prop()
refundId?: string // 微信退款单号
}
export const PaymentOrderSchema = SchemaFactory.createForClass(PaymentOrder)
PaymentOrderSchema.index({ createdAt: -1 })
PaymentOrderSchema.index({ status: 1, createdAt: -1 })