From 36fb8659f0bd7a568c7c0d5b5713039a95ff2d2b Mon Sep 17 00:00:00 2001 From: RogerLi Date: Fri, 28 Jun 2024 22:43:10 +0800 Subject: [PATCH] fix: add default value to thirdPartyPaymentId and paidAt --- src/models/order.ts | 3 ++- src/types/order.type.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/models/order.ts b/src/models/order.ts index 1e4c2bb..d76281b 100644 --- a/src/models/order.ts +++ b/src/models/order.ts @@ -32,7 +32,7 @@ const { userId, productId, plan } = schemaDef; const schema = new Schema( { - thirdPartyPaymentId: { type: String }, + thirdPartyPaymentId: { type: String, default: '' }, userId, products: { type: [ @@ -61,6 +61,7 @@ const schema = new Schema( }, paidAt: { type: Date, + default: '', }, deliveryInfo: { type: { diff --git a/src/types/order.type.ts b/src/types/order.type.ts index 0fac6b4..0e73516 100644 --- a/src/types/order.type.ts +++ b/src/types/order.type.ts @@ -2,6 +2,7 @@ import { IUserReq, TPaginationQuery } from './common.type'; import { IPlan, IProductId } from './product.type'; import { IProduct } from '../models/product'; import { Types } from 'mongoose'; +import { IOrder } from '../models/order'; export enum PaymentMethod { linePay = 'linePay', @@ -105,3 +106,13 @@ export interface IUpdateOrderParam extends IOrderId { export interface INewebPayCheckOrderReq extends IUserReq { body: { TradeInfo: string; TradeSha: unknown }; } + +export interface IGetOrderParam extends IOrder { + thirdPartyPaymentId: string; + paidAt: Date; +} + +export type OrderDocumentWithPayment = Document & + IGetOrderParam & { + _id: Types.ObjectId; + };