zksu
/
API
forked from yoone/API
1
0
Fork 0
API/src/dto/woocommerce.dto.ts

754 lines
17 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// WooCommerce 平台原始数据类型定义
// 仅包含当前映射逻辑所需字段以保持简洁与类型安全
// 产品类型
export interface WooProduct {
// 产品主键
id: number;
// 创建时间
date_created: string;
// 创建时间(GMT)
date_created_gmt: string;
// 更新时间
date_modified: string;
// 更新时间(GMT)
date_modified_gmt: string;
// 产品类型 simple grouped external variable
type: string;
// 产品状态 draft pending private publish
status: string;
// 是否为特色产品
featured: boolean;
// 目录可见性选项:visible, catalog, search and hidden. Default is visible.
catalog_visibility: string;
// 常规价格
regular_price?: string;
// 促销价格
sale_price?: string;
// 当前价格
price?: string;
price_html?: string;
date_on_sale_from?: string; // Date the product is on sale from.
date_on_sale_from_gmt?: string; // Date the product is on sale from (GMT).
date_on_sale_to?: string; // Date the product is on sale to.
date_on_sale_to_gmt?: string; // Date the product is on sale to (GMT).
on_sale: boolean; // Whether the product is on sale.
purchasable: boolean; // Whether the product is purchasable.
total_sales: number; // Total sales for this product.
virtual: boolean; // Whether the product is virtual.
downloadable: boolean; // Whether the product is downloadable.
downloads: Array<{ id?: number; name?: string; file?: string }>; // Downloadable files for the product.
download_limit: number; // Download limit.
download_expiry: number; // Download expiry days.
external_url: string; // URL of the external product.
global_unique_id: string; // GTIN, UPC, EAN or ISBN - a unique identifier for each distinct product and service that can be purchased.
// 产品SKU
sku: string;
// 产品名称
name: string;
// 产品描述
description: string;
// 产品短描述
short_description: string;
// 产品永久链接
permalink: string;
// 产品URL路径
slug: string;
// 库存状态
stock_status?: 'instock' | 'outofstock' | 'onbackorder';
// 库存数量
stock_quantity?: number;
// 是否管理库存
manage_stock?: boolean;
// 缺货预定设置 no notify yes
backorders?: 'no' | 'notify' | 'yes';
// 是否允许缺货预定 只读
backorders_allowed?: boolean;
// 是否处于缺货预定状态 只读
backordered?: boolean;
// 是否单独出售
sold_individually?: boolean;
// 重量
weight?: string;
// 尺寸
dimensions?: { length?: string; width?: string; height?: string };
// 是否需要运输 只读
shipping_required?: boolean;
// 运输是否计税 只读
shipping_taxable?: boolean;
// 运输类别 slug
shipping_class?: string;
// 运输类别ID 只读
shipping_class_id?: number;
// 图片列表
images?: Array<{ id: number; src: string; name?: string; alt?: string }>;
// 属性列表
attributes?: Array<{
id?: number;
name?: string;
position?: number;
visible?: boolean;
variation?: boolean;
options?: string[];
}>;
// 变体列表
variations?: number[];
// 默认变体属性
default_attributes?: Array<{ id?: number; name?: string; option?: string }>;
// 允许评论
reviews_allowed?: boolean;
// 平均评分 只读
average_rating?: string;
// 评分数量 只读
rating_count?: number;
// 相关产品ID列表 只读
related_ids?: number[];
// 追加销售产品ID列表
upsell_ids?: number[];
// 交叉销售产品ID列表
cross_sell_ids?: number[];
// 父产品ID
parent_id?: number;
// 购买备注
purchase_note?: string;
// 分类列表
categories?: Array<{ id?: number; name?: string; slug?: string }>;
// 标签列表
tags?: Array<{ id?: number; name?: string; slug?: string }>;
// 菜单排序
menu_order?: number;
// 元数据
meta_data?: Array<{ id?: number; key: string; value: any }>;
}
export interface WooVariation {
// 变体主键
id: number;
// 创建时间
date_created: string;
// 创建时间(GMT)
date_created_gmt: string;
// 更新时间
date_modified: string;
// 更新时间(GMT)
date_modified_gmt: string;
// 变体描述
description: string;
// 变体SKU
sku: string;
// 常规价格
regular_price?: string;
// 促销价格
sale_price?: string;
// 当前价格
price?: string;
// 价格HTML
price_html?: string;
// 促销开始日期
date_on_sale_from?: string;
// 促销开始日期(GMT)
date_on_sale_from_gmt?: string;
// 促销结束日期
date_on_sale_to?: string;
// 促销结束日期(GMT)
date_on_sale_to_gmt?: string;
// 是否在促销中
on_sale: boolean;
// 是否可购买
purchasable: boolean;
// 总销量
total_sales: number;
// 是否为虚拟商品
virtual: boolean;
// 是否可下载
downloadable: boolean;
// 下载文件
downloads: Array<{ id?: number; name?: string; file?: string }>;
// 下载限制
download_limit: number;
// 下载过期天数
download_expiry: number;
// 库存状态
stock_status?: 'instock' | 'outofstock' | 'onbackorder';
// 库存数量
stock_quantity?: number;
// 是否管理库存
manage_stock?: boolean;
// 缺货预定设置
backorders?: 'no' | 'notify' | 'yes';
// 是否允许缺货预定
backorders_allowed?: boolean;
// 是否处于缺货预定状态
backordered?: boolean;
// 是否单独出售
sold_individually?: boolean;
// 重量
weight?: string;
// 尺寸
dimensions?: { length?: string; width?: string; height?: string };
// 是否需要运输
shipping_required?: boolean;
// 运输是否计税
shipping_taxable?: boolean;
// 运输类别
shipping_class?: string;
// 运输类别ID
shipping_class_id?: number;
// 变体图片
image?: { id: number; src: string; name?: string; alt?: string };
// 变体属性列表
attributes?: Array<{
id?: number;
name?: string;
option?: string;
}>;
// 菜单排序
menu_order?: number;
// 元数据
meta_data?: Array<{ id?: number; key: string; value: any }>;
// 父产品ID
parent_id?: number;
// 变体名称
name?: string;
// 是否启用
status?: string;
}
// 订单类型
export interface WooOrder {
// 订单主键
id: number;
// 父订单ID
parent_id?: number;
// 订单号
number: string;
// 订单键 只读
order_key?: string;
// 创建来源
created_via?: string;
// WooCommerce版本 只读
version?: string;
// 状态
status: string;
// 币种
currency: string;
// 价格是否含税 只读
prices_include_tax?: boolean;
// 总金额
total: string;
// 总税额 只读
total_tax?: string;
// 折扣总额 只读
discount_total?: string;
// 折扣税额 只读
discount_tax?: string;
// 运费总额 只读
shipping_total?: string;
// 运费税额 只读
shipping_tax?: string;
// 购物车税额 只读
cart_tax?: string;
// 客户ID
customer_id: number;
// 客户IP 只读
customer_ip_address?: string;
// 客户UA 只读
customer_user_agent?: string;
// 客户备注
customer_note?: string;
// 账单信息
billing?: {
first_name?: string;
last_name?: string;
email?: string;
company?: string;
address_1?: string;
address_2?: string;
city?: string;
state?: string;
postcode?: string;
country?: string;
phone?: string;
fullname?: string;
};
// 收货信息
shipping?: {
first_name?: string;
last_name?: string;
company?: string;
address_1?: string;
address_2?: string;
city?: string;
state?: string;
postcode?: string;
country?: string;
phone?: string;
fullname?: string;
};
// 订单项
line_items?: Array<{
product_id?: number;
variation_id?: number;
quantity?: number;
subtotal?: string;
subtotal_tax?: string;
total?: string;
total_tax?: string;
name?: string;
sku?: string;
price?: number;
meta_data?: Array<{ key: string; value: any }>;
[key: string]: any;
}>;
// 税费行 只读
tax_lines?: Array<{
id?: number;
rate_code?: string;
rate_id?: number;
label?: string;
tax_total?: string;
shipping_tax_total?: string;
compound?: boolean;
meta_data?: any[];
}>;
// 物流费用行
shipping_lines?: Array<{
id?: number;
method_title?: string;
method_id?: string;
total?: string;
total_tax?: string;
taxes?: any[];
meta_data?: any[];
}>;
// 手续费行
fee_lines?: Array<{
id?: number;
name?: string;
tax_class?: string;
tax_status?: string;
total?: string;
total_tax?: string;
taxes?: any[];
meta_data?: any[];
}>;
// 优惠券行
coupon_lines?: Array<{
id?: number;
code?: string;
discount?: string;
discount_tax?: string;
meta_data?: any[];
}>;
// 退款列表 只读
refunds?: Array<WooOrderRefund>;
// 支付方式标题
payment_method_title?: string;
// 支付方式ID
payment_method?: string;
// 交易ID
transaction_id?: string;
// 已支付时间
date_paid?: string;
date_paid_gmt?: string;
// 完成时间
date_completed?: string;
date_completed_gmt?: string;
// 购物车hash 只读
cart_hash?: string;
// 设置为已支付 写入专用
set_paid?: boolean;
// 元数据
meta_data?: Array<{ id?: number; key: string; value: any }>;
// 创建与更新时间
date_created: string;
date_created_gmt?: string;
date_modified?: string;
date_modified_gmt?: string;
}
export interface MetaDataFulfillment {
custom_tracking_link: string;
custom_tracking_provider: string;
date_shipped: number;
source: string;
status_shipped: string;
tracking_id: string;
tracking_number: string;
tracking_product_code: string;
tracking_provider: string;
user_id: number;
}
// 这个是一个插件的物流追踪信息
// 接口:
export interface WooFulfillment {
data_sipped: string;
tracking_id: string;
tracking_link: string;
tracking_number: string;
tracking_provider: string;
}
// https://docs.zorem.com/docs/ast-free/developers/adding-tracking-info-to-orders/
export interface WooFulfillmentCreateParams {
order_id: string;
tracking_provider: string;
tracking_number: string;
date_shipped?: string;
status_shipped?: string;
}
export interface WooOrderRefund {
id?: number;
reason?: string;
total?: string;
}
// 订阅类型
export interface WooSubscription {
// 订阅主键
id: number;
// 订阅状态
status: string;
// 客户ID
customer_id: number;
// 计费周期
billing_period?: string;
// 计费间隔
billing_interval?: number;
// 开始时间
start_date?: string;
// 下次支付时间
next_payment_date?: string;
// 订阅项
line_items?: any[];
// 创建时间
date_created?: string;
// 更新时间
date_modified?: string;
}
// WordPress 媒体类型
export interface WpMedia {
// 媒体主键
id: number;
// 标题可能为字符串或包含rendered的对象
title?: { rendered?: string } | string;
// 媒体类型
media_type?: string;
// MIME类型
mime_type?: string;
// 源地址
source_url?: string;
// 创建时间兼容date字段
date_created?: string;
date?: string;
// 更新时间兼容modified字段
date_modified?: string;
modified?: string;
}
// 评论类型
export interface WooReview {
// 评论ID
id: number;
// 评论内容
review: string;
// 评分
rating: number;
// 评论者
reviewer: string;
// 评论者邮箱
reviewer_email: string;
// 状态
status: string;
// 产品ID
product_id: number;
// 创建日期
date_created: string;
// 更新日期
}
// 客户类型
export interface WooCustomer {
// 客户主键
id: number;
// 头像URL
avatar_url?: string;
// 邮箱
email: string;
// 订单总数
orders?: number;
// 总花费
total_spent?: number | string;
// 名
first_name?: string;
// 姓
last_name?: string;
// 用户名
username?: string;
// 角色 只读
role?: string;
// 密码 写入专用
password?: string;
// 账单信息
billing?: {
first_name?: string;
last_name?: string;
email?: string;
company?: string;
phone?: string;
address_1?: string;
address_2?: string;
city?: string;
state?: string;
postcode?: string;
country?: string;
};
// 收货信息
shipping?: {
first_name?: string;
last_name?: string;
company?: string;
phone?: string;
address_1?: string;
address_2?: string;
city?: string;
state?: string;
postcode?: string;
country?: string;
};
// 是否为付费客户 只读
is_paying_customer?: boolean;
// 元数据
meta_data?: Array<{ id?: number; key: string; value: any }>;
// 创建时间
date_created?: string;
date_created_gmt?: string;
// 更新时间
date_modified?: string;
date_modified_gmt?: string;
}
// Webhook类型
export interface WooWebhook {
id: number;
name: string;
status: string;
topic: string;
resource: string;
event: string;
hooks: string;
delivery_url: string;
secret: string;
date_created: string;
date_created_gmt: string;
date_modified: string;
date_modified_gmt: string;
api_version: string;
meta_data?: Array<{ id?: number; key: string; value: any }>;
}
export interface WooOrderSearchParams {
context: WooContext;
page: number;
per_page: number;
search: string;
after: string;
before: string;
modified_after: string;
modified_before: string;
date_are_gmt: boolean;
exclude: string[];
include: string[];
offset: number;
order: string;
orderby: string;
parant: string[];
parent_exclude: string[];
status: WooOrderStatusSearchParams[];
customer: number;
product: number;
dp: number;
created_via: string;
}
export enum WooOrderStatusSearchParams {
pending,
processing,
"on-hold",
completed,
cancelled,
refunded,
failed,
trash,
any
}
export interface WooProductSearchParams extends ListParams {
slug: string;
status: string[];
include_status: string;
exclude_status: string;
type: string;
include_types: string;
exclude_types: string;
sku: string;
featured: boolean;
category: string;
tag: string;
shipping_class: string;
attribute: string;
attribute_term: string;
tax_class: string;
on_sale: boolean;
min_price: string;
max_price: string;
stock_status: string;
virtual: boolean;
downloadable: boolean;
}
export interface ListParams {
context: WooContext;
page: number;
per_page: number;
search: string;
search_fields: any[];
after: string;
before: string;
modified_after: string;
modified_before: string;
date_are_gmt: boolean;
exclude: string[];
include: string[];
offset: number;
order: string;
orderby: string;
parant: string[];
parent_exclude: string[];
}
export interface WpMediaGetListParams {
// 请求范围,决定响应中包含的字段
// 默认: view
// 可选值: view, embed, edit
context?: 'view' | 'embed' | 'edit';
// 当前页码
// 默认: 1
page?: number;
// 每页最大返回数量
// 默认: 10
per_page?: number;
// 搜索字符串,限制结果匹配
search?: string;
// ISO8601格式日期限制发布时间之后的结果
after?: string;
// ISO8601格式日期限制修改时间之后的结果
modified_after?: string;
// 作者ID数组限制结果集为特定作者
author?: number[];
// 作者ID数组排除特定作者的结果
author_exclude?: number[];
// ISO8601格式日期限制发布时间之前的结果
before?: string;
// ISO8601格式日期限制修改时间之前的结果
modified_before?: string;
// ID数组排除特定ID的结果
exclude?: number[];
// ID数组限制结果集为特定ID
include?: number[];
// 结果集偏移量
offset?: number;
// 排序方向
// 默认: desc
// 可选值: asc, desc
order?: 'asc' | 'desc';
// 排序字段
// 默认: date
// 可选值: author, date, id, include, modified, parent, relevance, slug, include_slugs, title
orderby?: 'author' | 'date' | 'id' | 'include' | 'modified' | 'parent' | 'relevance' | 'slug' | 'include_slugs' | 'title';
// 父ID数组限制结果集为特定父ID
parent?: number[];
// 父ID数组排除特定父ID的结果
parent_exclude?: number[];
// 搜索的列名数组
search_columns?: string[];
// slug数组限制结果集为特定slug
slug?: string[];
// 状态数组,限制结果集为特定状态
// 默认: inherit
status?: string[];
// 媒体类型,限制结果集为特定媒体类型
// 可选值: image, video, text, application, audio
media_type?: 'image' | 'video' | 'text' | 'application' | 'audio';
// MIME类型限制结果集为特定MIME类型
mime_type?: string;
}
export enum WooContext {
view,
edit
}
export enum WooProductStatusSearchParams {
any,
draft,
pending,
private,
publish
}
// 发货相关DTO
export class WooShipOrderItemDTO {
order_item_id: number;
quantity: number;
}
export class WooShipOrderDTO {
tracking_number?: string;
shipping_provider?: string;
shipping_method?: string;
items?: WooShipOrderItemDTO[];
}
export class WooCancelShipOrderDTO {
reason?: string;
shipment_id?: string;
}
export class WooBatchShipOrderItemDTO {
order_id: string;
tracking_number?: string;
shipping_provider?: string;
shipping_method?: string;
items?: WooShipOrderItemDTO[];
}
export class WooBatchShipOrdersDTO {
orders: WooBatchShipOrderItemDTO[];
}