This commit is contained in:
mahyargdz
2025-09-14 15:15:03 +03:30
commit be82059172
534 changed files with 51310 additions and 0 deletions
@@ -0,0 +1,12 @@
import { Types } from "mongoose";
import { OrderItemsStatus } from "../../../../common/enums/order.enum";
import { CancellerRefEnum } from "../cancel.model";
export interface ICancelOrder {
order: number;
canceller: Types.ObjectId;
cancellerRef: CancellerRefEnum;
status: OrderItemsStatus;
total_price: number;
}
@@ -0,0 +1,13 @@
import { Types } from "mongoose";
import { OrderItemsStatus } from "../../../../common/enums/order.enum";
export interface ICancelOrderItem {
cancelOrderId: Types.ObjectId;
orderItem: Types.ObjectId;
shipmentItem: Types.ObjectId;
quantity: number;
comment: string;
reason: Types.ObjectId;
status: OrderItemsStatus;
}
@@ -0,0 +1,7 @@
import { Types } from "mongoose";
export interface ICancelReason {
title: string;
fineRule: Types.ObjectId;
deleted: boolean;
}
+24
View File
@@ -0,0 +1,24 @@
import { Schema, model } from "mongoose";
import { ICancelOrder } from "./Abstraction/ICancel";
import { OrderItemsStatus } from "../../../common/enums/order.enum";
export enum CancellerRefEnum {
User = "User",
Seller = "Seller",
Admin = "Admin",
}
const CancelOrderSchema = new Schema<ICancelOrder>(
{
order: { type: Number, ref: "Order", required: true },
canceller: { type: Schema.Types.ObjectId, refPath: "cancellerRef", required: true },
cancellerRef: { type: String, enum: CancellerRefEnum, required: true },
status: { type: String, enum: OrderItemsStatus, default: OrderItemsStatus.cancelled_system },
total_price: { type: Number, default: 0 },
},
{ timestamps: true, toJSON: { versionKey: false, virtuals: true }, id: false },
);
const CancelOrderModel = model<ICancelOrder>("CancelOrder", CancelOrderSchema);
export { CancelOrderModel };
@@ -0,0 +1,20 @@
import { Schema, model } from "mongoose";
import { ICancelOrderItem } from "./Abstraction/ICancelItem";
import { OrderItemsStatus } from "../../../common/enums/order.enum";
//TODO:add a refund model to refund user after complete return
const CancelOrderItemSchema = new Schema<ICancelOrderItem>(
{
cancelOrderId: { type: Schema.Types.ObjectId, ref: "CancelOrder", required: true },
orderItem: { type: Schema.Types.ObjectId, ref: "OrderItem", required: true },
shipmentItem: { type: Schema.Types.ObjectId, required: true },
quantity: { type: Number, required: true },
comment: { type: String, required: true },
reason: { type: Schema.Types.ObjectId, ref: "CancelReason", required: true },
status: { type: String, enum: OrderItemsStatus, default: OrderItemsStatus.cancelled_system },
},
{ timestamps: true, toJSON: { versionKey: false, virtuals: true }, id: false },
);
const CancelOrderItemModel = model<ICancelOrderItem>("CancelOrderItem", CancelOrderItemSchema);
export { CancelOrderItemModel };
@@ -0,0 +1,16 @@
import { Schema, model } from "mongoose";
import { ICancelReason } from "./Abstraction/ICancelReason";
const CancelReasonSchema = new Schema<ICancelReason>(
{
title: { type: String, required: true, unique: true },
fineRule: { type: Schema.Types.ObjectId, ref: "FineRule", required: true },
deleted: { type: Boolean, default: false },
},
{ timestamps: true, toJSON: { versionKey: false, virtuals: true }, id: false },
);
const CancelReasonModel = model<ICancelReason>("CancelReason", CancelReasonSchema);
export { CancelReasonModel };