@pisell/pisellos 2.3.224 → 2.3.226
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/dataVariant/evaluator.d.ts +2 -1
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +60 -15
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Customer/types.d.ts +4 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +123 -79
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Order/utils/bookingUuid.d.ts +4 -0
- package/dist/modules/Order/utils/bookingUuid.js +24 -0
- package/dist/modules/Order/utils.js +2 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BaseSales/index.js +3 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +12 -12
- package/dist/solution/Checkout/index.js +104 -69
- package/dist/solution/Checkout/types.d.ts +1 -0
- package/dist/solution/ScanOrder/index.js +10 -2
- package/dist/solution/VenueBooking/index.js +522 -490
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -1
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +40 -6
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Customer/types.d.ts +4 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +44 -6
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Order/utils/bookingUuid.d.ts +4 -0
- package/lib/modules/Order/utils/bookingUuid.js +25 -0
- package/lib/modules/Order/utils.js +5 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BaseSales/index.js +3 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +12 -12
- package/lib/solution/Checkout/index.js +21 -0
- package/lib/solution/Checkout/types.d.ts +1 -0
- package/lib/solution/ScanOrder/index.js +6 -0
- package/lib/solution/VenueBooking/index.js +6 -1
- package/package.json +1 -1
|
@@ -44,7 +44,7 @@ export declare class DataVariantEvaluator {
|
|
|
44
44
|
* 返回 null 表示接口没有提供该字段;空 Map 表示已计算但没有任何命中。
|
|
45
45
|
*/
|
|
46
46
|
private getAuthoritativeVariantPriorities;
|
|
47
|
-
private
|
|
47
|
+
private normalizeId;
|
|
48
48
|
private buildGlobalEffectiveRuleMap;
|
|
49
49
|
private resolveProduct;
|
|
50
50
|
/**
|
|
@@ -90,6 +90,7 @@ export declare class DataVariantEvaluator {
|
|
|
90
90
|
private timeToMinutes;
|
|
91
91
|
private isProductInMenuScope;
|
|
92
92
|
private mergeMatchedVariants;
|
|
93
|
+
private mergeSkuVariants;
|
|
93
94
|
private getProductDataVariants;
|
|
94
95
|
private normalizeStrategyConfigs;
|
|
95
96
|
private isStrategyActive;
|
|
@@ -158,14 +158,14 @@ class DataVariantEvaluator {
|
|
|
158
158
|
const orderedIds = [];
|
|
159
159
|
const seen = new Set();
|
|
160
160
|
for (const rawId of rawIds) {
|
|
161
|
-
const id = this.
|
|
161
|
+
const id = this.normalizeId(rawId);
|
|
162
162
|
if (id === null || seen.has(id)) continue;
|
|
163
163
|
seen.add(id);
|
|
164
164
|
orderedIds.push(id);
|
|
165
165
|
}
|
|
166
166
|
return new Map(orderedIds.map((id, index) => [id, orderedIds.length - index]));
|
|
167
167
|
}
|
|
168
|
-
|
|
168
|
+
normalizeId(value) {
|
|
169
169
|
if (value === undefined || value === null) return null;
|
|
170
170
|
const normalized = String(value).trim();
|
|
171
171
|
return normalized || null;
|
|
@@ -206,7 +206,7 @@ class DataVariantEvaluator {
|
|
|
206
206
|
for (const variant of dataVariants) {
|
|
207
207
|
if (variant.business_type === 'multi_currency_settlement') continue;
|
|
208
208
|
if (authoritativeVariantPriorities !== null) {
|
|
209
|
-
const variantId = this.
|
|
209
|
+
const variantId = this.normalizeId(variant.id);
|
|
210
210
|
const priority = variantId === null ? undefined : authoritativeVariantPriorities.get(variantId);
|
|
211
211
|
if (priority === undefined) continue;
|
|
212
212
|
matchedVariants.push({
|
|
@@ -250,7 +250,7 @@ class DataVariantEvaluator {
|
|
|
250
250
|
const ruleId = String(variant.data_variant_rule_id);
|
|
251
251
|
const isDefault = Number(variant.data_variant_rule_id) === 0;
|
|
252
252
|
const rule = isDefault ? undefined : globalEffectiveRuleMap.get(ruleId);
|
|
253
|
-
const variantId = this.
|
|
253
|
+
const variantId = this.normalizeId(variant.id);
|
|
254
254
|
const authoritativePriority = variantId === null ? undefined : authoritativeVariantPriorities?.get(variantId);
|
|
255
255
|
let available;
|
|
256
256
|
let priority;
|
|
@@ -575,20 +575,54 @@ class DataVariantEvaluator {
|
|
|
575
575
|
const appliedFields = new Set();
|
|
576
576
|
for (const matched of sortedVariants) {
|
|
577
577
|
for (const [key, value] of Object.entries(matched.data)) {
|
|
578
|
-
if (value === undefined) continue;
|
|
578
|
+
if (value === undefined || key === 'variant_overrides') continue;
|
|
579
579
|
result[key] = value;
|
|
580
580
|
appliedFields.add(key);
|
|
581
581
|
}
|
|
582
|
+
const mergedVariants = this.mergeSkuVariants(result.variant, matched.data.variant_overrides);
|
|
583
|
+
if (mergedVariants) {
|
|
584
|
+
result.variant = mergedVariants;
|
|
585
|
+
appliedFields.add('variant');
|
|
586
|
+
}
|
|
582
587
|
appliedRuleIds.push(matched.ruleId);
|
|
583
588
|
}
|
|
584
589
|
result._dataVariant = {
|
|
585
590
|
appliedRuleIds,
|
|
586
|
-
appliedVariantIds: Array.from(new Set([...sortedVariants].reverse().map(matched => this.
|
|
591
|
+
appliedVariantIds: Array.from(new Set([...sortedVariants].reverse().map(matched => this.normalizeId(matched.variant.id)).filter(id => id !== null))),
|
|
587
592
|
appliedFields: Array.from(appliedFields),
|
|
588
593
|
original
|
|
589
594
|
};
|
|
590
595
|
return result;
|
|
591
596
|
}
|
|
597
|
+
mergeSkuVariants(variants, overrides) {
|
|
598
|
+
if (!Array.isArray(variants) || !Array.isArray(overrides)) return;
|
|
599
|
+
const overridesById = new Map();
|
|
600
|
+
for (const override of overrides) {
|
|
601
|
+
const rawId = override?.id;
|
|
602
|
+
if (typeof rawId !== 'number' && typeof rawId !== 'string') continue;
|
|
603
|
+
const id = this.normalizeId(rawId);
|
|
604
|
+
if (id === null) continue;
|
|
605
|
+
const fields = Object.entries(override).filter(([key, value]) => key !== 'id' && value !== undefined);
|
|
606
|
+
if (fields.length === 0) continue;
|
|
607
|
+
overridesById.set(id, {
|
|
608
|
+
...overridesById.get(id),
|
|
609
|
+
...Object.fromEntries(fields)
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
if (overridesById.size === 0) return;
|
|
613
|
+
let hasUpdates = false;
|
|
614
|
+
const merged = variants.map(variant => {
|
|
615
|
+
const id = this.normalizeId(variant?.id);
|
|
616
|
+
const fields = id === null ? undefined : overridesById.get(id);
|
|
617
|
+
if (!fields) return variant;
|
|
618
|
+
hasUpdates = true;
|
|
619
|
+
return {
|
|
620
|
+
...variant,
|
|
621
|
+
...fields
|
|
622
|
+
};
|
|
623
|
+
});
|
|
624
|
+
return hasUpdates ? merged : undefined;
|
|
625
|
+
}
|
|
592
626
|
getProductDataVariants(product) {
|
|
593
627
|
return Array.isArray(product.data_variants) ? product.data_variants : [];
|
|
594
628
|
}
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _adapter.PromotionAdapter;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _evaluator.PromotionEvaluator;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "default", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _adapter.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
var _evaluator = require("./evaluator");
|
|
43
|
-
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
-
var _examples = require("./examples");
|
|
45
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
"use strict";
|
|
@@ -44,6 +44,10 @@ export interface ShopGetCustomerListParams {
|
|
|
44
44
|
num?: number;
|
|
45
45
|
/** 搜索关键词 */
|
|
46
46
|
search?: string;
|
|
47
|
+
/** Full national phone number, without the international calling code. */
|
|
48
|
+
phone?: string;
|
|
49
|
+
/** Exact email lookup, independent from the generic search keyword. */
|
|
50
|
+
email?: string;
|
|
47
51
|
/** 关联查询参数 */
|
|
48
52
|
with?: CustomerWith[];
|
|
49
53
|
/** wallet搜索标识 */
|
|
@@ -642,7 +642,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
642
642
|
generateIdempotencyToken(): string;
|
|
643
643
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
644
644
|
createOrder(params: CommitOrderParams['query']): {
|
|
645
|
-
type: "
|
|
645
|
+
type: "appointment_booking" | "virtual";
|
|
646
646
|
platform: string;
|
|
647
647
|
sales_channel: string;
|
|
648
648
|
order_sales_channel: string;
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, "isFulfillmentTimingBooking", {
|
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
var _loadSalesOrderSnapshot = require("../../shared/sales/loadSalesOrderSnapshot");
|
|
14
|
+
var _bookingUuid = require("./utils/bookingUuid");
|
|
14
15
|
var _localEftposState = require("./localEftposState");
|
|
15
16
|
var _BaseModule = require("../BaseModule");
|
|
16
17
|
var _types = require("./types");
|
|
@@ -2584,7 +2585,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2584
2585
|
booking_uid: bookingUid
|
|
2585
2586
|
},
|
|
2586
2587
|
booking: {
|
|
2587
|
-
...params.booking,
|
|
2588
|
+
...(0, _bookingUuid.ensureBookingUuid)(params.booking),
|
|
2588
2589
|
is_all: (0, _utils.normalizeBookingIsAll)(params.booking),
|
|
2589
2590
|
product_uid: productUid,
|
|
2590
2591
|
sub_type: (0, _utils.normalizeBookingSubType)(params.booking),
|
|
@@ -3199,7 +3200,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3199
3200
|
const tempOrder = this.ensureTempOrder();
|
|
3200
3201
|
const bookings = tempOrder.bookings || [];
|
|
3201
3202
|
const firstIndex = bookings.findIndex(_pickupTiming.isFulfillmentTimingBooking);
|
|
3202
|
-
const nextBooking = (0, _pickupTiming.buildPickupTimingBooking)(input, bookings[firstIndex]);
|
|
3203
|
+
const nextBooking = (0, _bookingUuid.ensureBookingUuid)((0, _pickupTiming.buildPickupTimingBooking)(input, bookings[firstIndex]));
|
|
3203
3204
|
// Keep the first row's identity and position; repair duplicate marked rows only.
|
|
3204
3205
|
tempOrder.bookings = firstIndex === -1 ? [...bookings, nextBooking] : bookings.flatMap((booking, index) => index === firstIndex ? [nextBooking] : (0, _pickupTiming.isFulfillmentTimingBooking)(booking) ? [] : [booking]);
|
|
3205
3206
|
this.notifyTempOrderChanged();
|
|
@@ -3851,6 +3852,16 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3851
3852
|
* if (pending) await pending;
|
|
3852
3853
|
*/
|
|
3853
3854
|
appendProductLineToTempOrder(tempOrder, product, booking, options) {
|
|
3855
|
+
const incomingBookingUuid = booking?.uuid;
|
|
3856
|
+
if (booking && incomingBookingUuid && tempOrder.bookings?.some(item => item.uuid === incomingBookingUuid)) {
|
|
3857
|
+
// Appending a copy creates a different booking; editing uses the update path below.
|
|
3858
|
+
booking = {
|
|
3859
|
+
...booking,
|
|
3860
|
+
uuid: (0, _utils.createUuidV4)(),
|
|
3861
|
+
id: undefined,
|
|
3862
|
+
schedule_event_id: undefined
|
|
3863
|
+
};
|
|
3864
|
+
}
|
|
3854
3865
|
const linked = booking ? this.createLinkedProductAndBooking({
|
|
3855
3866
|
product,
|
|
3856
3867
|
booking
|
|
@@ -4015,6 +4026,12 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4015
4026
|
singleLine.num = 1;
|
|
4016
4027
|
delete singleLine.product_quantity;
|
|
4017
4028
|
const singleBooking = (0, _lodashEs.cloneDeep)(booking);
|
|
4029
|
+
if (index > 0) {
|
|
4030
|
+
// Both single-add and batch-add quantity splits create separate appointments.
|
|
4031
|
+
delete singleBooking.uuid;
|
|
4032
|
+
delete singleBooking.schedule_event_id;
|
|
4033
|
+
delete singleBooking.id;
|
|
4034
|
+
}
|
|
4018
4035
|
const bookingHolder = booking?.holder && typeof booking.holder === 'object' ? booking.holder : null;
|
|
4019
4036
|
const metadataHolder = booking?.metadata?.holder && typeof booking.metadata.holder === 'object' ? booking.metadata.holder : null;
|
|
4020
4037
|
const rawHolderIds = bookingHolder?.form_record ?? booking?.metadata?.holder_id ?? metadataHolder?.form_record ?? product?.metadata?.holder_id;
|
|
@@ -4265,7 +4282,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4265
4282
|
const target = live.products[targetIndex];
|
|
4266
4283
|
const scopeKey = String(target?.metadata?.venue_booking_scope_key || '');
|
|
4267
4284
|
const targetBookingUid = String(target?.booking_uid || target?.metadata?.booking_uid || '');
|
|
4268
|
-
|
|
4285
|
+
const targetBookings = (live.bookings || []).filter(row => this.getBookingUniqueIdentificationNumber(row) === targetBookingUid);
|
|
4286
|
+
if (!uid || !target || !scopeKey || live.order_id || target.order_detail_id != null || Number(target.num) !== 1 || Number(params.product.num ?? 1) !== 1 || target.metadata?.venue_booking_role !== 'party_main' || params.product.metadata?.venue_booking_role !== 'party_main' || params.product.metadata?.venue_booking_scope_key !== scopeKey || !Array.isArray(params.relatedRetailProducts) || (live.payments || []).length > 0 || !targetBookingUid || String(params.booking.metadata?.unique_identification_number || '') !== targetBookingUid || targetBookings.length !== 1 || live.products.filter(line => line.metadata?.venue_booking_role === 'party_main' && line.metadata?.venue_booking_scope_key === scopeKey).length !== 1) {
|
|
4269
4287
|
throw new Error('[Order] Party replacement requires one unsubmitted, unpaid main booking in the same scope');
|
|
4270
4288
|
}
|
|
4271
4289
|
const children = live.products.filter(line => line.metadata?.venue_booking_role === 'party_extra' && String(line.metadata?.venue_booking_parent_uid || '') === uid);
|
|
@@ -4325,7 +4343,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4325
4343
|
venue_booking_service_datetime: serviceDatetime
|
|
4326
4344
|
};
|
|
4327
4345
|
replacement.unique_identification_number = uid;
|
|
4328
|
-
|
|
4346
|
+
const replacementBooking = (0, _lodashEs.cloneDeep)(params.booking);
|
|
4347
|
+
replacementBooking.uuid = targetBookings[0].uuid || replacementBooking.uuid;
|
|
4348
|
+
await this.appendProductLineToTempOrder(draft, replacement, replacementBooking, {
|
|
4329
4349
|
insertAtIndex: targetIndex,
|
|
4330
4350
|
disableMerge: true,
|
|
4331
4351
|
beforeCommit
|
|
@@ -4733,12 +4753,22 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4733
4753
|
...(normalizedProduct.metadata || {}),
|
|
4734
4754
|
unique_identification_number: productUid
|
|
4735
4755
|
};
|
|
4756
|
+
const originalBookingUid = targetProduct.booking_uid || targetProduct.metadata?.booking_uid || preservedBookingUid;
|
|
4757
|
+
const bookings = tempOrder.bookings || [];
|
|
4758
|
+
const eventId = booking.schedule_event_id;
|
|
4759
|
+
const originalBooking = bookings.find(row => Number(eventId) > 0 && String(row.schedule_event_id) === String(eventId)) ?? bookings.find(row => originalBookingUid && row.metadata?.unique_identification_number === originalBookingUid);
|
|
4760
|
+
const {
|
|
4761
|
+
uuid: incomingUuid = originalBooking?.uuid
|
|
4762
|
+
} = booking;
|
|
4736
4763
|
const linked = this.createLinkedProductAndBooking({
|
|
4737
4764
|
product: {
|
|
4738
4765
|
...normalizedProduct,
|
|
4739
4766
|
unique_identification_number: productUid
|
|
4740
4767
|
},
|
|
4741
|
-
booking
|
|
4768
|
+
booking: {
|
|
4769
|
+
...booking,
|
|
4770
|
+
uuid: originalBooking?.uuid || incomingUuid
|
|
4771
|
+
}
|
|
4742
4772
|
});
|
|
4743
4773
|
this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
|
|
4744
4774
|
normalizedProduct = {
|
|
@@ -5000,9 +5030,13 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5000
5030
|
throw new Error('[Order] 目标 booking 不存在,无法更新');
|
|
5001
5031
|
}
|
|
5002
5032
|
const targetBooking = tempOrder.bookings[bookingIndex] || {};
|
|
5033
|
+
const {
|
|
5034
|
+
uuid: incomingUuid = targetBooking.uuid
|
|
5035
|
+
} = updates;
|
|
5003
5036
|
const nextBooking = {
|
|
5004
5037
|
...targetBooking,
|
|
5005
5038
|
...updates,
|
|
5039
|
+
uuid: targetBooking.uuid || incomingUuid,
|
|
5006
5040
|
metadata: {
|
|
5007
5041
|
...(targetBooking.metadata || {}),
|
|
5008
5042
|
...(updates.metadata || {}),
|
|
@@ -5012,6 +5046,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5012
5046
|
unique_identification_number: bookingUid
|
|
5013
5047
|
}
|
|
5014
5048
|
};
|
|
5049
|
+
(0, _bookingUuid.assignBookingUuid)(nextBooking);
|
|
5015
5050
|
this.syncBookingMetadataHolder(nextBooking, nextBooking.metadata);
|
|
5016
5051
|
nextBooking.is_all = (0, _utils.normalizeBookingIsAll)(nextBooking);
|
|
5017
5052
|
nextBooking.sub_type = (0, _utils.normalizeBookingSubType)(nextBooking);
|
|
@@ -5712,6 +5747,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5712
5747
|
* @returns 后端返回的订单数据(包含订单ID等)
|
|
5713
5748
|
*/
|
|
5714
5749
|
async createOrderByCheckout(params) {
|
|
5750
|
+
params.bookings?.forEach(_bookingUuid.assignBookingUuid);
|
|
5715
5751
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5716
5752
|
const onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
5717
5753
|
params.payments = params.payments?.filter(p => !onlineStorePaymentCodeList.includes(p.code));
|
|
@@ -5799,6 +5835,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5799
5835
|
url,
|
|
5800
5836
|
query
|
|
5801
5837
|
} = params;
|
|
5838
|
+
query.bookings?.forEach(_bookingUuid.assignBookingUuid);
|
|
5802
5839
|
const fetchUrl = url || '/order/sales/checkout';
|
|
5803
5840
|
const handledByOsServer = this.isSalesCheckoutHandledByOsServer(fetchUrl);
|
|
5804
5841
|
const requestQuery = handledByOsServer ? query : (0, _localEftposState.stripLocalEftposState)((0, _osPrivatePayload.stripOsPrivatePayloadFields)(query));
|
|
@@ -6153,8 +6190,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
6153
6190
|
})) : [];
|
|
6154
6191
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(b => {
|
|
6155
6192
|
const booking = this.normalizeHydratedBookingHolder(b || {});
|
|
6193
|
+
const submitted = (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0;
|
|
6156
6194
|
return {
|
|
6157
|
-
...booking,
|
|
6195
|
+
...(submitted ? (0, _bookingUuid.ensureBookingUuid)(booking) : booking),
|
|
6158
6196
|
is_all: (0, _utils.normalizeBookingIsAll)(booking),
|
|
6159
6197
|
sub_type: (0, _utils.normalizeBookingSubType)(booking)
|
|
6160
6198
|
};
|
|
@@ -617,6 +617,8 @@ export interface CommitOrderParams {
|
|
|
617
617
|
};
|
|
618
618
|
}
|
|
619
619
|
export interface OrderSubmitBooking {
|
|
620
|
+
/** Stable booking identity, created once and shared with external allocations. */
|
|
621
|
+
uuid?: string | null;
|
|
620
622
|
relation_id?: string;
|
|
621
623
|
form_id?: string;
|
|
622
624
|
collect_pax?: number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Cross-system booking identity; independent from the legacy cart-line UID. */
|
|
2
|
+
export declare function ensureBookingUuid<T extends Record<string, any>>(booking: T): T;
|
|
3
|
+
/** Retain a generated UUID on the draft so a checkout retry sends the same value. */
|
|
4
|
+
export declare function assignBookingUuid(booking: Record<string, any> | null | undefined): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.assignBookingUuid = assignBookingUuid;
|
|
7
|
+
exports.ensureBookingUuid = ensureBookingUuid;
|
|
8
|
+
var _orderCollectionIdentity = require("./orderCollectionIdentity");
|
|
9
|
+
/** Cross-system booking identity; independent from the legacy cart-line UID. */
|
|
10
|
+
function ensureBookingUuid(booking) {
|
|
11
|
+
if (booking.uuid) return booking;
|
|
12
|
+
// Only an explicit null confirms that an existing booking needs a UUID when saved.
|
|
13
|
+
if (booking.uuid !== null && Number(booking.schedule_event_id || booking.id) > 0) return booking;
|
|
14
|
+
return {
|
|
15
|
+
...booking,
|
|
16
|
+
uuid: (0, _orderCollectionIdentity.createUuidV4)()
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Retain a generated UUID on the draft so a checkout retry sends the same value. */
|
|
21
|
+
function assignBookingUuid(booking) {
|
|
22
|
+
if (!booking) return;
|
|
23
|
+
const resolved = ensureBookingUuid(booking);
|
|
24
|
+
if (resolved !== booking) booking.uuid = resolved.uuid;
|
|
25
|
+
}
|
|
@@ -140,6 +140,7 @@ var _manualProductDiscount = require("./utils/manualProductDiscount");
|
|
|
140
140
|
var _utils = require("../Holder/utils");
|
|
141
141
|
var _utils2 = require("../../solution/ScanOrder/utils");
|
|
142
142
|
var _orderCollectionIdentity = require("./utils/orderCollectionIdentity");
|
|
143
|
+
var _bookingUuid = require("./utils/bookingUuid");
|
|
143
144
|
var _salesNotes = require("./salesNotes");
|
|
144
145
|
var _pickupTiming = require("./pickupTiming");
|
|
145
146
|
var _holderRelations = require("./holderRelations");
|
|
@@ -1664,7 +1665,10 @@ function buildSubmitPayload(params) {
|
|
|
1664
1665
|
delivery_type: tempOrder.delivery_type || 'shop_service',
|
|
1665
1666
|
schedule_date: scheduleDate,
|
|
1666
1667
|
// created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
|
|
1667
|
-
bookings: (tempOrder.bookings || []).filter(booking => (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0).map(booking =>
|
|
1668
|
+
bookings: (tempOrder.bookings || []).filter(booking => (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0).map(booking => {
|
|
1669
|
+
(0, _bookingUuid.assignBookingUuid)(booking);
|
|
1670
|
+
return normalizeSubmitBooking(booking);
|
|
1671
|
+
}),
|
|
1668
1672
|
payments: tempOrder.payments || [],
|
|
1669
1673
|
relation_forms: tempOrder.relation_forms || [],
|
|
1670
1674
|
// contacts: tempOrder.contacts || [],
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "duration" | "normal" | "session";
|
|
53
53
|
}
|
|
@@ -223,6 +223,9 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
|
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
const mergedItem = mergedUid ? (0, _orderCollectionIdentity.setOrderCollectionUid)(kind, incomingItem, mergedUid) : (0, _lodashEs.cloneDeep)(incomingItem);
|
|
226
|
+
if (kind === 'booking' && !mergedItem.uuid && currentItem.uuid !== undefined) {
|
|
227
|
+
mergedItem.uuid = currentItem.uuid;
|
|
228
|
+
}
|
|
226
229
|
const persistentIdField = BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND[kind];
|
|
227
230
|
if (isBaseSalesBlankValue(mergedItem[persistentIdField]) && !isBaseSalesBlankValue(identityMergedItem[persistentIdField])) {
|
|
228
231
|
mergedItem[persistentIdField] = identityMergedItem[persistentIdField];
|
|
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
342
342
|
date: string;
|
|
343
343
|
status: string;
|
|
344
344
|
week: string;
|
|
345
|
-
weekNum: 0 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
346
346
|
}[]>;
|
|
347
347
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
348
348
|
private getScheduleDataByIds;
|
|
@@ -389,7 +389,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
389
389
|
};
|
|
390
390
|
setOtherData(key: string, value: any): void;
|
|
391
391
|
getOtherData(key: string): any;
|
|
392
|
-
getProductTypeById(id: number): Promise<"
|
|
392
|
+
getProductTypeById(id: number): Promise<"duration" | "normal" | "session">;
|
|
393
393
|
/**
|
|
394
394
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
395
395
|
*
|
|
@@ -25,31 +25,28 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
25
25
|
notes?: import("../../../modules/Order/types").SalesNote[] | undefined;
|
|
26
26
|
summary?: import("../../../modules/Order/types").OrderSummary | undefined;
|
|
27
27
|
small_ticket_data_flag?: number | undefined;
|
|
28
|
+
status: string;
|
|
28
29
|
metadata: Record<string, any>;
|
|
30
|
+
business_code?: string | undefined;
|
|
31
|
+
customer_id: number | null;
|
|
29
32
|
type: string;
|
|
30
|
-
note: string;
|
|
31
33
|
holder: Record<string, any> | null;
|
|
34
|
+
email: string;
|
|
35
|
+
phone: string;
|
|
36
|
+
note: string;
|
|
32
37
|
relation_forms: any[];
|
|
33
38
|
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
39
|
+
country_calling_code: string;
|
|
40
|
+
contacts_info: Record<string, any> | null;
|
|
34
41
|
order_id: number | null;
|
|
35
42
|
external_sale_number: string;
|
|
36
|
-
customer_id: number | null;
|
|
37
|
-
bookings: any[];
|
|
38
|
-
payments: any[];
|
|
39
43
|
order_number: string | null;
|
|
40
|
-
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
41
44
|
shop_order_number: string | null;
|
|
42
|
-
business_code?: string | undefined;
|
|
43
|
-
status: string;
|
|
44
|
-
schedule_date: string;
|
|
45
45
|
shop_full_order_number: string | null;
|
|
46
46
|
sales_channel: string;
|
|
47
47
|
order_sales_channel: string;
|
|
48
48
|
shipping_status: string;
|
|
49
49
|
customer_name: string;
|
|
50
|
-
country_calling_code: string;
|
|
51
|
-
phone: string;
|
|
52
|
-
email: string;
|
|
53
50
|
is_price_include_tax: number;
|
|
54
51
|
tax_title: string;
|
|
55
52
|
tax_country_code: string;
|
|
@@ -63,10 +60,13 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
63
60
|
buzzer?: string | undefined;
|
|
64
61
|
delivery_type?: string | undefined;
|
|
65
62
|
table_number?: Record<string, any> | undefined;
|
|
63
|
+
schedule_date: string;
|
|
64
|
+
bookings: any[];
|
|
65
|
+
payments: any[];
|
|
66
|
+
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
66
67
|
refunds?: any[] | undefined;
|
|
67
68
|
surcharges: any[];
|
|
68
69
|
contacts: any[];
|
|
69
|
-
contacts_info: Record<string, any> | null;
|
|
70
70
|
};
|
|
71
71
|
export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
|
|
72
72
|
schedule_event_id: any;
|
|
@@ -10,6 +10,8 @@ exports.CheckoutImpl = void 0;
|
|
|
10
10
|
var _BaseModule = require("../../modules/BaseModule");
|
|
11
11
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
12
12
|
var _Order = require("../../modules/Order");
|
|
13
|
+
var _bookingUuid = require("../../modules/Order/utils/bookingUuid");
|
|
14
|
+
var _orderCollectionIdentity = require("../../modules/Order/utils/orderCollectionIdentity");
|
|
13
15
|
var _Payment = require("../../modules/Payment");
|
|
14
16
|
var _types = require("./types");
|
|
15
17
|
Object.keys(_types).forEach(function (key) {
|
|
@@ -458,6 +460,7 @@ class CheckoutImpl extends _BaseModule.BaseModule {
|
|
|
458
460
|
params.orderData.tax_fee = params.totalInfo?.total?.tax;
|
|
459
461
|
|
|
460
462
|
// 保存原始订单数据和小计数据到状态中
|
|
463
|
+
params.orderData.bookings?.forEach(_bookingUuid.assignBookingUuid);
|
|
461
464
|
this.store.localOrderData = params.orderData;
|
|
462
465
|
this.store.cartSummary = params.cartSummary;
|
|
463
466
|
|
|
@@ -590,6 +593,24 @@ class CheckoutImpl extends _BaseModule.BaseModule {
|
|
|
590
593
|
// 保留原有支付项:通过 orderId 找到现有订单(按 id 或 order_id 匹配)
|
|
591
594
|
const allOrders = await this.payment.getOrderListAsync();
|
|
592
595
|
const existingOrder = allOrders.find(o => String(o.id) === String(params.orderId) || String(o.order_id) === String(params.orderId));
|
|
596
|
+
|
|
597
|
+
// POS 再次保存会重建预约行;按已有行标识复用上次保存的 UUID。
|
|
598
|
+
const previousBookings = existingOrder?.order_info?.original_order_data?.bookings;
|
|
599
|
+
const previousUuids = new Map();
|
|
600
|
+
if (Array.isArray(previousBookings)) {
|
|
601
|
+
for (const booking of previousBookings) {
|
|
602
|
+
const uid = (0, _orderCollectionIdentity.getOrderCollectionUid)('booking', booking);
|
|
603
|
+
if (uid && booking.uuid !== undefined) previousUuids.set(uid, booking.uuid);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
for (const booking of params.orderData.bookings || []) {
|
|
607
|
+
const uid = (0, _orderCollectionIdentity.getOrderCollectionUid)('booking', booking);
|
|
608
|
+
if (uid && previousUuids.has(uid)) {
|
|
609
|
+
booking.uuid ?? (booking.uuid = previousUuids.get(uid));
|
|
610
|
+
previousUuids.delete(uid);
|
|
611
|
+
}
|
|
612
|
+
(0, _bookingUuid.assignBookingUuid)(booking);
|
|
613
|
+
}
|
|
593
614
|
if (existingOrder) {
|
|
594
615
|
// 🔧 新增: 如果传入了 existPayment,需要更新支付项列表
|
|
595
616
|
if (params.existPayment && params.existPayment.length > 0) {
|
|
@@ -876,10 +876,16 @@ class ScanOrderImpl extends _BaseSales.BaseSalesImpl {
|
|
|
876
876
|
const bookingCapacityDimensionId = (0, _utils.pickFirstCustomCapacityDimensionId)(this.enabledReservationRuleProducts) ?? 0;
|
|
877
877
|
let bookings = payload.bookings || [];
|
|
878
878
|
if (!tempOrder.order_id && bookings.length === 0) {
|
|
879
|
+
const extend = tempOrder._extend ?? (tempOrder._extend = {});
|
|
880
|
+
if (!extend.scanOrderBookingUuid) {
|
|
881
|
+
extend.scanOrderBookingUuid = (0, _utils2.createUuidV4)();
|
|
882
|
+
this.store.order?.persistTempOrder?.();
|
|
883
|
+
}
|
|
879
884
|
const bookingStart = (0, _dayjs.default)(now);
|
|
880
885
|
const bookingDuration = (0, _utils2.resolveTableOccupancyDuration)(tempOrder);
|
|
881
886
|
const bookingEnd = bookingStart.add(bookingDuration, 'minute');
|
|
882
887
|
bookings = [(0, _utils2.normalizeSubmitBooking)({
|
|
888
|
+
uuid: extend.scanOrderBookingUuid,
|
|
883
889
|
relation_id: 0,
|
|
884
890
|
form_id: 0,
|
|
885
891
|
start_time: bookingStart.format('HH:mm'),
|
|
@@ -38,6 +38,7 @@ var _smartPricing = require("./utils/smartPricing");
|
|
|
38
38
|
var _slotMerge = require("./utils/slotMerge");
|
|
39
39
|
var _utils3 = require("../../modules/Order/utils");
|
|
40
40
|
var _Order = require("../../modules/Order");
|
|
41
|
+
var _bookingUuid = require("../../modules/Order/utils/bookingUuid");
|
|
41
42
|
var _types4 = require("../RegisterAndLogin/types");
|
|
42
43
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
43
44
|
var _Holder = require("../../modules/Holder");
|
|
@@ -1197,6 +1198,7 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1197
1198
|
if (!mapping) return;
|
|
1198
1199
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
1199
1200
|
const matchesCurrent = (meta, pid) => !!meta?.venue_booking && String(meta?.resource_id) === String(resourceId) && Number(pid) === Number(productId);
|
|
1201
|
+
const previousBookings = (tempOrder.bookings || []).filter(row => row.uuid && matchesCurrent(row.metadata, row.metadata?.product_id ?? row.product?.product_id));
|
|
1200
1202
|
tempOrder.products = tempOrder.products.filter(p => !matchesCurrent(p.metadata, p.product_id));
|
|
1201
1203
|
tempOrder.bookings = (tempOrder.bookings || []).filter(b => {
|
|
1202
1204
|
if (!b.metadata?.venue_booking) return true;
|
|
@@ -1332,7 +1334,10 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1332
1334
|
productUid,
|
|
1333
1335
|
childResources: childRawResources
|
|
1334
1336
|
});
|
|
1335
|
-
|
|
1337
|
+
// A resized or split interval can reuse its original UUID once.
|
|
1338
|
+
const original = previousBookings.findIndex(row => `${row.start_date} ${String(row.start_time).slice(0, 5)}` < group.endTime && `${row.end_date} ${String(row.end_time).slice(0, 5)}` > group.startTime);
|
|
1339
|
+
if (original >= 0) booking.uuid = previousBookings.splice(original, 1)[0].uuid;
|
|
1340
|
+
tempOrder.bookings.push((0, _bookingUuid.ensureBookingUuid)(booking));
|
|
1336
1341
|
}
|
|
1337
1342
|
|
|
1338
1343
|
// 获取表单信息
|