@pisell/pisellos 2.3.226 → 2.3.227
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/modules/Customer/types.d.ts +0 -4
- package/dist/modules/Order/index.d.ts +3 -1
- package/dist/modules/Order/index.js +82 -125
- package/dist/modules/Order/types.d.ts +0 -2
- package/dist/modules/Order/utils.js +0 -2
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.js +1 -1
- package/dist/modules/Rules/types.d.ts +2 -0
- package/dist/modules/Summary/utils.d.ts +1 -1
- package/dist/solution/BaseSales/index.js +0 -3
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/utils/redeemArrival.d.ts +13 -13
- package/dist/solution/Checkout/index.js +69 -104
- package/dist/solution/Checkout/types.d.ts +0 -1
- package/dist/solution/ScanOrder/index.js +2 -10
- package/dist/solution/UnifiedBookingSales/draftDiscounts.d.ts +8 -0
- package/dist/solution/UnifiedBookingSales/draftDiscounts.js +101 -0
- package/dist/solution/UnifiedBookingSales/index.d.ts +7 -0
- package/dist/solution/UnifiedBookingSales/index.js +1253 -1072
- package/dist/solution/UnifiedBookingSales/types.d.ts +5 -0
- package/dist/solution/VenueBooking/index.js +490 -522
- package/lib/modules/Customer/types.d.ts +0 -4
- package/lib/modules/Order/index.d.ts +3 -1
- package/lib/modules/Order/index.js +9 -46
- package/lib/modules/Order/types.d.ts +0 -2
- package/lib/modules/Order/utils.js +1 -5
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.js +1 -1
- package/lib/modules/Rules/types.d.ts +2 -0
- package/lib/modules/Summary/utils.d.ts +1 -1
- package/lib/solution/BaseSales/index.js +0 -3
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/utils/redeemArrival.d.ts +13 -13
- package/lib/solution/Checkout/index.js +0 -21
- package/lib/solution/Checkout/types.d.ts +0 -1
- package/lib/solution/ScanOrder/index.js +0 -6
- package/lib/solution/UnifiedBookingSales/draftDiscounts.d.ts +8 -0
- package/lib/solution/UnifiedBookingSales/draftDiscounts.js +36 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +7 -0
- package/lib/solution/UnifiedBookingSales/index.js +78 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +5 -0
- package/lib/solution/VenueBooking/index.js +1 -6
- package/package.json +1 -1
- package/dist/modules/Order/utils/bookingUuid.d.ts +0 -4
- package/dist/modules/Order/utils/bookingUuid.js +0 -24
- package/lib/modules/Order/utils/bookingUuid.d.ts +0 -4
- package/lib/modules/Order/utils/bookingUuid.js +0 -25
|
@@ -44,10 +44,6 @@ 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;
|
|
51
47
|
/** 关联查询参数 */
|
|
52
48
|
with?: CustomerWith[];
|
|
53
49
|
/** wallet搜索标识 */
|
|
@@ -131,6 +131,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
131
131
|
scannedDiscountList?: Discount[];
|
|
132
132
|
}>;
|
|
133
133
|
applyDiscount(options?: {
|
|
134
|
+
/** Draft recovery must remove stale discounts even when no card survives revalidation. */
|
|
135
|
+
force?: boolean;
|
|
134
136
|
reapplyBookingDiscountProductUids?: string[];
|
|
135
137
|
reapplyWeighedDiscountProductUids?: string[];
|
|
136
138
|
preferredEntitlementPassIds?: number[];
|
|
@@ -642,7 +644,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
642
644
|
generateIdempotencyToken(): string;
|
|
643
645
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
644
646
|
createOrder(params: CommitOrderParams['query']): {
|
|
645
|
-
type: "
|
|
647
|
+
type: "virtual" | "appointment_booking";
|
|
646
648
|
platform: string;
|
|
647
649
|
sales_channel: string;
|
|
648
650
|
order_sales_channel: string;
|
|
@@ -11,7 +11,6 @@ Object.defineProperty(exports, "isFulfillmentTimingBooking", {
|
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
var _loadSalesOrderSnapshot = require("../../shared/sales/loadSalesOrderSnapshot");
|
|
14
|
-
var _bookingUuid = require("./utils/bookingUuid");
|
|
15
14
|
var _localEftposState = require("./localEftposState");
|
|
16
15
|
var _BaseModule = require("../BaseModule");
|
|
17
16
|
var _types = require("./types");
|
|
@@ -945,7 +944,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
945
944
|
delete tempOrder.discount_list;
|
|
946
945
|
const discountList = this.store.discount?.getDiscountList() || [];
|
|
947
946
|
const shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
948
|
-
if (shouldSkipDiscountCalculation) return;
|
|
947
|
+
if (shouldSkipDiscountCalculation && !options?.force) return;
|
|
949
948
|
const rulesModule = this.store.rules;
|
|
950
949
|
if (!rulesModule) return;
|
|
951
950
|
const result = rulesModule.calcDiscount({
|
|
@@ -957,7 +956,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
957
956
|
}, {
|
|
958
957
|
reapplyBookingDiscountProductUids: options?.reapplyBookingDiscountProductUids,
|
|
959
958
|
reapplyWeighedDiscountProductUids: options?.reapplyWeighedDiscountProductUids,
|
|
960
|
-
preferredEntitlementPassIds: options?.preferredEntitlementPassIds
|
|
959
|
+
preferredEntitlementPassIds: options?.preferredEntitlementPassIds,
|
|
960
|
+
force: options?.force
|
|
961
961
|
});
|
|
962
962
|
if (result?.productList) {
|
|
963
963
|
const previousProductsByUid = (0, _utils.indexOrderProductsByUid)(tempOrder.products);
|
|
@@ -2585,7 +2585,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
2585
2585
|
booking_uid: bookingUid
|
|
2586
2586
|
},
|
|
2587
2587
|
booking: {
|
|
2588
|
-
...
|
|
2588
|
+
...params.booking,
|
|
2589
2589
|
is_all: (0, _utils.normalizeBookingIsAll)(params.booking),
|
|
2590
2590
|
product_uid: productUid,
|
|
2591
2591
|
sub_type: (0, _utils.normalizeBookingSubType)(params.booking),
|
|
@@ -3200,7 +3200,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3200
3200
|
const tempOrder = this.ensureTempOrder();
|
|
3201
3201
|
const bookings = tempOrder.bookings || [];
|
|
3202
3202
|
const firstIndex = bookings.findIndex(_pickupTiming.isFulfillmentTimingBooking);
|
|
3203
|
-
const nextBooking = (0,
|
|
3203
|
+
const nextBooking = (0, _pickupTiming.buildPickupTimingBooking)(input, bookings[firstIndex]);
|
|
3204
3204
|
// Keep the first row's identity and position; repair duplicate marked rows only.
|
|
3205
3205
|
tempOrder.bookings = firstIndex === -1 ? [...bookings, nextBooking] : bookings.flatMap((booking, index) => index === firstIndex ? [nextBooking] : (0, _pickupTiming.isFulfillmentTimingBooking)(booking) ? [] : [booking]);
|
|
3206
3206
|
this.notifyTempOrderChanged();
|
|
@@ -3852,16 +3852,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
3852
3852
|
* if (pending) await pending;
|
|
3853
3853
|
*/
|
|
3854
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
|
-
}
|
|
3865
3855
|
const linked = booking ? this.createLinkedProductAndBooking({
|
|
3866
3856
|
product,
|
|
3867
3857
|
booking
|
|
@@ -4026,12 +4016,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4026
4016
|
singleLine.num = 1;
|
|
4027
4017
|
delete singleLine.product_quantity;
|
|
4028
4018
|
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
|
-
}
|
|
4035
4019
|
const bookingHolder = booking?.holder && typeof booking.holder === 'object' ? booking.holder : null;
|
|
4036
4020
|
const metadataHolder = booking?.metadata?.holder && typeof booking.metadata.holder === 'object' ? booking.metadata.holder : null;
|
|
4037
4021
|
const rawHolderIds = bookingHolder?.form_record ?? booking?.metadata?.holder_id ?? metadataHolder?.form_record ?? product?.metadata?.holder_id;
|
|
@@ -4282,8 +4266,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4282
4266
|
const target = live.products[targetIndex];
|
|
4283
4267
|
const scopeKey = String(target?.metadata?.venue_booking_scope_key || '');
|
|
4284
4268
|
const targetBookingUid = String(target?.booking_uid || target?.metadata?.booking_uid || '');
|
|
4285
|
-
|
|
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
|
+
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 || (live.bookings || []).filter(booking => this.getBookingUniqueIdentificationNumber(booking) === targetBookingUid).length !== 1 || live.products.filter(line => line.metadata?.venue_booking_role === 'party_main' && line.metadata?.venue_booking_scope_key === scopeKey).length !== 1) {
|
|
4287
4270
|
throw new Error('[Order] Party replacement requires one unsubmitted, unpaid main booking in the same scope');
|
|
4288
4271
|
}
|
|
4289
4272
|
const children = live.products.filter(line => line.metadata?.venue_booking_role === 'party_extra' && String(line.metadata?.venue_booking_parent_uid || '') === uid);
|
|
@@ -4343,9 +4326,7 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4343
4326
|
venue_booking_service_datetime: serviceDatetime
|
|
4344
4327
|
};
|
|
4345
4328
|
replacement.unique_identification_number = uid;
|
|
4346
|
-
|
|
4347
|
-
replacementBooking.uuid = targetBookings[0].uuid || replacementBooking.uuid;
|
|
4348
|
-
await this.appendProductLineToTempOrder(draft, replacement, replacementBooking, {
|
|
4329
|
+
await this.appendProductLineToTempOrder(draft, replacement, (0, _lodashEs.cloneDeep)(params.booking), {
|
|
4349
4330
|
insertAtIndex: targetIndex,
|
|
4350
4331
|
disableMerge: true,
|
|
4351
4332
|
beforeCommit
|
|
@@ -4753,22 +4734,12 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
4753
4734
|
...(normalizedProduct.metadata || {}),
|
|
4754
4735
|
unique_identification_number: productUid
|
|
4755
4736
|
};
|
|
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;
|
|
4763
4737
|
const linked = this.createLinkedProductAndBooking({
|
|
4764
4738
|
product: {
|
|
4765
4739
|
...normalizedProduct,
|
|
4766
4740
|
unique_identification_number: productUid
|
|
4767
4741
|
},
|
|
4768
|
-
booking
|
|
4769
|
-
...booking,
|
|
4770
|
-
uuid: originalBooking?.uuid || incomingUuid
|
|
4771
|
-
}
|
|
4742
|
+
booking
|
|
4772
4743
|
});
|
|
4773
4744
|
this.removeLinkedBookingsForProduct(tempOrder, targetProduct);
|
|
4774
4745
|
normalizedProduct = {
|
|
@@ -5030,13 +5001,9 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5030
5001
|
throw new Error('[Order] 目标 booking 不存在,无法更新');
|
|
5031
5002
|
}
|
|
5032
5003
|
const targetBooking = tempOrder.bookings[bookingIndex] || {};
|
|
5033
|
-
const {
|
|
5034
|
-
uuid: incomingUuid = targetBooking.uuid
|
|
5035
|
-
} = updates;
|
|
5036
5004
|
const nextBooking = {
|
|
5037
5005
|
...targetBooking,
|
|
5038
5006
|
...updates,
|
|
5039
|
-
uuid: targetBooking.uuid || incomingUuid,
|
|
5040
5007
|
metadata: {
|
|
5041
5008
|
...(targetBooking.metadata || {}),
|
|
5042
5009
|
...(updates.metadata || {}),
|
|
@@ -5046,7 +5013,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5046
5013
|
unique_identification_number: bookingUid
|
|
5047
5014
|
}
|
|
5048
5015
|
};
|
|
5049
|
-
(0, _bookingUuid.assignBookingUuid)(nextBooking);
|
|
5050
5016
|
this.syncBookingMetadataHolder(nextBooking, nextBooking.metadata);
|
|
5051
5017
|
nextBooking.is_all = (0, _utils.normalizeBookingIsAll)(nextBooking);
|
|
5052
5018
|
nextBooking.sub_type = (0, _utils.normalizeBookingSubType)(nextBooking);
|
|
@@ -5747,7 +5713,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5747
5713
|
* @returns 后端返回的订单数据(包含订单ID等)
|
|
5748
5714
|
*/
|
|
5749
5715
|
async createOrderByCheckout(params) {
|
|
5750
|
-
params.bookings?.forEach(_bookingUuid.assignBookingUuid);
|
|
5751
5716
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5752
5717
|
const onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
5753
5718
|
params.payments = params.payments?.filter(p => !onlineStorePaymentCodeList.includes(p.code));
|
|
@@ -5835,7 +5800,6 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
5835
5800
|
url,
|
|
5836
5801
|
query
|
|
5837
5802
|
} = params;
|
|
5838
|
-
query.bookings?.forEach(_bookingUuid.assignBookingUuid);
|
|
5839
5803
|
const fetchUrl = url || '/order/sales/checkout';
|
|
5840
5804
|
const handledByOsServer = this.isSalesCheckoutHandledByOsServer(fetchUrl);
|
|
5841
5805
|
const requestQuery = handledByOsServer ? query : (0, _localEftposState.stripLocalEftposState)((0, _osPrivatePayload.stripOsPrivatePayloadFields)(query));
|
|
@@ -6190,9 +6154,8 @@ class OrderModule extends _BaseModule.BaseModule {
|
|
|
6190
6154
|
})) : [];
|
|
6191
6155
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(b => {
|
|
6192
6156
|
const booking = this.normalizeHydratedBookingHolder(b || {});
|
|
6193
|
-
const submitted = (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0;
|
|
6194
6157
|
return {
|
|
6195
|
-
...
|
|
6158
|
+
...booking,
|
|
6196
6159
|
is_all: (0, _utils.normalizeBookingIsAll)(booking),
|
|
6197
6160
|
sub_type: (0, _utils.normalizeBookingSubType)(booking)
|
|
6198
6161
|
};
|
|
@@ -617,8 +617,6 @@ 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;
|
|
622
620
|
relation_id?: string;
|
|
623
621
|
form_id?: string;
|
|
624
622
|
collect_pax?: number;
|
|
@@ -140,7 +140,6 @@ 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");
|
|
144
143
|
var _salesNotes = require("./salesNotes");
|
|
145
144
|
var _pickupTiming = require("./pickupTiming");
|
|
146
145
|
var _holderRelations = require("./holderRelations");
|
|
@@ -1665,10 +1664,7 @@ function buildSubmitPayload(params) {
|
|
|
1665
1664
|
delivery_type: tempOrder.delivery_type || 'shop_service',
|
|
1666
1665
|
schedule_date: scheduleDate,
|
|
1667
1666
|
// created_at: tempOrder.created_at || formatDateTime(now), 和后端协定这个字段先不提交到接口
|
|
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
|
-
}),
|
|
1667
|
+
bookings: (tempOrder.bookings || []).filter(booking => (0, _pickupTiming.isFulfillmentTimingBooking)(booking) || Number(booking.parent_id) !== 0).map(booking => normalizeSubmitBooking(booking)),
|
|
1672
1668
|
payments: tempOrder.payments || [],
|
|
1673
1669
|
relation_forms: tempOrder.relation_forms || [],
|
|
1674
1670
|
// 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(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -307,7 +307,7 @@ class RulesModule extends _BaseModule.BaseModule {
|
|
|
307
307
|
}
|
|
308
308
|
});
|
|
309
309
|
}
|
|
310
|
-
const hasDiscountInput = editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options?.discountId) || Boolean(options?.selectedList?.length) || Boolean(options?.scan);
|
|
310
|
+
const hasDiscountInput = options?.force === true || editModeDiscount.length > 0 || addModeDiscount.length > 0 || Boolean(options?.discountId) || Boolean(options?.selectedList?.length) || Boolean(options?.scan);
|
|
311
311
|
if (!hasDiscountInput) {
|
|
312
312
|
return {
|
|
313
313
|
discountList,
|
|
@@ -34,6 +34,8 @@ export interface RulesCalcDiscountParams {
|
|
|
34
34
|
orderTotalAmount: number;
|
|
35
35
|
}
|
|
36
36
|
export interface RulesCalcDiscountOptions {
|
|
37
|
+
/** Clear stale line discounts when draft revalidation yields no eligible cards. */
|
|
38
|
+
force?: boolean;
|
|
37
39
|
isSelected?: boolean;
|
|
38
40
|
discountId?: number;
|
|
39
41
|
selectedList?: SetDiscountSelectedParams[];
|
|
@@ -72,7 +72,7 @@ export declare const calculateOriginSubtotal: (items: CartItem[]) => string;
|
|
|
72
72
|
* @return {*}
|
|
73
73
|
* @Author: xiangfeng.xue
|
|
74
74
|
*/
|
|
75
|
-
export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) =>
|
|
75
|
+
export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => "0.00" | Decimal;
|
|
76
76
|
/**
|
|
77
77
|
* @title: 计算定金
|
|
78
78
|
* @param items - 购物车商品数组
|
|
@@ -223,9 +223,6 @@ 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
|
-
}
|
|
229
226
|
const persistentIdField = BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND[kind];
|
|
230
227
|
if (isBaseSalesBlankValue(mergedItem[persistentIdField]) && !isBaseSalesBlankValue(identityMergedItem[persistentIdField])) {
|
|
231
228
|
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 | 1 | 2 | 5 | 4 | 3 | 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<"normal" | "duration" | "session">;
|
|
393
393
|
/**
|
|
394
394
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
395
395
|
*
|
|
@@ -25,19 +25,19 @@ 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
|
-
|
|
28
|
+
type: string;
|
|
29
29
|
metadata: Record<string, any>;
|
|
30
30
|
business_code?: string | undefined;
|
|
31
|
-
|
|
32
|
-
type: string;
|
|
33
|
-
holder: Record<string, any> | null;
|
|
34
|
-
email: string;
|
|
35
|
-
phone: string;
|
|
31
|
+
status: string;
|
|
36
32
|
note: string;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
holder: Record<string, any> | null;
|
|
34
|
+
customer_id: number | null;
|
|
35
|
+
bookings: any[];
|
|
36
|
+
payments: any[];
|
|
40
37
|
contacts_info: Record<string, any> | null;
|
|
38
|
+
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
39
|
+
refunds?: any[] | undefined;
|
|
40
|
+
holder_relations?: import("../../../modules/Order/types").OrderHolderRelation[] | undefined;
|
|
41
41
|
order_id: number | null;
|
|
42
42
|
external_sale_number: string;
|
|
43
43
|
order_number: string | null;
|
|
@@ -47,6 +47,9 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
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;
|
|
50
53
|
is_price_include_tax: number;
|
|
51
54
|
tax_title: string;
|
|
52
55
|
tax_country_code: string;
|
|
@@ -61,11 +64,8 @@ export declare function buildArrivalCheckoutQuery(order: OrderTempOrder, summary
|
|
|
61
64
|
delivery_type?: string | undefined;
|
|
62
65
|
table_number?: Record<string, any> | undefined;
|
|
63
66
|
schedule_date: string;
|
|
64
|
-
bookings: any[];
|
|
65
|
-
payments: any[];
|
|
66
|
-
order_meta_list?: import("../../../modules/Order/types").OrderMetaList | undefined;
|
|
67
|
-
refunds?: any[] | undefined;
|
|
68
67
|
surcharges: any[];
|
|
68
|
+
relation_forms: any[];
|
|
69
69
|
contacts: any[];
|
|
70
70
|
};
|
|
71
71
|
export declare function describeChangedBookings(before: OrderTempOrder['bookings'], after: OrderTempOrder['bookings']): {
|
|
@@ -10,8 +10,6 @@ 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");
|
|
15
13
|
var _Payment = require("../../modules/Payment");
|
|
16
14
|
var _types = require("./types");
|
|
17
15
|
Object.keys(_types).forEach(function (key) {
|
|
@@ -460,7 +458,6 @@ class CheckoutImpl extends _BaseModule.BaseModule {
|
|
|
460
458
|
params.orderData.tax_fee = params.totalInfo?.total?.tax;
|
|
461
459
|
|
|
462
460
|
// 保存原始订单数据和小计数据到状态中
|
|
463
|
-
params.orderData.bookings?.forEach(_bookingUuid.assignBookingUuid);
|
|
464
461
|
this.store.localOrderData = params.orderData;
|
|
465
462
|
this.store.cartSummary = params.cartSummary;
|
|
466
463
|
|
|
@@ -593,24 +590,6 @@ class CheckoutImpl extends _BaseModule.BaseModule {
|
|
|
593
590
|
// 保留原有支付项:通过 orderId 找到现有订单(按 id 或 order_id 匹配)
|
|
594
591
|
const allOrders = await this.payment.getOrderListAsync();
|
|
595
592
|
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
|
-
}
|
|
614
593
|
if (existingOrder) {
|
|
615
594
|
// 🔧 新增: 如果传入了 existPayment,需要更新支付项列表
|
|
616
595
|
if (params.existPayment && params.existPayment.length > 0) {
|
|
@@ -876,16 +876,10 @@ 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
|
-
}
|
|
884
879
|
const bookingStart = (0, _dayjs.default)(now);
|
|
885
880
|
const bookingDuration = (0, _utils2.resolveTableOccupancyDuration)(tempOrder);
|
|
886
881
|
const bookingEnd = bookingStart.add(bookingDuration, 'minute');
|
|
887
882
|
bookings = [(0, _utils2.normalizeSubmitBooking)({
|
|
888
|
-
uuid: extend.scanOrderBookingUuid,
|
|
889
883
|
relation_id: 0,
|
|
890
884
|
form_id: 0,
|
|
891
885
|
start_time: bookingStart.format('HH:mm'),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Persist selection intent only; availability and pricing must come from fresh OS data. */
|
|
2
|
+
export interface DraftDiscountSelection {
|
|
3
|
+
id: string;
|
|
4
|
+
code?: string;
|
|
5
|
+
selected: boolean;
|
|
6
|
+
isScan?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function collectDraftDiscountSelection(order: Record<string, any>, runtime?: Record<string, any>[]): DraftDiscountSelection[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.collectDraftDiscountSelection = collectDraftDiscountSelection;
|
|
7
|
+
/** Persist selection intent only; availability and pricing must come from fresh OS data. */
|
|
8
|
+
|
|
9
|
+
const voucherTypes = new Set(['discount_card', 'product_discount_card', 'good_pass', 'entitlement_pass']);
|
|
10
|
+
function collectDraftDiscountSelection(order, runtime) {
|
|
11
|
+
const selections = new Map();
|
|
12
|
+
const append = (discount, line = false) => {
|
|
13
|
+
if (!voucherTypes.has(discount?.tag || discount?.type) || discount.isEditMode) return;
|
|
14
|
+
const id = String(line ? discount.discount?.resource_id || discount.id || '' : discount.id || '');
|
|
15
|
+
if (!id || !Number.isFinite(Number(id)) || Number(id) <= 0) return;
|
|
16
|
+
const machineCode = discount.data?.discount_card_list?.[0] || discount.discount_card_list?.[0] || discount.machinecode || discount.machine_code || discount;
|
|
17
|
+
const code = machineCode.encoded || discount.metadata?.encoded;
|
|
18
|
+
const previous = selections.get(id);
|
|
19
|
+
selections.set(id, {
|
|
20
|
+
id,
|
|
21
|
+
code: typeof code === 'string' && code.trim() ? code.trim() : previous?.code,
|
|
22
|
+
selected: line || discount.isSelected !== false,
|
|
23
|
+
isScan: Boolean(discount.isScan || previous?.isScan)
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
// Old venue drafts may have lost the root list on reload, while line discounts retain the code.
|
|
27
|
+
for (const product of order.products || []) {
|
|
28
|
+
for (const discount of product.discount_list || []) append(discount, true);
|
|
29
|
+
for (const bundle of product.product_bundle || []) {
|
|
30
|
+
for (const discount of bundle.discount_list || []) append(discount, true);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
for (const discount of order.discount_list || []) append(discount);
|
|
34
|
+
for (const discount of runtime || []) append(discount);
|
|
35
|
+
return [...selections.values()];
|
|
36
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type DraftDiscountSelection } from './draftDiscounts';
|
|
1
2
|
import type { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
3
|
import type { ProductData } from '../../modules';
|
|
3
4
|
import type { BookingCalcContext } from '../../modules/BookingContext';
|
|
@@ -195,6 +196,12 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
195
196
|
protected getRegisteredModuleNames(): readonly string[];
|
|
196
197
|
protected createSubModule(moduleName: string): Module | null;
|
|
197
198
|
addNewOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
199
|
+
getDraftDiscountSelection(): DraftDiscountSelection[];
|
|
200
|
+
/** Restore a local draft's cards as editable runtime entries, never as settled historical cards. */
|
|
201
|
+
restoreDraftDiscountSelection(snapshot: {
|
|
202
|
+
order: Record<string, any>;
|
|
203
|
+
discountSelection?: DraftDiscountSelection[];
|
|
204
|
+
}): Promise<void>;
|
|
198
205
|
syncAuthenticatedOrderCustomer(): Promise<boolean>;
|
|
199
206
|
private isAuthenticatedCustomerUserPlatform;
|
|
200
207
|
private resolveDiscountOrderIdentity;
|
|
@@ -31,6 +31,7 @@ exports.collectAvailabilityResourceIds = collectAvailabilityResourceIds;
|
|
|
31
31
|
exports.normalizeProductForAvailability = normalizeProductForAvailability;
|
|
32
32
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
33
33
|
var _lodashEs = require("lodash-es");
|
|
34
|
+
var _draftDiscounts = require("./draftDiscounts");
|
|
34
35
|
var _modules = require("../../modules");
|
|
35
36
|
var _pickupTiming = require("../../modules/Order/pickupTiming");
|
|
36
37
|
var _cacheItemToBookingInput = require("../../modules/BookingContext/utils/cacheItemToBookingInput");
|
|
@@ -2097,6 +2098,83 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
2097
2098
|
}
|
|
2098
2099
|
return this.store.order?.getTempOrder() || tempOrder;
|
|
2099
2100
|
}
|
|
2101
|
+
getDraftDiscountSelection() {
|
|
2102
|
+
const order = this.getTempOrder();
|
|
2103
|
+
return order ? (0, _draftDiscounts.collectDraftDiscountSelection)(order, this.getDiscountList()) : [];
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
/** Restore a local draft's cards as editable runtime entries, never as settled historical cards. */
|
|
2107
|
+
async restoreDraftDiscountSelection(snapshot) {
|
|
2108
|
+
const order = this.getTempOrder();
|
|
2109
|
+
if (!order || order.order_id && !isLocalOrderId(order.order_id)) return;
|
|
2110
|
+
const customerId = resolveTempOrderCustomerId(order);
|
|
2111
|
+
// A login/account change must not replay another customer's saved cards.
|
|
2112
|
+
if (resolveTempOrderCustomerId(snapshot.order) !== customerId) return;
|
|
2113
|
+
if (snapshot.order.external_sale_number !== order.external_sale_number) return;
|
|
2114
|
+
const selections = snapshot.discountSelection ?? (0, _draftDiscounts.collectDraftDiscountSelection)(snapshot.order);
|
|
2115
|
+
if (!selections.length) return;
|
|
2116
|
+
const beforeCommit = this.store.order.createCartIntentCommitGuard('scan_promotion', order);
|
|
2117
|
+
const assertCurrent = () => {
|
|
2118
|
+
if (this.getTempOrder() !== order || resolveTempOrderCustomerId(this.getTempOrder()) !== customerId) {
|
|
2119
|
+
throw Object.assign(new Error('The draft discount session ended.'), {
|
|
2120
|
+
code: 'SALES_GUARD_REJECTED'
|
|
2121
|
+
});
|
|
2122
|
+
}
|
|
2123
|
+
};
|
|
2124
|
+
assertCurrent();
|
|
2125
|
+
const discountModule = this.store.order.store.discount;
|
|
2126
|
+
const current = this.getDiscountList();
|
|
2127
|
+
const currentById = new Map(current.map(discount => [String(discount.id), discount]));
|
|
2128
|
+
const codes = [...new Set(selections.filter(selection => selection.code && (selection.isScan || !currentById.has(String(selection.id)))).map(selection => selection.code))];
|
|
2129
|
+
// Scanned cards are absent from prepare/config. Re-query each unique code once;
|
|
2130
|
+
// copying their old config would keep expired cards and stale eligibility alive.
|
|
2131
|
+
const results = await Promise.all(codes.map(code => discountModule.batchSearch(code, {
|
|
2132
|
+
customerId: customerId || undefined
|
|
2133
|
+
})));
|
|
2134
|
+
assertCurrent();
|
|
2135
|
+
const scanned = new Map();
|
|
2136
|
+
for (const result of results) {
|
|
2137
|
+
for (const discount of result.discountList || []) scanned.set(String(discount.id), discount);
|
|
2138
|
+
}
|
|
2139
|
+
const next = new Map(this.getDiscountList().map(discount => [String(discount.id), discount]));
|
|
2140
|
+
for (const selection of selections) {
|
|
2141
|
+
const id = String(selection.id);
|
|
2142
|
+
const revalidated = selection.code && (selection.isScan || !currentById.has(id));
|
|
2143
|
+
const discount = revalidated ? scanned.get(id) : next.get(id);
|
|
2144
|
+
if (!discount) {
|
|
2145
|
+
next.delete(id);
|
|
2146
|
+
continue;
|
|
2147
|
+
}
|
|
2148
|
+
next.set(id, {
|
|
2149
|
+
...discount,
|
|
2150
|
+
isScan: Boolean(selection.isScan || revalidated),
|
|
2151
|
+
isSelected: selection.selected,
|
|
2152
|
+
isManualSelect: !selection.selected
|
|
2153
|
+
});
|
|
2154
|
+
}
|
|
2155
|
+
beforeCommit();
|
|
2156
|
+
await discountModule.setOriginalDiscountList([...next.values()]);
|
|
2157
|
+
assertCurrent();
|
|
2158
|
+
await discountModule.setDiscountList([...next.values()]);
|
|
2159
|
+
assertCurrent();
|
|
2160
|
+
// One calculation owns both the displayed cards and the restored line prices.
|
|
2161
|
+
this.store.order.applyDiscount({
|
|
2162
|
+
force: true
|
|
2163
|
+
});
|
|
2164
|
+
await this.store.order.recalculateSummary({
|
|
2165
|
+
createIfMissing: true
|
|
2166
|
+
});
|
|
2167
|
+
assertCurrent();
|
|
2168
|
+
const restored = this.store.order.ensureTempOrder();
|
|
2169
|
+
restored.discount_list = this.getDiscountList().filter(discount => discount.isSelected);
|
|
2170
|
+
this.store.order.persistTempOrder();
|
|
2171
|
+
await this.effectsEmit('onDiscountApplied', {
|
|
2172
|
+
productList: restored.products || [],
|
|
2173
|
+
discountList: this.getDiscountList(),
|
|
2174
|
+
selectedDiscountList: restored.discount_list,
|
|
2175
|
+
tempOrder: restored
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2100
2178
|
async syncAuthenticatedOrderCustomer() {
|
|
2101
2179
|
if (!this.isAuthenticatedCustomerUserPlatform()) return false;
|
|
2102
2180
|
const authenticatedCustomer = this.core?.getPlugin?.('user')?.get?.();
|
|
@@ -302,6 +302,11 @@ export interface UnifiedBookingSalesDiscountResult {
|
|
|
302
302
|
summaryAfter?: unknown;
|
|
303
303
|
}
|
|
304
304
|
export interface UnifiedBookingSalesApi {
|
|
305
|
+
getDraftDiscountSelection: () => import('./draftDiscounts').DraftDiscountSelection[];
|
|
306
|
+
restoreDraftDiscountSelection: (snapshot: {
|
|
307
|
+
order: Record<string, any>;
|
|
308
|
+
discountSelection?: import('./draftDiscounts').DraftDiscountSelection[];
|
|
309
|
+
}) => Promise<void>;
|
|
305
310
|
/** Uses cached business settings and evaluates the current store-local clock. */
|
|
306
311
|
getBusinessAvailability: () => Promise<import('../../modules/BusinessAvailability').BusinessAvailability>;
|
|
307
312
|
loadOpenData: (params: UnifiedBookingSalesLoadOpenDataParams) => Promise<OpenDataConfig>;
|
|
@@ -38,7 +38,6 @@ 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");
|
|
42
41
|
var _types4 = require("../RegisterAndLogin/types");
|
|
43
42
|
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
44
43
|
var _Holder = require("../../modules/Holder");
|
|
@@ -1198,7 +1197,6 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1198
1197
|
if (!mapping) return;
|
|
1199
1198
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
1200
1199
|
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));
|
|
1202
1200
|
tempOrder.products = tempOrder.products.filter(p => !matchesCurrent(p.metadata, p.product_id));
|
|
1203
1201
|
tempOrder.bookings = (tempOrder.bookings || []).filter(b => {
|
|
1204
1202
|
if (!b.metadata?.venue_booking) return true;
|
|
@@ -1334,10 +1332,7 @@ class VenueBookingImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1334
1332
|
productUid,
|
|
1335
1333
|
childResources: childRawResources
|
|
1336
1334
|
});
|
|
1337
|
-
|
|
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));
|
|
1335
|
+
tempOrder.bookings.push(booking);
|
|
1341
1336
|
}
|
|
1342
1337
|
|
|
1343
1338
|
// 获取表单信息
|
package/package.json
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
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;
|