@pisell/pisellos 0.10.76 → 0.10.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apis/picoding.d.ts +0 -0
- package/dist/effects/index.d.ts +19 -0
- package/dist/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +105 -0
- package/dist/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/dist/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +173 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +70 -0
- package/dist/model/strategy/adapter/promotion/examples.d.ts +224 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/promotion/type.d.ts +535 -0
- package/dist/model/strategy/adapter/type.d.ts +28 -0
- package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/dist/model/strategy/adapter/walletPass/type.d.ts +192 -0
- package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/dist/model/strategy/engine.d.ts +119 -0
- package/dist/model/strategy/type.d.ts +245 -0
- package/dist/modules/Account/types.d.ts +56 -0
- package/dist/modules/BookingContext/types.d.ts +104 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/dist/modules/Customer/constants.d.ts +7 -0
- package/dist/modules/Date/types.d.ts +84 -0
- package/dist/modules/Date/utils.d.ts +36 -0
- package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
- package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
- package/dist/modules/Order/payment-utils.d.ts +26 -0
- package/dist/modules/Order/pickupTiming.d.ts +46 -0
- package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +68 -0
- package/dist/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +21 -0
- package/dist/modules/Payment/mx51.d.ts +0 -0
- package/dist/modules/Payment/types.d.ts +943 -0
- package/dist/modules/Payment/utils.d.ts +19 -0
- package/dist/modules/Quotation/types.d.ts +61 -0
- package/dist/modules/Resource/types.d.ts +50 -0
- package/dist/modules/Resource/utils.d.ts +23 -0
- package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/dist/modules/SalesSummary/types.d.ts +69 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +53 -0
- package/dist/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
- package/dist/modules/Schedule/type.d.ts +157 -0
- package/dist/modules/Schedule/types.d.ts +201 -0
- package/dist/modules/Schedule/utils.d.ts +67 -0
- package/dist/modules/Step/tyeps.d.ts +20 -0
- package/dist/modules/SurchargeList/types.d.ts +15 -0
- package/dist/plugins/app.d.ts +10 -0
- package/dist/plugins/shopStore.d.ts +4 -0
- package/dist/plugins/user.d.ts +7 -0
- package/dist/server/modules/floor-plan/types.d.ts +43 -0
- package/dist/server/modules/menu/types.d.ts +68 -0
- package/dist/server/modules/payment/types.d.ts +9 -0
- package/dist/server/modules/quotation/types.d.ts +50 -0
- package/dist/server/modules/resource/types.d.ts +121 -0
- package/dist/server/modules/schedule/types.d.ts +1 -0
- package/dist/server/modules/schedule/utils.d.ts +32 -0
- package/dist/server/types.d.ts +66 -0
- package/dist/server/utils/index.d.ts +5 -0
- package/dist/server/utils/schedule.d.ts +14 -0
- package/dist/server/utils/time.d.ts +18 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +38 -0
- package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/PlaceOrder/index.d.ts +0 -0
- package/dist/solution/RegisterAndLogin/config.d.ts +93 -0
- package/dist/solution/RegisterAndLogin/types.d.ts +445 -0
- package/dist/solution/RegisterAndLogin/utils.d.ts +103 -0
- package/dist/solution/UnifiedBookingSales/index.js +107 -58
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +4 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/dist/store/createStore.d.ts +3 -0
- package/dist/types/index.d.ts +132 -0
- package/dist/utils/os-private-payload.d.ts +5 -0
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/task.d.ts +40 -0
- package/dist/utils/watch.d.ts +102 -0
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/effects/index.d.ts +19 -0
- package/lib/model/strategy/adapter/dataVariant/adapter.d.ts +50 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +105 -0
- package/lib/model/strategy/adapter/dataVariant/examples.d.ts +39 -0
- package/lib/model/strategy/adapter/dataVariant/index.d.ts +4 -0
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +173 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +70 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +224 -0
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/model/strategy/adapter/promotion/type.d.ts +535 -0
- package/lib/model/strategy/adapter/type.d.ts +28 -0
- package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
- package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
- package/lib/model/strategy/adapter/walletPass/type.d.ts +192 -0
- package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
- package/lib/model/strategy/engine.d.ts +119 -0
- package/lib/model/strategy/type.d.ts +245 -0
- package/lib/modules/Account/types.d.ts +56 -0
- package/lib/modules/BookingContext/types.d.ts +104 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
- package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
- package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
- package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
- package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
- package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
- package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
- package/lib/modules/Customer/constants.d.ts +7 -0
- package/lib/modules/Date/types.d.ts +84 -0
- package/lib/modules/Date/utils.d.ts +36 -0
- package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
- package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
- package/lib/modules/Order/payment-utils.d.ts +26 -0
- package/lib/modules/Order/pickupTiming.d.ts +46 -0
- package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +68 -0
- package/lib/modules/Order/utils/weighedProduct.d.ts +12 -0
- package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +21 -0
- package/lib/modules/Payment/mx51.d.ts +0 -0
- package/lib/modules/Payment/types.d.ts +943 -0
- package/lib/modules/Payment/utils.d.ts +19 -0
- package/lib/modules/Quotation/types.d.ts +61 -0
- package/lib/modules/Resource/types.d.ts +50 -0
- package/lib/modules/Resource/utils.d.ts +23 -0
- package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/lib/modules/SalesSummary/types.d.ts +69 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +53 -0
- package/lib/modules/Schedule/getDateIsInSchedule.d.ts +32 -0
- package/lib/modules/Schedule/type.d.ts +157 -0
- package/lib/modules/Schedule/types.d.ts +201 -0
- package/lib/modules/Schedule/utils.d.ts +67 -0
- package/lib/modules/Step/tyeps.d.ts +20 -0
- package/lib/modules/SurchargeList/types.d.ts +15 -0
- package/lib/plugins/app.d.ts +10 -0
- package/lib/plugins/shopStore.d.ts +4 -0
- package/lib/plugins/user.d.ts +7 -0
- package/lib/server/modules/floor-plan/types.d.ts +43 -0
- package/lib/server/modules/menu/types.d.ts +68 -0
- package/lib/server/modules/payment/types.d.ts +9 -0
- package/lib/server/modules/quotation/types.d.ts +50 -0
- package/lib/server/modules/resource/types.d.ts +121 -0
- package/lib/server/modules/schedule/types.d.ts +1 -0
- package/lib/server/modules/schedule/utils.d.ts +32 -0
- package/lib/server/types.d.ts +66 -0
- package/lib/server/utils/index.d.ts +5 -0
- package/lib/server/utils/schedule.d.ts +14 -0
- package/lib/server/utils/time.d.ts +18 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
- package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
- package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +38 -0
- package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/PlaceOrder/index.d.ts +0 -0
- package/lib/solution/RegisterAndLogin/config.d.ts +93 -0
- package/lib/solution/RegisterAndLogin/types.d.ts +445 -0
- package/lib/solution/RegisterAndLogin/utils.d.ts +103 -0
- package/lib/solution/UnifiedBookingSales/index.js +42 -11
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +2 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +2 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +2 -0
- package/lib/store/createStore.d.ts +3 -0
- package/lib/types/index.d.ts +132 -0
- package/lib/utils/os-private-payload.d.ts +5 -0
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/task.d.ts +40 -0
- package/lib/utils/watch.d.ts +102 -0
- package/package.json +1 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { EvaluationResult, StrategyConfig } from '../../type';
|
|
2
|
+
/**
|
|
3
|
+
* Voucher 数据结构
|
|
4
|
+
*/
|
|
5
|
+
export interface Voucher {
|
|
6
|
+
id: number;
|
|
7
|
+
amount: number;
|
|
8
|
+
balance: number;
|
|
9
|
+
type?: string;
|
|
10
|
+
usedCount?: number;
|
|
11
|
+
available_product_type?: 'product_all' | 'product_collection' | 'products';
|
|
12
|
+
available_product_ids?: number[];
|
|
13
|
+
product_id: number;
|
|
14
|
+
unified_available_status: number;
|
|
15
|
+
/** 用户手动编辑的金额,优先于 recommended_usage_amount 使用 */
|
|
16
|
+
edit_current_amount?: number;
|
|
17
|
+
/** 前端基于策略返回的 不可用状态 */
|
|
18
|
+
_unified_available_status?: number;
|
|
19
|
+
/** 前端基于策略返回的 可用最大金额 */
|
|
20
|
+
_available_max_amount?: number;
|
|
21
|
+
/** 前端基于策略返回的 不可用原因 */
|
|
22
|
+
reason?: string;
|
|
23
|
+
/** 前端基于策略返回的 不可用原因码 */
|
|
24
|
+
reasonCode?: string;
|
|
25
|
+
/** 后端计算推荐使用金额 */
|
|
26
|
+
recommended_usage_amount: number;
|
|
27
|
+
/** 后端计算推荐使用金额(仅商品) 不包含税费附加费 */
|
|
28
|
+
recommended_pure_product_usage_amount: number;
|
|
29
|
+
/**
|
|
30
|
+
* 扫码资产自身可供前端重新计算的金额基准。
|
|
31
|
+
* 后端 recommended_usage_amount 会包含当前已选券上下文,取消勾选后不能继续把它当作资产永久上限。
|
|
32
|
+
*/
|
|
33
|
+
_wallet_asset_recalculation_base_amount?: number;
|
|
34
|
+
/** 实际抵扣金额 */
|
|
35
|
+
actualDeduction: number;
|
|
36
|
+
/** 抵扣详情 */
|
|
37
|
+
deductionDetails: any[];
|
|
38
|
+
config?: {
|
|
39
|
+
/** 最大抵扣金额 */
|
|
40
|
+
maxDeductionAmount: number;
|
|
41
|
+
/** 每单最多使用张数(同一 product_id 的券)。默认为 0,表示不限制数量。 */
|
|
42
|
+
maxUsagePerOrder: number;
|
|
43
|
+
/** 是否抵扣税费与附加费 */
|
|
44
|
+
deductTaxAndFee: boolean;
|
|
45
|
+
/** 适用粒度(多商品共用) 默认开启勾选项 */
|
|
46
|
+
allowCrossProduct: boolean;
|
|
47
|
+
/** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
|
|
48
|
+
applicableProductLimit: number;
|
|
49
|
+
/** 单订单行每单位可用同一 Wallet Pass 券次数;该行总券次上限 = maxPassesPerItem × 该行 quantity(按行唯一键区分)。0 表示不限制。 */
|
|
50
|
+
maxPassesPerItem: number;
|
|
51
|
+
/** 是否抵扣单规格价格 (Option Price),默认 false。开启后折扣范围包含 option 的 add_price */
|
|
52
|
+
deductOptionPrice: boolean;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 商品数据结构
|
|
57
|
+
*/
|
|
58
|
+
export interface Product {
|
|
59
|
+
product_id: number;
|
|
60
|
+
/** 订单明细 id,参与行唯一键兜底解析 */
|
|
61
|
+
id?: number;
|
|
62
|
+
/** 行级唯一串,参与行唯一键解析 */
|
|
63
|
+
product_unique_string?: string;
|
|
64
|
+
price: number;
|
|
65
|
+
quantity: number;
|
|
66
|
+
name?: string;
|
|
67
|
+
selling_price?: number;
|
|
68
|
+
/** 主商品折扣前金额,不包含套餐子商品 */
|
|
69
|
+
main_product_original_price?: number;
|
|
70
|
+
/** 主商品折扣后金额,不包含套餐子商品 */
|
|
71
|
+
main_product_selling_price?: number;
|
|
72
|
+
/** 单规格(Option)列表 */
|
|
73
|
+
product_options?: {
|
|
74
|
+
id: number;
|
|
75
|
+
add_price: number | string;
|
|
76
|
+
num: number;
|
|
77
|
+
[key: string]: any;
|
|
78
|
+
}[];
|
|
79
|
+
/** 主商品税费 */
|
|
80
|
+
tax_fee: number;
|
|
81
|
+
metadata: {
|
|
82
|
+
/** 行唯一标识,优先用于 Wallet Pass 按行配额 */
|
|
83
|
+
product_unique?: string;
|
|
84
|
+
unique_identification_number?: string;
|
|
85
|
+
main_product_attached_bundle_tax_fee?: number;
|
|
86
|
+
main_product_attached_bundle_surcharge_fee?: number;
|
|
87
|
+
surcharge_rounding_remainder?: number;
|
|
88
|
+
tax_fee_rounding_remainder?: number;
|
|
89
|
+
main_product_selling_price: number;
|
|
90
|
+
};
|
|
91
|
+
is_price_include_tax: 0 | 1;
|
|
92
|
+
product_bundle: {
|
|
93
|
+
is_price_include_tax: 0 | 1;
|
|
94
|
+
bundle_id: number;
|
|
95
|
+
bundle_product_id: number;
|
|
96
|
+
bundle_variant_id: number;
|
|
97
|
+
price_type: string;
|
|
98
|
+
price_type_ext: string;
|
|
99
|
+
bundle_selling_price: number;
|
|
100
|
+
num: number;
|
|
101
|
+
is_charge_tax: number;
|
|
102
|
+
tax_fee: number;
|
|
103
|
+
metadata: {
|
|
104
|
+
surcharge_fee: number;
|
|
105
|
+
surcharge_rounding_remainder?: number;
|
|
106
|
+
tax_fee_rounding_remainder?: number;
|
|
107
|
+
};
|
|
108
|
+
}[];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Voucher 评估结果
|
|
112
|
+
*/
|
|
113
|
+
export interface VoucherEvaluationResult {
|
|
114
|
+
voucher: Voucher;
|
|
115
|
+
/** 是否可用 */
|
|
116
|
+
isApplicable: boolean;
|
|
117
|
+
/** 每单可使用张数 */
|
|
118
|
+
canUseCount: number;
|
|
119
|
+
/** 最大抵扣金额 */
|
|
120
|
+
maxDeduction: number;
|
|
121
|
+
/** 是否抵扣税费与附加费 */
|
|
122
|
+
deductTaxAndFee: boolean;
|
|
123
|
+
/** 适用商品ID列表 */
|
|
124
|
+
applicableProductIds: number[];
|
|
125
|
+
/** 不可用原因 */
|
|
126
|
+
reason?: string;
|
|
127
|
+
/** 不可用原因码 */
|
|
128
|
+
reasonCode?: string;
|
|
129
|
+
strategyResult?: EvaluationResult;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 评估器输入参数
|
|
133
|
+
*/
|
|
134
|
+
export interface EvaluatorInput {
|
|
135
|
+
/** 订单总金额 */
|
|
136
|
+
orderTotalAmount: number;
|
|
137
|
+
/** 商品列表 */
|
|
138
|
+
products: Product[];
|
|
139
|
+
/** 代金券列表 */
|
|
140
|
+
vouchers: Voucher[];
|
|
141
|
+
/** 策略配置列表 */
|
|
142
|
+
strategyConfigs?: StrategyConfig<{
|
|
143
|
+
/** 最大抵扣金额 */
|
|
144
|
+
maxDeductionAmount: number;
|
|
145
|
+
/** 每单最多使用张数(同一 product_id 的券)。默认为 0,表示不限制数量。 */
|
|
146
|
+
maxUsagePerOrder: number;
|
|
147
|
+
/** 是否抵扣税费与附加费 */
|
|
148
|
+
deductTaxAndFee: boolean;
|
|
149
|
+
/** 适用粒度(多商品共用) 默认开启勾选项 */
|
|
150
|
+
allowCrossProduct: boolean;
|
|
151
|
+
/** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
|
|
152
|
+
applicableProductLimit: number;
|
|
153
|
+
/** 单订单行每单位可用同一 Wallet Pass 券次数;行总上限 = maxPassesPerItem × 该行 quantity(按行唯一键计)。0 表示不限制。 */
|
|
154
|
+
maxPassesPerItem: number;
|
|
155
|
+
/** 是否抵扣单规格价格 (Option Price),默认 false */
|
|
156
|
+
deductOptionPrice: boolean;
|
|
157
|
+
}>[];
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* WalletPassAdapter 业务数据输入
|
|
161
|
+
*/
|
|
162
|
+
export interface WalletPassBusinessData {
|
|
163
|
+
/** 订单总金额 */
|
|
164
|
+
orderTotalAmount: number;
|
|
165
|
+
/** 商品列表 */
|
|
166
|
+
products: Product[];
|
|
167
|
+
/** 当前评估的 voucher */
|
|
168
|
+
voucher: Voucher;
|
|
169
|
+
/** 策略配置 */
|
|
170
|
+
strategyConfig: StrategyConfig;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* WalletPassAdapter 转换结果
|
|
174
|
+
*/
|
|
175
|
+
export interface WalletPassTransformResult {
|
|
176
|
+
/** 是否可用 */
|
|
177
|
+
isApplicable: boolean;
|
|
178
|
+
/** 每单可使用张数 */
|
|
179
|
+
canUseCount: number;
|
|
180
|
+
/** 最大抵扣金额 */
|
|
181
|
+
maxDeduction: number;
|
|
182
|
+
/** 是否抵扣税费与附加费 */
|
|
183
|
+
deductTaxAndFee: boolean;
|
|
184
|
+
/** 适用商品ID列表 */
|
|
185
|
+
applicableProductIds: number[];
|
|
186
|
+
/** 不可用原因 */
|
|
187
|
+
reason?: string;
|
|
188
|
+
/** 不可用原因码 */
|
|
189
|
+
reasonCode?: string;
|
|
190
|
+
/** 原始策略评估结果 */
|
|
191
|
+
strategyResult?: EvaluationResult;
|
|
192
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Product, Voucher } from './type';
|
|
2
|
+
/** 订单商品数量 */
|
|
3
|
+
export declare const getProductQuantity: (product: any) => any;
|
|
4
|
+
/**
|
|
5
|
+
* 订单商品行唯一键,用于 maxPassesPerItem 按行、按件配额(同 SPU 不同规格视为不同行)。
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveWalletPassLineKey(product: any, indexInOrder: number): string;
|
|
8
|
+
export declare const getApplicableProductIds: (voucher: Voucher) => number[] | null;
|
|
9
|
+
/**
|
|
10
|
+
* 优惠券处理函数
|
|
11
|
+
* @param applicableVouchers 可用的券列表
|
|
12
|
+
* @param orderTotalAmount 订单总金额
|
|
13
|
+
* @param products 订单商品列表
|
|
14
|
+
* @returns 返回推荐券列表和全部列表,每个券包含 _available_max_amount 和 _unified_available_status
|
|
15
|
+
*/
|
|
16
|
+
export declare function processVouchers(applicableVouchers: Voucher[], orderTotalAmount: number, products: Product[]): {
|
|
17
|
+
recommended: any[];
|
|
18
|
+
transformList: any[];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* 重新计算优惠券状态(基于已选券的增量计算)
|
|
22
|
+
* @param allVouchers 所有原始券列表
|
|
23
|
+
* @param selectedVouchers 已选中的券列表(按选中顺序)
|
|
24
|
+
* @param orderTotalAmount 订单总金额
|
|
25
|
+
* @param products 订单商品列表
|
|
26
|
+
* @returns 返回更新后的所有券列表和已选券的详细抵扣信息
|
|
27
|
+
*/
|
|
28
|
+
export declare function recalculateVouchers(allVouchers: any[], selectedVouchers: any[], orderTotalAmount: number, products: any[]): {
|
|
29
|
+
allWithUpdatedStatus: any[];
|
|
30
|
+
selectedWithDetails: any[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* 获取主商品价格(单价,不含舍入余数)
|
|
34
|
+
* @param product 商品
|
|
35
|
+
* @param isDeductTaxAndFee 是否抵扣税费与附加费
|
|
36
|
+
* @returns 商品单价
|
|
37
|
+
*/
|
|
38
|
+
export declare const getMainProductPrice: (product: Product, isDeductTaxAndFee: boolean) => number;
|
|
39
|
+
/**
|
|
40
|
+
* 获取套餐子商品价格(不含舍入余数)
|
|
41
|
+
* @param bundleItem 套餐子商品
|
|
42
|
+
* @param parentQuantity 父商品数量
|
|
43
|
+
* @param isDeductTaxAndFee 是否抵扣税费与附加费
|
|
44
|
+
* @returns 子商品总价格(不含舍入余数)
|
|
45
|
+
*/
|
|
46
|
+
export declare const getBundleItemPrice: (bundleItem: any, parentQuantity: number, isDeductTaxAndFee: boolean) => number;
|
|
47
|
+
export declare const getBundleItemIsOriginalPrice: (item: any) => boolean;
|
|
48
|
+
export declare const getBundleItemIsMarkupPrice: (item: any) => boolean;
|
|
49
|
+
export declare const getBundleItemIsDiscountPrice: (item: any) => boolean;
|
|
50
|
+
export declare const getBundleItemIsMarkupOrDiscountPrice: (item: any) => boolean;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { StrategyConfig, RuntimeContext, EvaluationResult, EngineOptions, OperatorHandler } from './type';
|
|
2
|
+
/**
|
|
3
|
+
* 策略模型 - 核心实现
|
|
4
|
+
*
|
|
5
|
+
* 完全业务无关的通用策略引擎
|
|
6
|
+
* 支持条件评估、动作匹配、结果返回
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 策略引擎
|
|
10
|
+
*
|
|
11
|
+
* 核心职责:
|
|
12
|
+
* 1. 递归评估条件组
|
|
13
|
+
* 2. 收集满足条件的 actionIds
|
|
14
|
+
* 3. 根据 actionIds 获取 ActionEffect 对象
|
|
15
|
+
* 4. 按 priority 排序返回
|
|
16
|
+
*/
|
|
17
|
+
export declare class StrategyEngine {
|
|
18
|
+
private options;
|
|
19
|
+
private operatorHandlers;
|
|
20
|
+
constructor(options?: EngineOptions);
|
|
21
|
+
/**
|
|
22
|
+
* 评估策略
|
|
23
|
+
*/
|
|
24
|
+
evaluate(config: StrategyConfig, context: RuntimeContext): EvaluationResult;
|
|
25
|
+
/**
|
|
26
|
+
* 递归评估条件组
|
|
27
|
+
*
|
|
28
|
+
* @param group 条件组
|
|
29
|
+
* @param context 运行时上下文
|
|
30
|
+
* @returns 评估结果对象,包含条件是否满足、收集到的 actionIds、以及失败的原子规则信息
|
|
31
|
+
*/
|
|
32
|
+
private evaluateConditionGroup;
|
|
33
|
+
/**
|
|
34
|
+
* 评估条件组的逻辑运算(带失败规则收集)
|
|
35
|
+
*
|
|
36
|
+
* 失败规则收集策略:
|
|
37
|
+
* - `and`:返回第一个失败的原子规则(嵌套 group 递归取其首个失败原子规则)
|
|
38
|
+
* - `or`:所有分支失败时,聚合每个分支的失败规则
|
|
39
|
+
* - `not`:被取反规则实际通过时,记录该规则
|
|
40
|
+
*/
|
|
41
|
+
private evaluateGroupLogicDetailed;
|
|
42
|
+
/**
|
|
43
|
+
* 评估单个规则(带失败规则收集)
|
|
44
|
+
*/
|
|
45
|
+
private evaluateRuleDetailed;
|
|
46
|
+
/**
|
|
47
|
+
* 评估原子规则(不收集失败信息,仅返回布尔结果)
|
|
48
|
+
*/
|
|
49
|
+
private evaluateAtomicRule;
|
|
50
|
+
/**
|
|
51
|
+
* 构建失败规则信息
|
|
52
|
+
*/
|
|
53
|
+
private buildFailedRuleInfo;
|
|
54
|
+
/**
|
|
55
|
+
* 评估代码模式条件
|
|
56
|
+
*/
|
|
57
|
+
private evaluateCodeCondition;
|
|
58
|
+
/**
|
|
59
|
+
* 评估运算符模式条件
|
|
60
|
+
*/
|
|
61
|
+
private evaluateOperatorCondition;
|
|
62
|
+
/**
|
|
63
|
+
* 获取字段值
|
|
64
|
+
*/
|
|
65
|
+
private getFieldValue;
|
|
66
|
+
/**
|
|
67
|
+
* 评估内置运算符
|
|
68
|
+
*/
|
|
69
|
+
private evaluateBuiltInOperator;
|
|
70
|
+
/**
|
|
71
|
+
* 根据 actionIds 获取 ActionEffect 对象
|
|
72
|
+
*/
|
|
73
|
+
private getActionsByIds;
|
|
74
|
+
/**
|
|
75
|
+
* 按 priority 排序(降序)
|
|
76
|
+
*/
|
|
77
|
+
private sortActionsByPriority;
|
|
78
|
+
/**
|
|
79
|
+
* 判断是否为条件组
|
|
80
|
+
*/
|
|
81
|
+
private isConditionGroup;
|
|
82
|
+
/**
|
|
83
|
+
* 验证配置
|
|
84
|
+
*/
|
|
85
|
+
private validateConfig;
|
|
86
|
+
/**
|
|
87
|
+
* 初始化内置运算符处理器
|
|
88
|
+
*/
|
|
89
|
+
private initializeBuiltInOperators;
|
|
90
|
+
/**
|
|
91
|
+
* 评估商品匹配运算符
|
|
92
|
+
*
|
|
93
|
+
* 匹配规则:
|
|
94
|
+
* - 首先匹配 product_id
|
|
95
|
+
* - 如果配置的 product_variant_id = 0,只需要 product_id 匹配(表示任意变体)
|
|
96
|
+
* - 如果配置的 product_variant_id != 0,还需要 product_variant_id 精确匹配
|
|
97
|
+
*
|
|
98
|
+
* @param fieldValue 实际商品 { product_id: number, product_variant_id: number }
|
|
99
|
+
* @param configValue 配置的商品列表 Array<{ product_id: number, product_variant_id: number }>
|
|
100
|
+
* @returns 是否匹配
|
|
101
|
+
*/
|
|
102
|
+
private evaluateProductMatch;
|
|
103
|
+
/**
|
|
104
|
+
* 注册自定义运算符
|
|
105
|
+
*/
|
|
106
|
+
registerOperator(operator: string, handler: OperatorHandler): void;
|
|
107
|
+
/**
|
|
108
|
+
* 获取调试信息
|
|
109
|
+
*/
|
|
110
|
+
getDebugInfo(): Record<string, any>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* 创建策略引擎实例
|
|
114
|
+
*/
|
|
115
|
+
export declare function createStrategyEngine(options?: EngineOptions): StrategyEngine;
|
|
116
|
+
/**
|
|
117
|
+
* 快速评估(使用默认引擎配置)
|
|
118
|
+
*/
|
|
119
|
+
export declare function evaluate(config: StrategyConfig, context: RuntimeContext): EvaluationResult;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 策略配置主结构
|
|
3
|
+
*/
|
|
4
|
+
export interface StrategyConfig<T = Record<string, any>> {
|
|
5
|
+
/** 元信息 */
|
|
6
|
+
metadata: StrategyMetadata<T>;
|
|
7
|
+
/** 条件组(可嵌套,每层可绑定动作) */
|
|
8
|
+
conditions: ConditionGroup;
|
|
9
|
+
/** 动作列表(带唯一ID) */
|
|
10
|
+
actions: ActionEffect[];
|
|
11
|
+
/** 展示配置(可选) */
|
|
12
|
+
display?: DisplayConfig;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 策略元信息
|
|
16
|
+
*/
|
|
17
|
+
export interface StrategyMetadata<T = Record<string, any>> {
|
|
18
|
+
/** 策略ID */
|
|
19
|
+
id: string;
|
|
20
|
+
/** 策略名称 */
|
|
21
|
+
name: string | Record<string, string>;
|
|
22
|
+
/** 策略类型(完全可扩展) */
|
|
23
|
+
type: string;
|
|
24
|
+
/** 计算类型 */
|
|
25
|
+
calculationType?: 'single' | 'cumulative';
|
|
26
|
+
/** 版本 */
|
|
27
|
+
version?: string;
|
|
28
|
+
/** 描述 */
|
|
29
|
+
description?: string | Record<string, string>;
|
|
30
|
+
/** 自定义元数据 */
|
|
31
|
+
custom?: T;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 条件组(支持嵌套)
|
|
35
|
+
*/
|
|
36
|
+
export interface ConditionGroup {
|
|
37
|
+
/** 逻辑运算符 */
|
|
38
|
+
operator: 'and' | 'or' | 'not';
|
|
39
|
+
/** 条件规则列表(可以是单条件或嵌套的条件组) */
|
|
40
|
+
rules: Array<ConditionRule | ConditionGroup>;
|
|
41
|
+
/** 关联的动作ID列表(必填,可以为空数组) */
|
|
42
|
+
actionIds: string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 条件规则(原子条件)
|
|
46
|
+
* 支持 code 模式使用 eval 执行
|
|
47
|
+
*/
|
|
48
|
+
export interface ConditionRule {
|
|
49
|
+
/** 类型 */
|
|
50
|
+
type: 'code' | 'operator';
|
|
51
|
+
/** 代码(code模式使用,使用eval执行) */
|
|
52
|
+
code?: string;
|
|
53
|
+
/** 维度(完全可扩展) */
|
|
54
|
+
dimension?: string;
|
|
55
|
+
/** 字段名 */
|
|
56
|
+
field?: string;
|
|
57
|
+
/** 运算符 */
|
|
58
|
+
operator?: string;
|
|
59
|
+
/** 比较值 */
|
|
60
|
+
value?: any;
|
|
61
|
+
/** 值类型 */
|
|
62
|
+
valueType?: 'number' | 'string' | 'boolean' | 'array' | 'object' | 'date';
|
|
63
|
+
/** 值单位 */
|
|
64
|
+
valueUnit?: string;
|
|
65
|
+
/** 额外配置 */
|
|
66
|
+
config?: Record<string, any>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 动作效果
|
|
70
|
+
*/
|
|
71
|
+
export interface ActionEffect {
|
|
72
|
+
/** 动作的唯一标识 */
|
|
73
|
+
id: string;
|
|
74
|
+
/** 效果类型(完全可扩展) */
|
|
75
|
+
type: string;
|
|
76
|
+
/** 运算符(可选) */
|
|
77
|
+
operator?: string;
|
|
78
|
+
/** 值 */
|
|
79
|
+
value: any;
|
|
80
|
+
/** 值类型 */
|
|
81
|
+
valueType?: 'number' | 'string' | 'boolean' | 'array' | 'object';
|
|
82
|
+
/** 值单位 */
|
|
83
|
+
valueUnit?: string;
|
|
84
|
+
/** 作用目标 */
|
|
85
|
+
target: string;
|
|
86
|
+
/** 优先级(数字越大优先级越高) */
|
|
87
|
+
priority?: number;
|
|
88
|
+
/** 配置(完全可扩展) */
|
|
89
|
+
config?: Record<string, any>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 展示配置
|
|
93
|
+
*/
|
|
94
|
+
export interface DisplayConfig {
|
|
95
|
+
/** 商品卡片展示 */
|
|
96
|
+
productCard?: {
|
|
97
|
+
text: string | Record<string, string>;
|
|
98
|
+
type: 'tag' | 'badge' | 'label';
|
|
99
|
+
image?: string;
|
|
100
|
+
style?: Record<string, any>;
|
|
101
|
+
};
|
|
102
|
+
/** 详情页展示 */
|
|
103
|
+
detail?: {
|
|
104
|
+
title: string | Record<string, string>;
|
|
105
|
+
description: string | Record<string, string>;
|
|
106
|
+
image?: string;
|
|
107
|
+
};
|
|
108
|
+
/** 自定义展示配置 */
|
|
109
|
+
custom?: Record<string, any>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 运行时上下文结构
|
|
113
|
+
*/
|
|
114
|
+
export interface RuntimeContext {
|
|
115
|
+
/** 实体数据(完全开放,由业务层定义) */
|
|
116
|
+
entities: Record<string, any>;
|
|
117
|
+
/** 属性数据(扁平化的计算值,用于条件判断) */
|
|
118
|
+
attributes: Record<string, any>;
|
|
119
|
+
/** 上下文元数据 */
|
|
120
|
+
metadata: ContextMetadata;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 上下文元数据
|
|
124
|
+
*/
|
|
125
|
+
export interface ContextMetadata {
|
|
126
|
+
/** 请求ID(用于追踪) */
|
|
127
|
+
requestId?: string;
|
|
128
|
+
/** 时间戳 */
|
|
129
|
+
timestamp: number;
|
|
130
|
+
/** 语言 */
|
|
131
|
+
locale?: string;
|
|
132
|
+
/** 自定义元数据 */
|
|
133
|
+
custom?: Record<string, any>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 评估结果结构
|
|
137
|
+
*/
|
|
138
|
+
export interface EvaluationResult {
|
|
139
|
+
/** 是否成功执行(引擎层面) */
|
|
140
|
+
success: boolean;
|
|
141
|
+
/** 策略是否适用(业务层面) */
|
|
142
|
+
applicable: boolean;
|
|
143
|
+
/** 结果码 */
|
|
144
|
+
code: string;
|
|
145
|
+
/** 消息(多语言key或直接文本) */
|
|
146
|
+
message?: string;
|
|
147
|
+
/** 匹配信息 */
|
|
148
|
+
matched: MatchedInfo;
|
|
149
|
+
/** 匹配的动作列表(按priority排序) */
|
|
150
|
+
matchedActions: ActionEffect[];
|
|
151
|
+
/** 输出结果(完全开放,由适配器定义) */
|
|
152
|
+
outputs: Record<string, any>;
|
|
153
|
+
/** 执行轨迹(可选,用于调试) */
|
|
154
|
+
trace?: ExecutionTrace;
|
|
155
|
+
/** 策略配置 */
|
|
156
|
+
config: StrategyConfig;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 匹配信息
|
|
160
|
+
*/
|
|
161
|
+
export interface MatchedInfo {
|
|
162
|
+
/** 条件是否满足 */
|
|
163
|
+
conditions: boolean;
|
|
164
|
+
/** 收集到的 actionIds */
|
|
165
|
+
actionIds: string[];
|
|
166
|
+
/** 详细匹配信息 */
|
|
167
|
+
details: Record<string, any>;
|
|
168
|
+
/** 顶层第一个失败的 field(仅在 conditions=false 时存在,便于直接消费) */
|
|
169
|
+
failedField?: string;
|
|
170
|
+
/** 失败的原子规则列表(仅在 conditions=false 时存在;or 全失败时可能有多条) */
|
|
171
|
+
failedRules?: FailedRuleInfo[];
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* 失败规则信息
|
|
175
|
+
*/
|
|
176
|
+
export interface FailedRuleInfo {
|
|
177
|
+
/** 字段名 */
|
|
178
|
+
field?: string;
|
|
179
|
+
/** 运算符 */
|
|
180
|
+
operator?: string;
|
|
181
|
+
/** 配置的比较值(阈值) */
|
|
182
|
+
value?: any;
|
|
183
|
+
/** 实际取到的字段值 */
|
|
184
|
+
actualValue?: any;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* 执行轨迹
|
|
188
|
+
*/
|
|
189
|
+
export interface ExecutionTrace {
|
|
190
|
+
/** 执行步骤 */
|
|
191
|
+
steps: TraceStep[];
|
|
192
|
+
/** 总耗时(毫秒) */
|
|
193
|
+
duration: number;
|
|
194
|
+
/** 错误信息 */
|
|
195
|
+
errors?: Array<{
|
|
196
|
+
step: string;
|
|
197
|
+
error: string;
|
|
198
|
+
timestamp: number;
|
|
199
|
+
}>;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* 追踪步骤
|
|
203
|
+
*/
|
|
204
|
+
export interface TraceStep {
|
|
205
|
+
/** 步骤名称 */
|
|
206
|
+
step: string;
|
|
207
|
+
/** 步骤状态 */
|
|
208
|
+
status: 'success' | 'failed' | 'skipped';
|
|
209
|
+
/** 耗时(毫秒) */
|
|
210
|
+
duration: number;
|
|
211
|
+
/** 详细信息 */
|
|
212
|
+
details?: Record<string, any>;
|
|
213
|
+
}
|
|
214
|
+
/** 成功码 */
|
|
215
|
+
export declare const SUCCESS_CODES: {
|
|
216
|
+
readonly SUCCESS: "SUCCESS";
|
|
217
|
+
};
|
|
218
|
+
/** 不适用码 */
|
|
219
|
+
export declare const NOT_APPLICABLE_CODES: {
|
|
220
|
+
readonly CONDITION_NOT_MET: "CONDITION_NOT_MET";
|
|
221
|
+
};
|
|
222
|
+
/** 错误码 */
|
|
223
|
+
export declare const ERROR_CODES: {
|
|
224
|
+
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
225
|
+
readonly INVALID_CONTEXT: "INVALID_CONTEXT";
|
|
226
|
+
readonly EVALUATION_ERROR: "EVALUATION_ERROR";
|
|
227
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* 引擎配置选项
|
|
231
|
+
*/
|
|
232
|
+
export interface EngineOptions {
|
|
233
|
+
/** 是否启用调试模式 */
|
|
234
|
+
debug?: boolean;
|
|
235
|
+
/** 是否启用追踪 */
|
|
236
|
+
enableTrace?: boolean;
|
|
237
|
+
/** 运算符处理器映射 */
|
|
238
|
+
operatorHandlers?: Record<string, OperatorHandler>;
|
|
239
|
+
/** 自定义错误处理器 */
|
|
240
|
+
errorHandler?: (error: Error, context: RuntimeContext) => void;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* 运算符处理器
|
|
244
|
+
*/
|
|
245
|
+
export type OperatorHandler = (fieldValue: any, compareValue: any, rule: ConditionRule) => boolean;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export declare enum AccountHooks {
|
|
2
|
+
OnLogin = "account:onLogin",
|
|
3
|
+
OnLogout = "account:onLogout",
|
|
4
|
+
OnRegister = "account:onRegister",
|
|
5
|
+
OnProfileUpdate = "account:onProfileUpdate"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 用户账户信息
|
|
9
|
+
*/
|
|
10
|
+
export interface Account {
|
|
11
|
+
id: string | number;
|
|
12
|
+
/** 用户名 */
|
|
13
|
+
username: string;
|
|
14
|
+
/** 邮箱 */
|
|
15
|
+
email?: string;
|
|
16
|
+
/** 手机号 */
|
|
17
|
+
phone?: string;
|
|
18
|
+
/** 昵称 */
|
|
19
|
+
name?: string;
|
|
20
|
+
/** 头像 */
|
|
21
|
+
avatar?: string;
|
|
22
|
+
/** 元数据 */
|
|
23
|
+
metadata?: Record<string, any>;
|
|
24
|
+
/** 是否为游客 */
|
|
25
|
+
isGuest?: boolean;
|
|
26
|
+
/** 账户类型 */
|
|
27
|
+
type?: 'account' | 'holder';
|
|
28
|
+
/** 账户信息原始数据 */
|
|
29
|
+
_origin?: Record<string, any>;
|
|
30
|
+
/** 是否是登录账号 */
|
|
31
|
+
isLogin?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 账户模块状态
|
|
35
|
+
*/
|
|
36
|
+
export interface AccountState {
|
|
37
|
+
accountInfo: Account | null;
|
|
38
|
+
isLoggedIn: boolean;
|
|
39
|
+
active: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 账户模块 API
|
|
43
|
+
*/
|
|
44
|
+
export interface AccountModuleAPI {
|
|
45
|
+
login: (credentials: {
|
|
46
|
+
username: string;
|
|
47
|
+
password: string;
|
|
48
|
+
}) => Promise<void>;
|
|
49
|
+
logout: () => Promise<void>;
|
|
50
|
+
register: (account: Omit<Account, 'id'>) => Promise<void>;
|
|
51
|
+
getCurrentAccount: () => Account | null;
|
|
52
|
+
updateProfile: (updates: Partial<Account>) => Promise<void>;
|
|
53
|
+
isLoggedIn: () => boolean;
|
|
54
|
+
resetPassword: (email: string) => Promise<void>;
|
|
55
|
+
updatePassword: (oldPassword: string, newPassword: string) => Promise<void>;
|
|
56
|
+
}
|