@pisell/pisellos
Version:
一个可扩展的前端模块化SDK框架,支持插件系统
152 lines (151 loc) • 4.32 kB
TypeScript
export declare enum DiscountHooks {
OnDiscountListChange = "discount:onDiscountListChange",
OnDestroy = "discount:onDestroy"
}
interface Product {
id: number;
title: string;
is_charge_tax: number;
base_price: string;
}
interface Formattitle {
auto: string;
original: string;
en?: any;
'zh-CN'?: any;
'zh-HK'?: any;
}
interface PackageSubItemUsageRules {
type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
rules: ("original_price" | "markup_price")[];
}
interface Limitedrelationproductdata {
id: number;
type: 'product_all' | 'products' | 'product_collection';
product_ids: number[];
product_collection_id: number[];
package_sub_item_usage_rules?: PackageSubItemUsageRules;
filter: 0 | 1;
exclude_product_ids: number[];
}
interface ApplicableProductDetails {
amount: string;
type: string;
resource_id: number;
title: string;
original_amount: string;
num: number;
metadata?: {
product_discount_difference?: number;
};
discount?: {
fixed_amount?: number;
product_id?: number;
original_amount?: string;
percent?: string;
resource_id?: number;
title?: string;
};
_num: number;
}
interface UsageCreditsValue {
total_credits: number;
per_user_limit: number;
max_per_day: number;
max_per_week: number;
max_per_month: number;
}
interface ExtensionData {
id: number;
shop_id: number;
product_id: number;
field_id: number;
field_key: string;
type: string;
value: UsageCreditsValue | Record<string, any> | string | number | boolean | any[];
created_at: string | null;
updated_at: string | null;
deleted_at: string | null;
}
export interface Discount {
id: number;
product_name: string;
encoded: string;
code: string;
tag: string;
expire_time?: string;
product_id: number;
relation_type: string;
par_value: string;
used_par_value: string;
limit_status: string;
limited_relation_product_data: Limitedrelationproductdata;
balance: string;
format_title: Formattitle;
metadata?: {
num?: number;
discount_card_type?: 'fixed_amount' | 'percent';
custom_product_bundle_map_id?: string;
validity_type?: "custom_schedule_validity" | "fixed_validity";
discount_calculation_mode: 'item_level' | 'order_level';
holder: {
type: "customer" | "custom";
};
};
product: Product;
type: "product" | 'good_pass';
resource_id?: number;
savedAmount?: number;
isEditMode?: boolean;
isScan?: boolean;
discount?: {
discount_product_id: number;
resource_id: number;
discount_calculation_mode: 'item_level' | 'order_level';
};
isManualSelect?: boolean;
isDisabled?: boolean;
isSelected?: boolean;
isAvailable?: boolean;
isUsed?: boolean;
config?: {
isAvailable?: boolean;
/** 最大抵扣金额 */
maxDeductionAmount?: number;
/** 每单最多使用张数 */
maxUsagePerOrder?: number;
/** 是否抵扣税费与附加费 */
deductTaxAndFee?: boolean;
/** 适用粒度(多商品共用) */
allowCrossProduct?: boolean;
/** 可用商品数量上限 */
applicableProductLimit?: number;
};
applicableProductIds?: number[];
applicableProductDetails: ApplicableProductDetails[];
appliedProductDetails: ApplicableProductDetails[];
isDisabledForProductUsed?: boolean;
amount?: number;
extension_data?: ExtensionData[];
total_order_behavior_count?: number;
today_order_behavior_count?: number;
week_order_behavior_count?: number;
month_order_behavior_count?: number;
customer_order_behavior_count?: number;
custom_schedule_snapshot?: {
data: any[];
};
num?: number;
start_date?: string;
start_time?: string;
discount_rule_uncheck_flag?: boolean;
}
export interface DiscountState {
discountList: Discount[];
originalDiscountList?: Discount[];
}
export interface DiscountModuleAPI {
setDiscountList: (discountList: Discount[]) => Promise<void>;
clear: () => Promise<void>;
}
export {};