@pisell/pisellos 2.3.152 → 2.3.154
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/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.js +820 -658
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.js +72 -1
- package/package.json +1 -1
|
@@ -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";
|
|
@@ -595,7 +595,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
595
595
|
generateIdempotencyToken(): string;
|
|
596
596
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
597
597
|
createOrder(params: CommitOrderParams['query']): {
|
|
598
|
-
type: "
|
|
598
|
+
type: "virtual" | "appointment_booking";
|
|
599
599
|
platform: string;
|
|
600
600
|
sales_channel: string;
|
|
601
601
|
order_sales_channel: string;
|
|
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
328
328
|
date: string;
|
|
329
329
|
status: string;
|
|
330
330
|
week: string;
|
|
331
|
-
weekNum: 0 |
|
|
331
|
+
weekNum: 0 | 1 | 2 | 3 | 5 | 4 | 6;
|
|
332
332
|
}[]>;
|
|
333
333
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
334
334
|
private getScheduleDataByIds;
|
|
@@ -147,6 +147,8 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
147
147
|
* 用于支付跳转等终态场景,避免浏览器返回时恢复已提交订单。
|
|
148
148
|
*/
|
|
149
149
|
clearSessionStorageOrderSnapshot(): void;
|
|
150
|
+
/** 在 Kiosk 拉起支付设备前补齐订单号,同一订单重试复用已分配的号码。 */
|
|
151
|
+
ensureLocalOrderNumbersForCheckout(): Promise<void>;
|
|
150
152
|
/**
|
|
151
153
|
* PC/H5/Kiosk 结账默认直接等待云端 checkout;POS/WebPOS 仍保持本地待同步。
|
|
152
154
|
* 显式传 checkoutSyncTaskEnabled: true 时仍可回退到本地同步模式。
|
|
@@ -276,6 +278,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
276
278
|
private assertAvailabilityCommitWriteCAS;
|
|
277
279
|
private findProductLineByUid;
|
|
278
280
|
private findLinkedBooking;
|
|
281
|
+
removeBookingProductsOutsideStartDate(startDate: unknown): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
279
282
|
/** Revalidates against the latest landed occupancy cache, then mutates exactly one product line. */
|
|
280
283
|
commitAvailabilitySelection(contextId: string, params: ContextualCommitAvailabilitySelectionParams): Promise<UnifiedBookingSalesCommitAvailabilitySelectionResult>;
|
|
281
284
|
}
|
|
@@ -32,6 +32,7 @@ exports.normalizeProductForAvailability = normalizeProductForAvailability;
|
|
|
32
32
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
33
33
|
var _lodashEs = require("lodash-es");
|
|
34
34
|
var _modules = require("../../modules");
|
|
35
|
+
var _pickupTiming = require("../../modules/Order/pickupTiming");
|
|
35
36
|
var _utils = require("../../modules/BookingContext/utils");
|
|
36
37
|
var _cacheItemToBookingInput = require("../../modules/BookingContext/utils/cacheItemToBookingInput");
|
|
37
38
|
var _OpenData = require("../../modules/OpenData");
|
|
@@ -866,6 +867,20 @@ function collectAvailabilityResourceIds(products, explicitResourceIds = []) {
|
|
|
866
867
|
function getProductLineUid(product) {
|
|
867
868
|
return String(product?.metadata?.unique_identification_number ?? product?.unique_identification_number ?? '');
|
|
868
869
|
}
|
|
870
|
+
function getVisibleCalendarDate(value) {
|
|
871
|
+
if (typeof value !== 'string') return null;
|
|
872
|
+
const raw = value.trim();
|
|
873
|
+
try {
|
|
874
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(raw)) {
|
|
875
|
+
(0, _localClock.parseLocalDate)(raw);
|
|
876
|
+
} else {
|
|
877
|
+
(0, _localClock.parseLocalDateTime)(raw);
|
|
878
|
+
}
|
|
879
|
+
return raw.slice(0, 10);
|
|
880
|
+
} catch (_error) {
|
|
881
|
+
return null;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
869
884
|
function buildAvailabilityLineIdentity(product) {
|
|
870
885
|
return {
|
|
871
886
|
product_id: product.product_id,
|
|
@@ -1676,6 +1691,42 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
1676
1691
|
this.store.order?.clearSessionStoragePersistedTempOrder?.();
|
|
1677
1692
|
}
|
|
1678
1693
|
|
|
1694
|
+
/** 在 Kiosk 拉起支付设备前补齐订单号,同一订单重试复用已分配的号码。 */
|
|
1695
|
+
async ensureLocalOrderNumbersForCheckout() {
|
|
1696
|
+
if ((0, _platform.normalizeRuntimePlatform)(this.otherParams?.platform) !== 'kiosk') return;
|
|
1697
|
+
const order = this.store.order;
|
|
1698
|
+
const tempOrder = order?.getTempOrder();
|
|
1699
|
+
if (!tempOrder) throw new Error('当前订单不存在,无法生成订单编号');
|
|
1700
|
+
if (tempOrder.shop_order_number && tempOrder.shop_full_order_number) return;
|
|
1701
|
+
const biz = this.getBookingTicketBusinessCode();
|
|
1702
|
+
if (!biz) throw new Error('当前订单缺少业务类型,无法生成订单编号');
|
|
1703
|
+
const idGenerator = this.appPlugin?.getApp?.()?.getPlugin?.('idGenerator');
|
|
1704
|
+
if (!tempOrder.shop_order_number && typeof idGenerator?.generateShopOrderNumber !== 'function' || !tempOrder.shop_full_order_number && typeof idGenerator?.generateReceiptId !== 'function') {
|
|
1705
|
+
throw new Error('订单编号生成器不可用,请重启应用后重试');
|
|
1706
|
+
}
|
|
1707
|
+
try {
|
|
1708
|
+
if (!tempOrder.shop_order_number) {
|
|
1709
|
+
tempOrder.shop_order_number = await idGenerator.generateShopOrderNumber({
|
|
1710
|
+
biz
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
if (!tempOrder.shop_full_order_number) {
|
|
1714
|
+
tempOrder.shop_full_order_number = await idGenerator.generateReceiptId({
|
|
1715
|
+
biz
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
if (order.getTempOrder() !== tempOrder) {
|
|
1719
|
+
throw new Error('当前订单已切换,请重新发起支付');
|
|
1720
|
+
}
|
|
1721
|
+
if (!tempOrder.shop_order_number || !tempOrder.shop_full_order_number) {
|
|
1722
|
+
throw new Error('订单编号生成失败,请重试');
|
|
1723
|
+
}
|
|
1724
|
+
} finally {
|
|
1725
|
+
// 部分生成成功时也保留号码,后续只补仍然缺失的字段。
|
|
1726
|
+
if (order.getTempOrder() === tempOrder) order.persistTempOrder();
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1679
1730
|
/**
|
|
1680
1731
|
* PC/H5/Kiosk 结账默认直接等待云端 checkout;POS/WebPOS 仍保持本地待同步。
|
|
1681
1732
|
* 显式传 checkoutSyncTaskEnabled: true 时仍可回退到本地同步模式。
|
|
@@ -3351,6 +3402,24 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3351
3402
|
const bookingUid = String(product.booking_uid ?? product.metadata?.booking_uid ?? '');
|
|
3352
3403
|
return (this.getTempOrder()?.bookings || []).find(booking => bookingUid && getBookingUid(booking) === bookingUid || productUid && String(booking.product_uid ?? '') === productUid);
|
|
3353
3404
|
}
|
|
3405
|
+
async removeBookingProductsOutsideStartDate(startDate) {
|
|
3406
|
+
const products = this.getTempOrder()?.products || [];
|
|
3407
|
+
if (this.otherParams?.enforceSingleBookingStartDate !== true) {
|
|
3408
|
+
return products;
|
|
3409
|
+
}
|
|
3410
|
+
const targetDate = getVisibleCalendarDate(startDate);
|
|
3411
|
+
if (!targetDate) return products;
|
|
3412
|
+
const identities = products.flatMap(product => {
|
|
3413
|
+
if (!getProductLineUid(product) || product?.metadata?.product_add_schedule_time != null) {
|
|
3414
|
+
return [];
|
|
3415
|
+
}
|
|
3416
|
+
const booking = this.findLinkedBooking(product);
|
|
3417
|
+
if (!booking || (0, _pickupTiming.isFulfillmentTimingBooking)(booking)) return [];
|
|
3418
|
+
const bookingDate = getVisibleCalendarDate(booking.start_date);
|
|
3419
|
+
return bookingDate && bookingDate !== targetDate ? [buildAvailabilityLineIdentity(product)] : [];
|
|
3420
|
+
});
|
|
3421
|
+
return identities.length ? this.removeProductsFromOrder(identities) : products;
|
|
3422
|
+
}
|
|
3354
3423
|
|
|
3355
3424
|
/** Revalidates against the latest landed occupancy cache, then mutates exactly one product line. */
|
|
3356
3425
|
async commitAvailabilitySelection(contextId, params) {
|
|
@@ -3761,6 +3830,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3761
3830
|
allow_booking_discount_reapply: params.allowBookingDiscountReapply
|
|
3762
3831
|
} : {})
|
|
3763
3832
|
});
|
|
3833
|
+
await this.removeBookingProductsOutsideStartDate(booking.start_date);
|
|
3764
3834
|
productLineUid = params.productLineUid;
|
|
3765
3835
|
bookingUid = existingBookingUid;
|
|
3766
3836
|
productLineUids = [productLineUid];
|
|
@@ -3769,7 +3839,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3769
3839
|
const beforeProductLineUids = new Set((this.getTempOrder()?.products || []).map(line => getProductLineUid(line)).filter(Boolean));
|
|
3770
3840
|
const beforeBookingUids = new Set((this.getTempOrder()?.bookings || []).map(item => getBookingUid(item)).filter(Boolean));
|
|
3771
3841
|
availabilityCommitGuard?.();
|
|
3772
|
-
|
|
3842
|
+
let products = await this.addProductToOrder(transformed, booking, params.salesNotes?.length || availabilityCommitGuard ? {
|
|
3773
3843
|
...(params.salesNotes?.length ? {
|
|
3774
3844
|
salesNotes: params.salesNotes
|
|
3775
3845
|
} : {}),
|
|
@@ -3778,6 +3848,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3778
3848
|
availabilityCommitTargetGuard
|
|
3779
3849
|
} : {})
|
|
3780
3850
|
} : undefined);
|
|
3851
|
+
products = await this.removeBookingProductsOutsideStartDate(booking.start_date);
|
|
3781
3852
|
guardedCommitPublished = hasCommitGuard;
|
|
3782
3853
|
const addedLines = products.filter(line => sameAvailabilityId(line.product_id ?? line.id, refreshedCandidate.productId) && line.metadata?.availability_candidate_key === refreshedCandidate.key && !beforeProductLineUids.has(getProductLineUid(line)));
|
|
3783
3854
|
productLineUids = addedLines.map(line => getProductLineUid(line)).filter(Boolean);
|