171 lines
3.8 KiB
TypeScript
171 lines
3.8 KiB
TypeScript
export type DiscountCodeType = "percentage" | "fixed" | "fee_percentage";
|
|
|
|
export type DiscountApplicationLevel =
|
|
| "invoice"
|
|
| "category"
|
|
| "product"
|
|
| "shipping"
|
|
| "product_fee";
|
|
|
|
export type DiscountApplicationLevels =
|
|
| DiscountApplicationLevel
|
|
| DiscountApplicationLevel[];
|
|
|
|
export type DiscountStatus = "active" | "inactive";
|
|
|
|
export type DiscountReportViewMode = "simple" | "detailed";
|
|
|
|
export type DiscountReportSortBy =
|
|
| "usage_count"
|
|
| "amount"
|
|
| "date"
|
|
| "code"
|
|
| "created_at";
|
|
|
|
export type DiscountReportSortOrder = "asc" | "desc";
|
|
|
|
export type UserGroup = "new" | "loyal" | "all";
|
|
|
|
export interface DiscountUserRestrictions {
|
|
user_ids?: number[];
|
|
user_group?: UserGroup;
|
|
min_purchase_count?: number;
|
|
max_purchase_count?: number;
|
|
referrer_user_id?: number;
|
|
new_users_only?: boolean;
|
|
loyal_users_only?: boolean;
|
|
}
|
|
|
|
export interface DiscountMeta {
|
|
[key: string]: string | number | boolean | null;
|
|
}
|
|
|
|
export interface SteppedDiscountStep {
|
|
min_amount: number;
|
|
value: number;
|
|
}
|
|
|
|
export interface SteppedDiscount {
|
|
steps: SteppedDiscountStep[];
|
|
}
|
|
|
|
export interface DiscountCode {
|
|
id: number;
|
|
code: string;
|
|
name: string;
|
|
description?: string;
|
|
type: DiscountCodeType;
|
|
value: number;
|
|
status: DiscountStatus;
|
|
application_level: DiscountApplicationLevels;
|
|
min_purchase_amount?: number;
|
|
max_discount_amount?: number;
|
|
usage_limit?: number;
|
|
user_usage_limit?: number;
|
|
single_use: boolean;
|
|
valid_from?: string;
|
|
valid_to?: string;
|
|
user_restrictions?: DiscountUserRestrictions;
|
|
stepped_discount?: SteppedDiscount;
|
|
meta?: DiscountMeta;
|
|
product_ids?: number[];
|
|
category_ids?: number[];
|
|
created_at?: string;
|
|
updated_at?: string;
|
|
}
|
|
|
|
export interface DiscountCodeFilters {
|
|
page?: number;
|
|
limit?: number;
|
|
status?: DiscountStatus;
|
|
type?: DiscountCodeType;
|
|
application_level?: DiscountApplicationLevels;
|
|
code?: string;
|
|
active_only?: boolean;
|
|
}
|
|
|
|
export interface DiscountReportFilters {
|
|
view_mode?: DiscountReportViewMode;
|
|
discount_code?: string;
|
|
discount_id?: number;
|
|
user_id?: number;
|
|
status?: "active" | "inactive" | "expired";
|
|
type?: DiscountCodeType;
|
|
application_level?: DiscountApplicationLevel;
|
|
from_date?: string;
|
|
to_date?: string;
|
|
min_usage_count?: number;
|
|
include_unused?: boolean;
|
|
group_by_code?: boolean;
|
|
sort_by?: DiscountReportSortBy;
|
|
sort_order?: DiscountReportSortOrder;
|
|
limit?: number;
|
|
offset?: number;
|
|
}
|
|
|
|
export interface DiscountReportUsage {
|
|
discount_id: number;
|
|
discount_code: string;
|
|
discount_name: string;
|
|
usage_count: number;
|
|
total_amount: number;
|
|
unique_users: number;
|
|
first_used_at: string;
|
|
last_used_at: string;
|
|
}
|
|
|
|
export interface DiscountReportSummarySimple {
|
|
total_usages: number;
|
|
total_discount_given: number;
|
|
unique_users: number;
|
|
unique_codes: number;
|
|
}
|
|
|
|
export interface DiscountReportSimpleResponse {
|
|
usages: DiscountReportUsage[];
|
|
summary: DiscountReportSummarySimple;
|
|
total: number;
|
|
has_more: boolean;
|
|
}
|
|
|
|
export interface CreateDiscountCodeRequest {
|
|
code: string;
|
|
name: string;
|
|
description?: string;
|
|
type: DiscountCodeType;
|
|
value: number;
|
|
status: DiscountStatus;
|
|
application_level: DiscountApplicationLevels;
|
|
min_purchase_amount?: number;
|
|
max_discount_amount?: number;
|
|
usage_limit?: number;
|
|
user_usage_limit?: number;
|
|
single_use: boolean;
|
|
valid_from?: string;
|
|
valid_to?: string;
|
|
user_restrictions?: DiscountUserRestrictions;
|
|
stepped_discount?: SteppedDiscount;
|
|
meta?: DiscountMeta;
|
|
product_ids?: number[];
|
|
category_ids?: number[];
|
|
}
|
|
|
|
export interface UpdateDiscountCodeRequest
|
|
extends Partial<CreateDiscountCodeRequest> {
|
|
id: number;
|
|
}
|
|
|
|
export interface PaginatedDiscountCodesResponse {
|
|
discount_codes: DiscountCode[];
|
|
total: number;
|
|
page: number;
|
|
limit: number;
|
|
total_pages: number;
|
|
}
|
|
|
|
export type Response<T> = {
|
|
data: T;
|
|
message?: string;
|
|
success?: boolean;
|
|
};
|