@pisell/pisellos 2.2.291 → 2.2.293
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/core/index.d.ts +7 -0
- package/dist/core/index.js +108 -65
- package/dist/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/dist/model/strategy/adapter/itemRule/adapter.js +135 -35
- package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/dist/model/strategy/adapter/itemRule/evaluator.js +25 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/dist/model/strategy/adapter/itemRule/type.js +19 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/BookingContext/index.d.ts +3 -0
- package/dist/modules/BookingContext/index.js +42 -13
- package/dist/modules/BookingContext/types.d.ts +4 -4
- package/dist/modules/BookingContext/types.js +3 -3
- package/dist/modules/OpenData/types.d.ts +1 -0
- package/dist/modules/Order/index.d.ts +18 -3
- package/dist/modules/Order/index.js +885 -485
- package/dist/modules/Order/salesNotes.d.ts +31 -0
- package/dist/modules/Order/salesNotes.js +492 -0
- package/dist/modules/Order/types.d.ts +93 -5
- package/dist/modules/Order/types.js +5 -0
- package/dist/modules/Order/utils.d.ts +12 -0
- package/dist/modules/Order/utils.js +96 -31
- package/dist/modules/Product/types.d.ts +2 -0
- package/dist/modules/ProductList/clientDataVariants.d.ts +50 -0
- package/dist/modules/ProductList/clientDataVariants.js +216 -0
- package/dist/modules/ProductList/index.d.ts +18 -3
- package/dist/modules/ProductList/index.js +220 -38
- package/dist/modules/ProductList/types.d.ts +10 -0
- package/dist/modules/Quotation/index.d.ts +22 -0
- package/dist/modules/Quotation/index.js +293 -28
- package/dist/modules/ResourcePlanner/index.d.ts +0 -22
- package/dist/modules/ResourcePlanner/index.js +1 -180
- package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/dist/modules/ResourcePlanner/localClock.js +183 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +5 -14
- package/dist/modules/ResourcePlanner/planner.js +2111 -958
- package/dist/modules/ResourcePlanner/types.d.ts +359 -187
- package/dist/modules/ResourcePlanner/types.js +33 -1
- package/dist/plugins/request.d.ts +1 -0
- package/dist/server/index.d.ts +17 -2
- package/dist/server/index.js +1134 -932
- package/dist/server/modules/floor-plan/index.d.ts +4 -0
- package/dist/server/modules/floor-plan/index.js +240 -98
- package/dist/server/modules/menu/index.js +48 -23
- package/dist/server/modules/order/index.d.ts +17 -7
- package/dist/server/modules/order/index.js +419 -207
- package/dist/server/modules/products/index.d.ts +10 -4
- package/dist/server/modules/products/index.js +177 -84
- package/dist/server/modules/resource/index.js +21 -13
- package/dist/server/utils/product.d.ts +1 -1
- package/dist/server/utils/product.js +186 -22
- package/dist/server/utils/small-ticket.d.ts +9 -1
- package/dist/server/utils/small-ticket.js +131 -84
- package/dist/solution/BaseSales/index.d.ts +26 -3
- package/dist/solution/BaseSales/index.js +1384 -905
- package/dist/solution/BaseSales/types.d.ts +2 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +10 -3
- package/dist/solution/BaseSales/utils.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +4 -4
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +4 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -3
- package/dist/solution/BookingTicket/utils/orderCustomer.js +3 -2
- package/dist/solution/RegisterAndLogin/config.d.ts +9 -3
- package/dist/solution/RegisterAndLogin/config.js +95 -40
- package/dist/solution/RegisterAndLogin/index.js +4 -1
- package/dist/solution/ScanOrder/index.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +31 -27
- package/dist/solution/ScanOrder/types.d.ts +2 -0
- package/dist/solution/ScanOrder/utils.d.ts +1 -0
- package/dist/solution/ScanOrder/utils.js +8 -3
- package/dist/solution/UnifiedBookingSales/index.d.ts +128 -74
- package/dist/solution/UnifiedBookingSales/index.js +3877 -963
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +430 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +161 -77
- package/dist/solution/UnifiedBookingSales/types.js +4 -9
- package/dist/solution/VenueBooking/index.d.ts +3 -0
- package/dist/solution/VenueBooking/index.js +549 -497
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +3 -1
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
- package/dist/solution/VenueBooking/utils/slotMerge.js +3 -1
- package/dist/utils/platform.d.ts +8 -0
- package/dist/utils/platform.js +15 -0
- package/lib/core/index.d.ts +7 -0
- package/lib/core/index.js +20 -2
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +4 -1
- package/lib/model/strategy/adapter/itemRule/adapter.js +73 -4
- package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +8 -1
- package/lib/model/strategy/adapter/itemRule/evaluator.js +23 -1
- package/lib/model/strategy/adapter/itemRule/type.d.ts +44 -0
- package/lib/model/strategy/adapter/itemRule/type.js +19 -1
- package/lib/modules/BookingContext/index.d.ts +3 -0
- package/lib/modules/BookingContext/index.js +35 -8
- package/lib/modules/BookingContext/types.d.ts +4 -4
- package/lib/modules/BookingContext/types.js +3 -3
- package/lib/modules/OpenData/types.d.ts +1 -0
- package/lib/modules/Order/index.d.ts +18 -3
- package/lib/modules/Order/index.js +325 -28
- package/lib/modules/Order/salesNotes.d.ts +31 -0
- package/lib/modules/Order/salesNotes.js +382 -0
- package/lib/modules/Order/types.d.ts +93 -5
- package/lib/modules/Order/types.js +4 -0
- package/lib/modules/Order/utils.d.ts +12 -0
- package/lib/modules/Order/utils.js +85 -16
- package/lib/modules/Product/types.d.ts +2 -0
- package/lib/modules/ProductList/clientDataVariants.d.ts +50 -0
- package/lib/modules/ProductList/clientDataVariants.js +204 -0
- package/lib/modules/ProductList/index.d.ts +18 -3
- package/lib/modules/ProductList/index.js +137 -8
- package/lib/modules/ProductList/types.d.ts +10 -0
- package/lib/modules/Quotation/index.d.ts +22 -0
- package/lib/modules/Quotation/index.js +158 -11
- package/lib/modules/ResourcePlanner/index.d.ts +0 -22
- package/lib/modules/ResourcePlanner/index.js +9 -129
- package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/lib/modules/ResourcePlanner/localClock.js +205 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +5 -14
- package/lib/modules/ResourcePlanner/planner.js +1807 -783
- package/lib/modules/ResourcePlanner/types.d.ts +359 -187
- package/lib/modules/ResourcePlanner/types.js +13 -1
- package/lib/plugins/request.d.ts +1 -0
- package/lib/server/index.d.ts +17 -2
- package/lib/server/index.js +149 -21
- package/lib/server/modules/floor-plan/index.d.ts +4 -0
- package/lib/server/modules/floor-plan/index.js +60 -7
- package/lib/server/modules/menu/index.js +26 -4
- package/lib/server/modules/order/index.d.ts +17 -7
- package/lib/server/modules/order/index.js +194 -57
- package/lib/server/modules/products/index.d.ts +10 -4
- package/lib/server/modules/products/index.js +93 -23
- package/lib/server/modules/resource/index.js +12 -2
- package/lib/server/utils/product.d.ts +1 -1
- package/lib/server/utils/product.js +163 -3
- package/lib/server/utils/small-ticket.d.ts +9 -1
- package/lib/server/utils/small-ticket.js +123 -79
- package/lib/solution/BaseSales/index.d.ts +26 -3
- package/lib/solution/BaseSales/index.js +396 -70
- package/lib/solution/BaseSales/types.d.ts +2 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +3 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +9 -2
- package/lib/solution/BaseSales/utils.js +3 -0
- package/lib/solution/BookingByStep/index.d.ts +4 -4
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +5 -2
- package/lib/solution/BookingTicket/utils/orderCustomer.js +2 -1
- package/lib/solution/RegisterAndLogin/config.d.ts +9 -3
- package/lib/solution/RegisterAndLogin/config.js +49 -8
- package/lib/solution/RegisterAndLogin/index.js +4 -1
- package/lib/solution/ScanOrder/index.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +5 -1
- package/lib/solution/ScanOrder/types.d.ts +2 -0
- package/lib/solution/ScanOrder/utils.d.ts +1 -0
- package/lib/solution/ScanOrder/utils.js +4 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +128 -74
- package/lib/solution/UnifiedBookingSales/index.js +2592 -424
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +316 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +161 -77
- package/lib/solution/UnifiedBookingSales/types.js +4 -6
- package/lib/solution/VenueBooking/index.d.ts +3 -0
- package/lib/solution/VenueBooking/index.js +33 -9
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +3 -1
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +2 -0
- package/lib/solution/VenueBooking/utils/slotMerge.js +3 -1
- package/lib/utils/platform.d.ts +8 -0
- package/lib/utils/platform.js +22 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StrategyConfig } from '../../type';
|
|
2
|
-
import { type ItemRuleBusinessData, type ItemRuleEvaluationResult, type QuantityCheckResult, type QuantityLimitResult, type PrefillItemResult } from './type';
|
|
2
|
+
import { type ItemRuleBusinessData, type ItemRuleEvaluationResult, type QuantityCheckResult, type QuantityLimitResult, type PrefillItemResult, type AllergyRequirement } from './type';
|
|
3
3
|
/**
|
|
4
4
|
* ItemRule 评估器
|
|
5
5
|
*
|
|
@@ -21,6 +21,13 @@ export declare class ItemRuleEvaluator {
|
|
|
21
21
|
* 完整评估:数量校验 + 预填购物车
|
|
22
22
|
*/
|
|
23
23
|
evaluate(businessData: ItemRuleBusinessData): ItemRuleEvaluationResult;
|
|
24
|
+
/**
|
|
25
|
+
* 获取当前商品优先级最高的过敏门禁要求。
|
|
26
|
+
*
|
|
27
|
+
* 不同商品或不同 Action 的数据源不会合并;相同优先级按
|
|
28
|
+
* strategyId + ruleId 稳定排序,保证多次评估结果一致。
|
|
29
|
+
*/
|
|
30
|
+
getAllergyRequirement(businessData: ItemRuleBusinessData): AllergyRequirement | null;
|
|
24
31
|
/**
|
|
25
32
|
* 获取当前配置中各商品的数量限制
|
|
26
33
|
*
|
|
@@ -63,6 +63,7 @@ export var ItemRuleEvaluator = /*#__PURE__*/function () {
|
|
|
63
63
|
}) : this.strategyConfigs;
|
|
64
64
|
var allQuantityChecks = [];
|
|
65
65
|
var allPrefillItems = [];
|
|
66
|
+
var allAllergyRequirements = [];
|
|
66
67
|
var rawResults = [];
|
|
67
68
|
var context = this.adapter.prepareContext(businessData);
|
|
68
69
|
var _iterator = _createForOfIteratorHelper(configs),
|
|
@@ -74,9 +75,11 @@ export var ItemRuleEvaluator = /*#__PURE__*/function () {
|
|
|
74
75
|
rawResults.push(evalResult);
|
|
75
76
|
var _this$adapter$transfo = this.adapter.transformResult(evalResult, businessData),
|
|
76
77
|
quantityChecks = _this$adapter$transfo.quantityChecks,
|
|
77
|
-
prefillItems = _this$adapter$transfo.prefillItems
|
|
78
|
+
prefillItems = _this$adapter$transfo.prefillItems,
|
|
79
|
+
allergyRequirements = _this$adapter$transfo.allergyRequirements;
|
|
78
80
|
allQuantityChecks.push.apply(allQuantityChecks, _toConsumableArray(quantityChecks));
|
|
79
81
|
allPrefillItems.push.apply(allPrefillItems, _toConsumableArray(prefillItems));
|
|
82
|
+
allAllergyRequirements.push.apply(allAllergyRequirements, _toConsumableArray(allergyRequirements));
|
|
80
83
|
}
|
|
81
84
|
} catch (err) {
|
|
82
85
|
_iterator.e(err);
|
|
@@ -89,12 +92,33 @@ export var ItemRuleEvaluator = /*#__PURE__*/function () {
|
|
|
89
92
|
return {
|
|
90
93
|
quantityChecks: allQuantityChecks,
|
|
91
94
|
prefillItems: allPrefillItems,
|
|
95
|
+
allergyRequirements: allAllergyRequirements,
|
|
92
96
|
allPassed: failedChecks.length === 0,
|
|
93
97
|
failedChecks: failedChecks,
|
|
94
98
|
rawResults: rawResults
|
|
95
99
|
};
|
|
96
100
|
}
|
|
97
101
|
|
|
102
|
+
/**
|
|
103
|
+
* 获取当前商品优先级最高的过敏门禁要求。
|
|
104
|
+
*
|
|
105
|
+
* 不同商品或不同 Action 的数据源不会合并;相同优先级按
|
|
106
|
+
* strategyId + ruleId 稳定排序,保证多次评估结果一致。
|
|
107
|
+
*/
|
|
108
|
+
}, {
|
|
109
|
+
key: "getAllergyRequirement",
|
|
110
|
+
value: function getAllergyRequirement(businessData) {
|
|
111
|
+
var requirements = this.evaluate(businessData).allergyRequirements;
|
|
112
|
+
if (!requirements.length) return null;
|
|
113
|
+
return _toConsumableArray(requirements).sort(function (left, right) {
|
|
114
|
+
var priorityDiff = right.priority - left.priority;
|
|
115
|
+
if (priorityDiff !== 0) return priorityDiff;
|
|
116
|
+
var strategyDiff = left.strategyId.localeCompare(right.strategyId);
|
|
117
|
+
if (strategyDiff !== 0) return strategyDiff;
|
|
118
|
+
return left.ruleId.localeCompare(right.ruleId);
|
|
119
|
+
})[0];
|
|
120
|
+
}
|
|
121
|
+
|
|
98
122
|
/**
|
|
99
123
|
* 获取当前配置中各商品的数量限制
|
|
100
124
|
*
|
|
@@ -4,6 +4,8 @@ export declare const ITEM_RULE_ACTION_TYPES: {
|
|
|
4
4
|
readonly QUANTITY_CHECK: "QUANTITY_CHECK";
|
|
5
5
|
/** 预填购物车 */
|
|
6
6
|
readonly PREFILL_CART: "PREFILL_CART";
|
|
7
|
+
/** 加购前过敏信息确认 */
|
|
8
|
+
readonly ALLERGY_CHECK: "ALLERGY_CHECK";
|
|
7
9
|
};
|
|
8
10
|
export type ItemRuleActionType = (typeof ITEM_RULE_ACTION_TYPES)[keyof typeof ITEM_RULE_ACTION_TYPES];
|
|
9
11
|
export declare const ITEM_RULE_TEMPLATES: {
|
|
@@ -63,6 +65,42 @@ export interface TargetItem {
|
|
|
63
65
|
/** 变体 ID */
|
|
64
66
|
product_variant_id?: number;
|
|
65
67
|
}
|
|
68
|
+
/** 策略展示文案,可由调用方按当前 locale 解析。 */
|
|
69
|
+
export type ItemRuleLocalizedText = string | Record<string, string>;
|
|
70
|
+
/** 内联过敏源选项。稳定 id 用于保存选择,label 只负责展示。 */
|
|
71
|
+
export interface AllergyDataSourceItem {
|
|
72
|
+
id: string;
|
|
73
|
+
label: ItemRuleLocalizedText;
|
|
74
|
+
}
|
|
75
|
+
/** 当前仅支持随策略下发的内联过敏源。 */
|
|
76
|
+
export interface AllergyDataSource {
|
|
77
|
+
type: 'inline';
|
|
78
|
+
items: AllergyDataSourceItem[];
|
|
79
|
+
}
|
|
80
|
+
/** 每个目标商品独立持有自己的过敏源,禁止跨商品合并。 */
|
|
81
|
+
export interface AllergyTargetItem extends TargetItem {
|
|
82
|
+
dataSource: AllergyDataSource;
|
|
83
|
+
}
|
|
84
|
+
export type AllergyPromptScope = 'once_per_order_product';
|
|
85
|
+
/** ALLERGY_CHECK Action 的商品级配置。 */
|
|
86
|
+
export interface AllergyCheckConfig {
|
|
87
|
+
targetType: 'product';
|
|
88
|
+
targets: AllergyTargetItem[];
|
|
89
|
+
promptScope: AllergyPromptScope;
|
|
90
|
+
allowNote?: boolean;
|
|
91
|
+
}
|
|
92
|
+
/** 当前商品命中的单条过敏门禁要求。 */
|
|
93
|
+
export interface AllergyRequirement {
|
|
94
|
+
strategyId: string;
|
|
95
|
+
ruleId: string;
|
|
96
|
+
priority: number;
|
|
97
|
+
targetType: 'product';
|
|
98
|
+
product_id: number;
|
|
99
|
+
product_variant_id?: number;
|
|
100
|
+
dataSource: AllergyDataSource;
|
|
101
|
+
promptScope: AllergyPromptScope;
|
|
102
|
+
allowNote: boolean;
|
|
103
|
+
}
|
|
66
104
|
/**
|
|
67
105
|
* 预填商品项
|
|
68
106
|
*/
|
|
@@ -119,6 +157,10 @@ export interface ItemRuleBusinessData {
|
|
|
119
157
|
historicalItems?: CartItemSummary[];
|
|
120
158
|
/** 服务类型(如 'dine-in', 'takeaway') */
|
|
121
159
|
serviceType?: string;
|
|
160
|
+
/** 当前业务渠道(如 'kiosk', 'pos', 'online_store') */
|
|
161
|
+
channel?: string;
|
|
162
|
+
/** 当前正在加入购物车的商品;ALLERGY_CHECK 只读取该商品的 Target。 */
|
|
163
|
+
currentProduct?: Pick<TargetItem, 'product_id' | 'product_variant_id'>;
|
|
122
164
|
/** 当前提交次数(0=首次提交, >0=追加提交) */
|
|
123
165
|
submissionIndex?: number;
|
|
124
166
|
/** 策略配置列表(可选,如果不传则使用 setStrategyConfigs 设置的) */
|
|
@@ -216,6 +258,8 @@ export interface ItemRuleEvaluationResult {
|
|
|
216
258
|
quantityChecks: QuantityCheckResult[];
|
|
217
259
|
/** 需要预填的商品列表 */
|
|
218
260
|
prefillItems: PrefillItemResult[];
|
|
261
|
+
/** 当前商品命中的过敏门禁要求;不同 Action/商品不会合并。 */
|
|
262
|
+
allergyRequirements: AllergyRequirement[];
|
|
219
263
|
/** 所有校验是否全部通过 */
|
|
220
264
|
allPassed: boolean;
|
|
221
265
|
/** 未通过的校验列表 */
|
|
@@ -6,7 +6,9 @@ export var ITEM_RULE_ACTION_TYPES = {
|
|
|
6
6
|
/** 数量校验 */
|
|
7
7
|
QUANTITY_CHECK: 'QUANTITY_CHECK',
|
|
8
8
|
/** 预填购物车 */
|
|
9
|
-
PREFILL_CART: 'PREFILL_CART'
|
|
9
|
+
PREFILL_CART: 'PREFILL_CART',
|
|
10
|
+
/** 加购前过敏信息确认 */
|
|
11
|
+
ALLERGY_CHECK: 'ALLERGY_CHECK'
|
|
10
12
|
};
|
|
11
13
|
// ============================================
|
|
12
14
|
// Rule Template 类型(创建规则时的起始模板)
|
|
@@ -50,6 +52,22 @@ export var ITEM_RULE_TEMPLATES = {
|
|
|
50
52
|
|
|
51
53
|
/** 目标项 */
|
|
52
54
|
|
|
55
|
+
// ============================================
|
|
56
|
+
// Allergy Check 相关类型
|
|
57
|
+
// ============================================
|
|
58
|
+
|
|
59
|
+
/** 策略展示文案,可由调用方按当前 locale 解析。 */
|
|
60
|
+
|
|
61
|
+
/** 内联过敏源选项。稳定 id 用于保存选择,label 只负责展示。 */
|
|
62
|
+
|
|
63
|
+
/** 当前仅支持随策略下发的内联过敏源。 */
|
|
64
|
+
|
|
65
|
+
/** 每个目标商品独立持有自己的过敏源,禁止跨商品合并。 */
|
|
66
|
+
|
|
67
|
+
/** ALLERGY_CHECK Action 的商品级配置。 */
|
|
68
|
+
|
|
69
|
+
/** 当前商品命中的单条过敏门禁要求。 */
|
|
70
|
+
|
|
53
71
|
// ============================================
|
|
54
72
|
// Prefill Cart 相关类型
|
|
55
73
|
// ============================================
|
|
@@ -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, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -19,12 +19,15 @@ export declare class BookingContextModule extends BaseModule implements Module,
|
|
|
19
19
|
protected defaultVersion: string;
|
|
20
20
|
private request;
|
|
21
21
|
private store;
|
|
22
|
+
private otherParams;
|
|
22
23
|
/** 上次成功 loadBookingConfig 的 query key;命中则不再请求。 */
|
|
23
24
|
private lastConfigQueryKey;
|
|
24
25
|
/** 上次成功 loadResources 的 query key(date|bookingIds);命中则不再请求。 */
|
|
25
26
|
private lastResourcesQueryKey;
|
|
26
27
|
constructor(name?: string, version?: string);
|
|
27
28
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
29
|
+
/** 同步父级解决方案的运行态参数;platform 变化后会自然切换 config endpoint/cache key。 */
|
|
30
|
+
updateOtherParams(params: Record<string, any>): void;
|
|
28
31
|
loadBookingConfig(params?: LoadBookingConfigParams, options?: {
|
|
29
32
|
forceRefresh?: boolean;
|
|
30
33
|
}): Promise<BookingContextConfig | null>;
|
|
@@ -26,6 +26,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
26
26
|
import dayjs from 'dayjs';
|
|
27
27
|
import { BaseModule } from "../BaseModule";
|
|
28
28
|
import { RequestModeENUM } from "../../plugins/request";
|
|
29
|
+
import { normalizeRuntimePlatform } from "../../utils/platform";
|
|
29
30
|
import { BookingContextEvent } from "./types";
|
|
30
31
|
import { formatResourceListAndMap } from "./utils/formatResourceList";
|
|
31
32
|
export * from "./types";
|
|
@@ -40,6 +41,8 @@ var DEFAULT_BOOKING_CONFIG_PARAMS = {
|
|
|
40
41
|
item_type: 'appointment_booking',
|
|
41
42
|
sub_type: 'ticket'
|
|
42
43
|
};
|
|
44
|
+
var BOOKING_CONFIG_ENDPOINT = '/core/board/management/config';
|
|
45
|
+
var H5_BOOKING_CONFIG_ENDPOINT = '/core/board/config';
|
|
43
46
|
var BOARD_CONFIG_CACHE = {
|
|
44
47
|
useCache: true,
|
|
45
48
|
cache: {
|
|
@@ -153,6 +156,24 @@ export function buildBookingConfigQueryKey() {
|
|
|
153
156
|
});
|
|
154
157
|
return JSON.stringify(sorted);
|
|
155
158
|
}
|
|
159
|
+
function resolveBookingConfigRequest(platform) {
|
|
160
|
+
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
161
|
+
var isH5 = normalizeRuntimePlatform(platform) === 'h5';
|
|
162
|
+
var endpoint = isH5 ? H5_BOOKING_CONFIG_ENDPOINT : BOOKING_CONFIG_ENDPOINT;
|
|
163
|
+
var query = isH5 ? {
|
|
164
|
+
item_type: params.item_type || DEFAULT_BOOKING_CONFIG_PARAMS.item_type
|
|
165
|
+
} : _objectSpread(_objectSpread({}, DEFAULT_BOOKING_CONFIG_PARAMS), params);
|
|
166
|
+
var keys = Object.keys(query).sort();
|
|
167
|
+
var sortedQuery = {};
|
|
168
|
+
keys.forEach(function (key) {
|
|
169
|
+
sortedQuery[key] = query[key];
|
|
170
|
+
});
|
|
171
|
+
return {
|
|
172
|
+
endpoint: endpoint,
|
|
173
|
+
query: query,
|
|
174
|
+
key: "".concat(endpoint, ":").concat(JSON.stringify(sortedQuery))
|
|
175
|
+
};
|
|
176
|
+
}
|
|
156
177
|
|
|
157
178
|
/** 稳定序列化资源列表查询(date + bookingIds),用于跳过重复 loadResources。 */
|
|
158
179
|
export function buildBookingResourcesQueryKey() {
|
|
@@ -176,6 +197,7 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
176
197
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
177
198
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
178
199
|
_defineProperty(_assertThisInitialized(_this), "store", _objectSpread({}, EMPTY_STATE));
|
|
200
|
+
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
179
201
|
/** 上次成功 loadBookingConfig 的 query key;命中则不再请求。 */
|
|
180
202
|
_defineProperty(_assertThisInitialized(_this), "lastConfigQueryKey", null);
|
|
181
203
|
/** 上次成功 loadResources 的 query key(date|bookingIds);命中则不再请求。 */
|
|
@@ -201,6 +223,7 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
201
223
|
}
|
|
202
224
|
throw new Error('BookingContextModule 需要 request 插件支持');
|
|
203
225
|
case 5:
|
|
226
|
+
this.otherParams = options.otherParams || {};
|
|
204
227
|
this.store = {
|
|
205
228
|
bookingConfig: null,
|
|
206
229
|
resourcesOrigin: [],
|
|
@@ -218,7 +241,7 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
218
241
|
if (initialState.date) {
|
|
219
242
|
this.store.date = initialState.date;
|
|
220
243
|
}
|
|
221
|
-
case
|
|
244
|
+
case 11:
|
|
222
245
|
case "end":
|
|
223
246
|
return _context.stop();
|
|
224
247
|
}
|
|
@@ -228,16 +251,22 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
228
251
|
return _initialize.apply(this, arguments);
|
|
229
252
|
}
|
|
230
253
|
return initialize;
|
|
231
|
-
}()
|
|
254
|
+
}() /** 同步父级解决方案的运行态参数;platform 变化后会自然切换 config endpoint/cache key。 */
|
|
255
|
+
}, {
|
|
256
|
+
key: "updateOtherParams",
|
|
257
|
+
value: function updateOtherParams(params) {
|
|
258
|
+
this.otherParams = params || {};
|
|
259
|
+
}
|
|
232
260
|
}, {
|
|
233
261
|
key: "loadBookingConfig",
|
|
234
262
|
value: function () {
|
|
235
263
|
var _loadBookingConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
236
|
-
var
|
|
264
|
+
var _this$otherParams,
|
|
265
|
+
_this2 = this;
|
|
237
266
|
var params,
|
|
238
267
|
options,
|
|
268
|
+
requestConfig,
|
|
239
269
|
configKey,
|
|
240
|
-
query,
|
|
241
270
|
sharedKey,
|
|
242
271
|
_sharedBookingConfigC,
|
|
243
272
|
cached,
|
|
@@ -250,14 +279,14 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
250
279
|
case 0:
|
|
251
280
|
params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
|
|
252
281
|
options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
253
|
-
|
|
282
|
+
requestConfig = resolveBookingConfigRequest((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform, params);
|
|
283
|
+
configKey = requestConfig.key;
|
|
254
284
|
if (!(!options.forceRefresh && this.store.bookingConfig != null && this.lastConfigQueryKey === configKey)) {
|
|
255
|
-
_context3.next =
|
|
285
|
+
_context3.next = 6;
|
|
256
286
|
break;
|
|
257
287
|
}
|
|
258
288
|
return _context3.abrupt("return", this.store.bookingConfig);
|
|
259
|
-
case
|
|
260
|
-
query = _objectSpread(_objectSpread({}, DEFAULT_BOOKING_CONFIG_PARAMS), params);
|
|
289
|
+
case 6:
|
|
261
290
|
sharedKey = buildSharedCacheKey(this.request, configKey);
|
|
262
291
|
if (!(!options.forceRefresh && sharedBookingConfigCache.has(sharedKey))) {
|
|
263
292
|
_context3.next = 12;
|
|
@@ -277,7 +306,7 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
277
306
|
case 0:
|
|
278
307
|
_context2.prev = 0;
|
|
279
308
|
_context2.next = 3;
|
|
280
|
-
return _this2.request.get(
|
|
309
|
+
return _this2.request.get(requestConfig.endpoint, requestConfig.query, BOARD_CONFIG_CACHE);
|
|
281
310
|
case 3:
|
|
282
311
|
res = _context2.sent;
|
|
283
312
|
_config = (_res$data = res === null || res === void 0 ? void 0 : res.data) !== null && _res$data !== void 0 ? _res$data : null;
|
|
@@ -411,9 +440,9 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
411
440
|
}, {
|
|
412
441
|
key: "isBookingContextReady",
|
|
413
442
|
value: function isBookingContextReady() {
|
|
414
|
-
var _ref3, _params$date2;
|
|
443
|
+
var _this$otherParams2, _ref3, _params$date2;
|
|
415
444
|
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
416
|
-
var configKey =
|
|
445
|
+
var configKey = resolveBookingConfigRequest((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.platform, params.bookingConfigParams).key;
|
|
417
446
|
var dateInput = (_ref3 = (_params$date2 = params.date) !== null && _params$date2 !== void 0 ? _params$date2 : this.store.date) !== null && _ref3 !== void 0 ? _ref3 : dayjs();
|
|
418
447
|
var queryDate = toScheduleQueryDate(dateInput);
|
|
419
448
|
var resourcesKey = buildBookingResourcesQueryKey({
|
|
@@ -428,7 +457,7 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
428
457
|
key: "initBookingContext",
|
|
429
458
|
value: function () {
|
|
430
459
|
var _initBookingContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
431
|
-
var _ref4, _params$date3;
|
|
460
|
+
var _ref4, _params$date3, _this$otherParams3;
|
|
432
461
|
var params,
|
|
433
462
|
dateInput,
|
|
434
463
|
queryDate,
|
|
@@ -450,7 +479,7 @@ export var BookingContextModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
450
479
|
}
|
|
451
480
|
return _context6.abrupt("return", this.getState());
|
|
452
481
|
case 6:
|
|
453
|
-
configKey =
|
|
482
|
+
configKey = resolveBookingConfigRequest((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform, params.bookingConfigParams).key;
|
|
454
483
|
resourcesKey = buildBookingResourcesQueryKey({
|
|
455
484
|
date: queryDate,
|
|
456
485
|
bookingIds: params.bookingIds
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BookingContext 子模块:承载「预约 UI 上下文」三件套。
|
|
3
3
|
*
|
|
4
|
-
* - bookingConfig:来自 `/core/board/management/config` 的整套预约配置(service_time / resource_tab /
|
|
4
|
+
* - bookingConfig:来自 staff `/core/board/management/config` 或 H5 `/core/board/config` 的整套预约配置(service_time / resource_tab /
|
|
5
5
|
* appointment_subject / subject_require / stock_setting / basic / capacity 等)。
|
|
6
6
|
* - resourcesOrigin / resourcesOriginMap:来自 `/schedule/resource/list` 的资源全集,含 times / event_list /
|
|
7
7
|
* combined_resource 等运行态信息,是 getResourceByIds / getResourceTimeIsUsable 的输入。
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - 默认由 `loadBookingConfig` / `loadResources` 拉取并写入 store;也支持消费方 `set*` 直接灌入(复用 ticketBooking 已拉到的数据)。
|
|
12
12
|
* - 所有读 API 返回浅克隆(数组)或原引用(map / config),避免 UI 写穿。
|
|
13
13
|
*/
|
|
14
|
-
/** `loadBookingConfig`
|
|
14
|
+
/** `loadBookingConfig` 入参;H5 公共接口只消费 `item_type`。 */
|
|
15
15
|
export interface LoadBookingConfigParams {
|
|
16
16
|
item_type?: string;
|
|
17
17
|
sub_type?: string;
|
|
@@ -42,7 +42,7 @@ export interface InitBookingContextParams {
|
|
|
42
42
|
export type BookingContextResource = Record<string, any>;
|
|
43
43
|
export type BookingContextResourceMap = Record<string, BookingContextResource>;
|
|
44
44
|
/**
|
|
45
|
-
* 形参 booking_config(结构来自
|
|
45
|
+
* 形参 booking_config(结构来自 staff management 或 H5 board config 接口的 `data`)。
|
|
46
46
|
* OS 不强制 schema,保留 `Record<string, any>` 兼容现网;常用路径文档化在 SDK docs。
|
|
47
47
|
*/
|
|
48
48
|
export type BookingContextConfig = Record<string, any>;
|
|
@@ -80,7 +80,7 @@ export interface BookingContextModuleAPI {
|
|
|
80
80
|
getState(): BookingContextState;
|
|
81
81
|
/** 一键清空,destroy / 切租户场景用。 */
|
|
82
82
|
clear(): void;
|
|
83
|
-
/**
|
|
83
|
+
/** 按运行平台拉取 board config 并写入 store。 */
|
|
84
84
|
loadBookingConfig(params?: LoadBookingConfigParams): Promise<BookingContextConfig | null>;
|
|
85
85
|
/** 拉取资源全集并写入 store(`/schedule/resource/list`)。 */
|
|
86
86
|
loadResources(params?: LoadBookingResourcesParams): Promise<BookingContextResource[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* BookingContext 子模块:承载「预约 UI 上下文」三件套。
|
|
3
3
|
*
|
|
4
|
-
* - bookingConfig:来自 `/core/board/management/config` 的整套预约配置(service_time / resource_tab /
|
|
4
|
+
* - bookingConfig:来自 staff `/core/board/management/config` 或 H5 `/core/board/config` 的整套预约配置(service_time / resource_tab /
|
|
5
5
|
* appointment_subject / subject_require / stock_setting / basic / capacity 等)。
|
|
6
6
|
* - resourcesOrigin / resourcesOriginMap:来自 `/schedule/resource/list` 的资源全集,含 times / event_list /
|
|
7
7
|
* combined_resource 等运行态信息,是 getResourceByIds / getResourceTimeIsUsable 的输入。
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* - 所有读 API 返回浅克隆(数组)或原引用(map / config),避免 UI 写穿。
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
/** `loadBookingConfig`
|
|
15
|
+
/** `loadBookingConfig` 入参;H5 公共接口只消费 `item_type`。 */
|
|
16
16
|
|
|
17
17
|
/** `loadResources` 入参,与 info2 `getResourceList` 一致。 */
|
|
18
18
|
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* 形参 booking_config(结构来自
|
|
27
|
+
* 形参 booking_config(结构来自 staff management 或 H5 board config 接口的 `data`)。
|
|
28
28
|
* OS 不强制 schema,保留 `Record<string, any>` 兼容现网;常用路径文档化在 SDK docs。
|
|
29
29
|
*/
|
|
30
30
|
|
|
@@ -23,6 +23,7 @@ export interface OpenDataConfig {
|
|
|
23
23
|
'reservation.auto_confirm'?: boolean;
|
|
24
24
|
'reservation.auto_confirm_mode'?: string;
|
|
25
25
|
'reservation.auto_confirm_delay_seconds'?: number;
|
|
26
|
+
'reservation.time_slice'?: number | string;
|
|
26
27
|
'sale.allow_item_notes'?: boolean;
|
|
27
28
|
'sale.allow_order_notes'?: boolean;
|
|
28
29
|
'sale.enable_item_rules'?: boolean;
|
|
@@ -3,7 +3,7 @@ import { BaseModule } from '../BaseModule';
|
|
|
3
3
|
import { OrderModuleAPI, CommitOrderParams, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, CancelOrderParams, ChangeBookingStatusParams, CheckoutOrderParams } from './types';
|
|
4
4
|
import { CartItem } from '../Cart/types';
|
|
5
5
|
import { type SubmitPayloadEnhancer } from './utils';
|
|
6
|
-
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions } from './types';
|
|
6
|
+
import type { OrderAmountSnapshot, AddProductBookingInput, AddProductToOrderOptions, OrderIdentitySnapshot, OrderPaymentSource, OrderSnapshot, OrderSyncState, SyncPaymentsToOrderParams, SyncPaymentsToOrderResult, SubmitSalesOrderParams, OrderProduct, OrderProductIdentity, OrderSummary, OrderTempOrder, OrderPaymentData, OrderPaymentUpdateOptions, OrderPaymentUpdateResult, SendCustomerPayLinkParams, UpdateTempOrderCustomerInput, OrderCustomerPatch, OrderCustomerView, ReplaceTempOrderOptions, OrderPromotionEvaluator, OrderGiftSelectResolver, OrderUnfulfilledPromotion, OrderLastGiftActions, RemoveProductsFromOrderOptions, SalesNote, SalesNotesMutationSnapshot, SetSalesNoteInput, PickupReferenceMode, ShopServiceData, ShopServiceType } from './types';
|
|
7
7
|
import type { ICustomer } from '../AccountList/types';
|
|
8
8
|
import type { Discount } from '../Discount/types';
|
|
9
9
|
import { UnavailableReason } from '../Rules/types';
|
|
@@ -301,9 +301,24 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
301
301
|
updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
|
|
302
302
|
syncTempOrderNoteToRemote(orderId: number | string, note: string): Promise<string>;
|
|
303
303
|
getTempOrderNote(): string;
|
|
304
|
+
private ensureSalesNotesRuntimeState;
|
|
305
|
+
private ensureSalesNotesLoadedForMutation;
|
|
306
|
+
private normalizeSalesNoteUuid;
|
|
307
|
+
private getSalesNotePrimaryRelation;
|
|
308
|
+
private removeSalesNotesForMissingProductLines;
|
|
309
|
+
private setSalesNoteOnTempOrder;
|
|
310
|
+
getSalesNotes(): SalesNote[];
|
|
311
|
+
createSalesNotesMutationSnapshot(): SalesNotesMutationSnapshot;
|
|
312
|
+
restoreSalesNotesMutationSnapshot(snapshot: SalesNotesMutationSnapshot): void;
|
|
313
|
+
setSalesNote(input: SetSalesNoteInput): Promise<SalesNote>;
|
|
314
|
+
removeSalesNote(uuid: string): Promise<void>;
|
|
315
|
+
clearSalesNotes(): Promise<void>;
|
|
304
316
|
updateTempOrderShopDiscount(amount: string | number): string;
|
|
305
317
|
updateTempOrderDepositAmount(amount: string | number): OrderSummary;
|
|
306
318
|
updateTempOrderBuzzer(buzzer: string): string;
|
|
319
|
+
private updateTempOrderShopServiceData;
|
|
320
|
+
updateTempOrderPickupReferenceMode(mode: PickupReferenceMode): ShopServiceData;
|
|
321
|
+
updateTempOrderServiceType(serviceType: ShopServiceType): ShopServiceData;
|
|
307
322
|
updateTempOrderContactsInfo(contactsInfo: Record<string, any> | null): Record<string, any> | null;
|
|
308
323
|
private buildTempOrderCustomer;
|
|
309
324
|
private isCustomerBoundDiscount;
|
|
@@ -454,7 +469,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
454
469
|
removeProductFromOrder(identity: OrderProductIdentity, options?: RemoveProductsFromOrderOptions): Promise<OrderProduct[]>;
|
|
455
470
|
/**
|
|
456
471
|
* 仅清空购物车行(products / bookings),不重置整单。
|
|
457
|
-
*
|
|
472
|
+
* 普通整单 note 保持不变;以商品行为主体的 Sales Notes 同步删除。
|
|
458
473
|
*/
|
|
459
474
|
clearOrderCartLines(): Promise<OrderTempOrder>;
|
|
460
475
|
buildCurrentSubmitPayloadForLocalPrint(params?: {
|
|
@@ -591,4 +606,4 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
591
606
|
getOrderInfo(order_id: number): Promise<any>;
|
|
592
607
|
getVouchers(): any[];
|
|
593
608
|
}
|
|
594
|
-
export type { AddProductToOrderOptions, RemoveProductsFromOrderOptions, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|
|
609
|
+
export type { AddProductToOrderOptions, RemoveProductsFromOrderOptions, SalesNote, SalesNoteDraftInput, SalesNoteLocalizedSelection, SalesNoteLocalizedText, SalesNoteRelation, SalesNoteTextInput, SetSalesNoteInput, UpdateOrderBookingParams, UpdateOrderProductParams, UpdateOrderProductQuantityParams, } from './types';
|