@pisell/pisellos 2.2.147 → 2.2.149
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/apis/picoding.js +1 -0
- package/dist/model/strategy/adapter/index.d.ts +2 -0
- package/dist/model/strategy/adapter/index.js +3 -1
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +483 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +382 -0
- package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/dist/model/strategy/adapter/itemRule/index.js +5 -0
- package/dist/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/modules/Cart/types.d.ts +2 -0
- package/dist/modules/Cart/utils/cartProduct.js +22 -1
- package/dist/modules/Cart/utils/changePrice.js +6 -0
- package/dist/modules/Date/index.d.ts +1 -1
- package/dist/modules/Date/index.js +16 -8
- package/dist/modules/Date/types.d.ts +3 -1
- package/dist/modules/OpenData/index.d.ts +24 -0
- package/dist/modules/OpenData/index.js +173 -0
- package/dist/modules/OpenData/types.d.ts +73 -0
- package/dist/modules/OpenData/types.js +1 -0
- package/dist/modules/OpenData/utils.d.ts +2 -0
- package/dist/modules/OpenData/utils.js +75 -0
- package/dist/modules/Order/index.d.ts +171 -1
- package/dist/modules/Order/index.js +2052 -112
- package/dist/modules/Order/types.d.ts +441 -20
- package/dist/modules/Order/types.js +23 -0
- package/dist/modules/Order/utils.d.ts +120 -0
- package/dist/modules/Order/utils.js +653 -2
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.js +2 -1
- package/dist/modules/Quotation/index.d.ts +8 -1
- package/dist/modules/Quotation/index.js +40 -10
- package/dist/modules/Quotation/types.d.ts +5 -0
- package/dist/modules/Rules/index.d.ts +3 -1
- package/dist/modules/Rules/index.js +136 -50
- package/dist/modules/Rules/types.d.ts +6 -0
- package/dist/modules/Rules/types.js +8 -0
- package/dist/modules/SalesSummary/index.d.ts +70 -0
- package/dist/modules/SalesSummary/index.js +175 -0
- package/dist/modules/SalesSummary/types.d.ts +64 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +34 -0
- package/dist/modules/SalesSummary/utils.js +488 -0
- package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
- package/dist/modules/ScanOrderLogger/index.js +161 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/feishu.js +203 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
- package/dist/modules/ScanOrderLogger/types.d.ts +52 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Schedule/getDateIsInSchedule.js +7 -7
- package/dist/modules/Schedule/index.d.ts +4 -13
- package/dist/modules/Schedule/index.js +6 -23
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/modules/Summary/index.d.ts +3 -0
- package/dist/modules/Summary/index.js +134 -15
- package/dist/modules/Summary/types.d.ts +7 -0
- package/dist/modules/Summary/utils.d.ts +104 -1
- package/dist/modules/Summary/utils.js +1116 -13
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/server/index.d.ts +41 -4
- package/dist/server/index.js +900 -405
- package/dist/server/modules/order/index.d.ts +10 -2
- package/dist/server/modules/order/index.js +251 -196
- package/dist/server/modules/products/index.d.ts +26 -0
- package/dist/server/modules/products/index.js +618 -338
- package/dist/server/modules/products/types.d.ts +5 -1
- package/dist/solution/BaseSales/index.d.ts +175 -0
- package/dist/solution/BaseSales/index.js +1293 -0
- package/dist/solution/BaseSales/types.d.ts +305 -0
- package/dist/solution/BaseSales/types.js +38 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +159 -0
- package/dist/solution/BaseSales/utils.d.ts +40 -0
- package/dist/solution/BaseSales/utils.js +222 -0
- package/dist/solution/BookingByStep/index.d.ts +14 -0
- package/dist/solution/BookingByStep/index.js +699 -212
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingByStep/utils/capacity.js +1 -1
- package/dist/solution/BookingByStep/utils/resources.js +6 -1
- package/dist/solution/BookingTicket/index.d.ts +113 -15
- package/dist/solution/BookingTicket/index.js +534 -196
- package/dist/solution/BookingTicket/types.d.ts +69 -6
- package/dist/solution/BookingTicket/types.js +40 -9
- package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/dist/solution/BookingTicket/utils/bookingStatus.js +66 -0
- package/dist/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/dist/solution/BookingTicket/utils/cartView.js +84 -0
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +1 -0
- package/dist/solution/ScanOrder/index.d.ts +146 -0
- package/dist/solution/ScanOrder/index.js +3029 -0
- package/dist/solution/ScanOrder/types.d.ts +305 -0
- package/dist/solution/ScanOrder/types.js +35 -0
- package/dist/solution/ScanOrder/utils.d.ts +167 -0
- package/dist/solution/ScanOrder/utils.js +768 -0
- package/dist/solution/ShopDiscount/index.d.ts +2 -0
- package/dist/solution/ShopDiscount/index.js +9 -5
- package/dist/solution/ShopDiscount/types.d.ts +4 -0
- package/dist/solution/VenueBooking/index.d.ts +197 -0
- package/dist/solution/VenueBooking/index.js +3411 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +153 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +104 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/dist/solution/VenueBooking/utils/resource.js +130 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +224 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +453 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +3 -0
- package/dist/solution/index.js +4 -1
- package/lib/apis/picoding.d.ts +0 -0
- package/lib/apis/picoding.js +0 -0
- package/lib/model/strategy/adapter/index.d.ts +2 -0
- package/lib/model/strategy/adapter/index.js +6 -0
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +67 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +377 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
- package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +79 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +316 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +60 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +225 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Cart/types.d.ts +2 -0
- package/lib/modules/Cart/utils/cartProduct.js +17 -1
- package/lib/modules/Cart/utils/changePrice.js +5 -0
- package/lib/modules/Date/index.d.ts +1 -1
- package/lib/modules/Date/index.js +7 -1
- package/lib/modules/Date/types.d.ts +3 -1
- package/lib/modules/OpenData/index.d.ts +24 -0
- package/lib/modules/OpenData/index.js +119 -0
- package/lib/modules/OpenData/types.d.ts +73 -0
- package/lib/modules/OpenData/types.js +17 -0
- package/lib/modules/OpenData/utils.d.ts +2 -0
- package/lib/modules/OpenData/utils.js +111 -0
- package/lib/modules/Order/index.d.ts +171 -1
- package/lib/modules/Order/index.js +1396 -5
- package/lib/modules/Order/types.d.ts +441 -20
- package/lib/modules/Order/types.js +1 -0
- package/lib/modules/Order/utils.d.ts +120 -0
- package/lib/modules/Order/utils.js +562 -2
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +8 -1
- package/lib/modules/Quotation/index.js +33 -4
- package/lib/modules/Quotation/types.d.ts +5 -0
- package/lib/modules/Rules/index.d.ts +3 -1
- package/lib/modules/Rules/index.js +46 -6
- package/lib/modules/Rules/types.d.ts +6 -0
- package/lib/modules/Rules/types.js +11 -2
- package/lib/modules/SalesSummary/index.d.ts +70 -0
- package/lib/modules/SalesSummary/index.js +106 -0
- package/lib/modules/SalesSummary/types.d.ts +64 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +34 -0
- package/lib/modules/SalesSummary/utils.js +430 -0
- package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
- package/lib/modules/ScanOrderLogger/index.js +135 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/feishu.js +148 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
- package/lib/modules/ScanOrderLogger/types.d.ts +52 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Schedule/getDateIsInSchedule.js +5 -5
- package/lib/modules/Schedule/index.d.ts +4 -13
- package/lib/modules/Schedule/index.js +4 -15
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/modules/Summary/index.d.ts +3 -0
- package/lib/modules/Summary/index.js +61 -2
- package/lib/modules/Summary/types.d.ts +7 -0
- package/lib/modules/Summary/utils.d.ts +104 -1
- package/lib/modules/Summary/utils.js +659 -8
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/server/index.d.ts +41 -4
- package/lib/server/index.js +272 -10
- package/lib/server/modules/order/index.d.ts +10 -2
- package/lib/server/modules/order/index.js +31 -4
- package/lib/server/modules/products/index.d.ts +26 -0
- package/lib/server/modules/products/index.js +174 -22
- package/lib/server/modules/products/types.d.ts +5 -1
- package/lib/solution/BaseSales/index.d.ts +175 -0
- package/lib/solution/BaseSales/index.js +655 -0
- package/lib/solution/BaseSales/types.d.ts +305 -0
- package/lib/solution/BaseSales/types.js +40 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +143 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +160 -0
- package/lib/solution/BaseSales/utils.d.ts +40 -0
- package/lib/solution/BaseSales/utils.js +200 -0
- package/lib/solution/BookingByStep/index.d.ts +14 -0
- package/lib/solution/BookingByStep/index.js +469 -91
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingByStep/utils/capacity.js +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +5 -2
- package/lib/solution/BookingTicket/index.d.ts +113 -15
- package/lib/solution/BookingTicket/index.js +253 -61
- package/lib/solution/BookingTicket/types.d.ts +69 -6
- package/lib/solution/BookingTicket/types.js +16 -14
- package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +37 -0
- package/lib/solution/BookingTicket/utils/bookingStatus.js +65 -0
- package/lib/solution/BookingTicket/utils/cartView.d.ts +26 -0
- package/lib/solution/BookingTicket/utils/cartView.js +103 -0
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.d.ts +146 -0
- package/lib/solution/ScanOrder/index.js +1820 -0
- package/lib/solution/ScanOrder/types.d.ts +305 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +167 -0
- package/lib/solution/ScanOrder/utils.js +639 -0
- package/lib/solution/ShopDiscount/index.d.ts +2 -0
- package/lib/solution/ShopDiscount/index.js +9 -4
- package/lib/solution/ShopDiscount/types.d.ts +4 -0
- package/lib/solution/VenueBooking/index.d.ts +197 -0
- package/lib/solution/VenueBooking/index.js +1892 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +153 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +11 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +110 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +14 -0
- package/lib/solution/VenueBooking/utils/resource.js +91 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +34 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +225 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +339 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +3 -0
- package/lib/solution/index.js +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import type { StrategyConfig, EvaluationResult } from '../../type';
|
|
2
|
+
export declare const ITEM_RULE_ACTION_TYPES: {
|
|
3
|
+
/** 数量校验 */
|
|
4
|
+
readonly QUANTITY_CHECK: "QUANTITY_CHECK";
|
|
5
|
+
/** 预填购物车 */
|
|
6
|
+
readonly PREFILL_CART: "PREFILL_CART";
|
|
7
|
+
};
|
|
8
|
+
export type ItemRuleActionType = (typeof ITEM_RULE_ACTION_TYPES)[keyof typeof ITEM_RULE_ACTION_TYPES];
|
|
9
|
+
export declare const ITEM_RULE_TEMPLATES: {
|
|
10
|
+
/** 空白规则 */
|
|
11
|
+
readonly BLANK: "blank";
|
|
12
|
+
/** 人数关联最少量(每人至少N份) */
|
|
13
|
+
readonly MINIMUM_PER_PERSON: "minimum_per_person";
|
|
14
|
+
/** 每桌限量 */
|
|
15
|
+
readonly MAXIMUM_PER_TABLE: "maximum_per_table";
|
|
16
|
+
/** 必选商品 */
|
|
17
|
+
readonly MUST_INCLUDE: "must_include";
|
|
18
|
+
};
|
|
19
|
+
export type ItemRuleTemplate = (typeof ITEM_RULE_TEMPLATES)[keyof typeof ITEM_RULE_TEMPLATES];
|
|
20
|
+
/** 数量比较类型 */
|
|
21
|
+
export type QuantityComparison = 'minimum' | 'maximum' | 'exact' | 'must_include';
|
|
22
|
+
/** 数量来源 */
|
|
23
|
+
export type QuantitySource = 'total_pax' | 'adult_pax' | 'fixed';
|
|
24
|
+
/** 目标类型(当前仅支持按商品) */
|
|
25
|
+
export type TargetType = 'product';
|
|
26
|
+
/** 作用范围 */
|
|
27
|
+
export type RuleScope = 'each_submission' | 'first_submission_only' | 'subsequent_only' | 'cumulative';
|
|
28
|
+
/**
|
|
29
|
+
* 单条数量规则
|
|
30
|
+
*
|
|
31
|
+
* 例如:Minimum + Total Pax 表示"最少数量 = 总人数"
|
|
32
|
+
* 例如:Maximum + Fixed + 10 表示"最多10份"
|
|
33
|
+
*/
|
|
34
|
+
export interface QuantityRule {
|
|
35
|
+
/** 比较方式 */
|
|
36
|
+
comparison: QuantityComparison;
|
|
37
|
+
/** 数量来源 */
|
|
38
|
+
source: QuantitySource;
|
|
39
|
+
/** 固定值(当 source 为 'fixed' 时使用) */
|
|
40
|
+
value?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Quantity Check Action 的详细配置
|
|
44
|
+
*
|
|
45
|
+
* 存储在 ActionEffect.config 中
|
|
46
|
+
*/
|
|
47
|
+
export interface QuantityCheckConfig {
|
|
48
|
+
/** 目标类型 */
|
|
49
|
+
targetType: TargetType;
|
|
50
|
+
/** 目标商品 ID 列表 */
|
|
51
|
+
targets: TargetItem[];
|
|
52
|
+
/** 数量规则列表(多条规则同时生效) */
|
|
53
|
+
quantityRules: QuantityRule[];
|
|
54
|
+
/** 作用范围 */
|
|
55
|
+
scope: RuleScope;
|
|
56
|
+
/** 校验失败时的提示语,支持 {min} {max} 占位符,支持多语言 */
|
|
57
|
+
validationMessage?: string | Record<string, string>;
|
|
58
|
+
}
|
|
59
|
+
/** 目标项 */
|
|
60
|
+
export interface TargetItem {
|
|
61
|
+
/** 目标商品 ID */
|
|
62
|
+
product_id: number;
|
|
63
|
+
/** 变体 ID */
|
|
64
|
+
product_variant_id?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 预填商品项
|
|
68
|
+
*/
|
|
69
|
+
export interface PrefillProduct {
|
|
70
|
+
/** 商品 ID */
|
|
71
|
+
product_id: number;
|
|
72
|
+
/** 变体 ID(可选,0 或不填表示无变体/默认) */
|
|
73
|
+
product_variant_id?: number;
|
|
74
|
+
/** 数量来源 */
|
|
75
|
+
quantityFrom: QuantitySource;
|
|
76
|
+
/** 固定数量(当 quantityFrom 为 'fixed' 时使用) */
|
|
77
|
+
quantity?: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Prefill Cart Action 的详细配置
|
|
81
|
+
*
|
|
82
|
+
* 存储在 ActionEffect.config 中
|
|
83
|
+
*/
|
|
84
|
+
export interface PrefillCartConfig {
|
|
85
|
+
/** 要预填的商品列表 */
|
|
86
|
+
products: PrefillProduct[];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 购物车商品摘要
|
|
90
|
+
*/
|
|
91
|
+
export interface CartItemSummary {
|
|
92
|
+
/** 商品 ID */
|
|
93
|
+
product_id: number;
|
|
94
|
+
/** 变体 ID */
|
|
95
|
+
product_variant_id?: number;
|
|
96
|
+
/** 数量 */
|
|
97
|
+
quantity: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 就餐人数信息
|
|
101
|
+
*/
|
|
102
|
+
export interface PaxInfo {
|
|
103
|
+
/** 总人数 */
|
|
104
|
+
total: number;
|
|
105
|
+
/** 成人人数 */
|
|
106
|
+
adult: number;
|
|
107
|
+
/** 儿童人数 */
|
|
108
|
+
child: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* ItemRule 评估器的输入业务数据
|
|
112
|
+
*/
|
|
113
|
+
export interface ItemRuleBusinessData {
|
|
114
|
+
/** 就餐人数 */
|
|
115
|
+
pax: PaxInfo;
|
|
116
|
+
/** 当前购物车商品列表 */
|
|
117
|
+
cartItems: CartItemSummary[];
|
|
118
|
+
/** 历史订单商品列表(用于 cumulative scope,主订单+加单的商品汇总) */
|
|
119
|
+
historicalItems?: CartItemSummary[];
|
|
120
|
+
/** 服务类型(如 'dine-in', 'takeaway') */
|
|
121
|
+
serviceType?: string;
|
|
122
|
+
/** 当前提交次数(0=首次提交, >0=追加提交) */
|
|
123
|
+
submissionIndex?: number;
|
|
124
|
+
/** 策略配置列表(可选,如果不传则使用 setStrategyConfigs 设置的) */
|
|
125
|
+
strategyConfigs?: StrategyConfig[];
|
|
126
|
+
/** 自定义属性(会合并到 context.attributes) */
|
|
127
|
+
custom?: Record<string, any>;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* 单个 Quantity Check 的校验结果
|
|
131
|
+
*/
|
|
132
|
+
export interface QuantityCheckResult {
|
|
133
|
+
/** 规则 ID(对应 ActionEffect.id) */
|
|
134
|
+
ruleId: string;
|
|
135
|
+
/** 是否通过校验 */
|
|
136
|
+
passed: boolean;
|
|
137
|
+
/** 目标类型 */
|
|
138
|
+
targetType: TargetType;
|
|
139
|
+
/** 目标列表 */
|
|
140
|
+
targets: TargetItem[];
|
|
141
|
+
/** 当前购物车中的实际数量 */
|
|
142
|
+
actualQuantity: number;
|
|
143
|
+
/** 要求的最小数量(根据规则计算后的值) */
|
|
144
|
+
requiredMin?: number;
|
|
145
|
+
/** 要求的最大数量 */
|
|
146
|
+
requiredMax?: number;
|
|
147
|
+
/** 要求的精确数量 */
|
|
148
|
+
requiredExact?: number;
|
|
149
|
+
/** 是否必须包含(must_include) */
|
|
150
|
+
mustInclude?: boolean;
|
|
151
|
+
/** 格式化后的校验提示语 */
|
|
152
|
+
validationMessage?: string;
|
|
153
|
+
/** 作用范围 */
|
|
154
|
+
scope: RuleScope;
|
|
155
|
+
/** 未通过的具体规则 */
|
|
156
|
+
failedRules?: QuantityRule[];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* 单个 Prefill Cart 的预填结果
|
|
160
|
+
*/
|
|
161
|
+
export interface PrefillItemResult {
|
|
162
|
+
/** 规则 ID(对应 ActionEffect.id) */
|
|
163
|
+
ruleId: string;
|
|
164
|
+
/** 商品 ID */
|
|
165
|
+
product_id: number;
|
|
166
|
+
/** 变体 ID */
|
|
167
|
+
product_variant_id?: number;
|
|
168
|
+
/** 应添加的数量 */
|
|
169
|
+
quantity: number;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* 单条规则的数量限制(不含校验结果,仅描述配置中的约束)
|
|
173
|
+
*/
|
|
174
|
+
export interface QuantityLimitResult {
|
|
175
|
+
/** 规则 ID(对应 ActionEffect.id) */
|
|
176
|
+
ruleId: string;
|
|
177
|
+
/** 目标类型 */
|
|
178
|
+
targetType: TargetType;
|
|
179
|
+
/** 目标列表 */
|
|
180
|
+
targets: TargetItem[];
|
|
181
|
+
/** 要求的最小数量 */
|
|
182
|
+
requiredMin?: number;
|
|
183
|
+
/** 要求的最大数量(规则配置的原始上限,用于 UI 文案展示) */
|
|
184
|
+
requiredMax?: number;
|
|
185
|
+
/**
|
|
186
|
+
* 当前提交剩余可选的最大数量。
|
|
187
|
+
*
|
|
188
|
+
* 仅在 scope='cumulative' 且存在 requiredMax 时计算:
|
|
189
|
+
* remainingMax = max(0, requiredMax - historicalItems 中目标商品累计数量)
|
|
190
|
+
*
|
|
191
|
+
* 非 cumulative 场景不设置此字段;调用方用于限制加购上限时,
|
|
192
|
+
* 应优先读取本字段,未定义时回退到 requiredMax。
|
|
193
|
+
*/
|
|
194
|
+
remainingMax?: number;
|
|
195
|
+
/** 要求的精确数量 */
|
|
196
|
+
requiredExact?: number;
|
|
197
|
+
/** 是否必须包含 */
|
|
198
|
+
mustInclude?: boolean;
|
|
199
|
+
/** 作用范围 */
|
|
200
|
+
scope: RuleScope;
|
|
201
|
+
/**
|
|
202
|
+
* 校验失败时的提示语(已做 {min}/{max}/{exact} 占位符替换)。
|
|
203
|
+
* 当 rawValidationMessage 为多语言对象时,后端不做 locale 选择,
|
|
204
|
+
* 默认按 en → Object.values()[0] 的顺序兜底,前端可再根据自身 locale
|
|
205
|
+
* 读取 rawValidationMessage 做精确匹配。
|
|
206
|
+
*/
|
|
207
|
+
validationMessage?: string;
|
|
208
|
+
/** 原始多语言模板,前端可根据自身 locale 做二次选择 */
|
|
209
|
+
rawValidationMessage?: string | Record<string, string>;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* ItemRule 评估器的完整输出结果
|
|
213
|
+
*/
|
|
214
|
+
export interface ItemRuleEvaluationResult {
|
|
215
|
+
/** 所有数量校验结果 */
|
|
216
|
+
quantityChecks: QuantityCheckResult[];
|
|
217
|
+
/** 需要预填的商品列表 */
|
|
218
|
+
prefillItems: PrefillItemResult[];
|
|
219
|
+
/** 所有校验是否全部通过 */
|
|
220
|
+
allPassed: boolean;
|
|
221
|
+
/** 未通过的校验列表 */
|
|
222
|
+
failedChecks: QuantityCheckResult[];
|
|
223
|
+
/** 原始策略评估结果列表 */
|
|
224
|
+
rawResults: EvaluationResult[];
|
|
225
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// ============================================
|
|
2
|
+
// Action Type 常量
|
|
3
|
+
// ============================================
|
|
4
|
+
|
|
5
|
+
export var ITEM_RULE_ACTION_TYPES = {
|
|
6
|
+
/** 数量校验 */
|
|
7
|
+
QUANTITY_CHECK: 'QUANTITY_CHECK',
|
|
8
|
+
/** 预填购物车 */
|
|
9
|
+
PREFILL_CART: 'PREFILL_CART'
|
|
10
|
+
};
|
|
11
|
+
// ============================================
|
|
12
|
+
// Rule Template 类型(创建规则时的起始模板)
|
|
13
|
+
// ============================================
|
|
14
|
+
|
|
15
|
+
export var ITEM_RULE_TEMPLATES = {
|
|
16
|
+
/** 空白规则 */
|
|
17
|
+
BLANK: 'blank',
|
|
18
|
+
/** 人数关联最少量(每人至少N份) */
|
|
19
|
+
MINIMUM_PER_PERSON: 'minimum_per_person',
|
|
20
|
+
/** 每桌限量 */
|
|
21
|
+
MAXIMUM_PER_TABLE: 'maximum_per_table',
|
|
22
|
+
/** 必选商品 */
|
|
23
|
+
MUST_INCLUDE: 'must_include'
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// ============================================
|
|
27
|
+
// Quantity Check 相关类型
|
|
28
|
+
// ============================================
|
|
29
|
+
|
|
30
|
+
/** 数量比较类型 */
|
|
31
|
+
|
|
32
|
+
/** 数量来源 */
|
|
33
|
+
|
|
34
|
+
/** 目标类型(当前仅支持按商品) */
|
|
35
|
+
|
|
36
|
+
/** 作用范围 */
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 单条数量规则
|
|
40
|
+
*
|
|
41
|
+
* 例如:Minimum + Total Pax 表示"最少数量 = 总人数"
|
|
42
|
+
* 例如:Maximum + Fixed + 10 表示"最多10份"
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Quantity Check Action 的详细配置
|
|
47
|
+
*
|
|
48
|
+
* 存储在 ActionEffect.config 中
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/** 目标项 */
|
|
52
|
+
|
|
53
|
+
// ============================================
|
|
54
|
+
// Prefill Cart 相关类型
|
|
55
|
+
// ============================================
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 预填商品项
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Prefill Cart Action 的详细配置
|
|
63
|
+
*
|
|
64
|
+
* 存储在 ActionEffect.config 中
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
// ============================================
|
|
68
|
+
// 业务数据类型(Evaluator 输入)
|
|
69
|
+
// ============================================
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 购物车商品摘要
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 就餐人数信息
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* ItemRule 评估器的输入业务数据
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
// ============================================
|
|
84
|
+
// 评估结果类型
|
|
85
|
+
// ============================================
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 单个 Quantity Check 的校验结果
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 单个 Prefill Cart 的预填结果
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 单条规则的数量限制(不含校验结果,仅描述配置中的约束)
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* ItemRule 评估器的完整输出结果
|
|
101
|
+
*/
|
|
@@ -13,6 +13,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
13
13
|
import Decimal from 'decimal.js';
|
|
14
14
|
import { isNormalProduct } from "../../Product/utils";
|
|
15
15
|
import { getDiscountAmount } from "../../../solution/ShopDiscount/utils";
|
|
16
|
+
import { calcDiscountListDifference } from "../../Summary/utils";
|
|
16
17
|
|
|
17
18
|
/** 与 Rules / ShopDiscount 一致的折扣入参,用于主价与 option 单价 */
|
|
18
19
|
var toDiscountPayload = function toDiscountPayload(discountItem) {
|
|
@@ -84,6 +85,11 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
|
|
|
84
85
|
num: num,
|
|
85
86
|
discounts: discounts
|
|
86
87
|
});
|
|
88
|
+
cartItem.totalDifference = getTotalDifference({
|
|
89
|
+
product: product,
|
|
90
|
+
bundle: bundle,
|
|
91
|
+
discounts: discounts
|
|
92
|
+
});
|
|
87
93
|
cartItem.summaryTotal = cartItem.total * (num || 1);
|
|
88
94
|
cartItem.origin_total = getProductOriginTotalPrice({
|
|
89
95
|
product: product,
|
|
@@ -250,6 +256,19 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
|
|
|
250
256
|
}
|
|
251
257
|
return Math.max(0, price);
|
|
252
258
|
};
|
|
259
|
+
var getTotalDifference = function getTotalDifference(params) {
|
|
260
|
+
var bundle = params.bundle,
|
|
261
|
+
discounts = params.discounts;
|
|
262
|
+
var bundleDiscountList = [];
|
|
263
|
+
if (bundle !== null && bundle !== void 0 && bundle.length) {
|
|
264
|
+
bundle.forEach(function (currentValue) {
|
|
265
|
+
bundleDiscountList.push.apply(bundleDiscountList, _toConsumableArray((currentValue === null || currentValue === void 0 ? void 0 : currentValue.discount_list) || []));
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
var allDiscounts = [].concat(_toConsumableArray(discounts || []), bundleDiscountList);
|
|
269
|
+
var productDiscountProductDiscountDifference = calcDiscountListDifference(allDiscounts);
|
|
270
|
+
return productDiscountProductDiscountDifference || 0;
|
|
271
|
+
};
|
|
253
272
|
|
|
254
273
|
/**
|
|
255
274
|
* 获取商品原始总价
|
|
@@ -336,7 +355,8 @@ export var formatBundle = function formatBundle(bundle) {
|
|
|
336
355
|
options: formatOptions(item === null || item === void 0 ? void 0 : item.option),
|
|
337
356
|
_bundle_product_id: item._bundle_product_id,
|
|
338
357
|
discount_list: item.discount_list,
|
|
339
|
-
originBundleItem: item.originBundleItem || item
|
|
358
|
+
originBundleItem: item.originBundleItem || item,
|
|
359
|
+
is_charge_tax: item === null || item === void 0 ? void 0 : item.is_charge_tax
|
|
340
360
|
};
|
|
341
361
|
});
|
|
342
362
|
};
|
|
@@ -362,6 +382,7 @@ export var formatBundleToOrigin = function formatBundleToOrigin(bundle) {
|
|
|
362
382
|
option: formatOptionsToOrigin(getBundleValueByKey('option')),
|
|
363
383
|
discount_list: d.discount_list,
|
|
364
384
|
"bundle_selling_price": d === null || d === void 0 ? void 0 : d.price,
|
|
385
|
+
"custom_price": d === null || d === void 0 ? void 0 : d.price,
|
|
365
386
|
metadata: {
|
|
366
387
|
custom_product_bundle_map_id: d._id,
|
|
367
388
|
product_discount_difference: product_discount_difference
|
|
@@ -57,6 +57,12 @@ function _updateAllCartItemPrice() {
|
|
|
57
57
|
if (targetBundleItem.price_type === 'markdown') {
|
|
58
58
|
targetBundleItem.price = new Decimal(targetBundleItem.price || 0).mul(-1).toNumber();
|
|
59
59
|
}
|
|
60
|
+
// 如果有选择 option,还需要加上 option 的价格
|
|
61
|
+
if (n.option) {
|
|
62
|
+
targetBundleItem.price = new Decimal(targetBundleItem.price || 0).add(n.option.reduce(function (pre, cur) {
|
|
63
|
+
return pre + new Decimal(cur.price || 0).mul(cur.num || 1).toNumber();
|
|
64
|
+
}, 0)).toNumber();
|
|
65
|
+
}
|
|
60
66
|
if (targetBundleItem) {
|
|
61
67
|
return _objectSpread(_objectSpread({}, n), {}, {
|
|
62
68
|
price: targetBundleItem.price,
|
|
@@ -37,5 +37,5 @@ export declare class DateModule extends BaseModule implements Module, DateModule
|
|
|
37
37
|
getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
|
|
38
38
|
clearDateRange(): void;
|
|
39
39
|
storeChange(): void;
|
|
40
|
-
getResourcesListByDate(date: string): any[]
|
|
40
|
+
getResourcesListByDate(date: string): any[];
|
|
41
41
|
}
|
|
@@ -85,6 +85,14 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
85
85
|
}, {
|
|
86
86
|
key: "setDateRange",
|
|
87
87
|
value: function setDateRange(dateRange) {
|
|
88
|
+
var _this2 = this;
|
|
89
|
+
// 如果 dateRange 传入的日期里没有 resource,但是本地有的,要尝试补充下
|
|
90
|
+
dateRange.forEach(function (item) {
|
|
91
|
+
var _item$resource;
|
|
92
|
+
if (!((_item$resource = item.resource) !== null && _item$resource !== void 0 && _item$resource.length)) {
|
|
93
|
+
item.resource = _this2.getResourcesListByDate(item.date);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
88
96
|
this.store.dateRange = dateRange;
|
|
89
97
|
}
|
|
90
98
|
}, {
|
|
@@ -157,10 +165,10 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
157
165
|
return n.date === item.date;
|
|
158
166
|
});
|
|
159
167
|
if (currentItemIndex !== -1) {
|
|
160
|
-
var _item$
|
|
168
|
+
var _item$resource2, _currentItem$resource3;
|
|
161
169
|
var currentItem = currentDateList[currentItemIndex];
|
|
162
170
|
// 看那一天的数据有没有相同的,把不同的资源合并进去即可
|
|
163
|
-
var newResource = (_item$
|
|
171
|
+
var newResource = (_item$resource2 = item.resource) === null || _item$resource2 === void 0 ? void 0 : _item$resource2.filter(function (n) {
|
|
164
172
|
var _currentItem$resource2;
|
|
165
173
|
return !((_currentItem$resource2 = currentItem.resource) !== null && _currentItem$resource2 !== void 0 && _currentItem$resource2.some(function (m) {
|
|
166
174
|
return m.id === n.id;
|
|
@@ -168,8 +176,8 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
168
176
|
});
|
|
169
177
|
// 如果有相同的资源,则使用 item 中的新的resource.times,而不是 currentItem 中的
|
|
170
178
|
(_currentItem$resource3 = currentItem.resource) === null || _currentItem$resource3 === void 0 || _currentItem$resource3.forEach(function (n) {
|
|
171
|
-
var _item$
|
|
172
|
-
var newResource = (_item$
|
|
179
|
+
var _item$resource3;
|
|
180
|
+
var newResource = (_item$resource3 = item.resource) === null || _item$resource3 === void 0 ? void 0 : _item$resource3.find(function (m) {
|
|
173
181
|
return m.id === n.id;
|
|
174
182
|
});
|
|
175
183
|
if (newResource) {
|
|
@@ -261,7 +269,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
261
269
|
}, {
|
|
262
270
|
key: "correctResourceTimeSlots",
|
|
263
271
|
value: function correctResourceTimeSlots(resourcesData) {
|
|
264
|
-
var
|
|
272
|
+
var _this3 = this;
|
|
265
273
|
return resourcesData.map(function (resource) {
|
|
266
274
|
// 检查资源是否有 times 数组和 start_time
|
|
267
275
|
if (!resource.times || !Array.isArray(resource.times) || !resource.start_time) {
|
|
@@ -284,7 +292,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
284
292
|
// 如果 start_at 早于资源的 start_time,需要修正
|
|
285
293
|
if (startAt.isBefore(resourceStartTime)) {
|
|
286
294
|
// 将 start_time 向上取整到下一个10分钟整数
|
|
287
|
-
var roundedStartTime =
|
|
295
|
+
var roundedStartTime = _this3.roundUpToNext10Minutes(resourceStartTime);
|
|
288
296
|
var roundedStartTimeDayjs = dayjs(roundedStartTime);
|
|
289
297
|
console.log("[DateModule] \u4FEE\u6B63\u65F6\u95F4\u6BB5\u5F00\u59CB\u65F6\u95F4: ".concat(timeSlot.start_at, " -> ").concat(roundedStartTime, " (\u8D44\u6E90ID: ").concat(resource.id, ", \u539F\u59CBstart_time: ").concat(resource.start_time, ")"));
|
|
290
298
|
|
|
@@ -393,9 +401,9 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
393
401
|
value: function getResourcesListByDate(date) {
|
|
394
402
|
var _dateList$find;
|
|
395
403
|
var dateList = this.store.dateList;
|
|
396
|
-
var resourcesList = (_dateList$find = dateList.find(function (item) {
|
|
404
|
+
var resourcesList = (dateList === null || dateList === void 0 || (_dateList$find = dateList.find(function (item) {
|
|
397
405
|
return item.date === date;
|
|
398
|
-
})) === null || _dateList$find === void 0 ? void 0 : _dateList$find.resource;
|
|
406
|
+
})) === null || _dateList$find === void 0 ? void 0 : _dateList$find.resource) || [];
|
|
399
407
|
return resourcesList;
|
|
400
408
|
}
|
|
401
409
|
}]);
|
|
@@ -20,7 +20,9 @@ export interface ITime {
|
|
|
20
20
|
date: string;
|
|
21
21
|
week: string;
|
|
22
22
|
weekNum: number;
|
|
23
|
-
status: 'unavailable' | 'available';
|
|
23
|
+
status: 'unavailable' | 'available' | 'lots_of_space' | 'filling_up_fast' | 'sold_out';
|
|
24
|
+
summaryCount?: number;
|
|
25
|
+
availableCount?: number;
|
|
24
26
|
resource?: any[];
|
|
25
27
|
color?: string[];
|
|
26
28
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import type { ScheduleModule } from '../Schedule';
|
|
4
|
+
import type { OpenDataConfig, OpenDataFetchParams, OpenDataAvailabilityResult } from './types';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export { computeAvailability } from './utils';
|
|
7
|
+
export declare class OpenDataModule extends BaseModule implements Module {
|
|
8
|
+
protected defaultName: string;
|
|
9
|
+
protected defaultVersion: string;
|
|
10
|
+
private request;
|
|
11
|
+
private window;
|
|
12
|
+
private store;
|
|
13
|
+
private cacheId;
|
|
14
|
+
private openCache;
|
|
15
|
+
private fatherModule;
|
|
16
|
+
private otherParams;
|
|
17
|
+
constructor(name?: string, version?: string);
|
|
18
|
+
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
19
|
+
fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
|
|
20
|
+
getOpenData(): OpenDataConfig | null;
|
|
21
|
+
getLastFetchedAt(): number | null;
|
|
22
|
+
checkAvailability(scheduleModule?: ScheduleModule): OpenDataAvailabilityResult;
|
|
23
|
+
storeChange(): void;
|
|
24
|
+
}
|