@pisell/pisellos 2.3.208 → 2.3.209
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/promotion/index.js +0 -9
- package/dist/solution/BaseSales/index.d.ts +0 -2
- package/dist/solution/BaseSales/index.js +37 -65
- package/dist/solution/BaseSales/types.d.ts +0 -2
- package/dist/solution/BookingTicket/index.d.ts +0 -7
- package/dist/solution/BookingTicket/index.js +323 -448
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/solution/BaseSales/index.d.ts +0 -2
- package/lib/solution/BaseSales/index.js +6 -27
- package/lib/solution/BaseSales/types.d.ts +0 -2
- package/lib/solution/BookingTicket/index.d.ts +0 -7
- package/lib/solution/BookingTicket/index.js +4 -50
- package/package.json +1 -1
|
@@ -1 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
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; }
|
|
@@ -55,8 +55,6 @@ 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;
|
|
60
58
|
prepareCheckout(signal?: AbortSignal): Promise<CheckoutRuntimeSnapshot | undefined>;
|
|
61
59
|
protected cacheId: string | undefined;
|
|
62
60
|
/**
|
|
@@ -23,7 +23,6 @@ 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");
|
|
27
26
|
var _pickupTiming = require("../../modules/Order/pickupTiming");
|
|
28
27
|
var _pickupTiming2 = require("./pickupTiming");
|
|
29
28
|
var _fulfillmentItemRules = require("./fulfillmentItemRules");
|
|
@@ -157,14 +156,6 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
|
|
|
157
156
|
return previous && isBaseSalesManualProductDiscountProduct(previous) ? previous : product;
|
|
158
157
|
});
|
|
159
158
|
}
|
|
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
|
-
}
|
|
168
159
|
function isBaseSalesHistoricalDiscountEntry(discount) {
|
|
169
160
|
return Boolean(discount?.isEditMode || discount?.isDisabled || discount?.order_discount_id != null);
|
|
170
161
|
}
|
|
@@ -526,11 +517,6 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
526
517
|
getInventory() {
|
|
527
518
|
return this.otherParams.inventory;
|
|
528
519
|
}
|
|
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
|
-
}
|
|
534
520
|
async prepareCheckout(signal) {
|
|
535
521
|
const inventory = this.getInventory();
|
|
536
522
|
const hooks = this.otherParams.checkoutHooks;
|
|
@@ -2330,7 +2316,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2330
2316
|
}
|
|
2331
2317
|
async loadDiscountConfig(params) {
|
|
2332
2318
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
2333
|
-
|
|
2319
|
+
const tempOrder = this.store.order.ensureTempOrder();
|
|
2334
2320
|
const orderStore = this.store.order.store || {};
|
|
2335
2321
|
const discountModule = orderStore.discount;
|
|
2336
2322
|
const rulesModule = orderStore.rules;
|
|
@@ -2345,11 +2331,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2345
2331
|
let requestEpoch = this.store.order.getCustomerWalletPrepareConfigEpoch?.();
|
|
2346
2332
|
const isCurrentRequest = () => {
|
|
2347
2333
|
const currentTempOrder = this.store.order?.getTempOrder?.();
|
|
2348
|
-
|
|
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;
|
|
2334
|
+
return Boolean(currentTempOrder && (requestEpoch === undefined || this.store.order?.getCustomerWalletPrepareConfigEpoch?.() === requestEpoch) && this.resolveDiscountConfigCustomerId(currentTempOrder) === customerId && this.getDiscountConfigOrderIdentityKey(currentTempOrder) === requestOrderIdentityKey);
|
|
2353
2335
|
};
|
|
2354
2336
|
const getCurrentResult = () => {
|
|
2355
2337
|
const currentTempOrder = this.store.order?.getTempOrder?.();
|
|
@@ -2478,7 +2460,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2478
2460
|
discountList: nextDiscountList
|
|
2479
2461
|
};
|
|
2480
2462
|
if (result.productList) {
|
|
2481
|
-
|
|
2463
|
+
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2482
2464
|
}
|
|
2483
2465
|
for (const product of tempOrder.products || []) {
|
|
2484
2466
|
const productUid = product.metadata?.unique_identification_number;
|
|
@@ -2571,7 +2553,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2571
2553
|
preserveEntitlementSelection: false
|
|
2572
2554
|
}) || result;
|
|
2573
2555
|
if (result.productList) {
|
|
2574
|
-
|
|
2556
|
+
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2575
2557
|
}
|
|
2576
2558
|
if (result.discountList) {
|
|
2577
2559
|
nextDiscountList = this.mergeHistoricalDiscountList(result.discountList, tempOrder.products || []);
|
|
@@ -2697,7 +2679,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2697
2679
|
discountList: updated
|
|
2698
2680
|
};
|
|
2699
2681
|
if (result?.productList) {
|
|
2700
|
-
|
|
2682
|
+
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2701
2683
|
}
|
|
2702
2684
|
if (result?.discountList) {
|
|
2703
2685
|
nextDiscountList = result.discountList;
|
|
@@ -2785,7 +2767,7 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
2785
2767
|
const orderStore = this.store.order.store || {};
|
|
2786
2768
|
const discountModule = orderStore.discount;
|
|
2787
2769
|
if (result.productList) {
|
|
2788
|
-
|
|
2770
|
+
tempOrder.products = preserveManualProductDiscountProducts(tempOrder.products, result.productList);
|
|
2789
2771
|
}
|
|
2790
2772
|
if (result.discountList) {
|
|
2791
2773
|
_Order.OrderModule.populateSavedAmounts(tempOrder.products, result.discountList);
|
|
@@ -4425,9 +4407,6 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
4425
4407
|
const currentOrderCustomerId = this.getCurrentOrderCustomerId();
|
|
4426
4408
|
const resolvedChannels = paramsList.map(params => this.getPriceQueryChannel(params.channel));
|
|
4427
4409
|
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
|
-
}
|
|
4431
4410
|
const plans = paramsList.map((params, index) => {
|
|
4432
4411
|
if (!isPos) return null;
|
|
4433
4412
|
const product = authoritativeProducts[index];
|
|
@@ -305,8 +305,6 @@ 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;
|
|
310
308
|
booking?: {
|
|
311
309
|
start_date?: string;
|
|
312
310
|
start_time?: string;
|
|
@@ -32,8 +32,6 @@ 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;
|
|
37
35
|
private orderCustomerContactRequest;
|
|
38
36
|
private readonly customerResolveRequests;
|
|
39
37
|
protected loadOpenDataInFlight: Promise<OpenDataConfig> | null;
|
|
@@ -285,9 +283,6 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
285
283
|
setOrderCustomer(customer: ICustomer | null, options?: {
|
|
286
284
|
source?: OrderCustomerChangePayload['source'];
|
|
287
285
|
}): void;
|
|
288
|
-
/** Shared by customer changes and an explicit retry; keep the selected customer/cart intact. */
|
|
289
|
-
private refreshMemberCartContext;
|
|
290
|
-
retryOrderCustomerRefresh(): Promise<void>;
|
|
291
286
|
private resetOrderCustomerContactInfo;
|
|
292
287
|
/** Explicit edits, including clearing the contact, must win over a pending default. */
|
|
293
288
|
updateTempOrderContactsInfo(contact: Record<string, any> | null): Record<string, any> | null;
|
|
@@ -326,8 +321,6 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
326
321
|
private buildOrderCustomerPayload;
|
|
327
322
|
protected refreshDiscountConfigAfterOrderCustomerChange(customerId: number | null): Promise<void>;
|
|
328
323
|
protected waitForOrderCustomerPromotionRefresh(): Promise<void>;
|
|
329
|
-
/** Wait before reading cart rows: member coupons can split or consolidate them. */
|
|
330
|
-
waitForOrderCustomerRefresh(): Promise<void>;
|
|
331
324
|
protected prepareProductPriceQueryContext(customerId?: number | string): Promise<void>;
|
|
332
325
|
protected preferAuthoritativeProductQueryPrice(): boolean;
|
|
333
326
|
/**
|
|
@@ -167,9 +167,6 @@ 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;
|
|
173
170
|
orderCustomerContactRequest = null;
|
|
174
171
|
customerResolveRequests = new Map();
|
|
175
172
|
loadOpenDataInFlight = null;
|
|
@@ -1085,17 +1082,13 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1085
1082
|
}
|
|
1086
1083
|
return;
|
|
1087
1084
|
}
|
|
1088
|
-
const enableMemberCartConsistency = this.isMemberCartConsistencyEnabled();
|
|
1089
1085
|
const next = this.buildOrderCustomerPayload();
|
|
1090
1086
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next && options?.source ? {
|
|
1091
1087
|
...next,
|
|
1092
1088
|
source: options.source
|
|
1093
1089
|
} : next);
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
return;
|
|
1097
|
-
}
|
|
1098
|
-
void this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
|
|
1090
|
+
this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
|
|
1091
|
+
// 客户切换可能改变可用促销/赠品;触发一次重算(recursion-safe)。
|
|
1099
1092
|
const promotionRefreshTask = this.store.order.applyPromotion().then(() => undefined);
|
|
1100
1093
|
this.orderCustomerPromotionRefreshInFlight = promotionRefreshTask;
|
|
1101
1094
|
void promotionRefreshTask.then(() => {
|
|
@@ -1107,31 +1100,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1107
1100
|
this.orderCustomerPromotionRefreshInFlight = null;
|
|
1108
1101
|
});
|
|
1109
1102
|
}
|
|
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
|
-
}
|
|
1135
1103
|
resetOrderCustomerContactInfo() {
|
|
1136
1104
|
this.orderCustomerContactRequest = null;
|
|
1137
1105
|
const order = this.getTempOrder();
|
|
@@ -1250,8 +1218,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1250
1218
|
* 清空下单客户(协议字段 + snapshot)。
|
|
1251
1219
|
*/
|
|
1252
1220
|
clearOrderCustomer(options) {
|
|
1253
|
-
const enableMemberCartConsistency = this.isMemberCartConsistencyEnabled();
|
|
1254
|
-
const refreshRevision = enableMemberCartConsistency ? ++this.orderCustomerRefreshRevision : undefined;
|
|
1255
1221
|
this.orderCustomerContactRequest = null;
|
|
1256
1222
|
if (!options?.preserveContactInfo) this.resetOrderCustomerContactInfo();
|
|
1257
1223
|
if (!options?.preserveContactInfo) this.store.order.updateTempOrderContactsInfo(null);
|
|
@@ -1263,11 +1229,9 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1263
1229
|
void discountModule?.setOriginalDiscountList?.([]);
|
|
1264
1230
|
void discountModule?.setDiscountList?.([]);
|
|
1265
1231
|
this.store.order.applyDiscount();
|
|
1266
|
-
|
|
1267
|
-
const refreshTask = this.store.order.recalculateSummary({
|
|
1232
|
+
void this.store.order.recalculateSummary({
|
|
1268
1233
|
createIfMissing: true
|
|
1269
1234
|
}).then(() => {
|
|
1270
|
-
if (enableMemberCartConsistency && (this.orderCustomerRefreshRevision !== refreshRevision || this.getCustomerContactOrderKey() !== customerOrderKey)) return;
|
|
1271
1235
|
const tempOrder = this.store.order.ensureTempOrder();
|
|
1272
1236
|
this.store.order.persistTempOrder();
|
|
1273
1237
|
return this.effectsEmit('onDiscountApplied', {
|
|
@@ -1276,9 +1240,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1276
1240
|
selectedDiscountList: tempOrder.discount_list || [],
|
|
1277
1241
|
tempOrder
|
|
1278
1242
|
});
|
|
1279
|
-
})
|
|
1280
|
-
if (enableMemberCartConsistency) this.orderCustomerRefreshTask = refreshTask.then(() => undefined);
|
|
1281
|
-
void (enableMemberCartConsistency ? this.orderCustomerRefreshTask : refreshTask).catch(error => {
|
|
1243
|
+
}).catch(error => {
|
|
1282
1244
|
console.error('Failed to recalculate summary after clearing customer:', error);
|
|
1283
1245
|
});
|
|
1284
1246
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, null);
|
|
@@ -1362,14 +1324,6 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
|
|
|
1362
1324
|
waitForOrderCustomerPromotionRefresh() {
|
|
1363
1325
|
return this.orderCustomerPromotionRefreshInFlight || Promise.resolve();
|
|
1364
1326
|
}
|
|
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
|
-
}
|
|
1373
1327
|
async prepareProductPriceQueryContext(customerId) {
|
|
1374
1328
|
// onOrderCustomerChange 的订阅回调会立即开始重报价,而客户 Wallet/优惠资产
|
|
1375
1329
|
// 在事件派发后才创建异步刷新任务。先让出一个微任务,确保能观察到该任务。
|