@pisell/pisellos 2.3.66 → 2.3.68
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/Order/index.d.ts +22 -2
- package/dist/modules/Order/index.js +313 -142
- package/dist/modules/Order/types.d.ts +13 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +75 -0
- package/dist/modules/Order/utils.js +0 -1
- package/dist/modules/Payment/index.d.ts +4 -0
- package/dist/modules/Payment/index.js +14 -4
- package/dist/modules/Payment/walletpass.js +21 -7
- package/dist/modules/Rules/index.js +46 -31
- package/dist/solution/BaseSales/index.d.ts +3 -1
- package/dist/solution/BaseSales/index.js +99 -82
- package/dist/solution/BaseSales/utils.js +31 -20
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +4 -2
- package/dist/solution/BookingTicket/index.js +89 -65
- package/dist/solution/ScanOrder/utils.js +31 -20
- package/dist/solution/UnifiedBookingSales/index.d.ts +25 -0
- package/dist/solution/UnifiedBookingSales/index.js +640 -321
- package/dist/solution/UnifiedBookingSales/types.d.ts +7 -0
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/modules/BaseModule.d.ts +1 -0
- package/lib/modules/BaseModule.js +24 -37
- package/lib/modules/Order/index.d.ts +22 -2
- package/lib/modules/Order/index.js +212 -54
- package/lib/modules/Order/types.d.ts +13 -1
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +70 -0
- package/lib/modules/Order/utils.js +0 -1
- package/lib/modules/Payment/index.d.ts +4 -0
- package/lib/modules/Payment/index.js +7 -0
- package/lib/modules/Payment/walletpass.js +12 -0
- package/lib/modules/Rules/index.js +17 -1
- package/lib/solution/BaseSales/index.d.ts +3 -1
- package/lib/solution/BaseSales/index.js +29 -16
- package/lib/solution/BaseSales/utils.js +29 -18
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +4 -2
- package/lib/solution/BookingTicket/index.js +35 -12
- package/lib/solution/ScanOrder/utils.js +29 -18
- package/lib/solution/UnifiedBookingSales/index.d.ts +25 -0
- package/lib/solution/UnifiedBookingSales/index.js +188 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -1206,7 +1206,6 @@ function productRequiresFormSubject(tempOrder, product) {
|
|
|
1206
1206
|
}
|
|
1207
1207
|
function resolveIsFormSubject(tempOrder, product) {
|
|
1208
1208
|
var _a;
|
|
1209
|
-
debugger;
|
|
1210
1209
|
if (((_a = tempOrder == null ? void 0 : tempOrder.holder) == null ? void 0 : _a.type) === "form")
|
|
1211
1210
|
return true;
|
|
1212
1211
|
if (product)
|
|
@@ -41,6 +41,10 @@ export declare class PaymentModule extends BaseModule implements Module, Payment
|
|
|
41
41
|
* paymentModule.updateOtherParams({ fatherModule: 'bookingTicket' });
|
|
42
42
|
*/
|
|
43
43
|
updateOtherParams(params: Record<string, any>): void;
|
|
44
|
+
/**
|
|
45
|
+
* 获取标准化后的宿主平台标识,供支付子能力做平台边界判断。
|
|
46
|
+
*/
|
|
47
|
+
getPlatform(): string;
|
|
44
48
|
private getPaymentNumberAppData;
|
|
45
49
|
/**
|
|
46
50
|
* 记录信息日志
|
|
@@ -139,6 +139,13 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
|
|
|
139
139
|
updateOtherParams(params) {
|
|
140
140
|
this.otherParams = params || {};
|
|
141
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* 获取标准化后的宿主平台标识,供支付子能力做平台边界判断。
|
|
144
|
+
*/
|
|
145
|
+
getPlatform() {
|
|
146
|
+
var _a;
|
|
147
|
+
return String(((_a = this.otherParams) == null ? void 0 : _a.platform) || "").trim().toLowerCase();
|
|
148
|
+
}
|
|
142
149
|
getPaymentNumberAppData(key) {
|
|
143
150
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
144
151
|
const getData = (_b = (_a = this.appPlugin) == null ? void 0 : _a.getData) == null ? void 0 : _b.call(_a);
|
|
@@ -722,6 +722,18 @@ var WalletPassPaymentImpl = class {
|
|
|
722
722
|
this.paymentModule.logInfo("[WalletPass] 商品列表为空,跳过获取用户识别码列表");
|
|
723
723
|
return [];
|
|
724
724
|
}
|
|
725
|
+
const platform = this.paymentModule.getPlatform();
|
|
726
|
+
if (platform === "pc" || platform === "h5") {
|
|
727
|
+
this.userIdentificationCodes = [];
|
|
728
|
+
this.emitEvent(import_types.WalletPassHooks.OnUserIdentificationCodesUpdated, {
|
|
729
|
+
userIdentificationCodes: []
|
|
730
|
+
});
|
|
731
|
+
this.paymentModule.logInfo(
|
|
732
|
+
"[WalletPass] 用户端平台跳过获取用户识别码列表",
|
|
733
|
+
{ platform }
|
|
734
|
+
);
|
|
735
|
+
return [];
|
|
736
|
+
}
|
|
725
737
|
if (typeof newParams.payment_order_id === "string" && newParams.payment_order_id.startsWith("LOCAL_")) {
|
|
726
738
|
newParams.payment_order_id = void 0;
|
|
727
739
|
}
|
|
@@ -865,10 +865,26 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
865
865
|
);
|
|
866
866
|
}) : void 0;
|
|
867
867
|
const explicitlySelectedDiscountCard = explicitlySelectedDiscount && (explicitlySelectedDiscount.tag || explicitlySelectedDiscount.type) !== "good_pass" ? explicitlySelectedDiscount : void 0;
|
|
868
|
+
const appliedDiscountCardIds = new Set(
|
|
869
|
+
(product.discount_list || []).filter(
|
|
870
|
+
(item) => ["discount_card", "product_discount_card"].includes(
|
|
871
|
+
(item == null ? void 0 : item.tag) || (item == null ? void 0 : item.type)
|
|
872
|
+
)
|
|
873
|
+
).map(
|
|
874
|
+
(item) => {
|
|
875
|
+
var _a3;
|
|
876
|
+
return ((_a3 = item == null ? void 0 : item.discount) == null ? void 0 : _a3.resource_id) ?? (item == null ? void 0 : item.resource_id) ?? (item == null ? void 0 : item.id);
|
|
877
|
+
}
|
|
878
|
+
).filter((id) => id !== void 0 && id !== null).map(String)
|
|
879
|
+
);
|
|
880
|
+
const appliedDiscountCard = (options == null ? void 0 : options.scan) ? void 0 : applicableDiscounts.find((discount) => {
|
|
881
|
+
const discountType = discount.tag || discount.type;
|
|
882
|
+
return discount.isSelected === true && ["discount_card", "product_discount_card"].includes(discountType) && appliedDiscountCardIds.has(String(discount.id));
|
|
883
|
+
});
|
|
868
884
|
const scannedSelectedDiscountCard = applicableDiscounts.find(
|
|
869
885
|
(n) => n.isScan && n.isSelected && (n.tag || n.type) !== "good_pass"
|
|
870
886
|
);
|
|
871
|
-
const selectedDiscountCard = explicitlySelectedDiscountCard || scannedSelectedDiscountCard;
|
|
887
|
+
const selectedDiscountCard = explicitlySelectedDiscountCard || appliedDiscountCard || scannedSelectedDiscountCard;
|
|
872
888
|
const selectedDiscount = explicitlySelectedDiscount || selectedDiscountCard || applicableDiscounts[0];
|
|
873
889
|
const prioritizedApplicableDiscounts = explicitlySelectedDiscount && (explicitlySelectedDiscount.tag || explicitlySelectedDiscount.type) === "good_pass" ? [
|
|
874
890
|
explicitlySelectedDiscount,
|
|
@@ -141,7 +141,9 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
141
141
|
* const params = this.buildSubModuleOtherParams();
|
|
142
142
|
* this.core.registerModule(orderModule, { otherParams: params });
|
|
143
143
|
*/
|
|
144
|
-
protected
|
|
144
|
+
protected isSessionStoragePersistEnabled(): boolean;
|
|
145
|
+
protected shouldUseSessionStorageForSubModule(_moduleName?: string): boolean;
|
|
146
|
+
protected buildSubModuleOtherParams(moduleName?: string): Record<string, any>;
|
|
145
147
|
/**
|
|
146
148
|
* 将父级 otherParams 的变更显式同步给已注册的子模块。
|
|
147
149
|
*
|
|
@@ -591,7 +591,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
591
591
|
});
|
|
592
592
|
});
|
|
593
593
|
}
|
|
594
|
-
async hydrateLatestLoadedSalesDetail(record, loadSequence) {
|
|
594
|
+
async hydrateLatestLoadedSalesDetail(record, loadSequence, hydrateSource) {
|
|
595
595
|
let hydratedSales = null;
|
|
596
596
|
let skippedBeforeHydrate = false;
|
|
597
597
|
const hydrateTask = async () => {
|
|
@@ -601,9 +601,10 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
601
601
|
}
|
|
602
602
|
if (!this.store.order)
|
|
603
603
|
throw new Error("order 模块未初始化");
|
|
604
|
-
const sales = await this.store.order.hydrateTempOrderFromRecord(
|
|
605
|
-
|
|
606
|
-
|
|
604
|
+
const sales = await this.store.order.hydrateTempOrderFromRecord(
|
|
605
|
+
record,
|
|
606
|
+
hydrateSource === "sessionStorage" ? { recalcOnHydrate: true, source: "sessionStorage" } : { recalcOnHydrate: false }
|
|
607
|
+
);
|
|
607
608
|
hydratedSales = sales;
|
|
608
609
|
if (loadSequence !== this.salesDetailLoadSequence)
|
|
609
610
|
return;
|
|
@@ -927,12 +928,18 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
927
928
|
* const params = this.buildSubModuleOtherParams();
|
|
928
929
|
* this.core.registerModule(orderModule, { otherParams: params });
|
|
929
930
|
*/
|
|
930
|
-
|
|
931
|
+
isSessionStoragePersistEnabled() {
|
|
932
|
+
return Boolean(this.cacheId);
|
|
933
|
+
}
|
|
934
|
+
shouldUseSessionStorageForSubModule(_moduleName) {
|
|
935
|
+
return this.isSessionStoragePersistEnabled();
|
|
936
|
+
}
|
|
937
|
+
buildSubModuleOtherParams(moduleName) {
|
|
931
938
|
return {
|
|
932
939
|
...this.otherParams,
|
|
933
940
|
salesSummaryModuleName: `${this.name}_salesSummary`,
|
|
934
941
|
fatherModule: this.name,
|
|
935
|
-
openCache: this.
|
|
942
|
+
openCache: this.shouldUseSessionStorageForSubModule(moduleName),
|
|
936
943
|
cacheId: this.cacheId
|
|
937
944
|
};
|
|
938
945
|
}
|
|
@@ -943,7 +950,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
943
950
|
* await this.syncOtherParamsToSubModules({ channel: 'pos' });
|
|
944
951
|
*/
|
|
945
952
|
async syncOtherParamsToSubModules(changedParams, { cover = false } = {}) {
|
|
946
|
-
const nextSubModuleOtherParams = this.buildSubModuleOtherParams();
|
|
947
953
|
await Promise.all(
|
|
948
954
|
Object.entries(this.store).map(async ([moduleName, subModule]) => {
|
|
949
955
|
if (this.reusedSharedSubModuleNames.has(moduleName)) {
|
|
@@ -953,6 +959,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
953
959
|
if (!targetModule || typeof targetModule.updateOtherParams !== "function") {
|
|
954
960
|
return;
|
|
955
961
|
}
|
|
962
|
+
const nextSubModuleOtherParams = this.buildSubModuleOtherParams(moduleName);
|
|
956
963
|
await targetModule.updateOtherParams(nextSubModuleOtherParams, {
|
|
957
964
|
changedParams,
|
|
958
965
|
cover
|
|
@@ -965,14 +972,16 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
965
972
|
* sessionStorage 损坏时静默忽略,按空状态注册。
|
|
966
973
|
*/
|
|
967
974
|
readSessionCacheData() {
|
|
968
|
-
|
|
975
|
+
const cacheId = this.cacheId;
|
|
976
|
+
if (!cacheId || !this.isSessionStoragePersistEnabled() || !this.window) {
|
|
969
977
|
return {};
|
|
978
|
+
}
|
|
970
979
|
try {
|
|
971
980
|
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
972
981
|
if (!sessionData)
|
|
973
982
|
return {};
|
|
974
983
|
const data = JSON.parse(sessionData);
|
|
975
|
-
return data && data[
|
|
984
|
+
return data && data[cacheId] || {};
|
|
976
985
|
} catch {
|
|
977
986
|
return {};
|
|
978
987
|
}
|
|
@@ -1074,9 +1083,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1074
1083
|
const hooks = this.getSubModuleHooks(step);
|
|
1075
1084
|
this.store[step] = targetModule;
|
|
1076
1085
|
this.core.registerModule(targetModule, {
|
|
1077
|
-
initialState: (targetCacheData == null ? void 0 : targetCacheData[targetModule.name]) || {},
|
|
1086
|
+
initialState: this.shouldUseSessionStorageForSubModule(step) ? (targetCacheData == null ? void 0 : targetCacheData[targetModule.name]) || {} : {},
|
|
1078
1087
|
...hooks ? { hooks } : {},
|
|
1079
|
-
otherParams: this.buildSubModuleOtherParams()
|
|
1088
|
+
otherParams: this.buildSubModuleOtherParams(step)
|
|
1080
1089
|
});
|
|
1081
1090
|
});
|
|
1082
1091
|
if (this.store.schedule && !this.isScheduleListLoaded(this.store.schedule)) {
|
|
@@ -1143,17 +1152,21 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1143
1152
|
const message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || `加载销售详情失败: ${lookup}`;
|
|
1144
1153
|
throw new Error(message);
|
|
1145
1154
|
}
|
|
1146
|
-
const
|
|
1147
|
-
|
|
1148
|
-
);
|
|
1155
|
+
const loadedSalesDetail = preloadedSalesDetail ?? loadedRecord.data;
|
|
1156
|
+
const shouldFilterPendingPayments = params.hydrateSource !== "sessionStorage";
|
|
1157
|
+
const remoteRecord = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(loadedSalesDetail) : loadedSalesDetail;
|
|
1149
1158
|
const currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
1150
1159
|
const mergedRecord = params.merge ? mergeSalesDetailRecordWithTempOrder(
|
|
1151
1160
|
currentTempOrder,
|
|
1152
1161
|
remoteRecord,
|
|
1153
1162
|
"preserve-local"
|
|
1154
1163
|
) : remoteRecord;
|
|
1155
|
-
const record = filterPendingPaymentsFromLoadedSalesDetail(mergedRecord);
|
|
1156
|
-
return await this.hydrateLatestLoadedSalesDetail(
|
|
1164
|
+
const record = shouldFilterPendingPayments ? filterPendingPaymentsFromLoadedSalesDetail(mergedRecord) : mergedRecord;
|
|
1165
|
+
return await this.hydrateLatestLoadedSalesDetail(
|
|
1166
|
+
record,
|
|
1167
|
+
loadSequence,
|
|
1168
|
+
params.hydrateSource
|
|
1169
|
+
);
|
|
1157
1170
|
} finally {
|
|
1158
1171
|
this.salesDetailLoadInFlightCount = Math.max(
|
|
1159
1172
|
0,
|
|
@@ -60,33 +60,44 @@ function createEmptySummary() {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
function buildProductLineFingerprint(productOptionItem, productBundle) {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
63
|
+
const normalizeOptions = (options) => {
|
|
64
|
+
const optionArr = Array.isArray(options) ? options : [];
|
|
65
|
+
return optionArr.map((item) => ({
|
|
66
|
+
option_group_item_id: Number(item == null ? void 0 : item.option_group_item_id) || 0,
|
|
67
|
+
option_group_id: Number(item == null ? void 0 : item.option_group_id) || 0,
|
|
68
|
+
num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
|
|
69
|
+
price: String((item == null ? void 0 : item.add_price) ?? (item == null ? void 0 : item.price) ?? "")
|
|
70
|
+
})).sort((p, q) => {
|
|
71
|
+
if (p.option_group_item_id !== q.option_group_item_id) {
|
|
72
|
+
return p.option_group_item_id - q.option_group_item_id;
|
|
73
|
+
}
|
|
74
|
+
if (p.option_group_id !== q.option_group_id) {
|
|
75
|
+
return p.option_group_id - q.option_group_id;
|
|
76
|
+
}
|
|
77
|
+
if (p.num !== q.num)
|
|
78
|
+
return p.num - q.num;
|
|
79
|
+
return p.price.localeCompare(q.price);
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
const normalizedOpts = normalizeOptions(productOptionItem);
|
|
79
83
|
const bundleArr = Array.isArray(productBundle) ? productBundle : [];
|
|
80
84
|
const normalizedBundles = bundleArr.map((item) => ({
|
|
81
85
|
bundle_id: Number((item == null ? void 0 : item.bundle_id) ?? (item == null ? void 0 : item.id) ?? 0) || 0,
|
|
82
86
|
product_id: Number(item == null ? void 0 : item.product_id) || 0,
|
|
83
|
-
|
|
87
|
+
product_variant_id: Number((item == null ? void 0 : item.bundle_variant_id) ?? (item == null ? void 0 : item.product_variant_id)) || 0,
|
|
88
|
+
num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
|
|
89
|
+
option: normalizeOptions(item == null ? void 0 : item.option)
|
|
84
90
|
})).sort((p, q) => {
|
|
85
91
|
if (p.bundle_id !== q.bundle_id)
|
|
86
92
|
return p.bundle_id - q.bundle_id;
|
|
87
93
|
if (p.product_id !== q.product_id)
|
|
88
94
|
return p.product_id - q.product_id;
|
|
89
|
-
|
|
95
|
+
if (p.product_variant_id !== q.product_variant_id) {
|
|
96
|
+
return p.product_variant_id - q.product_variant_id;
|
|
97
|
+
}
|
|
98
|
+
if (p.num !== q.num)
|
|
99
|
+
return p.num - q.num;
|
|
100
|
+
return JSON.stringify(p.option).localeCompare(JSON.stringify(q.option));
|
|
90
101
|
});
|
|
91
102
|
return JSON.stringify([normalizedOpts, normalizedBundles]);
|
|
92
103
|
}
|
|
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
326
326
|
date: string;
|
|
327
327
|
status: string;
|
|
328
328
|
week: string;
|
|
329
|
-
weekNum: 0 |
|
|
329
|
+
weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -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。
|
|
@@ -284,7 +285,8 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
284
285
|
restoreOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
285
286
|
/** 内部:基于 OrderModule 当前状态构造一份 OrderCustomerChangePayload。 */
|
|
286
287
|
private buildOrderCustomerPayload;
|
|
287
|
-
|
|
288
|
+
protected refreshDiscountConfigAfterOrderCustomerChange(customerId: number | null): Promise<void>;
|
|
289
|
+
protected waitForOrderCustomerPromotionRefresh(): Promise<void>;
|
|
288
290
|
/**
|
|
289
291
|
* 获取客户分页信息
|
|
290
292
|
* @returns 分页信息
|
|
@@ -328,7 +330,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
328
330
|
* 获取当前的客户搜索条件
|
|
329
331
|
* @returns 当前搜索条件
|
|
330
332
|
*/
|
|
331
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
333
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
332
334
|
/**
|
|
333
335
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
334
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) {
|
|
@@ -915,9 +918,21 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
915
918
|
const next = this.buildOrderCustomerPayload();
|
|
916
919
|
this.core.effects.emit(`${this.name}:onOrderCustomerChange`, next);
|
|
917
920
|
this.refreshDiscountConfigAfterOrderCustomerChange(patch.customer_id);
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
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
|
+
);
|
|
921
936
|
}
|
|
922
937
|
/**
|
|
923
938
|
* 读取 tempOrder 上的下单客户协议字段;customer_id 缺失时返回 null。
|
|
@@ -987,12 +1002,13 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
987
1002
|
}
|
|
988
1003
|
refreshDiscountConfigAfterOrderCustomerChange(customerId) {
|
|
989
1004
|
if (!customerId || customerId === 1)
|
|
990
|
-
return;
|
|
1005
|
+
return Promise.resolve();
|
|
991
1006
|
if (this.orderCustomerDiscountRefreshInFlight && this.orderCustomerDiscountRefreshCustomerId === customerId) {
|
|
992
|
-
return;
|
|
1007
|
+
return this.orderCustomerDiscountRefreshInFlight;
|
|
993
1008
|
}
|
|
994
1009
|
const previousRefresh = this.orderCustomerDiscountRefreshInFlight;
|
|
995
1010
|
const refreshTask = (async () => {
|
|
1011
|
+
var _a, _b, _c, _d;
|
|
996
1012
|
if (previousRefresh) {
|
|
997
1013
|
await previousRefresh.catch(() => void 0);
|
|
998
1014
|
}
|
|
@@ -1000,7 +1016,10 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1000
1016
|
if (!currentCustomer || Number(currentCustomer.customer_id) !== customerId) {
|
|
1001
1017
|
return;
|
|
1002
1018
|
}
|
|
1003
|
-
|
|
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 });
|
|
1004
1023
|
})();
|
|
1005
1024
|
this.orderCustomerDiscountRefreshInFlight = refreshTask;
|
|
1006
1025
|
this.orderCustomerDiscountRefreshCustomerId = customerId;
|
|
@@ -1012,6 +1031,10 @@ var BookingTicketImpl = class extends import_BaseSales.BaseSalesImpl {
|
|
|
1012
1031
|
this.orderCustomerDiscountRefreshInFlight = null;
|
|
1013
1032
|
this.orderCustomerDiscountRefreshCustomerId = null;
|
|
1014
1033
|
});
|
|
1034
|
+
return refreshTask;
|
|
1035
|
+
}
|
|
1036
|
+
waitForOrderCustomerPromotionRefresh() {
|
|
1037
|
+
return this.orderCustomerPromotionRefreshInFlight || Promise.resolve();
|
|
1015
1038
|
}
|
|
1016
1039
|
/**
|
|
1017
1040
|
* 获取客户分页信息
|
|
@@ -357,33 +357,44 @@ function attachItemRuleLimitsToTopLevelProducts(productList, limits) {
|
|
|
357
357
|
return productList;
|
|
358
358
|
}
|
|
359
359
|
function buildProductLineFingerprint(productOptionItem, productBundle) {
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
360
|
+
const normalizeOptions = (options) => {
|
|
361
|
+
const optionArr = Array.isArray(options) ? options : [];
|
|
362
|
+
return optionArr.map((item) => ({
|
|
363
|
+
option_group_item_id: Number(item == null ? void 0 : item.option_group_item_id) || 0,
|
|
364
|
+
option_group_id: Number(item == null ? void 0 : item.option_group_id) || 0,
|
|
365
|
+
num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
|
|
366
|
+
price: String((item == null ? void 0 : item.add_price) ?? (item == null ? void 0 : item.price) ?? "")
|
|
367
|
+
})).sort((p, q) => {
|
|
368
|
+
if (p.option_group_item_id !== q.option_group_item_id) {
|
|
369
|
+
return p.option_group_item_id - q.option_group_item_id;
|
|
370
|
+
}
|
|
371
|
+
if (p.option_group_id !== q.option_group_id) {
|
|
372
|
+
return p.option_group_id - q.option_group_id;
|
|
373
|
+
}
|
|
374
|
+
if (p.num !== q.num)
|
|
375
|
+
return p.num - q.num;
|
|
376
|
+
return p.price.localeCompare(q.price);
|
|
377
|
+
});
|
|
378
|
+
};
|
|
379
|
+
const normalizedOpts = normalizeOptions(productOptionItem);
|
|
376
380
|
const bundleArr = Array.isArray(productBundle) ? productBundle : [];
|
|
377
381
|
const normalizedBundles = bundleArr.map((item) => ({
|
|
378
382
|
bundle_id: Number((item == null ? void 0 : item.bundle_id) ?? (item == null ? void 0 : item.id) ?? 0) || 0,
|
|
379
383
|
product_id: Number(item == null ? void 0 : item.product_id) || 0,
|
|
380
|
-
|
|
384
|
+
product_variant_id: Number((item == null ? void 0 : item.bundle_variant_id) ?? (item == null ? void 0 : item.product_variant_id)) || 0,
|
|
385
|
+
num: typeof (item == null ? void 0 : item.num) === "number" && !Number.isNaN(item.num) ? Math.max(1, Math.floor(item.num)) : 1,
|
|
386
|
+
option: normalizeOptions(item == null ? void 0 : item.option)
|
|
381
387
|
})).sort((p, q) => {
|
|
382
388
|
if (p.bundle_id !== q.bundle_id)
|
|
383
389
|
return p.bundle_id - q.bundle_id;
|
|
384
390
|
if (p.product_id !== q.product_id)
|
|
385
391
|
return p.product_id - q.product_id;
|
|
386
|
-
|
|
392
|
+
if (p.product_variant_id !== q.product_variant_id) {
|
|
393
|
+
return p.product_variant_id - q.product_variant_id;
|
|
394
|
+
}
|
|
395
|
+
if (p.num !== q.num)
|
|
396
|
+
return p.num - q.num;
|
|
397
|
+
return JSON.stringify(p.option).localeCompare(JSON.stringify(q.option));
|
|
387
398
|
});
|
|
388
399
|
return JSON.stringify([normalizedOpts, normalizedBundles]);
|
|
389
400
|
}
|
|
@@ -63,6 +63,24 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
63
63
|
private openDataTarget;
|
|
64
64
|
private loadOpenDataInFlight;
|
|
65
65
|
private loadOpenDataInFlightTarget;
|
|
66
|
+
protected getSubmitOrderSalesChannel(): string;
|
|
67
|
+
protected isSessionStoragePersistEnabled(): boolean;
|
|
68
|
+
protected shouldUseSessionStorageForSubModule(moduleName?: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* 读取与当前 cacheId 同分桶的 Solution 会话状态。
|
|
71
|
+
* 该状态独立于 otherParams,适合页面皮肤保存短生命周期 UI 状态。
|
|
72
|
+
*/
|
|
73
|
+
getSessionStateValue<T = unknown>(key: string): T | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* 写入与当前 cacheId 同分桶的 Solution 会话状态。
|
|
76
|
+
* value 为 undefined 时删除该 key;存储失败不阻断业务流程。
|
|
77
|
+
*/
|
|
78
|
+
setSessionStateValue(key: string, value: unknown): void;
|
|
79
|
+
/**
|
|
80
|
+
* 清除当前 cacheId 的可恢复订单快照,同时保留 Solution UI sessionState。
|
|
81
|
+
* 用于支付跳转等终态场景,避免浏览器返回时恢复已提交订单。
|
|
82
|
+
*/
|
|
83
|
+
clearSessionStorageOrderSnapshot(): void;
|
|
66
84
|
/**
|
|
67
85
|
* Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
|
|
68
86
|
* 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
|
|
@@ -72,6 +90,13 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
72
90
|
protected getDefaultCheckoutSmallTicketDataFlag(): number;
|
|
73
91
|
protected getRegisteredModuleNames(): readonly string[];
|
|
74
92
|
protected createSubModule(moduleName: string): Module | null;
|
|
93
|
+
addNewOrder(): Promise<import("../../modules/Order/types").OrderTempOrder>;
|
|
94
|
+
syncAuthenticatedOrderCustomer(): Promise<boolean>;
|
|
95
|
+
private isAuthenticatedCustomerUserPlatform;
|
|
96
|
+
private resolveDiscountOrderIdentity;
|
|
97
|
+
private resolveDiscountAction;
|
|
98
|
+
private resetCachedCustomerDiscountState;
|
|
99
|
+
private refreshLegacySessionCustomerDiscounts;
|
|
75
100
|
/**
|
|
76
101
|
* Loads OpenData without borrowing BookingTicket. Cache ownership is tied to the exact
|
|
77
102
|
* business/channel target so a reused solution instance cannot leak another entry's menus.
|