@pisell/pisellos 2.3.207 → 2.3.208
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/Order/index.d.ts +1 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BaseSales/index.d.ts +2 -0
- package/dist/solution/BaseSales/index.js +65 -37
- package/dist/solution/BaseSales/types.d.ts +2 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingTicket/index.d.ts +7 -0
- package/dist/solution/BookingTicket/index.js +448 -323
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BaseSales/index.d.ts +2 -0
- package/lib/solution/BaseSales/index.js +27 -6
- package/lib/solution/BaseSales/types.d.ts +2 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingTicket/index.d.ts +7 -0
- package/lib/solution/BookingTicket/index.js +50 -4
- package/package.json +1 -1
|
@@ -640,7 +640,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
640
640
|
generateIdempotencyToken(): string;
|
|
641
641
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
642
642
|
createOrder(params: CommitOrderParams['query']): {
|
|
643
|
-
type: "
|
|
643
|
+
type: "virtual" | "appointment_booking";
|
|
644
644
|
platform: string;
|
|
645
645
|
sales_channel: string;
|
|
646
646
|
order_sales_channel: string;
|
|
@@ -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(): "normal" | "
|
|
52
|
+
getProductType(): "normal" | "session" | "duration";
|
|
53
53
|
}
|
|
@@ -55,6 +55,8 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
55
55
|
protected store: BaseSalesState;
|
|
56
56
|
protected otherParams: Record<string, any>;
|
|
57
57
|
getInventory(): InventoryController | undefined;
|
|
58
|
+
/** Retail and standard POS opt in per sales instance; other hosts retain their member flow. */
|
|
59
|
+
isMemberCartConsistencyEnabled(): boolean;
|
|
58
60
|
prepareCheckout(signal?: AbortSignal): Promise<CheckoutRuntimeSnapshot | undefined>;
|
|
59
61
|
protected cacheId: string | undefined;
|
|
60
62
|
/**
|
|
@@ -23,6 +23,7 @@ Object.keys(_types).forEach(function (key) {
|
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
25
|
var _Order = require("../../modules/Order");
|
|
26
|
+
var _discountProductLineIdentity = require("../../modules/Order/utils/discountProductLineIdentity");
|
|
26
27
|
var _pickupTiming = require("../../modules/Order/pickupTiming");
|
|
27
28
|
var _pickupTiming2 = require("./pickupTiming");
|
|
28
29
|
var _fulfillmentItemRules = require("./fulfillmentItemRules");
|
|
@@ -156,6 +157,14 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
|
|
|
156
157
|
return previous && isBaseSalesManualProductDiscountProduct(previous) ? previous : product;
|
|
157
158
|
});
|
|
158
159
|
}
|
|
160
|
+
|
|
161
|
+
/** Rules may split a coupon quantity into rows that still share the original UID. */
|
|
162
|
+
function applyDiscountProductLines(tempOrder, products, discounts, enableMemberCartConsistency) {
|
|
163
|
+
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, products);
|
|
164
|
+
if (!enableMemberCartConsistency) return;
|
|
165
|
+
(0, _discountProductLineIdentity.ensureUniqueProductLineUids)(tempOrder, discounts);
|
|
166
|
+
(0, _discountProductLineIdentity.consolidateDiscountFreeProductLines)(tempOrder);
|
|
167
|
+
}
|
|
159
168
|
function isBaseSalesHistoricalDiscountEntry(discount) {
|
|
160
169
|
return Boolean(discount?.isEditMode || discount?.isDisabled || discount?.order_discount_id != null);
|
|
161
170
|
}
|
|
@@ -517,6 +526,11 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
517
526
|
getInventory() {
|
|
518
527
|
return this.otherParams.inventory;
|
|
519
528
|
}
|
|
529
|
+
|
|
530
|
+
/** Retail and standard POS opt in per sales instance; other hosts retain their member flow. */
|
|
531
|
+
isMemberCartConsistencyEnabled() {
|
|
532
|
+
return this.otherParams.enableMemberCartConsistency === true;
|
|
533
|
+
}
|
|
520
534
|
async prepareCheckout(signal) {
|
|
521
535
|
const inventory = this.getInventory();
|
|
522
536
|
const hooks = this.otherParams.checkoutHooks;
|
|
@@ -2316,7 +2330,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2316
2330
|
}
|
|
2317
2331
|
async loadDiscountConfig(params) {
|
|
2318
2332
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2319
|
-
|
|
2333
|
+
let tempOrder = this.store.order.ensureTempOrder();
|
|
2320
2334
|
const orderStore = this.store.order.store || {};
|
|
2321
2335
|
const discountModule = orderStore.discount;
|
|
2322
2336
|
const rulesModule = orderStore.rules;
|
|
@@ -2331,7 +2345,11 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2331
2345
|
let requestEpoch = this.store.order.getCustomerWalletPrepareConfigEpoch?.();
|
|
2332
2346
|
const isCurrentRequest = () => {
|
|
2333
2347
|
const currentTempOrder = this.store.order?.getTempOrder?.();
|
|
2334
|
-
|
|
2348
|
+
const current = Boolean(currentTempOrder && (requestEpoch === undefined || this.store.order?.getCustomerWalletPrepareConfigEpoch?.() === requestEpoch) && this.resolveDiscountConfigCustomerId(currentTempOrder) === customerId && this.getDiscountConfigOrderIdentityKey(currentTempOrder) === requestOrderIdentityKey);
|
|
2349
|
+
// Cart edits can replace the object while member configuration is pending.
|
|
2350
|
+
// Keep the logical-order guard, but apply coupons to its latest rows.
|
|
2351
|
+
if (current && this.isMemberCartConsistencyEnabled()) tempOrder = currentTempOrder;
|
|
2352
|
+
return current;
|
|
2335
2353
|
};
|
|
2336
2354
|
const getCurrentResult = () => {
|
|
2337
2355
|
const currentTempOrder = this.store.order?.getTempOrder?.();
|
|
@@ -2460,7 +2478,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2460
2478
|
discountList: nextDiscountList
|
|
2461
2479
|
};
|
|
2462
2480
|
if (result.productList) {
|
|
2463
|
-
tempOrder
|
|
2481
|
+
applyDiscountProductLines(tempOrder, result.productList, result.discountList || nextDiscountList, this.isMemberCartConsistencyEnabled());
|
|
2464
2482
|
}
|
|
2465
2483
|
for (const product of tempOrder.products || []) {
|
|
2466
2484
|
const productUid = product.metadata?.unique_identification_number;
|
|
@@ -2553,7 +2571,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2553
2571
|
preserveEntitlementSelection: false
|
|
2554
2572
|
}) || result;
|
|
2555
2573
|
if (result.productList) {
|
|
2556
|
-
tempOrder
|
|
2574
|
+
applyDiscountProductLines(tempOrder, result.productList, result.discountList || nextDiscountList, this.isMemberCartConsistencyEnabled());
|
|
2557
2575
|
}
|
|
2558
2576
|
if (result.discountList) {
|
|
2559
2577
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
@@ -2679,7 +2697,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2679
2697
|
discountList: updated
|
|
2680
2698
|
};
|
|
2681
2699
|
if (result?.productList) {
|
|
2682
|
-
tempOrder
|
|
2700
|
+
applyDiscountProductLines(tempOrder, result.productList, result.discountList || updated, this.isMemberCartConsistencyEnabled());
|
|
2683
2701
|
}
|
|
2684
2702
|
if (result?.discountList) {
|
|
2685
2703
|
nextDiscountList = result.discountList;
|
|
@@ -2767,7 +2785,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2767
2785
|
const orderStore = this.store.order.store || {};
|
|
2768
2786
|
const discountModule = orderStore.discount;
|
|
2769
2787
|
if (result.productList) {
|
|
2770
|
-
tempOrder.
|
|
2788
|
+
applyDiscountProductLines(tempOrder, result.productList, result.discountList || this.getDiscountList(), this.isMemberCartConsistencyEnabled());
|
|
2771
2789
|
}
|
|
2772
2790
|
if (result.discountList) {
|
|
2773
2791
|
_Order.OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
|
|
@@ -4407,6 +4425,9 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
4407
4425
|
const currentOrderCustomerId = this.getCurrentOrderCustomerId();
|
|
4408
4426
|
const resolvedChannels = paramsList.map(params => this.getPriceQueryChannel(params.channel));
|
|
4409
4427
|
const authoritativeProducts = await this.resolveProductBookingPriceGroups(paramsList, currentOrderCustomerId);
|
|
4428
|
+
if (paramsList.some((params, index) => params.requireAuthoritativePrice && !authoritativeProducts[index])) {
|
|
4429
|
+
throw new Error('The current customer product price is unavailable. Please retry before paying.');
|
|
4430
|
+
}
|
|
4410
4431
|
const plans = paramsList.map((params, index) => {
|
|
4411
4432
|
if (!isPos) return null;
|
|
4412
4433
|
const product = authoritativeProducts[index];
|
|
@@ -305,6 +305,8 @@ export interface BaseSalesQuotationDurationConfig {
|
|
|
305
305
|
}
|
|
306
306
|
export interface BaseSalesCalculateProductBookingPriceParams {
|
|
307
307
|
product: Record<string, any>;
|
|
308
|
+
/** Fail closed when the current customer price cannot be resolved; no old-line fallback. */
|
|
309
|
+
requireAuthoritativePrice?: boolean;
|
|
308
310
|
booking?: {
|
|
309
311
|
start_date?: string;
|
|
310
312
|
start_time?: string;
|
|
@@ -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 | 2 | 1 |
|
|
345
|
+
weekNum: 0 | 2 | 1 | 3 | 5 | 4 | 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<"normal" | "
|
|
392
|
+
getProductTypeById(id: number): Promise<"normal" | "session" | "duration">;
|
|
393
393
|
/**
|
|
394
394
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
395
395
|
*
|
|
@@ -32,6 +32,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
32
32
|
private orderCustomerDiscountRefreshCustomerId;
|
|
33
33
|
private orderCustomerDiscountRefreshTarget;
|
|
34
34
|
private orderCustomerPromotionRefreshInFlight;
|
|
35
|
+
private orderCustomerRefreshTask;
|
|
36
|
+
private orderCustomerRefreshRevision;
|
|
35
37
|
private orderCustomerContactRequest;
|
|
36
38
|
private readonly customerResolveRequests;
|
|
37
39
|
protected loadOpenDataInFlight: Promise<OpenDataConfig> | null;
|
|
@@ -283,6 +285,9 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
283
285
|
setOrderCustomer(customer: ICustomer | null, options?: {
|
|
284
286
|
source?: OrderCustomerChangePayload['source'];
|
|
285
287
|
}): void;
|
|
288
|
+
/** Shared by customer changes and an explicit retry; keep the selected customer/cart intact. */
|
|
289
|
+
private refreshMemberCartContext;
|
|
290
|
+
retryOrderCustomerRefresh(): Promise<void>;
|
|
286
291
|
private resetOrderCustomerContactInfo;
|
|
287
292
|
/** Explicit edits, including clearing the contact, must win over a pending default. */
|
|
288
293
|
updateTempOrderContactsInfo(contact: Record<string, any> | null): Record<string, any> | null;
|
|
@@ -321,6 +326,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
321
326
|
private buildOrderCustomerPayload;
|
|
322
327
|
protected refreshDiscountConfigAfterOrderCustomerChange(customerId: number | null): Promise<void>;
|
|
323
328
|
protected waitForOrderCustomerPromotionRefresh(): Promise<void>;
|
|
329
|
+
/** Wait before reading cart rows: member coupons can split or consolidate them. */
|
|
330
|
+
waitForOrderCustomerRefresh(): Promise<void>;
|
|
324
331
|
protected prepareProductPriceQueryContext(customerId?: number | string): Promise<void>;
|
|
325
332
|
protected preferAuthoritativeProductQueryPrice(): boolean;
|
|
326
333
|
/**
|
|
@@ -167,6 +167,9 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
167
167
|
orderCustomerDiscountRefreshCustomerId = null;
|
|
168
168
|
orderCustomerDiscountRefreshTarget = null;
|
|
169
169
|
orderCustomerPromotionRefreshInFlight = null;
|
|
170
|
+
// Retain the settled result too: a failed refresh must remain observable by checkout callers.
|
|
171
|
+
orderCustomerRefreshTask = Promise.resolve();
|
|
172
|
+
orderCustomerRefreshRevision = 0;
|
|
170
173
|
orderCustomerContactRequest = null;
|
|
171
174
|
customerResolveRequests = new Map();
|
|
172
175
|
loadOpenDataInFlight = null;
|
|
@@ -1082,13 +1085,17 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1082
1085
|
}
|
|
1083
1086
|
return;
|
|
1084
1087
|
}
|
|
1088
|
+
const enableMemberCartConsistency = this.isMemberCartConsistencyEnabled();
|
|
1085
1089
|
const next = this.buildOrderCustomerPayload();
|
|
1086
1090
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next && options?.source ? {
|
|
1087
1091
|
...next,
|
|
1088
1092
|
source: options.source
|
|
1089
1093
|
} : next);
|
|
1090
|
-
|
|
1091
|
-
|
|
1094
|
+
if (enableMemberCartConsistency) {
|
|
1095
|
+
this.refreshMemberCartContext(patch.customer_id);
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
void this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
|
|
1092
1099
|
const promotionRefreshTask = this.store.order.applyPromotion().then(() => undefined);
|
|
1093
1100
|
this.orderCustomerPromotionRefreshInFlight = promotionRefreshTask;
|
|
1094
1101
|
void promotionRefreshTask.then(() => {
|
|
@@ -1100,6 +1107,31 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1100
1107
|
this.orderCustomerPromotionRefreshInFlight = null;
|
|
1101
1108
|
});
|
|
1102
1109
|
}
|
|
1110
|
+
|
|
1111
|
+
/** Shared by customer changes and an explicit retry; keep the selected customer/cart intact. */
|
|
1112
|
+
refreshMemberCartContext(customerId) {
|
|
1113
|
+
const revision = ++this.orderCustomerRefreshRevision;
|
|
1114
|
+
const orderKey = this.getCustomerContactOrderKey();
|
|
1115
|
+
const isCurrent = () => revision === this.orderCustomerRefreshRevision && this.getCustomerContactOrderKey() === orderKey && Number(this.store.order.getOrderCustomer()?.customer_id || 0) === Number(customerId || 0);
|
|
1116
|
+
const task = (async () => {
|
|
1117
|
+
if (customerId) await this.refreshDiscountConfigAfterOrderCustomerChange(customerId);else await this.loadDiscountConfig({
|
|
1118
|
+
force: true
|
|
1119
|
+
});
|
|
1120
|
+
if (isCurrent()) await this.store.order.applyPromotion();
|
|
1121
|
+
})();
|
|
1122
|
+
this.orderCustomerRefreshTask = task;
|
|
1123
|
+
this.orderCustomerPromotionRefreshInFlight = task;
|
|
1124
|
+
void task.catch(error => {
|
|
1125
|
+
if (isCurrent()) console.error('[BookingTicket] Member cart refresh failed', error);
|
|
1126
|
+
}).finally(() => {
|
|
1127
|
+
if (this.orderCustomerPromotionRefreshInFlight === task) this.orderCustomerPromotionRefreshInFlight = null;
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
async retryOrderCustomerRefresh() {
|
|
1131
|
+
if (!this.isMemberCartConsistencyEnabled()) return;
|
|
1132
|
+
this.refreshMemberCartContext(this.store.order.getOrderCustomer()?.customer_id ?? null);
|
|
1133
|
+
await this.waitForOrderCustomerRefresh();
|
|
1134
|
+
}
|
|
1103
1135
|
resetOrderCustomerContactInfo() {
|
|
1104
1136
|
this.orderCustomerContactRequest = null;
|
|
1105
1137
|
const order = this.getTempOrder();
|
|
@@ -1218,6 +1250,8 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1218
1250
|
* 清空下单客户(协议字段 + snapshot)。
|
|
1219
1251
|
*/
|
|
1220
1252
|
clearOrderCustomer(options) {
|
|
1253
|
+
const enableMemberCartConsistency = this.isMemberCartConsistencyEnabled();
|
|
1254
|
+
const refreshRevision = enableMemberCartConsistency ? ++this.orderCustomerRefreshRevision : undefined;
|
|
1221
1255
|
this.orderCustomerContactRequest = null;
|
|
1222
1256
|
if (!options?.preserveContactInfo) this.resetOrderCustomerContactInfo();
|
|
1223
1257
|
if (!options?.preserveContactInfo) this.store.order.updateTempOrderContactsInfo(null);
|
|
@@ -1229,9 +1263,11 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1229
1263
|
void discountModule?.setOriginalDiscountList?.([]);
|
|
1230
1264
|
void discountModule?.setDiscountList?.([]);
|
|
1231
1265
|
this.store.order.applyDiscount();
|
|
1232
|
-
|
|
1266
|
+
const customerOrderKey = enableMemberCartConsistency ? this.getCustomerContactOrderKey() : undefined;
|
|
1267
|
+
const refreshTask = this.store.order.recalculateSummary({
|
|
1233
1268
|
createIfMissing: true
|
|
1234
1269
|
}).then(() => {
|
|
1270
|
+
if (enableMemberCartConsistency && (this.orderCustomerRefreshRevision !== refreshRevision || this.getCustomerContactOrderKey() !== customerOrderKey)) return;
|
|
1235
1271
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
1236
1272
|
this.store.order.persistTempOrder();
|
|
1237
1273
|
return this.effectsEmit('onDiscountApplied', {
|
|
@@ -1240,7 +1276,9 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1240
1276
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
1241
1277
|
tempOrder
|
|
1242
1278
|
});
|
|
1243
|
-
})
|
|
1279
|
+
});
|
|
1280
|
+
if (enableMemberCartConsistency) this.orderCustomerRefreshTask = refreshTask.then(() => undefined);
|
|
1281
|
+
void (enableMemberCartConsistency ? this.orderCustomerRefreshTask : refreshTask).catch(error => {
|
|
1244
1282
|
console.error('Failed to recalculate summary after clearing customer:', error);
|
|
1245
1283
|
});
|
|
1246
1284
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
|
|
@@ -1324,6 +1362,14 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1324
1362
|
waitForOrderCustomerPromotionRefresh() {
|
|
1325
1363
|
return this.orderCustomerPromotionRefreshInFlight || Promise.resolve();
|
|
1326
1364
|
}
|
|
1365
|
+
|
|
1366
|
+
/** Wait before reading cart rows: member coupons can split or consolidate them. */
|
|
1367
|
+
async waitForOrderCustomerRefresh() {
|
|
1368
|
+
if (!this.isMemberCartConsistencyEnabled()) return;
|
|
1369
|
+
// Customer-change listeners run synchronously before setOrderCustomer assigns its task.
|
|
1370
|
+
await Promise.resolve();
|
|
1371
|
+
await this.orderCustomerRefreshTask;
|
|
1372
|
+
}
|
|
1327
1373
|
async prepareProductPriceQueryContext(customerId) {
|
|
1328
1374
|
// onOrderCustomerChange 的订阅回调会立即开始重报价,而客户 Wallet/优惠资产
|
|
1329
1375
|
// 在事件派发后才创建异步刷新任务。先让出一个微任务,确保能观察到该任务。
|