@pisell/pisellos 2.2.277 → 2.2.279
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/modules/BaseModule.d.ts +1 -0
- package/dist/modules/BaseModule.js +24 -28
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +7 -3
- package/dist/modules/BookingContext/utils/productExtend.js +5 -9
- package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
- package/dist/modules/Customer/index.d.ts +4 -0
- package/dist/modules/Customer/index.js +91 -59
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Discount/index.d.ts +1 -0
- package/dist/modules/Discount/index.js +40 -11
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Holder/index.d.ts +48 -0
- package/dist/modules/Holder/index.js +640 -0
- package/dist/modules/Holder/types.d.ts +123 -0
- package/dist/modules/Holder/types.js +1 -0
- package/dist/modules/Holder/utils.d.ts +13 -0
- package/dist/modules/Holder/utils.js +34 -0
- package/dist/modules/OpenData/index.js +2 -2
- package/dist/modules/Order/index.d.ts +32 -4
- package/dist/modules/Order/index.js +868 -675
- package/dist/modules/Order/types.d.ts +22 -1
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +75 -0
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +71 -34
- package/dist/modules/Payment/index.d.ts +4 -0
- package/dist/modules/Payment/index.js +14 -4
- package/dist/modules/Payment/walletpass.js +48 -13
- package/dist/modules/Product/types.d.ts +1 -0
- package/dist/modules/ProductList/index.js +33 -13
- package/dist/modules/Quotation/index.d.ts +1 -1
- package/dist/modules/Quotation/index.js +2 -2
- package/dist/modules/ResourcePlanner/index.d.ts +24 -0
- package/dist/modules/ResourcePlanner/index.js +181 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
- package/dist/modules/ResourcePlanner/planner.js +1069 -0
- package/dist/modules/ResourcePlanner/types.d.ts +227 -0
- package/dist/modules/ResourcePlanner/types.js +1 -0
- package/dist/modules/Rules/index.js +153 -56
- package/dist/modules/SalesSummary/index.js +12 -13
- package/dist/modules/ScanOrderLogger/index.d.ts +2 -0
- package/dist/modules/ScanOrderLogger/index.js +15 -2
- package/dist/modules/ScanOrderLogger/providers/feishu.js +45 -27
- package/dist/modules/ScanOrderLogger/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +3 -1
- package/dist/modules/Schedule/index.js +21 -16
- package/dist/modules/Summary/utils.js +38 -13
- package/dist/modules/index.d.ts +2 -0
- package/dist/modules/index.js +3 -1
- package/dist/plugins/window.d.ts +1 -0
- package/dist/server/index.d.ts +20 -0
- package/dist/server/index.js +1101 -909
- package/dist/server/modules/order/index.d.ts +2 -0
- package/dist/server/modules/order/index.js +261 -96
- package/dist/server/modules/order/types.d.ts +1 -1
- package/dist/server/utils/small-ticket.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +10 -1
- package/dist/solution/BaseSales/index.js +201 -148
- package/dist/solution/BaseSales/utils/cartPromotion.js +19 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BaseSales/utils.js +31 -20
- package/dist/solution/BookingByStep/index.d.ts +16 -1
- package/dist/solution/BookingByStep/index.js +294 -215
- package/dist/solution/BookingByStep/types.d.ts +2 -1
- package/dist/solution/BookingByStep/types.js +3 -1
- package/dist/solution/BookingByStep/utils/capacity.js +17 -1
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/dist/solution/BookingByStep/utils/timeslots.js +19 -12
- package/dist/solution/BookingTicket/index.d.ts +6 -2
- package/dist/solution/BookingTicket/index.js +125 -77
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +10 -2
- package/dist/solution/ScanOrder/index.d.ts +26 -14
- package/dist/solution/ScanOrder/index.js +1142 -739
- package/dist/solution/ScanOrder/types.d.ts +21 -1
- package/dist/solution/ScanOrder/utils.d.ts +8 -0
- package/dist/solution/ScanOrder/utils.js +97 -45
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +125 -87
- package/dist/solution/UnifiedBookingSales/index.d.ts +204 -0
- package/dist/solution/UnifiedBookingSales/index.js +2211 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +150 -0
- package/dist/solution/UnifiedBookingSales/types.js +11 -0
- package/dist/solution/VenueBooking/index.d.ts +39 -11
- package/dist/solution/VenueBooking/index.js +1167 -841
- package/dist/solution/VenueBooking/types.d.ts +3 -0
- package/dist/solution/VenueBooking/utils/resource.js +1 -0
- package/dist/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/dist/solution/VenueBooking/utils/slotMerge.js +10 -5
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +2 -1
- package/dist/types/index.d.ts +1 -0
- package/lib/model/strategy/adapter/promotion/index.js +51 -0
- package/lib/modules/BaseModule.d.ts +1 -0
- package/lib/modules/BaseModule.js +24 -37
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -0
- package/lib/modules/BookingContext/utils/productExtend.js +4 -3
- package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
- package/lib/modules/Customer/index.d.ts +4 -0
- package/lib/modules/Customer/index.js +11 -0
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Discount/index.d.ts +1 -0
- package/lib/modules/Discount/index.js +9 -0
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Holder/index.d.ts +48 -0
- package/lib/modules/Holder/index.js +402 -0
- package/lib/modules/Holder/types.d.ts +123 -0
- package/lib/modules/Holder/types.js +17 -0
- package/lib/modules/Holder/utils.d.ts +13 -0
- package/lib/modules/Holder/utils.js +71 -0
- package/lib/modules/OpenData/index.js +1 -1
- package/lib/modules/Order/index.d.ts +32 -4
- package/lib/modules/Order/index.js +372 -156
- package/lib/modules/Order/types.d.ts +22 -1
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +70 -0
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +39 -6
- package/lib/modules/Payment/index.d.ts +4 -0
- package/lib/modules/Payment/index.js +7 -0
- package/lib/modules/Payment/walletpass.js +27 -1
- package/lib/modules/Product/types.d.ts +1 -0
- package/lib/modules/ProductList/index.js +49 -31
- package/lib/modules/Quotation/index.d.ts +1 -1
- package/lib/modules/Quotation/index.js +2 -2
- package/lib/modules/ResourcePlanner/index.d.ts +24 -0
- package/lib/modules/ResourcePlanner/index.js +148 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
- package/lib/modules/ResourcePlanner/planner.js +933 -0
- package/lib/modules/ResourcePlanner/types.d.ts +227 -0
- package/lib/modules/ResourcePlanner/types.js +17 -0
- package/lib/modules/Rules/index.js +117 -25
- package/lib/modules/SalesSummary/index.js +6 -7
- package/lib/modules/ScanOrderLogger/index.d.ts +2 -0
- package/lib/modules/ScanOrderLogger/index.js +13 -1
- package/lib/modules/ScanOrderLogger/providers/feishu.js +15 -6
- package/lib/modules/ScanOrderLogger/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +3 -1
- package/lib/modules/Schedule/index.js +10 -8
- package/lib/modules/Summary/utils.js +21 -1
- package/lib/modules/index.d.ts +2 -0
- package/lib/modules/index.js +5 -1
- package/lib/plugins/window.d.ts +1 -0
- package/lib/server/index.d.ts +20 -0
- package/lib/server/index.js +124 -19
- package/lib/server/modules/order/index.d.ts +2 -0
- package/lib/server/modules/order/index.js +75 -5
- package/lib/server/modules/order/types.d.ts +1 -1
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +10 -1
- package/lib/solution/BaseSales/index.js +73 -29
- package/lib/solution/BaseSales/utils/cartPromotion.js +18 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -0
- package/lib/solution/BaseSales/utils.js +29 -18
- package/lib/solution/BookingByStep/index.d.ts +16 -1
- package/lib/solution/BookingByStep/index.js +60 -18
- package/lib/solution/BookingByStep/types.d.ts +2 -1
- package/lib/solution/BookingByStep/types.js +5 -0
- package/lib/solution/BookingByStep/utils/capacity.js +20 -1
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +3 -1
- package/lib/solution/BookingByStep/utils/timeslots.js +19 -11
- package/lib/solution/BookingTicket/index.d.ts +6 -2
- package/lib/solution/BookingTicket/index.js +63 -16
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -2
- package/lib/solution/ScanOrder/index.d.ts +26 -14
- package/lib/solution/ScanOrder/index.js +449 -182
- package/lib/solution/ScanOrder/types.d.ts +21 -1
- package/lib/solution/ScanOrder/utils.d.ts +8 -0
- package/lib/solution/ScanOrder/utils.js +60 -18
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +204 -0
- package/lib/solution/UnifiedBookingSales/index.js +1273 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +150 -0
- package/lib/solution/UnifiedBookingSales/types.js +33 -0
- package/lib/solution/VenueBooking/index.d.ts +39 -11
- package/lib/solution/VenueBooking/index.js +322 -110
- package/lib/solution/VenueBooking/types.d.ts +3 -0
- package/lib/solution/VenueBooking/utils/resource.js +1 -0
- package/lib/solution/VenueBooking/utils/slotMerge.d.ts +4 -4
- package/lib/solution/VenueBooking/utils/slotMerge.js +6 -4
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +3 -1
- package/lib/types/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -19,10 +19,12 @@ export declare function calculateResourceAvailableTime({ resource, timeSlots, cu
|
|
|
19
19
|
* @param countMap 已预约数量映射
|
|
20
20
|
* @returns 最快可用的资源
|
|
21
21
|
*/
|
|
22
|
-
export declare function findFastestAvailableResource({ resources, currentCapacity, countMap, }: {
|
|
22
|
+
export declare function findFastestAvailableResource({ resources, currentCapacity, countMap, targetDate, durationMinutes, }: {
|
|
23
23
|
resources: ResourceItem[];
|
|
24
24
|
currentCapacity?: number;
|
|
25
25
|
countMap?: Record<number, number>;
|
|
26
|
+
targetDate?: string | Dayjs;
|
|
27
|
+
durationMinutes?: number;
|
|
26
28
|
}): ResourceItem | null;
|
|
27
29
|
/**
|
|
28
30
|
* 给定一个时间列表,通过开始和结束时间过滤出符合条件的时间段
|
|
@@ -77,10 +77,15 @@ function calculateResourceAvailableTime({
|
|
|
77
77
|
function findFastestAvailableResource({
|
|
78
78
|
resources,
|
|
79
79
|
currentCapacity = 1,
|
|
80
|
-
countMap = {}
|
|
80
|
+
countMap = {},
|
|
81
|
+
targetDate,
|
|
82
|
+
durationMinutes = 30
|
|
81
83
|
}) {
|
|
82
84
|
var _a, _b, _c;
|
|
83
85
|
const currentTime = (0, import_dayjs.default)();
|
|
86
|
+
const resolvedDuration = durationMinutes > 0 ? durationMinutes : 30;
|
|
87
|
+
const targetDay = targetDate ? (0, import_dayjs.default)(targetDate) : currentTime;
|
|
88
|
+
const isTargetDayToday = targetDay.isSame(currentTime, "day");
|
|
84
89
|
let fastestTime = null;
|
|
85
90
|
let fastestResources = [];
|
|
86
91
|
console.log("[TimeslotUtils] 查找最快可用资源:", {
|
|
@@ -90,19 +95,22 @@ function findFastestAvailableResource({
|
|
|
90
95
|
countMap
|
|
91
96
|
});
|
|
92
97
|
for (const resource of resources) {
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
const targetDayTimes = resource.times.filter((time) => {
|
|
99
|
+
const isSameTargetDay = (0, import_dayjs.default)(time.start_at).isSame(targetDay, "day");
|
|
100
|
+
if (!isSameTargetDay)
|
|
101
|
+
return false;
|
|
102
|
+
if (!isTargetDayToday)
|
|
103
|
+
return true;
|
|
104
|
+
return (0, import_dayjs.default)(time.end_at).isAfter(currentTime);
|
|
97
105
|
});
|
|
98
|
-
if (
|
|
106
|
+
if (targetDayTimes.length === 0) {
|
|
99
107
|
console.log(`[TimeslotUtils] 资源 ${resource.id}(${resource.main_field}) 今日无可用时间段`);
|
|
100
108
|
continue;
|
|
101
109
|
}
|
|
102
|
-
for (const time of
|
|
110
|
+
for (const time of targetDayTimes) {
|
|
103
111
|
const workStartTime = (0, import_dayjs.default)(time.start_at);
|
|
104
112
|
const workEndTime = (0, import_dayjs.default)(time.end_at);
|
|
105
|
-
let nextAvailableTime = currentTime.
|
|
113
|
+
let nextAvailableTime = isTargetDayToday && currentTime.isAfter(workStartTime) ? currentTime : workStartTime;
|
|
106
114
|
console.log(`[TimeslotUtils] 检查资源 ${resource.id}(${resource.main_field}):`, {
|
|
107
115
|
workTime: `${workStartTime.format("HH:mm")}-${workEndTime.format("HH:mm")}`,
|
|
108
116
|
checkStartTime: nextAvailableTime.format("HH:mm:ss"),
|
|
@@ -126,7 +134,7 @@ function findFastestAvailableResource({
|
|
|
126
134
|
pax: event.pax || 1
|
|
127
135
|
});
|
|
128
136
|
if (resource.resourceType === "single" || (resource.capacity || 1) === 1) {
|
|
129
|
-
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(
|
|
137
|
+
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(resolvedDuration, "minute"))) {
|
|
130
138
|
finalAvailableTime = eventEnd;
|
|
131
139
|
console.log(`[TimeslotUtils] 发现时间冲突,调整到: ${finalAvailableTime.format("HH:mm:ss")}`);
|
|
132
140
|
}
|
|
@@ -134,7 +142,7 @@ function findFastestAvailableResource({
|
|
|
134
142
|
const totalCapacity = resource.capacity || 0;
|
|
135
143
|
const currentUsedCapacity = countMap[resource.id] || 0;
|
|
136
144
|
const eventUsedCapacity = event.pax || 1;
|
|
137
|
-
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(
|
|
145
|
+
if (finalAvailableTime.isBefore(eventEnd) && eventStart.isBefore(finalAvailableTime.add(resolvedDuration, "minute"))) {
|
|
138
146
|
const totalRequiredCapacity = currentUsedCapacity + currentCapacity + eventUsedCapacity;
|
|
139
147
|
if (totalRequiredCapacity > totalCapacity) {
|
|
140
148
|
finalAvailableTime = eventEnd;
|
|
@@ -143,7 +151,7 @@ function findFastestAvailableResource({
|
|
|
143
151
|
}
|
|
144
152
|
}
|
|
145
153
|
}
|
|
146
|
-
if (finalAvailableTime.isAfter(workEndTime)) {
|
|
154
|
+
if (finalAvailableTime.add(resolvedDuration, "minute").isAfter(workEndTime)) {
|
|
147
155
|
console.log(`[TimeslotUtils] 资源 ${resource.id} 可用时间超出工作时间,跳过`);
|
|
148
156
|
continue;
|
|
149
157
|
}
|
|
@@ -29,6 +29,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
29
29
|
private addTimeProductsCatalog;
|
|
30
30
|
private orderCustomerDiscountRefreshInFlight;
|
|
31
31
|
private orderCustomerDiscountRefreshCustomerId;
|
|
32
|
+
private orderCustomerPromotionRefreshInFlight;
|
|
32
33
|
private loadOpenDataConfigInFlight;
|
|
33
34
|
/**
|
|
34
35
|
* 在 BaseSales 默认模块清单(products/order/salesSummary/schedule)基础上追加 customer + bookingContext。
|
|
@@ -63,6 +64,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
63
64
|
scanPromotionCode(code: string, customerId?: number): Promise<BaseSalesScanCodeResult>;
|
|
64
65
|
private hydrateOrderCustomerFromScanDiscounts;
|
|
65
66
|
private getDiscountCustomerId;
|
|
67
|
+
resolveCustomerById(customerId: string | number): Promise<ICustomer | null>;
|
|
68
|
+
/** 兼容既有优惠码扫码逻辑。 */
|
|
66
69
|
private resolveCustomerByDiscountCustomerId;
|
|
67
70
|
private findCustomerById;
|
|
68
71
|
private normalizeCustomer;
|
|
@@ -282,7 +285,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
282
285
|
restoreOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
283
286
|
/** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
|
|
284
287
|
private buildOrderCustomerPayload;
|
|
285
|
-
|
|
288
|
+
protected refreshDiscountConfigAfterOrderCustomerChange(customerId: number | null): Promise<void>;
|
|
289
|
+
protected waitForOrderCustomerPromotionRefresh(): Promise<void>;
|
|
286
290
|
/**
|
|
287
291
|
* 获取客户分页信息
|
|
288
292
|
* @returns 分页信息
|
|
@@ -326,7 +330,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
326
330
|
* 获取当前的客户搜索条件
|
|
327
331
|
* @returns 当前搜索条件
|
|
328
332
|
*/
|
|
329
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
333
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
330
334
|
/**
|
|
331
335
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
332
336
|
* @returns 客户状态
|
|
@@ -56,6 +56,7 @@ var import_utils = require("../../modules/Order/utils");
|
|
|
56
56
|
__reExport(BookingTicket_exports, require("./types"), module.exports);
|
|
57
57
|
var OPEN_DATA_SECTION_CODES = ["sale", "reservation", "fulfillment", "menu", "workflow"];
|
|
58
58
|
var OPEN_DATA_CACHE_TTL = 5 * 60 * 1e3;
|
|
59
|
+
var USER_PLATFORM = ["pc", "h5"];
|
|
59
60
|
function resolveBookingUidForAddTime(booking) {
|
|
60
61
|
var _a;
|
|
61
62
|
const uid = (_a = booking == null ? void 0 : booking.metadata) == null ? void 0 : _a.unique_identification_number;
|
|
@@ -135,6 +136,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
135
136
|
this.addTimeProductsCatalog = [];
|
|
136
137
|
this.orderCustomerDiscountRefreshInFlight = null;
|
|
137
138
|
this.orderCustomerDiscountRefreshCustomerId = null;
|
|
139
|
+
this.orderCustomerPromotionRefreshInFlight = null;
|
|
138
140
|
this.loadOpenDataConfigInFlight = null;
|
|
139
141
|
}
|
|
140
142
|
/**
|
|
@@ -240,6 +242,11 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
240
242
|
}
|
|
241
243
|
async configureIdGeneratorFromOpenData() {
|
|
242
244
|
this.setPaymentNumberDevicePrefix(null);
|
|
245
|
+
const idGenerator = this.getIdGeneratorPlugin();
|
|
246
|
+
if (!(idGenerator == null ? void 0 : idGenerator.configure)) {
|
|
247
|
+
console.warn("[BookingTicket] idGenerator 插件不可用,跳过配置");
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
243
250
|
let openDataConfig = null;
|
|
244
251
|
try {
|
|
245
252
|
openDataConfig = await this.loadOpenDataConfig();
|
|
@@ -247,11 +254,6 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
247
254
|
console.warn("[BookingTicket] OpenData 配置加载失败,跳过 idGenerator 配置", error);
|
|
248
255
|
return;
|
|
249
256
|
}
|
|
250
|
-
const idGenerator = this.getIdGeneratorPlugin();
|
|
251
|
-
if (!(idGenerator == null ? void 0 : idGenerator.configure)) {
|
|
252
|
-
console.warn("[BookingTicket] idGenerator 插件不可用,跳过配置");
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
257
|
const receiptSequenceLength = this.normalizePositiveInteger(
|
|
256
258
|
openDataConfig == null ? void 0 : openDataConfig["sale.short_number_digits"],
|
|
257
259
|
5
|
|
@@ -352,7 +354,8 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
352
354
|
const scannedList = raw.scannedDiscountList || [];
|
|
353
355
|
const extractedCustomerId = this.getDiscountCustomerId(scannedList);
|
|
354
356
|
const hasOrderCustomer = Boolean(this.store.order.getOrderCustomer());
|
|
355
|
-
|
|
357
|
+
const isUserPlatform = USER_PLATFORM.includes(this.otherParams.platform);
|
|
358
|
+
if (!hasOrderCustomer && extractedCustomerId && !isUserPlatform) {
|
|
356
359
|
await this.hydrateOrderCustomerFromScanDiscounts(scannedList);
|
|
357
360
|
}
|
|
358
361
|
if (raw.isAvailable) {
|
|
@@ -396,7 +399,7 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
396
399
|
}
|
|
397
400
|
return null;
|
|
398
401
|
}
|
|
399
|
-
async
|
|
402
|
+
async resolveCustomerById(customerId) {
|
|
400
403
|
var _a;
|
|
401
404
|
const localCustomers = this.store.customer.getCustomers();
|
|
402
405
|
const localCustomer = this.findCustomerById(localCustomers, customerId);
|
|
@@ -410,7 +413,23 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
410
413
|
num: 1
|
|
411
414
|
});
|
|
412
415
|
const remoteCustomer = this.findCustomerById((result == null ? void 0 : result.list) || [], customerId) || ((_a = result == null ? void 0 : result.list) == null ? void 0 : _a[0]) || null;
|
|
413
|
-
|
|
416
|
+
if (remoteCustomer) {
|
|
417
|
+
return this.normalizeCustomer(remoteCustomer);
|
|
418
|
+
}
|
|
419
|
+
try {
|
|
420
|
+
const detailCustomer = await this.store.customer.queryCustomerDetail(customerId);
|
|
421
|
+
return detailCustomer ? this.normalizeCustomer(detailCustomer) : null;
|
|
422
|
+
} catch (error) {
|
|
423
|
+
console.warn(
|
|
424
|
+
"[BookingTicket] resolveCustomerById detail request failed",
|
|
425
|
+
{ customerId, error }
|
|
426
|
+
);
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
/** 兼容既有优惠码扫码逻辑。 */
|
|
431
|
+
resolveCustomerByDiscountCustomerId(customerId) {
|
|
432
|
+
return this.resolveCustomerById(customerId);
|
|
414
433
|
}
|
|
415
434
|
findCustomerById(customers = [], customerId) {
|
|
416
435
|
return customers.find((customer) => {
|
|
@@ -899,9 +918,21 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
899
918
|
const next = this.buildOrderCustomerPayload();
|
|
900
919
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
|
|
901
920
|
this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
921
|
+
const promotionRefreshTask = this.store.order.applyPromotion().then(() => void 0);
|
|
922
|
+
this.orderCustomerPromotionRefreshInFlight = promotionRefreshTask;
|
|
923
|
+
void promotionRefreshTask.then(
|
|
924
|
+
() => {
|
|
925
|
+
if (this.orderCustomerPromotionRefreshInFlight !== promotionRefreshTask)
|
|
926
|
+
return;
|
|
927
|
+
this.orderCustomerPromotionRefreshInFlight = null;
|
|
928
|
+
},
|
|
929
|
+
(error) => {
|
|
930
|
+
console.error("[BookingTicket] applyPromotion after customer change failed", error);
|
|
931
|
+
if (this.orderCustomerPromotionRefreshInFlight !== promotionRefreshTask)
|
|
932
|
+
return;
|
|
933
|
+
this.orderCustomerPromotionRefreshInFlight = null;
|
|
934
|
+
}
|
|
935
|
+
);
|
|
905
936
|
}
|
|
906
937
|
/**
|
|
907
938
|
* 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
|
|
@@ -971,12 +1002,13 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
971
1002
|
}
|
|
972
1003
|
refreshDiscountConfigAfterOrderCustomerChange(customerId) {
|
|
973
1004
|
if (!customerId || customerId === 1)
|
|
974
|
-
return;
|
|
1005
|
+
return Promise.resolve();
|
|
975
1006
|
if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
|
|
976
|
-
return;
|
|
1007
|
+
return this.orderCustomerDiscountRefreshInFlight;
|
|
977
1008
|
}
|
|
978
1009
|
const previousRefresh = this.orderCustomerDiscountRefreshInFlight;
|
|
979
1010
|
const refreshTask = (async () => {
|
|
1011
|
+
var _a, _b, _c, _d;
|
|
980
1012
|
if (previousRefresh) {
|
|
981
1013
|
await previousRefresh.catch(() => void 0);
|
|
982
1014
|
}
|
|
@@ -984,7 +1016,10 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
984
1016
|
if (!currentCustomer || Number(currentCustomer.customer_id) !== customerId) {
|
|
985
1017
|
return;
|
|
986
1018
|
}
|
|
987
|
-
|
|
1019
|
+
const tempOrder = (_b = (_a = this.store.order).getTempOrder) == null ? void 0 : _b.call(_a);
|
|
1020
|
+
const orderId = (tempOrder == null ? void 0 : tempOrder.order_id) || ((_d = (_c = this.getOrderIdentity) == null ? void 0 : _c.call(this)) == null ? void 0 : _d.orderId);
|
|
1021
|
+
const action = !orderId || String(orderId).startsWith("local_order") ? "create" : "edit";
|
|
1022
|
+
await this.loadDiscountConfig({ customerId, action });
|
|
988
1023
|
})();
|
|
989
1024
|
this.orderCustomerDiscountRefreshInFlight = refreshTask;
|
|
990
1025
|
this.orderCustomerDiscountRefreshCustomerId = customerId;
|
|
@@ -996,6 +1031,10 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
996
1031
|
this.orderCustomerDiscountRefreshInFlight = null;
|
|
997
1032
|
this.orderCustomerDiscountRefreshCustomerId = null;
|
|
998
1033
|
});
|
|
1034
|
+
return refreshTask;
|
|
1035
|
+
}
|
|
1036
|
+
waitForOrderCustomerPromotionRefresh() {
|
|
1037
|
+
return this.orderCustomerPromotionRefreshInFlight || Promise.resolve();
|
|
999
1038
|
}
|
|
1000
1039
|
/**
|
|
1001
1040
|
* 获取客户分页信息
|
|
@@ -1093,7 +1132,11 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1093
1132
|
*/
|
|
1094
1133
|
scanGlobalListener(callback) {
|
|
1095
1134
|
const localSearch = (v) => this.store.products.findProductsByCodeOrBarcode(v);
|
|
1096
|
-
const scanCallback = (0, import_handleScan.handleGlobalScan)(
|
|
1135
|
+
const scanCallback = (0, import_handleScan.handleGlobalScan)(
|
|
1136
|
+
this.request,
|
|
1137
|
+
localSearch,
|
|
1138
|
+
this.getSubmitOrderSalesChannel()
|
|
1139
|
+
);
|
|
1097
1140
|
const safeCallback = (d) => {
|
|
1098
1141
|
try {
|
|
1099
1142
|
callback(d);
|
|
@@ -1422,7 +1465,11 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1422
1465
|
}
|
|
1423
1466
|
try {
|
|
1424
1467
|
const localSearch = (v) => this.store.products.findProductsByCodeOrBarcode(v);
|
|
1425
|
-
const scanCallback = (0, import_handleScan.handleGlobalScan)(
|
|
1468
|
+
const scanCallback = (0, import_handleScan.handleGlobalScan)(
|
|
1469
|
+
this.request,
|
|
1470
|
+
localSearch,
|
|
1471
|
+
this.getSubmitOrderSalesChannel()
|
|
1472
|
+
);
|
|
1426
1473
|
const raw = await scanCallback({ type: "nativeScanner", value: trimmed });
|
|
1427
1474
|
const formatted = (0, import_formatGlobalScan.formatGlobalScanResult)(raw, trimmed);
|
|
1428
1475
|
if (!formatted) {
|
|
@@ -2,9 +2,11 @@ import { RequestPlugin } from '../../../../plugins';
|
|
|
2
2
|
/**
|
|
3
3
|
* 处理全局扫码
|
|
4
4
|
* @param request 请求插件
|
|
5
|
+
* @param localSearch 本地商品搜索
|
|
6
|
+
* @param channel 当前销售渠道
|
|
5
7
|
* @returns 处理结果
|
|
6
8
|
*/
|
|
7
|
-
export declare const handleGlobalScan: (request: RequestPlugin, localSearch: (v: string) => any[]) => (scanResult: {
|
|
9
|
+
export declare const handleGlobalScan: (request: RequestPlugin, localSearch: (v: string) => any[], channel?: string) => (scanResult: {
|
|
8
10
|
type: string;
|
|
9
11
|
value: string;
|
|
10
12
|
}) => Promise<any>;
|
|
@@ -102,14 +102,14 @@ var handleScanFn = (getRequestList, localSearch) => {
|
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
104
|
};
|
|
105
|
-
var handleGlobalScan = (request, localSearch) => {
|
|
105
|
+
var handleGlobalScan = (request, localSearch, channel) => {
|
|
106
106
|
const getRequestList = (value) => {
|
|
107
107
|
let requestList = [];
|
|
108
108
|
if (value.startsWith("WL")) {
|
|
109
109
|
requestList = [(0, import_cloudSearch.searchWallet)(request, value)];
|
|
110
110
|
} else {
|
|
111
111
|
requestList = [
|
|
112
|
-
(0, import_cloudSearch.searchOrder)(request, value),
|
|
112
|
+
...channel === "kiosk" ? [] : [(0, import_cloudSearch.searchOrder)(request, value)],
|
|
113
113
|
(0, import_cloudSearch.searchWalletPass)(request, value),
|
|
114
114
|
(0, import_cloudSearch.searchWallet)(request, value),
|
|
115
115
|
(0, import_cloudSearch.searchProduct)(request, value)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
|
-
import {
|
|
3
|
-
import { ScanOrderAddLogParams, ScanOrderAvailabilityInfo, ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderScanCodeResult } from './types';
|
|
2
|
+
import { BaseSalesImpl } from '../BaseSales';
|
|
3
|
+
import { ScanOrderAddLogParams, ScanOrderAvailabilityInfo, ScanOrderAllowAddItemsInfo, ScanOrderOrderProduct, ScanOrderOrderProductIdentity, ScanOrderReservationResourceSelectInfo, ScanOrderState, ScanOrderScanCodeResult, ScanOrderSyncAdditionalOrderResult } from './types';
|
|
4
4
|
import type { UpdateOrderProductParams } from '../../modules/Order/types';
|
|
5
5
|
import type { Discount } from '../../modules/Discount/types';
|
|
6
|
+
import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
6
7
|
import { type CartItemSummary, type PaxInfo, type QuantityCheckResult, type QuantityLimitResult } from '../../model/strategy/adapter/itemRule';
|
|
7
8
|
import type { StrategyConfig } from '../../model/strategy/type';
|
|
8
9
|
import type { ProductData } from '../../modules/Product/types';
|
|
@@ -15,16 +16,16 @@ interface ScanOrderItemRuleRuntimeConfig {
|
|
|
15
16
|
submissionIndex?: number;
|
|
16
17
|
custom?: Record<string, any>;
|
|
17
18
|
}
|
|
18
|
-
export declare class ScanOrderImpl extends
|
|
19
|
+
export declare class ScanOrderImpl extends BaseSalesImpl implements Module {
|
|
19
20
|
protected defaultName: string;
|
|
20
21
|
protected defaultVersion: string;
|
|
21
22
|
isSolution: boolean;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
protected initializeOptions: ModuleOptions;
|
|
24
|
+
protected store: ScanOrderState;
|
|
25
|
+
protected otherParams: Record<string, any>;
|
|
26
|
+
protected cacheId: string | undefined;
|
|
27
|
+
window: WindowPlugin;
|
|
28
|
+
request: RequestPlugin;
|
|
28
29
|
private itemRuleEvaluator;
|
|
29
30
|
private itemRuleConfigs;
|
|
30
31
|
private itemRuleConfigsPromise;
|
|
@@ -53,9 +54,10 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
|
|
|
53
54
|
private registerCustomerLoginListeners;
|
|
54
55
|
private refreshOrderMarketingAfterLogin;
|
|
55
56
|
constructor(name?: string, version?: string);
|
|
57
|
+
protected getRegisteredModuleNames(): readonly string[];
|
|
58
|
+
protected createSubModule(moduleName: string): Module | null;
|
|
56
59
|
/** 与 `otherParams.cacheId` 一致,供宿主在 URL 变化时判断是否需要重新注册模块 */
|
|
57
60
|
getCacheId(): string | undefined;
|
|
58
|
-
private destroyRegisteredChildModules;
|
|
59
61
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
60
62
|
destroy(): Promise<void>;
|
|
61
63
|
retryInit(): Promise<void>;
|
|
@@ -71,12 +73,14 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
|
|
|
71
73
|
};
|
|
72
74
|
getTempOrder(): import("../../modules/Order/types").OrderTempOrder | null;
|
|
73
75
|
updateTempOrderNote(note: string): string;
|
|
76
|
+
updateTempOrderNote(note: string, sync: true): Promise<string>;
|
|
77
|
+
updateTempOrderNote(note: string, sync: boolean): string | Promise<string>;
|
|
74
78
|
setPickupReferenceMode(mode: 'counter_pickup' | 'table_service'): {
|
|
75
|
-
service_type: 'dine_in';
|
|
79
|
+
service_type: 'dine_in' | '';
|
|
76
80
|
pickup_reference_mode: 'counter_pickup' | 'table_service';
|
|
77
81
|
};
|
|
78
82
|
setPickupRef(buzzer: string): string;
|
|
79
|
-
private
|
|
83
|
+
private ensureScanOrderTempOrder;
|
|
80
84
|
addNewOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
81
85
|
restoreOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
82
86
|
getOrderProducts(): import("../../modules/Order/types").OrderProduct[];
|
|
@@ -92,7 +96,10 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
|
|
|
92
96
|
}): Promise<void>;
|
|
93
97
|
private findReservationRuleResource;
|
|
94
98
|
private buildScanOrderResourceMetadata;
|
|
99
|
+
private prepareRetailAvailability;
|
|
95
100
|
private buildSubmitPayloadEnhancer;
|
|
101
|
+
private isScanOrderMoreMode;
|
|
102
|
+
private submitScanOrderMore;
|
|
96
103
|
submitScanOrder<T = any>(): Promise<T>;
|
|
97
104
|
addProductToOrder(product: Partial<ScanOrderOrderProduct> & ScanOrderOrderProductIdentity): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
98
105
|
updateOrderProduct(params: UpdateOrderProductParams): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
@@ -117,8 +124,10 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
|
|
|
117
124
|
setItemRuleRuntimeConfig(config?: ScanOrderItemRuleRuntimeConfig): Promise<void>;
|
|
118
125
|
private normalizeResourceState;
|
|
119
126
|
private resolveResourceSelectType;
|
|
120
|
-
private
|
|
121
|
-
|
|
127
|
+
private fetchResourceOccupyDetailsByResourceId;
|
|
128
|
+
private resolveAdditionalOrderFromOccupyDetail;
|
|
129
|
+
checkResourceAvailable(resourceId?: string | null, hasOrderId?: boolean): Promise<ScanOrderAvailabilityInfo>;
|
|
130
|
+
restorePreviousOrderData(): Promise<void>;
|
|
122
131
|
getAdditionalOrderInfo(): Promise<{
|
|
123
132
|
orderId: string;
|
|
124
133
|
orderStatus: 'pending' | 'processing' | 'completed' | 'cancelled';
|
|
@@ -141,6 +150,9 @@ export declare class ScanOrderImpl extends BaseModule implements Module {
|
|
|
141
150
|
clearUIState(): void;
|
|
142
151
|
setEntryPaxNumber(number: number): Promise<void>;
|
|
143
152
|
getEntryPaxNumber(): number | null;
|
|
153
|
+
syncAdditionalOrderFromResource(resourceId?: string | null): Promise<ScanOrderSyncAdditionalOrderResult>;
|
|
154
|
+
getReservationResourceSelectType(): ScanOrderReservationResourceSelectInfo;
|
|
155
|
+
checkAllowAddItems(): ScanOrderAllowAddItemsInfo;
|
|
144
156
|
getFulfillmentModes(): {
|
|
145
157
|
enablePickup: boolean;
|
|
146
158
|
enableTableService: boolean;
|