@pisell/pisellos 0.0.491 → 0.0.492
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 +59 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +439 -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 +64 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +315 -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 +206 -0
- package/dist/model/strategy/adapter/itemRule/type.js +101 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/walletPass/utils.js +2 -2
- package/dist/modules/OpenData/index.d.ts +23 -0
- package/dist/modules/OpenData/index.js +167 -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 +54 -2
- package/dist/modules/Order/index.js +717 -27
- package/dist/modules/Order/types.d.ts +144 -12
- package/dist/modules/Order/utils.d.ts +25 -0
- package/dist/modules/Order/utils.js +214 -1
- package/dist/modules/Product/utils.js +2 -2
- package/dist/modules/ProductList/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +3 -1
- package/dist/modules/Quotation/index.d.ts +40 -0
- package/dist/modules/Quotation/index.js +212 -0
- package/dist/modules/Quotation/types.d.ts +42 -0
- package/dist/modules/Quotation/types.js +1 -0
- package/dist/modules/SalesSummary/index.d.ts +63 -0
- package/dist/modules/SalesSummary/index.js +174 -0
- package/dist/modules/SalesSummary/types.d.ts +59 -0
- package/dist/modules/SalesSummary/types.js +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +30 -0
- package/dist/modules/SalesSummary/utils.js +506 -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 +95 -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 +46 -0
- package/dist/modules/ScanOrderLogger/types.js +1 -0
- package/dist/modules/Summary/utils.d.ts +3 -3
- package/dist/modules/Summary/utils.js +4 -4
- package/dist/modules/index.d.ts +4 -0
- package/dist/modules/index.js +5 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/types.d.ts +3 -1
- package/dist/solution/BookingByStep/types.js +5 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +90 -0
- package/dist/solution/ScanOrder/index.js +1853 -0
- package/dist/solution/ScanOrder/types.d.ts +210 -0
- package/dist/solution/ScanOrder/types.js +16 -0
- package/dist/solution/ScanOrder/utils.d.ts +93 -0
- package/dist/solution/ScanOrder/utils.js +378 -0
- package/dist/solution/VenueBooking/index.d.ts +159 -0
- package/dist/solution/VenueBooking/index.js +2773 -0
- package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/dist/solution/VenueBooking/types.d.ts +123 -0
- package/dist/solution/VenueBooking/types.js +21 -0
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +102 -0
- package/dist/solution/VenueBooking/utils/resource.d.ts +4 -0
- package/dist/solution/VenueBooking/utils/resource.js +94 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +18 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +128 -0
- package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/dist/solution/VenueBooking/utils/timeSlot.js +256 -0
- package/dist/solution/VenueBooking/utils.d.ts +1 -0
- package/dist/solution/VenueBooking/utils.js +1 -0
- package/dist/solution/index.d.ts +2 -0
- package/dist/solution/index.js +3 -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 +59 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +338 -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 +64 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +269 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
- package/lib/model/strategy/adapter/itemRule/index.js +58 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +206 -0
- package/lib/model/strategy/adapter/itemRule/type.js +46 -0
- package/lib/model/strategy/adapter/walletPass/utils.js +2 -2
- package/lib/modules/OpenData/index.d.ts +23 -0
- package/lib/modules/OpenData/index.js +116 -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 +54 -2
- package/lib/modules/Order/index.js +389 -1
- package/lib/modules/Order/types.d.ts +144 -12
- package/lib/modules/Order/utils.d.ts +25 -0
- package/lib/modules/Order/utils.js +217 -0
- package/lib/modules/Product/utils.js +2 -2
- package/lib/modules/ProductList/index.d.ts +1 -1
- package/lib/modules/ProductList/index.js +2 -1
- package/lib/modules/Quotation/index.d.ts +40 -0
- package/lib/modules/Quotation/index.js +128 -0
- package/lib/modules/Quotation/types.d.ts +42 -0
- package/lib/modules/Quotation/types.js +17 -0
- package/lib/modules/SalesSummary/index.d.ts +63 -0
- package/lib/modules/SalesSummary/index.js +105 -0
- package/lib/modules/SalesSummary/types.d.ts +59 -0
- package/lib/modules/SalesSummary/types.js +17 -0
- package/lib/modules/SalesSummary/utils.d.ts +30 -0
- package/lib/modules/SalesSummary/utils.js +445 -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 +82 -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 +46 -0
- package/lib/modules/ScanOrderLogger/types.js +17 -0
- package/lib/modules/Summary/utils.d.ts +3 -3
- package/lib/modules/Summary/utils.js +4 -4
- package/lib/modules/index.d.ts +4 -0
- package/lib/modules/index.js +9 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/types.d.ts +3 -1
- package/lib/solution/BookingByStep/types.js +10 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +90 -0
- package/lib/solution/ScanOrder/index.js +1071 -0
- package/lib/solution/ScanOrder/types.d.ts +210 -0
- package/lib/solution/ScanOrder/types.js +36 -0
- package/lib/solution/ScanOrder/utils.d.ts +93 -0
- package/lib/solution/ScanOrder/utils.js +342 -0
- package/lib/solution/VenueBooking/index.d.ts +159 -0
- package/lib/solution/VenueBooking/index.js +1508 -0
- package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
- package/lib/solution/VenueBooking/types.d.ts +123 -0
- package/lib/solution/VenueBooking/types.js +44 -0
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +101 -0
- package/lib/solution/VenueBooking/utils/resource.d.ts +4 -0
- package/lib/solution/VenueBooking/utils/resource.js +80 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +18 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +156 -0
- package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
- package/lib/solution/VenueBooking/utils/timeSlot.js +200 -0
- package/lib/solution/VenueBooking/utils.d.ts +1 -0
- package/lib/solution/VenueBooking/utils.js +69 -0
- package/lib/solution/index.d.ts +2 -0
- package/lib/solution/index.js +5 -1
- package/package.json +1 -1
|
@@ -0,0 +1,206 @@
|
|
|
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
|
+
/** 要求的最大数量 */
|
|
184
|
+
requiredMax?: number;
|
|
185
|
+
/** 要求的精确数量 */
|
|
186
|
+
requiredExact?: number;
|
|
187
|
+
/** 是否必须包含 */
|
|
188
|
+
mustInclude?: boolean;
|
|
189
|
+
/** 作用范围 */
|
|
190
|
+
scope: RuleScope;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* ItemRule 评估器的完整输出结果
|
|
194
|
+
*/
|
|
195
|
+
export interface ItemRuleEvaluationResult {
|
|
196
|
+
/** 所有数量校验结果 */
|
|
197
|
+
quantityChecks: QuantityCheckResult[];
|
|
198
|
+
/** 需要预填的商品列表 */
|
|
199
|
+
prefillItems: PrefillItemResult[];
|
|
200
|
+
/** 所有校验是否全部通过 */
|
|
201
|
+
allPassed: boolean;
|
|
202
|
+
/** 未通过的校验列表 */
|
|
203
|
+
failedChecks: QuantityCheckResult[];
|
|
204
|
+
/** 原始策略评估结果列表 */
|
|
205
|
+
rawResults: EvaluationResult[];
|
|
206
|
+
}
|
|
@@ -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
|
+
*/
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// 导出评估器
|
|
2
|
-
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
-
|
|
4
|
-
// 导出适配器
|
|
5
|
-
export { PromotionAdapter } from "./adapter";
|
|
6
|
-
export { default } from "./adapter";
|
|
7
|
-
|
|
8
|
-
// 导出策略配置示例常量
|
|
9
|
-
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
|
|
@@ -980,7 +980,7 @@ export var getProductDiscountDifference = function getProductDiscountDifference(
|
|
|
980
980
|
* @returns 商品单价
|
|
981
981
|
*/
|
|
982
982
|
export var getMainProductPrice = function getMainProductPrice(product, isDeductTaxAndFee) {
|
|
983
|
-
var _product$metadata4, _product$metadata5, _product$metadata6, _product$metadata7;
|
|
983
|
+
var _product$metadata4, _product$metadata5, _product$metadata6, _product$metadata7, _product$metadata8;
|
|
984
984
|
var mainProductPrice = new Decimal((product === null || product === void 0 ? void 0 : product.main_product_selling_price) || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.main_product_selling_price) || 0);
|
|
985
985
|
var _iterator6 = _createForOfIteratorHelper((product === null || product === void 0 ? void 0 : product.product_bundle) || []),
|
|
986
986
|
_step6;
|
|
@@ -1007,7 +1007,7 @@ export var getMainProductPrice = function getMainProductPrice(product, isDeductT
|
|
|
1007
1007
|
|
|
1008
1008
|
// 税费
|
|
1009
1009
|
// 附加费
|
|
1010
|
-
var surchargeFee = new Decimal((product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.main_product_attached_bundle_surcharge_fee) || 0);
|
|
1010
|
+
var surchargeFee = new Decimal((product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.main_product_attached_bundle_surcharge_fee) || 0).add((product === null || product === void 0 || (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.surcharge_rounding_remainder) || 0);
|
|
1011
1011
|
|
|
1012
1012
|
// 税费附加费总额
|
|
1013
1013
|
var taxAndFeeTotal = taxFee.add(surchargeFee);
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
checkAvailability(scheduleModule?: ScheduleModule): OpenDataAvailabilityResult;
|
|
22
|
+
storeChange(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
9
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
10
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
12
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
13
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
15
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
+
import { BaseModule } from "../BaseModule";
|
|
19
|
+
import { computeAvailability } from "./utils";
|
|
20
|
+
export * from "./types";
|
|
21
|
+
export { computeAvailability } from "./utils";
|
|
22
|
+
export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
23
|
+
_inherits(OpenDataModule, _BaseModule);
|
|
24
|
+
var _super = _createSuper(OpenDataModule);
|
|
25
|
+
function OpenDataModule(name, version) {
|
|
26
|
+
var _this;
|
|
27
|
+
_classCallCheck(this, OpenDataModule);
|
|
28
|
+
_this = _super.call(this, name, version);
|
|
29
|
+
_defineProperty(_assertThisInitialized(_this), "defaultName", 'openData');
|
|
30
|
+
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
31
|
+
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "openCache", false);
|
|
36
|
+
_defineProperty(_assertThisInitialized(_this), "fatherModule", void 0);
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
38
|
+
return _this;
|
|
39
|
+
}
|
|
40
|
+
_createClass(OpenDataModule, [{
|
|
41
|
+
key: "initialize",
|
|
42
|
+
value: function () {
|
|
43
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
44
|
+
var _options$initialState, _options$initialState2, _options$initialState3, _options$initialState4;
|
|
45
|
+
var _this$otherParams$ope;
|
|
46
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
47
|
+
while (1) switch (_context.prev = _context.next) {
|
|
48
|
+
case 0:
|
|
49
|
+
this.core = core;
|
|
50
|
+
this.store = options.store;
|
|
51
|
+
this.store.data = (_options$initialState = (_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.data) !== null && _options$initialState !== void 0 ? _options$initialState : null;
|
|
52
|
+
this.store.lastFetchedAt = (_options$initialState3 = (_options$initialState4 = options.initialState) === null || _options$initialState4 === void 0 ? void 0 : _options$initialState4.lastFetchedAt) !== null && _options$initialState3 !== void 0 ? _options$initialState3 : null;
|
|
53
|
+
this.otherParams = options.otherParams || {};
|
|
54
|
+
if (this.otherParams.cacheId) {
|
|
55
|
+
this.openCache = (_this$otherParams$ope = this.otherParams.openCache) !== null && _this$otherParams$ope !== void 0 ? _this$otherParams$ope : false;
|
|
56
|
+
this.cacheId = this.otherParams.cacheId;
|
|
57
|
+
}
|
|
58
|
+
if (this.otherParams.fatherModule) {
|
|
59
|
+
this.fatherModule = this.otherParams.fatherModule;
|
|
60
|
+
}
|
|
61
|
+
this.request = core.getPlugin('request');
|
|
62
|
+
this.window = core.getPlugin('window');
|
|
63
|
+
if (this.request) {
|
|
64
|
+
_context.next = 11;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
throw new Error('OpenDataModule 需要 request 插件支持');
|
|
68
|
+
case 11:
|
|
69
|
+
if (this.window) {
|
|
70
|
+
_context.next = 13;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
throw new Error('OpenDataModule 需要 window 插件支持');
|
|
74
|
+
case 13:
|
|
75
|
+
console.log('[OpenDataModule] 初始化完成');
|
|
76
|
+
case 14:
|
|
77
|
+
case "end":
|
|
78
|
+
return _context.stop();
|
|
79
|
+
}
|
|
80
|
+
}, _callee, this);
|
|
81
|
+
}));
|
|
82
|
+
function initialize(_x, _x2) {
|
|
83
|
+
return _initialize.apply(this, arguments);
|
|
84
|
+
}
|
|
85
|
+
return initialize;
|
|
86
|
+
}()
|
|
87
|
+
}, {
|
|
88
|
+
key: "fetchOpenData",
|
|
89
|
+
value: function () {
|
|
90
|
+
var _fetchOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
91
|
+
var _this$otherParams, _this$otherParams$get, _this$otherParams2, _this$otherParams2$ge;
|
|
92
|
+
var shopId, tenantId, headers, response, data;
|
|
93
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
94
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
shopId = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 || (_this$otherParams$get = _this$otherParams.getStateData) === null || _this$otherParams$get === void 0 ? void 0 : _this$otherParams$get.call(_this$otherParams, 'shop_id');
|
|
97
|
+
if (shopId) {
|
|
98
|
+
_context2.next = 3;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
throw new Error('[OpenDataModule] 无法获取 shop_id');
|
|
102
|
+
case 3:
|
|
103
|
+
tenantId = (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 || (_this$otherParams2$ge = _this$otherParams2.getStateData) === null || _this$otherParams2$ge === void 0 ? void 0 : _this$otherParams2$ge.call(_this$otherParams2, 'tenant_id');
|
|
104
|
+
headers = {};
|
|
105
|
+
if (tenantId) headers['Tenant-Id'] = String(tenantId);
|
|
106
|
+
_context2.next = 8;
|
|
107
|
+
return this.request.post("/open/my-pisell/".concat(shopId, "/setting"), {
|
|
108
|
+
scope: params.scope,
|
|
109
|
+
target: params.target,
|
|
110
|
+
section_code: params.section_code
|
|
111
|
+
}, {
|
|
112
|
+
pisell2: true,
|
|
113
|
+
headers: headers
|
|
114
|
+
});
|
|
115
|
+
case 8:
|
|
116
|
+
response = _context2.sent;
|
|
117
|
+
if (!((response === null || response === void 0 ? void 0 : response.status) === false)) {
|
|
118
|
+
_context2.next = 11;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
throw new Error((response === null || response === void 0 ? void 0 : response.message) || '获取 OpenData 配置失败');
|
|
122
|
+
case 11:
|
|
123
|
+
data = (response === null || response === void 0 ? void 0 : response.data) || {};
|
|
124
|
+
this.store.data = data;
|
|
125
|
+
this.store.lastFetchedAt = Date.now();
|
|
126
|
+
return _context2.abrupt("return", data);
|
|
127
|
+
case 15:
|
|
128
|
+
case "end":
|
|
129
|
+
return _context2.stop();
|
|
130
|
+
}
|
|
131
|
+
}, _callee2, this);
|
|
132
|
+
}));
|
|
133
|
+
function fetchOpenData(_x3) {
|
|
134
|
+
return _fetchOpenData.apply(this, arguments);
|
|
135
|
+
}
|
|
136
|
+
return fetchOpenData;
|
|
137
|
+
}()
|
|
138
|
+
}, {
|
|
139
|
+
key: "getOpenData",
|
|
140
|
+
value: function getOpenData() {
|
|
141
|
+
return this.store.data;
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
key: "checkAvailability",
|
|
145
|
+
value: function checkAvailability(scheduleModule) {
|
|
146
|
+
var _this$store$data;
|
|
147
|
+
var scheduleList = scheduleModule ? scheduleModule.getScheduleListByIds(((_this$store$data = this.store.data) === null || _this$store$data === void 0 ? void 0 : _this$store$data['availability.operating_hours']) || []) : undefined;
|
|
148
|
+
return computeAvailability({
|
|
149
|
+
config: this.store.data,
|
|
150
|
+
scheduleList: scheduleList
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "storeChange",
|
|
155
|
+
value: function storeChange() {
|
|
156
|
+
if (this.openCache) {
|
|
157
|
+
this.checkSaveCache({
|
|
158
|
+
cacheId: this.cacheId,
|
|
159
|
+
fatherModule: this.fatherModule,
|
|
160
|
+
store: this.store,
|
|
161
|
+
cacheKey: ['data', 'lastFetchedAt']
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}]);
|
|
166
|
+
return OpenDataModule;
|
|
167
|
+
}(BaseModule);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { ScheduleItem } from '../Schedule/types';
|
|
2
|
+
export interface MultiLangObject {
|
|
3
|
+
en?: string;
|
|
4
|
+
ja?: string;
|
|
5
|
+
pt?: string;
|
|
6
|
+
'zh-CN'?: string;
|
|
7
|
+
'zh-HK'?: string;
|
|
8
|
+
original?: string;
|
|
9
|
+
[key: string]: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface OpenDataConfig {
|
|
12
|
+
'basic.enable'?: boolean;
|
|
13
|
+
'basic.code'?: string | null;
|
|
14
|
+
'basic.name'?: string | MultiLangObject;
|
|
15
|
+
'basic.unavailable_message'?: string | MultiLangObject;
|
|
16
|
+
'availability.paused'?: boolean;
|
|
17
|
+
'availability.pause_message'?: string | MultiLangObject;
|
|
18
|
+
'availability.pause_behavior'?: string;
|
|
19
|
+
'availability.closed_behavior'?: string;
|
|
20
|
+
'availability.closed_message'?: string | MultiLangObject;
|
|
21
|
+
'availability.operating_hours'?: number[];
|
|
22
|
+
'reservation.enable'?: boolean;
|
|
23
|
+
'reservation.auto_confirm'?: boolean;
|
|
24
|
+
'reservation.auto_confirm_mode'?: string;
|
|
25
|
+
'reservation.auto_confirm_delay_seconds'?: number;
|
|
26
|
+
'sale.allow_item_notes'?: boolean;
|
|
27
|
+
'sale.allow_order_notes'?: boolean;
|
|
28
|
+
'sale.enable_item_rules'?: boolean;
|
|
29
|
+
'sale.enable_short_number'?: boolean;
|
|
30
|
+
'sale.short_number_daily_reset'?: boolean;
|
|
31
|
+
'sale.short_number_start_number'?: number;
|
|
32
|
+
'sale.short_number_prefix'?: string | null;
|
|
33
|
+
'sale.sale_number_prefix'?: string | null;
|
|
34
|
+
'sale.enabled_item_rules'?: number[];
|
|
35
|
+
'fulfillment.enable_pickup'?: boolean;
|
|
36
|
+
'fulfillment.overdue_reminder'?: boolean;
|
|
37
|
+
'fulfillment.manual_input_type'?: string;
|
|
38
|
+
'fulfillment.enable_auto_complete'?: boolean;
|
|
39
|
+
'fulfillment.enable_table_service'?: boolean;
|
|
40
|
+
'fulfillment.fulfillment_ref_mode'?: string;
|
|
41
|
+
'fulfillment.advance_warning_minutes'?: number;
|
|
42
|
+
'fulfillment.update_end_time_on_auto_complete'?: string;
|
|
43
|
+
'menu.associated_menus'?: Array<{
|
|
44
|
+
label: string;
|
|
45
|
+
value: number;
|
|
46
|
+
}>;
|
|
47
|
+
[key: string]: any;
|
|
48
|
+
}
|
|
49
|
+
export interface OpenDataState {
|
|
50
|
+
data: OpenDataConfig | null;
|
|
51
|
+
lastFetchedAt: number | null;
|
|
52
|
+
}
|
|
53
|
+
export interface OpenDataFetchParams {
|
|
54
|
+
scope: string;
|
|
55
|
+
target: string;
|
|
56
|
+
section_code: string[];
|
|
57
|
+
}
|
|
58
|
+
export interface OpenDataApiResponse {
|
|
59
|
+
status: boolean;
|
|
60
|
+
code: number;
|
|
61
|
+
message: string;
|
|
62
|
+
data: OpenDataConfig;
|
|
63
|
+
}
|
|
64
|
+
export type OpenDataUnavailableReason = 'shop_disabled' | 'paused' | 'closed' | 'reservation_disabled';
|
|
65
|
+
export interface OpenDataAvailabilityResult {
|
|
66
|
+
available: boolean;
|
|
67
|
+
reason: OpenDataUnavailableReason | null;
|
|
68
|
+
message: string | MultiLangObject | null;
|
|
69
|
+
}
|
|
70
|
+
export interface ComputeAvailabilityParams {
|
|
71
|
+
config: OpenDataConfig | null;
|
|
72
|
+
scheduleList?: ScheduleItem[];
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|