@pisell/pisellos 2.3.49 → 2.3.50
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/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 +3 -1
- package/dist/modules/Order/index.js +54 -25
- package/dist/modules/Order/types.d.ts +9 -0
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +35 -3
- package/dist/modules/Payment/types.d.ts +0 -8
- package/dist/modules/Payment/walletpass.d.ts +1 -7
- package/dist/modules/Payment/walletpass.js +45 -155
- package/dist/modules/Product/types.d.ts +1 -0
- package/dist/modules/ProductList/index.js +33 -14
- 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 +47 -13
- 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 +14 -0
- package/dist/server/index.js +907 -793
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +0 -16
- package/dist/server/modules/order/index.js +776 -964
- package/dist/server/modules/order/types.d.ts +0 -14
- package/dist/server/modules/order/types.js +0 -6
- package/dist/solution/BaseSales/index.d.ts +8 -3
- package/dist/solution/BaseSales/index.js +64 -50
- package/dist/solution/BookingByStep/index.d.ts +17 -2
- 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 +1 -1
- package/dist/solution/BookingTicket/index.js +2 -2
- 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 +66 -25
- package/dist/solution/ShopDiscount/index.d.ts +1 -0
- package/dist/solution/ShopDiscount/index.js +125 -87
- package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/dist/solution/UnifiedBookingSales/index.js +1891 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +143 -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/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 +3 -1
- package/lib/modules/Order/index.js +26 -10
- package/lib/modules/Order/types.d.ts +9 -0
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +36 -5
- package/lib/modules/Payment/types.d.ts +0 -8
- package/lib/modules/Payment/walletpass.d.ts +1 -7
- package/lib/modules/Payment/walletpass.js +9 -107
- package/lib/modules/Product/types.d.ts +1 -0
- package/lib/modules/ProductList/index.js +40 -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 +33 -16
- 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 +14 -0
- package/lib/server/index.js +72 -15
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +0 -16
- package/lib/server/modules/order/index.js +4 -140
- package/lib/server/modules/order/types.d.ts +0 -14
- package/lib/server/modules/order/types.js +0 -1
- package/lib/solution/BaseSales/index.d.ts +8 -3
- package/lib/solution/BaseSales/index.js +24 -14
- package/lib/solution/BookingByStep/index.d.ts +17 -2
- 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 +1 -1
- package/lib/solution/BookingTicket/index.js +10 -2
- 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 +31 -0
- package/lib/solution/ShopDiscount/index.d.ts +1 -0
- package/lib/solution/ShopDiscount/index.js +14 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
- package/lib/solution/UnifiedBookingSales/index.js +1084 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +143 -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
package/lib/server/index.d.ts
CHANGED
|
@@ -49,6 +49,10 @@ declare class Server {
|
|
|
49
49
|
private productQuerySubscribers;
|
|
50
50
|
/** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
|
|
51
51
|
private productQueryScheduleTimers;
|
|
52
|
+
/** 餐牌筛选为空时才触发的菜单/日程缓存自愈,避免每次商品查询都请求远端。 */
|
|
53
|
+
private menuScheduleRefreshInFlight;
|
|
54
|
+
private lastMenuScheduleRefreshAt;
|
|
55
|
+
private readonly MENU_SCHEDULE_REFRESH_COOLDOWN_MS;
|
|
52
56
|
private orderQuerySubscribers;
|
|
53
57
|
private bookingQuerySubscribers;
|
|
54
58
|
private bookingRemoteQuerySubscribers;
|
|
@@ -262,6 +266,16 @@ declare class Server {
|
|
|
262
266
|
* 存储订阅者信息,便于数据变更时推送最新结果
|
|
263
267
|
*/
|
|
264
268
|
private handleProductQuery;
|
|
269
|
+
/**
|
|
270
|
+
* ProductList callers such as standalone retail pages do not always have a selected schedule.
|
|
271
|
+
* In that case query against the current local time so menu availability can still be evaluated.
|
|
272
|
+
*/
|
|
273
|
+
private resolveProductQueryScheduleContext;
|
|
274
|
+
/**
|
|
275
|
+
* OpenData 的关联餐牌可能已更新,而 server_menu/server_schedule 仍命中本地持久化缓存。
|
|
276
|
+
* 仅在当前筛选没有任何生效餐牌时刷新一次,并由调用方重新计算筛选结果。
|
|
277
|
+
*/
|
|
278
|
+
private refreshMenuScheduleCacheAfterEmptyResult;
|
|
265
279
|
/**
|
|
266
280
|
* 按商品 id 查询单条(GET /shop/product/query/:productId)
|
|
267
281
|
* schedule_date 必填:query 或 data;schedule_datetime 可选。不走订阅。
|
package/lib/server/index.js
CHANGED
|
@@ -82,6 +82,10 @@ var Server = class {
|
|
|
82
82
|
this.productQuerySubscribers = /* @__PURE__ */ new Map();
|
|
83
83
|
/** subscriberId → 智能定价变价时间点定时器句柄(与 subscriber 分离存储,便于 clear) */
|
|
84
84
|
this.productQueryScheduleTimers = /* @__PURE__ */ new Map();
|
|
85
|
+
/** 餐牌筛选为空时才触发的菜单/日程缓存自愈,避免每次商品查询都请求远端。 */
|
|
86
|
+
this.menuScheduleRefreshInFlight = null;
|
|
87
|
+
this.lastMenuScheduleRefreshAt = 0;
|
|
88
|
+
this.MENU_SCHEDULE_REFRESH_COOLDOWN_MS = 30 * 1e3;
|
|
85
89
|
// ---- 订单 / 预约列表查询订阅者 ----
|
|
86
90
|
this.orderQuerySubscribers = /* @__PURE__ */ new Map();
|
|
87
91
|
this.bookingQuerySubscribers = /* @__PURE__ */ new Map();
|
|
@@ -215,7 +219,11 @@ var Server = class {
|
|
|
215
219
|
*/
|
|
216
220
|
this.handleProductQuery = async ({ url, method, data, config }) => {
|
|
217
221
|
console.log("[Server] handleProductQuery:", url, method, data, config);
|
|
218
|
-
const { menu_list_ids,
|
|
222
|
+
const { menu_list_ids, customer_id, ids, extension_type, strategy_context } = data;
|
|
223
|
+
const { schedule_date, schedule_datetime } = this.resolveProductQueryScheduleContext({
|
|
224
|
+
schedule_date: data.schedule_date,
|
|
225
|
+
schedule_datetime: data.schedule_datetime
|
|
226
|
+
});
|
|
219
227
|
const { callback, subscriberId } = config || {};
|
|
220
228
|
this.logInfo("handleProductQuery: 开始处理商品查询请求", {
|
|
221
229
|
menu_list_ids,
|
|
@@ -2211,15 +2219,12 @@ var Server = class {
|
|
|
2211
2219
|
return;
|
|
2212
2220
|
const scheduleDate = subscriber.context.schedule_date || (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
2213
2221
|
const timerIds = [];
|
|
2214
|
-
|
|
2215
|
-
const
|
|
2216
|
-
if (
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
}, delayMs);
|
|
2221
|
-
timerIds.push(timerId);
|
|
2222
|
-
}
|
|
2222
|
+
setInterval(() => {
|
|
2223
|
+
const currentTime = (0, import_dayjs.default)().format("hh:mm");
|
|
2224
|
+
if (timePoints.includes(currentTime)) {
|
|
2225
|
+
this.onScheduleTimePointTimerFire(subscriberId);
|
|
2226
|
+
}
|
|
2227
|
+
}, 6e4);
|
|
2223
2228
|
if (timerIds.length > 0) {
|
|
2224
2229
|
this.productQueryScheduleTimers.set(subscriberId, timerIds);
|
|
2225
2230
|
subscriber.scheduleTimerIds = timerIds;
|
|
@@ -2234,7 +2239,7 @@ var Server = class {
|
|
|
2234
2239
|
* schedule 变价时间点定时器触发:刷新 schedule_datetime 后重算并 callback。
|
|
2235
2240
|
*/
|
|
2236
2241
|
async onScheduleTimePointTimerFire(subscriberId, timerId) {
|
|
2237
|
-
this.removeScheduleTimerRef(subscriberId, timerId);
|
|
2242
|
+
timerId && this.removeScheduleTimerRef(subscriberId, timerId);
|
|
2238
2243
|
if (!this.productQuerySubscribers.has(subscriberId))
|
|
2239
2244
|
return;
|
|
2240
2245
|
const subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
@@ -2277,6 +2282,43 @@ var Server = class {
|
|
|
2277
2282
|
this.scheduleSubscriberTimePointReloads(subscriberId, timePoints);
|
|
2278
2283
|
}
|
|
2279
2284
|
}
|
|
2285
|
+
/**
|
|
2286
|
+
* ProductList callers such as standalone retail pages do not always have a selected schedule.
|
|
2287
|
+
* In that case query against the current local time so menu availability can still be evaluated.
|
|
2288
|
+
*/
|
|
2289
|
+
resolveProductQueryScheduleContext(params) {
|
|
2290
|
+
const now = (0, import_dayjs.default)();
|
|
2291
|
+
const schedule_datetime = typeof params.schedule_datetime === "string" && params.schedule_datetime.trim() ? params.schedule_datetime : now.format("YYYY-MM-DD HH:mm:ss");
|
|
2292
|
+
const schedule_date = typeof params.schedule_date === "string" && params.schedule_date.trim() ? params.schedule_date : (0, import_dayjs.default)(schedule_datetime).isValid() ? (0, import_dayjs.default)(schedule_datetime).format("YYYY-MM-DD") : now.format("YYYY-MM-DD");
|
|
2293
|
+
return { schedule_date, schedule_datetime };
|
|
2294
|
+
}
|
|
2295
|
+
/**
|
|
2296
|
+
* OpenData 的关联餐牌可能已更新,而 server_menu/server_schedule 仍命中本地持久化缓存。
|
|
2297
|
+
* 仅在当前筛选没有任何生效餐牌时刷新一次,并由调用方重新计算筛选结果。
|
|
2298
|
+
*/
|
|
2299
|
+
async refreshMenuScheduleCacheAfterEmptyResult() {
|
|
2300
|
+
if (!this.menu || !this.schedule)
|
|
2301
|
+
return false;
|
|
2302
|
+
const now = Date.now();
|
|
2303
|
+
if (now - this.lastMenuScheduleRefreshAt < this.MENU_SCHEDULE_REFRESH_COOLDOWN_MS) {
|
|
2304
|
+
return false;
|
|
2305
|
+
}
|
|
2306
|
+
if (!this.menuScheduleRefreshInFlight) {
|
|
2307
|
+
this.lastMenuScheduleRefreshAt = now;
|
|
2308
|
+
this.menuScheduleRefreshInFlight = Promise.all([
|
|
2309
|
+
this.menu.loadMenuList(),
|
|
2310
|
+
this.schedule.loadAllSchedule()
|
|
2311
|
+
]).then(() => void 0).catch((error) => {
|
|
2312
|
+
this.logWarning("刷新菜单/日程缓存失败,继续使用现有缓存", {
|
|
2313
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2314
|
+
});
|
|
2315
|
+
}).finally(() => {
|
|
2316
|
+
this.menuScheduleRefreshInFlight = null;
|
|
2317
|
+
});
|
|
2318
|
+
}
|
|
2319
|
+
await this.menuScheduleRefreshInFlight;
|
|
2320
|
+
return true;
|
|
2321
|
+
}
|
|
2280
2322
|
/**
|
|
2281
2323
|
* 执行 sales 搜索并登记可见订单号。
|
|
2282
2324
|
* 搜索参数完全透传后端,OS 不做过滤、筛选、排序。
|
|
@@ -3779,10 +3821,22 @@ var Server = class {
|
|
|
3779
3821
|
data: (normalized == null ? void 0 : normalized.data) ?? null
|
|
3780
3822
|
};
|
|
3781
3823
|
}
|
|
3782
|
-
|
|
3824
|
+
const response = this.withSyncedOrderIdInCheckoutResponse(
|
|
3783
3825
|
syncResult.normalizedResponse,
|
|
3784
3826
|
syncResult.syncedOrder
|
|
3785
3827
|
);
|
|
3828
|
+
const syncedOrder = syncResult.syncedOrder;
|
|
3829
|
+
if (syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData) && this.isSalesOrderFullyPaid(syncedOrder)) {
|
|
3830
|
+
await this.dispatchLocalReceiptPrint({
|
|
3831
|
+
checkoutData: syncResult.checkoutData,
|
|
3832
|
+
order: syncedOrder,
|
|
3833
|
+
response: syncResult.normalizedResponse,
|
|
3834
|
+
requireFullyPaid: true,
|
|
3835
|
+
// print_all 的 type=0 是收据打印;不要沿用同步成功后的券/手环打印 type=99。
|
|
3836
|
+
isManualPrint: true
|
|
3837
|
+
});
|
|
3838
|
+
}
|
|
3839
|
+
return response;
|
|
3786
3840
|
} catch (error) {
|
|
3787
3841
|
const backendError = this.extractBackendErrorResponse(error);
|
|
3788
3842
|
if (backendError) {
|
|
@@ -5072,13 +5126,16 @@ var Server = class {
|
|
|
5072
5126
|
let activeMenuList = [];
|
|
5073
5127
|
if (menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0) {
|
|
5074
5128
|
const tMenu = performance.now();
|
|
5075
|
-
const
|
|
5076
|
-
activeMenuList = menuList.filter((menu) => {
|
|
5129
|
+
const getActiveMenus = () => this.menu.getMenuByIds(menu_list_ids).filter((menu) => {
|
|
5077
5130
|
var _a;
|
|
5078
5131
|
return ((_a = this.schedule) == null ? void 0 : _a.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
5079
5132
|
});
|
|
5133
|
+
activeMenuList = getActiveMenus();
|
|
5134
|
+
if (!activeMenuList.length && await this.refreshMenuScheduleCacheAfterEmptyResult()) {
|
|
5135
|
+
activeMenuList = getActiveMenus();
|
|
5136
|
+
}
|
|
5080
5137
|
(0, import_product.perfMark)("computeQuery.filterActiveMenu", performance.now() - tMenu, {
|
|
5081
|
-
totalMenu:
|
|
5138
|
+
totalMenu: menu_list_ids.length,
|
|
5082
5139
|
activeMenu: activeMenuList.length
|
|
5083
5140
|
});
|
|
5084
5141
|
}
|
|
@@ -14,7 +14,7 @@ export { QuotationHooks } from './quotation/types';
|
|
|
14
14
|
export { ScheduleModuleEx } from './schedule';
|
|
15
15
|
export type { ScheduleState, ScheduleItem } from './schedule/types';
|
|
16
16
|
export { OrderModule } from './order';
|
|
17
|
-
export type { OrderState, OrderData, OrderId, OrderSummary, OrderBookingItem, OrderProductLineItem, OrderPaymentItem, OrderSurchargeItem, OrderProductDiscountItem, OrderWithoutBookings, BookingData, OrderFilters, BookingFilters, OrderFilterResult, OrderFilterRejectDetail, OrderFilterRejectedEntry, BookingFilterResult, OrderModulePagedResult,
|
|
17
|
+
export type { OrderState, OrderData, OrderId, OrderSummary, OrderBookingItem, OrderProductLineItem, OrderPaymentItem, OrderSurchargeItem, OrderProductDiscountItem, OrderWithoutBookings, BookingData, OrderFilters, BookingFilters, OrderFilterResult, OrderFilterRejectDetail, OrderFilterRejectedEntry, BookingFilterResult, OrderModulePagedResult, } from './order/types';
|
|
18
18
|
export { OrderHooks } from './order/types';
|
|
19
19
|
export { PaymentServerModule } from './payment';
|
|
20
20
|
export type { PaymentMethod, PaymentMethodsChangedEventData, PaymentServerState } from './payment/types';
|
|
@@ -30,10 +30,6 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
30
30
|
* await this.emitOrdersChanged([freshOrder], 'pubsub.bodyUpsert')
|
|
31
31
|
*/
|
|
32
32
|
private emitOrdersChanged;
|
|
33
|
-
/**
|
|
34
|
-
* 广播远端商品成员增删。监听器异常必须与订单落库和原有订单广播隔离。
|
|
35
|
-
*/
|
|
36
|
-
private emitRemoteProductMembershipChanges;
|
|
37
33
|
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
38
34
|
/**
|
|
39
35
|
* 记录信息日志
|
|
@@ -235,18 +231,6 @@ export declare class OrderModule extends BaseModule implements Module {
|
|
|
235
231
|
*/
|
|
236
232
|
private lookupOrderIndexByIdentityKeys;
|
|
237
233
|
private isRemoteEchoMergeSource;
|
|
238
|
-
private getProductMembershipKey;
|
|
239
|
-
private doProductsHaveStableMembershipIdentity;
|
|
240
|
-
/**
|
|
241
|
-
* 冲突提示关注逻辑商品行,而不是服务端 checkout 过程中可能被重建的 detail 记录。
|
|
242
|
-
* 通用集合合并仍以 order_detail_id 为事实主键;这里只允许相同稳定 UID 跨 detail id 对齐,
|
|
243
|
-
* 避免本机 checkout 回声被误判成“一删一增”。
|
|
244
|
-
*/
|
|
245
|
-
private isSameProductMembershipItem;
|
|
246
|
-
/**
|
|
247
|
-
* 对比合并前后的商品成员集合。商品字段修改与数组重排不会产生 diff。
|
|
248
|
-
*/
|
|
249
|
-
private getRemoteProductMembershipChange;
|
|
250
234
|
/**
|
|
251
235
|
* 将订单的全部身份键登记到索引并指向其在列表中的下标。
|
|
252
236
|
* 合并后订单新增的身份字段(如挂单同步后拿到 order_id)也会被登记。
|
|
@@ -89,24 +89,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
89
89
|
};
|
|
90
90
|
await this.core.effects.emit(import_types.OrderHooks.onOrdersChanged, payload);
|
|
91
91
|
}
|
|
92
|
-
/**
|
|
93
|
-
* 广播远端商品成员增删。监听器异常必须与订单落库和原有订单广播隔离。
|
|
94
|
-
*/
|
|
95
|
-
async emitRemoteProductMembershipChanges(changes) {
|
|
96
|
-
for (const payload of changes) {
|
|
97
|
-
try {
|
|
98
|
-
await this.core.effects.emit(import_types.OrderHooks.onRemoteProductMembershipChanged, payload);
|
|
99
|
-
} catch (error) {
|
|
100
|
-
this.logError("广播远端订单商品成员变更失败", {
|
|
101
|
-
order_id: payload.order_id,
|
|
102
|
-
source: payload.source,
|
|
103
|
-
added_product_count: payload.added_product_keys.length,
|
|
104
|
-
removed_product_count: payload.removed_product_keys.length,
|
|
105
|
-
error: error instanceof Error ? error.message : String(error)
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
92
|
async initialize(core, options) {
|
|
111
93
|
var _a;
|
|
112
94
|
this.core = core;
|
|
@@ -332,7 +314,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
332
314
|
* @example
|
|
333
315
|
* const { toWrite, skipped } = this.filterRedundantPatchOrders('pubsub.bodyUpsert', orders, mergeActions)
|
|
334
316
|
*/
|
|
335
|
-
filterRedundantPatchOrders(source, orders, mergeActions
|
|
317
|
+
filterRedundantPatchOrders(source, orders, mergeActions) {
|
|
336
318
|
const eligibleSkipSources = /* @__PURE__ */ new Set(["pubsub.bodyUpsert", "pubsub.httpRefresh"]);
|
|
337
319
|
if (!eligibleSkipSources.has(source)) {
|
|
338
320
|
return { toWrite: orders, skipped: [] };
|
|
@@ -352,10 +334,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
352
334
|
toWrite.push(order);
|
|
353
335
|
continue;
|
|
354
336
|
}
|
|
355
|
-
if (forceWriteStorageKeys.has(storageKey)) {
|
|
356
|
-
toWrite.push(order);
|
|
357
|
-
continue;
|
|
358
|
-
}
|
|
359
337
|
const recent = this.recentSqliteWriteByStorageKey.get(storageKey);
|
|
360
338
|
if (recent && ORDER_BUSINESS_WRITE_SOURCES.has(recent.source) && now - recent.ts < ORDER_SQLITE_DEDUPE_MS) {
|
|
361
339
|
skipped.push({
|
|
@@ -1506,20 +1484,10 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1506
1484
|
});
|
|
1507
1485
|
this.logDuplicateOrders(`${source}.beforeMerge`, this.store.list);
|
|
1508
1486
|
const normalizedFreshOrders = [];
|
|
1509
|
-
const incomingProductsHaveStableIdentity = /* @__PURE__ */ new Map();
|
|
1510
1487
|
for (const order of freshOrders) {
|
|
1511
1488
|
const id = order == null ? void 0 : order.order_id;
|
|
1512
1489
|
if (id === void 0 || id === null)
|
|
1513
1490
|
continue;
|
|
1514
|
-
const rawProducts = order.products;
|
|
1515
|
-
if (Array.isArray(rawProducts)) {
|
|
1516
|
-
const allProductsHaveStableIdentity = this.doProductsHaveStableMembershipIdentity(rawProducts);
|
|
1517
|
-
const orderIdKey = this.getIdKey(id);
|
|
1518
|
-
incomingProductsHaveStableIdentity.set(
|
|
1519
|
-
orderIdKey,
|
|
1520
|
-
(incomingProductsHaveStableIdentity.get(orderIdKey) ?? true) && allProductsHaveStableIdentity
|
|
1521
|
-
);
|
|
1522
|
-
}
|
|
1523
1491
|
normalizedFreshOrders.push(this.normalizeRemoteSyncedOrder(order));
|
|
1524
1492
|
}
|
|
1525
1493
|
const uniqueFreshOrders = this.compactOrderListByIdentity(
|
|
@@ -1528,14 +1496,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1528
1496
|
).list;
|
|
1529
1497
|
const uniqueFreshCount = uniqueFreshOrders.length;
|
|
1530
1498
|
const patchedOrders = [];
|
|
1531
|
-
const remoteProductMembershipChanges = [];
|
|
1532
|
-
const forceWriteStorageKeys = /* @__PURE__ */ new Set();
|
|
1533
1499
|
const mergeActions = {};
|
|
1534
|
-
const existingProductsHaveStableIdentity = this.store.list.map(
|
|
1535
|
-
(order) => this.doProductsHaveStableMembershipIdentity(
|
|
1536
|
-
order.products
|
|
1537
|
-
)
|
|
1538
|
-
);
|
|
1539
1500
|
const updatedList = this.store.list.map(
|
|
1540
1501
|
(order) => this.normalizeOrderForMemoryList(order, `${source}.existingMemory`)
|
|
1541
1502
|
);
|
|
@@ -1579,17 +1540,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1579
1540
|
continue;
|
|
1580
1541
|
}
|
|
1581
1542
|
let mergedOrder = this.mergeOrderRecords(existingOrder, fresh);
|
|
1582
|
-
const freshOrderId = fresh.order_id;
|
|
1583
|
-
const incomingProductsAreStable = freshOrderId !== void 0 && freshOrderId !== null && incomingProductsHaveStableIdentity.get(this.getIdKey(freshOrderId)) !== false;
|
|
1584
|
-
let membershipChange = null;
|
|
1585
|
-
if (Array.isArray(fresh.products) && freshOrderId !== void 0 && freshOrderId !== null && existingProductsHaveStableIdentity[matchIndex] !== false && incomingProductsAreStable) {
|
|
1586
|
-
membershipChange = this.getRemoteProductMembershipChange(
|
|
1587
|
-
existingOrder,
|
|
1588
|
-
mergedOrder,
|
|
1589
|
-
source
|
|
1590
|
-
);
|
|
1591
|
-
}
|
|
1592
|
-
let mergedProductsHaveStableIdentity = existingProductsHaveStableIdentity[matchIndex] !== false && incomingProductsAreStable;
|
|
1593
1543
|
let adjustedMatchIndex = matchIndex;
|
|
1594
1544
|
const duplicateIndexes = /* @__PURE__ */ new Set();
|
|
1595
1545
|
for (const key of freshIdentityKeys) {
|
|
@@ -1601,9 +1551,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1601
1551
|
if (duplicateIndexes.size > 0) {
|
|
1602
1552
|
for (const duplicateIndex of [...duplicateIndexes].sort((left, right) => right - left)) {
|
|
1603
1553
|
mergedOrder = this.mergeOrderRecords(mergedOrder, updatedList[duplicateIndex]);
|
|
1604
|
-
mergedProductsHaveStableIdentity = mergedProductsHaveStableIdentity && existingProductsHaveStableIdentity[duplicateIndex] !== false;
|
|
1605
1554
|
updatedList.splice(duplicateIndex, 1);
|
|
1606
|
-
existingProductsHaveStableIdentity.splice(duplicateIndex, 1);
|
|
1607
1555
|
if (duplicateIndex < adjustedMatchIndex)
|
|
1608
1556
|
adjustedMatchIndex -= 1;
|
|
1609
1557
|
}
|
|
@@ -1616,13 +1564,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1616
1564
|
}
|
|
1617
1565
|
}
|
|
1618
1566
|
updatedList[adjustedMatchIndex] = mergedOrder;
|
|
1619
|
-
existingProductsHaveStableIdentity[adjustedMatchIndex] = mergedProductsHaveStableIdentity;
|
|
1620
|
-
if (membershipChange) {
|
|
1621
|
-
remoteProductMembershipChanges.push(membershipChange);
|
|
1622
|
-
const mergedStorageKey = this.getOrderStorageKey(mergedOrder);
|
|
1623
|
-
if (mergedStorageKey)
|
|
1624
|
-
forceWriteStorageKeys.add(mergedStorageKey);
|
|
1625
|
-
}
|
|
1626
1567
|
this.registerOrderIdentityKeys(identityKeyToIndex, mergedOrder, adjustedMatchIndex);
|
|
1627
1568
|
patchedOrders.push(mergedOrder);
|
|
1628
1569
|
if (mergeKey)
|
|
@@ -1631,9 +1572,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1631
1572
|
}
|
|
1632
1573
|
const insertIndex = updatedList.length;
|
|
1633
1574
|
updatedList.push(fresh);
|
|
1634
|
-
existingProductsHaveStableIdentity.push(
|
|
1635
|
-
fresh.order_id !== void 0 && fresh.order_id !== null && incomingProductsHaveStableIdentity.get(this.getIdKey(fresh.order_id)) !== false
|
|
1636
|
-
);
|
|
1637
1575
|
this.registerOrderIdentityKeys(identityKeyToIndex, fresh, insertIndex);
|
|
1638
1576
|
patchedOrders.push(fresh);
|
|
1639
1577
|
if (mergeKey)
|
|
@@ -1648,20 +1586,13 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1648
1586
|
});
|
|
1649
1587
|
this.store.list = this.runOrderStoreSelfCheck(updatedList, `${source}.store`);
|
|
1650
1588
|
this.syncOrdersMap();
|
|
1651
|
-
await this.patchOrdersInSQLite(
|
|
1652
|
-
patchedOrders,
|
|
1653
|
-
source,
|
|
1654
|
-
mergeActions,
|
|
1655
|
-
{},
|
|
1656
|
-
forceWriteStorageKeys
|
|
1657
|
-
);
|
|
1589
|
+
await this.patchOrdersInSQLite(patchedOrders, source, mergeActions);
|
|
1658
1590
|
this.logInfo("mergeOrdersToStore-结束", {
|
|
1659
1591
|
uniqueFreshCount,
|
|
1660
1592
|
storeOrderCountAfter: this.store.list.length,
|
|
1661
1593
|
insertCount,
|
|
1662
1594
|
updateCount
|
|
1663
1595
|
});
|
|
1664
|
-
await this.emitRemoteProductMembershipChanges(remoteProductMembershipChanges);
|
|
1665
1596
|
await this.emitOrdersChanged(patchedOrders, source);
|
|
1666
1597
|
}
|
|
1667
1598
|
/**
|
|
@@ -1685,72 +1616,6 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1685
1616
|
isRemoteEchoMergeSource(source) {
|
|
1686
1617
|
return source === "pubsub.bodyUpsert" || source === "pubsub.httpRefresh";
|
|
1687
1618
|
}
|
|
1688
|
-
getProductMembershipKey(product) {
|
|
1689
|
-
const persistentId = (0, import_orderCollectionIdentity.getOrderCollectionPersistentId)("product", product);
|
|
1690
|
-
if (persistentId)
|
|
1691
|
-
return `order_detail_id:${persistentId}`;
|
|
1692
|
-
const uid = (0, import_orderCollectionIdentity.getOrderCollectionUid)("product", product);
|
|
1693
|
-
return uid ? `unique_identification_number:${uid}` : "";
|
|
1694
|
-
}
|
|
1695
|
-
doProductsHaveStableMembershipIdentity(products) {
|
|
1696
|
-
if (!Array.isArray(products))
|
|
1697
|
-
return true;
|
|
1698
|
-
return products.every(
|
|
1699
|
-
(product) => Boolean(
|
|
1700
|
-
(0, import_orderCollectionIdentity.getOrderCollectionPersistentId)("product", product) || (0, import_orderCollectionIdentity.getOrderCollectionUid)("product", product)
|
|
1701
|
-
)
|
|
1702
|
-
);
|
|
1703
|
-
}
|
|
1704
|
-
/**
|
|
1705
|
-
* 冲突提示关注逻辑商品行,而不是服务端 checkout 过程中可能被重建的 detail 记录。
|
|
1706
|
-
* 通用集合合并仍以 order_detail_id 为事实主键;这里只允许相同稳定 UID 跨 detail id 对齐,
|
|
1707
|
-
* 避免本机 checkout 回声被误判成“一删一增”。
|
|
1708
|
-
*/
|
|
1709
|
-
isSameProductMembershipItem(left, right) {
|
|
1710
|
-
if ((0, import_orderCollectionIdentity.isSameOrderCollectionItem)("product", left, right))
|
|
1711
|
-
return true;
|
|
1712
|
-
const leftUid = (0, import_orderCollectionIdentity.getOrderCollectionUid)("product", left);
|
|
1713
|
-
const rightUid = (0, import_orderCollectionIdentity.getOrderCollectionUid)("product", right);
|
|
1714
|
-
return Boolean(leftUid && rightUid && leftUid === rightUid);
|
|
1715
|
-
}
|
|
1716
|
-
/**
|
|
1717
|
-
* 对比合并前后的商品成员集合。商品字段修改与数组重排不会产生 diff。
|
|
1718
|
-
*/
|
|
1719
|
-
getRemoteProductMembershipChange(existingOrder, mergedOrder, source) {
|
|
1720
|
-
if (!this.isRemoteEchoMergeSource(source))
|
|
1721
|
-
return null;
|
|
1722
|
-
const previousProducts = Array.isArray(existingOrder.products) ? existingOrder.products : [];
|
|
1723
|
-
const currentProducts = Array.isArray(mergedOrder.products) ? mergedOrder.products : [];
|
|
1724
|
-
const unmatchedCurrentIndexes = new Set(currentProducts.map((_, index) => index));
|
|
1725
|
-
const removedProductKeys = [];
|
|
1726
|
-
for (const previousProduct of previousProducts) {
|
|
1727
|
-
const matchedIndex = currentProducts.findIndex(
|
|
1728
|
-
(currentProduct, index) => unmatchedCurrentIndexes.has(index) && this.isSameProductMembershipItem(previousProduct, currentProduct)
|
|
1729
|
-
);
|
|
1730
|
-
if (matchedIndex >= 0) {
|
|
1731
|
-
unmatchedCurrentIndexes.delete(matchedIndex);
|
|
1732
|
-
continue;
|
|
1733
|
-
}
|
|
1734
|
-
const productKey = this.getProductMembershipKey(previousProduct);
|
|
1735
|
-
if (productKey)
|
|
1736
|
-
removedProductKeys.push(productKey);
|
|
1737
|
-
}
|
|
1738
|
-
const addedProductKeys = [...unmatchedCurrentIndexes].map((index) => this.getProductMembershipKey(currentProducts[index])).filter(Boolean);
|
|
1739
|
-
if (addedProductKeys.length === 0 && removedProductKeys.length === 0) {
|
|
1740
|
-
return null;
|
|
1741
|
-
}
|
|
1742
|
-
const orderId = mergedOrder.order_id ?? existingOrder.order_id;
|
|
1743
|
-
if (orderId === void 0 || orderId === null)
|
|
1744
|
-
return null;
|
|
1745
|
-
return {
|
|
1746
|
-
order_id: orderId,
|
|
1747
|
-
source,
|
|
1748
|
-
added_product_keys: addedProductKeys,
|
|
1749
|
-
removed_product_keys: removedProductKeys,
|
|
1750
|
-
previous_product_count: previousProducts.length,
|
|
1751
|
-
current_product_count: currentProducts.length
|
|
1752
|
-
};
|
|
1753
|
-
}
|
|
1754
1619
|
/**
|
|
1755
1620
|
* 将订单的全部身份键登记到索引并指向其在列表中的下标。
|
|
1756
1621
|
* 合并后订单新增的身份字段(如挂单同步后拿到 order_id)也会被登记。
|
|
@@ -2275,7 +2140,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2275
2140
|
* @example
|
|
2276
2141
|
* await this.patchOrdersInSQLite(freshOrders)
|
|
2277
2142
|
*/
|
|
2278
|
-
async patchOrdersInSQLite(orders, source, mergeActions = {}, options = {}
|
|
2143
|
+
async patchOrdersInSQLite(orders, source, mergeActions = {}, options = {}) {
|
|
2279
2144
|
if (orders.length === 0) {
|
|
2280
2145
|
return;
|
|
2281
2146
|
}
|
|
@@ -2291,8 +2156,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2291
2156
|
const { toWrite, skipped } = this.filterRedundantPatchOrders(
|
|
2292
2157
|
source,
|
|
2293
2158
|
ordersSnapshot,
|
|
2294
|
-
mergeActions
|
|
2295
|
-
forceWriteStorageKeys
|
|
2159
|
+
mergeActions
|
|
2296
2160
|
);
|
|
2297
2161
|
if (toWrite.length === 0) {
|
|
2298
2162
|
return;
|
|
@@ -568,19 +568,6 @@ export interface OrderChangedPayload {
|
|
|
568
568
|
/** 触发来源,便于订阅者区分 pubsub / 远端覆盖 / 清空等场景 */
|
|
569
569
|
source?: string;
|
|
570
570
|
}
|
|
571
|
-
export type RemoteProductMembershipChangeSource = 'pubsub.bodyUpsert' | 'pubsub.httpRefresh';
|
|
572
|
-
/**
|
|
573
|
-
* 远端订单快照相对本地订单产生商品成员增删时的广播载荷。
|
|
574
|
-
* 只表达商品行成员关系变化,不包含数量、价格、备注等字段级修改。
|
|
575
|
-
*/
|
|
576
|
-
export interface RemoteProductMembershipChangedPayload {
|
|
577
|
-
order_id: OrderId;
|
|
578
|
-
source: RemoteProductMembershipChangeSource;
|
|
579
|
-
added_product_keys: string[];
|
|
580
|
-
removed_product_keys: string[];
|
|
581
|
-
previous_product_count: number;
|
|
582
|
-
current_product_count: number;
|
|
583
|
-
}
|
|
584
571
|
/**
|
|
585
572
|
* OrderSyncMessage - pubsub 同步消息结构
|
|
586
573
|
*/
|
|
@@ -618,6 +605,5 @@ export interface OrderState {
|
|
|
618
605
|
export declare enum OrderHooks {
|
|
619
606
|
onOrdersLoaded = "order:onOrdersLoaded",
|
|
620
607
|
onOrdersChanged = "order:onOrdersChanged",
|
|
621
|
-
onRemoteProductMembershipChanged = "order:onRemoteProductMembershipChanged",
|
|
622
608
|
onOrdersSyncCompleted = "order:onOrdersSyncCompleted"
|
|
623
609
|
}
|
|
@@ -25,7 +25,6 @@ module.exports = __toCommonJS(types_exports);
|
|
|
25
25
|
var OrderHooks = /* @__PURE__ */ ((OrderHooks2) => {
|
|
26
26
|
OrderHooks2["onOrdersLoaded"] = "order:onOrdersLoaded";
|
|
27
27
|
OrderHooks2["onOrdersChanged"] = "order:onOrdersChanged";
|
|
28
|
-
OrderHooks2["onRemoteProductMembershipChanged"] = "order:onRemoteProductMembershipChanged";
|
|
29
28
|
OrderHooks2["onOrdersSyncCompleted"] = "order:onOrdersSyncCompleted";
|
|
30
29
|
return OrderHooks2;
|
|
31
30
|
})(OrderHooks || {});
|
|
@@ -9,7 +9,7 @@ import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
|
9
9
|
export * from './types';
|
|
10
10
|
import { ProductList } from '../../modules/ProductList';
|
|
11
11
|
import { PaymentModule } from '../../modules/Payment';
|
|
12
|
-
import type { PaymentMethod, RoundingResult, WalletAssetId,
|
|
12
|
+
import type { PaymentMethod, RoundingResult, WalletAssetId, WalletAssetsSnapshot, WalletAssetsState, WalletAssetSelectionSource, ScanWalletAssetResult } from '../../modules/Payment/types';
|
|
13
13
|
import type { SalesSummaryModule } from '../../modules/SalesSummary';
|
|
14
14
|
import type { ScheduleModule } from '../../modules/Schedule';
|
|
15
15
|
import { QuotationModule } from '../../modules/Quotation';
|
|
@@ -280,6 +280,13 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
280
280
|
confirmPendingVoucherPayments?: boolean;
|
|
281
281
|
enhancePayload?: SubmitPayloadEnhancer;
|
|
282
282
|
}): Promise<T>;
|
|
283
|
+
/**
|
|
284
|
+
* 默认保持 WebPOS 的本地待同步订单模式;需要云端确认后才算成功的渠道可覆盖此策略。
|
|
285
|
+
* otherParams.checkoutSyncTaskEnabled 优先,便于同一 solution 按入口恢复旧行为。
|
|
286
|
+
*/
|
|
287
|
+
protected shouldUseCheckoutSyncTask(): boolean;
|
|
288
|
+
/** 可由特定 solution 为真实 checkout 补充默认收据数据请求。 */
|
|
289
|
+
protected getDefaultCheckoutSmallTicketDataFlag(): number | undefined;
|
|
283
290
|
printLocalOrderReceipt<T = any>(lookup?: BaseSalesPrintLocalOrderReceiptParams): Promise<T>;
|
|
284
291
|
private getSubmitPaymentStatus;
|
|
285
292
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
@@ -326,8 +333,6 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
326
333
|
getWalletAssetsState(): WalletAssetsState;
|
|
327
334
|
/** 导出 Shared Checkout 跨运行时恢复所需的钱包状态与搜索缓存。 */
|
|
328
335
|
exportWalletAssetsSnapshot(): WalletAssetsSnapshot;
|
|
329
|
-
/** 配置仅影响 Wallet Assets,不改变 Promotion/Voucher 选择流程。 */
|
|
330
|
-
configureWalletAssetsBehavior(options: WalletAssetsBehaviorOptions): void;
|
|
331
336
|
/**
|
|
332
337
|
* 恢复 Shared Checkout 钱包快照,并把选择重新同步为订单 pending payment。
|
|
333
338
|
*/
|
|
@@ -1008,7 +1008,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1008
1008
|
return isChanged;
|
|
1009
1009
|
}
|
|
1010
1010
|
async initialize(core, options = {}) {
|
|
1011
|
-
var _a, _b;
|
|
1011
|
+
var _a, _b, _c, _d;
|
|
1012
1012
|
this.core = core;
|
|
1013
1013
|
this.initializeOptions = options || {};
|
|
1014
1014
|
this.paymentNumberDevicePrefix = null;
|
|
@@ -1019,10 +1019,9 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1019
1019
|
this.request = core.getPlugin("request");
|
|
1020
1020
|
this.appPlugin = core.getPlugin("app");
|
|
1021
1021
|
if (!this.appPlugin) {
|
|
1022
|
-
throw new Error("Checkout 解决方案需要 app 插件支持");
|
|
1023
1022
|
}
|
|
1024
|
-
const app = this.appPlugin.getApp();
|
|
1025
|
-
this.logger = app.logger;
|
|
1023
|
+
const app = (_c = (_b = this.appPlugin) == null ? void 0 : _b.getApp) == null ? void 0 : _c.call(_b);
|
|
1024
|
+
this.logger = app == null ? void 0 : app.logger;
|
|
1026
1025
|
const targetCacheData = this.readSessionCacheData();
|
|
1027
1026
|
const moduleNames = this.getRegisteredModuleNames();
|
|
1028
1027
|
moduleNames.forEach((step) => {
|
|
@@ -1047,7 +1046,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1047
1046
|
if (this.store.schedule && !this.isScheduleListLoaded(this.store.schedule)) {
|
|
1048
1047
|
await this.store.schedule.loadAllSchedule();
|
|
1049
1048
|
}
|
|
1050
|
-
if (this.store.order && typeof ((
|
|
1049
|
+
if (this.store.order && typeof ((_d = this.otherParams) == null ? void 0 : _d.enableTempOrderPersist) === "boolean") {
|
|
1051
1050
|
this.store.order.setEnableTempOrderPersist(
|
|
1052
1051
|
this.otherParams.enableTempOrderPersist
|
|
1053
1052
|
);
|
|
@@ -1901,6 +1900,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1901
1900
|
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
1902
1901
|
}
|
|
1903
1902
|
const inferredPaymentStatus = this.getSubmitPaymentStatus(params == null ? void 0 : params.paymentStatus);
|
|
1903
|
+
const smallTicketDataFlag = (params == null ? void 0 : params.smallTicketDataFlag) ?? this.getDefaultCheckoutSmallTicketDataFlag();
|
|
1904
1904
|
const submitParams = {
|
|
1905
1905
|
cacheId: this.cacheId,
|
|
1906
1906
|
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
@@ -1910,11 +1910,11 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1910
1910
|
request_unique_idempotency_token: this.store.order.generateIdempotencyToken(),
|
|
1911
1911
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1912
1912
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1913
|
-
...
|
|
1913
|
+
...smallTicketDataFlag !== void 0 ? { smallTicketDataFlag } : {},
|
|
1914
1914
|
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1915
1915
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1916
1916
|
};
|
|
1917
|
-
return this.store.order.submitTempOrder(submitParams);
|
|
1917
|
+
return this.shouldUseCheckoutSyncTask() ? this.store.order.submitTempOrder(submitParams) : this.store.order.submitTempOrderAsync(submitParams);
|
|
1918
1918
|
}
|
|
1919
1919
|
async saveSalesOrderDraft(params) {
|
|
1920
1920
|
var _a, _b, _c, _d;
|
|
@@ -1936,20 +1936,35 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1936
1936
|
throw new Error("BaseSales 解决方案需要 order 模块支持");
|
|
1937
1937
|
}
|
|
1938
1938
|
const inferredPaymentStatus = this.getSubmitPaymentStatus(params == null ? void 0 : params.paymentStatus);
|
|
1939
|
+
const smallTicketDataFlag = (params == null ? void 0 : params.smallTicketDataFlag) ?? this.getDefaultCheckoutSmallTicketDataFlag();
|
|
1939
1940
|
const submitParams = {
|
|
1940
1941
|
cacheId: this.cacheId,
|
|
1941
1942
|
platform: (_a = this.otherParams) == null ? void 0 : _a.platform,
|
|
1942
1943
|
businessCode: ((_b = this.otherParams) == null ? void 0 : _b.businessCode) || ((_c = this.otherParams) == null ? void 0 : _c.business_code),
|
|
1943
1944
|
channel: this.getSubmitOrderSalesChannel(),
|
|
1944
1945
|
type: (_d = this.otherParams) == null ? void 0 : _d.type,
|
|
1946
|
+
request_unique_idempotency_token: this.store.order.generateIdempotencyToken(),
|
|
1945
1947
|
...(params == null ? void 0 : params.payments) !== void 0 ? { payments: params.payments } : {},
|
|
1946
1948
|
...inferredPaymentStatus !== void 0 ? { paymentStatus: inferredPaymentStatus } : {},
|
|
1947
|
-
...
|
|
1949
|
+
...smallTicketDataFlag !== void 0 ? { smallTicketDataFlag } : {},
|
|
1948
1950
|
...(params == null ? void 0 : params.confirmPendingVoucherPayments) !== void 0 ? { confirmPendingVoucherPayments: params.confirmPendingVoucherPayments } : {},
|
|
1949
1951
|
...(params == null ? void 0 : params.enhancePayload) !== void 0 ? { enhancePayload: params.enhancePayload } : {}
|
|
1950
1952
|
};
|
|
1951
1953
|
return this.store.order.submitTempOrderAsync(submitParams);
|
|
1952
1954
|
}
|
|
1955
|
+
/**
|
|
1956
|
+
* 默认保持 WebPOS 的本地待同步订单模式;需要云端确认后才算成功的渠道可覆盖此策略。
|
|
1957
|
+
* otherParams.checkoutSyncTaskEnabled 优先,便于同一 solution 按入口恢复旧行为。
|
|
1958
|
+
*/
|
|
1959
|
+
shouldUseCheckoutSyncTask() {
|
|
1960
|
+
var _a;
|
|
1961
|
+
const configured = (_a = this.otherParams) == null ? void 0 : _a.checkoutSyncTaskEnabled;
|
|
1962
|
+
return typeof configured === "boolean" ? configured : true;
|
|
1963
|
+
}
|
|
1964
|
+
/** 可由特定 solution 为真实 checkout 补充默认收据数据请求。 */
|
|
1965
|
+
getDefaultCheckoutSmallTicketDataFlag() {
|
|
1966
|
+
return void 0;
|
|
1967
|
+
}
|
|
1953
1968
|
async printLocalOrderReceipt(lookup) {
|
|
1954
1969
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1955
1970
|
if (!this.store.order) {
|
|
@@ -2009,6 +2024,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2009
2024
|
const channel = params.channel ?? this.getSubmitOrderSalesChannel();
|
|
2010
2025
|
const syncParams = {
|
|
2011
2026
|
...params,
|
|
2027
|
+
checkoutSyncTaskEnabled: this.shouldUseCheckoutSyncTask(),
|
|
2012
2028
|
...businessCode !== void 0 ? { businessCode } : {},
|
|
2013
2029
|
...channel !== void 0 ? { channel } : {}
|
|
2014
2030
|
};
|
|
@@ -2535,12 +2551,6 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
2535
2551
|
throw new Error("payment 模块未初始化");
|
|
2536
2552
|
return this.store.payment.wallet.exportWalletAssetsSnapshot();
|
|
2537
2553
|
}
|
|
2538
|
-
/** 配置仅影响 Wallet Assets,不改变 Promotion/Voucher 选择流程。 */
|
|
2539
|
-
configureWalletAssetsBehavior(options) {
|
|
2540
|
-
if (!this.store.payment)
|
|
2541
|
-
throw new Error("payment 模块未初始化");
|
|
2542
|
-
this.store.payment.wallet.configureWalletAssetsBehavior(options);
|
|
2543
|
-
}
|
|
2544
2554
|
/**
|
|
2545
2555
|
* 恢复 Shared Checkout 钱包快照,并把选择重新同步为订单 pending payment。
|
|
2546
2556
|
*/
|