@pisell/pisellos 2.1.125 → 2.1.127
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/model/strategy/adapter/itemRule/adapter.d.ts +8 -0
- package/dist/model/strategy/adapter/itemRule/adapter.js +52 -8
- package/dist/model/strategy/adapter/itemRule/examples.d.ts +15 -0
- package/dist/model/strategy/adapter/itemRule/examples.js +68 -1
- package/dist/model/strategy/adapter/itemRule/index.d.ts +1 -1
- package/dist/model/strategy/adapter/itemRule/index.js +1 -1
- package/dist/model/strategy/adapter/itemRule/type.d.ts +20 -1
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +6 -40
- package/dist/modules/Order/utils.d.ts +24 -0
- package/dist/modules/Order/utils.js +87 -11
- package/dist/modules/SalesSummary/types.d.ts +2 -1
- package/dist/modules/SalesSummary/utils.js +10 -10
- package/dist/modules/Schedule/utils.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +5 -0
- package/dist/solution/ScanOrder/index.js +205 -64
- package/dist/solution/ScanOrder/types.d.ts +19 -5
- package/dist/solution/ScanOrder/utils.d.ts +15 -0
- package/dist/solution/ScanOrder/utils.js +142 -62
- package/dist/solution/VenueBooking/index.d.ts +4 -0
- package/dist/solution/VenueBooking/index.js +219 -141
- package/dist/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/dist/solution/VenueBooking/utils/dateSummary.js +6 -4
- package/lib/model/strategy/adapter/itemRule/adapter.d.ts +8 -0
- package/lib/model/strategy/adapter/itemRule/adapter.js +41 -2
- package/lib/model/strategy/adapter/itemRule/examples.d.ts +15 -0
- package/lib/model/strategy/adapter/itemRule/examples.js +47 -0
- package/lib/model/strategy/adapter/itemRule/index.d.ts +1 -1
- package/lib/model/strategy/adapter/itemRule/index.js +2 -0
- package/lib/model/strategy/adapter/itemRule/type.d.ts +20 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +4 -37
- package/lib/modules/Order/utils.d.ts +24 -0
- package/lib/modules/Order/utils.js +65 -4
- package/lib/modules/SalesSummary/types.d.ts +2 -1
- package/lib/modules/SalesSummary/utils.js +2 -2
- package/lib/modules/Schedule/utils.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +5 -0
- package/lib/solution/ScanOrder/index.js +94 -18
- package/lib/solution/ScanOrder/types.d.ts +19 -5
- package/lib/solution/ScanOrder/utils.d.ts +15 -0
- package/lib/solution/ScanOrder/utils.js +86 -19
- package/lib/solution/VenueBooking/index.d.ts +4 -0
- package/lib/solution/VenueBooking/index.js +85 -25
- package/lib/solution/VenueBooking/utils/dateSummary.d.ts +1 -0
- package/lib/solution/VenueBooking/utils/dateSummary.js +13 -4
- package/package.json +1 -1
|
@@ -38,6 +38,7 @@ var import_types = require("./types");
|
|
|
38
38
|
var import_utils = require("./utils");
|
|
39
39
|
var import_types2 = require("../BookingByStep/types");
|
|
40
40
|
var import_ProductList = require("../../modules/ProductList");
|
|
41
|
+
var import_utils2 = require("../../modules/Order/utils");
|
|
41
42
|
var import_dayjs = __toESM(require("dayjs"));
|
|
42
43
|
var import_itemRule = require("../../model/strategy/adapter/itemRule");
|
|
43
44
|
__reExport(ScanOrder_exports, require("./types"), module.exports);
|
|
@@ -60,7 +61,8 @@ var ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
60
61
|
cartValidation: {
|
|
61
62
|
passed: null,
|
|
62
63
|
failures: []
|
|
63
|
-
}
|
|
64
|
+
},
|
|
65
|
+
entryPaxNumber: 1
|
|
64
66
|
};
|
|
65
67
|
this.otherParams = {};
|
|
66
68
|
this.itemRuleEvaluator = new import_itemRule.ItemRuleEvaluator();
|
|
@@ -420,6 +422,11 @@ var ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
420
422
|
if (!this.store.order) {
|
|
421
423
|
throw new Error("scanOrder解决方案需要 order 模块支持");
|
|
422
424
|
}
|
|
425
|
+
const pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(this.store.entryPaxNumber);
|
|
426
|
+
this.store.entryPaxNumber = pax;
|
|
427
|
+
const tempOrderForSubmit = this.store.order.ensureTempOrder();
|
|
428
|
+
tempOrderForSubmit.metadata = { ...tempOrderForSubmit.metadata, collect_pax: pax };
|
|
429
|
+
this.store.order.persistTempOrder();
|
|
423
430
|
const result = await this.store.order.submitTempOrder({
|
|
424
431
|
cacheId: this.cacheId,
|
|
425
432
|
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
@@ -698,22 +705,13 @@ var ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
698
705
|
(sourceItem == null ? void 0 : sourceItem.price) ?? (sourceItem == null ? void 0 : sourceItem.selling_price),
|
|
699
706
|
"0.00"
|
|
700
707
|
);
|
|
701
|
-
const originalPrice = (0, import_utils.toPriceString)(
|
|
702
|
-
(sourceItem == null ? void 0 : sourceItem.original_price) ?? (sourceItem == null ? void 0 : sourceItem.price) ?? sellingPrice,
|
|
703
|
-
sellingPrice
|
|
704
|
-
);
|
|
705
|
-
const paymentPrice = (0, import_utils.toPriceString)(
|
|
706
|
-
(sourceItem == null ? void 0 : sourceItem.payment_price) ?? (sourceItem == null ? void 0 : sourceItem.price) ?? sellingPrice,
|
|
707
|
-
sellingPrice
|
|
708
|
-
);
|
|
709
708
|
tempOrder.products.push(
|
|
710
709
|
(0, import_utils.normalizeOrderProduct)({
|
|
711
710
|
product_id: productId,
|
|
712
711
|
product_variant_id: productVariantId,
|
|
713
712
|
num: targetQuantity,
|
|
714
713
|
selling_price: sellingPrice,
|
|
715
|
-
original_price:
|
|
716
|
-
payment_price: paymentPrice,
|
|
714
|
+
original_price: sellingPrice,
|
|
717
715
|
metadata: {
|
|
718
716
|
item_rule_prefill: true,
|
|
719
717
|
item_rule_id: prefillItem.ruleId
|
|
@@ -765,6 +763,10 @@ var ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
765
763
|
});
|
|
766
764
|
}
|
|
767
765
|
async applyItemRulePrefill() {
|
|
766
|
+
var _a, _b;
|
|
767
|
+
if ((_b = (_a = this.store.order) == null ? void 0 : _a.getLastOrderInfo) == null ? void 0 : _b.call(_a)) {
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
768
770
|
this.logMethodStart("applyItemRulePrefill");
|
|
769
771
|
await this.applyPrefillByItemRule();
|
|
770
772
|
await this.refreshItemRuleQuantityLimits();
|
|
@@ -926,7 +928,8 @@ var ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
926
928
|
isExclusive,
|
|
927
929
|
isFull,
|
|
928
930
|
orderNumberPrefix,
|
|
929
|
-
raw: config
|
|
931
|
+
raw: config,
|
|
932
|
+
table_form_record: (config == null ? void 0 : config.table_form_record) ?? null
|
|
930
933
|
};
|
|
931
934
|
}
|
|
932
935
|
async fetchTableConfigByResourceId(resourceId) {
|
|
@@ -950,7 +953,7 @@ var ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
950
953
|
// 通过 resource_id + 店铺配置
|
|
951
954
|
// hasOrderId 表示 url 上是否有 orderid,如果是的话,后续的流程会走加单
|
|
952
955
|
async checkResourceAvailable(resourceId, hasOrderId) {
|
|
953
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
956
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
954
957
|
this.logMethodStart("checkResourceAvailable", {
|
|
955
958
|
resourceId
|
|
956
959
|
});
|
|
@@ -988,6 +991,7 @@ var ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
988
991
|
relation_id: resourceState.relationId,
|
|
989
992
|
table_form_id: resourceState.tableFormId,
|
|
990
993
|
deskmate_valid: resourceState.deskmate_valid,
|
|
994
|
+
table_form_record: resourceState.table_form_record,
|
|
991
995
|
policy: (_c = config == null ? void 0 : config.table_form_record) == null ? void 0 : _c.policy,
|
|
992
996
|
partyroom_booking: (_d = config == null ? void 0 : config.table_form_record) == null ? void 0 : _d.partyroom_booking
|
|
993
997
|
};
|
|
@@ -1000,8 +1004,11 @@ var ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1000
1004
|
);
|
|
1001
1005
|
if (reservationLinkIds.length === 0) {
|
|
1002
1006
|
this.enabledReservationRuleProducts = [];
|
|
1003
|
-
if (this.store.resource)
|
|
1007
|
+
if (this.store.resource) {
|
|
1004
1008
|
delete this.store.resource.requestEntryPax;
|
|
1009
|
+
delete this.store.resource.requestPaxMin;
|
|
1010
|
+
delete this.store.resource.requestPaxMax;
|
|
1011
|
+
}
|
|
1005
1012
|
} else {
|
|
1006
1013
|
tempOrder.metadata = { ...tempOrder.metadata || {} };
|
|
1007
1014
|
delete tempOrder.metadata.table_occupancy_duration;
|
|
@@ -1036,13 +1043,35 @@ var ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1036
1043
|
availabilityInfo.requestEntryPax = 1;
|
|
1037
1044
|
if (this.store.resource)
|
|
1038
1045
|
this.store.resource.requestEntryPax = 1;
|
|
1046
|
+
delete availabilityInfo.requestPaxMin;
|
|
1047
|
+
delete availabilityInfo.requestPaxMax;
|
|
1048
|
+
if (this.store.resource) {
|
|
1049
|
+
delete this.store.resource.requestPaxMin;
|
|
1050
|
+
delete this.store.resource.requestPaxMax;
|
|
1051
|
+
}
|
|
1052
|
+
const paxBounds = (0, import_utils.pickFirstCustomCapacityPaxBounds)(loaded);
|
|
1053
|
+
if ((paxBounds == null ? void 0 : paxBounds.min) !== void 0) {
|
|
1054
|
+
availabilityInfo.requestPaxMin = paxBounds.min;
|
|
1055
|
+
if (this.store.resource)
|
|
1056
|
+
this.store.resource.requestPaxMin = paxBounds.min;
|
|
1057
|
+
}
|
|
1058
|
+
if ((paxBounds == null ? void 0 : paxBounds.max) !== void 0) {
|
|
1059
|
+
availabilityInfo.requestPaxMax = paxBounds.max;
|
|
1060
|
+
if (this.store.resource)
|
|
1061
|
+
this.store.resource.requestPaxMax = paxBounds.max;
|
|
1062
|
+
}
|
|
1039
1063
|
} else if (this.store.resource) {
|
|
1040
1064
|
delete this.store.resource.requestEntryPax;
|
|
1065
|
+
delete this.store.resource.requestPaxMin;
|
|
1066
|
+
delete this.store.resource.requestPaxMax;
|
|
1041
1067
|
}
|
|
1042
1068
|
} else {
|
|
1043
1069
|
this.enabledReservationRuleProducts = [];
|
|
1044
|
-
if (this.store.resource)
|
|
1070
|
+
if (this.store.resource) {
|
|
1045
1071
|
delete this.store.resource.requestEntryPax;
|
|
1072
|
+
delete this.store.resource.requestPaxMin;
|
|
1073
|
+
delete this.store.resource.requestPaxMax;
|
|
1074
|
+
}
|
|
1046
1075
|
void this.addScanOrderLog({
|
|
1047
1076
|
level: "error",
|
|
1048
1077
|
title: "[ScanOrder] enabled_reservation_rules product query failed",
|
|
@@ -1061,10 +1090,31 @@ var ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1061
1090
|
tempOrder.order_id = resourceState.lastOrderId;
|
|
1062
1091
|
}
|
|
1063
1092
|
if (tempOrder.order_id) {
|
|
1064
|
-
await ((_g = this.store.order) == null ? void 0 : _g.getOrderInfoByRemote(tempOrder.order_id));
|
|
1093
|
+
const res = await ((_g = this.store.order) == null ? void 0 : _g.getOrderInfoByRemote(tempOrder.order_id));
|
|
1094
|
+
const entryPaxNumber = (_k = (_j = (_i = (_h = res == null ? void 0 : res.data) == null ? void 0 : _h.bookings) == null ? void 0 : _i.find((p) => {
|
|
1095
|
+
var _a2;
|
|
1096
|
+
return (_a2 = p.metadata) == null ? void 0 : _a2.collect_pax;
|
|
1097
|
+
})) == null ? void 0 : _j.metadata) == null ? void 0 : _k.collect_pax;
|
|
1098
|
+
if (entryPaxNumber) {
|
|
1099
|
+
await this.setEntryPaxNumber(entryPaxNumber);
|
|
1100
|
+
}
|
|
1065
1101
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
1102
|
+
const lastOrderInfo = (_m = (_l = this.store.order) == null ? void 0 : _l.getLastOrderInfo) == null ? void 0 : _m.call(_l);
|
|
1103
|
+
const historicalItems = hasOrderId && Array.isArray(lastOrderInfo == null ? void 0 : lastOrderInfo.products) ? lastOrderInfo.products.reduce((acc, p) => {
|
|
1104
|
+
if (typeof (p == null ? void 0 : p.product_id) !== "number")
|
|
1105
|
+
return acc;
|
|
1106
|
+
acc.push({
|
|
1107
|
+
product_id: p.product_id,
|
|
1108
|
+
quantity: Number(p.product_quantity) || 0,
|
|
1109
|
+
...typeof p.product_variant_id === "number" ? { product_variant_id: p.product_variant_id } : {}
|
|
1110
|
+
});
|
|
1111
|
+
return acc;
|
|
1112
|
+
}, []) : [];
|
|
1113
|
+
await this.setItemRuleRuntimeConfig({
|
|
1114
|
+
serviceType: (_n = this.otherParams) == null ? void 0 : _n.businessCode,
|
|
1115
|
+
submissionIndex: hasOrderId ? 1 : 0,
|
|
1116
|
+
historicalItems
|
|
1117
|
+
});
|
|
1068
1118
|
this.logMethodSuccess("checkResourceAvailable", {
|
|
1069
1119
|
resourceId,
|
|
1070
1120
|
mode: availabilityInfo.mode,
|
|
@@ -1131,6 +1181,32 @@ var ScanOrderImpl = class extends import_BaseModule.BaseModule {
|
|
|
1131
1181
|
getOtherParams() {
|
|
1132
1182
|
return this.otherParams;
|
|
1133
1183
|
}
|
|
1184
|
+
async setOtherParams(params, { cover = false } = {}) {
|
|
1185
|
+
if (cover) {
|
|
1186
|
+
this.otherParams = params;
|
|
1187
|
+
} else {
|
|
1188
|
+
this.otherParams = { ...this.otherParams, ...params };
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
async setEntryPaxNumber(number) {
|
|
1192
|
+
const pax = (0, import_utils2.normalizeSubmitCollectPaxValue)(number);
|
|
1193
|
+
this.store.entryPaxNumber = pax;
|
|
1194
|
+
if (this.store.order) {
|
|
1195
|
+
const t = this.store.order.ensureTempOrder();
|
|
1196
|
+
t.metadata = { ...t.metadata, collect_pax: pax };
|
|
1197
|
+
this.store.order.persistTempOrder();
|
|
1198
|
+
}
|
|
1199
|
+
this.itemRuleRuntimeConfig = {
|
|
1200
|
+
...this.itemRuleRuntimeConfig,
|
|
1201
|
+
pax: { total: pax, adult: 0, child: 0 }
|
|
1202
|
+
};
|
|
1203
|
+
this.itemRulePrefillApplied = false;
|
|
1204
|
+
await this.refreshItemRuleQuantityLimits();
|
|
1205
|
+
await this.refreshCartValidationPassed();
|
|
1206
|
+
}
|
|
1207
|
+
getEntryPaxNumber() {
|
|
1208
|
+
return this.store.entryPaxNumber;
|
|
1209
|
+
}
|
|
1134
1210
|
};
|
|
1135
1211
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1136
1212
|
0 && (module.exports = {
|
|
@@ -36,9 +36,10 @@ export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
|
|
|
36
36
|
order_detail_id: number | null;
|
|
37
37
|
num: number;
|
|
38
38
|
product_option_item: any[];
|
|
39
|
+
/** 券后单品单价(= 订单域实际成交单价)。未应用券时等同 original_price。 */
|
|
39
40
|
selling_price: string;
|
|
41
|
+
/** 券前单品单价(= 店铺售价),不承载后台划线价语义。 */
|
|
40
42
|
original_price: string;
|
|
41
|
-
payment_price: string;
|
|
42
43
|
tax_fee: string;
|
|
43
44
|
is_charge_tax: number;
|
|
44
45
|
discount_list: any[];
|
|
@@ -47,6 +48,11 @@ export interface ScanOrderOrderProduct extends ScanOrderOrderProductIdentity {
|
|
|
47
48
|
_origin?: Record<string, any>;
|
|
48
49
|
}
|
|
49
50
|
export interface ScanOrderSubmitProduct extends Omit<ScanOrderOrderProduct, '_origin' | 'identity_key'> {
|
|
51
|
+
/**
|
|
52
|
+
* 出站兼容字段:SDK 内部不再消费 payment_price,
|
|
53
|
+
* 仅在提交后端时由 selling_price 派生,保持原有后端契约。
|
|
54
|
+
*/
|
|
55
|
+
payment_price: string;
|
|
50
56
|
}
|
|
51
57
|
export interface ScanOrderSummary {
|
|
52
58
|
product_quantity: number;
|
|
@@ -133,6 +139,11 @@ export interface ScanOrderSubmitPayload extends Omit<ScanOrderTempOrder, 'platfo
|
|
|
133
139
|
products: ScanOrderSubmitProduct[];
|
|
134
140
|
}
|
|
135
141
|
export type ScanOrderAvailabilityMode = 'idle' | 'shop_closed' | 'resource_block' | 'resource_busy' | 'additional_order_with_code' | 'additional_order';
|
|
142
|
+
export interface ScanOrderTableFormRecord {
|
|
143
|
+
policy?: string | null;
|
|
144
|
+
partyroom_booking?: string | null;
|
|
145
|
+
[key: string]: any;
|
|
146
|
+
}
|
|
136
147
|
export interface ScanOrderAvailabilityInfo {
|
|
137
148
|
mode: ScanOrderAvailabilityMode;
|
|
138
149
|
order_id?: string;
|
|
@@ -140,10 +151,16 @@ export interface ScanOrderAvailabilityInfo {
|
|
|
140
151
|
table_form_id?: string;
|
|
141
152
|
deskmate_valid?: boolean;
|
|
142
153
|
errorTips?: string;
|
|
154
|
+
/** `/order/dining/table/config` 返回的 `table_form_record` 原样透出 */
|
|
155
|
+
table_form_record?: ScanOrderTableFormRecord | null;
|
|
143
156
|
policy?: string | null;
|
|
144
157
|
partyroom_booking?: string | null;
|
|
145
158
|
/** 预约规则关联商品存在 custom 容量时,由 checkResourceAvailable 置为 1 */
|
|
146
159
|
requestEntryPax?: number;
|
|
160
|
+
/** 首个 `capacity.type === 'custom'` 商品里 `custom[0]` 的 min(人数下限) */
|
|
161
|
+
requestPaxMin?: number;
|
|
162
|
+
/** 首个 `capacity.type === 'custom'` 商品里 `custom[0]` 的 max(人数上限) */
|
|
163
|
+
requestPaxMax?: number;
|
|
147
164
|
}
|
|
148
165
|
export interface ScanOrderTableSnackConfig {
|
|
149
166
|
snack?: boolean | number | string;
|
|
@@ -153,9 +170,6 @@ export interface ScanOrderOrderNumberPrefixConfig {
|
|
|
153
170
|
table_order?: string;
|
|
154
171
|
pos?: string;
|
|
155
172
|
}
|
|
156
|
-
export interface ScanOrderTableFormRecord {
|
|
157
|
-
policy?: string | null;
|
|
158
|
-
}
|
|
159
173
|
export interface ScanOrderTableConfigApiData {
|
|
160
174
|
table_max_number?: number | string | null;
|
|
161
175
|
order_count?: number | string | null;
|
|
@@ -186,7 +200,6 @@ export interface ScanOrderResourceState extends ScanOrderAvailabilityInfo {
|
|
|
186
200
|
isFull: boolean;
|
|
187
201
|
orderNumberPrefix: ScanOrderOrderNumberPrefixConfig[];
|
|
188
202
|
raw: ScanOrderTableConfigApiData | null;
|
|
189
|
-
table_form_record?: ScanOrderTableFormRecord | null;
|
|
190
203
|
}
|
|
191
204
|
export interface ScanOrderState {
|
|
192
205
|
entryContext: ScanOrderEntryContext | null;
|
|
@@ -204,6 +217,7 @@ export interface ScanOrderState {
|
|
|
204
217
|
passed: boolean | null;
|
|
205
218
|
failures: QuantityCheckResult[];
|
|
206
219
|
};
|
|
220
|
+
entryPaxNumber: number | null;
|
|
207
221
|
}
|
|
208
222
|
export interface ScanOrderLoggerRuntimeConfig {
|
|
209
223
|
provider?: ScanOrderLoggerProviderType;
|
|
@@ -59,8 +59,15 @@ export declare function resolveSkuMatchedQuantityLimits(params: {
|
|
|
59
59
|
export declare function aggregateItemRuleLimit(matchedLimits: QuantityLimitResult[]): {
|
|
60
60
|
min: number | undefined;
|
|
61
61
|
max: number | undefined;
|
|
62
|
+
remainingMax: number | undefined;
|
|
62
63
|
exact: number | undefined;
|
|
63
64
|
mustInclude: boolean;
|
|
65
|
+
validationMessage: string | undefined;
|
|
66
|
+
rawValidationMessage: string | Record<string, string> | undefined;
|
|
67
|
+
maxValidationMessage: string | undefined;
|
|
68
|
+
rawMaxValidationMessage: string | Record<string, string> | undefined;
|
|
69
|
+
minValidationMessage: string | undefined;
|
|
70
|
+
rawMinValidationMessage: string | Record<string, string> | undefined;
|
|
64
71
|
} | null;
|
|
65
72
|
export declare function buildItemRuleBusinessData(params: {
|
|
66
73
|
tempOrder: ScanOrderTempOrder;
|
|
@@ -102,3 +109,11 @@ export declare function collectLinkProductIdsFromReservationRules(rules: unknown
|
|
|
102
109
|
export declare function pickFirstDurationMinutesFromProducts(products: ProductData[]): number | undefined;
|
|
103
110
|
/** 是否存在 capacity.type === 'custom' 的商品 */
|
|
104
111
|
export declare function hasCustomCapacityProduct(products: ProductData[]): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* 在商品列表中找到第一个 `capacity.type === 'custom'` 的商品,取其 `custom` 数组第一项的 min/max。
|
|
114
|
+
* 仅返回有限数字字段;若均无法解析则返回 `undefined`。
|
|
115
|
+
*/
|
|
116
|
+
export declare function pickFirstCustomCapacityPaxBounds(products: ProductData[]): {
|
|
117
|
+
min?: number;
|
|
118
|
+
max?: number;
|
|
119
|
+
} | undefined;
|
|
@@ -36,6 +36,7 @@ __export(utils_exports, {
|
|
|
36
36
|
normalizeEnabledItemRuleIds: () => normalizeEnabledItemRuleIds,
|
|
37
37
|
normalizeItemRuleStrategies: () => normalizeItemRuleStrategies,
|
|
38
38
|
normalizeOrderProduct: () => normalizeOrderProduct,
|
|
39
|
+
pickFirstCustomCapacityPaxBounds: () => pickFirstCustomCapacityPaxBounds,
|
|
39
40
|
pickFirstDurationMinutesFromProducts: () => pickFirstDurationMinutesFromProducts,
|
|
40
41
|
resolveSkuMatchedQuantityLimits: () => resolveSkuMatchedQuantityLimits,
|
|
41
42
|
toBoolean: () => toBoolean,
|
|
@@ -163,18 +164,20 @@ function buildQuantityLimitIndex(limits) {
|
|
|
163
164
|
const exactLimitMap = /* @__PURE__ */ new Map();
|
|
164
165
|
const productLimitMap = /* @__PURE__ */ new Map();
|
|
165
166
|
for (const limit of limits) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
167
|
+
const targets = limit.targets || [];
|
|
168
|
+
if (targets.length !== 1)
|
|
169
|
+
continue;
|
|
170
|
+
const target = targets[0];
|
|
171
|
+
const productId = Number(target.product_id);
|
|
172
|
+
if (!Number.isFinite(productId) || productId <= 0)
|
|
173
|
+
continue;
|
|
174
|
+
const variantId = Number(target.product_variant_id);
|
|
175
|
+
const hasVariant = Number.isFinite(variantId) && variantId > 0;
|
|
176
|
+
if (hasVariant) {
|
|
177
|
+
const exactKey = buildProductKey(productId, variantId);
|
|
178
|
+
const existed = exactLimitMap.get(exactKey) || [];
|
|
179
|
+
exactLimitMap.set(exactKey, [...existed, limit]);
|
|
180
|
+
} else {
|
|
178
181
|
const existed = productLimitMap.get(productId) || [];
|
|
179
182
|
productLimitMap.set(productId, [...existed, limit]);
|
|
180
183
|
}
|
|
@@ -195,29 +198,66 @@ function aggregateItemRuleLimit(matchedLimits) {
|
|
|
195
198
|
return null;
|
|
196
199
|
let min;
|
|
197
200
|
let max;
|
|
201
|
+
let remainingMax;
|
|
198
202
|
let exact;
|
|
199
203
|
let mustInclude = false;
|
|
204
|
+
let maxSourceLimit;
|
|
205
|
+
let remainingMaxSourceLimit;
|
|
206
|
+
let exactSourceLimit;
|
|
207
|
+
let minSourceLimit;
|
|
208
|
+
let firstMessagedLimit;
|
|
200
209
|
for (const limit of matchedLimits) {
|
|
201
210
|
if (typeof limit.requiredMin === "number" && Number.isFinite(limit.requiredMin)) {
|
|
202
|
-
|
|
211
|
+
if (min === void 0 || limit.requiredMin > min) {
|
|
212
|
+
min = limit.requiredMin;
|
|
213
|
+
minSourceLimit = limit;
|
|
214
|
+
}
|
|
203
215
|
}
|
|
204
216
|
if (typeof limit.requiredMax === "number" && Number.isFinite(limit.requiredMax)) {
|
|
205
|
-
|
|
217
|
+
if (max === void 0 || limit.requiredMax < max) {
|
|
218
|
+
max = limit.requiredMax;
|
|
219
|
+
maxSourceLimit = limit;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (typeof limit.remainingMax === "number" && Number.isFinite(limit.remainingMax)) {
|
|
223
|
+
if (remainingMax === void 0 || limit.remainingMax < remainingMax) {
|
|
224
|
+
remainingMax = limit.remainingMax;
|
|
225
|
+
remainingMaxSourceLimit = limit;
|
|
226
|
+
}
|
|
206
227
|
}
|
|
207
228
|
if (typeof limit.requiredExact === "number" && Number.isFinite(limit.requiredExact)) {
|
|
208
229
|
exact = limit.requiredExact;
|
|
230
|
+
exactSourceLimit = limit;
|
|
209
231
|
}
|
|
210
232
|
mustInclude = mustInclude || Boolean(limit.mustInclude);
|
|
233
|
+
if (!firstMessagedLimit && limit.validationMessage) {
|
|
234
|
+
firstMessagedLimit = limit;
|
|
235
|
+
}
|
|
211
236
|
}
|
|
212
237
|
if (typeof exact === "number" && Number.isFinite(exact)) {
|
|
213
238
|
min = exact;
|
|
214
239
|
max = exact;
|
|
215
240
|
}
|
|
241
|
+
const maxMessageSource = maxSourceLimit || remainingMaxSourceLimit || exactSourceLimit || firstMessagedLimit;
|
|
242
|
+
const minMessageSource = minSourceLimit || exactSourceLimit || firstMessagedLimit;
|
|
243
|
+
const maxValidationMessage = maxMessageSource == null ? void 0 : maxMessageSource.validationMessage;
|
|
244
|
+
const rawMaxValidationMessage = maxMessageSource == null ? void 0 : maxMessageSource.rawValidationMessage;
|
|
245
|
+
const minValidationMessage = minMessageSource == null ? void 0 : minMessageSource.validationMessage;
|
|
246
|
+
const rawMinValidationMessage = minMessageSource == null ? void 0 : minMessageSource.rawValidationMessage;
|
|
247
|
+
const validationMessage = maxValidationMessage ?? minValidationMessage;
|
|
248
|
+
const rawValidationMessage = rawMaxValidationMessage ?? rawMinValidationMessage;
|
|
216
249
|
return {
|
|
217
250
|
min,
|
|
218
251
|
max,
|
|
252
|
+
remainingMax,
|
|
219
253
|
exact,
|
|
220
|
-
mustInclude
|
|
254
|
+
mustInclude,
|
|
255
|
+
validationMessage,
|
|
256
|
+
rawValidationMessage,
|
|
257
|
+
maxValidationMessage,
|
|
258
|
+
rawMaxValidationMessage,
|
|
259
|
+
minValidationMessage,
|
|
260
|
+
rawMinValidationMessage
|
|
221
261
|
};
|
|
222
262
|
}
|
|
223
263
|
function buildItemRuleBusinessData(params) {
|
|
@@ -297,13 +337,13 @@ function getProductIdentityIndex(products, identity) {
|
|
|
297
337
|
return products.findIndex((item) => isIdentityMatch(item, identity));
|
|
298
338
|
}
|
|
299
339
|
function normalizeOrderProduct(product) {
|
|
300
|
-
var _a;
|
|
340
|
+
var _a, _b;
|
|
301
341
|
const metadata = { ...product.metadata || {} };
|
|
302
342
|
if (product.identity_key && !metadata.unique_identification_number) {
|
|
303
343
|
metadata.unique_identification_number = product.identity_key;
|
|
304
344
|
}
|
|
305
|
-
const resolvedOriginalPrice = product.original_price || "0.00";
|
|
306
345
|
const resolvedSellingPrice = product.selling_price || "0.00";
|
|
346
|
+
const resolvedOriginalPrice = product.original_price || resolvedSellingPrice;
|
|
307
347
|
if (metadata.main_product_original_price === void 0) {
|
|
308
348
|
metadata.main_product_original_price = resolvedOriginalPrice;
|
|
309
349
|
}
|
|
@@ -311,7 +351,7 @@ function normalizeOrderProduct(product) {
|
|
|
311
351
|
metadata.main_product_selling_price = resolvedSellingPrice;
|
|
312
352
|
}
|
|
313
353
|
if (metadata.source_product_price === void 0) {
|
|
314
|
-
metadata.source_product_price = ((_a = product._origin) == null ? void 0 : _a.
|
|
354
|
+
metadata.source_product_price = ((_a = product._origin) == null ? void 0 : _a.price) ?? ((_b = product._origin) == null ? void 0 : _b.base_price) ?? resolvedSellingPrice;
|
|
315
355
|
}
|
|
316
356
|
const normalizedBundle = (product.product_bundle || []).map((item) => ({
|
|
317
357
|
...item,
|
|
@@ -327,7 +367,6 @@ function normalizeOrderProduct(product) {
|
|
|
327
367
|
product_option_item: product.product_option_item || [],
|
|
328
368
|
selling_price: resolvedSellingPrice,
|
|
329
369
|
original_price: resolvedOriginalPrice,
|
|
330
|
-
payment_price: product.payment_price || "0.00",
|
|
331
370
|
tax_fee: product.tax_fee || "0.00",
|
|
332
371
|
is_charge_tax: product.is_charge_tax ?? 0,
|
|
333
372
|
discount_list: product.discount_list || [],
|
|
@@ -372,6 +411,33 @@ function hasCustomCapacityProduct(products) {
|
|
|
372
411
|
return ((_a = p == null ? void 0 : p.capacity) == null ? void 0 : _a.type) === "custom";
|
|
373
412
|
});
|
|
374
413
|
}
|
|
414
|
+
function pickFirstCustomCapacityPaxBounds(products) {
|
|
415
|
+
for (const p of products) {
|
|
416
|
+
const cap = p == null ? void 0 : p.capacity;
|
|
417
|
+
if (!cap || cap.type !== "custom")
|
|
418
|
+
continue;
|
|
419
|
+
if (!Array.isArray(cap.custom) || cap.custom.length === 0)
|
|
420
|
+
continue;
|
|
421
|
+
const row = cap.custom[0];
|
|
422
|
+
if (!row || typeof row !== "object")
|
|
423
|
+
continue;
|
|
424
|
+
const raw = row;
|
|
425
|
+
const out = {};
|
|
426
|
+
if (raw.min !== null && raw.min !== void 0 && raw.min !== "") {
|
|
427
|
+
const min = Number(raw.min);
|
|
428
|
+
if (Number.isFinite(min))
|
|
429
|
+
out.min = min;
|
|
430
|
+
}
|
|
431
|
+
if (raw.max !== null && raw.max !== void 0 && raw.max !== "") {
|
|
432
|
+
const max = Number(raw.max);
|
|
433
|
+
if (Number.isFinite(max))
|
|
434
|
+
out.max = max;
|
|
435
|
+
}
|
|
436
|
+
if (out.min !== void 0 || out.max !== void 0)
|
|
437
|
+
return out;
|
|
438
|
+
}
|
|
439
|
+
return void 0;
|
|
440
|
+
}
|
|
375
441
|
// Annotate the CommonJS export names for ESM import in node:
|
|
376
442
|
0 && (module.exports = {
|
|
377
443
|
aggregateItemRuleLimit,
|
|
@@ -391,6 +457,7 @@ function hasCustomCapacityProduct(products) {
|
|
|
391
457
|
normalizeEnabledItemRuleIds,
|
|
392
458
|
normalizeItemRuleStrategies,
|
|
393
459
|
normalizeOrderProduct,
|
|
460
|
+
pickFirstCustomCapacityPaxBounds,
|
|
394
461
|
pickFirstDurationMinutesFromProducts,
|
|
395
462
|
resolveSkuMatchedQuantityLimits,
|
|
396
463
|
toBoolean,
|
|
@@ -25,6 +25,7 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
25
25
|
private cacheId;
|
|
26
26
|
private window;
|
|
27
27
|
private request;
|
|
28
|
+
private baseSlotConfig;
|
|
28
29
|
private itemRuleEvaluator;
|
|
29
30
|
private itemRuleConfigs;
|
|
30
31
|
private itemRuleConfigsPromise;
|
|
@@ -80,6 +81,9 @@ export declare class VenueBookingImpl extends BaseModule implements Module {
|
|
|
80
81
|
startDate: string;
|
|
81
82
|
endDate: string;
|
|
82
83
|
}): Promise<void>;
|
|
84
|
+
private getOperatingHoursScheduleIds;
|
|
85
|
+
private resolveSlotConfigForDate;
|
|
86
|
+
private syncOperatingHoursToSlotConfig;
|
|
83
87
|
getDateRangeSummary(params: {
|
|
84
88
|
startDate: string;
|
|
85
89
|
endDate: string;
|